+/* vi: set sw=4 ts=4: */
/* fdisk.c -- Partition table manipulator for Linux.
*
* Copyright (C) 1992 A. V. Le Blanc (LeBlanc@mcc.ac.uk)
- * Copyright (C) 2001,2002 Vladimir Oleynik <dzo@simtreas.ru> (Busybox port)
+ * Copyright (C) 2001,2002 Vladimir Oleynik <dzo@simtreas.ru> (initial bb port)
*
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
+/* Current changes have not compatibility with this version */
#define UTIL_LINUX_VERSION "2.12"
+
+#define _(x) x
+
#define PROC_PARTITIONS "/proc/partitions"
#include <features.h>
#define DKTYPENAMES
-#define BLKRRPART _IO(0x12,95) /* re-read partition table */
-#define BLKGETSIZE _IO(0x12,96) /* return device size */
-#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
-#define BLKSSZGET _IO(0x12,104) /* get block device sector size */
-
-/* Avoid conflicts with the 2.6 kernel headers, which define
- * _IOR rather differently */
-#undef _IOR
-#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
-#define BLKGETSIZE64 _IOR(0x12,114,uint64_t)
-
/*
fdisk.h
*/
# define MBRbuffer bb_common_bufsiz1
#endif
-#ifdef CONFIG_FEATURE_SUN_LABEL
-static int sun_label; /* looking at sun disklabel */
-#else
-#define sun_label 0
-#endif
-#ifdef CONFIG_FEATURE_SGI_LABEL
-static int sgi_label; /* looking at sgi disklabel */
-#else
-#define sgi_label 0
-#endif
-#ifdef CONFIG_FEATURE_AIX_LABEL
-static int aix_label; /* looking at aix disklabel */
-#else
-#define aix_label 0
-#endif
#ifdef CONFIG_FEATURE_OSF_LABEL
-static int osf_label; /* looking at OSF/1 disklabel */
static int possibly_osf_label;
-#else
-#define osf_label 0
#endif
-#define dos_label (!sun_label && !sgi_label && !aix_label && !osf_label)
-
static uint heads, sectors, cylinders;
static void update_units(void);
unable_to_write
};
+enum label_type{
+ label_dos, label_sun, label_sgi, label_aix, label_osf
+};
+
enum action { fdisk, require, try_only, create_empty_dos, create_empty_sun };
+static enum label_type current_label_type;
+
static const char *disk_device;
static int fd; /* the disk */
static int partitions = 4; /* maximum partition + 1 */
);
}
-static void
-aix_nolabel(void)
-{
- aixlabel->magic = 0;
- aix_label = 0;
- partitions = 4;
- memset(MBRbuffer, 0, sizeof(MBRbuffer)); /* avoid fdisk cores */
- return;
-}
-
static int
check_aix_label(void)
{
if (aixlabel->magic != AIX_LABEL_MAGIC &&
aixlabel->magic != AIX_LABEL_MAGIC_SWAPPED) {
- aix_label = 0;
+ current_label_type = 0;
aix_other_endian = 0;
return 0;
}
aix_other_endian = (aixlabel->magic == AIX_LABEL_MAGIC_SWAPPED);
update_units();
- aix_label = 1;
+ current_label_type = label_aix;
partitions = 1016;
aix_volumes = 15;
aix_info();
- aix_nolabel(); /* %% */
- aix_label = 1; /* %% */
+ /*aix_nolabel();*/ /* %% */
+ /*aix_label = 1;*/ /* %% */
return 1;
}
#endif /* AIX_LABEL */
#define BSD_LINUX_BOOTDIR "/usr/ucb/mdec"
-#if defined (i386) || defined (__sparc__) || defined (__arm__) || defined (__mips__) || defined (__s390__) || defined (__sh__) || defined(__x86_64__)
+#if defined (i386) || defined (__sparc__) || defined (__arm__) || defined (__m68k__) || defined (__mips__) || defined (__s390__) || defined (__sh__) || defined(__x86_64__)
#define BSD_LABELSECTOR 1
#define BSD_LABELOFFSET 0
#elif defined (__alpha__) || defined (__powerpc__) || defined (__ia64__) || defined (__hppa__)
/* We need a backup of the disklabel (xbsd_dlabel might have changed). */
d = &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE];
- bcopy(d, &dl, sizeof(struct xbsd_disklabel));
+ memmove(&dl, d, sizeof(struct xbsd_disklabel));
/* The disklabel will be overwritten by 0's from bootxx anyway */
memset(d, 0, sizeof(struct xbsd_disklabel));
exit(EXIT_FAILURE);
}
- bcopy(&dl, d, sizeof(struct xbsd_disklabel));
+ memmove(d, &dl, sizeof(struct xbsd_disklabel));
#if defined (__powerpc__) || defined (__hppa__)
sector = 0;
else
d->d_type = BSD_DTYPE_ST506;
-#if 0 /* not used (at least not written to disk) by NetBSD/i386 1.0 */
- d->d_subtype = BSD_DSTYPE_INDOSPART & pindex;
-#endif
-
#if !defined (__alpha__)
d->d_flags = BSD_D_DOSPART;
#else
if (BSD_BBSIZE != read(fd, disklabelbuffer, BSD_BBSIZE))
fdisk_fatal(unable_to_read);
- bcopy(&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
- d, sizeof(struct xbsd_disklabel));
+ memmove(d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
+ sizeof(struct xbsd_disklabel));
if (d->d_magic != BSD_DISKMAGIC || d->d_magic2 != BSD_DISKMAGIC)
return 0;
/* This is necessary if we want to write the bootstrap later,
otherwise we'd write the old disklabel with the bootstrap.
*/
- bcopy(d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
- sizeof(struct xbsd_disklabel));
+ memmove(&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
+ d, sizeof(struct xbsd_disklabel));
#if defined (__alpha__) && BSD_LABELSECTOR == 0
alpha_bootblock_checksum (disklabelbuffer);
return SGI_SSWAP16(sgilabel->devparam.ntrks);
}
-static void
-sgi_nolabel(void)
-{
- sgilabel->magic = 0;
- sgi_label = 0;
- partitions = 4;
-}
-
static unsigned int
two_s_complement_32bit_sum(unsigned int* base, int size /* in bytes */)
{
if (sgilabel->magic != SGI_LABEL_MAGIC
&& sgilabel->magic != SGI_LABEL_MAGIC_SWAPPED) {
- sgi_label = 0;
- sgi_other_endian = 0;
+ current_label_type = label_dos;
return 0;
}
_("Detected sgi disklabel with wrong checksum.\n"));
}
update_units();
- sgi_label = 1;
+ current_label_type = label_sgi;
partitions = 16;
sgi_volumes = 15;
return 1;
/* I keep SGI's habit to write the sgilabel to the second block */
sgilabel->directory[0].vol_file_start = SGI_SSWAP32(2);
sgilabel->directory[0].vol_file_size = SGI_SSWAP32(sizeof(sgiinfo));
- strncpy((char*)sgilabel->directory[0].vol_file_name, "sgilabel", 8);
+ strcpy((char*)sgilabel->directory[0].vol_file_name, "sgilabel");
}
static sgiinfo *fill_sgiinfo(void);
"until you decide to write them. After that, of course, the previous\n"
"content will be unrecoverably lost.\n\n"));
- sgi_other_endian = (BYTE_ORDER == LITTLE_ENDIAN);
+ sgi_other_endian = (BB_LITTLE_ENDIAN);
res = ioctl(fd, BLKGETSIZE, &longsectors);
if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
heads = geometry.heads;
sgilabel->devparam.xylogics_writecont = SGI_SSWAP16(0);
memset( &(sgilabel->directory), 0, sizeof(struct volume_directory)*15 );
memset( &(sgilabel->partitions), 0, sizeof(struct sgi_partition)*16 );
- sgi_label = 1;
+ current_label_type = label_sgi;
partitions = 16;
sgi_volumes = 15;
sgi_set_entire();
set_changed(i);
}
-static void
-sun_nolabel(void)
-{
- sun_label = 0;
- sunlabel->magic = 0;
- partitions = 4;
-}
-
static int
check_sun_label(void)
{
if (sunlabel->magic != SUN_LABEL_MAGIC
&& sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED) {
- sun_label = 0;
+ current_label_type = label_dos;
sun_other_endian = 0;
return 0;
}
sectors = SUN_SSWAP16(sunlabel->nsect);
}
update_units();
- sun_label = 1;
+ current_label_type = label_sun;
partitions = 8;
return 1;
}
if (!ioctl(fd, SCSI_IOCTL_GET_IDLUN, &id)) {
sprintf(buffer,
"Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n",
-#if 0
- ((id[0]>>24)&0xff)-/*PROC_SCSI_SCSI+PROC_SCSI_FILE*/33,
-#else
/* This is very wrong (works only if you have one HBA),
but I haven't found a way how to get hostno
from the current kernel */
0,
-#endif
(id[0]>>16) & 0xff,
id[0] & 0xff,
(id[0]>>8) & 0xff
_("Building a new sun disklabel. Changes will remain in memory only,\n"
"until you decide to write them. After that, of course, the previous\n"
"content won't be recoverable.\n\n"));
-#if BYTE_ORDER == LITTLE_ENDIAN
- sun_other_endian = 1;
-#else
- sun_other_endian = 0;
-#endif
+ sun_other_endian = BB_LITTLE_ENDIAN;
memset(MBRbuffer, 0, sizeof(MBRbuffer));
sunlabel->magic = SUN_SSWAP16(SUN_LABEL_MAGIC);
if (!floppy) {
menu(void)
{
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label) {
+ if (label_sun == current_label_type) {
puts(_("Command action"));
puts(_("\ta\ttoggle a read only flag")); /* sun */
puts(_("\tb\tedit bsd disklabel"));
} else
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- if (sgi_label) {
+ if (label_sgi == current_label_type) {
puts(_("Command action"));
puts(_("\ta\tselect bootable partition")); /* sgi flavour */
puts(_("\tb\tedit bootfile entry")); /* sgi */
} else
#endif
#ifdef CONFIG_FEATURE_AIX_LABEL
- if (aix_label) {
+ if (label_aix == current_label_type) {
puts(_("Command action"));
puts(_("\tm\tprint this menu"));
puts(_("\to\tcreate a new empty DOS partition table"));
xmenu(void)
{
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label) {
+ if (label_sun == current_label_type) {
puts(_("Command action"));
puts(_("\ta\tchange number of alternate cylinders")); /*sun*/
puts(_("\tc\tchange number of cylinders"));
} else
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- if (sgi_label) {
+ if (label_sgi == current_label_type) {
puts(_("Command action"));
puts(_("\tb\tmove beginning of data in a partition")); /* !sun */
puts(_("\tc\tchange number of cylinders"));
} else
#endif
#ifdef CONFIG_FEATURE_AIX_LABEL
- if (aix_label) {
+ if (label_aix == current_label_type) {
puts(_("Command action"));
puts(_("\tb\tmove beginning of data in a partition")); /* !sun */
puts(_("\tc\tchange number of cylinders"));
{
return (
#ifdef CONFIG_FEATURE_SUN_LABEL
- sun_label ? sun_sys_types :
+ label_sun == current_label_type ? sun_sys_types :
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- sgi_label ? sgi_sys_types :
+ label_sgi == current_label_type ? sgi_sys_types :
#endif
i386_sys_types);
}
{
return (
#ifdef CONFIG_FEATURE_SUN_LABEL
- sun_label ? sunlabel->infos[i].id :
+ label_sun == current_label_type ? sunlabel->infos[i].id :
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- sgi_label ? sgi_get_sysid(i) :
+ label_sgi == current_label_type ? sgi_get_sysid(i) :
#endif
ptes[i].part_table->sys_ind);
}
static void
warn_cylinders(void)
{
- if (dos_label && cylinders > 1024 && !nowarn)
+ if (label_dos == current_label_type && cylinders > 1024 && !nowarn)
fprintf(stderr, _("\n"
"The number of cylinders for this disk is set to %d.\n"
"There is nothing wrong with that, but this is larger than 1024,\n"
_("Building a new DOS disklabel. Changes will remain in memory only,\n"
"until you decide to write them. After that, of course, the previous\n"
"content won't be recoverable.\n\n"));
-#ifdef CONFIG_FEATURE_SUN_LABEL
- sun_nolabel(); /* otherwise always recognised as sun */
-#endif
-#ifdef CONFIG_FEATURE_SGI_LABEL
- sgi_nolabel(); /* otherwise always recognised as sgi */
-#endif
-#ifdef CONFIG_FEATURE_AIX_LABEL
- aix_label = 0;
-#endif
+
+ current_label_type = label_dos;
+
#ifdef CONFIG_FEATURE_OSF_LABEL
- osf_label = 0;
possibly_osf_label = 0;
#endif
partitions = 4;
if (check_osf_label()) {
possibly_osf_label = 1;
if (!valid_part_table_flag(MBRbuffer)) {
- osf_label = 1;
+ current_label_type = label_osf;
return 0;
}
printf(_("This disk has both DOS and BSD magic.\n"
pe = &ptes[i];
if (warn) {
- if ((!sun_label && !sgi_label && !pe->part_table->sys_ind)
+ if (
+ (
+ label_sun != current_label_type &&
+ label_sgi != current_label_type &&
+ !pe->part_table->sys_ind
+ )
#ifdef CONFIG_FEATURE_SUN_LABEL
- || (sun_label &&
- (!sunlabel->partitions[i].num_sectors ||
- !sunlabel->infos[i].id))
+ || (
+ label_sun == current_label_type &&
+ (
+ !sunlabel->partitions[i].num_sectors
+ || !sunlabel->infos[i].id
+ )
+ )
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- || (sgi_label && (!sgi_get_num_sectors(i)))
+ || (
+ label_sgi == current_label_type &&
+ !sgi_get_num_sectors(i)
+ )
#endif
- )
+ ){
fprintf(stderr,
_("Warning: partition %d has empty type\n"),
- i+1);
+ i+1
+ );
+ }
}
return i;
}
pe->changed = 1;
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label) {
+ if (label_sun == current_label_type) {
sun_delete_partition(i);
return;
}
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- if (sgi_label) {
+ if (label_sgi == current_label_type) {
sgi_delete_partition(i);
return;
}
/* If sgi_label then don't use get_existing_partition,
let the user select a partition, since get_existing_partition()
only works for Linux like partition tables. */
- if (!sgi_label) {
+ if (label_sgi != current_label_type) {
i = get_existing_partition(0, partitions);
} else {
i = get_partition(0, partitions);
/* if changing types T to 0 is allowed, then
the reverse change must be allowed, too */
- if (!sys && !sgi_label && !sun_label && !get_nr_sects(p))
+ if (!sys && label_sgi != current_label_type &&
+ label_sun != current_label_type && !get_nr_sects(p))
+ {
printf(_("Partition %d does not exist yet!\n"), i + 1);
- else while (1) {
+ }else{
+ while (1) {
sys = read_hex (get_sys_types());
- if (!sys && !sgi_label && !sun_label) {
+ if (!sys && label_sgi != current_label_type &&
+ label_sun != current_label_type)
+ {
printf(_("Type 0 means free space to many systems\n"
"(but not to Linux). Having partitions of\n"
"type 0 is probably unwise. You can delete\n"
/* break; */
}
- if (!sun_label && !sgi_label) {
+ if (label_sun != current_label_type && label_sgi != current_label_type) {
if (IS_EXTENDED(sys) != IS_EXTENDED(p->sys_ind)) {
printf(_("You cannot change a partition into"
" an extended one or vice versa\n"
if (sys < 256) {
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label && i == 2 && sys != WHOLE_DISK)
+ if (label_sun == current_label_type && i == 2 && sys != WHOLE_DISK)
printf(_("Consider leaving partition 3 "
"as Whole disk (5),\n"
"as SunOS/Solaris expects it and "
"even Linux likes it.\n\n"));
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- if (sgi_label && ((i == 10 && sys != ENTIRE_DISK)
- || (i == 8 && sys != 0)))
+ if (label_sgi == current_label_type &&
+ (
+ (i == 10 && sys != ENTIRE_DISK) ||
+ (i == 8 && sys != 0)
+ )
+ ){
printf(_("Consider leaving partition 9 "
"as volume header (0),\nand "
"partition 11 as entire volume (6)"
"as IRIX expects it.\n\n"));
+ }
#endif
if (sys == origsys)
break;
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label) {
+ if (label_sun == current_label_type) {
sun_change_sysid(i, sys);
} else
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- if (sgi_label) {
+ if (label_sgi == current_label_type) {
sgi_change_sysid(i, sys);
} else
#endif
p->sys_ind = sys;
+
printf(_("Changed system type of partition %d "
"to %x (%s)\n"), i + 1, sys,
partition_type(sys));
dos_changed = 1;
break;
}
+ }
}
}
#endif /* CONFIG_FEATURE_FDISK_WRITABLE */
printf(_("logical=(%d, %d, %d)\n"),lec, leh, les);
}
-#if 0
-/* Beginning on cylinder boundary? */
- if (pbh != !pbc || pbs != 1) {
- printf(_("Partition %i does not start on cylinder "
- "boundary:\n"), partition + 1);
- printf(_(" phys=(%d, %d, %d) "), pbc, pbh, pbs);
- printf(_("should be (%d, %d, 1)\n"), pbc, !pbc);
- }
-#endif
-
/* Ending on cylinder boundary? */
if (peh != (heads - 1) || pes != sectors) {
printf(_("Partition %i does not end on cylinder boundary.\n"),
partition + 1);
-#if 0
- printf(_(" phys=(%d, %d, %d) "), pec, peh, pes);
- printf(_("should be (%d, %d, %d)\n"),
- pec, heads - 1, sectors);
-#endif
}
}
int i, w;
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label) {
+ if (label_sun == current_label_type) {
sun_list_table(xtra);
return;
}
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- if (sgi_label) {
+ if (label_sgi == current_label_type) {
sgi_list_table(xtra);
return;
}
list_disk_geometry();
#ifdef CONFIG_FEATURE_OSF_LABEL
- if (osf_label) {
+ if (label_osf == current_label_type) {
xbsd_print_disklabel(xtra);
return;
}
/* Is partition table in disk order? It need not be, but... */
/* partition table entries are not checked for correct order if this
is a sgi, sun or aix labeled disk... */
- if (dos_label && wrong_p_order(NULL)) {
+ if (label_dos == current_label_type && wrong_p_order(NULL)) {
+ /* FIXME */
printf(_("\nPartition table entries are not in disk order\n"));
}
}
return;
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label) {
+ if (label_sun == current_label_type) {
verify_sun();
return;
}
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- if (sgi_label) {
+ if (label_sgi == current_label_type) {
verify_sgi(1);
return;
}
add_partition(int n, int sys)
{
char mesg[256]; /* 48 does not suffice in Japanese */
- int i, readed = 0;
+ int i, num_read = 0;
struct partition *p = ptes[n].part_table;
struct partition *q = ptes[ext_index].part_table;
long long llimit;
}
if (start > limit)
break;
- if (start >= temp+units_per_sector && readed) {
+ if (start >= temp+units_per_sector && num_read) {
printf(_("Sector %llu is already allocated\n"), (unsigned long long)temp);
temp = start;
- readed = 0;
+ num_read = 0;
}
- if (!readed && start == temp) {
+ if (!num_read && start == temp) {
off_t saved_start;
saved_start = start;
start = (start - 1) * units_per_sector;
if (start < saved_start) start = saved_start;
}
- readed = 1;
+ num_read = 1;
}
- } while (start != temp || !readed);
+ } while (start != temp || !num_read);
if (n > 4) { /* NOT for fifth partition */
struct pte *pe = &ptes[n];
ext_index = n;
pen->ext_pointer = p;
pe4->offset = extended_offset = start;
- pe4->sectorbuffer = xcalloc(1, sector_size);
+ pe4->sectorbuffer = xzalloc(sector_size);
pe4->part_table = pt_offset(pe4->sectorbuffer, 0);
pe4->ext_pointer = pe4->part_table + 1;
pe4->changed = 1;
if (partitions > 5 || ptes[4].part_table->sys_ind) {
struct pte *pe = &ptes[partitions];
- pe->sectorbuffer = xcalloc(1, sector_size);
+ pe->sectorbuffer = xzalloc(sector_size);
pe->part_table = pt_offset(pe->sectorbuffer, 0);
pe->ext_pointer = pe->part_table + 1;
pe->offset = 0;
return;
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label) {
+ if (label_sun == current_label_type) {
add_sun_partition(get_partition(0, partitions), LINUX_NATIVE);
return;
}
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- if (sgi_label) {
+ if (label_sgi == current_label_type) {
sgi_add_partition(get_partition(0, partitions), LINUX_NATIVE);
return;
}
#endif
#ifdef CONFIG_FEATURE_AIX_LABEL
- if (aix_label) {
+ if (label_aix == current_label_type) {
printf(_("\tSorry - this fdisk cannot handle AIX disk labels."
"\n\tIf you want to add DOS-type partitions, create"
"\n\ta new empty DOS partition table first. (Use o.)"
{
int i;
- if (dos_label) {
+ if (label_dos == current_label_type) {
for (i = 0; i < 3; i++)
if (ptes[i].changed)
ptes[3].changed = 1;
}
}
#ifdef CONFIG_FEATURE_SGI_LABEL
- else if (sgi_label) {
+ else if (label_sgi == current_label_type) {
/* no test on change? the printf below might be mistaken */
sgi_write_table();
}
#endif
#ifdef CONFIG_FEATURE_SUN_LABEL
- else if (sun_label) {
+ else if (label_sun == current_label_type) {
int needw = 0;
for (i = 0; i < 8; i++)
printf(_("Device: %s\n"), disk_device);
#if defined(CONFIG_FEATURE_SGI_LABEL) || defined(CONFIG_FEATURE_SUN_LABEL)
- if (sun_label || sgi_label)
+ if (label_sun == current_label_type || label_sgi == current_label_type)
print_buffer(MBRbuffer);
else
#endif
switch (c) {
case 'a':
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label)
+ if (label_sun == current_label_type)
sun_set_alt_cyl();
#endif
break;
case 'b':
- if (dos_label)
+ if (label_dos == current_label_type)
move_begin(get_partition(0, partitions));
break;
case 'c':
read_int(1, cylinders, 1048576, 0,
_("Number of cylinders"));
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label)
+ if (label_sun == current_label_type)
sun_set_ncyl(cylinders);
#endif
- if (dos_label)
+ if (label_dos == current_label_type)
warn_cylinders();
break;
case 'd':
break;
case 'e':
#ifdef CONFIG_FEATURE_SGI_LABEL
- if (sgi_label)
+ if (label_sgi == current_label_type)
sgi_set_xcyl();
- else
+ else
#endif
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label)
+ if (label_sun == current_label_type)
sun_set_xcyl();
else
#endif
- if (dos_label)
+ if (label_dos == current_label_type)
x_list_table(1);
break;
case 'f':
- if (dos_label)
+ if (label_dos == current_label_type)
fix_partition_table_order();
break;
case 'g':
break;
case 'i':
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label)
+ if (label_sun == current_label_type)
sun_set_ilfact();
#endif
break;
case 'o':
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label)
+ if (label_sun == current_label_type)
sun_set_rspeed();
#endif
break;
case 'p':
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label)
+ if (label_sun == current_label_type)
list_table(1);
else
#endif
break;
case 'y':
#ifdef CONFIG_FEATURE_SUN_LABEL
- if (sun_label)
+ if (label_sun == current_label_type)
sun_set_pcylcount();
#endif
break;
return is_ide;
}
+
static void
try(const char *device, int user_specified)
{
close(fd);
} else if (gb < 0) { /* no DOS signature */
list_disk_geometry();
- if (aix_label)
+ if (label_aix == current_label_type){
return;
+ }
#ifdef CONFIG_FEATURE_OSF_LABEL
if (btrydev(device) < 0)
#endif
close(fd);
list_table(0);
#ifdef CONFIG_FEATURE_FDISK_WRITABLE
- if (!sun_label && partitions > 4)
+ if (label_sun != current_label_type && partitions > 4){
delete_partition(ext_index);
+ }
#endif
}
} else {
}
}
-#if 0
- printf(_("This kernel finds the sector size itself - "
- "-b option ignored\n"));
-#else
if (user_set_sector_size && argc-optind != 1)
printf(_("Warning: the -b (set sector size) option should"
" be used with one specified device\n"));
-#endif
#ifdef CONFIG_FEATURE_FDISK_WRITABLE
if (optl) {
get_boot(fdisk);
#ifdef CONFIG_FEATURE_OSF_LABEL
- if (osf_label) {
+ if (label_osf == current_label_type) {
/* OSF label, and no DOS label */
printf(_("Detected an OSF/1 disklabel on %s, entering "
"disklabel mode.\n"),
disk_device);
bselect();
- osf_label = 0;
+ /*Why do we do this? It seems to be counter-intuitive*/
+ current_label_type = label_dos;
/* If we return we may want to make an empty DOS label? */
}
#endif
c = tolower(read_char(_("Command (m for help): ")));
switch (c) {
case 'a':
- if (dos_label)
+ if (label_dos == current_label_type)
toggle_active(get_partition(1, partitions));
#ifdef CONFIG_FEATURE_SUN_LABEL
- else if (sun_label)
+ else if (label_sun == current_label_type)
toggle_sunflags(get_partition(1, partitions),
0x01);
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- else if (sgi_label)
+ else if (label_sgi == current_label_type)
sgi_set_bootpartition(
get_partition(1, partitions));
#endif
break;
case 'b':
#ifdef CONFIG_FEATURE_SGI_LABEL
- if (sgi_label) {
+ if (label_sgi == current_label_type) {
printf(_("\nThe current boot file is: %s\n"),
sgi_get_bootfile());
if (read_chars(_("Please enter the name of the "
#endif
break;
case 'c':
- if (dos_label)
+ if (label_dos == current_label_type)
toggle_dos_compatibility_flag();
#ifdef CONFIG_FEATURE_SUN_LABEL
- else if (sun_label)
+ else if (label_sun == current_label_type)
toggle_sunflags(get_partition(1, partitions),
0x10);
#endif
#ifdef CONFIG_FEATURE_SGI_LABEL
- else if (sgi_label)
+ else if (label_sgi == current_label_type)
sgi_set_swappartition(
get_partition(1, partitions));
#endif
let the user select a partition, since
get_existing_partition() only works for Linux-like
partition tables */
- if (!sgi_label) {
+ if (label_sgi != current_label_type) {
j = get_existing_partition(1, partitions);
} else {
j = get_partition(1, partitions);
break;
case 'i':
#ifdef CONFIG_FEATURE_SGI_LABEL
- if (sgi_label)
+ if (label_sgi == current_label_type)
create_sgiinfo();
else
#endif
#ifdef CONFIG_FEATURE_FDISK_ADVANCED
case 'x':
#ifdef CONFIG_FEATURE_SGI_LABEL
- if (sgi_label) {
+ if (label_sgi == current_label_type) {
fprintf(stderr,
_("\n\tSorry, no experts menu for SGI "
"partition tables available.\n\n"));