]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut.sh: write directly to the output file
authorHarald Hoyer <harald@redhat.com>
Wed, 19 Feb 2014 14:22:39 +0000 (15:22 +0100)
committerHarald Hoyer <harald@redhat.com>
Tue, 29 Jul 2014 09:52:06 +0000 (11:52 +0200)
Because we already remove the output file before writing to it, we don't
have to play games and write to a temporary file first.

dracut.sh

index 89df9cd89e3097a42af03b61c2fe67e44008666e..c4bf4ebcf1c85a4f81df3babcc961ed8f78282c1 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -729,7 +729,6 @@ fi
 # clean up after ourselves no matter how we die.
 trap '
     ret=$?;
-    [[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f -- "$outfile.$$";
     [[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; };
     [[ $keep ]] && echo "Not removing $early_cpio_dir." >&2 || { [[ $early_cpio_dir ]] && rm -Rf -- "$early_cpio_dir"; };
     [[ $_dlogdir ]] && rm -Rf -- "$_dlogdir";
@@ -1383,15 +1382,13 @@ dinfo "*** Creating image file ***"
 if [[ $create_early_cpio = yes ]]; then
     echo 1 > "$early_cpio_dir/d/early_cpio"
     # The microcode blob is _before_ the initramfs blob, not after
-    (cd "$early_cpio_dir/d";     find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet >../early.cpio)
-    mv $early_cpio_dir/early.cpio $outfile.$$
+    (cd "$early_cpio_dir/d";     find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet > $outfile)
 fi
 if ! ( umask 077; cd "$initdir"; find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet | \
-    $compress >> "$outfile.$$"; ); then
-    dfatal "dracut: creation of $outfile.$$ failed"
+    $compress >> "$outfile"; ); then
+    dfatal "dracut: creation of $outfile failed"
     exit 1
 fi
-mv -- "$outfile.$$" "$outfile"
 dinfo "*** Creating image file done ***"
 
 if (( maxloglvl >= 5 )); then