Right now cpio ignores the "-u" flag. (-u: Copy unconditionally (normally,
an older file will not replace a newer file with the same name).)

For directories, it behaves like "-u" is not specified, and for regular
files, symlinks, devnode it behaves like "-u" is specified (sort of..)

$ mkdir a
$ touch a/b
$ find a | cpio -o -H newc >a.cpio
$ # at this point, a and a/b still exist
$ cpio -i <a.cpio
cpio: a: File exists
$ echo $?
1

* EEXIST for a. This is behaving like "-u" not specified, so not replacing
existing file/path
* no error for extracting a/b, albeit a/b already exists. This is like "-u"
is specified.
* toybox cpio returns with non-zero exit status.

Should we (1) make "-u" the default behavior of toybox, and not print an
error when "a" already exists?
Or (2) we make "-u" a real option, and toybox would only overwrite existing
files if "-u"? (that is, "-u" would need to be specified explicitly to get
the current behavior)

Another question is, if we go (2), how do we handle existing files for the
non-"-u" case?
(2.1) Do we just skip the file and print an EEXIST message?
Or (2.2) do we check the timestamp like what GNU did?
I think for simplicity (in terms of feature and code size), we should just
go (1). But for SUSv2 compatibility we should do (2), at least (2.1).
I have a WIP patch for (2.1), but I'd like to discuss this before moving
this forward.

-- 

Yi-yo Chiang
Software Engineer
yochi...@google.com
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to