Package: usbmount
Version: 0.0.14-0.1
Severity: important
Tags: patch

I use a n-in-1 device wich have 4 slots. Basically, linux sees this as four 
devices. Usbmount is started four times at the same time. This means that two 
of the processes gets a timeout while waiting for the other two to finish.
Usbmount locks as soon as possible, so only one instance is active at a time. 
But is that needed? I haven't checked it 100%, but I think there is not need to 
lock before usbmount has decided to try to mount something, this is what my 
patch does.

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing'), (20, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-k7
Locale: LANG=da_DK, LC_CTYPE=da_DK (charmap=ISO-8859-1)

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

usbmount recommends no packages.

-- no debconf information
--- usbmount.orig       2006-07-09 23:15:17.000000000 +0200
+++ usbmount    2006-07-09 23:34:36.000000000 +0200
@@ -35,6 +35,15 @@
     return 1
 }
 
+# Acquire lock.
+lock()
+{
+    log debug "trying to acquire lock /var/run/usbmount/.mount.lock"
+    lockfile-create --retry 3 /var/run/usbmount/.mount || \
+       { log err "cannot acquire lock /var/run/usbmount/.mount.lock"; exit 1; }
+    trap '( lockfile-remove /var/run/usbmount/.mount )' 0
+    log debug "acquired lock /var/run/usbmount/.mount.lock"
+}
 
 # Test if /lib/udev/vol_id is executable.
 test -x /lib/udev/vol_id || { log err "cannnot execute /lib/udev/vol_id"; exit 
1; }
@@ -56,13 +65,6 @@
 
 if test "$1" = add; then
 
-    # Acquire lock.
-    log debug "trying to acquire lock /var/run/usbmount/.mount.lock"
-    lockfile-create --retry 3 /var/run/usbmount/.mount || \
-       { log err "cannot acquire lock /var/run/usbmount/.mount.lock"; exit 1; }
-    trap '( lockfile-remove /var/run/usbmount/.mount )' 0
-    log debug "acquired lock /var/run/usbmount/.mount.lock"
-
     # Try to read from the device.  Some devices need a few seconds
     # initialization time before they can be accessed.  Give up after
     # 20 seconds.  Thanks to Peter Stelmachovic for his help with
@@ -95,6 +97,8 @@
        # types to mount.
        if in_list "$fstype" "$FILESYSTEMS"; then
 
+           lock
+
            # Search an available mountpoint.
            for v in $MOUNTPOINTS; do
                if test -d "$v" \

Reply via email to