From: "Todd T. Fries" <todd@fries.net>
To: git@vger.kernel.org
Cc: "Shawn O. Pearce" <spearce@spearce.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Brandon Casey <casey@nrlssc.navy.mil>
Subject: Re: git on afs
Date: Fri, 19 Oct 2007 07:19:19 -0500 [thread overview]
Message-ID: <200710190719.21660.todd@fries.net> (raw)
In-Reply-To: <20071019060624.GK14735@spearce.org>
[-- Attachment #1: Type: text/plain, Size: 2631 bytes --]
Shawn,
If DT_UNKNOWN exists, then we have to do a stat() of some form to
find out the right type.
This is difficult to fix properly to avoid the extra stat() since
inside the switch logic we do the recursion, but we might have
avoided it earlier because of the exclusion.
I'll send a separate diff for an updated link() vs rename() diff.
I've attached an updated diff that should address concerns of everyone
who gave me feedback on my dir.c changes.
Better?
Thanks,
On Friday 19 October 2007 01:06:24 Shawn O. Pearce wrote:
> Linus Torvalds <torvalds@linux-foundation.org> wrote:
> > On Thu, 18 Oct 2007, Todd T. Fries wrote:
> > > 2) git presumes that DTYPE(de) != DT_DIR .. means the dirent is not a
> > > dir this is not true for afs
> >
> > That's a major bug, and has nothing to do with AFS. Oops.
> >
> > If you look just a bit lower, you'll see that just a few lines down, git
> > handles DT_UNKNOWN correctly, and just does a lstat() on it as required.
> > I guess that logic should be moved up, or alternatively the exclude logic
> > should be moved down.
> >
> > Your patch looks ok, but at the same time, I don't think it's really the
> > right thing to do, since it now does that lstat() twice.
>
> What about this instead? It avoids the double lstat() of Todd's
> original patch but seems like it would fix the issue here. Or did
> I misunderstand the problem?
[..]
> diff --git a/dir.c b/dir.c
> index eb6c3ab..d2597ff 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -487,9 +487,10 @@ static int read_directory_recursive(struct dir_struct
> *dir, const char *path, co && in_pathspec(fullname, baselen + len,
> simplify))
> dir_add_ignored(dir, fullname, baselen + len);
> if (exclude != dir->show_ignored) {
> - if (!dir->show_ignored || DTYPE(de) != DT_DIR) {
> + if (!dir->show_ignored)
> + continue;
> + else if (DTYPE(de) != DT_DIR && DTYPE(de) != DT_UNKNOWN)
> continue;
> - }
> }
>
> switch (DTYPE(de)) {
> --
> 1.5.3.4.1249.g895be
--
Todd Fries .. todd@fries.net
_____________________________________________
| \ 1.636.410.0632 (voice)
| Free Daemon Consulting \ 1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com \ 1.866.792.3418 (FAX)
| "..in support of free software solutions." \ 250797 (FWD)
| \
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
37E7 D3EB 74D0 8D66 A68D B866 0326 204E 3F42 004A
http://todd.fries.net/pgp.txt
[-- Attachment #2: 0001-If-readdir-returns-a-DTYPE-of-DT_UNKNOWN-this-w.patch --]
[-- Type: text/x-diff, Size: 1848 bytes --]
From f7bca472645db70b52824e1be827ba99195198d2 Mon Sep 17 00:00:00 2001
From: Todd T. Fries <todd@fries.net>
Date: Fri, 19 Oct 2007 06:26:49 -0500
Subject: [PATCH] If readdir() returns a DTYPE() of DT_UNKNOWN, this warrants further
investigation, i.e. a stat() or lstat(). We have been presuming
anything not DT_DIR is not a dir, which is not the case for
all filesystems (e.g. afs).
Do the lstat() once, and use the results twice.
Signed-off-by: Todd T. Fries <todd@fries.net>
---
dir.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/dir.c b/dir.c
index eb6c3ab..0ed4739 100644
--- a/dir.c
+++ b/dir.c
@@ -468,6 +468,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
while ((de = readdir(fdir)) != NULL) {
int len;
int exclude;
+ struct stat st;
if ((de->d_name[0] == '.') &&
(de->d_name[1] == 0 ||
@@ -486,19 +487,24 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
if (exclude && dir->collect_ignored
&& in_pathspec(fullname, baselen + len, simplify))
dir_add_ignored(dir, fullname, baselen + len);
+ if (DTYPE(de) == DT_UNKNOWN) {
+ if (lstat(fullname, &st))
+ continue;
+ }
if (exclude != dir->show_ignored) {
- if (!dir->show_ignored || DTYPE(de) != DT_DIR) {
+ if (!dir->show_ignored))
continue;
- }
+ if (DTYPE(de) == DT_UNKNOWN && !S_ISDIR(st.st_mode))
+ continue;
+ else
+ if (DTYPE(de) != DT_DIR)
+ continue;
}
switch (DTYPE(de)) {
- struct stat st;
default:
continue;
case DT_UNKNOWN:
- if (lstat(fullname, &st))
- continue;
if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))
break;
if (!S_ISDIR(st.st_mode))
--
1.5.2.5
next prev parent reply other threads:[~2007-10-19 12:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-18 20:31 git on afs Todd T. Fries
2007-10-18 21:28 ` Brandon Casey
2007-10-18 21:57 ` Brandon Casey
2007-10-18 22:47 ` Linus Torvalds
2007-10-19 6:06 ` Shawn O. Pearce
2007-10-19 12:19 ` Todd T. Fries [this message]
2007-10-19 17:59 ` Linus Torvalds
2007-10-19 19:06 ` Linus Torvalds
2007-10-19 5:48 ` Shawn O. Pearce
2007-10-19 12:42 ` Todd T. Fries
2007-10-19 20:19 ` Daniel Barkalow
2007-10-20 5:29 ` Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200710190719.21660.todd@fries.net \
--to=todd@fries.net \
--cc=casey@nrlssc.navy.mil \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).