From 05b2fd309f3e28f6d2bf7015f5007bfe33fc780a Mon Sep 17 00:00:00 2001 From: Dima Dorfman Date: Mon, 2 Jan 2006 01:50:30 +0000 Subject: 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 --- sbin/mdmfs/mdmfs.8 | 11 +++++++++-- sbin/mdmfs/mdmfs.c | 17 +++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'sbin/mdmfs') diff --git a/sbin/mdmfs/mdmfs.8 b/sbin/mdmfs/mdmfs.8 index 39af0cba69bf..3d429885ec3a 100644 --- a/sbin/mdmfs/mdmfs.8 +++ b/sbin/mdmfs/mdmfs.8 @@ -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 diff --git a/sbin/mdmfs/mdmfs.c b/sbin/mdmfs/mdmfs.c index 9d4095cf004c..33c35f9bf99c 100644 --- a/sbin/mdmfs/mdmfs.c +++ b/sbin/mdmfs/mdmfs.c @@ -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" -- cgit v1.2.3