]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: prefer FTS_ROOTLEVEL when checking the fts_level of an FTSENT
authorCollin Funk <collin.funk1@gmail.com>
Mon, 27 Oct 2025 00:00:03 +0000 (17:00 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Mon, 27 Oct 2025 23:56:01 +0000 (16:56 -0700)
* 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
src/chmod.c
src/chown-core.c

index a54133a5cd767e374bd620ab63029b4313428ba2..f118820ccd9c528f2edf5fe89a10a1b6dee03f02 100644 (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);
index 1e1cc4cd590ae7b892e8ed3cef61e6f4332c1466..e38fdbd2bc014045a3fed000dbde61717383fa30 100644 (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;
index 0e08f93e609c5de8fa271b4e982df4608a663d97..55d1cf7182dfb871090af220e2231660eefa4143 100644 (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);