[Toybox] cpio and duplicate directories

Rob Landley rob at landley.net
Fri Mar 10 12:57:33 PST 2023


On 3/9/23 18:25, enh via Toybox wrote:
> i don't _think_ there's been a bug report beyond the discussion on
> https://android-review.googlesource.com/c/platform/test/vts-testcase/kernel/+/2477517,
> so repeating it here...
> 
> """
> The Toybox version of cpio doesn't allow duplicated directories.

It tries to?

      if (mkdir(*toys.optargs, 0700) == -1 && errno != EEXIST)
        perror_exit("mkdir %s", *toys.optargs);

Ah, hang on, that's for -d. (And it should warn instead of exiting.)

Yup, my bug...

> This
> is however not a problem at all for the kernel or other archive
> extraction implementations. Workaround that limitation with the option
> -u which enforces files deletion and also has the side-effect of not failing
> when a folder already exists.

Hmmm, I wonder if I should tackle --sparse.

Did the kernel discussion of xattr support ever revive? The linux-kernel
community has gotten so profoundly unfriendly to non-members that
https://lkml.iu.edu/hypermail/linux/kernel/2302.2/05594.html didn't end well but
I'd happily implement something compatible in cpio.c if the new feature ever
made it past the ever tightening kernel clique.

> """
> 
> """
> This does not relate to the dev nodes but to the folder dev/ which is
> added twice for different orthogonal reasons.


> For some reasons toybox's CPIO does not support this by default unless
> -u is set. (contrary to other implementations)
> """

Bug. I was only checking for errno != EEXIST in one of the two mkdir codepaths.

Try commit d95ea079466c? Checked the fix in, still redoing the cpio.test file
because the host version needs --quiet all the time to not be crazy...

Rob


More information about the Toybox mailing list