[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    tar can't create hardlink
From:       Filip BanĂ¡k <filip.banak.62 () gmail ! com>
Date:       2021-02-16 17:59:41
Message-ID: CABbGoW5fFyQobjj+hXh047FVm0ei1swoXBB4BeyKhmfU6zTXXw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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.

[Attachment #5 (text/html)]

<div dir="ltr"><div>When I tar x -vf (using latest busybox on linux \
1.32.1):</div><div>image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/c \
ommerci/</div><div>image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/c \
ommerci/mcfg_sw.mbn</div><div>image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/mcfg_sw.mbn</div><div>tar: \
can&#39;t create hardlink \
&#39;image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/mcfg_sw.mbn&#39; \
to &#39;/image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/mcfg_sw.mbn&#39;</div><div><br></div><div>The \
archive was created form a folder structure that looks like this (with more files, \
but not related to the issue):</div><div>drwxrwxrwx root/root         0 2011-07-05 \
19:30:16 image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/</div><div>-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</div><div>-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 \
-&gt; /image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/mcfg_sw.mbn</div><div><br></div><div>Now, \
as far as I know, one can&#39;t have a hardlink with the same name as an existing \
file in the same directory,</div><div>but my folder in my android device apparently \
overcame this issue somehow as you can see, the files are by the OEM not \
me.</div><div><br></div><div>So there is actually just one real file in the \
archive.</div><div>But not only does tar fail and stop, it also deletes the real \
mcfg_sw.mbn file, so after it fails the</div><div>extracted folder \
image/modem_pr/mcfg/configs/mcfg_sw/generic/china/cmcc/3csfb/dsds/commerci/ is \
empty.<br></div><div><br></div><div>GNU tar extracts the real file without an error, \
ignores the weird hardlink and continues, so all the files are \
successfully</div><div>extracted, except the weird hardlinks, but it doesn&#39;t \
fail.</div><div><br></div><div>I wish that busybox tar would behave just like GNU tar \
in this case.<br></div><div><br></div><div>The consequence of this behavior is that \
in TWRP android recovery,</div><div>which makes use of busybox tar to extract backups \
so that they can be restored,</div><div>it fails to recover the files from the \
archive therefore not completing the restoration.</div><div><br></div><div><div>I \
know this is weird but as you can see things like this happen.</div></div></div>



_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic