这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/tar/another-hardlink.patch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linkat() call you patched is in the extract_link() function.
Changing it to a symlinkat() breaks the explicit intended behavior of the extract_link() function.

A better approach may be to replace the extractor for case LNKTYPE: in prepare_to_extract()

diff --git a/src/extract.c b/src/extract.c
index 314d8bc0..1207f3ad 100644
--- a/src/extract.c
+++ b/src/extract.c
@@ -1694,7 +1694,7 @@ prepare_to_extract (char const *file_name, int typeflag, tar_extractor_t *fun)
       break;
 
     case LNKTYPE:
-      extractor = extract_link;
+      extractor = extract_symlink;
       break;
 
 #if S_IFCHR

This way we aren't changing the behavior of any of the extractor functions, we merely change the extractor function being applied.
We're also sidestepping needing to deal with the linkat() calls in apply_delayed_link() since those have a fallthrough for symlinking if hardlinking isn't an option.

I am still unsure what the implications of changing the extractor type for hardlinks are, there may be unintended consequences to this patch.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- tar-1.35/src/extract.c 2023-07-10 13:13:55.000000000 +0300
+++ src/src/extract.c 2025-09-22 11:47:15.534159916 +0300
@@ -1507,7 +1507,7 @@
{
struct stat st1, st2;
int e;
- int status = linkat (chdir_fd, link_name, chdir_fd, file_name, 0);
+ int status = symlinkat (link_name, chdir_fd, file_name);
e = errno;

if (status == 0)
Loading