Bug 118025 - [patch] sysutils/freebsd-snapshot: automounter, mount-points
Summary: [patch] sysutils/freebsd-snapshot: automounter, mount-points
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Rong-En Fan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-13 20:50 UTC by clemens fischer
Modified: 2007-12-17 01:40 UTC (History)
1 user (show)

See Also:


Attachments
file.diff (2.52 KB, patch)
2007-11-13 20:50 UTC, clemens fischer
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description clemens fischer 2007-11-13 20:50:03 UTC
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.

Fix: run the following patch:
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.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2007-11-13 20:50:12 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 2 Rong-En Fan freebsd_committer freebsd_triage 2007-11-14 07:48:29 UTC
Responsible Changed
From-To: freebsd-ports-bugs->rafan

I'll take it.
Comment 3 clemens fischer 2007-11-14 14:43:16 UTC
hi rafan,

my patch was incorrect. i had stopped amd(8), but somehow "amq -p"
will immediately error out instead of hanging. when amd(8) has never
been started, amq(8) hangs. might be it checks for the pid file in
var/run/amd.pid.

ralf engelschall solved this problem in his current (ZFS) version in
another way:  he checks for this pid file instead of relying on amq(8).

thus my new patch does the same, and it works.

sorry for the confusion,


regards, clemens


--- /l/sbin/snapshot	2007-11-10 15:00:27.000000000 +0100
+++ /root/bin/snapshot.sh	2007-11-14 15:27:56.000000000 +0100
@@ -33,6 +33,7 @@
 
 #   option defaults
 fs_subdir=".snap"
+mnt_dir="/mnt"
 verbose=no
 help=no
 
@@ -41,6 +42,7 @@
     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:"
@@ -54,7 +56,7 @@
     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
@@ -66,6 +68,7 @@
         -v ) verbose=yes;    shift        ;;
         -h ) help=yes;       shift        ;;
         -d ) fs_subdir="$2"; shift; shift ;;
+        -m ) mnt_dir="$2"; shift; shift ;;
         -- )                 shift; break ;;
     esac    
 done
@@ -145,8 +148,12 @@
             continue
         fi
         #   make sure filesystem isn't an already automounted snapshot
-        if [ ".`amq $fs_dir 2>&1 | grep 'not automounted'`" = . ]; then
-            continue
+        if [ -f /var/run/amd.pid ]; then
+            if kill -0 `cat /var/run/amd.pid` 2>/dev/null; then
+                if [ ".`amq $fs_dir 2>&1 | grep 'not automounted'`" = . ]; then
+                    continue
+                fi
+            fi
         fi
         for snap in $fs_dir/$fs_subdir/*; do
             if [ -f $snap ]; then
@@ -269,16 +276,16 @@
     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
 }
Comment 4 Rong-En Fan freebsd_committer freebsd_triage 2007-12-13 08:39:02 UTC
State Changed
From-To: feedback->closed

Committed. Thanks!
Comment 5 Rong-En Fan freebsd_committer freebsd_triage 2007-12-13 08:40:00 UTC
State Changed
From-To: closed->open

Reopen. I closed the wrong PR.
Comment 6 dfilter service freebsd_committer freebsd_triage 2007-12-17 01:34:37 UTC
rafan       2007-12-17 01:34:31 UTC

  FreeBSD ports repository

  Modified files:
    sysutils/freebsd-snapshot Makefile distinfo 
    sysutils/freebsd-snapshot/files pkg-message.in 
  Log:
  - Update to 20071207.1 [1]
  - Update pkg-message to reflect ZFS functionality [2]
  
  PR:             ports/118008 [1], ports/118025 [2]
  Submitted by:   rafan [1], clemens fischer <ino-news at spotteswoode.dnsalias.org> [2]
  Approved by:    Graham Todd <gtodd at bellanet.org> (maintainer)
  
  Revision  Changes    Path
  1.6       +2 -3      ports/sysutils/freebsd-snapshot/Makefile
  1.3       +3 -3      ports/sysutils/freebsd-snapshot/distinfo
  1.2       +3 -3      ports/sysutils/freebsd-snapshot/files/pkg-message.in
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 7 Rong-En Fan freebsd_committer freebsd_triage 2007-12-17 01:35:55 UTC
State Changed
From-To: open->closed

Committed with relevant changes (pkg-message). Rest are updated in 
upstream.