0002-use-udev-environment-instead-of-blkid.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. udev can provide all the values that usbmount determined using the
  2. blkid binary. This patch drops use of blkid in favor of using the
  3. environment variables set by udev. Thus it removes the dependency
  4. on blkid from usbmount.
  5. Signed-off-by: Sven Neumann <s.neumann@raumfeld.com>
  6. --- usbmount-0.0.22/usbmount.orig 2013-06-18 14:44:40.143096147 +0200
  7. +++ usbmount-0.0.22/usbmount 2013-06-19 16:13:09.882434896 +0200
  8. @@ -59,11 +59,6 @@
  9. exit 0
  10. fi
  11. -if [ ! -x /sbin/blkid ]; then
  12. - log err "cannot execute /sbin/blkid"
  13. - exit 1
  14. -fi
  15. -
  16. # Per Policy 9.3.2, directories under /var/run have to be created
  17. # after every reboot.
  18. if [ ! -e /var/run/usbmount ]; then
  19. @@ -83,15 +78,7 @@
  20. trap '( lockfile-remove /var/run/usbmount/.mount )' 0
  21. log debug "acquired lock /var/run/usbmount/.mount.lock"
  22. - # Grab device information from device and "divide it"
  23. - # FIXME: improvement: implement mounting by label (notice that labels
  24. - # can contain spaces, which makes things a little bit less comfortable).
  25. - DEVINFO=$(/sbin/blkid -p $DEVNAME)
  26. - FSTYPE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]TYPE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
  27. - UUID=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]UUID="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
  28. - USAGE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]USAGE="\([^"]*\)".*/\1/g; s/[[:blank:]]*//g;')
  29. -
  30. - if ! echo $USAGE | egrep -q "(filesystem|disklabel)"; then
  31. + if ! echo $ID_FS_USAGE | egrep -q "(filesystem|disklabel)"; then
  32. log info "$DEVNAME does not contain a filesystem or disklabel"
  33. exit 1
  34. fi
  35. @@ -101,14 +88,14 @@
  36. log info "executing command: mount $DEVNAME"
  37. mount $DEVNAME || log err "mount by DEVNAME with $DEVNAME wasn't successful; return code $?"
  38. - elif grep -q "^[[:blank:]]*UUID=$UUID" /etc/fstab; then
  39. - log info "executing command: mount -U $UUID"
  40. - mount -U $UUID || log err "mount by UUID with $UUID wasn't successful; return code $?"
  41. + elif grep -q "^[[:blank:]]*UUID=$ID_FS_UUID" /etc/fstab; then
  42. + log info "executing command: mount -U $ID_FS_UUID"
  43. + mount -U $ID_FS_UUID || log err "mount by UUID with $ID_FS_UUID wasn't successful; return code $?"
  44. else
  45. - log debug "$DEVNAME contains filesystem type $FSTYPE"
  46. + log debug "$DEVNAME contains filesystem type $ID_FS_TYPE"
  47. - fstype=$FSTYPE
  48. + fstype=$ID_FS_TYPE
  49. # Test if the filesystem type is in the list of filesystem
  50. # types to mount.
  51. if in_list "$fstype" "$FILESYSTEMS"; then
  52. @@ -176,11 +163,13 @@
  53. # Run hook scripts; ignore errors.
  54. export UM_DEVICE="$DEVNAME"
  55. + export UM_UUID="$ID_FS_UUID"
  56. export UM_MOUNTPOINT="$mountpoint"
  57. export UM_FILESYSTEM="$fstype"
  58. export UM_MOUNTOPTIONS="$options"
  59. export UM_VENDOR="$vendor"
  60. export UM_MODEL="$model"
  61. + export UM_LABEL="$ID_FS_LABEL"
  62. log info "executing command: run-parts /etc/usbmount/mount.d"
  63. run-parts /etc/usbmount/mount.d || :
  64. else