[PATCH v3 1/9] util: Introduce virFileCanonicalizePath()

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

 



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@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/util/virfile.c       | 13 +++++++++++++
 src/util/virfile.h       |  1 +
 3 files changed, 15 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d2728749fb..cbf27ffa05 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1761,6 +1761,7 @@ virFileAccessibleAs;
 virFileActivateDirOverride;
 virFileBindMountDevice;
 virFileBuildPath;
+virFileCanonicalizePath;
 virFileClose;
 virFileComparePaths;
 virFileCopyACLs;
diff --git a/src/util/virfile.c b/src/util/virfile.c
index e12a584ca1..2a16b01ae5 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -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:
  *
diff --git a/src/util/virfile.h b/src/util/virfile.h
index cd2a3867c2..341320b3d3 100644
--- a/src/util/virfile.h
+++ b/src/util/virfile.h
@@ -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,
-- 
2.14.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux