]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Shorten permission checking to ensure we can actually write our initramfs.
authorVictor Lowther <victor.lowther@gmail.com>
Sat, 14 Aug 2010 19:23:24 +0000 (14:23 -0500)
committerHarald Hoyer <harald@redhat.com>
Mon, 23 Aug 2010 09:51:34 +0000 (11:51 +0200)
These tests can be combined into an if... elif... elif... statement, and
that makes it clear they are all part of the same test.

dracut

diff --git a/dracut b/dracut
index 33d802a0e9bd521c9bacd24176d8eb387a4983fb..184b0c1c05e97b864dd8fe781a3135cb5769fdd0 100755 (executable)
--- 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