2006-12-06 17:25:33 -06:00
|
|
|
/*
|
|
|
|
fdisk.h
|
|
|
|
*/
|
|
|
|
|
2009-10-15 18:26:46 -05:00
|
|
|
#include "c.h"
|
|
|
|
|
2006-12-06 17:25:37 -06:00
|
|
|
#define DEFAULT_SECTOR_SIZE 512
|
|
|
|
#define MAX_SECTOR_SIZE 2048
|
|
|
|
#define SECTOR_SIZE 512 /* still used in BSD code */
|
2006-12-06 17:25:35 -06:00
|
|
|
#define MAXIMUM_PARTS 60
|
|
|
|
|
2006-12-06 17:25:37 -06:00
|
|
|
#define ACTIVE_FLAG 0x80
|
|
|
|
|
|
|
|
#define EXTENDED 0x05
|
|
|
|
#define WIN98_EXTENDED 0x0f
|
|
|
|
#define LINUX_PARTITION 0x81
|
|
|
|
#define LINUX_SWAP 0x82
|
|
|
|
#define LINUX_NATIVE 0x83
|
|
|
|
#define LINUX_EXTENDED 0x85
|
2006-12-06 17:25:46 -06:00
|
|
|
#define LINUX_LVM 0x8e
|
|
|
|
#define LINUX_RAID 0xfd
|
2006-12-06 17:25:37 -06:00
|
|
|
|
|
|
|
#define IS_EXTENDED(i) \
|
|
|
|
((i) == EXTENDED || (i) == WIN98_EXTENDED || (i) == LINUX_EXTENDED)
|
|
|
|
|
2006-12-06 17:25:39 -06:00
|
|
|
#define cround(n) (display_in_cyl_units ? ((n)/units_per_sector)+1 : (n))
|
|
|
|
#define scround(x) (((x)+units_per_sector-1)/units_per_sector)
|
2006-12-06 17:25:33 -06:00
|
|
|
|
2006-12-06 17:26:28 -06:00
|
|
|
#if defined(__GNUC__) && (defined(__arm__) || defined(__alpha__))
|
|
|
|
# define PACKED __attribute__ ((packed))
|
|
|
|
#else
|
|
|
|
# define PACKED
|
|
|
|
#endif
|
|
|
|
|
2006-12-06 17:25:35 -06:00
|
|
|
struct partition {
|
|
|
|
unsigned char boot_ind; /* 0x80 - active */
|
|
|
|
unsigned char head; /* starting head */
|
|
|
|
unsigned char sector; /* starting sector */
|
|
|
|
unsigned char cyl; /* starting cylinder */
|
|
|
|
unsigned char sys_ind; /* What partition type */
|
|
|
|
unsigned char end_head; /* end head */
|
|
|
|
unsigned char end_sector; /* end sector */
|
|
|
|
unsigned char end_cyl; /* end cylinder */
|
|
|
|
unsigned char start4[4]; /* starting sector counting from 0 */
|
|
|
|
unsigned char size4[4]; /* nr of sectors in partition */
|
2006-12-06 17:26:28 -06:00
|
|
|
} PACKED;
|
2006-12-06 17:25:35 -06:00
|
|
|
|
2010-02-15 03:08:03 -06:00
|
|
|
enum failure {help, usage, ioctl_error,
|
2006-12-06 17:25:39 -06:00
|
|
|
unable_to_open, unable_to_read, unable_to_seek,
|
2006-12-06 17:25:41 -06:00
|
|
|
unable_to_write, out_of_memory};
|
2006-12-06 17:25:33 -06:00
|
|
|
|
2006-12-06 17:25:49 -06:00
|
|
|
enum action {fdisk, require, try_only, create_empty_dos, create_empty_sun};
|
2006-12-06 17:25:35 -06:00
|
|
|
|
2006-12-06 17:25:43 -06:00
|
|
|
struct geom {
|
|
|
|
unsigned int heads;
|
|
|
|
unsigned int sectors;
|
|
|
|
unsigned int cylinders;
|
|
|
|
};
|
|
|
|
|
2006-12-06 17:25:33 -06:00
|
|
|
/* prototypes for fdisk.c */
|
2006-12-06 17:26:12 -06:00
|
|
|
extern char *disk_device, *line_ptr;
|
|
|
|
extern int fd, partitions;
|
|
|
|
extern unsigned int display_in_cyl_units, units_per_sector;
|
2006-12-06 17:25:43 -06:00
|
|
|
extern void change_units(void);
|
2006-12-06 17:25:33 -06:00
|
|
|
extern void fatal(enum failure why);
|
2006-12-06 17:25:43 -06:00
|
|
|
extern void get_geometry(int fd, struct geom *);
|
2006-12-06 17:25:35 -06:00
|
|
|
extern int get_boot(enum action what);
|
2006-12-06 17:25:33 -06:00
|
|
|
extern int get_partition(int warn, int max);
|
2006-12-06 17:25:35 -06:00
|
|
|
extern void list_types(struct systypes *sys);
|
2006-12-06 17:25:33 -06:00
|
|
|
extern int read_line (void);
|
|
|
|
extern char read_char(char *mesg);
|
2006-12-06 17:25:35 -06:00
|
|
|
extern int read_hex(struct systypes *sys);
|
2006-12-06 17:25:41 -06:00
|
|
|
extern void reread_partition_table(int leave);
|
2006-12-06 17:25:43 -06:00
|
|
|
extern struct partition *get_part_table(int);
|
|
|
|
extern int valid_part_table_flag(unsigned char *b);
|
2006-12-06 17:26:12 -06:00
|
|
|
extern unsigned int read_int(unsigned int low, unsigned int dflt,
|
|
|
|
unsigned int high, unsigned int base, char *mesg);
|
2006-12-06 17:25:43 -06:00
|
|
|
|
2009-10-16 14:49:33 -05:00
|
|
|
extern unsigned char *MBRbuffer;
|
|
|
|
extern void zeroize_mbr_buffer(void);
|
|
|
|
|
2007-06-27 16:36:08 -05:00
|
|
|
extern unsigned int heads, cylinders, sector_size;
|
|
|
|
extern unsigned long long sectors;
|
|
|
|
extern char *partition_type(unsigned char type);
|
|
|
|
extern void update_units(void);
|
|
|
|
extern char read_chars(char *mesg);
|
|
|
|
extern void set_changed(int);
|
|
|
|
extern void set_all_unchanged(void);
|
2006-12-06 17:25:39 -06:00
|
|
|
|
|
|
|
#define PLURAL 0
|
|
|
|
#define SINGULAR 1
|
2007-05-30 10:41:14 -05:00
|
|
|
extern const char * str_units(int);
|
2006-12-06 17:25:33 -06:00
|
|
|
|
2007-05-30 10:10:43 -05:00
|
|
|
extern unsigned long long get_start_sect(struct partition *p);
|
|
|
|
extern unsigned long long get_nr_sects(struct partition *p);
|
2006-12-06 17:25:35 -06:00
|
|
|
|
2006-12-06 17:25:43 -06:00
|
|
|
extern int osf_label;
|
2007-06-27 16:36:08 -05:00
|
|
|
extern int sun_label;
|
|
|
|
extern int sgi_label;
|
|
|
|
extern int aix_label;
|
2007-06-27 16:49:56 -05:00
|
|
|
extern int mac_label;
|
2006-12-06 17:25:43 -06:00
|
|
|
|
2006-12-06 17:25:37 -06:00
|
|
|
/* prototypes for fdiskbsdlabel.c */
|
2006-12-06 17:25:33 -06:00
|
|
|
extern void bselect(void);
|
2006-12-06 17:25:43 -06:00
|
|
|
extern int check_osf_label(void);
|
|
|
|
extern int btrydev(char * dev);
|
|
|
|
extern void xbsd_print_disklabel(int);
|
2006-12-06 17:25:35 -06:00
|
|
|
|
2006-12-06 17:25:37 -06:00
|
|
|
/* prototypes for fdisksgilabel.c */
|
|
|
|
extern int valid_part_table_flag(unsigned char *b);
|
2006-12-06 17:25:41 -06:00
|
|
|
|