]> git.ipfire.org Git - thirdparty/util-linux.git/blame - fdisk/fdisk.h
Imported from util-linux-2.9i tarball.
[thirdparty/util-linux.git] / fdisk / fdisk.h
CommitLineData
726f69e2
KZ
1/*
2 fdisk.h
3*/
4
5c36a0eb
KZ
5#define DEFAULT_SECTOR_SIZE 512
6#define MAX_SECTOR_SIZE 2048
7#define SECTOR_SIZE 512 /* still used in BSD code */
2b6fc908
KZ
8#define MAXIMUM_PARTS 60
9
5c36a0eb
KZ
10#define ACTIVE_FLAG 0x80
11
12#define EXTENDED 0x05
13#define WIN98_EXTENDED 0x0f
14#define LINUX_PARTITION 0x81
15#define LINUX_SWAP 0x82
16#define LINUX_NATIVE 0x83
17#define LINUX_EXTENDED 0x85
18
19#define IS_EXTENDED(i) \
20 ((i) == EXTENDED || (i) == WIN98_EXTENDED || (i) == LINUX_EXTENDED)
21
2b6fc908
KZ
22#define SIZE(a) (sizeof(a)/sizeof((a)[0]))
23
726f69e2
KZ
24#define cround(n) (((n) + display_factor * unit_flag) / display_factor)
25
26#if defined(__GNUC__) || defined(HAS_LONG_LONG)
27typedef long long ext2_loff_t;
28#else
29typedef long ext2_loff_t;
30#endif
31
32extern ext2_loff_t ext2_llseek(unsigned int fd,
33 ext2_loff_t offset,
34 unsigned int origin);
35
2b6fc908
KZ
36struct partition {
37 unsigned char boot_ind; /* 0x80 - active */
38 unsigned char head; /* starting head */
39 unsigned char sector; /* starting sector */
40 unsigned char cyl; /* starting cylinder */
41 unsigned char sys_ind; /* What partition type */
42 unsigned char end_head; /* end head */
43 unsigned char end_sector; /* end sector */
44 unsigned char end_cyl; /* end cylinder */
45 unsigned char start4[4]; /* starting sector counting from 0 */
46 unsigned char size4[4]; /* nr of sectors in partition */
47};
48
726f69e2 49enum failure {usage, unable_to_open, unable_to_read, unable_to_seek,
5c36a0eb 50 unable_to_write, out_of_memory, no_partition, no_device};
726f69e2 51
2b6fc908
KZ
52enum action {fdisk, require, try_only, create_empty};
53
726f69e2
KZ
54struct systypes {
55 unsigned char index;
56 char *name;
57};
58
59/* prototypes for fdisk.c */
60extern char *disk_device,
61 *line_ptr;
62extern int fd,
63 partitions;
64extern uint unit_flag,
65 display_factor;
66extern struct partition *part_table[];
67extern void fatal(enum failure why);
2b6fc908 68extern int get_boot(enum action what);
726f69e2 69extern int get_partition(int warn, int max);
2b6fc908 70extern void list_types(struct systypes *sys);
726f69e2
KZ
71extern int read_line (void);
72extern char read_char(char *mesg);
2b6fc908 73extern int read_hex(struct systypes *sys);
5c36a0eb 74uint read_int(uint low, uint dflt, uint high, uint base, char *mesg);
726f69e2
KZ
75extern char *const str_units(void);
76
2b6fc908
KZ
77extern unsigned int get_start_sect(struct partition *p);
78extern unsigned int get_nr_sects(struct partition *p);
79
5c36a0eb 80/* prototypes for fdiskbsdlabel.c */
726f69e2 81extern void bselect(void);
2b6fc908
KZ
82extern int btrydev (char * dev);
83
5c36a0eb
KZ
84/* prototypes for fdisksgilabel.c */
85extern int valid_part_table_flag(unsigned char *b);