From owner-freebsd-bugs@FreeBSD.ORG Mon Oct 6 01:50:25 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2E94E16A4B3 for ; Mon, 6 Oct 2003 01:50:25 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id F41F243FF7 for ; Mon, 6 Oct 2003 01:50:22 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h968oMFY055644 for ; Mon, 6 Oct 2003 01:50:22 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h968oMAY055643; Mon, 6 Oct 2003 01:50:22 -0700 (PDT) (envelope-from gnats) Resent-Date: Mon, 6 Oct 2003 01:50:22 -0700 (PDT) Resent-Message-Id: <200310060850.h968oMAY055643@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ruben de Groot Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7451616A4B3 for ; Mon, 6 Oct 2003 01:45:51 -0700 (PDT) Received: from ei.bzerk.org (ei.xs4all.nl [213.84.67.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 05F1443FDF for ; Mon, 6 Oct 2003 01:45:50 -0700 (PDT) (envelope-from ruben@3vilHaX0rCave.bzerk.org) Received: from ei.bzerk.org (BOFH@localhost [127.0.0.1]) by ei.bzerk.org (8.12.10/8.12.10) with ESMTP id h968kwl3030880 for ; Mon, 6 Oct 2003 10:46:58 +0200 (CEST) (envelope-from ruben@ei.bzerk.org) Received: (from ruben@localhost) by ei.bzerk.org (8.12.10/8.12.10/Submit) id h968kwdg030879; Mon, 6 Oct 2003 10:46:58 +0200 (CEST) (envelope-from ruben) Message-Id: <200310060846.h968kwdg030879@ei.bzerk.org> Date: Mon, 6 Oct 2003 10:46:58 +0200 (CEST) From: Ruben de Groot To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/57641: [patch] missing option in mdmfs (mount_mfs) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Ruben de Groot List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Oct 2003 08:50:25 -0000 >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: