]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: always use mnt_resolve_target() in mnt_fs_match_target()
authorKarel Zak <kzak@redhat.com>
Tue, 1 Jul 2014 08:34:09 +0000 (10:34 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 1 Jul 2014 08:34:09 +0000 (10:34 +0200)
The requested path is also target mountpoint, so let's optimize
realpath() usage as well.

Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/cache.c
libmount/src/fs.c

index 05b078b4451a5ce7417b0d260ab59088bccc8bd3..8b2e6560f8ccc6557d1f61c733d9fecdec889f39 100644 (file)
@@ -504,6 +504,7 @@ static char *canonicalize_path_and_cache(const char *path,
        char *key = NULL;
        char *value = NULL;
 
+       DBG(CACHE, ul_debugobj(cache, "canonicalize path %s", path));
        p = canonicalize_path(path);
 
        if (p && cache) {
index 82541083a79223b3a1711c60b0e1f23a8e5afea9..fe3260bb344c43dc5787421be51048b09d82987c 100644 (file)
@@ -1411,11 +1411,15 @@ int mnt_fs_append_comment(struct libmnt_fs *fs, const char *comm)
  *
  * Possible are three attempts:
  *     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. 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()).
+ *        /proc/self/mountinfo.
+ *
+ *        However, if mnt_cache_set_targets(cache, mtab) was called, and the
+ *        path @target or @fs->target is found in the @mtab, the canonicalization is
+ *        is not performed (see mnt_resolve_target()).
  *
  * The 2nd and 3rd attempts are not performed when @cache is NULL.
  *
@@ -1435,7 +1439,7 @@ int mnt_fs_match_target(struct libmnt_fs *fs, const char *target,
 
        if (!rc && cache) {
                /* 2) - canonicalized and non-canonicalized */
-               char *cn = mnt_resolve_path(target, cache);
+               char *cn = mnt_resolve_target(target, cache);
                rc = (cn && mnt_fs_streq_target(fs, cn));
 
                /* 3) - canonicalized and canonicalized */