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)
{
longest_path_match(name, len, cache->path, cache->len,
&previous_slash);
match_flags = cache->flags & track_flags & (FL_NOENT|FL_SYMLINK);
+
+ if (!(track_flags & FL_FULLPATH) && match_len == len)
+ match_len = last_slash = previous_slash;
+
if (match_flags && match_len == cache->len)
return match_flags;
/*
return ret_flags;
}
-/*
- * Invalidate the given 'name' from the cache, if 'name' matches
- * completely with the cache.
- */
-void invalidate_lstat_cache(const char *name, int len)
-{
- int match_len, previous_slash;
- struct cache_def *cache = &default_cache; /* FIXME */
-
- match_len = longest_path_match(name, len, cache->path, cache->len,
- &previous_slash);
- if (len == match_len) {
- if ((cache->track_flags & FL_DIR) && previous_slash > 0) {
- cache->path[previous_slash] = '\0';
- cache->len = previous_slash;
- cache->flags = FL_DIR;
- } else {
- reset_lstat_cache(cache);
- }
- }
-}
+#define USE_ONLY_LSTAT 0
/*
- * Completely clear the contents of the cache
+ * Return non-zero if path 'name' has a leading symlink component
*/
-void clear_lstat_cache(void)
+int threaded_has_symlink_leading_path(struct cache_def *cache, const char *name, int len)
{
- struct cache_def *cache = &default_cache; /* FIXME */
- reset_lstat_cache(cache);
+ return lstat_cache(cache, name, len, FL_SYMLINK|FL_DIR, USE_ONLY_LSTAT) & FL_SYMLINK;
}
-#define USE_ONLY_LSTAT 0
-
/*
* 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);
}
/*