23b8b7ccc4940449488e4c33bbf2f69ae3efbe88
[rrq/maintain_lilo.git] / src / partition.h
1 /* partition.h  -  Partition table handling */
2
3 /*
4 Copyright 1992-1998 Werner Almesberger.
5 Copyright 1999-2004 John Coffman.
6 All rights reserved.
7
8 Licensed under the terms contained in the file 'COPYING' in the 
9 source directory.
10
11 */
12
13
14 #ifndef PARTITION_H
15 #define PARTITION_H
16
17 #include <unistd.h>
18 #include <linux/unistd.h>
19
20 typedef struct _change_rule {
21     const char *type;
22     unsigned char normal;
23     unsigned char hidden;
24     struct _change_rule *next;
25 } CHANGE_RULE;
26
27 enum {PTW_OKAY=0, PTW_DOS=1, PTW_OS2=2, PTW_SWAP, PTW_XFS,
28                 PTW_mask=7, PTW_NTFS=8};
29
30
31 #define LLSECTORSIZE ((long long)SECTOR_SIZE)
32
33 #if __GLIBC__ < 2 || __GLIBC_MINOR__ < 1
34 typedef long long lloff_t;
35
36 #ifdef _syscall5
37        lloff_t lseek64(unsigned int fd, lloff_t offs, unsigned int whence);
38 #endif
39 #endif
40
41 struct partition {
42         unsigned char boot_ind;         /* 0x80 - active */
43         unsigned char head;             /* starting head */
44         unsigned char sector;           /* starting sector */
45         unsigned char cyl;              /* starting cylinder */
46         unsigned char sys_ind;          /* What partition type */
47         unsigned char end_head;         /* end head */
48         unsigned char end_sector;       /* end sector */
49         unsigned char end_cyl;          /* end cylinder */
50         unsigned int start_sect;        /* starting sector counting from 0 */
51         unsigned int nr_sects;          /* nr of sectors in partition */
52 };
53
54
55 int part_nowrite(char* device);
56 /* identify partitions which would be destroyed if the boot block
57    is overwritten:
58    
59    known problems occur for:
60         XFS
61         NTFS
62         DOS FAT (relocation will fix)
63 */
64
65 #define is_extd_part(x) ((x)==PART_DOS_EXTD||(x)==PART_WIN_EXTD_LBA||(x)==PART_LINUX_EXTD)
66
67 void part_verify(int dev_nr,int type);
68 /* Verify the partition table of the disk of which dev_nr is a partition. May
69    also try to "fix" a partition table. Fail on non-Linux partitions if the
70    TYPE flag is non-zero (unless IGNORE-TABLE is set too). */
71
72 void do_cr_auto(void);
73 /* do automatic change-rules */
74
75 void preload_types(void);
76 /* Preload some partition types for convenience */
77
78 void do_activate(char *where, char *which);
79 /* Activate the specified partition */
80
81 void do_install_mbr(char *where, char *what);
82 /* Install a new MBR (Master Boot Record) */
83
84 int read_partitions(char *part, int max, int *volid,
85                 struct partition *p, long long *where);
86 /* read all partitions & partition tables */
87
88 #endif