- don't free user-supplied string (via -e)
[oweals/busybox.git] / util-linux / fdisk_osf.c
index 30c42553b7841121c2ce6d9ada9f10cc415b6991..c50ee9b1652111432c0814a8850f3b395a695b71 100644 (file)
@@ -516,7 +516,7 @@ xbsd_print_disklabel(int show_all)
                printf("disk: %.*s\n", (int) sizeof(lp->d_typename), lp->d_typename);
                printf("label: %.*s\n", (int) sizeof(lp->d_packname), lp->d_packname);
                printf("flags: ");
-               print_flags_separated(d_masks, "removable\0""ecc\0""badsect\0", lp->d_flags, " "); 
+               print_flags_separated(d_masks, "removable\0""ecc\0""badsect\0", lp->d_flags, " ");
                bb_putchar('\n');
                /* On various machines the fields of *lp are short/int/long */
                /* In order to avoid problems, we cast them all to long. */
@@ -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;