[PATCHv1.5 2/8] storage: Add witness for checking storage volume use in security driver

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

 



With my intended use of storage driver assist to chown files on remote
storage we will need a witness that will tell us whether the given
storage volume supports operations needed by the storage driver.
---
 src/storage/storage_driver.c | 30 ++++++++++++++++++++++++++++++
 src/storage/storage_driver.h |  2 ++
 2 files changed, 32 insertions(+)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index efd79b9..b397c6e 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -2357,6 +2357,36 @@ virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src)
            backend->storageFileAccess;
 }

+
+/**
+ * virStorageFileSupportsSecurityDriver:
+ *
+ * @src: a storage file structure
+ *
+ * Check if a storage file supports operations needed by the security
+ * driver to perform labelling */
+bool
+virStorageFileSupportsSecurityDriver(virStorageSourcePtr src)
+{
+    int actualType = virStorageSourceGetActualType(src);
+    virStorageFileBackendPtr backend;
+
+    if (!src)
+        return false;
+
+    if (src->drv) {
+        backend = src->drv->backend;
+    } else {
+        if (!(backend = virStorageFileBackendForTypeInternal(actualType,
+                                                             src->protocol,
+                                                             false)))
+            return false;
+    }
+
+    return !!backend->storageFileChown;
+}
+
+
 void
 virStorageFileDeinit(virStorageSourcePtr src)
 {
diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h
index eefd766..9592dd8 100644
--- a/src/storage/storage_driver.h
+++ b/src/storage/storage_driver.h
@@ -45,6 +45,8 @@ const char *virStorageFileGetUniqueIdentifier(virStorageSourcePtr src);
 int virStorageFileAccess(virStorageSourcePtr src, int mode);
 int virStorageFileChown(virStorageSourcePtr src, uid_t uid, gid_t gid);

+bool virStorageFileSupportsSecurityDriver(virStorageSourcePtr src);
+
 int virStorageFileGetMetadata(virStorageSourcePtr src,
                               uid_t uid, gid_t gid,
                               bool allow_probe)
-- 
2.0.0

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