[sandbox v2 09/11] Add function to check if there is a mount with / target

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

 



gvir_sandbox_config_has_root_mount is a convenience function to check
if there is a mount with target '/'
---
 libvirt-sandbox/libvirt-sandbox-config.c | 21 +++++++++++++++++++++
 libvirt-sandbox/libvirt-sandbox-config.h |  1 +
 libvirt-sandbox/libvirt-sandbox.sym      |  1 +
 3 files changed, 23 insertions(+)

diff --git a/libvirt-sandbox/libvirt-sandbox-config.c b/libvirt-sandbox/libvirt-sandbox-config.c
index b9c13a7..2506072 100644
--- a/libvirt-sandbox/libvirt-sandbox-config.c
+++ b/libvirt-sandbox/libvirt-sandbox-config.c
@@ -1561,6 +1561,27 @@ gboolean gvir_sandbox_config_has_mounts_with_type(GVirSandboxConfig *config,
 }
 
 
+gboolean gvir_sandbox_config_has_root_mount(GVirSandboxConfig *config)
+{
+    GList *tmp = NULL, *mounts = NULL;
+    gboolean hasRoot = FALSE;
+
+    tmp = mounts = gvir_sandbox_config_get_mounts(config);
+    while (tmp && !hasRoot) {
+        const gchar *target;
+        GVirSandboxConfigMount *mount = GVIR_SANDBOX_CONFIG_MOUNT(tmp->data);
+        target = gvir_sandbox_config_mount_get_target(mount);
+        if (g_str_equal(target, "/"))
+            hasRoot = TRUE;
+        tmp = tmp->next;
+    }
+    g_list_foreach(mounts, (GFunc)g_object_unref, NULL);
+    g_list_free(mounts);
+
+    return hasRoot;
+}
+
+
 
 
 /**
diff --git a/libvirt-sandbox/libvirt-sandbox-config.h b/libvirt-sandbox/libvirt-sandbox-config.h
index ebbebf2..2c5f0a6 100644
--- a/libvirt-sandbox/libvirt-sandbox-config.h
+++ b/libvirt-sandbox/libvirt-sandbox-config.h
@@ -150,6 +150,7 @@ gboolean gvir_sandbox_config_add_mount_strv(GVirSandboxConfig *config,
 gboolean gvir_sandbox_config_has_mounts(GVirSandboxConfig *config);
 gboolean gvir_sandbox_config_has_mounts_with_type(GVirSandboxConfig *config,
                                                   GType type);
+gboolean gvir_sandbox_config_has_root_mount(GVirSandboxConfig *config);
 
 gboolean gvir_sandbox_config_add_host_include_strv(GVirSandboxConfig *config,
                                                    gchar **includes,
diff --git a/libvirt-sandbox/libvirt-sandbox.sym b/libvirt-sandbox/libvirt-sandbox.sym
index e5f8660..65b0db5 100644
--- a/libvirt-sandbox/libvirt-sandbox.sym
+++ b/libvirt-sandbox/libvirt-sandbox.sym
@@ -212,6 +212,7 @@ LIBVIRT_SANDBOX_0.2.1 {
 
 LIBVIRT_SANDBOX_0.5.2 {
    global:
+    gvir_sandbox_config_has_root_mount;
 	gvir_sandbox_config_mount_guest_bind_get_format;
 	gvir_sandbox_config_add_disk;
 	gvir_sandbox_config_add_disk_strv;
-- 
2.1.4

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