Re: [PATCH 3/4] libmount: mnt_resolve_target: tiptoe around active mount points

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

 



On Thu, Jun 26, 2014 at 10:17:18PM -0700, Eric Rannaud wrote:
>  libmount/src/cache.c       | 124 ++++++++++++++++++++++++++++++++++++++-------
>  libmount/src/fs.c          |   6 ++-
>  libmount/src/libmount.h.in |   4 ++
>  libmount/src/libmount.sym  |   2 +
>  libmount/src/tab.c         |   8 +--
>  5 files changed, 121 insertions(+), 23 deletions(-)

 Applied with small changes, thanks.

> +int mnt_cache_set_targets(struct libmnt_cache *cache,
> +				struct libmnt_table *mtab)

 added docs.

 [...]

> +char *mnt_resolve_target(const char *path, struct libmnt_cache *cache)
> +{
> +	char *p = NULL;
> +	struct libmnt_iter *itr = NULL;
> +	struct libmnt_fs *fs = NULL;

 added fallback to mnt_reolve_path() if no cache or cache->mtab no
 specified.

> +	if (!path)
> +		return NULL;
> +	if (cache)
> +		p = (char *) cache_find_path(cache, path);
> +
> +	if (cache && cache->mtab) {
> +		itr = mnt_new_iter(MNT_ITER_FORWARD);
> +		if (!itr)
> +			goto skip_mtab;

 within libmount we don't allocate iterators, just use "struct
 libmnt_iter" (no pointer) and mnt_reset_iter().

 [...]

> +> diff --git a/libmount/src/fs.c b/libmount/src/fs.c
> index 21ef0f7479fd..82541083a792 100644
> --- a/libmount/src/fs.c
> +++ b/libmount/src/fs.c
> @@ -1413,7 +1413,9 @@ int mnt_fs_append_comment(struct libmnt_fs *fs, const char *comm)
>   *	1) compare @target with @fs->target
>   *	2) realpath(@target) with @fs->target
>   *	3) realpath(@target) with realpath(@fs->target) if @fs is not from
> - *	   /proc/self/mountinfo.
> + *	   /proc/self/mountinfo. However, if mnt_cache_set_targets(cache,
> + *	   mtab) was called, and the path @fs->target is found in @mtab,
> + *	   this comparison is not performed (see mnt_resolve_target()).
>   *
>   * The 2nd and 3rd attempts are not performed when @cache is NULL.
>   *

 I did small change here, it seems that we can use  mnt_resolve_target() also
 for 2nd attempt to avoid canonicalization of the requested path. It
 means that for example:

     findmnt --fstab --target /mnt/nfs

 where "/mnt/nfs" is mounted NFS mounpoint will not canonicalize the
 path from fstab (@fs->target) as well as from command line (@target).

 I have added a debug message to canonicalize_path_and_cache(), so
 from

    LIBMOUNT_DEBUG=0xffff ./findmnt ...

 it's pretty obvious when we call realpath().

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux