diff options
Diffstat (limited to 'fdisks')
-rw-r--r-- | fdisks/Makemodule.am | 3 | ||||
-rw-r--r-- | fdisks/cfdisk.c | 9 | ||||
-rw-r--r-- | fdisks/common.h | 7 | ||||
-rw-r--r-- | fdisks/dos_part_types.h (renamed from fdisks/i386_sys_types.c) | 7 | ||||
-rw-r--r-- | fdisks/fdisk.c | 32 | ||||
-rw-r--r-- | fdisks/fdisk.h | 17 | ||||
-rw-r--r-- | fdisks/fdiskaixlabel.h | 2 | ||||
-rw-r--r-- | fdisks/fdiskbsdlabel.c | 18 | ||||
-rw-r--r-- | fdisks/fdiskbsdlabel.h | 2 | ||||
-rw-r--r-- | fdisks/fdiskdoslabel.c | 5 | ||||
-rw-r--r-- | fdisks/fdiskmaclabel.h | 1 | ||||
-rw-r--r-- | fdisks/fdisksgilabel.c | 6 | ||||
-rw-r--r-- | fdisks/fdisksgilabel.h | 1 | ||||
-rw-r--r-- | fdisks/fdisksunlabel.c | 6 | ||||
-rw-r--r-- | fdisks/fdisksunlabel.h | 1 | ||||
-rw-r--r-- | fdisks/sfdisk.c | 11 |
16 files changed, 70 insertions, 58 deletions
diff --git a/fdisks/Makemodule.am b/fdisks/Makemodule.am index f58676912..26b47b0a7 100644 --- a/fdisks/Makemodule.am +++ b/fdisks/Makemodule.am @@ -2,8 +2,7 @@ fdisk_common_sources = \ fdisks/common.h \ fdisks/gpt.c \ - fdisks/gpt.h \ - fdisks/i386_sys_types.c + fdisks/gpt.h if !ARCH_M68K diff --git a/fdisks/cfdisk.c b/fdisks/cfdisk.c index 0ceed33ba..9dda1d4f4 100644 --- a/fdisks/cfdisk.c +++ b/fdisks/cfdisk.c @@ -107,6 +107,15 @@ #include "mbsalign.h" #include "widechar.h" +struct systypes { + unsigned char type; + char *name; +}; + +static struct systypes i386_sys_types[] = { + #include "dos_part_types.h" +}; + #ifdef __GNU__ #define DEFAULT_DEVICE "/dev/hd0" #define ALTERNATE_DEVICE "/dev/sd0" diff --git a/fdisks/common.h b/fdisks/common.h index 352b9a597..9b98f9e5a 100644 --- a/fdisks/common.h +++ b/fdisks/common.h @@ -3,13 +3,6 @@ /* common stuff for fdisk, cfdisk, sfdisk */ -struct systypes { - unsigned char type; - char *name; -}; - -extern struct systypes i386_sys_types[]; - extern char *partname(char *dev, int pno, int lth); #endif /* FDISK_COMMON_H */ diff --git a/fdisks/i386_sys_types.c b/fdisks/dos_part_types.h index 916daf68b..282adba91 100644 --- a/fdisks/i386_sys_types.c +++ b/fdisks/dos_part_types.h @@ -1,8 +1,3 @@ -/* DOS partition types */ -#include "common.h" -#include "nls.h" - -struct systypes i386_sys_types[] = { {0x00, N_("Empty")}, {0x01, N_("FAT12")}, {0x02, N_("XENIX root")}, @@ -106,5 +101,5 @@ struct systypes i386_sys_types[] = { superblock */ {0xfe, N_("LANstep")}, /* SpeedStor >1024 cyl. or LANstep */ {0xff, N_("BBT")}, /* Xenix Bad Block Table */ + { 0, 0 } -}; diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index 3a16c5f22..fe1996698 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -117,6 +117,8 @@ static const struct menulist_descr menulist[] = { {'y', N_("change number of physical cylinders"), {0, SUN_LABEL}}, }; + + sector_t get_nr_sects(struct partition *p) { return read4_little_endian(p->size4); } @@ -226,18 +228,11 @@ get_sysid(struct fdisk_context *cxt, int i) { ptes[i].part_table->sys_ind); } -static struct systypes * -get_sys_types(void) { - return ( - disklabel == SUN_LABEL ? sun_sys_types : - disklabel == SGI_LABEL ? sgi_sys_types : - i386_sys_types); -} -char *partition_type(unsigned char type) +char *partition_type(struct fdisk_context *cxt, unsigned char type) { int i; - struct systypes *types = get_sys_types(); + struct fdisk_parttype *types = cxt->label->parttypes; for (i=0; types[i].name; i++) if (types[i].type == type) @@ -246,8 +241,9 @@ char *partition_type(unsigned char type) return NULL; } -void list_types(struct systypes *sys) +void list_types(struct fdisk_context *cxt) { + struct fdisk_parttype *sys = cxt->label->parttypes; unsigned int last[4], done = 0, next = 0, size; int i; @@ -563,7 +559,7 @@ read_chars(char *mesg) } int -read_hex(struct systypes *sys) +read_hex(struct fdisk_context *cxt) { int hex; @@ -571,7 +567,7 @@ read_hex(struct systypes *sys) { read_char(_("Hex code (type L to list codes): ")); if (tolower(*line_ptr) == 'l') - list_types(sys); + list_types(cxt); else if (isxdigit (*line_ptr)) { hex = 0; @@ -843,7 +839,7 @@ static void delete_partition(struct fdisk_context *cxt, int partnum) static void change_sysid(struct fdisk_context *cxt) { - char *temp; + const char *temp; int i, sys, origsys; struct partition *p; @@ -859,7 +855,7 @@ static void change_sysid(struct fdisk_context *cxt) if (!sys && disklabel != SGI_LABEL && disklabel != SUN_LABEL && !get_nr_sects(p)) printf(_("Partition %d does not exist yet!\n"), i + 1); else while (1) { - sys = read_hex (get_sys_types()); + sys = read_hex (cxt); if (!sys && disklabel != SGI_LABEL && disklabel != SUN_LABEL) { printf(_("Type 0 means free space to many systems\n" @@ -901,7 +897,7 @@ static void change_sysid(struct fdisk_context *cxt) p->sys_ind = sys; ptes[i].changed = 1; } - temp = partition_type(sys) ? : _("Unknown"); + temp = partition_type(cxt, sys) ? : _("Unknown"); if (ptes[i].changed) printf (_("Changed system type of partition %d " "to %x (%s)\n"), i + 1, sys, temp); @@ -1223,7 +1219,7 @@ list_table(struct fdisk_context *cxt, int xtra) { - (psects ? 1 : 0)), /* odd flag on end */ (unsigned long) pblocks, podd ? '+' : ' ', /* type id */ p->sys_ind, -/* type name */ (type = partition_type(p->sys_ind)) ? +/* type name */ (type = partition_type(cxt, p->sys_ind)) ? type : _("Unknown")); check_consistency(cxt, p, i); check_alignment(cxt, get_partition_start(pe), i); @@ -1325,7 +1321,7 @@ void print_partition_size(struct fdisk_context *cxt, { char *str = size_to_human_string(SIZE_SUFFIX_3LETTER | SIZE_SUFFIX_SPACE, (uint64_t)(stop - start + 1) * cxt->sector_size); - printf(_("Partition %d of type %s and of size %s is set\n"), num, partition_type(sysid), str); + printf(_("Partition %d of type %s and of size %s is set\n"), num, partition_type(cxt, sysid), str); free(str); } @@ -1744,7 +1740,7 @@ static void command_prompt(struct fdisk_context *cxt) unknown_command(c); break; case 'l': - list_types(get_sys_types()); + list_types(cxt); break; case 'm': print_menu(MAIN_MENU); diff --git a/fdisks/fdisk.h b/fdisks/fdisk.h index 05dc8a8e0..8221cd9a3 100644 --- a/fdisks/fdisk.h +++ b/fdisks/fdisk.h @@ -100,6 +100,14 @@ enum failure { typedef unsigned long long sector_t; /* + * Partition types + */ +struct fdisk_parttype { + unsigned int type; /* type as number or zero */ + char *name; /* description */ +}; + +/* * Legacy CHS based geometry */ struct fdisk_geometry { @@ -137,6 +145,9 @@ struct fdisk_context { struct fdisk_label { const char *name; + /* array with partition types */ + struct fdisk_parttype *parttypes; + /* probe disk label */ int (*probe)(struct fdisk_context *cxt); /* write in-memory changes to disk */ @@ -189,10 +200,10 @@ extern void check(struct fdisk_context *cxt, int n, unsigned int h, unsigned int extern void change_units(struct fdisk_context *cxt); extern void fatal(struct fdisk_context *cxt, enum failure why); extern int get_partition(struct fdisk_context *cxt, int warn, int max); -extern void list_types(struct systypes *sys); +extern void list_types(struct fdisk_context *cxt); extern int read_line (int *asked); extern char read_char(char *mesg); -extern int read_hex(struct systypes *sys); +extern int read_hex(struct fdisk_context *cxt); extern void reread_partition_table(struct fdisk_context *cxt, int leave); extern struct partition *get_part_table(int); extern unsigned int read_int(struct fdisk_context *cxt, @@ -203,7 +214,7 @@ extern void print_partition_size(struct fdisk_context *cxt, int num, sector_t st extern void fill_bounds(sector_t *first, sector_t *last); -extern char *partition_type(unsigned char type); +extern char *partition_type(struct fdisk_context *cxt, unsigned char type); extern void update_units(struct fdisk_context *cxt); extern char read_chars(char *mesg); extern void set_changed(int); diff --git a/fdisks/fdiskaixlabel.h b/fdisks/fdiskaixlabel.h index c3af9a0e3..d0818e7c6 100644 --- a/fdisks/fdiskaixlabel.h +++ b/fdisks/fdiskaixlabel.h @@ -20,6 +20,4 @@ struct aix_partition { #define AIX_INFO_MAGIC 0x00072959 #define AIX_INFO_MAGIC_SWAPPED 0x59290700 -/* fdiskaixlabel.c */ -extern struct systypes aix_sys_types[]; #endif /* FDISK_AIX_LABEL_H */ diff --git a/fdisks/fdiskbsdlabel.c b/fdisks/fdiskbsdlabel.c index 442a79f2d..c7c13b1b1 100644 --- a/fdisks/fdiskbsdlabel.c +++ b/fdisks/fdiskbsdlabel.c @@ -64,10 +64,9 @@ static void xbsd_delete_part (struct fdisk_context *cxt, int partnum); static void xbsd_edit_disklabel (void); static void xbsd_write_bootstrap (struct fdisk_context *cxt); -static void xbsd_change_fstype (void); +static void xbsd_change_fstype (struct fdisk_context *cxt); static int xbsd_get_part_index (int max); static int xbsd_check_new_partition (int *i); -static void xbsd_list_types (void); static unsigned short xbsd_dkcksum (struct xbsd_disklabel *lp); static int xbsd_initlabel (struct fdisk_context *cxt, struct partition *p, struct xbsd_disklabel *d, @@ -275,7 +274,7 @@ bsd_command_prompt (struct fdisk_context *cxt) xbsd_write_bootstrap (cxt); break; case 'l': - xbsd_list_types (); + list_types (cxt); break; case 'n': xbsd_add_part (cxt, 0, 0); @@ -292,7 +291,7 @@ bsd_command_prompt (struct fdisk_context *cxt) xbsd_print_disklabel (cxt, 1); break; case 't': - xbsd_change_fstype (); + xbsd_change_fstype (cxt); break; case 'u': change_units(cxt); @@ -560,12 +559,12 @@ xbsd_write_bootstrap (struct fdisk_context *cxt) } static void -xbsd_change_fstype (void) +xbsd_change_fstype (struct fdisk_context *cxt) { int i; i = xbsd_get_part_index (xbsd_dlabel.d_npartitions); - xbsd_dlabel.d_partitions[i].p_fstype = read_hex (xbsd_fstypes); + xbsd_dlabel.d_partitions[i].p_fstype = read_hex (cxt); } static int @@ -612,11 +611,6 @@ xbsd_check_new_partition (int *i) { return 1; } -static void -xbsd_list_types (void) { - list_types (xbsd_fstypes); -} - static unsigned short xbsd_dkcksum (struct xbsd_disklabel *lp) { unsigned short *start, *end; @@ -846,6 +840,8 @@ alpha_bootblock_checksum (char *boot) const struct fdisk_label bsd_label = { .name = "bsd", + .parttypes = xbsd_fstypes, + .probe = osf_probe_label, .write = xbsd_write_disklabel, .verify = NULL, diff --git a/fdisks/fdiskbsdlabel.h b/fdisks/fdiskbsdlabel.h index ab6877eaa..9a60c6172 100644 --- a/fdisks/fdiskbsdlabel.h +++ b/fdisks/fdiskbsdlabel.h @@ -200,7 +200,7 @@ static char *xbsd_dktypenames[] = { #endif #ifdef DKTYPENAMES -static struct systypes xbsd_fstypes[] = { +static struct fdisk_parttype xbsd_fstypes[] = { {BSD_FS_UNUSED, "unused"}, {BSD_FS_SWAP, "swap"}, {BSD_FS_V6, "Version 6"}, diff --git a/fdisks/fdiskdoslabel.c b/fdisks/fdiskdoslabel.c index cc17a036d..9c08b9869 100644 --- a/fdisks/fdiskdoslabel.c +++ b/fdisks/fdiskdoslabel.c @@ -13,6 +13,10 @@ #include "fdisk.h" #include "fdiskdoslabel.h" +static struct fdisk_parttype dos_parttypes[] = { + #include "dos_part_types.h" +}; + #define set_hsc(h,s,c,sector) { \ s = sector % cxt->geom.sectors + 1; \ sector /= cxt->geom.sectors; \ @@ -824,6 +828,7 @@ done: const struct fdisk_label dos_label = { .name = "dos", + .parttypes = dos_parttypes, .probe = dos_probe_label, .write = dos_write_disklabel, .verify = dos_verify_disklabel, diff --git a/fdisks/fdiskmaclabel.h b/fdisks/fdiskmaclabel.h index 4aaaadd1c..4e6fef130 100644 --- a/fdisks/fdiskmaclabel.h +++ b/fdisks/fdiskmaclabel.h @@ -28,7 +28,6 @@ struct mac_partition { #define MAC_LABEL_MAGIC_3_SWAPPED 0x0000d405 /* fdiskmaclabel.c */ -extern struct systypes mac_sys_types[]; extern void mac_nolabel(struct fdisk_context *cxt); #endif /* FDISK_MAC_LABEL_H */ diff --git a/fdisks/fdisksgilabel.c b/fdisks/fdisksgilabel.c index 7253d21fa..d8aabd05d 100644 --- a/fdisks/fdisksgilabel.c +++ b/fdisks/fdisksgilabel.c @@ -87,7 +87,7 @@ isinfreelist(unsigned int b) { /* * end of free blocks section */ -struct systypes sgi_sys_types[] = { +static struct fdisk_parttype sgi_parttypes[] = { {SGI_VOLHDR, N_("SGI volhdr")}, {0x01, N_("SGI trkrepl")}, {0x02, N_("SGI secrepl")}, @@ -206,7 +206,7 @@ sgi_list_table(struct fdisk_context *cxt, int xtra) { /* end */ (long) scround(start+len)-1, /* no odd flag on end */ (long) len, /* type id */ sgi_get_sysid(cxt, i), -/* type name */ (type = partition_type(sgi_get_sysid(cxt, i))) +/* type name */ (type = partition_type(cxt, sgi_get_sysid(cxt, i))) ? type : _("Unknown")); } } @@ -898,6 +898,8 @@ static sgiinfo *fill_sgiinfo(void) const struct fdisk_label sgi_label = { .name = "sgi", + .parttypes = sgi_parttypes, + .probe = sgi_probe_label, .write = sgi_write_disklabel, .verify = sgi_verify_disklabel, diff --git a/fdisks/fdisksgilabel.h b/fdisks/fdisksgilabel.h index 4d511139d..9155a2400 100644 --- a/fdisks/fdisksgilabel.h +++ b/fdisks/fdisksgilabel.h @@ -110,7 +110,6 @@ typedef struct { #define sgiparam (sgilabel->devparam) /* fdisksgilabel.c */ -extern struct systypes sgi_sys_types[]; extern void sgi_list_table( struct fdisk_context *cxt, int xtra ); extern int sgi_change_sysid(struct fdisk_context *cxt, int i, int sys); extern unsigned int sgi_get_start_sector(struct fdisk_context *cxt, int i ); diff --git a/fdisks/fdisksunlabel.c b/fdisks/fdisksunlabel.c index 9d17ed22e..7ec2d5783 100644 --- a/fdisks/fdisksunlabel.c +++ b/fdisks/fdisksunlabel.c @@ -27,7 +27,7 @@ static int other_endian = 0; -struct systypes sun_sys_types[] = { +static struct fdisk_parttype sun_parttypes[] = { {SUN_TAG_UNASSIGNED, N_("Unassigned")}, {SUN_TAG_BOOT, N_("Boot")}, {SUN_TAG_ROOT, N_("SunOS root")}, @@ -582,7 +582,7 @@ void sun_list_table(struct fdisk_context *cxt, int xtra) /* end */ (unsigned long) scround(start+len), /* odd flag on end */ (unsigned long) len / 2, len & 1 ? '+' : ' ', /* type id */ SSWAP16(tag->tag), -/* type name */ (type = partition_type(SSWAP16(tag->tag))) +/* type name */ (type = partition_type(cxt, SSWAP16(tag->tag))) ? type : _("Unknown")); } } @@ -652,6 +652,8 @@ int sun_get_sysid(struct fdisk_context *cxt, int i) const struct fdisk_label sun_label = { .name = "sun", + .parttypes = sun_parttypes, + .probe = sun_probe_label, .write = sun_write_disklabel, .verify = sun_verify_disklabel, diff --git a/fdisks/fdisksunlabel.h b/fdisks/fdisksunlabel.h index 12cccb146..31cb7e89d 100644 --- a/fdisks/fdisksunlabel.h +++ b/fdisks/fdisksunlabel.h @@ -76,7 +76,6 @@ struct sun_disk_label { #define sunlabel ((struct sun_disk_label *)cxt->firstsector) /* fdisksunlabel.c */ -extern struct systypes sun_sys_types[]; extern int sun_change_sysid(struct fdisk_context *cxt, int i, uint16_t sys); extern void sun_list_table(struct fdisk_context *cxt, int xtra); extern void sun_set_alt_cyl(struct fdisk_context *cxt); diff --git a/fdisks/sfdisk.c b/fdisks/sfdisk.c index da5c60612..28ce2daa8 100644 --- a/fdisks/sfdisk.c +++ b/fdisks/sfdisk.c @@ -57,6 +57,15 @@ #include "closestream.h" #include "strutils.h" +struct systypes { + unsigned char type; + char *name; +}; + +static struct systypes i386_sys_types[] = { + #include "dos_part_types.h" +}; + /* * Table of contents: * A. About seeking @@ -597,7 +606,7 @@ chs_ok(chs a, char *v, char *w) { #define BSD_PARTITION 0xa5 #define NETBSD_PARTITION 0xa9 -/* List of partition types now in i386_sys_types.c */ +/* List of partition types */ static const char * sysname(unsigned char type) { |