diff options
author | Isaac Dunham <ibid.ag@gmail.com> | 2014-06-01 13:50:39 -0500 |
---|---|---|
committer | Isaac Dunham <ibid.ag@gmail.com> | 2014-06-01 13:50:39 -0500 |
commit | 670626ab009f1d369be94def71f48be2e88f0106 (patch) | |
tree | cdf9e2e09148f68005e7ccc532e3f0191686fb86 /toys | |
parent | c20fb908bb733a3d7c1dda77a3c1d22d5c3fafec (diff) | |
download | toybox-670626ab009f1d369be94def71f48be2e88f0106.tar.gz |
cpio: archive more files
While writing tests for cpio, I found that cpio tries to open empty
files if they're regular files, and fails to archive them if unreadable.
This can be easily avoided, and is not the usual behavior.
Diffstat (limited to 'toys')
-rw-r--r-- | toys/posix/cpio.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/toys/posix/cpio.c b/toys/posix/cpio.c index 958931e6..668f2ee9 100644 --- a/toys/posix/cpio.c +++ b/toys/posix/cpio.c @@ -202,8 +202,8 @@ void cpio_main(void) if (len<1) break; if (name[len-1] == '\n') name[--len] = 0; nlen = len+1; - if (lstat(name, &st) - || (S_ISREG(st.st_mode) && (fd = open(name, O_RDONLY))<0)) + if (lstat(name, &st) || (S_ISREG(st.st_mode) + && st.st_size && (fd = open(name, O_RDONLY))<0)) { perror_msg("%s", name); continue; |