]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
du,chgrp,chmod,chown: use FTS_DEFER_STAT
authorJim Meyering <meyering@redhat.com>
Wed, 11 Feb 2009 11:26:14 +0000 (12:26 +0100)
committerJim Meyering <meyering@redhat.com>
Fri, 13 Feb 2009 17:41:01 +0000 (18:41 +0100)
* src/du.c (main): Use FTS_DEFER_STAT, for better locality of inode
reference.  Important when traversing file systems with fake inodes.
* src/chgrp.c (main): Likewise.
* src/chmod.c (main): Likewise.
* src/chown.c (main): Likewise.
The only remaining fts client, chcon, doesn't need this, since it goes
further and uses FTS_NOSTAT, which suppresses all non- directory
stat calls.

src/chgrp.c
src/chmod.c
src/chown.c
src/du.c

index db83c59df8baa9095e4384011c8d6fa9b721006e..0653a9033dbebcd6f60a83d995bda5b5f2d0d122 100644 (file)
@@ -1,5 +1,5 @@
 /* chgrp -- change group ownership of files
-   Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
+   Copyright (C) 89, 90, 91, 1995-2009 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
@@ -302,6 +302,7 @@ main (int argc, char **argv)
               quote ("/"));
     }
 
+  bit_flags |= FTS_DEFER_STAT;
   ok = chown_files (argv + optind, bit_flags,
                    (uid_t) -1, gid,
                    (uid_t) -1, (gid_t) -1, &chopt);
index 8c5cc3e49a714a95f9928e61f71bf9f26f24ecba..91dfbc3aa5208c47e2b7310028ac68fe9e9b800d 100644 (file)
@@ -1,5 +1,5 @@
 /* chmod -- change permission modes of files
-   Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
+   Copyright (C) 89, 90, 91, 1995-2009 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
@@ -534,7 +534,8 @@ main (int argc, char **argv)
       root_dev_ino = NULL;
     }
 
-  ok = process_files (argv + optind, FTS_COMFOLLOW | FTS_PHYSICAL);
+  ok = process_files (argv + optind,
+                     FTS_COMFOLLOW | FTS_PHYSICAL | FTS_DEFER_STAT);
 
   exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
index 972b281af249078cf3a666547b965cad76aba4bd..00cdb242b36aa247b228672ec2975bfbb6c94e63 100644 (file)
@@ -1,5 +1,5 @@
 /* chown -- change user and group ownership of files
-   Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
+   Copyright (C) 89, 90, 91, 1995-2009 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
@@ -326,6 +326,7 @@ main (int argc, char **argv)
               quote ("/"));
     }
 
+  bit_flags |= FTS_DEFER_STAT;
   ok = chown_files (argv + optind, bit_flags,
                    uid, gid,
                    required_uid, required_gid, &chopt);
index 860e8fefa8722e24f0484e9fc969a2ff9f1d47c1..0749097fa6b51dbed4951a7464f4601de844408d 100644 (file)
--- a/src/du.c
+++ b/src/du.c
@@ -1,5 +1,5 @@
 /* du -- summarize disk usage
-   Copyright (C) 1988-1991, 1995-2008 Free Software Foundation, Inc.
+   Copyright (C) 1988-1991, 1995-2009 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
@@ -660,7 +660,7 @@ main (int argc, char **argv)
   char *files_from = NULL;
 
   /* Bit flags that control how fts works.  */
-  int bit_flags = FTS_TIGHT_CYCLE_CHECK;
+  int bit_flags = FTS_TIGHT_CYCLE_CHECK | FTS_DEFER_STAT;
 
   /* Select one of the three FTS_ options that control if/when
      to follow a symlink.  */