Date: Sat, 04 Aug 2001 17:26:12 -0700 From: Dima Dorfman <dima@unixfreak.org> To: Kris Kennaway <kris@obsecurity.org> Cc: current@FreeBSD.org Subject: Re: md/mdmfs bugs Message-ID: <20010805002617.471D03E32@bazooka.unixfreak.org> In-Reply-To: <20010729185401.A642@xor.obsecurity.org>; from kris@obsecurity.org on "Sun, 29 Jul 2001 18:54:01 -0700"
next in thread | previous in thread | raw e-mail | index | archive | help
Kris Kennaway <kris@obsecurity.org> writes: > 1) For some reason, my mdmfs line in /etc/fstab always does a chmod > 777 /tmp at mount-time > > /dev/md0 /tmp mfs rw,-s=65536 0 0 As previously threatened, I implemented bug-to-bug compatibility with mount_mfs(). The patch is attached below. Please try it and see if it fixes this problem. Here's an excerpt from the manual page that roughly describes what I did: COMPATIBILITY mdmfs, while designed to be fully compatible with mount_mfs(8), can be useful by itself. Since mount_mfs(8) has some silly defaults, a ``full compatibility'' mode is provided for the case where bug-to-bug compati- bility is desired. Full compatibility is enabled with the -C flag, or by starting mdmfs with mount_ at the beginning of its name (as returned by getprogname(3)). In this mode, only the options which would be accepted by mount_mfs(8) are valid. Furthermore, the following behavior, as done by mount_mfs(8), is duplicated: o The file mode of mount-point is set to 01777 as if -p 1777 was given on the command line. If you have a link from /sbin/mount_mfs to /sbin/mdmfs, you don't need to worry about all that stuff. Just apply the patch below, build it, copy it to /sbin, and umount/mount /tmp; it should DTRT. Please let me know how it works out. Thanks. Index: mdmfs.8 =================================================================== RCS file: /ref/cvsf/src/sbin/mdmfs/mdmfs.8,v retrieving revision 1.6 diff -u -r1.6 mdmfs.8 --- mdmfs.8 2001/07/30 09:13:21 1.6 +++ mdmfs.8 2001/08/05 00:17:02 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD: src/sbin/mdmfs/mdmfs.8,v 1.6 2001/07/30 09:13:21 dd Exp $ .\" -.Dd May 26, 2001 +.Dd August 5, 2001 .Dt MDMFS 8 .Os .Sh NAME @@ -35,7 +35,7 @@ driver .Sh SYNOPSIS .Nm -.Op Fl DLMNSX +.Op Fl DLMNSUX .Op Fl a Ar maxcontig .Op Fl b Ar block-size .Op Fl c Ar cylinders @@ -53,6 +53,24 @@ .Op Fl w Ar user : Ns Ar group .Ar md-device .Ar mount-point +.Nm +.Fl C +.Op Fl NU +.Op Fl a Ar maxcontig +.Op Fl b Ar block-size +.Op Fl c Ar cylinders +.Op Fl d Ar rotdelay +.Op Fl e Ar maxbpg +.Op Fl F Ar file +.Op Fl f Ar frag-size +.Op Fl i Ar bytes +.Op Fl m Ar percent-free +.Op Fl n Ar rotational-positions +.Op Fl O Ar optimization +.Op Fl o Ar mount-options +.Op Fl s Ar size +.Ar md-device +.Ar mount-point .Sh DESCRIPTION The .Nm @@ -110,6 +128,13 @@ option). .It Fl b Ar block-size The block size of the filesystem, in bytes. +.It Fl C +Enable full compatibility mode with +.Xr mount_mfs 8 . +See the +.\" XXX link to another section? +.Em COMPATIBILITY +section for more information. .It Fl c Ar cylinders The number of cylinders per cylinder group in the filesystem. .It Fl D @@ -192,6 +217,13 @@ .Xr malloc 9 backed disks .Pq Dv MD_MALLOC . +.It Fl U +Enable soft-updates on the filesystem. +This is the default, even in compatibility mode, and is accepted only +for compatibility. +It is only really useful to negate the +.Fl S +flag, should such a need occur. .It Fl w Ar user : Ns Ar group Set the owner and group to .Ar user @@ -257,8 +289,46 @@ .Cm async : .Pp .Dl "mdmfs -M -S -o async -s 16m md1 /tmp" +.Sh COMPATIBILITY +.Nm , +while designed to be fully compatible with +.Xr mount_mfs 8 , +can be useful by itself. +Since +.Xr mount_mfs 8 +has some silly defaults, a +.Dq full compatibility +mode is provided for the case where bug-to-bug compatibility is desired. +.Pp +Full compatibility is enabled with the +.Fl C +flag, +or by starting +.Nm +with +.Li mount_ +at the beginning of its name +(as returned by +.Xr getprogname 3 ) . +In this mode, only the options which would be accepted by +.Xr mount_mfs 8 +are valid. +Furthermore, the following behavior, as done by +.Xr mount_mfs 8 , +is duplicated: +.Bl -bullet -offset indent -compat +.It +The file mode of +.Ar mount-point +is set to +.Li 01777 +as if +.Fl p Ar 1777 +was given on the command line. +.El .Sh SEE ALSO .Xr md 4 , +.Xr fstab 5 , .Xr disklabel 8 , .Xr mdconfig 8 , .Xr mount 8 , Index: mdmfs.c =================================================================== RCS file: /ref/cvsf/src/sbin/mdmfs/mdmfs.c,v retrieving revision 1.5 diff -u -r1.5 mdmfs.c --- mdmfs.c 2001/07/30 09:11:17 1.5 +++ mdmfs.c 2001/08/05 00:18:38 @@ -65,6 +65,7 @@ bool mi_have_mode; }; +static bool compat; /* Full compatibility with mount_mfs? */ static bool debug; /* Emit debugging information? */ static bool loudsubs; /* Suppress output from helper programs? */ static bool norun; /* Actually run the helper programs? */ @@ -115,8 +116,12 @@ newfs_arg = strdup(""); mount_arg = strdup(""); + /* If we were started as mount_*, imply -C. */ + if (strncmp(getprogname(), "mount_", 6) == 0) + compat = true; + while ((ch = getopt(ac, av, - "a:b:c:Dd:e:F:f:hi:LMm:Nn:O:o:p:Ss:t:w:X")) != -1) + "a:b:Cc:Dd:e:F:f:hi:LMm:Nn:O:o:p:Ss:t:Uw:X")) != -1) switch (ch) { case 'a': argappend(&newfs_arg, "-a %s", optarg); @@ -124,10 +129,17 @@ case 'b': argappend(&newfs_arg, "-b %s", optarg); break; + case 'C': + if (compat) + usage(); + compat = true; + break; case 'c': argappend(&newfs_arg, "-c %s", optarg); break; case 'D': + if (compat) + usage(); detach = false; break; case 'd': @@ -153,6 +165,8 @@ argappend(&newfs_arg, "-i %s", optarg); break; case 'L': + if (compat) + usage(); loudsubs = true; break; case 'M': @@ -165,6 +179,8 @@ argappend(&newfs_arg, "-m %s", optarg); break; case 'N': + if (compat) + usage(); norun = true; break; case 'n': @@ -177,6 +193,8 @@ argappend(&mount_arg, "-o %s", optarg); break; case 'p': + if (compat) + usage(); if (*optarg >= '0' && *optarg <= '7') mi.mi_mode = strtol(optarg, NULL, 8); if ((mi.mi_mode & ~07777) != 0) @@ -184,15 +202,24 @@ mi.mi_have_mode = true; break; case 'S': + if (compat) + usage(); softdep = false; break; case 's': argappend(&mdconfig_arg, "-s %s", optarg); break; + case 'U': + softdep = true; + break; case 'w': + if (compat) + usage(); extract_ugid(optarg, &mi); break; case 'X': + if (compat) + usage(); debug = true; break; default: @@ -203,6 +230,12 @@ if (ac < 2) usage(); + /* Make compatibility assumptions. */ + if (compat) { + mi.mi_mode = 01777; + mi.mi_have_mode = true; + } + /* Derive 'unit' (global). */ unitstr = av[0]; if (strncmp(unitstr, "/dev/", 5) == 0) @@ -634,12 +667,23 @@ static void usage(void) { + const char *name; - fprintf(stderr, -"usage: %s [-DLMNSX] [-a maxcontig] [-b block-size] [-c cylinders]\n" + if (compat) + name = getprogname(); + else + name = "mdmfs"; + if (!compat) + fprintf(stderr, +"Usage: %s [-DLMNSUX] [-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] [-w user:group]\n" -"\tmd-device mount-point\n", getprogname()); +"\tmd-device mount-point\n", name); + fprintf(stderr, +"Usage: %s -C [-NU] [-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] md-device mount-point\n", name); exit(1); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010805002617.471D03E32>