]> granicus.if.org Git - sudo/commitdiff
Clarify a comment.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 18 May 2013 08:38:26 +0000 (04:38 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 18 May 2013 08:38:26 +0000 (04:38 -0400)
src/ttyname.c

index beb025431314062598eb17c5cf9942a0390e608c..02480ef0a2e5023d0b621c006f838b6a5f6333c7 100644 (file)
@@ -247,9 +247,12 @@ sudo_ttyname_scan(const char *dir, dev_t rdev, bool builtin)
                continue;
        }
 # if defined(HAVE_STRUCT_DIRENT_D_TYPE) && defined(DTTOIF)
-       /* Use d_type to avoid a stat() if possible. */
-       /* Convert d_type to stat-style type bits but follow links. */
-       if (dp->d_type != DT_LNK && dp->d_type != DT_CHR && dp->d_type != DT_UNKNOWN)
+       /*
+        * Convert dp->d_type to sb.st_mode to avoid a stat(2) if possible.
+        * We can't use it for links (since we want to follow them) or
+        * char devs (since we need st_rdev to compare the device number).
+        */
+       if (dp->d_type != DT_UNKNOWN && dp->d_type != DT_LNK && dp->d_type != DT_CHR)
            sb.st_mode = DTTOIF(dp->d_type);
        else
 # endif