summaryrefslogtreecommitdiff
path: root/src/chmod.c
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2014-09-30 18:22:48 +0400
committerIgor Pashev <pashev.igor@gmail.com>2014-09-30 18:22:48 +0400
commitc18578632fd3c9e513e613a86ba2b7c4ebee6c45 (patch)
tree377f4d4e3f0a6471a5012126078fcd97f4c67242 /src/chmod.c
parent974ab3dd887985e3aa347f3c6521f819296396a0 (diff)
downloadcoreutils-c18578632fd3c9e513e613a86ba2b7c4ebee6c45.tar.gz
Imported Upstream version 8.23upstream/8.23
Diffstat (limited to 'src/chmod.c')
-rw-r--r--src/chmod.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/chmod.c b/src/chmod.c
index 2c25ce6d..756ec5a4 100644
--- a/src/chmod.c
+++ b/src/chmod.c
@@ -1,5 +1,5 @@
/* chmod -- change permission modes of files
- Copyright (C) 1989-2013 Free Software Foundation, Inc.
+ Copyright (C) 1989-2014 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -111,7 +111,8 @@ static struct option const long_options[] =
The old mode was OLD_MODE, but it was changed to NEW_MODE. */
static bool
-mode_changed (char const *file, mode_t old_mode, mode_t new_mode)
+mode_changed (int dir_fd, char const *file, char const *file_full_name,
+ mode_t old_mode, mode_t new_mode)
{
if (new_mode & (S_ISUID | S_ISGID | S_ISVTX))
{
@@ -120,10 +121,11 @@ mode_changed (char const *file, mode_t old_mode, mode_t new_mode)
struct stat new_stats;
- if (stat (file, &new_stats) != 0)
+ if (fstatat (dir_fd, file, &new_stats, 0) != 0)
{
if (! force_silent)
- error (0, errno, _("getting new attributes of %s"), quote (file));
+ error (0, errno, _("getting new attributes of %s"),
+ quote (file_full_name));
return false;
}
@@ -283,7 +285,8 @@ process_file (FTS *fts, FTSENT *ent)
if (verbosity != V_off)
{
bool changed = (chmod_succeeded
- && mode_changed (file, old_mode, new_mode));
+ && mode_changed (fts->fts_cwd_fd, file, file_full_name,
+ old_mode, new_mode));
if (changed || verbosity == V_high)
{