From: Victor Lowther Date: Sat, 14 Aug 2010 19:23:24 +0000 (-0500) Subject: Shorten permission checking to ensure we can actually write our initramfs. X-Git-Tag: 008~164 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ebfdb219c63d9139ee9fc249b65e2e761c89586a;p=thirdparty%2Fdracut.git Shorten permission checking to ensure we can actually write our initramfs. These tests can be combined into an if... elif... elif... statement, and that makes it clear they are all part of the same test. --- diff --git a/dracut b/dracut index 33d802a0e..184b0c1c0 100755 --- a/dracut +++ b/dracut @@ -210,18 +210,14 @@ if [[ -f $outfile && ! $force ]]; then exit 1 fi -outdir=$(dirname "$outfile") -if ! [[ -d "$outdir" ]]; then +outdir=${outfile%/*} +if [[ ! -d "$outdir" ]]; then echo "Can't write $outfile: Directory $outdir does not exist." exit 1 -fi - -if ! [[ -w "$outdir" ]]; then +elif [[ ! -w "$outdir" ]]; then echo "No permission to write $outdir." exit 1 -fi - -if [[ -f "$outfile" ]] && ! [[ -w "$outfile" ]]; then +elif [[ ! -w "$outfile" ]]; then echo "No permission to write $outfile." exit 1 fi