diff options
author | Jim Meyering <jim@meyering.net> | 2003-10-17 13:37:23 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-10-17 13:37:23 +0000 |
commit | 0c73b9e2c55d96293169ddc27e0f52acefed9c31 (patch) | |
tree | 39b037596f4e7d152f905857c4b5f6d2f5dec5db | |
parent | ae7d7b4ad4fd1373c3e05da1e3572d90cfc1056b (diff) | |
download | coreutils-0c73b9e2c55d96293169ddc27e0f52acefed9c31.tar.xz |
(change_file_owner): Handle the cases in
which fts_info indicates an error with the given entry.
-rw-r--r-- | src/chown-core.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/chown-core.c b/src/chown-core.c index 532f84a05..3d95bc5a3 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -173,6 +173,7 @@ change_file_owner (FTS *fts, FTSENT *ent, uid_t old_uid, gid_t old_gid, struct Chown_option const *chopt) { + const char *file_full_name = ent->fts_path; struct stat *file_stats = ent->fts_statp; int errors = 0; @@ -180,10 +181,29 @@ change_file_owner (FTS *fts, FTSENT *ent, if (ent->fts_info == FTS_DP) return 0; + switch (ent->fts_info) + { + case FTS_NS: + error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name)); + return 1; + + case FTS_ERR: + /* if (S_ISDIR (ent->fts_statp->st_mode) && FIXME */ + error (0, ent->fts_errno, _("%s"), quote (file_full_name)); + return 1; + + case FTS_DNR: + error (0, ent->fts_errno, _("cannot read directory %s"), + quote (file_full_name)); + return 1; + + default: + break; + } + if ((old_uid == (uid_t) -1 || file_stats->st_uid == old_uid) && (old_gid == (gid_t) -1 || file_stats->st_gid == old_gid)) { - const char *file_full_name = ent->fts_path; uid_t new_uid = (uid == (uid_t) -1 ? file_stats->st_uid : uid); gid_t new_gid = (gid == (gid_t) -1 ? file_stats->st_gid : gid); if (new_uid != file_stats->st_uid || new_gid != file_stats->st_gid) |