diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/dev.inc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/dev.inc b/modules/dev.inc index 13b042f..c054b63 100644 --- a/modules/dev.inc +++ b/modules/dev.inc @@ -8,7 +8,13 @@ # The output will be a list of matching devices, # sorted from largest to smallest. dev_find_partitions() { - local ID dev target + local ID dev target rw + # check if only interested in writable devices + rw= + if [ "$1" = "--rw" ]; then + shift + rw=1 + fi # target for the scan, defaults to /dev to check everything if [ "${1:0:1}" = "/" ] && [ -b "$1" ]; then target="$1" @@ -40,6 +46,7 @@ dev_find_partitions() { done local label number mbrid uuid for dev in $(find $target* -type b); do + [ -n "$rw" ] && [ "$( cat "/sys/class/block/$dev/ro" )" = "1" ] && continue dev_get_type "$dev" || continue echo "$dev is $number - MBR=$mbrid, UUID=$uuid, label=$label" >&2 if regex_imatch "$mbrid" "^($want_type)$" || regex_imatch "$uuid" "^($want_uuid)$" \ |