From dfcf92e96c44906c2387c491a53fd159ac9842a4 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Sun, 26 Oct 2025 17:00:03 -0700 Subject: [PATCH] maint: prefer FTS_ROOTLEVEL when checking the fts_level of an FTSENT * src/chcon.c (process_file): Use FTS_ROOTLEVEL instead of 0. * src/chmod.c (process_file): Likewise. * src/chown-core.c (change_file_owner): Likewise. --- src/chcon.c | 2 +- src/chmod.c | 4 ++-- src/chown-core.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/chcon.c b/src/chcon.c index a54133a5cd..f118820ccd 100644 --- a/src/chcon.c +++ b/src/chcon.c @@ -245,7 +245,7 @@ process_file (FTS *fts, FTSENT *ent) accessible when control reaches this point. So, if this is the first time we've seen the FTS_NS for this file, tell fts_read to stat it "again". */ - if (ent->fts_level == 0 && ent->fts_number == 0) + if (ent->fts_level == FTS_ROOTLEVEL && ent->fts_number == 0) { ent->fts_number = 1; fts_set (fts, ent, FTS_AGAIN); diff --git a/src/chmod.c b/src/chmod.c index 1e1cc4cd59..e38fdbd2bc 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -229,7 +229,7 @@ process_file (FTS *fts, FTSENT *ent) accessible when control reaches this point. So, if this is the first time we've seen the FTS_NS for this file, tell fts_read to stat it "again". */ - if (ent->fts_level == 0 && ent->fts_number == 0) + if (ent->fts_level == FTS_ROOTLEVEL && ent->fts_number == 0) { ent->fts_number = 1; fts_set (fts, ent, FTS_AGAIN); @@ -308,7 +308,7 @@ process_file (FTS *fts, FTSENT *ent) umask_value, change, nullptr); bool follow_symlink = !!dereference; if (dereference == -1) /* -H with/without -R, -P without -R. */ - follow_symlink = ent->fts_level == 0; + follow_symlink = ent->fts_level == FTS_ROOTLEVEL; if (fchmodat (fts->fts_cwd_fd, file, ch.new_mode, follow_symlink ? 0 : AT_SYMLINK_NOFOLLOW) == 0) ch.status = CH_SUCCEEDED; diff --git a/src/chown-core.c b/src/chown-core.c index 0e08f93e60..55d1cf7182 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -327,7 +327,7 @@ change_file_owner (FTS *fts, FTSENT *ent, accessible when control reaches this point. So, if this is the first time we've seen the FTS_NS for this file, tell fts_read to stat it "again". */ - if (ent->fts_level == 0 && ent->fts_number == 0) + if (ent->fts_level == FTS_ROOTLEVEL && ent->fts_number == 0) { ent->fts_number = 1; fts_set (fts, ent, FTS_AGAIN); -- 2.47.3