]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sulogin: use dirent->d_type when scans /dev
authorKarel Zak <kzak@redhat.com>
Tue, 12 Nov 2013 11:26:13 +0000 (12:26 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 12 Nov 2013 11:26:13 +0000 (12:26 +0100)
... it's more effective than call fstatat() for all device.

Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/sulogin-consoles.c

index 07af33a6de4af25772b327925fc86ac2c7e7a338..6ceea6ba79885ddbad3ceadfa05930b22c5b8190 100644 (file)
@@ -242,6 +242,11 @@ char* scandev(DIR *dir, dev_t comparedev)
        while ((dent = readdir(dir))) {
                char path[PATH_MAX];
                struct stat st;
+
+#ifdef _DIRENT_HAVE_D_TYPE
+               if (dent->d_type != DT_UNKNOWN && dent->d_type != DT_CHR)
+                       continue;
+#endif
                if (fstatat(fd, dent->d_name, &st, 0) < 0)
                        continue;
                if (!S_ISCHR(st.st_mode))