1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-16 12:22:01 +02:00

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.
This commit is contained in:
Collin Funk
2025-10-26 17:00:03 -07:00
parent dac96ce3e3
commit dfcf92e96c
3 changed files with 4 additions and 4 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);