* src/chown-core.c (change_file_owner): Use fstatat, not stat,
authorJim Meyering <jim@meyering.net>
Fri, 13 Oct 2006 18:51:08 +0000 (18:51 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 13 Oct 2006 18:51:08 +0000 (18:51 +0000)
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
src/chown-core.c
tests/chgrp/posix-H

index 021f692..1ca6b44 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2006-10-13  Jim Meyering  <jim@meyering.net>
 
+       * 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.
index dbd3e52..d1efe52 100644 (file)
@@ -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));
index 147bb52..907b7da 100755 (executable)
@@ -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.
 # =========================