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
This commit is contained in:
@ -688,13 +688,12 @@ xbsd_get_bootstrap(char *path, void *ptr, int size)
|
||||
{
|
||||
int fdb;
|
||||
|
||||
fdb = open(path, O_RDONLY);
|
||||
fdb = open_or_warn(path, O_RDONLY);
|
||||
if (fdb < 0) {
|
||||
perror(path);
|
||||
return 0;
|
||||
}
|
||||
if (read(fdb, ptr, size) < 0) {
|
||||
perror(path);
|
||||
if (full_read(fdb, ptr, size) < 0) {
|
||||
bb_simple_perror_msg(path);
|
||||
close(fdb);
|
||||
return 0;
|
||||
}
|
||||
@ -765,10 +764,8 @@ xbsd_write_bootstrap(void)
|
||||
sector = get_start_sect(xbsd_part);
|
||||
#endif
|
||||
|
||||
if (lseek(dev_fd, sector * SECTOR_SIZE, SEEK_SET) == -1)
|
||||
fdisk_fatal(unable_to_seek);
|
||||
if (BSD_BBSIZE != write(dev_fd, disklabelbuffer, BSD_BBSIZE))
|
||||
fdisk_fatal(unable_to_write);
|
||||
seek_sector(sector);
|
||||
xwrite(dev_fd, disklabelbuffer, BSD_BBSIZE);
|
||||
|
||||
#if defined(__alpha__)
|
||||
printf("Bootstrap installed on %s\n", disk_device);
|
||||
@ -938,9 +935,8 @@ xbsd_readlabel(struct partition *p)
|
||||
sector = 0;
|
||||
#endif
|
||||
|
||||
if (lseek(dev_fd, sector * SECTOR_SIZE, SEEK_SET) == -1)
|
||||
fdisk_fatal(unable_to_seek);
|
||||
if (BSD_BBSIZE != read(dev_fd, disklabelbuffer, BSD_BBSIZE))
|
||||
seek_sector(sector);
|
||||
if (BSD_BBSIZE != full_read(dev_fd, disklabelbuffer, BSD_BBSIZE))
|
||||
fdisk_fatal(unable_to_read);
|
||||
|
||||
memmove(d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
|
||||
@ -984,15 +980,12 @@ xbsd_writelabel(struct partition *p)
|
||||
|
||||
#if defined(__alpha__) && BSD_LABELSECTOR == 0
|
||||
alpha_bootblock_checksum(disklabelbuffer);
|
||||
if (lseek(dev_fd, 0, SEEK_SET) == -1)
|
||||
fdisk_fatal(unable_to_seek);
|
||||
if (BSD_BBSIZE != write(dev_fd, disklabelbuffer, BSD_BBSIZE))
|
||||
fdisk_fatal(unable_to_write);
|
||||
seek_sector(0);
|
||||
xwrite(dev_fd, disklabelbuffer, BSD_BBSIZE);
|
||||
#else
|
||||
if (lseek(dev_fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1)
|
||||
fdisk_fatal(unable_to_seek);
|
||||
if (sizeof(struct xbsd_disklabel) != write(dev_fd, d, sizeof(struct xbsd_disklabel)))
|
||||
fdisk_fatal(unable_to_write);
|
||||
seek_sector(sector);
|
||||
lseek(dev_fd, BSD_LABELOFFSET, SEEK_CUR);
|
||||
xwrite(dev_fd, d, sizeof(*d));
|
||||
#endif
|
||||
sync_disks();
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user