Update to upstream util-linux 2.20.1
[framework/base/util-linux-ng.git] / fdisk / fdisk.h
1 /*
2    fdisk.h
3 */
4
5 #include "c.h"
6
7 #define DEFAULT_SECTOR_SIZE     512
8 #define MAX_SECTOR_SIZE 2048
9 #define SECTOR_SIZE     512     /* still used in BSD code */
10 #define MAXIMUM_PARTS   60
11
12 #define ACTIVE_FLAG     0x80
13
14 #define EXTENDED        0x05
15 #define WIN98_EXTENDED  0x0f
16 #define LINUX_PARTITION 0x81
17 #define LINUX_SWAP      0x82
18 #define LINUX_NATIVE    0x83
19 #define LINUX_EXTENDED  0x85
20 #define LINUX_LVM       0x8e
21 #define LINUX_RAID      0xfd
22
23 #define IS_EXTENDED(i) \
24         ((i) == EXTENDED || (i) == WIN98_EXTENDED || (i) == LINUX_EXTENDED)
25
26 #define cround(n)       (display_in_cyl_units ? ((n)/units_per_sector)+1 : (n))
27 #define scround(x)      (((x)+units_per_sector-1)/units_per_sector)
28
29 #if defined(__GNUC__) && (defined(__arm__) || defined(__alpha__))
30 # define PACKED __attribute__ ((packed))
31 #else
32 # define PACKED
33 #endif
34
35 struct partition {
36         unsigned char boot_ind;         /* 0x80 - active */
37         unsigned char head;             /* starting head */
38         unsigned char sector;           /* starting sector */
39         unsigned char cyl;              /* starting cylinder */
40         unsigned char sys_ind;          /* What partition type */
41         unsigned char end_head;         /* end head */
42         unsigned char end_sector;       /* end sector */
43         unsigned char end_cyl;          /* end cylinder */
44         unsigned char start4[4];        /* starting sector counting from 0 */
45         unsigned char size4[4];         /* nr of sectors in partition */
46 } PACKED;
47
48 enum failure {ioctl_error,
49         unable_to_open, unable_to_read, unable_to_seek,
50         unable_to_write};
51
52 enum action {fdisk, require, try_only, create_empty_dos, create_empty_sun};
53
54 struct geom {
55         unsigned int heads;
56         unsigned int sectors;
57         unsigned int cylinders;
58 };
59
60 /* prototypes for fdisk.c */
61 extern char *disk_device, *line_ptr;
62 extern int fd, partitions;
63 extern unsigned int display_in_cyl_units, units_per_sector;
64 extern void change_units(void);
65 extern void fatal(enum failure why);
66 extern void get_geometry(int fd, struct geom *);
67 extern int get_boot(enum action what);
68 extern int  get_partition(int warn, int max);
69 extern void list_types(struct systypes *sys);
70 extern int read_line (int *asked);
71 extern char read_char(char *mesg);
72 extern int read_hex(struct systypes *sys);
73 extern void reread_partition_table(int leave);
74 extern struct partition *get_part_table(int);
75 extern int valid_part_table_flag(unsigned char *b);
76 extern unsigned int read_int(unsigned int low, unsigned int dflt,
77                              unsigned int high, unsigned int base, char *mesg);
78
79 extern unsigned char *MBRbuffer;
80 extern void zeroize_mbr_buffer(void);
81
82 extern unsigned int heads, cylinders, sector_size;
83 extern unsigned long long sectors;
84 extern char *partition_type(unsigned char type);
85 extern void update_units(void);
86 extern char read_chars(char *mesg);
87 extern void set_changed(int);
88 extern void set_all_unchanged(void);
89
90 #define PLURAL  0
91 #define SINGULAR 1
92 extern const char * str_units(int);
93
94 extern unsigned long long get_start_sect(struct partition *p);
95 extern unsigned long long get_nr_sects(struct partition *p);
96
97 enum labeltype {
98         DOS_LABEL,
99         SUN_LABEL,
100         SGI_LABEL,
101         AIX_LABEL,
102         OSF_LABEL,
103         MAC_LABEL
104 };
105
106 extern enum labeltype disklabel;
107
108 /* prototypes for fdiskbsdlabel.c */
109 extern void bselect(void);
110 extern int check_osf_label(void);
111 extern int btrydev(char * dev);
112 extern void xbsd_print_disklabel(int);
113
114 /* prototypes for fdisksgilabel.c */
115 extern int valid_part_table_flag(unsigned char *b);
116