summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Bosboom2025-12-14 06:38:47 +0000
committerDaniel Golle2026-02-09 11:02:43 +0000
commitc4e9859876d5db7d8d69e8dc92bc7fde44ee96ec (patch)
treed8ec54fc599962c0a80fc730ff7100260bb826e8
parentbafdfff100d3bf1e91d35664b97cfd101d564416 (diff)
hotplug-dispatch: use stat if d_type is DT_UNKNOWN
As documented in the readdir man page, support for d_type varies by filesystem. The ISO 9660 filesystem used in the x86 target's bootable ISO images always sets d_type to DT_UNKNOWN. Fall back to checking S_ISDIR(st_mode) when d_type is DT_UNKNOWN. Fixes: 08938fe ("procd: add hotplug-call dispatcher") Signed-off-by: Jeffrey Bosboom <jbosboom@jeffreybosboom.com>
-rw-r--r--hotplug-dispatch.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/hotplug-dispatch.c b/hotplug-dispatch.c
index fd87a09..c89c90a 100644
--- a/hotplug-dispatch.c
+++ b/hotplug-dispatch.c
@@ -390,6 +390,7 @@ static int init_subsystems(void)
{
DIR *dir;
struct dirent *dirent;
+ struct stat st;
add_subsystem("button");
@@ -399,7 +400,11 @@ static int init_subsystems(void)
while ((dirent = readdir(dir))) {
/* skip everything but directories */
- if (dirent->d_type != DT_DIR)
+ if (dirent->d_type == DT_UNKNOWN) {
+ if ((fstatat(dirfd(dir), dirent->d_name, &st, AT_SYMLINK_NOFOLLOW) == -1)
+ || !S_ISDIR(st.st_mode))
+ continue;
+ } else if (dirent->d_type != DT_DIR)
continue;
/* skip '.' and '..' as well as hidden files */