Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Nov 2007 21:46:05 +0100 (CET)
From:      clemens fischer <ino-news@spotteswoode.dnsalias.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        clemens fischer <ino-news@spotteswoode.dnsalias.org>
Subject:   ports/118025: [patch] sysutils/freebsd-snapshot: automounter, mount-points
Message-ID:  <20071113204605.364B8534F2@spotteswoode.dnsalias.org>
Resent-Message-ID: <200711132050.lADKo4tb097727@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         118025
>Category:       ports
>Synopsis:       [patch] sysutils/freebsd-snapshot: automounter, mount-points
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 13 20:50:03 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     clemens fischer
>Release:        FreeBSD 7.0-BETA2 i386
>Organization:
>Environment:
System: FreeBSD spotteswoode.dnsalias.org 7.0-BETA2
FreeBSD 7.0-BETA2 #1: Fri Nov 9 22:38:21 CET 2007
root@spotteswoode.dnsalias.org:/usr/obj/usr/src/sys/spott_fbsd7_i386
i386

>Description:

sysutils/freebsd-snapshot provides a convenient wrapper for maintaining
UFS2 snapshots.  the documentation mentions an optional dependency on
amd(8) to enable unprivileged users to browse snapshots.  this
dependency is mandatory in the current version, ie. the "snapshot"
script won't run properly without it.  also, a function is included to
use a snapshot as a regular filesystem.  the directory used for the
mountpoint is hardwired to "/mnt".

the most recent version from the developers website has dropped UFS2
support in favour of ZFS, but even that version fixes only the amd(8)
issue, not the hardwired mountpoint.

the little patch below uses the automounter check only if it is actually
running and makes the auxiliary mountpoint runtime configurable.

>How-To-Repeat:

try to use "snapshot list" without amd(8) running:  the command won't
complete trying to read from a pipe.  there's no way to set the
mountpoint for the "visit" sub-command.

>Fix:

run the following patch:

--- /l/sbin/snapshot	2007-11-10 15:00:27.000000000 +0100
+++ /root/bin/snapshot.sh	2007-11-13 21:05:45.000000000 +0100
@@ -31,18 +31,20 @@
 #   make sure system tools are used first
 PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:$PATH"
 
 #   option defaults
 fs_subdir=".snap"
+mnt_dir="/mnt"
 verbose=no
 help=no
 
 #   command line parsing
 usage () {
     echo "Usage: snapshot [<option> ...] <operation> <argument> ..."
     echo "Global <option> arguments are:"
     echo "    -d <subdir> filesystem sub-directory of snapshots"
+    echo "    -m <subdir> filesystem mount-directory for snapshots"
     echo "    -v          enable verbose messages"
     echo "    -h          display usage help (this message)"
     echo "Operations <operations> and their arguments <argument> are:"
     echo "    list   [<fs>]"
     echo "    make   [-g <generations>] <fs>:<tag>[.<generation>]"
@@ -52,11 +54,11 @@
 }
 if [ $# -eq 0 ]; then
     usage
     exit 0
 fi
-args=`getopt vhd: $*`
+args=`getopt vhd:m: $*`
 if [ $? != 0 ]; then
     echo "snapshot:ERROR: invalid command line arguments" 1>&2
     exit 2
 fi
 set -- $args
@@ -64,10 +66,11 @@
 do
     case "$arg" in
         -v ) verbose=yes;    shift        ;;
         -h ) help=yes;       shift        ;;
         -d ) fs_subdir="$2"; shift; shift ;;
+        -m ) mnt_dir="$2"; shift; shift ;;
         -- )                 shift; break ;;
     esac    
 done
 if [ ".$help" = .yes ]; then
     usage
@@ -143,11 +146,12 @@
         #   make sure filesystem really has a snapshot subdirectory
         if [ ! -d $fs_dir/$fs_subdir ]; then
             continue
         fi
         #   make sure filesystem isn't an already automounted snapshot
-        if [ ".`amq $fs_dir 2>&1 | grep 'not automounted'`" = . ]; then
+        if amq -p >/dev/null 2>&1 &&
+           [ ".`amq $fs_dir 2>&1 | grep 'not automounted'`" = . ]; then
             continue
         fi
         for snap in $fs_dir/$fs_subdir/*; do
             if [ -f $snap ]; then
                 #   determine sizes
@@ -267,20 +271,20 @@
         echo "snapshot:ERROR: no such snapshot \"$fs_tag.$fs_gen\" on filesystem \"$fs_dir\"" 1>&2
         exit 1
     fi
 
     #   mount snapshot
-    op_mount $fs_dir:$fs_tag.$fs_gen /mnt
+    op_mount $fs_dir:$fs_tag.$fs_gen "$mnt_dir"
 
     #   enter interactive shell
     oldpwd=`pwd`
-    system cd /mnt || exit $?
+    system cd "$mnt_dir" || exit $?
     system ${SHELL-"/bin/sh"}
     system cd $oldpwd
     
     #   unmount snapshot
-    op_umount /mnt
+    op_umount "$mnt_dir"
 
     return 0
 }
 
 ##
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071113204605.364B8534F2>