aboutsummaryrefslogtreecommitdiff
path: root/symlinks.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-07-09 13:35:31 -0700
committerJunio C Hamano <gitster@pobox.com>2009-07-09 20:05:19 -0700
commitb9fd284657de3ec30922fb17c0baf243ae947fdd (patch)
treedb952a083002444b5c95af6f40a39f8b32d258e0 /symlinks.c
parent867f72bf434a05b9eadf851a81564be5173fbba5 (diff)
downloadgit-b9fd284657de3ec30922fb17c0baf243ae947fdd.tar.gz
git-b9fd284657de3ec30922fb17c0baf243ae947fdd.tar.xz
Export thread-safe version of 'has_symlink_leading_path()'
The threaded index preloading will want it, so that it can avoid locking by simply using a per-thread symlink/directory cache. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'symlinks.c')
-rw-r--r--symlinks.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/symlinks.c b/symlinks.c
index 08ad35330..4bdded39c 100644
--- a/symlinks.c
+++ b/symlinks.c
@@ -32,13 +32,7 @@ static int longest_path_match(const char *name_a, int len_a,
return match_len;
}
-static struct cache_def {
- char path[PATH_MAX + 1];
- int len;
- int flags;
- int track_flags;
- int prefix_len_stat_func;
-} default_cache;
+static struct cache_def default_cache;
static inline void reset_lstat_cache(struct cache_def *cache)
{
@@ -217,12 +211,17 @@ void clear_lstat_cache(void)
/*
* Return non-zero if path 'name' has a leading symlink component
*/
+int threaded_has_symlink_leading_path(struct cache_def *cache, const char *name, int len)
+{
+ return lstat_cache(cache, name, len, FL_SYMLINK|FL_DIR, USE_ONLY_LSTAT) & FL_SYMLINK;
+}
+
+/*
+ * Return non-zero if path 'name' has a leading symlink component
+ */
int has_symlink_leading_path(const char *name, int len)
{
- struct cache_def *cache = &default_cache; /* FIXME */
- return lstat_cache(cache, name, len,
- FL_SYMLINK|FL_DIR, USE_ONLY_LSTAT) &
- FL_SYMLINK;
+ return threaded_has_symlink_leading_path(&default_cache, name, len);
}
/*