summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2007-05-03 04:33:11 +0000
committercperciva <cperciva@FreeBSD.org>2007-05-03 04:33:11 +0000
commit372e0ffbebe4ed301da3904e9a19b9eda8405ec2 (patch)
treeb71ae125fa4a291fa58155f5053f3603f7717f22 /usr.bin
parente8c2f0332704184aca02626e60a00f3e5c87d91f (diff)
downloadFreeBSD-src-372e0ffbebe4ed301da3904e9a19b9eda8405ec2.zip
FreeBSD-src-372e0ffbebe4ed301da3904e9a19b9eda8405ec2.tar.gz
If lstat(2) fails, have bsdtar return a non-zero exit code if the
failed path is one which was specified on the command line. This is a compromise between the situation prior to revision 1.57 (where a race between tar(1) and rm(1) could cause tar(1) to spuriously report an error) and the situation after revision 1.57 (where "tar -c /no/such/path" prints a warning but returns with an exit code of zero). Inspired by: rafan MFC after: 1 week
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tar/write.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c
index ffbee4e..76d6fcf 100644
--- a/usr.bin/tar/write.c
+++ b/usr.bin/tar/write.c
@@ -649,6 +649,16 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path)
if (lst == NULL) {
/* Couldn't lstat(); must not exist. */
bsdtar_warnc(bsdtar, errno, "%s: Cannot stat", name);
+
+ /*
+ * Report an error via the exit code if the failed
+ * path is a prefix of what the user provided via
+ * the command line. (Testing for string equality
+ * here won't work due to trailing '/' characters.)
+ */
+ if (memcmp(name, path, strlen(name)) == 0)
+ bsdtar->return_value = 1;
+
continue;
}
if (S_ISLNK(lst->st_mode))
OpenPOWER on IntegriCloud