misc/90415: Add -Z (no newfs) to sbin/mount_mfs. Use with
existing vnode backed devices between reboots.
L. Jason Godsey
lannygodsey at yahoo.com
Thu Dec 15 05:40:06 PST 2005
The following reply was made to PR misc/90415; it has been noted by GNATS.
From: "L. Jason Godsey" <lannygodsey at yahoo.com>
To: bug-followup at 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);
More information about the freebsd-bugs
mailing list