Date: Mon, 6 Oct 2003 10:46:58 +0200 (CEST) From: Ruben de Groot <rdg@bzerk.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/57641: [patch] missing option in mdmfs (mount_mfs) Message-ID: <200310060846.h968kwdg030879@ei.bzerk.org> Resent-Message-ID: <200310060850.h968oMAY055643@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 57641 >Category: bin >Synopsis: [patch] missing option in mdmfs (mount_mfs) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Oct 06 01:50:22 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Ruben de Groot >Release: FreeBSD 5.1-CURRENT i386 >Organization: >Environment: System: FreeBSD ei.bzerk.org 5.1-CURRENT FreeBSD 5.1-CURRENT #1: Thu Oct 2 09:35:43 CEST 2003 root@ei.bzerk.org:/usr/build/usr/obj/usr/build/current/usr/src/sys/SMP-EI i386 >Description: Currently, mdmfs will allways do a newfs before mounting a mfs. When using filesystem image files (MD_VNODE), an option to skip the newfs part, preserving the existing filesystem would be desirable. >How-To-Repeat: root@caliban:/root> tail -1 /etc/fstab /dev/md1 /jails/jail1 mfs rw,-F/jails/vnodes/jail1fs,async 0 0 root@caliban:/root> mount /jails/jail1 root@caliban:/root> touch /jails/jail1/IMPORTANT_DATA root@caliban:/root> umount /jails/jail1 root@caliban:/root> mount /jails/jail1 root@caliban:/root> ls /jails/jail1 root@caliban:/root> >Fix: Add a -P option to mdmfs (and mount_mfs) that will skip the do_newfs() part. Adding P to the fstab line above like this: /dev/md1 /jails/jail1 mfs rw,-PF/jails/vnodes/jail1fs,async 0 0 will preserve data between mounts. The following patch adds the -P option (patch for HEAD) : diff -u sbin/mdmfs.orig/mdmfs.8 sbin/mdmfs/mdmfs.8 --- sbin/mdmfs.orig/mdmfs.8 Wed Aug 6 04:41:52 2003 +++ sbin/mdmfs/mdmfs.8 Mon Oct 6 08:48:27 2003 @@ -36,7 +36,7 @@ driver .Sh SYNOPSIS .Nm -.Op Fl DLMNSUX +.Op Fl DLMNPSUX .Op Fl a Ar maxcontig .Op Fl b Ar block-size .Op Fl c Ar cylinders @@ -57,7 +57,7 @@ .Ar mount-point .Nm .Fl C -.Op Fl NU +.Op Fl NPU .Op Fl a Ar maxcontig .Op Fl b Ar block-size .Op Fl c Ar cylinders @@ -195,6 +195,11 @@ See .Xr mount 8 for more information. +.It Fl P +Preserve existing filesystem. Do not run newfs. This only makes sense if +.Fl F +is specified +.Pq Dv MD_VNODE . .It Fl p Ar permissions Set the file (directory) permissions of the mount point .Ar mount-point diff -u sbin/mdmfs.orig/mdmfs.c sbin/mdmfs/mdmfs.c --- sbin/mdmfs.orig/mdmfs.c Fri Oct 3 13:50:18 2003 +++ sbin/mdmfs/mdmfs.c Sat Oct 4 13:41:14 2003 @@ -89,7 +89,7 @@ *mount_arg; enum md_types mdtype; /* The type of our memory disk. */ bool have_mdtype; - bool detach, softdep, autounit; + bool detach, softdep, autounit, no_newfs; char *mtpoint, *unitstr; char ch, *p; void *set; @@ -99,6 +99,7 @@ detach = true; softdep = true; autounit = false; + no_newfs = false; have_mdtype = false; mdname = MD_NAME; mdnamelen = strlen(mdname); @@ -118,7 +119,7 @@ compat = true; while ((ch = getopt(argc, argv, - "a:b:Cc:Dd:e:F:f:hi:LMm:Nn:O:o:p:Ss:t:Uv:w:X")) != -1) + "a:b:Cc:Dd:e:F:f:hi:LMm:Nn:O:o:Pp:Ss:t:Uv:w:X")) != -1) switch (ch) { case 'a': argappend(&newfs_arg, "-a %s", optarg); @@ -189,6 +190,9 @@ case 'o': argappend(&mount_arg, "-o %s", optarg); break; + case 'P': + no_newfs = true; + break; case 'p': if (compat) usage(); @@ -264,7 +268,8 @@ do_mdconfig_attach_au(mdconfig_arg, mdtype); else do_mdconfig_attach(mdconfig_arg, mdtype); - do_newfs(newfs_arg); + if (!no_newfs || (mdtype != MD_VNODE)) + do_newfs(newfs_arg); do_mount(mount_arg, mtpoint); do_mtptsetup(mtpoint, &mi); @@ -661,13 +666,13 @@ name = "mdmfs"; if (!compat) fprintf(stderr, -"usage: %s [-DLMNSUX] [-a maxcontig [-b block-size] [-c cylinders]\n" +"usage: %s [-DLMNPSUX] [-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", name); fprintf(stderr, -"usage: %s -C [-NU] [-a maxcontig] [-b block-size] [-c cylinders]\n" +"usage: %s -C [-NPU] [-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); >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200310060846.h968kwdg030879>