summaryrefslogtreecommitdiff
path: root/lib/chown.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-03-13 05:17:16 +0000
committerJim Meyering <jim@meyering.net>1997-03-13 05:17:16 +0000
commit5ed7bf6069bf4888e1abfe58f86d0843db06f462 (patch)
tree98b39ec2fb437bc294e83cf56b5be246b37696b8 /lib/chown.c
parenta7cbdd04cd6e3c672bfdb85da83c5b5c94ef5d61 (diff)
downloadcoreutils-5ed7bf6069bf4888e1abfe58f86d0843db06f462.tar.xz
.
Diffstat (limited to 'lib/chown.c')
-rw-r--r--lib/chown.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/chown.c b/lib/chown.c
index 2d3b4e821..1d3346d36 100644
--- a/lib/chown.c
+++ b/lib/chown.c
@@ -34,8 +34,17 @@ chown (file, gid, uid)
{
if (gid == (gid_t) -1 || uid == (uid_t) -1)
{
- /* Stat file to get id(s) that will remain unchanged. */
- FIXME
+ struct stat file_stats;
+
+ /* Stat file to get id(s) that should remain unchanged. */
+ if (stat (file, &file_stats))
+ return 1;
+
+ if (gid == (gid_t) -1)
+ gid = file_stats.st_gid;
+
+ if (uid == (uid_t) -1)
+ uid = file_stats.st_uid;
}
#undef chown