Mercurial > hg > toybox
diff toys/posix/cpio.c @ 1331:11fe363078b8 draft
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.
author | Isaac Dunham <ibid.ag@gmail.com> |
---|---|
date | Sun, 01 Jun 2014 13:50:39 -0500 |
parents | c214de62b18b |
children | 2148d1502264 |
line wrap: on
line diff
--- a/toys/posix/cpio.c Sat May 31 11:18:30 2014 +0200 +++ b/toys/posix/cpio.c Sun Jun 01 13:50:39 2014 -0500 @@ -202,8 +202,8 @@ 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;