From 18b8f5bf5c18115d0546e42951dc951da58a549c Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= Date: Thu, 27 Nov 2008 15:04:10 +0100 Subject: [PATCH] chmod, chown, chgrp: Reduce verbosity of silent mode * chmod.c (process_file): Do not show fts directory-traversal errors in silent mode * chown-core.c (change_file_owner): Likewise --- src/chmod.c | 24 +++++++++++++++--------- src/chown-core.c | 20 +++++++++++++------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/chmod.c b/src/chmod.c index 80fc363..75a25a5 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -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; diff --git a/src/chown-core.c b/src/chown-core.c index 4ab52ac..9dbe374 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -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; -- 1.5.6.1.156.ge903b