From 8f1122f4361028d8044c65de359ad95eaed2e105 Mon Sep 17 00:00:00 2001 From: IgnorantGuru Date: Wed, 4 Dec 2013 13:06:12 -0700 Subject: [PATCH] [devmon 1.1.7] add option --enumerate-device-files #26 --- ChangeLog | 1 + src/devmon | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4b6d707..3fa1045 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ default fmask=0133 for vfat ntfs msdos umsdos #25 [devmon 1.1.7] support raid /dev/mda in partition detection #28 fix identify empty optical drive + [devmon 1.1.7] add option --enumerate-device-files #26 0.4.1 2013-03-17: update Russian translation added translation files to transifex.com diff --git a/src/devmon b/src/devmon index a838181..6c63f8e 100755 --- a/src/devmon +++ b/src/devmon @@ -55,6 +55,7 @@ MOUNT-OPTIONS: (these can be used only in client mode) --mount DEVICE Mount DEVICE --mount-options|--mount-fstype|--eject-options "OPTIONS" These options will be passed to mount or eject +--enumerate-device-files List known devices UNIVERSAL OPTIONS: (these can be used in both daemon and client modes) --ignore-device DEVICE Ignore DEVICE (eg /dev/sdd1) @@ -248,6 +249,39 @@ while [ "$1" != "" ]; do (( iglabx++ )) shift ;; + --enumerate-device-files ) + all=`grep " [ms]d[a-z0-9]*$" /proc/partitions | \ + sed 's/.* \([ms]d[a-z0-9]*\)/\/dev\/\1/'` + n=$'\n' + if [ "$all" != "" ]; then + all="$all$n" + fi + for f in /dev/mapper/*; do + if [ -h "$f" ]; then + name="$(basename "$f")" + target="$(readlink "$f")" + target="$(basename "$target")" + if [ "$target" != "" ]; then + all="$all/dev/$target$n" + if [ "${name:0:4}" = "loop" ]; then + all="$all/dev/$name$n" + fi + fi + fi + done + # add mounted loop devices (attached requires losetup as root) + loop=`cat /proc/self/mountinfo 2>/dev/null | grep ' /dev/loop[0-9]* ' | cut -f9 -d ' ' 2>/dev/null` + if [ "$loop" != "" ]; then + loop="$loop$n" + fi + other=`/bin/ls -1 /dev/md[0-9]* /dev/dm-* /dev/sr* 2>/dev/null` + if [ "$other" != "" ]; then + other="$other$n" + fi + all="$all$loop$other" + echo -n "$all" | sort | uniq + exit + ;; --* ) unknown "$1";; -* )