Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/newfs_msdos fix regressions after split.



details:   https://anonhg.NetBSD.org/src/rev/f0a9a32112f0
branches:  trunk
changeset: 784264:f0a9a32112f0
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jan 23 15:29:15 2013 +0000

description:
fix regressions after split.

diffstat:

 sbin/newfs_msdos/mkfs_msdos.c  |  21 ++++++++++-------
 sbin/newfs_msdos/mkfs_msdos.h  |  50 +++++++++++++++++++++---------------------
 sbin/newfs_msdos/newfs_msdos.c |   6 ++--
 3 files changed, 40 insertions(+), 37 deletions(-)

diffs (169 lines):

diff -r 8213b659b8ec -r f0a9a32112f0 sbin/newfs_msdos/mkfs_msdos.c
--- a/sbin/newfs_msdos/mkfs_msdos.c     Wed Jan 23 15:02:52 2013 +0000
+++ b/sbin/newfs_msdos/mkfs_msdos.c     Wed Jan 23 15:29:15 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkfs_msdos.c,v 1.1 2013/01/21 20:28:38 christos Exp $  */
+/*     $NetBSD: mkfs_msdos.c,v 1.2 2013/01/23 15:29:15 christos Exp $  */
 
 /*
  * Copyright (c) 1998 Robert Nordier
@@ -33,7 +33,7 @@
 static const char rcsid[] =
   "$FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $";
 #else
-__RCSID("$NetBSD: mkfs_msdos.c,v 1.1 2013/01/21 20:28:38 christos Exp $");
+__RCSID("$NetBSD: mkfs_msdos.c,v 1.2 2013/01/23 15:29:15 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -258,7 +258,7 @@
        warnx("Cannot specify both block size and sectors per cluster");
        return -1;
     }
-    if (strlen(o.OEM_string) > 8) {
+    if (o.OEM_string && strlen(o.OEM_string) > 8) {
        warnx("%s: bad OEM string", o.OEM_string);
        return -1;
     }
@@ -280,9 +280,10 @@
        }
        pos = lseek(fd, 0, SEEK_SET);
     } else if ((fd = open(fname, o.no_create ? O_RDONLY : O_RDWR)) == -1 ||
-       fstat(fd, &sb))
+       fstat(fd, &sb)) {
        warn("%s", fname);
        return -1;
+    }
     if (!o.no_create)
        if (check_mounted(fname, sb.st_mode) == -1)
            return -1;
@@ -333,7 +334,7 @@
        }
     }
 
-    if (!oklabel(o.volume_label)) {
+    if (o.volume_label && !oklabel(o.volume_label)) {
        warnx("%s: bad volume label", o.volume_label);
        return -1;
     }
@@ -385,12 +386,12 @@
        }
        if (o.block_size < bpb.bps) {
            warnx("block size (%u) is too small; minimum is %u",
-                o.block_size, bpb.bps);
+               o.block_size, bpb.bps);
            return -1;
        }
        if (o.block_size > bpb.bps * MAXSPC) {
            warnx("block size (%u) is too large; maximum is %u",
-                o.block_size, bpb.bps * MAXSPC);
+               o.block_size, bpb.bps * MAXSPC);
            return -1;
        }
        bpb.spc = o.block_size / bpb.bps;
@@ -435,8 +436,10 @@
        bname = o.bootstrap;
        if (!strchr(bname, '/')) {
            snprintf(buf, sizeof(buf), "/boot/%s", bname);
-           if (!(bname = strdup(buf)))
-               err(1, NULL);
+           if (!(bname = strdup(buf))) {
+               warn(NULL);
+               return -1;
+           }
        }
        if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, &sb)) {
            warn("%s", bname);
diff -r 8213b659b8ec -r f0a9a32112f0 sbin/newfs_msdos/mkfs_msdos.h
--- a/sbin/newfs_msdos/mkfs_msdos.h     Wed Jan 23 15:02:52 2013 +0000
+++ b/sbin/newfs_msdos/mkfs_msdos.h     Wed Jan 23 15:29:15 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkfs_msdos.h,v 1.1 2013/01/21 20:28:38 christos Exp $  */
+/*     $NetBSD: mkfs_msdos.h,v 1.2 2013/01/23 15:29:15 christos Exp $  */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -35,32 +35,32 @@
 #include <sys/types.h>
 #include <stdbool.h>
 #define ALLOPTS \
-AOPT('@', off_t, offset, "Offset in device") \
-AOPT('B', char *, bootstrap, "Bootstrap file") \
-AOPT('C', off_t, create_size, "Create file") \
-AOPT('F', uint8_t,  fat_type, "FAT type (12, 16, or 32)") \
-AOPT('I', uint32_t, volume_id, "Volume ID") \
-AOPT('L', char *, volume_label, "Volume Label") \
-AOPT('N', bool, no_create, "Don't create filesystem, print params only") \
-AOPT('O', char *, OEM_string, "OEM string") \
-AOPT('S', uint16_t, bytes_per_sector, "Bytes per sector") \
-AOPT('a', uint32_t, sectors_per_fat, "Sectors per FAT") \
-AOPT('b', uint32_t, block_size, "Block size") \
-AOPT('c', uint8_t, sectors_per_cluster, "Sectors per cluster") \
-AOPT('e', uint16_t, directory_entries, "Directory entries") \
-AOPT('f', char *, floppy, "Standard format floppies (160,180,320,360,640,720,1200,1232,1440,2880)") \
-AOPT('h', uint16_t, drive_heads, "Drive heads") \
-AOPT('i', uint16_t, info_sector, "Info sector") \
-AOPT('k', uint16_t, backup_sector, "Backup sector") \
-AOPT('m', uint8_t, media_descriptor, "Media descriptor") \
-AOPT('n', uint8_t, num_FAT, "Number of FATs") \
-AOPT('o', uint32_t, hidden_sectors, "Hidden sectors") \
-AOPT('r', uint16_t, reserved_sectors, "Reserved sectors") \
-AOPT('s', uint32_t, size, "File System size") \
-AOPT('u', uint16_t, sectors_per_track, "Sectors per track")
+AOPT('@', off_t, offset, 0, "Offset in device") \
+AOPT('B', char *, bootstrap, -1, "Bootstrap file") \
+AOPT('C', off_t, create_size, 0, "Create file") \
+AOPT('F', uint8_t,  fat_type, 12, "FAT type (12, 16, or 32)") \
+AOPT('I', uint32_t, volume_id, 0, "Volume ID") \
+AOPT('L', char *, volume_label, -1, "Volume Label") \
+AOPT('N', bool, no_create, -2, "Don't create filesystem, print params only") \
+AOPT('O', char *, OEM_string, -1, "OEM string") \
+AOPT('S', uint16_t, bytes_per_sector, 1, "Bytes per sector") \
+AOPT('a', uint32_t, sectors_per_fat, 1, "Sectors per FAT") \
+AOPT('b', uint32_t, block_size, 1, "Block size") \
+AOPT('c', uint8_t, sectors_per_cluster, 1, "Sectors per cluster") \
+AOPT('e', uint16_t, directory_entries, 1, "Directory entries") \
+AOPT('f', char *, floppy, -1, "Standard format floppies (160,180,320,360,640,720,1200,1232,1440,2880)") \
+AOPT('h', uint16_t, drive_heads, 1, "Drive heads") \
+AOPT('i', uint16_t, info_sector, 1, "Info sector") \
+AOPT('k', uint16_t, backup_sector, 1, "Backup sector") \
+AOPT('m', uint8_t, media_descriptor, 0, "Media descriptor") \
+AOPT('n', uint8_t, num_FAT, 1, "Number of FATs") \
+AOPT('o', uint32_t, hidden_sectors, 0, "Hidden sectors") \
+AOPT('r', uint16_t, reserved_sectors, 1, "Reserved sectors") \
+AOPT('s', uint32_t, size, 1, "File System size") \
+AOPT('u', uint16_t, sectors_per_track, 1, "Sectors per track")
 
 struct msdos_options {
-#define AOPT(a, b, c, d)       b c;
+#define AOPT(_opt, _type, _name, _min, _desc) _type _name;
 ALLOPTS
 #undef AOPT    
        uint32_t volume_id_set:1;
diff -r 8213b659b8ec -r f0a9a32112f0 sbin/newfs_msdos/newfs_msdos.c
--- a/sbin/newfs_msdos/newfs_msdos.c    Wed Jan 23 15:02:52 2013 +0000
+++ b/sbin/newfs_msdos/newfs_msdos.c    Wed Jan 23 15:29:15 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: newfs_msdos.c,v 1.41 2013/01/21 20:28:38 christos Exp $        */
+/*     $NetBSD: newfs_msdos.c,v 1.42 2013/01/23 15:29:15 christos Exp $        */
 
 /*
  * Copyright (c) 1998 Robert Nordier
@@ -33,7 +33,7 @@
 static const char rcsid[] =
   "$FreeBSD: src/sbin/newfs_msdos/newfs_msdos.c,v 1.15 2000/10/10 01:49:37 wollman Exp $";
 #else
-__RCSID("$NetBSD: newfs_msdos.c,v 1.41 2013/01/21 20:28:38 christos Exp $");
+__RCSID("$NetBSD: newfs_msdos.c,v 1.42 2013/01/23 15:29:15 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -243,7 +243,7 @@
        char o;
        const char *h;
 } opts[] = {
-#define AOPT(a, b, c, d) { a, d },
+#define AOPT(_opt, _type, _name, _min, _desc) { _opt, _desc },
 ALLOPTS
 #undef AOPT
 };



Home | Main Index | Thread Index | Old Index