diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 5a59f4cfc487ec3d69c71ba002cee8ddad52008c..32492137014ee948e32bc26106c54a0a6fa3264b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,8 +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) \ No newline at end of file +jeremiazhao +joeytao +rockerzhu +tallwu +deshengwu +haifulian +jackxjchen +cunshunxia +abushwang \ No newline at end of file diff --git a/VERSION b/VERSION index 0c62199f16ac1e2d7f7ae75b420c1231325dff4e..ee1372d33a29e27945406f0527f8af8e6ee119c9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.1 +0.2.2 diff --git a/libldevice.spec b/libldevice.spec index b75c9657b88d788cc6558aaf960f1add20ad4ddc..7ea99413e56c1a2941895ea2731083f0d957f44c 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 61b3a99b8ba73fb164a3dfa11f96bb3e87e443f7..42fc913c5f514ac18c3b9aa7dd137e66d2ab2e36 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 3d99e4db91c99d5249c84c3369182240c1b1e219..43022995ffc4ee624b32bef767f17ca26f585379 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 6f995f8fe406051c02df763050c04bc7c76dea87..fc97d4d879327d93442753fb6151f57034a09a2f 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 cd1c8ef2d5e6dfe06822ba302df3f2e28429492a..0000000000000000000000000000000000000000 --- 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; -}