]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
chmod, chown, chgrp: honor --silent (-f) once again
authorOndřej Vašík <ovasik@redhat.com>
Thu, 27 Nov 2008 14:04:10 +0000 (15:04 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 3 Dec 2008 10:02:45 +0000 (11:02 +0100)
* chmod.c (process_file): Make -f suppress fts-related diagnostics.
* chown-core.c (change_file_owner): Likewise.
Reported via <http://bugzilla.redhat.com/474220>.

src/chmod.c
src/chown-core.c

index 80fc363aa30d464c52e7ad71d3e49b54ec5aaacb..8c5cc3e49a714a95f9928e61f71bf9f26f24ecba 100644 (file)
@@ -67,7 +67,7 @@ static mode_t umask_value;
 /* If true, change the modes of directories recursively. */
 static bool recurse;
 
-/* If true, force silence (no error messages). */
+/* If true, force silence (suppress most of error messages). */
 static bool force_silent;
 
 /* If true, diagnose surprises from naive misuses like "chmod -r file".
@@ -121,7 +121,7 @@ mode_changed (char const *file, mode_t old_mode, mode_t new_mode)
 
       if (stat (file, &new_stats) != 0)
        {
-         if (!force_silent)
+         if (! force_silent)
            error (0, errno, _("getting new attributes of %s"), quote (file));
          return false;
        }
@@ -203,24 +203,29 @@ process_file (FTS *fts, FTSENT *ent)
          fts_set (fts, ent, FTS_AGAIN);
          return true;
        }
-      error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name));
+      if (! force_silent)
+        error (0, ent->fts_errno, _("cannot access %s"),
+              quote (file_full_name));
       ok = false;
       break;
 
     case FTS_ERR:
-      error (0, ent->fts_errno, _("%s"), quote (file_full_name));
+      if (! force_silent)
+        error (0, ent->fts_errno, _("%s"), quote (file_full_name));
       ok = false;
       break;
 
     case FTS_DNR:
-      error (0, ent->fts_errno, _("cannot read directory %s"),
-            quote (file_full_name));
+      if (! force_silent)
+        error (0, ent->fts_errno, _("cannot read directory %s"),
+              quote (file_full_name));
       ok = false;
       break;
 
     case FTS_SLNONE:
-      error (0, 0, _("cannot operate on dangling symlink %s"),
-            quote (file_full_name));
+      if (! force_silent)
+        error (0, 0, _("cannot operate on dangling symlink %s"),
+              quote (file_full_name));
       ok = false;
 
     default:
@@ -319,7 +324,8 @@ process_files (char **files, int bit_flags)
          if (errno != 0)
            {
              /* FIXME: try to give a better message  */
-             error (0, errno, _("fts_read failed"));
+             if (! force_silent)
+               error (0, errno, _("fts_read failed"));
              ok = false;
            }
          break;
index 4ab52ac537e034b90e74b10e5fd1dc81e8ef2331..cf0c941b65aee11d4de3990662cbd32069193f21 100644 (file)
@@ -296,18 +296,22 @@ change_file_owner (FTS *fts, FTSENT *ent,
          fts_set (fts, ent, FTS_AGAIN);
          return true;
        }
-      error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name));
+      if (! chopt->force_silent)
+        error (0, ent->fts_errno, _("cannot access %s"),
+              quote (file_full_name));
       ok = false;
       break;
 
     case FTS_ERR:
-      error (0, ent->fts_errno, _("%s"), quote (file_full_name));
+      if (! chopt->force_silent)
+        error (0, ent->fts_errno, _("%s"), quote (file_full_name));
       ok = false;
       break;
 
     case FTS_DNR:
-      error (0, ent->fts_errno, _("cannot read directory %s"),
-            quote (file_full_name));
+      if (! chopt->force_silent)
+        error (0, ent->fts_errno, _("cannot read directory %s"),
+              quote (file_full_name));
       ok = false;
       break;
 
@@ -338,8 +342,9 @@ change_file_owner (FTS *fts, FTSENT *ent,
        {
          if (fstatat (fts->fts_cwd_fd, file, &stat_buf, 0) != 0)
            {
-             error (0, errno, _("cannot dereference %s"),
-                    quote (file_full_name));
+             if (! chopt->force_silent)
+               error (0, errno, _("cannot dereference %s"),
+                      quote (file_full_name));
              ok = false;
            }
 
@@ -492,7 +497,8 @@ chown_files (char **files, int bit_flags,
          if (errno != 0)
            {
              /* FIXME: try to give a better message  */
-             error (0, errno, _("fts_read failed"));
+             if (! chopt->force_silent)
+               error (0, errno, _("fts_read failed"));
              ok = false;
            }
          break;