From f8344a39086ff43f019ebc8ea91f836a4e95c0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 3 Jul 2023 16:28:25 +0200 Subject: [PATCH] pipewire: impl-module: only stat if necessary On some filesystems, the directory entry type is immediately available, so use that to check if the entity is a directory, and only use `stat()` when the entity type cannot be determined from the directory entry. --- src/pipewire/impl-module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pipewire/impl-module.c b/src/pipewire/impl-module.c index 3568a84ac..15488132a 100644 --- a/src/pipewire/impl-module.c +++ b/src/pipewire/impl-module.c @@ -75,7 +75,8 @@ static char *find_module(const char *path, const char *name, int level) if (newpath == NULL) break; - if (stat(newpath, &s) == 0 && S_ISDIR(s.st_mode)) + if (entry->d_type == DT_DIR || + (entry->d_type == DT_UNKNOWN && stat(newpath, &s) == 0 && S_ISDIR(s.st_mode))) filename = find_module(newpath, name, level - 1); free(newpath);