From dc9790379c129698d0dead906135a4a7b0b551f6 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 13 Oct 2006 18:51:08 +0000 Subject: [PATCH] * src/chown-core.c (change_file_owner): Use fstatat, not stat, now that we're using fts_open with FTS_CWDFD. * tests/chgrp/posix-H: Add --preserve-root to an invocation of chgrp, to exercise the above fix. --- ChangeLog | 5 +++++ src/chown-core.c | 2 +- tests/chgrp/posix-H | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 021f692..1ca6b44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2006-10-13 Jim Meyering + * src/chown-core.c (change_file_owner): Use fstatat, not stat, + now that we're using fts_open with FTS_CWDFD. + * tests/chgrp/posix-H: Add --preserve-root to an invocation of + chgrp, to exercise the above fix. + * src/du-tests: Clean up a little, though it's still not portable. * .vg-suppressions: Add 3 more for debian unstable. diff --git a/src/chown-core.c b/src/chown-core.c index dbd3e52..d1efe52 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -318,7 +318,7 @@ change_file_owner (FTS *fts, FTSENT *ent, stat it to get info on the referent. */ if (S_ISLNK (file_stats->st_mode) && chopt->affect_symlink_referent) { - if (stat (file, &stat_buf) != 0) + if (fstatat (fts->fts_cwd_fd, file, &stat_buf, 0) != 0) { error (0, errno, _("cannot dereference %s"), quote (file_full_name)); diff --git a/tests/chgrp/posix-H b/tests/chgrp/posix-H index 147bb52..907b7da 100755 --- a/tests/chgrp/posix-H +++ b/tests/chgrp/posix-H @@ -1,7 +1,7 @@ #!/bin/sh # Test POSIX-mandated -H option. -# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2005, 2006 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 @@ -50,7 +50,7 @@ fi fail=0 -chgrp -H -R $g2 1s 2 || fail=1 +chgrp --preserve-root -H -R $g2 1s 2 || fail=1 # These must have group $g2. # ========================= -- 2.7.4