1 Star 0 Fork 16

吴超超/libosinfo

forked from src-openEuler/libosinfo 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bugfix-do-not-raise-error-on-unknown-osinfo-db-directory.patch 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
syyhao 提交于 2019-12-31 23:48 . init repo
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wcc_140409/libosinfo.git
git@gitee.com:wcc_140409/libosinfo.git
wcc_140409
libosinfo
libosinfo
master

搜索帮助