Add a -P option to allow skipping newfs when using a vnode-backed

disk. Apparently some people want to use mdmfs as mount_* as a
shortcut for mounting existing file-based file systems.

Note that unlike in the patches from the submitters, this option is
not available in compat mode. Compat mode was supposed to support only
things that mount_mfs used to support. To use this option from fstab,
mdmfs should be called mount_md, not mount_mfs. This distinction has
not always upkept for new options, and those can't be fixed now
without breaking people's systems, but new options should not usually
be allowed in compat mode. (Not sure why -F is allowed there at all.)

PR:		57641
Submitted by:	Ruben de Groot
Submitted independently by: Wojciech A. Koszek, for Urzad Miasta Czestochowa
This commit is contained in:
Dima Dorfman 2006-01-02 01:50:30 +00:00
parent b65bc26736
commit 05b2fd309f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=153961
2 changed files with 22 additions and 6 deletions

View file

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd February 26, 2004
.Dd January 2, 2006
.Dt MDMFS 8
.Os
.Sh NAME
@ -36,7 +36,7 @@
driver
.Sh SYNOPSIS
.Nm
.Op Fl DLlMNSUX
.Op Fl DLlMNPSUX
.Op Fl a Ar maxcontig
.Op Fl b Ar block-size
.Op Fl c Ar cylinders
@ -197,6 +197,13 @@ Specify the mount options with which to mount the file system.
See
.Xr mount 8
for more information.
.It Fl P
Preserve the existing filesystem;
do not run
.Xr newfs 8 .
This only makes sense if
.Fl F
is specified to create a vnode-backed disk.
.It Fl p Ar permissions
Set the file (directory) permissions of the mount point
.Ar mount-point

View file

@ -89,7 +89,7 @@ main(int argc, char **argv)
*mount_arg;
enum md_types mdtype; /* The type of our memory disk. */
bool have_mdtype;
bool detach, softdep, autounit;
bool detach, softdep, autounit, newfs;
char *mtpoint, *unitstr;
char *p;
int ch;
@ -101,6 +101,7 @@ main(int argc, char **argv)
detach = true;
softdep = true;
autounit = false;
newfs = true;
have_mdtype = false;
mdtype = MD_SWAP;
mdname = MD_NAME;
@ -121,7 +122,7 @@ main(int argc, char **argv)
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:PSs:t:Uv:w:X")) != -1)
switch (ch) {
case 'a':
argappend(&newfs_arg, "-a %s", optarg);
@ -195,6 +196,11 @@ main(int argc, char **argv)
case 'o':
argappend(&mount_arg, "-o %s", optarg);
break;
case 'P':
if (compat)
usage();
newfs = false;
break;
case 'p':
if (compat)
usage();
@ -263,6 +269,8 @@ main(int argc, char **argv)
mdtype = MD_SWAP;
if (softdep)
argappend(&newfs_arg, "-U");
if (mdtype != MD_VNODE && !newfs)
errx(1, "-P requires a vnode-backed disk");
/* Do the work. */
if (detach && !autounit)
@ -271,7 +279,8 @@ main(int argc, char **argv)
do_mdconfig_attach_au(mdconfig_arg, mdtype);
else
do_mdconfig_attach(mdconfig_arg, mdtype);
do_newfs(newfs_arg);
if (newfs)
do_newfs(newfs_arg);
do_mount(mount_arg, mtpoint);
do_mtptsetup(mtpoint, &mi);
@ -666,7 +675,7 @@ usage(void)
name = "mdmfs";
if (!compat)
fprintf(stderr,
"usage: %s [-DLlMNSUX] [-a maxcontig] [-b block-size] [-c cylinders]\n"
"usage: %s [-DLlMNPSUX] [-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"