Hi,

When creating archives, cpio relies on the value of the `stat` system call to 
populate the `nlink` member of each entry's header. For directories, the cpio 
format manual ( https://man.archlinux.org/man/cpio.5.en 
<https://man.archlinux.org/man/cpio.5.en> ) notes that "Directories always have 
a value of at least two here.". However, some filesystems, such as BTRFS and 
possibly others ( 
https://linux-btrfs.vger.kernel.narkive.com/oAoDX89D/btrfs-st-nlink-for-directories
 
<https://linux-btrfs.vger.kernel.narkive.com/oAoDX89D/btrfs-st-nlink-for-directories>
 ), always return 1 for `nlink` of a directory. This means that archives 
created on such filesystems violate the format specification and are not 
reproducible.

It would be good to either manually set `nlink` for directories and not trust 
the filesystem, or at least add an option to always force the value to 1 and 
thus make it reproducible across different filesystems.

Thanks for your consideration,
Thomas Watson

Reply via email to