Debian Bug report logs - #361693
usbmount: Patch to automatically create mountpoints

version graph

Package: usbmount; Maintainer for usbmount is Rogério Brito <rbrito@ime.usp.br>; Source for usbmount is src:usbmount.

Reported by: "Ramkumar R. Aiyengar" <andyetitmoves@gmail.com>

Date: Sun, 9 Apr 2006 18:18:01 UTC

Severity: wishlist

Tags: patch

Found in version usbmount/0.0.14

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, R.Ramkumar <ramk@cse.iitm.ernet.in>, Martin Dickopp <martin@zero-based.org>:
Bug#361693; Package usbmount. Full text and rfc822 format available.

Acknowledgement sent to "R.Ramkumar" <ramk@cse.iitm.ernet.in>:
New Bug report received and forwarded. Copy sent to R.Ramkumar <ramk@cse.iitm.ernet.in>, Martin Dickopp <martin@zero-based.org>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: "R.Ramkumar" <ramk@cse.iitm.ernet.in>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: usbmount: Patch to automatically create mountpoints
Date: Sun, 09 Apr 2006 23:34:59 +0530
[Message part 1 (text/plain, inline)]
Package: usbmount
Version: 0.0.14
Severity: wishlist

Just found it painful to have all the usbN directories, even when
that many usb sticks may not be mounted. This patch adds an option
MOUNTPOINT_GENERATE (off by default, so there is no change in the
existing behaviour) which when set, reuses MOUNTPOINTS to be the
prefix, and creates directories as and when needed, by suffixing
them with an integer. The directory, if empty, is also unlinked on
device removal (This however does not take effect in the current
version, due to Bug #356227)

Here is the patch:



[usbmount-autogenerate.diff (text/plain, inline)]
--- usbmount.distrib	2005-07-08 22:21:02.000000000 +0530
+++ usbmount	2006-04-09 20:30:01.000000000 +0530
@@ -15,7 +15,6 @@
 set -e
 exec > /dev/null 2>&1
 
-
 # Log a string via the syslog facility.
 log()
 {
@@ -35,6 +34,14 @@
     return 1
 }
 
+test_mtpt()
+{
+    if test -d "$1" && ! grep -q "^[^ ][^ ]*  *$1 " /proc/mounts; then
+	return 0
+    else
+	return 1
+    fi
+}
 
 # Test if /sbin/vol_id is executable.
 test -x /sbin/vol_id || { log err "cannnot execute /sbin/vol_id"; exit 1; }
@@ -51,7 +58,6 @@
     . /etc/usbmount/usbmount.conf
 fi
 
-
 umask 022
 
 if test "$1" = add; then
@@ -96,15 +102,27 @@
 	if in_list "$fstype" "$FILESYSTEMS"; then
 
 	    # Search an available mountpoint.
-	    for v in $MOUNTPOINTS; do
-		if test -d "$v" \
-		    && ! grep -q "^[^ ][^ ]*  *$v " /proc/mounts; then
-		    mountpoint="$v"
-		    log debug "mountpoint $mountpoint is available for $DEVNAME"
-		    break
-		fi
-	    done
+	    if test "$MOUNTPOINT_GENERATE" = yes; then
+		ctr=0
+		while true; do
+		    v="$MOUNTPOINTS$ctr"
+		    test -e "$v" || mkdir "$v" || break
+		    if test_mtpt "$v"; then
+			mountpoint="$v"
+			break
+		    fi
+		    ctr=$(( $ctr + 1 ))
+		done
+	    else
+		for v in $MOUNTPOINTS; do
+		    if test_mtpt "$v"; then
+			mountpoint="$v"
+			break
+		    fi
+		done
+	    fi
 	    if test -n "$mountpoint"; then
+		log debug "mountpoint $mountpoint is available for $DEVNAME"
 		# Determine mount options.
 		options=
 		for v in $FS_MOUNTOPTIONS; do
@@ -172,11 +190,17 @@
 	if test "$DEVNAME" = "$device"; then
 	    # If the mountpoint and filesystem type are maintained by
 	    # this script, unmount the filesystem.
-	    if in_list "$mountpoint" "$MOUNTPOINTS" \
-		&& in_list "$fstype" "$FILESYSTEMS"; then
+	    if test "$MOUNTPOINT_GENERATE" = yes; then
+		test -z "${mountpoint##$MOUNTPOINTS[0-9]*}" && mttest=ok
+	    else
+		in_list "$mountpoint" "$MOUNTPOINTS" && mttest=ok
+	    fi
+	    if test "$mttest" = ok && in_list "$fstype" "$FILESYSTEMS"; then
 		log info "executing command: umount -l $mountpoint"
 		umount -l "$mountpoint"
-
+		if test "$MOUNTPOINT_GENERATE" = yes; then
+		    rmdir "$mountpoint" 2> /dev/null
+		fi
 		# Run hook scripts; ignore errors.
 		export UM_DEVICE="$DEVNAME"
 		export UM_MOUNTPOINT="$mountpoint"
[Message part 3 (text/plain, inline)]
Here is my config file. I have also documented the new option:

[usbmount.conf (text/plain, inline)]
# Configuration file for the usbmount package, which mounts USB mass
# storage devices when they are plugged in and unmounts them when they
# are removed.

# Set this to yes if you want mountpoints to be automatically generated based
# on a given prefix followed by the smallest available positive integer.
# MOUNTPOINTS specifies the prefix. For example, if /media/usb is specified,
# the mountpoints used are usb0, usb1 etc. The directory is created if not
# present. Further, if the directory is empty on device removal, it is removed
# as well.

MOUNTPOINT_GENERATE=yes

# Mountpoints: When MOUNTPOINT_GENERATE is not set, these directories are
# eligible as mointpoints for USB mass storage devices.  A newly plugged in
# device is mounted on the first directory in this list that exists and on
# which nothing is mounted yet. When MOUNTPOINT_GENERATE is set, this option
# specifies the prefix to be used.

MOUNTPOINTS=/media/usb

#MOUNTPOINTS="/media/usb0 /media/usb1 /media/usb2 /media/usb3
#             /media/usb4 /media/usb5 /media/usb6 /media/usb7"

# Filesystem types: USB mass storage devices are only mounted if they
# contain a filesystem type which is in this list.
#############################################################################
# WARNING!  The vfat filesystem does not yet fully implement sync-mounting. #
# If you include "vfat" in the list of filesystem types, you *MUST* make    #
# sure all data is written to the medium before you remove it (e.g. run the #
# "sync" command in a terminal window).  Otherwise, you *WILL* lose data!   #
#############################################################################
FILESYSTEMS="ext2 ext3 vfat"

# Mount options: Options passed to the mount command with the -o flag.
# WARNING!  Removing "sync" from the options is a very bad idea and
# might result in severe data loss.
MOUNTOPTIONS="noexec,nodev,noatime,users"

# Filesystem type specific mount options: This variable contains a space sepa-
# rated list of strings, each of which has the form "-fstype=TYPE,OPTIONS".
# If a filesystem with a type listed here is mounted, the corresponding
# options are appended to those specificed in the MOUNTOPTIONS variable.
# For example, "-fstype=vfat,gid=floppy,dmask=0007,fmask=0117" would add the
# options "gid=floppy,dmask=0007,fmask=0117" when a vfat filesystem is mounted.
FS_MOUNTOPTIONS="-fstype=vfat,dmask=000,fmask=111"

# If set to "yes", more information will be logged via the syslog
# facility.
VERBOSE="yes"
[Message part 5 (text/plain, inline)]
Regards,
Ramkumar.

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (101, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.15-archck2
Locale: LANG=en_IN, LC_CTYPE=en_IN (charmap=UTF-8)

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

usbmount recommends no packages.

-- no debconf information

-- 
WARN_(accel)("msg null; should hang here to be win compatible\n");
                                   -- WINE source code

Information forwarded to debian-bugs-dist@lists.debian.org, Martin Dickopp <martin@zero-based.org>:
Bug#361693; Package usbmount. Full text and rfc822 format available.

Acknowledgement sent to "R.Ramkumar" <ramk@cse.iitm.ernet.in>:
Extra info received and forwarded to list. Copy sent to Martin Dickopp <martin@zero-based.org>. Full text and rfc822 format available.

Message #10 received at 361693@bugs.debian.org (full text, mbox):

From: "R.Ramkumar" <ramk@cse.iitm.ernet.in>
To: control@bugs.debian.org, 361693@bugs.debian.org
Subject: Added the patch tag
Date: Mon, 10 Apr 2006 09:29:18 +0530
tags 361693 + patch
thanks

Forgot to add the patch tag.

Regards,
Ramkumar.

-- 
WARN_(accel)("msg null; should hang here to be win compatible\n");
                                   -- WINE source code





Tags added: patch Request was from "R.Ramkumar" <ramk@cse.iitm.ernet.in> to control@bugs.debian.org. Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#361693; Package usbmount. (Sat, 09 May 2009 07:39:18 GMT) Full text and rfc822 format available.

Acknowledgement sent to Rogério Brito <rbrito@ime.usp.br>:
Extra info received and forwarded to list. (Sat, 09 May 2009 07:39:18 GMT) Full text and rfc822 format available.

Message #17 received at 361693@bugs.debian.org (full text, mbox):

From: Rogério Brito <rbrito@ime.usp.br>
To: 377548@bugs.debian.org
Cc: 317844@bugs.debian.org, 337795@bugs.debian.org, 356227@bugs.debian.org, 402389@bugs.debian.org, 502352@bugs.debian.org, 508699@bugs.debian.org, 361693@bugs.debian.org, 510007@bugs.debian.org, 321694@bugs.debian.org, 326081@bugs.debian.org
Subject: Is this bug still being seen?
Date: Sat, 9 May 2009 04:36:46 -0300
Hi,

I am triaging some bugs of usbmount to see if they are still  
reproducible (some still seem to be, but others do not---or, at  
least, I can't).

Could you please let me know if you still see the problem that you've  
reported with the latest package (version 0.0.17) from unstable (soon  
to be migrated to testing)?

Please, if you find any new bugs, don't hesitate to file another one  
against usbmount.

If you submitted a patch, can you see if it is still needed? I would  
like to kill as many bugs as possible with an upcoming version.


Thanks, Rogério Brito.





Information forwarded to debian-bugs-dist@lists.debian.org, Rogério Brito <rbrito@ime.usp.br>:
Bug#361693; Package usbmount. (Fri, 02 Oct 2009 16:45:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Martintxo <martintxo@sindominio.net>:
Extra info received and forwarded to list. Copy sent to Rogério Brito <rbrito@ime.usp.br>. (Fri, 02 Oct 2009 16:45:03 GMT) Full text and rfc822 format available.

Message #22 received at 361693@bugs.debian.org (full text, mbox):

From: Martintxo <martintxo@sindominio.net>
To: 361693@bugs.debian.org, Rogério Brito <rbrito@ime.usp.br>
Subject: usbmount-0.0.17.1: Patch to automatically create (and delete) mountpoints
Date: Fri, 2 Oct 2009 18:26:14 +0200
[Message part 1 (text/plain, inline)]
Hello:

As I said in other bug reports, I'm testing usbmount, and I think that
it is a so useful app. for lightweight systems.

But I missed the lack of an on-demand mountpoint create and delete. With this
feature, I think that the system is friendly for a normal user (where is the
newly plugged usbstick?, ah! in the newly created dir under /media :-D).

For that, I tryed the pach in
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=361693. I apply it by hand
to /usr/share/usbmount/usbmount and add the new options
to /etc/usbmount/usbmount.conf. The pach still runs OK: it creates the
mountpoint at usb plugg, but don't removes it, as saids in the bugreport
#361693.

For this issue I create a workaround that:

1. At usb-plugg stores some variables in /tmp/usbbmount. For identify the usb
number, I get the info from /var/log/syslog, so this package should be
installed and running.

2. At usb-detach reads the variables from /tmp/usbbmount and deletes the
corresponding mountpoint. I need to get the info about what usb-stick was
detached from syslog, because I don't find any other place, all udev apps
are useless now that device is removed !!.

As you can see, the workaround is so weak, as it depends in syslog. But is
working OK for me. I attached it.

I see that usbmout need to be changed as result of some changes in udev, so I
see that this pach will be changed in the future. It is so weak too. But you
can use it as a first point for a stronger one :-DD

Greetings. Martintxo.

-- 
Tu que no puedes, llévame a cuestas 
[usbmount-0.0.17.1-addremovemountpoints.diff (text/x-patch, attachment)]

Changed Bug submitter to '"Ramkumar R. Aiyengar" <andyetitmoves@gmail.com>' from '"R.Ramkumar" <ramk@cse.iitm.ernet.in>' Request was from "Ramkumar R. Aiyengar" <andyetitmoves@gmail.com> to control@bugs.debian.org. (Sun, 23 May 2010 15:27:03 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Fri Apr 18 03:17:25 2014; Machine Name: beach.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.