Package: usbmount
Version: 0.0.14
Severity: wishlist
Tags: patch

Hello,

here is a patch for /usr/share/usbmount/usbmount which allows _any_
user to unmount a device which was mounted automatically by usbmount.
This is great for USB sticks which are formatted as vfat and which you
do not want to mount with the "sync" option due to the resulting
horrible write performance.

You can safely use such USB sticks without "sync" if you always
remember to unmount the device. With this patch, unmounting becomes
very easy - for example, it can be done in a convenient way using
Nautilus on the Gnome desktop.

The idea is: Add to /etc/fstab entries of this form:
/var/run/usbmount/dev-media-usb0 /media/usb0 auto users,noauto 0 0
/var/run/usbmount/dev-media-usb1 /media/usb1 auto users,noauto 0 0
Note how each device is the string "/var/run/usbmount/dev", followed
by the mount point name (with "/" replaced by "-").

Next, have usbmount create symbolic links to the actual devices. For
example, when mounting /dev/hdb4 on /media/usb0, first create a symlink
/var/run/usbmount/dev-media-usb0 -> /dev/hdb4
and then mount /var/run/usbmount/dev-media-usb0 on /media/usb0.

The symlink trick has the advantage that /etc/fstab does not need to be
changed dynamically whenever a device is plugged in. Due to the "users"
option in the fstab line, any user is allowed to unmount the device.
The filesystem type ("auto" in the two lines above) is ignored by
umount AFAICT, so it need not be correct.

Another nice thing: The mount command actually notices that the mount
device is a symlink _and follows it_, so mtab will still show
"/dev/hdb4" as the device instead of /var/run/usbmount/dev-media-usb0!
Cool!

IMHO this is a very useful feature - hopefully it'll make its way into
your package!

Cheers,

  Richard


-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15
Locale: LANG=C, LC_CTYPE=de_DE (charmap=ISO-8859-15)

Versions of packages usbmount depends on:
ii  lockfile-progs                0.1.10     Programs for locking and unlocking
ii  udev                          0.081-1    /dev/ and hotplug management daemo

usbmount recommends no packages.

-- no debconf information

--- usbmount    2006-02-08 01:02:42.000000000 +0100
+++ /usr/share/usbmount/usbmount        2006-02-08 01:22:40.000000000 +0100
@@ -117,9 +117,14 @@
                    options="$MOUNTOPTIONS${options:+,$options}"
                fi
 
+               # Create a symlink to the device and use that for mounting.
+               # This is necessary to allow any user to unmount the device.
+               devlink="/var/run/usbmount/dev`echo $mountpoint | sed s%/%-%g`"
+               ln -sf "$DEVNAME" "$devlink"
+
                # Mount the filesystem.
-               log info "executing command: mount -t$fstype 
${options:+-o$options} $DEVNAME $mountpoint"
-               mount "-t$fstype" "${options:+-o$options}" "$DEVNAME" 
"$mountpoint"
+               log info "executing command: mount -t$fstype 
${options:+-o$options} $devlink $mountpoint"
+               mount "-t$fstype" "${options:+-o$options}" "$devlink" 
"$mountpoint"
 
                # Determine vendor and model.
                vendor=
@@ -147,6 +152,7 @@
 
                # Run hook scripts; ignore errors.
                export UM_DEVICE="$DEVNAME"
+               export UM_DEVLINK="$devlink"
                export UM_MOUNTPOINT="$mountpoint"
                export UM_FILESYSTEM="$fstype"
                export UM_MOUNTOPTIONS="$options"


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to