diff options
author | Eric Rannaud | 2014-06-27 07:17:18 +0200 |
---|---|---|
committer | Karel Zak | 2014-07-01 10:03:40 +0200 |
commit | 0382ba32eda9e9d14d1e425390abf4b1fd1bda6b (patch) | |
tree | e1e5fb6d007d08628571e0b28e3557652711422e /libmount/src/libmount.h.in | |
parent | libmount: mnt_resolve_path: don't canonicalize fs->target for swap (diff) | |
download | kernel-qcow2-util-linux-0382ba32eda9e9d14d1e425390abf4b1fd1bda6b.tar.gz kernel-qcow2-util-linux-0382ba32eda9e9d14d1e425390abf4b1fd1bda6b.tar.xz kernel-qcow2-util-linux-0382ba32eda9e9d14d1e425390abf4b1fd1bda6b.zip |
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>
Diffstat (limited to 'libmount/src/libmount.h.in')
-rw-r--r-- | libmount/src/libmount.h.in | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in index 08ddd6596..ac0c790f2 100644 --- a/libmount/src/libmount.h.in +++ b/libmount/src/libmount.h.in @@ -220,6 +220,8 @@ extern void mnt_free_cache(struct libmnt_cache *cache); extern void mnt_ref_cache(struct libmnt_cache *cache); extern void mnt_unref_cache(struct libmnt_cache *cache); +extern int mnt_cache_set_targets(struct libmnt_cache *cache, + struct libmnt_table *mtab); extern int mnt_cache_read_tags(struct libmnt_cache *cache, const char *devname); extern int mnt_cache_device_has_tag(struct libmnt_cache *cache, @@ -235,6 +237,8 @@ extern char *mnt_get_fstype(const char *devname, int *ambi, __ul_attribute__((warn_unused_result)); extern char *mnt_resolve_path(const char *path, struct libmnt_cache *cache) __ul_attribute__((warn_unused_result)); +extern char *mnt_resolve_target(const char *path, struct libmnt_cache *cache) + __ul_attribute__((warn_unused_result)); extern char *mnt_resolve_tag(const char *token, const char *value, struct libmnt_cache *cache) __ul_attribute__((warn_unused_result)); |