18971c
From 6381b9445980aae6c8533fe74603c902a9125fc5 Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Wed, 19 Feb 2014 15:22:39 +0100
18971c
Subject: [PATCH] dracut.sh: write directly to the output file
18971c
18971c
Because we already remove the output file before writing to it, we don't
18971c
have to play games and write to a temporary file first.
18971c
---
18971c
 dracut.sh | 9 +++------
18971c
 1 file changed, 3 insertions(+), 6 deletions(-)
18971c
18971c
diff --git a/dracut.sh b/dracut.sh
18971c
index 89df9cd8..c4bf4ebc 100755
18971c
--- a/dracut.sh
18971c
+++ b/dracut.sh
18971c
@@ -729,7 +729,6 @@ fi
18971c
 # clean up after ourselves no matter how we die.
18971c
 trap '
18971c
     ret=$?;
18971c
-    [[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f -- "$outfile.$$";
18971c
     [[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; };
18971c
     [[ $keep ]] && echo "Not removing $early_cpio_dir." >&2 || { [[ $early_cpio_dir ]] && rm -Rf -- "$early_cpio_dir"; };
18971c
     [[ $_dlogdir ]] && rm -Rf -- "$_dlogdir";
18971c
@@ -1383,15 +1382,13 @@ dinfo "*** Creating image file ***"
18971c
 if [[ $create_early_cpio = yes ]]; then
18971c
     echo 1 > "$early_cpio_dir/d/early_cpio"
18971c
     # The microcode blob is _before_ the initramfs blob, not after
18971c
-    (cd "$early_cpio_dir/d";     find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet >../early.cpio)
18971c
-    mv $early_cpio_dir/early.cpio $outfile.$$
18971c
+    (cd "$early_cpio_dir/d";     find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet > $outfile)
18971c
 fi
18971c
 if ! ( umask 077; cd "$initdir"; find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet | \
18971c
-    $compress >> "$outfile.$$"; ); then
18971c
-    dfatal "dracut: creation of $outfile.$$ failed"
18971c
+    $compress >> "$outfile"; ); then
18971c
+    dfatal "dracut: creation of $outfile failed"
18971c
     exit 1
18971c
 fi
18971c
-mv -- "$outfile.$$" "$outfile"
18971c
 dinfo "*** Creating image file done ***"
18971c
 
18971c
 if (( maxloglvl >= 5 )); then