bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] du,chgrp,chmod,chown: use FTS_DEFER_STAT


From: Jim Meyering
Subject: [PATCH] du,chgrp,chmod,chown: use FTS_DEFER_STAT
Date: Fri, 13 Feb 2009 18:43:03 +0100

Not terribly important, but I was surprised to see that
I had added this to fts (for find) but had never added
it to the fts clients in coreutils.

>From 982504452d60a87632a5a2f11d1be645e06d8346 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 11 Feb 2009 12:26:14 +0100
Subject: [PATCH] du,chgrp,chmod,chown: use FTS_DEFER_STAT

* 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 |    3 ++-
 src/chmod.c |    5 +++--
 src/chown.c |    3 ++-
 src/du.c    |    4 ++--
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/chgrp.c b/src/chgrp.c
index db83c59..0653a90 100644
--- a/src/chgrp.c
+++ b/src/chgrp.c
@@ -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);
diff --git a/src/chmod.c b/src/chmod.c
index 8c5cc3e..91dfbc3 100644
--- a/src/chmod.c
+++ b/src/chmod.c
@@ -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);
 }
diff --git a/src/chown.c b/src/chown.c
index 972b281..00cdb24 100644
--- a/src/chown.c
+++ b/src/chown.c
@@ -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);
diff --git a/src/du.c b/src/du.c
index 860e8fe..0749097 100644
--- 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.  */
--
1.6.2.rc0.234.g2cc0b3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]