]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libmount: mnt_resolve_target: tiptoe around active mount points
authorEric Rannaud <e@nanocritical.com>
Fri, 27 Jun 2014 05:17:18 +0000 (22:17 -0700)
committerKarel Zak <kzak@redhat.com>
Tue, 1 Jul 2014 08:03:40 +0000 (10:03 +0200)
commit0382ba32eda9e9d14d1e425390abf4b1fd1bda6b
treee1e5fb6d007d08628571e0b28e3557652711422e
parent45e8cdba91799c4149c9c7f20bfa7606bf295f7f
libmount: mnt_resolve_target: tiptoe around active mount points

Current code in mnt_fs_match_target() and mnt_table_find_target()
already does not canonicalize active mount points (when read from
mountinfo), because they are already canonicalized by the kernel.
Calling realpath(fs->target) on a mount point can hang -- e.g. if the
NFS server is unreachable.

This patch optionally extends this strategy to the general case, that is
when @fs does not directly come from the kernel through mountinfo (for
instance, it may have been parsed from /etc/fstab).

Given @mtab parsed from mountinfo, and if mnt_cache_set_targets(cache,
mtab) is used, then mnt_fs_match_target() and mnt_table_find_target()
check whether @fs->target is a known mount point in the cached
mountinfo, before attempting to canonicalize @fs->target, no matter
where @fs itself comes from. If found in the cached mountinfo,
@fs->target is not canonicalized.

[kzak@redhat.com: - don't allocate libmnt_iter,
                  - add docs for mnt_cache_set_targets(),
                  - fallback to mnt_resolve_path() if no cache->mtab specified,
                  - use streq_except_trailing_slash() to compare paths]

Signed-off-by: Eric Rannaud <e@nanocritical.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/cache.c
libmount/src/fs.c
libmount/src/libmount.h.in
libmount/src/libmount.sym
libmount/src/tab.c