libosinfo/bugfix-do-not-raise-error-on-unknown-osinfo-db-directory.patch
openeuler-basic 7d122d2431 init repo
2019-12-31 23:48:14 +08:00

45 lines
1.6 KiB
Diff

From 3e61b6ccfc2dcb88cc155b7ca33cbe34f20a25b9 Mon Sep 17 00:00:00 2001
From: huangkaibin <huangkaibin@huawei.com>
Date: Fri, 20 Jul 2018 15:54:54 +0800
Subject: [PATCH] libosinfo: Do not raise error on unknown osinfo db directory.
When an osinfo directory can not be acccessed by the running user,
g_file_query_info will return a type of G_FILE_TYPE_UNKNOWN, and
osinfo_loader_find_files will raise an error and abort the application.
This patch fix this problem by just ignoring this unknown osinfo directory.
---
osinfo/osinfo_loader.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index 46bc633..4c30e6c 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -35,6 +35,7 @@
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/xmlreader.h>
+#include <errno.h>
#include "ignore-value.h"
#include "osinfo_install_script_private.h"
#include "osinfo_device_driver_private.h"
@@ -2061,8 +2062,14 @@
}
g_object_unref(ents);
g_list_free(children);
+ } else if (type == G_FILE_TYPE_UNKNOWN) {
+ g_warning("File type unknown. path: %s, errno:%d.", g_file_get_path(file), errno);
} else {
- OSINFO_ERROR(&error, "Unexpected file type");
+ char *error_msg;
+ error_msg = g_strdup_printf("Unexpected file type. type: %d, path: %s, errno:%d.",
+ type, g_file_get_path(file), errno);
+ OSINFO_ERROR(&error, error_msg);
+ free(error_msg);
g_propagate_error(err, error);
}
}
--
1.8.3.1