From 5303f98f674ab5cb600dde0394ff7ddd5ba3c98a Mon Sep 17 00:00:00 2001 From: Rajesh Amaravathi Date: Mon, 26 Dec 2011 14:39:24 +0530 Subject: extras: add check for brick path existence Adding a couple of checks to validate brick path(s) Change-Id: I2d8538add21407d9457542373b528c2a02cd7eb6 BUG: 765572 Signed-off-by: Rajesh Amaravathi Reviewed-on: http://review.gluster.com/2514 Tested-by: Gluster Build System Reviewed-by: Jeff Darcy Reviewed-by: Vijay Bellur --- extras/clear_xattrs.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'extras/clear_xattrs.sh') diff --git a/extras/clear_xattrs.sh b/extras/clear_xattrs.sh index bdce5b895a3..dd04731e8bd 100755 --- a/extras/clear_xattrs.sh +++ b/extras/clear_xattrs.sh @@ -16,24 +16,34 @@ remove_xattrs () main () { if [ -z "$1" ]; then - echo "Please specify the brick path(s)"; + echo "Usage: $0 "; exit 1; fi + export PATH; which getfattr > /dev/null 2>&1; if [ $? -ne 0 ]; then echo "attr package missing"; - exit 1; + exit 2; fi which setfattr > /dev/null 2>&1; if [ $? -ne 0 ]; then echo "attr package missing"; - exit 1; + exit 2; fi for brick in "$@"; do + stat "$brick" > /dev/null 2>&1; + if [ $? -ne 0 ]; then + echo "brick: $brick does not exist"; + exit 3; + fi + if [ ! -d "$brick" ]; then + echo "$brick: not a directory"; + exit 4; + fi echo "xattr clean-up in progress: $brick"; remove_xattrs "$brick"; echo "$brick ready to be used as a glusterfs brick"; -- cgit