tar can't create hardlink

Filip Banák filip.banak.62 at gmail.com
Tue Feb 16 17:59:41 UTC 2021


When I tar x -vf (using latest busybox on linux 1.32.1):
image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/
image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/mcfg_sw.mbn
image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/mcfg_sw.mbn
tar: can't create hardlink
'image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/mcfg_sw.mbn'
to
'/image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/mcfg_sw.mbn'

The archive was created form a folder structure that looks like this (with
more files, but not related to the issue):
drwxrwxrwx root/root 0 2011-07-05 19:30:16
image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/
-rwxrwxrwx root/root 35724 2016-05-25 23:29:04
image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/mcfg_sw.mbn
-rwxrwxrwx root/root 0 2016-05-25 23:29:04
image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/mcfg_sw.mbn
->
/image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/mcfg_sw.mbn

Now, as far as I know, one can't have a hardlink with the same name as an
existing file in the same directory,
but my folder in my android device apparently overcame this issue somehow
as you can see, the files are by the OEM not me.

So there is actually just one real file in the archive.
But not only does tar fail and stop, it also deletes the real mcfg_sw.mbn
file, so after it fails the
extracted folder
image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/
is empty.

GNU tar extracts the real file without an error, ignores the weird hardlink
and continues, so all the files are successfully
extracted, except the weird hardlinks, but it doesn't fail.

I wish that busybox tar would behave just like GNU tar in this case.

The consequence of this behavior is that in TWRP android recovery,
which makes use of busybox tar to extract backups so that they can be
restored,
it fails to recover the files from the archive therefore not completing the
restoration.

I know this is weird but as you can see things like this happen.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20210216/12bdf8a1/attachment.html>


More information about the busybox mailing list