diff options
author | Denis Vlasenko | 2008-04-17 00:12:10 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-04-17 00:12:10 +0000 |
commit | 4437d19fb4d7bd7cd9d8acd5e67d85c8751a6e93 (patch) | |
tree | 5eb094c94adda9f92cbedac6062b0d0040a5142c /util-linux/fdisk_osf.c | |
parent | aca10f852ae760a3f2e2b9ed08bd13f9d5b85443 (diff) | |
download | busybox-4437d19fb4d7bd7cd9d8acd5e67d85c8751a6e93.zip busybox-4437d19fb4d7bd7cd9d8acd5e67d85c8751a6e93.tar.gz |
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
Diffstat (limited to 'util-linux/fdisk_osf.c')
-rw-r--r-- | util-linux/fdisk_osf.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c index 5a7e632..ba01a7f 100644 --- a/util-linux/fdisk_osf.c +++ b/util-linux/fdisk_osf.c @@ -413,7 +413,8 @@ bsd_select(void) xbsd_print_disklabel(0); break; case 'q': - close(fd); + if (ENABLE_FEATURE_CLEAN_UP) + close(dev_fd); exit(EXIT_SUCCESS); case 'r': return; @@ -627,12 +628,13 @@ xbsd_create_disklabel(void) #else xbsd_part #endif - ) == 1) { + ) == 1) { xbsd_print_disklabel(1); return 1; - } else - return 0; - } else if (c == 'n') + } + return 0; + } + if (c == 'n') return 0; } } @@ -766,9 +768,9 @@ xbsd_write_bootstrap(void) sector = get_start_sect(xbsd_part); #endif - if (lseek(fd, sector * SECTOR_SIZE, SEEK_SET) == -1) + if (lseek(dev_fd, sector * SECTOR_SIZE, SEEK_SET) == -1) fdisk_fatal(unable_to_seek); - if (BSD_BBSIZE != write(fd, disklabelbuffer, BSD_BBSIZE)) + if (BSD_BBSIZE != write(dev_fd, disklabelbuffer, BSD_BBSIZE)) fdisk_fatal(unable_to_write); #if defined(__alpha__) @@ -939,9 +941,9 @@ xbsd_readlabel(struct partition *p) sector = 0; #endif - if (lseek(fd, sector * SECTOR_SIZE, SEEK_SET) == -1) + if (lseek(dev_fd, sector * SECTOR_SIZE, SEEK_SET) == -1) fdisk_fatal(unable_to_seek); - if (BSD_BBSIZE != read(fd, disklabelbuffer, BSD_BBSIZE)) + if (BSD_BBSIZE != read(dev_fd, disklabelbuffer, BSD_BBSIZE)) fdisk_fatal(unable_to_read); memmove(d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET], @@ -985,14 +987,14 @@ xbsd_writelabel(struct partition *p) #if defined(__alpha__) && BSD_LABELSECTOR == 0 alpha_bootblock_checksum(disklabelbuffer); - if (lseek(fd, 0, SEEK_SET) == -1) + if (lseek(dev_fd, 0, SEEK_SET) == -1) fdisk_fatal(unable_to_seek); - if (BSD_BBSIZE != write(fd, disklabelbuffer, BSD_BBSIZE)) + if (BSD_BBSIZE != write(dev_fd, disklabelbuffer, BSD_BBSIZE)) fdisk_fatal(unable_to_write); #else - if (lseek(fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1) + if (lseek(dev_fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1) fdisk_fatal(unable_to_seek); - if (sizeof(struct xbsd_disklabel) != write(fd, d, sizeof(struct xbsd_disklabel))) + if (sizeof(struct xbsd_disklabel) != write(dev_fd, d, sizeof(struct xbsd_disklabel))) fdisk_fatal(unable_to_write); #endif sync_disks(); |