From 670626ab009f1d369be94def71f48be2e88f0106 Mon Sep 17 00:00:00 2001 From: Isaac Dunham Date: Sun, 1 Jun 2014 13:50:39 -0500 Subject: 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. --- toys/posix/cpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toys/posix/cpio.c') 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; -- cgit v1.2.3