Re: [PATCH 7/3] Make index preloading check the whole path to the file

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

 



Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> writes:

> From: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Date: Thu, 9 Jul 2009 13:37:02 -0700
> Subject: [PATCH 7/3] Make index preloading check the whole path to the file
>
> This uses the new thread-safe 'threaded_has_symlink_leading_path()'
> function to efficiently verify that the whole path leading up to the
> filename is a proper path, and does not contain symlinks.
>
> This makes 'ce_uptodate()' a much stronger guarantee: it no longer just
> guarantees that the 'lstat()' of the path would match, it also means
> that we know that people haven't played games with moving directories
> around and covered it up with symlinks.
>
> Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> ---
>
> Totally trivial, now that we have a thread-safe symlink checker.
>
> If we have leading symlinks in the cache-entry path, we will refuse to 
> mark it up-to-date. There's no need to even try to stat anything under 
> that directory.
>
>  preload-index.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/preload-index.c b/preload-index.c
> index 88edc5f..c3462dc 100644
> --- a/preload-index.c
> +++ b/preload-index.c
> @@ -34,6 +34,7 @@ static void *preload_thread(void *_data)
>  	struct thread_data *p = _data;
>  	struct index_state *index = p->index;
>  	struct cache_entry **cep = index->cache + p->offset;
> +	struct cache_def cache;
>  
>  	nr = p->nr;
>  	if (nr + p->offset > index->cache_nr)
> @@ -49,6 +50,8 @@ static void *preload_thread(void *_data)
>  			continue;
>  		if (!ce_path_match(ce, p->pathspec))
>  			continue;
> +		if (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce)))
> +			continue;

I must be missing something very obvious, but how would this call behave
on an uninitialized cache defined above, or do we need reset_lstat_cache()
on it before the first use?

>  		if (lstat(ce->name, &st))
>  			continue;
>  		if (ie_match_stat(index, ce, &st, CE_MATCH_RACY_IS_DIRTY))
> -- 
> 1.6.3.3.415.ga8877
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]