fdisk_common_sources = \
fdisks/common.h \
fdisks/gpt.c \
- fdisks/gpt.h \
- fdisks/i386_sys_types.c
+ fdisks/gpt.h
if !ARCH_M68K
#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"
/* 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 */
-/* DOS partition types */
-#include "common.h"
-#include "nls.h"
-
-struct systypes i386_sys_types[] = {
{0x00, N_("Empty")},
{0x01, N_("FAT12")},
{0x02, N_("XENIX root")},
superblock */
{0xfe, N_("LANstep")}, /* SpeedStor >1024 cyl. or LANstep */
{0xff, N_("BBT")}, /* Xenix Bad Block Table */
+
{ 0, 0 }
-};
{'y', N_("change number of physical cylinders"), {0, SUN_LABEL}},
};
+
+
sector_t get_nr_sects(struct partition *p) {
return read4_little_endian(p->size4);
}
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)
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;
}
int
-read_hex(struct systypes *sys)
+read_hex(struct fdisk_context *cxt)
{
int hex;
{
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;
static void change_sysid(struct fdisk_context *cxt)
{
- char *temp;
+ const char *temp;
int i, sys, origsys;
struct partition *p;
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"
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);
- (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);
{
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);
}
unknown_command(c);
break;
case 'l':
- list_types(get_sys_types());
+ list_types(cxt);
break;
case 'm':
print_menu(MAIN_MENU);
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_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 */
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,
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);
#define AIX_INFO_MAGIC 0x00072959
#define AIX_INFO_MAGIC_SWAPPED 0x59290700
-/* fdiskaixlabel.c */
-extern struct systypes aix_sys_types[];
#endif /* FDISK_AIX_LABEL_H */
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,
xbsd_write_bootstrap (cxt);
break;
case 'l':
- xbsd_list_types ();
+ list_types (cxt);
break;
case 'n':
xbsd_add_part (cxt, 0, 0);
xbsd_print_disklabel (cxt, 1);
break;
case 't':
- xbsd_change_fstype ();
+ xbsd_change_fstype (cxt);
break;
case 'u':
change_units(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
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;
const struct fdisk_label bsd_label =
{
.name = "bsd",
+ .parttypes = xbsd_fstypes,
+
.probe = osf_probe_label,
.write = xbsd_write_disklabel,
.verify = NULL,
#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"},
#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; \
const struct fdisk_label dos_label =
{
.name = "dos",
+ .parttypes = dos_parttypes,
.probe = dos_probe_label,
.write = dos_write_disklabel,
.verify = dos_verify_disklabel,
#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 */
/*
* 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")},
/* 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"));
}
}
const struct fdisk_label sgi_label =
{
.name = "sgi",
+ .parttypes = sgi_parttypes,
+
.probe = sgi_probe_label,
.write = sgi_write_disklabel,
.verify = sgi_verify_disklabel,
#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 );
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")},
/* 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"));
}
}
const struct fdisk_label sun_label =
{
.name = "sun",
+ .parttypes = sun_parttypes,
+
.probe = sun_probe_label,
.write = sun_write_disklabel,
.verify = sun_verify_disklabel,
#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);
#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
#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) {