KDK_HW_GET_PCI_INFO(3)
💖 KDK_HW_GET_PCI_INFO 💖
okay so this is KDK_HW_GET_PCI_INFO(3) from the Library Functions Manual, and bestie, it's literally the page that tells you how to pull your whole PCI bus out of libkysysinfo. sit down, grab a strawberry 🍓, let's go.
✨ NAME ✨
kdk_hw_get_pci_info — 获取总线信息
yes the name is in Chinese, and no we're not skipping it. 获取总线信息 = "get bus information". we contain multitudes 💅
🦋 SYNOPSIS 🦋
#include <libkysysinfo.h>
extern struct KPci *kdk_hw_get_pci_info();
Link with -lkysysinfo.
so you #include <libkysysinfo.h>, you declare the function, and you link with -lkysysinfo. that's the whole vibe check. 🔥
🌸 Detailed Description 🌸
the main function of the interface is to obtain bus information. that's it, that's the girl. no cap, that's literally what the page says and honestly? iconic. she has one job and she ate. 👑
💜 RETURN VALUE 💜
on success, it hands you back a pointer to a KPci structure that's holding all your pci bus information. slay. ✨
the KPci structure is defined in <libkysysinfo.h> like this, exactly:
struct KPci
{
char slot_path[16];
char class_name[128];
char product_name[128];
unsigned char rev;
char ss_name[256];
char driver_use[1024];
char **modules;
int module_count;
struct KPci *next;
};
and on error? it returns NULL. so like, always check her before you start printing. 😭
lowkey important: that next pointer means this is a linked list, not a single struct. you gotta walk the whole chain, bestie. don't just read the first one and call it a day.
🎀 EXAMPLES 🎀
here's the full example, copied exactly, no edits, we don't do that here:
#include <libkysysinfo.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *res = kdk_system_get_architecture();
printf("架构:%s0, res);
free(res);
res = kdk_system_get_systemName();
printf("系统名称:%s0, res);
free(res);
res = kdk_system_get_version(0);
printf("系统简略版本:%s0, res);
free(res);
res = kdk_system_get_version(1);
printf("系统详细版本:%s0, res);
free(res);
res = kdk_system_get_kernelVersion();
printf("内核版本:%s0, res);
free(res);
res = kdk_system_get_serialNumber();
printf("序列号:%s0, res);
free(res);
int p;
int d;
int act = kdk_system_get_activationStatus(&p,&d);
printf("--------------0);
printf("激活状态码:%d0,act);
printf("激活状态:%s0, act == 1 ? "已激活" : act == 0 ? "未激活" : "已过期");
res = kdk_system_get_eUser();
printf("当前用户:%s0, res);
// free(res);
res = kdk_system_get_eUser_login_time();
printf("登录时间:%s0, res);
res = kdk_system_get_projectName();
printf("项目编号名:%s0, res);
free(res);
int zyj = kdk_system_is_zyj();
printf("专用机:%s0, zyj == 0 ? "非专用机":"专用机");
res = kdk_system_get_hostVirtType();
printf("虚拟机类型:%s0, res);
free(res);
res = kdk_system_get_hostCloudPlatform();
printf("云平台类型:%s0, res);
free(res);
version_t test = kdk_system_get_version_detaile( );
printf("test.os_version = %s0,test.os_version);
printf("test.update_version = %s0,test.update_version);
char** name = kdk_system_get_resolving_power();
// printf("name = %s0, name);
size_t count = 0;
while (name[count])
{
printf("No. %d %s0, count + 1, name[count]);
count ++;
}
kdk_resolving_freeall(name);
char *ver = kdk_system_get_systemCategory();
printf("系统硬件版本类别 = %s0, ver);
free(ver);
// ver = kdk_system_get_cloudPlatformType();
// printf("云平台类型 = %s0, ver);
// free(ver);
char **ud_time = kdk_system_get_startup_time();
count = 0;
while (ud_time[count])
{
printf("开机时间 = %s0, ud_time[count]);
count++;
}
kdk_resolving_freeall(ud_time);
ud_time = kdk_system_get_shutdown_time();
count = 0;
while (ud_time[count])
{
printf("关机时间 = %s0, ud_time[count]);
count++;
}
kdk_resolving_freeall(ud_time);
res = kdk_get_host_vendor();
printf("整机制造商 = %s0, res);
free(res);
res = kdk_get_host_product();
printf("整机型号 = %s0, res);
free(res);
res = kdk_get_host_serial();
printf("整机序列号 = %s0, res);
free(res);
res = kdk_system_get_buildTime();
printf("构建时间:%s0, res);
free(res);
res = kdk_system_get_hostName();
printf("主机名:%s0, res);
free(res);
printf("系统位数:%d0, kdk_system_get_word());
struct KPci *pci = kdk_hw_get_pci_info();
struct KPci *tmp = pci;
while (tmp)
{
printf("slot path : %s0, tmp->slot_path);
printf("class name :%s0, tmp->class_name);
printf("product name :%s0, tmp->product_name);
printf("rev :%02x0, tmp->rev);
printf("subsystem name :%s0, tmp->ss_name);
printf("driver user :%s0, tmp->driver_use);
printf("modules :");
for(int i = 0; i < tmp->module_count; i++)
{
printf("%s", tmp->modules[i]);
}
printf("0);
tmp = tmp->next;
}
kdk_hw_free_pci_info(pci);
res = kdk_system_get_appScene();
printf("应用场景:%s0, res);
free(res);
return 0;
}
the part that's actually about this page is the middle bit, bestie, so let me zoom in on it 🧚:
- you call
kdk_hw_get_pci_info()and stash it instruct KPci *pci - you copy that into
struct KPci *tmpso you don't lose the head of the list while (tmp)— you walk the whole linked list, printingslot_path,class_name,product_name,rev(as%02x!),ss_name,driver_use, then loopingifrom0totmp->module_countprintingtmp->modules[i]- then
tmp = tmp->next;and you do it all again - and when you're done you must call
kdk_hw_free_pci_info(pci)— pass the original head pointer, nottmp, becausetmpis sitting atNULLby then 💀
fr fr, don't skip the free. you got the pointer from the library, you give it back to the library. that's the deal. 🫶
🌈 CONFORMING TO 🌈
these functions are as per the withdrawn POSIX.1e draft specification. yes, withdrawn. it's giving vintage. 🕰️
the following functions are Linux extensions:
kdk_system_get_systemName(), kdk_system_get_architecture(), kdk_system_get_activationStatus(), kdk_system_get_version(), kdk_system_get_serialNumber(), kdk_system_get_kernelVersion(), kdk_system_get_eUser(), kdk_system_get_eUser_login_time(), kdk_system_get_projectName(), kdk_system_get_projectSubName(), kdk_system_get_productFeatures(), kdk_system_get_hostVirtType(), kdk_system_get_hostCloudPlatform(), kdk_system_is_zyj(), kdk_system_get_version_detaile(), kdk_system_get_resolving_power(), kdk_system_get_systemCategory(), kdk_system_get_startup_time(), kdk_system_get_shutdown_time(), kdk_get_host_vendor(), kdk_get_host_product(), kdk_get_host_serial(), kdk_system_get_hostName(), kdk_system_get_word(), kdk_system_get_buildTime(), kdk_resolving_freeall(), kdk_hw_free_pci_info(), and kdk_system_get_appScene().
⭐ SEE ALSO ⭐
go read these next, bestie, they're all in the same girl group:
kdk_system_get_systemName(3), kdk_system_get_architecture(3), kdk_system_get_version(3), kdk_system_get_activationStatus(3), kdk_system_get_serialNumber(3), kdk_system_get_kernelVersion(3), kdk_system_get_eUser(3), kdk_system_get_eUser_login_time(3), kdk_system_get_projectName(3), kdk_system_get_projectSubName(3), kdk_system_get_productFeatures(3), kdk_system_get_hostVirtType(3), kdk_system_get_hostCloudPlatform(3), kdk_system_is_zyj(3), kdk_system_get_version_detaile(3), kdk_system_get_resolving_power(3), kdk_system_get_systemCategory(3), kdk_system_get_startup_time(3), kdk_system_get_shutdown_time(3), kdk_get_host_vendor(3), kdk_get_host_product(3), kdk_get_host_serial(3), kdk_system_get_hostName(3), kdk_system_get_word(3), kdk_system_get_buildTime(3), kdk_resolving_freeall(3), kdk_hw_free_pci_info(3), and kdk_system_get_appScene(3).
okay that's the whole page, you're officially PCI-literate, mwah 💋
and for the record? this one came out of the Linux Programmer's Manual, dated Tue Sep 19 2023, filed under KDK_HW_GET_PCI_INFO(3). periodt. 👑✨🦋
📦 where this page comes from
- arch rolling: libkysdk-system 3.0.1.4-1 · LGPL-3.0-or-later AND LGPL-2.1-only OR LGPL-3.0-only AND LGPL-2.1-only WITH Qt-LGPL-exception-1.1 OR LGPL-3.0-only WITH Qt-LGPL-exception-1.1 AND MIT
- ubuntu resolute: libkysdk-system-dev 3.0.1.2-0ubuntu1 · LGPL-3.0-only
- ubuntu stonking: libkysdk-system-dev 3.0.1.3-0ubuntu1 · LGPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms