Clean up function ordering
authorBryn M. Reeves <bmr@redhat.com>
Fri, 1 Feb 2013 18:48:19 +0000 (18:48 +0000)
committerBryn M. Reeves <bmr@redhat.com>
Fri, 1 Feb 2013 18:48:19 +0000 (18:48 +0000)
blkdevalias

index c3e3f7b..0802953 100755 (executable)
@@ -91,17 +91,6 @@ _debug () {
     [ "$BA_DEBUG" == "yes" ] && echo -e "$@" 1>&2
 }
 
-# print usage message
-# sub-commands may provide their own usage messages
-ba_usage () {
-    if [ x"$@" == x"" ]; then
-        _print "Usage: $0 <command> [<arg>]..."
-    else
-        _print "Usage: $0 $@"
-    fi
-    exit 2
-}
-
 ba_store_wwid_map_header() {
     local _TMP_MAP="$1"
     cat > $_TMP_MAP << EOF
@@ -243,19 +232,6 @@ ba_scsi_id () {
     $BA_SUDO $BA_SCSI_ID $BA_SCSI_ID_FLAGS $_DEV
 }
 
-# ba_chown_configs <user> <group>
-ba_chown_configs () {
-    local _USER _GROUP _OUT
-    _USER="$1"
-    _GROUP="$2"
-    $BA_CHOWN -R "$_USER:$_GROUP" "$BA_CONF_DIR"
-    $BA_CHOWN "$_USER:$_GROUP" "$BA_LOCK_PATH"
-    ls -l "$BA_CONF_DIR" | while read _OUT; do
-        _debug "$FUNCNAME: $_OUT"
-    done
-    return 0
-}
-
 # ba_refresh_alias <alias>
 ba_refresh_alias () {
     local _ALIAS _DEVPATH
@@ -289,6 +265,51 @@ ba_refresh_device () {
     $BA_SUDO $BA_SH -c "echo change > /sys/block/$_DEVNAME/uevent"
 }
 
+ba_lock_map () {
+    local _MODE _FLAG
+    _MODE="$1"
+    _FLAG="-s" # shared by default
+    if [ "$_MODE" == "exclusive" ]; then
+        _FLAG="-x"
+    fi
+    _debug "$FUNCNAME: locking $BA_LOCK_PATH on" \
+        "fd $BA_LOCK_FD with mode: $_MODE"
+    $BA_FLOCK $_FLAG -n $BA_LOCK_FD
+    _STATUS="$?"
+    _debug "$FUNCNAME: flock exited with status $_STATUS"
+    # we may be running as root - if so re-chown the lock file
+    if [ "$BA_REAL_UID" == "0" ] || [ "$BA_REAL_GID" == "0" ]; then
+        $BA_CHOWN "$BA_USER:$BA_GROUP" "$BA_LOCK_PATH"
+    fi
+    return $_STATUS
+}
+
+ba_unlock_map () {
+    local _STATUS
+    _debug "$FUNCNAME: unlocking $BA_LOCK_PATH on fd $BA_LOCK_FD"
+    $BA_FLOCK -u -n $BA_LOCK_FD
+    _STATUS="$?"
+    _debug "$FUNCNAME: flock exited with status $_STATUS"
+    if [ "$BA_REAL_UID" == "0" ] || [ "$BA_REAL_GID" == "0" ]; then
+        $BA_CHOWN "$BA_USER:$BA_GROUP" "$BA_LOCK_PATH"
+    fi
+    _STATUS="$?"
+    return $_STATUS
+}
+
+# ba_chown_configs <user> <group>
+ba_chown_configs () {
+    local _USER _GROUP _OUT
+    _USER="$1"
+    _GROUP="$2"
+    $BA_CHOWN -R "$_USER:$_GROUP" "$BA_CONF_DIR"
+    $BA_CHOWN "$_USER:$_GROUP" "$BA_LOCK_PATH"
+    ls -l "$BA_CONF_DIR" | while read _OUT; do
+        _debug "$FUNCNAME: $_OUT"
+    done
+    return 0
+}
+
 #ba_configure_store_header: <file>
 ba_store_conf_header() {
     local _TMP_CONF="$1"
@@ -523,36 +544,15 @@ ba_map () {
     echo "BA_MODE=$BA_MODE"
 }
 
-ba_lock_map () {
-    local _MODE _FLAG
-    _MODE="$1"
-    _FLAG="-s" # shared by default
-    if [ "$_MODE" == "exclusive" ]; then
-        _FLAG="-x"
-    fi
-    _debug "$FUNCNAME: locking $BA_LOCK_PATH on" \
-        "fd $BA_LOCK_FD with mode: $_MODE"
-    $BA_FLOCK $_FLAG -n $BA_LOCK_FD
-    _STATUS="$?"
-    _debug "$FUNCNAME: flock exited with status $_STATUS"
-    # we may be running as root - if so re-chown the lock file
-    if [ "$BA_REAL_UID" == "0" ] || [ "$BA_REAL_GID" == "0" ]; then
-        $BA_CHOWN "$BA_USER:$BA_GROUP" "$BA_LOCK_PATH"
-    fi
-    return $_STATUS
-}
-
-ba_unlock_map () {
-    local _STATUS
-    _debug "$FUNCNAME: unlocking $BA_LOCK_PATH on fd $BA_LOCK_FD"
-    $BA_FLOCK -u -n $BA_LOCK_FD
-    _STATUS="$?"
-    _debug "$FUNCNAME: flock exited with status $_STATUS"
-    if [ "$BA_REAL_UID" == "0" ] || [ "$BA_REAL_GID" == "0" ]; then
-        $BA_CHOWN "$BA_USER:$BA_GROUP" "$BA_LOCK_PATH"
+# print usage message
+# sub-commands may provide their own usage messages
+ba_usage () {
+    if [ x"$@" == x"" ]; then
+        _print "Usage: $0 <command> [<arg>]..."
+    else
+        _print "Usage: $0 $@"
     fi
-    _STATUS="$?"
-    return $_STATUS
+    exit 2
 }
 
 # error messages