diff options
Diffstat (limited to 'system/xar/patches/f_getpath_replacement.diff')
-rw-r--r-- | system/xar/patches/f_getpath_replacement.diff | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/system/xar/patches/f_getpath_replacement.diff b/system/xar/patches/f_getpath_replacement.diff new file mode 100644 index 0000000000..45eca09092 --- /dev/null +++ b/system/xar/patches/f_getpath_replacement.diff @@ -0,0 +1,30 @@ +--- a/lib/archive.c 2024-09-24 16:39:21.000000000 -0400 ++++ b/lib/archive.c 2024-11-23 21:12:31.213747869 -0500 +@@ -493,6 +493,18 @@ + return ret; + } + ++/* 20241123 bkw: work around lack of fcntl() F_GETPATH on Linux */ ++static int fd2path(int fd, char *buf) { ++ char procpath[PATH_MAX]; ++ ++ sprintf(procpath, "/proc/self/fd/%d", fd); ++ ++ if(realpath(procpath, buf)) ++ return 0; ++ ++ return -1; ++} ++ + xar_t xar_fdopen_digest_verify(int fd, int32_t flags, void *expected_toc_digest, size_t expected_toc_digest_len) + { + // Dup the descriptor vended to us so that we don't take ownership +@@ -507,7 +519,7 @@ + // If there are hardlinks, the path we pick is the most recently opened by + // the filesystem; which is effectively random. + char path_buff[PATH_MAX]; +- if (fcntl(fd, F_GETPATH, path_buff) < 0) { ++ if (fd2path(fd, path_buff) < 0) { + close(fd); + return NULL; + } |