[sandbox 08/10] 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 d82076a..c467ca8 100644
--- a/libvirt-sandbox/libvirt-sandbox-config.c
+++ b/libvirt-sandbox/libvirt-sandbox-config.c
@@ -1389,6 +1389,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 1a65e3d..0a9ef3b 100644
--- a/libvirt-sandbox/libvirt-sandbox-config.h
+++ b/libvirt-sandbox/libvirt-sandbox-config.h
@@ -139,6 +139,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 a17dfed..dba4068 100644
--- a/libvirt-sandbox/libvirt-sandbox.sym
+++ b/libvirt-sandbox/libvirt-sandbox.sym
@@ -212,5 +212,6 @@ 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;
 } LIBVIRT_SANDBOX_0.2.1;
-- 
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]