[libosinfo PATCH v2 3/6] loader: Set "inherit" accordingly to the resources

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

 



"inherit" is the new attribute of the resources that means whether this
resources should have its (non filled) values inherited.

In case the "inherit" attribute is present and as is "true", let's set
it. Otherwise (the default option), there's no change from the current
behaviour.

https://gitlab.com/libosinfo/osinfo-db/issues/15

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 osinfo/osinfo_loader.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index d1bf61d..21a20fe 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -38,6 +38,7 @@
 #include "ignore-value.h"
 #include "osinfo_install_script_private.h"
 #include "osinfo_device_driver_private.h"
+#include "osinfo_resources_private.h"
 
 #ifndef USB_IDS
 #define USB_IDS PKG_DATA_DIR "/usb.ids"
@@ -1269,13 +1270,17 @@ static OsinfoResources *osinfo_loader_resources(OsinfoLoader *loader,
     guint i;
 
     gchar *arch = (gchar *)xmlGetProp(root, BAD_CAST "arch");
+    gchar *inherit_str = (gchar *)xmlGetProp(root, BAD_CAST "inherit");
     gchar *node_path = g_strjoin("/", ".", name, "*", NULL);
     gint nnodes = osinfo_loader_nodeset(node_path, loader, ctxt, &nodes, err);
+    gboolean inherit = inherit_str != NULL && g_str_equal(inherit_str, "true");
     g_free(node_path);
-    if (error_is_set(err) || nnodes < 1)
+    g_free(inherit_str);
+    if (error_is_set(err) || (!inherit && nnodes < 1))
         goto EXIT;
 
     resources = osinfo_resources_new(id, arch);
+    osinfo_resources_set_inherit(resources, inherit);
 
     for (i = 0; i < nnodes; i++) {
         if (!nodes[i]->children ||
-- 
2.19.1

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




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

  Powered by Linux