fdisk: do not open device twice. Complain on fdisk -l /dev/bogus.
Made enums UPPERCASE. Removed one global variable.
Added some FIXMEs.
text data bss dec hex filename
804708 645 7112 812465 c65b1 busybox_old
804685 641 7112 812438 c6596 busybox_unstripped
diff --git a/util-linux/fdisk_sgi.c b/util-linux/fdisk_sgi.c
index 1fce0c1..55e77d5 100644
--- a/util-linux/fdisk_sgi.c
+++ b/util-linux/fdisk_sgi.c
@@ -235,7 +235,7 @@
if (sgilabel->magic != SGI_LABEL_MAGIC
&& sgilabel->magic != SGI_LABEL_MAGIC_SWAPPED
) {
- current_label_type = label_dos;
+ current_label_type = LABEL_DOS;
return 0;
}
@@ -248,7 +248,7 @@
printf("Detected sgi disklabel with wrong checksum\n");
}
update_units();
- current_label_type = label_sgi;
+ current_label_type = LABEL_SGI;
g_partitions = 16;
sgi_volumes = 15;
return 1;
@@ -439,9 +439,9 @@
assert(two_s_complement_32bit_sum(
(unsigned int*)sgilabel, sizeof(*sgilabel)) == 0);
- if (lseek(fd, 0, SEEK_SET) < 0)
+ if (lseek(dev_fd, 0, SEEK_SET) < 0)
fdisk_fatal(unable_to_seek);
- if (write(fd, sgilabel, SECTOR_SIZE) != SECTOR_SIZE)
+ if (write(dev_fd, sgilabel, SECTOR_SIZE) != SECTOR_SIZE)
fdisk_fatal(unable_to_write);
if (!strncmp((char*)sgilabel->directory[0].vol_file_name, "sgilabel", 8)) {
/*
@@ -450,9 +450,9 @@
*/
sgiinfo *info = fill_sgiinfo();
int infostartblock = SGI_SSWAP32(sgilabel->directory[0].vol_file_start);
- if (lseek(fd, infostartblock*SECTOR_SIZE, SEEK_SET) < 0)
+ if (lseek(dev_fd, infostartblock*SECTOR_SIZE, SEEK_SET) < 0)
fdisk_fatal(unable_to_seek);
- if (write(fd, info, SECTOR_SIZE) != SECTOR_SIZE)
+ if (write(dev_fd, info, SECTOR_SIZE) != SECTOR_SIZE)
fdisk_fatal(unable_to_write);
free(info);
}
@@ -782,8 +782,8 @@
printf(msg_building_new_label, "SGI disklabel");
sgi_other_endian = BB_LITTLE_ENDIAN;
- res = ioctl(fd, BLKGETSIZE, &longsectors);
- if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
+ res = ioctl(dev_fd, BLKGETSIZE, &longsectors);
+ if (!ioctl(dev_fd, HDIO_GETGEO, &geometry)) {
g_heads = geometry.heads;
g_sectors = geometry.sectors;
if (res == 0) {
@@ -851,7 +851,7 @@
//sgilabel->devparam.xylogics_writecont = SGI_SSWAP16(0);
//memset( &(sgilabel->directory), 0, sizeof(struct volume_directory)*15 );
//memset( &(sgilabel->partitions), 0, sizeof(struct sgi_partinfo)*16 );
- current_label_type = label_sgi;
+ current_label_type = LABEL_SGI;
g_partitions = 16;
sgi_volumes = 15;
sgi_set_entire();