[PATCHv3 05/36] test: storage: Initialize storage source to correct type

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

 



Stat the path of the storage file being tested to set the correct type
into the virStorageSource. This will avoid breaking the test suite when
inquiring metadata of directory paths in the next patches.
---

Notes:
    Version 3:
    - ACKed by eric

 tests/virstoragetest.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index fb96c71..746bf63 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -98,6 +98,7 @@ testStorageFileGetMetadata(const char *path,
                            uid_t uid, gid_t gid,
                            bool allow_probe)
 {
+    struct stat st;
     virStorageSourcePtr ret = NULL;

     if (VIR_ALLOC(ret) < 0)
@@ -106,6 +107,15 @@ testStorageFileGetMetadata(const char *path,
     ret->type = VIR_STORAGE_TYPE_FILE;
     ret->format = format;

+    if (stat(path, &st) == 0) {
+        if (S_ISDIR(st.st_mode)) {
+            ret->type = VIR_STORAGE_TYPE_DIR;
+            ret->format = VIR_STORAGE_FILE_DIR;
+        } else if (S_ISBLK(st.st_mode)) {
+            ret->type = VIR_STORAGE_TYPE_BLOCK;
+        }
+    }
+
     if (VIR_STRDUP(ret->relPath, path) < 0)
         goto error;

-- 
1.9.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]