- don't free user-supplied string (via -e)
[oweals/busybox.git] / util-linux / fdisk_sun.c
index e595444c436bd471e9b05533c09db70bd79a4d9e..d1a436b4ae0de93b676af1bffa6f13abc5c42556 100644 (file)
@@ -181,7 +181,7 @@ sun_autoconfigure_scsi(void)
                id[0] & 0xff,
                (id[0]>>8) & 0xff
        );
-       pfd = fopen("/proc/scsi/scsi", "r");
+       pfd = fopen_for_read("/proc/scsi/scsi");
        if (!pfd) {
                return NULL;
        }
@@ -230,8 +230,7 @@ static void
 create_sunlabel(void)
 {
        struct hd_geometry geometry;
-       unsigned int ndiv;
-       int i;
+       unsigned ndiv;
        unsigned char c;
        const struct sun_predefined_drives *p = NULL;
 
@@ -241,6 +240,7 @@ create_sunlabel(void)
        memset(MBRbuffer, 0, sizeof(MBRbuffer));
        sunlabel->magic = SUN_SSWAP16(SUN_LABEL_MAGIC);
        if (!floppy) {
+               unsigned i;
                puts("Drive type\n"
                 "   ?   auto configure\n"
                 "   0   custom (with hardware detected defaults)");
@@ -722,9 +722,6 @@ sun_write_table(void)
        while (ush < (unsigned short *)(&sunlabel->csum))
                csum ^= *ush++;
        sunlabel->csum = csum;
-       if (lseek(dev_fd, 0, SEEK_SET) < 0)
-               fdisk_fatal(unable_to_seek);
-       if (write(dev_fd, sunlabel, SECTOR_SIZE) != SECTOR_SIZE)
-               fdisk_fatal(unable_to_write);
+       write_sector(0, sunlabel);
 }
 #endif /* SUN_LABEL */