]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Introduce virFileCanonicalizePath()
authorAndrea Bolognani <abologna@redhat.com>
Thu, 3 May 2018 07:55:19 +0000 (09:55 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 3 May 2018 16:23:29 +0000 (18:23 +0200)
It's a trivial wrapper around canonicalize_file_name(),
which we need in order to fully mock file access on non-Linux
platforms.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/libvirt_private.syms
src/util/virfile.c
src/util/virfile.h

index ffaa38ccab0c49dcfe7314f5a53201d58c43dcf4..92b5e0fa2bc208aa7056d6c029e71828f88f658f 100644 (file)
@@ -1760,6 +1760,7 @@ virFileAccessibleAs;
 virFileActivateDirOverride;
 virFileBindMountDevice;
 virFileBuildPath;
+virFileCanonicalizePath;
 virFileClose;
 virFileComparePaths;
 virFileCopyACLs;
index e12a584ca1c5383ce265d7ede2c0184f729ffee5..2a16b01ae5141a55a3e7b52dcedf5a6c7e4d4090 100644 (file)
@@ -3299,6 +3299,19 @@ virFileSanitizePath(const char *path)
     return cleanpath;
 }
 
+/**
+ * virFileCanonicalizePath:
+ *
+ * Returns the canonical representation of @path.
+ *
+ * The returned string must be freed after use.
+ */
+char *
+virFileCanonicalizePath(const char *path)
+{
+    return canonicalize_file_name(path);
+}
+
 /**
  * virFileRemoveLastComponent:
  *
index cd2a3867c2674de6ec1c7b6bc64160b0f916b6a5..341320b3d34af356c590c6779cb095d9b768521c 100644 (file)
@@ -218,6 +218,7 @@ int virFileGetMountReverseSubtree(const char *mtabpath,
                                   size_t *nmountsret) ATTRIBUTE_RETURN_CHECK;
 
 char *virFileSanitizePath(const char *path);
+char *virFileCanonicalizePath(const char *path) ATTRIBUTE_NOINLINE;
 
 enum {
     VIR_FILE_OPEN_NONE        = 0,