]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dirent-util: no need to bother with fstatat() for "." and ".." to figure out if these...
authorLennart Poettering <lennart@poettering.net>
Fri, 25 Jun 2021 21:47:02 +0000 (23:47 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 8 Jul 2021 19:18:09 +0000 (04:18 +0900)
src/basic/dirent-util.c

index f6213a305354452cbb6175268b46515cbfba2353..aba14481df258449e9cb4096a11c47dc07b23b3b 100644 (file)
@@ -16,6 +16,11 @@ static int dirent_ensure_type(DIR *d, struct dirent *de) {
         if (de->d_type != DT_UNKNOWN)
                 return 0;
 
+        if (dot_or_dot_dot(de->d_name)) {
+                de->d_type = DT_DIR;
+                return 0;
+        }
+
         if (fstatat(dirfd(d), de->d_name, &st, AT_SYMLINK_NOFOLLOW) < 0)
                 return -errno;