diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-29 05:10:47 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-29 05:10:47 +0000 |
commit | 6eaf0a98831960e3a4593e6630404634d747ab82 (patch) | |
tree | 433a90cad26f3c6ae9eff8572be94773523789e4 /util-linux/fdisk_osf.c | |
parent | ce13b7600277478055de0b7c38b483a76145efd2 (diff) | |
download | busybox-w32-6eaf0a98831960e3a4593e6630404634d747ab82.tar.gz busybox-w32-6eaf0a98831960e3a4593e6630404634d747ab82.tar.bz2 busybox-w32-6eaf0a98831960e3a4593e6630404634d747ab82.zip |
fdisk: move more data to struct globals; shrink code
function old new delta
nowarn 1 - -1
listing 1 - -1
dos_compatible_flag 1 - -1
warn_cylinders 44 42 -2
open_list_and_close 364 362 -2
fdisk_fatal 41 38 -3
verify 1053 1049 -4
user_sectors 4 - -4
user_heads 4 - -4
user_cylinders 4 - -4
pt_sectors 4 - -4
pt_heads 4 - -4
kern_sectors 4 - -4
kern_heads 4 - -4
ext_index 4 - -4
total_number_of_sectors 8 - -8
extended_offset 8 - -8
create_doslabel 129 120 -9
write_table 225 211 -14
delete_partition 445 431 -14
set_partition 476 459 -17
list_disk_geometry 247 229 -18
unable_to_write 19 - -19
add_partition 2515 2486 -29
get_boot 1709 1636 -73
fdisk_main 2812 2679 -133
------------------------------------------------------------------------------
(add/remove: 0/14 grow/shrink: 0/12 up/down: 0/-388) Total: -388 bytes
text data bss dec hex filename
804634 611 6852 812097 c6441 busybox_old
804298 610 6804 811712 c62c0 busybox_unstripped
Diffstat (limited to 'util-linux/fdisk_osf.c')
-rw-r--r-- | util-linux/fdisk_osf.c | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c index 24f240af3..c50ee9b16 100644 --- a/util-linux/fdisk_osf.c +++ b/util-linux/fdisk_osf.c | |||
@@ -688,13 +688,12 @@ xbsd_get_bootstrap(char *path, void *ptr, int size) | |||
688 | { | 688 | { |
689 | int fdb; | 689 | int fdb; |
690 | 690 | ||
691 | fdb = open(path, O_RDONLY); | 691 | fdb = open_or_warn(path, O_RDONLY); |
692 | if (fdb < 0) { | 692 | if (fdb < 0) { |
693 | perror(path); | ||
694 | return 0; | 693 | return 0; |
695 | } | 694 | } |
696 | if (read(fdb, ptr, size) < 0) { | 695 | if (full_read(fdb, ptr, size) < 0) { |
697 | perror(path); | 696 | bb_simple_perror_msg(path); |
698 | close(fdb); | 697 | close(fdb); |
699 | return 0; | 698 | return 0; |
700 | } | 699 | } |
@@ -765,10 +764,8 @@ xbsd_write_bootstrap(void) | |||
765 | sector = get_start_sect(xbsd_part); | 764 | sector = get_start_sect(xbsd_part); |
766 | #endif | 765 | #endif |
767 | 766 | ||
768 | if (lseek(dev_fd, sector * SECTOR_SIZE, SEEK_SET) == -1) | 767 | seek_sector(sector); |
769 | fdisk_fatal(unable_to_seek); | 768 | xwrite(dev_fd, disklabelbuffer, BSD_BBSIZE); |
770 | if (BSD_BBSIZE != write(dev_fd, disklabelbuffer, BSD_BBSIZE)) | ||
771 | fdisk_fatal(unable_to_write); | ||
772 | 769 | ||
773 | #if defined(__alpha__) | 770 | #if defined(__alpha__) |
774 | printf("Bootstrap installed on %s\n", disk_device); | 771 | printf("Bootstrap installed on %s\n", disk_device); |
@@ -938,9 +935,8 @@ xbsd_readlabel(struct partition *p) | |||
938 | sector = 0; | 935 | sector = 0; |
939 | #endif | 936 | #endif |
940 | 937 | ||
941 | if (lseek(dev_fd, sector * SECTOR_SIZE, SEEK_SET) == -1) | 938 | seek_sector(sector); |
942 | fdisk_fatal(unable_to_seek); | 939 | if (BSD_BBSIZE != full_read(dev_fd, disklabelbuffer, BSD_BBSIZE)) |
943 | if (BSD_BBSIZE != read(dev_fd, disklabelbuffer, BSD_BBSIZE)) | ||
944 | fdisk_fatal(unable_to_read); | 940 | fdisk_fatal(unable_to_read); |
945 | 941 | ||
946 | memmove(d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET], | 942 | memmove(d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET], |
@@ -984,15 +980,12 @@ xbsd_writelabel(struct partition *p) | |||
984 | 980 | ||
985 | #if defined(__alpha__) && BSD_LABELSECTOR == 0 | 981 | #if defined(__alpha__) && BSD_LABELSECTOR == 0 |
986 | alpha_bootblock_checksum(disklabelbuffer); | 982 | alpha_bootblock_checksum(disklabelbuffer); |
987 | if (lseek(dev_fd, 0, SEEK_SET) == -1) | 983 | seek_sector(0); |
988 | fdisk_fatal(unable_to_seek); | 984 | xwrite(dev_fd, disklabelbuffer, BSD_BBSIZE); |
989 | if (BSD_BBSIZE != write(dev_fd, disklabelbuffer, BSD_BBSIZE)) | ||
990 | fdisk_fatal(unable_to_write); | ||
991 | #else | 985 | #else |
992 | if (lseek(dev_fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1) | 986 | seek_sector(sector); |
993 | fdisk_fatal(unable_to_seek); | 987 | lseek(dev_fd, BSD_LABELOFFSET, SEEK_CUR); |
994 | if (sizeof(struct xbsd_disklabel) != write(dev_fd, d, sizeof(struct xbsd_disklabel))) | 988 | xwrite(dev_fd, d, sizeof(*d)); |
995 | fdisk_fatal(unable_to_write); | ||
996 | #endif | 989 | #endif |
997 | sync_disks(); | 990 | sync_disks(); |
998 | return 1; | 991 | return 1; |