Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 35767 Details for
Bug 57633
patch to sys-apps/hotplug to automount into /mnt/usb
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to modify and add files to the hotplug ebuild install
hotplug.patch (text/plain), 7.28 KB, created by
Scott Marks
on 2004-07-19 13:47:50 UTC
(
hide
)
Description:
Patch to modify and add files to the hotplug ebuild install
Filename:
MIME Type:
Creator:
Scott Marks
Created:
2004-07-19 13:47:50 UTC
Size:
7.28 KB
patch
obsolete
>--- /etc/conf.d/usb 2004-07-19 14:50:06.000000000 -0400 >+++ hotplug.patched/etc/conf.d/usb 2004-07-18 02:44:07.000000000 -0400 >@@ -5,3 +5,4 @@ > > # Put any modules here that you want to be loaded by the USB hotplug system > #STATIC_MODULE_LIST= >+STATIC_MODULE_LIST=usb-storage >--- /etc/hotplug/usb.usermap 2004-07-19 14:50:06.000000000 -0400 >+++ hotplug.patched/etc/hotplug/usb.usermap 2004-07-19 14:57:32.671661472 -0400 >@@ -1 +1,10 @@ > # usb module match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceClass bInterfaceSubClass bInterfaceProtocol driver_info >+# >+# The entry below has two effects: >+# It causes /etc/hotplug/usb/usb-storage to be invoked, >+# as usual per its flags and matches (Interface class 8=USB mass storage) >+# It has the special side effect of invoking /usr/sbin/updfstab, >+# if that file exists >+# See hotplug.functions, around line 169 >+# >+usb-storage 0x0080 0x0000 0x0000 0x0000 0x0000 0x00 0x00 0x00 0x08 0x00 0x00 0x00000000 >--- /dev/null 1969-12-31 19:00:00.000000000 -0500 >+++ hotplug.patched/etc/hotplug/usb/usb-storage 2004-07-19 13:30:48.000000000 -0400 >@@ -0,0 +1,223 @@ >+#!/bin/sh >+# >+# Automount hotplugged USB block devices, by Scott Marks (smarks@mobile-mind.com) >+# Based on automount.hotplug by Wout Mertens (wmertens@gentoo.org) >+# >+# Linux v2.6 version >+# This script is released under version 2 of the GPL. >+ >+# To install this, either make it /etc/hotplug/usb/usb-storage. >+# It needs to be executable. >+# >+# The devices will be mounted for the console user if applicable. >+# >+# To work, this needs: >+# - v2.6 kernel support: >+# - hotplugging, /proc mounted, /sys mounted >+# - filesystems that will be mounted, like vfat >+# - sh, echo, sed, stat or ls, getent or grep passwd, >+# mount, umount, mkdir, rmdir. logger is used if there. >+# >+# Possible improvements: >+# - Create a desktop entry for the device. >+# - Mount as supermount if available. This will improve behaviour for >+# synchronous writes and hanging mounts, although umount -lf already >+# does a good job. UPDATE: added, but untested. Let me know if it works. >+# - Detect filesystem on device, so filesystems that don't need a mounting >+# user can skip user detection. >+ >+# Debugging >+# set -xv >+# exec > /tmp/hotplug.$$ 2>&1 >+ >+PATH="/bin:/sbin:/usr/bin:/usr/sbin" >+export PATH >+ >+# Proclaim stuff to the world >+mesg () { >+ logger -t $0 "$*" >+} >+ >+# Is path already mounted? >+is_path_mounted () { >+ while read dev path rest >+ do >+ if [ "$path" = "$1" ] >+ then >+ return 0 >+ fi >+ done < /proc/self/mounts >+ return 1 >+} >+ >+ >+# Remove strange characters from a filename >+clean_filename () { >+ # Note the lack of quotes around $1, this strips off spaces. >+ echo $1 | sed 's/[ /?*\"<>]/_/g' >+} >+ >+ >+SYSFS=/sys >+ >+: DEVPATH=$DEVPATH >+ >+# Wait for a file matching host* to appear in $SYSFS$DEVPATH >+ >+local count >+for count in 1 2 3 4 5 6 7 8 9 10 >+do >+ count is $count >+ HOST=`ls -1 $SYSFS$DEVPATH | grep -m 1 '^host[1-9][0-9]*$'` >+ [ -z "$HOST" ] || break >+ sleep 1 >+done >+ >+[ -z "$HOST" ] && mesg No host in $SYSFS$DEVPATH? >+ >+ >+BLKDEV=scsi/$HOST/bus0/target0/lun0 >+ >+ >+# Mount all partitions on this device >+: host devices are `ls -m /dev/$BLKDEV` >+ >+ >+ >+case "$ACTION" in >+add) >+ # Figure out user to which to assign mounted partition devices >+ CONSOLEUSER=`stat -c%U /dev/console 2>/dev/null` >+ if [ -z "$CONSOLEUSER" ] >+ then >+ set `ls -l /dev/console` >+ CONSOLEUSER=$3 >+ fi >+ >+ [ -n "$CONSOLEUSER" ] || CONSOLEUSER=root >+ PASSWD=`getent passwd $CONSOLEUSER 2>/dev/null` >+ if [ -z "$PASSWD" ] >+ then >+ PASSWD=`grep "$CONSOLEUSER" /etc/passwd||grep root /etc/passwd` >+ fi >+ if [ -z "$PASSWD" ] >+ then >+ mesg Could not get password entry for $CONSOLEUSER >+ exit 1 >+ fi >+ >+ set `echo $PASSWD | sed 's/:/ /g'` >+ if [ $# -lt 4 ] >+ then >+ mesg Bad password entry for $CONSOLEUSER >+ exit 1 >+ fi >+ >+ # These options should prevent abuse and make it writeable for the >+ # console user. >+ if grep -q supermount /proc/filesystems >+ then >+ MOUNTOPTS="-s -t supermount -onoatime,nosuid,umask=077,uid=$3,gid=$4" >+ else >+ MOUNTOPTS="-s -onoatime,sync,dirsync,nosuid,umask=077,uid=$3,gid=$4" >+ fi >+ >+ # Write the remover as we go >+ echo ". /etc/hotplug/usb/usb-storage.remove" > "$REMOVER" >+ >+ # Mount each partition device >+ for p in `ls /dev/$BLKDEV` ; >+ do >+ if [ "$p" != "disc" ] >+ then >+ >+ # If is there a symbolic link here, use it >+ PARTDEV=`find /dev -lname $BLKDEV/$p` >+ [ -z "$PARTDEV" ] && PARTDEV="/dev/$BLKDEV/$p" >+ >+ : Need to mount $PARTDEV >+ >+ # Mount it >+ >+ # Make sure we have support for vfat >+ modprobe -q vfat >+ >+ >+ # Find the name >+ >+ >+ # Find out where we mount it >+ MOUNTPATH=/mnt/usb/storage >+ if is_path_mounted "$MOUNTPATH" >+ then >+ count=1 >+ while is_path_mounted "${MOUNTPATH}_${count}" >+ do >+ count=$(( $count + 1 )) >+ done >+ MOUNTPATH="${MOUNTPATH}_${count}" >+ fi >+ >+ # Find out device info to make a nice alias >+ >+ VendorID=`cat $SYSFS$DEVPATH/../idVendor` >+ ProductID=`cat $SYSFS$DEVPATH/../idProduct` >+ >+ PRODUCT=$VendorID.$ProductID >+ if [ -x /usr/sbin/lsusb ] >+ then >+ set `lsusb -d 0x$VendorID:0x$ProductID` >+ shift 6 >+ PRODUCT="$*" >+ fi >+ ALIAS=/mnt/usb/`clean_filename "$PRODUCT"` >+ if [ -e "$ALIAS" ] >+ then >+ count=1 >+ while [ -e "${ALIAS}_${count}" ] >+ do >+ count=$(( $count + 1 )) >+ done >+ ALIAS="${ALIAS}_${count}" >+ fi >+ >+ # Make sure it's a directory >+ if [ -e "$MOUNTPATH" ] >+ then >+ if [ ! -d "$MOUNTPATH" ] >+ then >+ mesg $MOUNTPATH exists but is not a directory >+ continue >+ fi >+ else >+ mkdir -p "$MOUNTPATH" >+ if [ $? -ne 0 ] >+ then >+ mesg Could not create mountpoint $MOUNTPATH >+ continue >+ fi >+ fi >+ >+ mesg Mounting $PARTDEV on $MOUNTPATH, options $MOUNTOPTS >+ >+ mount $MOUNTOPTS $PARTDEV $MOUNTPATH >+ >+ ln -s $MOUNTPATH $ALIAS >+ >+ echo "remove $PARTDEV" >> "$REMOVER" >+ fi >+ >+ done >+ >+ chmod +x "$REMOVER" >+ ;; >+ >+remove) >+ # Umount each partition device >+ mesg Shouldn\'t be here -- $REMOVER missing? >+ ;; >+ >+*) >+ exit 1;; >+esac >+ >--- /dev/null 1969-12-31 19:00:00.000000000 -0500 >+++ hotplug.patched/etc/hotplug/usb/usb-storage.remove 2004-07-19 13:28:04.000000000 -0400 >@@ -0,0 +1,31 @@ >+remove ( ) { >+ local DEVICE=$1 >+ >+ : Need to umount $DEVICE >+ >+ # What dir is mounted to $DEVICE >+ while read dev path rest >+ do >+ if [ "$dev" = "$DEVICE" ] >+ then >+ MOUNTPATH="$path" >+ break >+ fi >+ done < /proc/self/mounts >+ >+ # If is isn't ours, never mind >+ echo "$MOUNTPATH" | grep -q ^/mnt/usb || return 0 >+ >+ # Bizarrely wrong if it isn't a dir >+ [ -d "$MOUNTPATH" ] || return 1 >+ >+ #remove its alias >+ ALIAS=`find /mnt/usb -lname $MOUNTPATH` >+ [ -L "$ALIAS" ] && rm $ALIAS >+ >+ umount -lf "$MOUNTPATH" >+ #unmount it >+ >+ #delete it >+ rmdir "$MOUNTPATH" >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 57633
: 35767