From nobody@FreeBSD.org  Thu Dec 15 02:45:11 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 81C0D16A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 15 Dec 2005 02:45:11 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 217ED43D5C
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 15 Dec 2005 02:45:11 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id jBF2jAdu006145
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 15 Dec 2005 02:45:11 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id jBF2jASe006144;
	Thu, 15 Dec 2005 02:45:10 GMT
	(envelope-from nobody)
Message-Id: <200512150245.jBF2jASe006144@www.freebsd.org>
Date: Thu, 15 Dec 2005 02:45:10 GMT
From: Lanny Jason Godsey <lannygodsey@yahoo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Add -Z (no newfs) to sbin/mount_mfs.  Use with existing vnode backed devices between reboots.
X-Send-Pr-Version: www-2.3

>Number:         90415
>Category:       bin
>Synopsis:       [patch] Add -Z (no newfs) to mount_mfs(8).  Use with existing vnode backed devices between reboots.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    matteo
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 15 02:50:05 GMT 2005
>Closed-Date:    Tue Feb 13 09:25:03 GMT 2007
>Last-Modified:  Tue Feb 13 09:25:03 GMT 2007
>Originator:     Lanny Jason Godsey
>Release:        RELENG_6_0
>Organization:
>Environment:
FreeBSD ne1.yournix.com 6.0-RELEASE FreeBSD 6.0-RELEASE #6: Mon Dec  5 11:48:50 EST 2005     root@ne1.yournix.com:/usr/obj/usr/src/sys/YOURNIX  i386
   
>Description:
Add -Z (no newfs) to sbin/mount_mfs.  Use with existing vnode backed devices between reboots.

ne1# cat /etc/fstab
md     /fs             mfs     rw,noatime,-Z,-F=/home/fs.img  0       0


ne1# df
/dev/md2       495726       6   456062     0%    /fs


ne1# mdconfig -l -u md2
md2     vnode     500M  /local/fs.img

>How-To-Repeat:
              
>Fix:
Index: mdmfs.8
===================================================================
RCS file: /usr/ncvs/src/sbin/mdmfs/mdmfs.8,v
retrieving revision 1.20
diff -u -r1.20 mdmfs.8
--- mdmfs.8     17 May 2004 08:35:41 -0000      1.20
+++ mdmfs.8     15 Dec 2005 02:43:26 -0000
@@ -263,6 +263,9 @@
 .It Fl X
 Print what command will be run before running it, and
 other assorted debugging information.
+.It Fl Z
+Skip newfs(8) command.  Use with existing vnode backed
+devices between boots.
 .El
 .Pp
 The
Index: mdmfs.c
===================================================================
RCS file: /usr/ncvs/src/sbin/mdmfs/mdmfs.c,v
retrieving revision 1.23
diff -u -r1.23 mdmfs.c
--- mdmfs.c     10 Feb 2005 09:19:30 -0000      1.23
+++ mdmfs.c     15 Dec 2005 02:43:26 -0000
@@ -90,6 +90,7 @@
        enum md_types mdtype;           /* The type of our memory disk. */
        bool have_mdtype;
        bool detach, softdep, autounit;
+       bool no_newfs;
        char *mtpoint, *unitstr;
        char *p;
        int ch;
@@ -98,6 +99,7 @@

        /* Misc. initialization. */
        (void)memset(&mi, '\0', sizeof(mi));
+       no_newfs = false;
        detach = true;
        softdep = true;
        autounit = false;
@@ -121,7 +123,7 @@
                compat = true;

        while ((ch = getopt(argc, argv,
-           "a:b:Cc:Dd:e:F:f:hi:LlMm:Nn:O:o:p:Ss:t:Uv:w:X")) != -1)
+           "a:b:Cc:Dd:e:F:f:hi:LlMm:Nn:O:o:p:Ss:t:Uv:w:XZ")) != -1)
                switch (ch) {
                case 'a':
                        argappend(&newfs_arg, "-a %s", optarg);
@@ -228,6 +230,9 @@
                                usage();
                        debug = true;
                        break;
+               case 'Z':
+                       no_newfs = true;
+                       break;
                default:
                        usage();
                }
@@ -271,7 +276,8 @@
                do_mdconfig_attach_au(mdconfig_arg, mdtype);
        else
                do_mdconfig_attach(mdconfig_arg, mdtype);
-       do_newfs(newfs_arg);
+       if (!no_newfs)
+               do_newfs(newfs_arg);
        do_mount(mount_arg, mtpoint);
        do_mtptsetup(mtpoint, &mi);

@@ -670,13 +676,13 @@
                name = "mdmfs";
        if (!compat)
                fprintf(stderr,
-"usage: %s [-DLlMNSUX] [-a maxcontig] [-b block-size] [-c cylinders]\n"
+"usage: %s [-DLlMNSUXZ] [-a maxcontig] [-b block-size] [-c cylinders]\n"
 "\t[-d rotdelay] [-e maxbpg] [-F file] [-f frag-size] [-i bytes]\n"
 "\t[-m percent-free] [-n rotational-positions] [-O optimization]\n"
 "\t[-o mount-options] [-p permissions] [-s size] [-v version]\n"
 "\t[-w user:group] md-device mount-point\n", name);
        fprintf(stderr,
-"usage: %s -C [-lNU] [-a maxcontig] [-b block-size] [-c cylinders]\n"
+"usage: %s -C [-lNUZ] [-a maxcontig] [-b block-size] [-c cylinders]\n"
 "\t[-d rotdelay] [-e maxbpg] [-F file] [-f frag-size] [-i bytes]\n"
 "\t[-m percent-free] [-n rotational-positions] [-O optimization]\n"
 "\t[-o mount-options] [-s size] [-v version] md-device mount-point\n", name);

>Release-Note:
>Audit-Trail:

From: "L. Jason Godsey" <lannygodsey@yahoo.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: misc/90415: Add -Z (no newfs) to sbin/mount_mfs.  Use with existing vnode backed devices between reboots.
Date: Thu, 15 Dec 2005 05:30:00 -0800 (PST)

 Revised patch, if skipping newfs, you need to run fsck.
 
 Index: mdmfs.8
 ===================================================================
 RCS file: /usr/ncvs/src/sbin/mdmfs/mdmfs.8,v
 retrieving revision 1.20
 diff -u -r1.20 mdmfs.8
 --- mdmfs.8     17 May 2004 08:35:41 -0000      1.20
 +++ mdmfs.8     15 Dec 2005 13:28:17 -0000
 @@ -263,6 +263,14 @@
  .It Fl X
  Print what command will be run before running it, and
  other assorted debugging information.
 +.It Fl y
 +Force fsck to answer Yes if using existing vnode device.
 +(see the
 +.Fl Z
 +option).
 +.It Fl Z
 +Skip newfs(8) command.  Use with existing vnode backed
 +devices between boots.
  .El
  .Pp
  The
 Index: mdmfs.c
 ===================================================================
 RCS file: /usr/ncvs/src/sbin/mdmfs/mdmfs.c,v
 retrieving revision 1.23
 diff -u -r1.23 mdmfs.c
 --- mdmfs.c     10 Feb 2005 09:19:30 -0000      1.23
 +++ mdmfs.c     15 Dec 2005 13:28:17 -0000
 @@ -77,6 +77,7 @@
  static void     do_mount(const char *, const char *);
  static void     do_mtptsetup(const char *, struct mtpt_info *);
  static void     do_newfs(const char *);
 +static void     do_fsck(const char *);
  static void     extract_ugid(const char *, struct mtpt_info *);
  static int      run(int *, const char *, ...) __printflike(2, 3);
  static void     usage(void);
 @@ -86,10 +87,11 @@
  {
         struct mtpt_info mi;            /* Mountpoint info. */
         char *mdconfig_arg, *newfs_arg, /* Args to helper programs. */
 -           *mount_arg;
 +           *mount_arg, *fsck_arg;
         enum md_types mdtype;           /* The type of our memory disk.
 */
         bool have_mdtype;
         bool detach, softdep, autounit;
 +       bool no_newfs;
         char *mtpoint, *unitstr;
         char *p;
         int ch;
 @@ -98,6 +100,7 @@
 
         /* Misc. initialization. */
         (void)memset(&mi, '\0', sizeof(mi));
 +       no_newfs = false;
         detach = true;
         softdep = true;
         autounit = false;
 @@ -113,6 +116,7 @@
          */
         mdconfig_arg = strdup("");
         newfs_arg = strdup("");
 +       fsck_arg = strdup("");
         mount_arg = strdup("");
 
         /* If we were started as mount_mfs or mfs, imply -C. */
 @@ -121,7 +125,7 @@
                 compat = true;
 
         while ((ch = getopt(argc, argv,
 -           "a:b:Cc:Dd:e:F:f:hi:LlMm:Nn:O:o:p:Ss:t:Uv:w:X")) != -1)
 +           "a:b:Cc:Dd:e:F:f:hi:LlMm:Nn:O:o:p:Ss:t:Uv:w:XyZ")) != -1)
                 switch (ch) {
                 case 'a':
                         argappend(&newfs_arg, "-a %s", optarg);
 @@ -228,6 +232,12 @@
                                 usage();
                         debug = true;
                         break;
 +               case 'y':
 +                       argappend(&fsck_arg, "-y");
 +                       break;
 +               case 'Z':
 +                       no_newfs = true;
 +                       break;
                 default:
                         usage();
                 }
 @@ -271,7 +281,11 @@
                 do_mdconfig_attach_au(mdconfig_arg, mdtype);
         else
                 do_mdconfig_attach(mdconfig_arg, mdtype);
 -       do_newfs(newfs_arg);
 +       if (!no_newfs) {
 +               do_newfs(newfs_arg);
 +       } else {
 +               do_fsck(fsck_arg);
 +       }
         do_mount(mount_arg, mtpoint);
         do_mtptsetup(mtpoint, &mi);
 
 @@ -488,6 +502,15 @@
                 errx(1, "newfs exited with error code %d", rv);
  }
 
 +static void
 +do_fsck(const char *args)
 +{
 +       int rv;
 +       rv = run(NULL, "%s -t ufs %s /dev/%s%d", "/sbin/fsck", args,
 mdname, unit);
 +       if (rv)
 +               errx(1, "fsck exited with error code %d", rv);
 +}
 +
  /*
   * 'str' should be a user and group name similar to the last argument
   * to chown(1); i.e., a user, followed by a colon, followed by a
 @@ -670,13 +693,13 @@
                 name = "mdmfs";
         if (!compat)
                 fprintf(stderr,
 -"usage: %s [-DLlMNSUX] [-a maxcontig] [-b block-size] [-c
 cylinders]\n"
 +"usage: %s [-DLlMNSUXZ] [-a maxcontig] [-b block-size] [-c
 cylinders]\n"
  "\t[-d rotdelay] [-e maxbpg] [-F file] [-f frag-size] [-i bytes]\n"
  "\t[-m percent-free] [-n rotational-positions] [-O optimization]\n"
  "\t[-o mount-options] [-p permissions] [-s size] [-v version]\n"
  "\t[-w user:group] md-device mount-point\n", name);
         fprintf(stderr,
 -"usage: %s -C [-lNU] [-a maxcontig] [-b block-size] [-c cylinders]\n"
 +"usage: %s -C [-lNUZ] [-a maxcontig] [-b block-size] [-c cylinders]\n"
  "\t[-d rotdelay] [-e maxbpg] [-F file] [-f frag-size] [-i bytes]\n"
  "\t[-m percent-free] [-n rotational-positions] [-O optimization]\n"
  "\t[-o mount-options] [-s size] [-v version] md-device mount-point\n",
 name);
 
State-Changed-From-To: open->closed 
State-Changed-By: matteo 
State-Changed-When: Tue Feb 13 09:24:09 UTC 2007 
State-Changed-Why:  
The "-P" option is available to accomplish this task. 


Responsible-Changed-From-To: freebsd-bugs->matteo 
Responsible-Changed-By: matteo 
Responsible-Changed-When: Tue Feb 13 09:24:09 UTC 2007 
Responsible-Changed-Why:  
The "-P" option is available to accomplish this task. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=90415 
>Unformatted:
