From def983628e14436998edc0bf7499a27013b5fe4b Mon Sep 17 00:00:00 2001 From: Romain GARBAGE Date: Wed, 12 Nov 2025 15:36:52 +0100 Subject: [PATCH] pack: Address DT_UNKNOWN case for exotic filesystems. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a followup of 4ce3a53ae5ee832aa92e0345f15780bc7da060d7. In some filesystems, the d_type field in the dirent struct returned by readdir(3) is not properly filled. According to readdir(3), "All applications must properly handle a return of DT_UNKNOWN". This patch addresses the issue. * gnu/packages/aux-files/run-in-namespace.c: Handle DT_UNKNOWN case. Change-Id: Iae3554a01f19a3f30f323916a3426a4068b5df59 Signed-off-by: Ludovic Courtès Modified-by: Ludovic Courtès --- gnu/packages/aux-files/run-in-namespace.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gnu/packages/aux-files/run-in-namespace.c b/gnu/packages/aux-files/run-in-namespace.c index 0ba017cec38381e0b423d3e17f78a2116b60f316..d33f21c3863ce41fb30565e5173bc3dc5039f8c7 100644 --- a/gnu/packages/aux-files/run-in-namespace.c +++ b/gnu/packages/aux-files/run-in-namespace.c @@ -205,11 +205,24 @@ mirror_directory (const char *source, const char *target, /* Create the mount point. */ int err = firmlink (abs_source, entry, new_entry); + int is_directory = 0; + if (entry->d_type == DT_UNKNOWN) + { + struct stat statbuf; + if (fstatat (dir_fd, entry->d_name, &statbuf, + AT_SYMLINK_NOFOLLOW) < 0) + assert_perror (errno); + if ((statbuf.st_mode & S_IFMT) == S_IFDIR) + is_directory = 1; + } + else if (entry->d_type == DT_DIR) + is_directory = 1; + /* It used to be that only directories could be bind-mounted. Thus, keep going if we fail to bind-mount a non-directory entry. That's OK because regular files in the root file system are usually uninteresting. */ - if (err != 0 && entry->d_type != DT_DIR) + if (err != 0 && is_directory == 0) assert_perror (errno); free (new_entry);