From afa4740db04c68dd31a999e05fd2ceca84b88c5d Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 11 Mar 2009 17:21:08 -0700 Subject: Cleanup show disk format Allow non-root to use 'show disk format' Check for block device. Use awk more effectivedly in finding disk names --- templates/show/disk/node.tag/format/node.def | 18 +++++------------- templates/show/disk/node.tag/node.def | 5 +---- 2 files changed, 6 insertions(+), 17 deletions(-) (limited to 'templates') diff --git a/templates/show/disk/node.tag/format/node.def b/templates/show/disk/node.tag/format/node.def index e5829ca..4b09369 100644 --- a/templates/show/disk/node.tag/format/node.def +++ b/templates/show/disk/node.tag/format/node.def @@ -1,14 +1,6 @@ help: Show disk drive formatting - -run: - disk_dev=$3 - valid_disks=`cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' | egrep -v "[0-9]"` - is_a_disk=`echo $valid_disks | grep $disk_dev` - - if [ -z "$is_a_disk" ]; then - echo "$disk_dev is not a disk device" - elif [ ! -r /dev/${disk_dev} ]; then - echo "Must be admin or root to display disk formating" - else - /sbin/fdisk -l /dev/${disk_dev} - fi +run: dev=/dev/$3 + if [ ! -b $dev ] + then echo "$3 is not a disk device"; exit 1 + fi + /sbin/fdisk -l /dev/${disk_dev} diff --git a/templates/show/disk/node.tag/node.def b/templates/show/disk/node.tag/node.def index 7e4fe05..8690008 100644 --- a/templates/show/disk/node.tag/node.def +++ b/templates/show/disk/node.tag/node.def @@ -1,7 +1,4 @@ help: Disk device name +allowed: awk 'NR > 2 && $4 !~ /[0-9]$/ { print $4 }'