diff options
author | Jim Meyering <jim@meyering.net> | 1999-11-07 20:18:11 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1999-11-07 20:18:11 +0000 |
commit | 717d76cf4bc17183413c2b8bc4ee3f97b1da520e (patch) | |
tree | 90062cc6bd8b689a185b1ad443352ab2e19bec9f /src/chgrp.c | |
parent | 8bc2ecda801d0f421a415ef28dbdf275784e3115 (diff) | |
download | coreutils-717d76cf4bc17183413c2b8bc4ee3f97b1da520e.tar.xz |
(xstat): New global.
(main): Define it.
(change_file_group): Use it. Before this change, when running chgrp
on a symlink without --dereference (-h) and when the requested group
is the same as the group for the *symlink*, chgrp would do nothing.
Now it changes the group of the file referenced through the symlink.
Reported by Martin Mitchell.
Diffstat (limited to 'src/chgrp.c')
-rw-r--r-- | src/chgrp.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/chgrp.c b/src/chgrp.c index 82f3ad0e4..52bb78ed0 100644 --- a/src/chgrp.c +++ b/src/chgrp.c @@ -81,6 +81,10 @@ char *program_name; of symbolic links rather than any files they point to. */ static int change_symlinks = 1; +/* When change_symlinks is set, this should be set to `lstat', otherwise, + it should be `stat'. */ +static int (*xstat) (); + /* If nonzero, change the ownership of directories recursively. */ static int recurse; @@ -196,7 +200,7 @@ change_file_group (int cmdline_arg, const char *file, gid_t group) struct stat file_stats; int errors = 0; - if (lstat (file, &file_stats)) + if ((*xstat) (file, &file_stats)) { if (force_silent == 0) error (0, errno, "%s", file); @@ -409,6 +413,11 @@ main (int argc, char **argv) usage (1); } + if (change_symlinks) + xstat = lstat; + else + xstat = stat; + if (reference_file) { struct stat ref_stats; |