[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Findutils-patches] [PATCH 2/2] More stat/xstat cleanup.
From: |
James Youngman |
Subject: |
[Findutils-patches] [PATCH 2/2] More stat/xstat cleanup. |
Date: |
Wed, 7 Apr 2010 10:56:24 +0100 |
* find/parser.c (estimate_fstype_success_rate): Change the name of
the variable "dir" to "the_root_dir" to emphasise that it doesn't
matter that we're calling stat rather than options.xstat.
* find/ftsfind.c (symlink_loop): Call options.xstat instead of
stat/lstat, because options.xstat takes account of
state.cwd_dir_fd.
Signed-off-by: James Youngman <address@hidden>
---
find/ftsfind.c | 6 +-----
find/parser.c | 8 ++++----
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/find/ftsfind.c b/find/ftsfind.c
index f5eba7b..7f9f0a8 100644
--- a/find/ftsfind.c
+++ b/find/ftsfind.c
@@ -294,11 +294,7 @@ static bool
symlink_loop (const char *name)
{
struct stat stbuf;
- int rv;
- if (following_links ())
- rv = stat (name, &stbuf);
- else
- rv = lstat (name, &stbuf);
+ const int rv = options.xstat (name, &stbuf);
return (0 != rv) && (ELOOP == errno);
}
diff --git a/find/parser.c b/find/parser.c
index 5bfe25d..f29f58b 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -1050,10 +1050,10 @@ parse_fprint0 (const struct parser_table* entry, char
**argv, int *arg_ptr)
static float estimate_fstype_success_rate (const char *fsname)
{
struct stat dir_stat;
- const char *dir = "/";
- if (0 == stat (dir, &dir_stat))
+ const char *the_root_dir = "/";
+ if (0 == stat (the_root_dir, &dir_stat)) /* it's an absolute path anyway */
{
- const char *fstype = filesystem_type (&dir_stat, dir);
+ const char *fstype = filesystem_type (&dir_stat, the_root_dir);
/* Assume most files are on the same file system type as the root fs. */
if (0 == strcmp (fsname, fstype))
return 0.7f;
@@ -2411,7 +2411,7 @@ parse_samefile (const struct parser_table* entry, char
**argv, int *arg_ptr)
if (fd == -1)
{
/* Race condition here. The file might become a
- * symbolic link in between out call to stat and
+ * symbolic link in between our call to stat and
* the call to open.
*/
fd = open (argv[*arg_ptr], openflags);
--
1.7.0