From 959c2c6eb06ffa92172538de68f200ca6224f824 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 17 Jan 2010 20:58:40 -0500 Subject: Cleanup mounting calls. Don't needlessly unmount squash just to mount it again, just check if its mounted and mount if we need it. In line with this, restrict verbose output about mounting to the mount squash/union functions --- squashfu | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/squashfu b/squashfu index 7cd93b8..457cac5 100755 --- a/squashfu +++ b/squashfu @@ -79,8 +79,7 @@ create_new_incremental () { # Determine the mount order via binventory local bin_order=($(sort -n -r -t: -k2 "$BINVENTORY" | cut -d: -f1)) - info "Mounting squash and union" - mount_squash + mountpoint "${SQUASH_MOUNT}" &>/dev/null || mount_squash mount_union_with_bins ${bin_order[@]} # Die with error on mount, else start rsync @@ -133,6 +132,7 @@ mount_squash () { mount_union_with_bins () { # Arguments: numbers of bins to be mounted (variable number) # Returns: 0 on successful mount, non-zero on failure + info "Mounting union" debug "Requested to mount bins: $*" # Mount first as rw, shift, and mount the rest ro @@ -255,9 +255,8 @@ action_backup () { info "Backup requested at $(date --rfc-3339=seconds)" - # Cleanup mounts, in case user was doing a rollback and forgot to unmount (or error on last run) + # Cleanup union, in case user was doing a rollback and forgot to unmount (or error on last run) mountpoint "$UNION_MOUNT" &>/dev/null && unmount_union - mountpoint "$SQUASH_MOUNT" &>/dev/null && unmount_squash create_new_incremental @@ -300,9 +299,7 @@ action_rollback () { local num_to_mount=$[ ${#bin_list[@]} - $1 ] mountpoint "$UNION_MOUNT" &>/dev/null && unmount_union - mountpoint "$SQUASH_MOUNT" &>/dev/null && unmount_squash - - mount_squash + mountpoint "$SQUASH_MOUNT" &>/dev/null || mount_squash mount_union_with_bins ${bin_list[@]:(-$num_to_mount)} -- cgit v1.2.3