From d2294ddfedfcc4b9afcdab276e22775ac6bc66c2 Mon Sep 17 00:00:00 2001 From: jeremiazhao Date: Wed, 12 Jun 2024 08:18:41 +0000 Subject: [PATCH 1/3] update CONTRIBUTORS. Signed-off-by: jeremiazhao --- CONTRIBUTORS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 5a59f4c..33717d6 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -5,4 +5,5 @@ 吴德胜 (deshengwu@tencent.com) 练海富 (haifulian@tencent.com) 陈晓杰 (jackxjchen@tencent.com) -夏存舜 (cunshunxia@tencent.com) \ No newline at end of file +夏存舜 (cunshunxia@tencent.com) +王烁 (abushwang@tencent.com) \ No newline at end of file -- Gitee From 0682382690bcfdd70776bc435a12942625521c74 Mon Sep 17 00:00:00 2001 From: xiaoji <345865759@163.com> Date: Mon, 17 Jun 2024 19:37:13 +0800 Subject: [PATCH 2/3] fixed error when lscpu in non en locale environment --- VERSION | 2 +- libldevice.spec | 11 ++++++++- meson.build | 2 +- src/ldevice.c | 8 +++---- src/ldevice.h | 2 +- src/test.c | 60 ------------------------------------------------- 6 files changed, 17 insertions(+), 68 deletions(-) delete mode 100644 src/test.c diff --git a/VERSION b/VERSION index 0c62199..ee1372d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.1 +0.2.2 diff --git a/libldevice.spec b/libldevice.spec index b75c965..7ea9941 100644 --- a/libldevice.spec +++ b/libldevice.spec @@ -1,5 +1,5 @@ Name: libldevice -Version: 0.2.1 +Version: 0.2.2 Release: 1%{?dist} Summary: A library that collecting device infomation @@ -81,5 +81,14 @@ fi %{_includedir}/ldevice.h %changelog +* Mon Jun 17 2024 Zhao Zhen - 0.2.2-1 +- fixed error when lscpu in non en locale environment + +* Thu Jun 06 2024 Zhao Zhen - 0.2.1-1 +- improved virtual machine support + +* Thu Jun 06 2024 Zhao Zhen - 0.2-1 +- added virtual machine support + * Thu May 16 2024 Zhao Zhen - 0.1-1 - First Build diff --git a/meson.build b/meson.build index 61b3a99..42fc913 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('libldevice', 'c', version: '0.2.1', license: 'LGPL V3') +project('libldevice', 'c', version: '0.2.2', license: 'LGPL V3') # Use dependency function to check for libraries libcrypto_dep = dependency('openssl', modules: 'crypto', required: true) diff --git a/src/ldevice.c b/src/ldevice.c index 3d99e4d..4302299 100644 --- a/src/ldevice.c +++ b/src/ldevice.c @@ -1,7 +1,7 @@ /* * Author: jeremiazhao (赵振) * - * This file is part of libdmi + * This file is part of libldevice * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -203,7 +203,7 @@ const char* system_get_cpu() { char cpu_tmp[512]; // try phisical machine - FILE* model_name = popen("lscpu | grep 'Model name:' | cut -d: -f2", "r"); + FILE* model_name = popen("LANG=en lscpu | grep 'Model name:' | cut -d: -f2", "r"); if(model_name == NULL) { printf("Failed to open /proc/cpuinfo\n"); return NULL; @@ -235,7 +235,7 @@ const char* system_get_cpu() { // try virtual machine - FILE* vendor_id = popen("lscpu | grep 'Vendor ID:' | cut -d: -f2", "r"); + FILE* vendor_id = popen("LANG=en lscpu | grep 'Vendor ID:' | cut -d: -f2", "r"); if(vendor_id == NULL) { printf("Failed to open /proc/cpuinfo\n"); return NULL; @@ -393,7 +393,7 @@ const char* system_get_blkid() { } char command[128]; - snprintf(command, sizeof(command), "blkid %s | sed 's/\"//g'", device); + snprintf(command, sizeof(command), "LANG=en blkid %s | sed 's/\"//g'", device); fp = popen(command, "r"); if (fp == NULL) { diff --git a/src/ldevice.h b/src/ldevice.h index 6f995f8..fc97d4d 100644 --- a/src/ldevice.h +++ b/src/ldevice.h @@ -1,7 +1,7 @@ /* * Author: jeremiazhao (赵振) * - * This file is part of libdmi + * This file is part of libldevice * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free diff --git a/src/test.c b/src/test.c deleted file mode 100644 index cd1c8ef..0000000 --- a/src/test.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Author: jeremiazhao (赵振) - * - * This file is part of libdmi - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for - * more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include - -int main() { - char buffer[1024]; - char *path = getcwd(buffer, sizeof(buffer)); - if(path == NULL) { - perror("getcwd error"); - } - void *handle; - const char *token; - char *error; - char *sopath = "/build/libldevice.so.0"; - strcat(path, sopath); - printf("%s\n", path); - - handle = dlopen(path, RTLD_LAZY); // 加载库文件,路径可能需要调整到你的环境 - if (!handle) { - fprintf(stderr, "%s\n", dlerror()); - exit(EXIT_FAILURE); - } - -// dlerror(); /* 清除可能存在的旧错误 */ - - const char* (*get_token)() = dlsym(handle, "system_get_token"); - token = get_token(); - /* 检查dlsym()是否错误 */ - if ((error = dlerror()) != NULL) { - fprintf(stderr, "%s\n", error); - exit(EXIT_FAILURE); - } - - printf ("%s\n", token); // 调用动态链接的函数 - - dlclose(handle); // 关闭库文件 - - return 0; -} -- Gitee From f9b14905c8fe52f05508e1f14fa786b236b7e184 Mon Sep 17 00:00:00 2001 From: xiaoji <345865759@163.com> Date: Mon, 17 Jun 2024 19:52:24 +0800 Subject: [PATCH 3/3] small fix --- CONTRIBUTORS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 33717d6..3249213 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,9 +1,9 @@ -赵振 (jeremiazhao@tencent.com) -陶松桥 (joeytao@tencent.com) -朱延朋 (rockerzhu@tencent.com) -吴涛 (tallwu@tencent.com) -吴德胜 (deshengwu@tencent.com) -练海富 (haifulian@tencent.com) -陈晓杰 (jackxjchen@tencent.com) -夏存舜 (cunshunxia@tencent.com) -王烁 (abushwang@tencent.com) \ No newline at end of file +jeremiazhao +joeytao +rockerzhu +tallwu +deshengwu +haifulian +jackxjchen +cunshunxia +abushwang \ No newline at end of file -- Gitee