From 58699165337e8d5be6ea97d3ad8fc2557c99221f Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 18 May 2013 04:38:26 -0400 Subject: [PATCH] Clarify a comment. --- src/ttyname.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ttyname.c b/src/ttyname.c index beb025431..02480ef0a 100644 --- a/src/ttyname.c +++ b/src/ttyname.c @@ -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 -- 2.40.0