Source-Changes-HG archive

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

[src/trunk]: src/sbin/newfs Support wedge names.



details:   https://anonhg.NetBSD.org/src/rev/d4989975b329
branches:  trunk
changeset: 333253:d4989975b329
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Oct 25 16:47:23 2014 +0000

description:
Support wedge names.

before:
    newfs dk1        - formats /dev/rdk1
    newfs rdk1       - cannot open /dev/rrdk1
    newfs /dev/dk1   - /dev/dk1 is a block-device, use raw device
    newfs /dev/rdk1  - formats /dev/rdk1

now:
    newfs dk1        - formats /dev/rdk1
    newfs rdk1       - cannot open /dev/rrdk1
    newfs /dev/dk1   - formats /dev/rdk1 (*)
    newfs /dev/rdk1  - formats /dev/rdk1
    newfs NAME=wedge - formats /dev/rdk1

(*) getfsspecname() returns the block device which must be translated.
    Passing a block device manually cannot be distinguished from this case.

diffstat:

 sbin/newfs/newfs.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (42 lines):

diff -r 3491ea3019e5 -r d4989975b329 sbin/newfs/newfs.c
--- a/sbin/newfs/newfs.c        Sat Oct 25 15:07:13 2014 +0000
+++ b/sbin/newfs/newfs.c        Sat Oct 25 16:47:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: newfs.c,v 1.111 2012/06/30 15:34:01 tsutsui Exp $      */
+/*     $NetBSD: newfs.c,v 1.112 2014/10/25 16:47:23 mlelstv Exp $      */
 
 /*
  * Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@
 #if 0
 static char sccsid[] = "@(#)newfs.c    8.13 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: newfs.c,v 1.111 2012/06/30 15:34:01 tsutsui Exp $");
+__RCSID("$NetBSD: newfs.c,v 1.112 2014/10/25 16:47:23 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -242,7 +242,10 @@
        struct statvfs *mp;
        struct stat sb;
        int ch, fsi, fso, len, n, Fflag, Iflag, Zflag;
-       char *s1, *s2, *special;
+       const char *s1, *special, *raw;
+       char *s2;
+       char specname[MAXPATHLEN];
+       char rawname[MAXPATHLEN];
        const char *opstring;
        int byte_sized = 0;
 #ifdef MFS
@@ -490,6 +493,11 @@
                                fso = fsi;
                }
        } else {        /* !Fflag && !mfs */
+               special = getfsspecname(specname, sizeof(specname), special);
+               raw = getdiskrawname(rawname, sizeof(rawname), special);
+               if (raw != NULL)
+                       special = raw;
+
                fsi = opendisk(special, O_RDONLY, device, sizeof(device), 0);
                special = device;
                if (fsi < 0 || fstat(fsi, &sb) == -1)



Home | Main Index | Thread Index | Old Index