在linux(/proc文件系统)中获取图形卡信息

在linux(/proc文件系统)中获取图形卡信息,linux,ubuntu,systems-programming,Linux,Ubuntu,Systems Programming,我可以创建proc文件。我想使用proc read函数了解图形卡信息。我该怎么做? 我的意思不是通过编写lspci vs来了解终端中的信息。 您知道在/proc目录中存储图形卡信息的文件的路径吗 #include <linux/init.h> #include <linux/module.h> #include <linux/proc_fs.h> // read proc function int read_proc(char *buf, char **s

我可以创建proc文件。我想使用proc read函数了解图形卡信息。我该怎么做? 我的意思不是通过编写lspci vs来了解终端中的信息。 您知道在/proc目录中存储图形卡信息的文件的路径吗

#include <linux/init.h>
#include <linux/module.h>
#include <linux/proc_fs.h> 

// read proc function
int read_proc(char *buf, char **start, off_t offset, int count, int *eof, void *data) {
    /* file to be read? */
    return 1;
}

// Module loading..
static int start(void){
    create_proc_read_entry("myproc", 0, NULL, read_proc, NULL);
    return 0;
}


static void fin(void) {
    remove_proc_entry("myproc", NULL);
}

module_init(start);
module_exit(fin);

我不完全确定我是否理解你的问题实际上是关于什么的。但如果你问在哪里可以阅读有关图形卡的信息,这里是我的0.01欧元

PCI设备信息在/sys/bus/PCI/devices下可用

使用lspci查找图形卡的设备编号。例如:lspci | grep-i graphics | awk{print$1}

然后查看/sys/bus/pci/devices中相应的子目录