[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [PATCH 38/39] backup-files: Keep /dev/null opened
From: |
Jean Delvare |
Subject: |
[Quilt-dev] [PATCH 38/39] backup-files: Keep /dev/null opened |
Date: |
Sat, 19 Mar 2011 10:53:08 +0100 |
User-agent: |
quilt/0.48-17.1 |
Keep /dev/null opened as we will need it repeatedly. Avoiding
repeated calls to open brings a small performance boost.
Signed-off-by: Jean Delvare <address@hidden>
Reviewed-by: Raphael Hertzog <address@hidden>
---
quilt/scripts/backup-files.in | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -1,6 +1,8 @@
#! @BASH@
set -e
+# Keep /dev/null opened as we will need it repeatedly
+exec 4> /dev/null
# Copyright (C) 2006 Steve Langasek <address@hidden>
# Copyright (C) 2011 Jean Delvare <address@hidden>
@@ -78,7 +80,7 @@ backup() {
if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ "$file")" = 1
]; then
cp -p "$file" "$backup"
else
- ln "$file" "$backup" 2> /dev/null || cp -p "$file"
"$backup"
+ ln "$file" "$backup" 2>&4 || cp -p "$file" "$backup"
if [ -n "$OPT_NOLINKS" ]; then
ensure_nolinks "$file"
fi
@@ -104,7 +106,7 @@ restore()
else
mkdir -p "$(dirname "$file")"
fi
- ln "$backup" "$file" 2> /dev/null || cp -p "$backup" "$file"
+ ln "$backup" "$file" 2>&4 || cp -p "$backup" "$file"
if [ -n "$OPT_TOUCH" ]; then
touch "$file"
@@ -118,7 +120,7 @@ restore()
if [ -z "$OPT_KEEP_BACKUP" ]; then
rm "$backup"
- rmdir -p "${backup%/*}" 2> /dev/null || true
+ rmdir -p "${backup%/*}" 2>&4 || true
fi
}
@@ -154,7 +156,7 @@ restore_all()
if (cd "$OPT_PREFIX" && \
xargs -0 cp -l --parents --remove-destination \
--target-directory="$target_dir" \
- < "$NONEMPTY_FILES" 2> /dev/null); then
+ < "$NONEMPTY_FILES" 2>&4); then
while read -d $'\0' -r
do
$ECHO "Restoring ${REPLY#./}"
@@ -171,7 +173,7 @@ restore_all()
local backup=$OPT_PREFIX$file
$ECHO "Restoring $file"
- ln "$backup" "$file" 2> /dev/null || cp -p
"$backup" "$file"
+ ln "$backup" "$file" 2>&4 || cp -p "$backup"
"$file"
done < "$NONEMPTY_FILES"
fi
@@ -240,7 +242,7 @@ copy_many()
# fallback to per-file processing, which always works.
if xargs -0 cp -p --parents --target-directory="$OPT_PREFIX" \
- < "$NONEMPTY_FILES" 2> /dev/null; then
+ < "$NONEMPTY_FILES" 2>&4; then
while read -d $'\0' -r
do
$ECHO "Copying $REPLY"
@@ -258,7 +260,7 @@ copy_many()
some_files_have_links()
{
(cd "$OPT_PREFIX" && find . -type f -print0) \
- | xargs -0 stat @STAT_HARDLINK@ 2> /dev/null | grep -qv '^1$'
+ | xargs -0 stat @STAT_HARDLINK@ 2>&4 | grep -qv '^1$'
}
- [Quilt-dev] [PATCH 10/39] backup-files: Speed up ensure_nolinks, (continued)
- [Quilt-dev] [PATCH 10/39] backup-files: Speed up ensure_nolinks, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 35/39] backup-files: Inline restore_fast, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 20/39] backup-files: Batch mass restore, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 31/39] backup-files: New function for copy, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 37/39] backup-files: Drop support for backup removal, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 08/39] backup-files: Drop variable progname, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 04/39] BSD compatibility: rmdir, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 32/39] backup-files: Separate function copy_many, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 39/39] backup-files: Skip echo-only loops in silent mode, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 34/39] backup-files: Clarify command line options, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 38/39] backup-files: Keep /dev/null opened,
Jean Delvare <=