query_module - 向内核查询和模块有关的各个位

本文深入解析了Linux系统中query_module函数的功能与应用,该函数用于获取已加载模块的信息,包括模块名称、依赖关系、导出的符号及值、模块地址、大小和状态等。文章详细介绍了函数参数的作用,如which参数决定返回信息的类型,name参数指定目标模块。同时,阐述了可能遇到的错误情况及其处理方式。

总览

#include <linux/module.h>

int query_module(const char *name, int which,void *buf, size_t bufsize, size _t *ret);

描述

query_module请求和可加载模块有关的来自内核的信息.信息的细致的特性和格式依赖于 which参数,一些函数要求name参数来命名当前被加载的模块.一些允许参数name为null, 指明内核是正确的.: which的值 0 Always returns success. Used to probe for the system call. 0 总是返回成功,用来探测系统调用. /* 参见 insmod -p 和前面文章 */ QM_MODULES Returns the names of all loaded modules. The output buffer
format is adjacent null-terminated strings; ret is set to the number of mod ules.
返回所有已加载的模块的名字.输出缓冲区的格式是邻近的以null终止的字符串;ret 被设置为模块的数目. QM_DEPS Returns the names of all modules used by the indicated module o the number of modules. 返回所有被name参数指定的模块使用的模块的名字.输出缓冲区格式是邻近的以null终止的字符串;ret被设置为模块的数目. QM_REFS Returns the names of all modules using the indicated module. This is the inverse of QM_DEPS. The output buffer format is adjacent null-te rminated strings; ret is set to the number of modules.
返回所有正使用被name参数指定的模块的模块名字.这和QM_DEPS是相反的.输出缓冲区格式是以邻近的null终止的字符串;ret被设置为模块的数目. QM_SYMBOLS Returns the symbols and values exported by the kernel or t he indicated module. The buffer format is an array of:
struct module_symbol
{
unsigned long value;
unsigned long name;
};
followed by null-terminated strings. The value of name is the character offset of the string relative to the start of buf; ret is set to t he number of symbols.
返回被内核或指定模块导出(开放)的符号和值对.缓冲区格式是一个以null终止的结构数组,name的值是相对缓冲区的开始的字符串的字符偏移;ret被设置为符号的数目.


struct module_symbol
{
unsigned long value;
unsigned long value;
} QM_INFO Returns miscelaneous information about the indicated module. The output buffer format is:
struct module_info
{
unsigned long address;
unsigned long size;
unsigned long flags;
};
where address is the kernel address at which the module reside s, size is the size of the module in bytes, and flags is a mask of MOD_RUNNI NG, MOD_AUTOCLEAN, et al that indicates the current status of the module. re t is set to the size of the module_info struct.
返回各种和指定模块相关的各种信息,输出缓冲区的格式如下:
struct module_info
{
unsigned long address;
unsigned long size;
unsigned long flags;
}
address是模块在内核空间中驻留的地址,size是模块以字节计数的大小,flags是MOD_R UNING,MOD_AUTOCLEAN等指示模块当前状态的标志的按位或组成的掩玛.ret被设置为mod ule_info结构的大小.

返回值

成功时总是返回0,错误是返回-1,全局变量errno被相应设置.

错误

ENOENT

被name指定的模块不存在.
EINVAL
ENOSPC

提供的缓冲区太小,ret被设置为需要的最小大小.
EFAULT

name,buf或ret中至少一个越出了程序可访问的地址空间.        

转载于:https://www.cnblogs.com/fanweisheng/p/11097689.html

16:15:27 ERROR: /home/work/mnt/miui_codes2/build_home_rom-krn-merged/kernel/kernel_device_modules-6.12/drivers/spi/BUILD.bazel:37:18: in _kernel_module rule //kernel_device_modules-6.12/drivers/spi:spidev.mgk_64_k612.6.12.userdebug: cycle in dependency graph: 16:15:27 //kernel_device_modules-6.12:mgk_64_k612_customer_modules_install.userdebug (83d3e758bc340144c798cc2d9a974bf064043269bff64f68c3611dc35c4b72d2) 16:15:27 //kernel_device_modules-6.12:mgk_64_k612_customer_modules_install.userdebug (c1569eaf85f423ad8a0e3fff085bef0dd32f0f0d07dad1638459a4c15d676364) 16:15:27 .-> //kernel_device_modules-6.12/drivers/spi:spidev.mgk_64_k612.6.12.userdebug (c1569eaf85f423ad8a0e3fff085bef0dd32f0f0d07dad1638459a4c15d676364) 16:15:27 | //kernel_device_modules-6.12/drivers/spi:spidev.mgk_64_k612.6.12.userdebug_config (c1569eaf85f423ad8a0e3fff085bef0dd32f0f0d07dad1638459a4c15d676364) 16:15:27 `-- //kernel_device_modules-6.12/drivers/spi:spidev.mgk_64_k612.6.12.userdebug (c1569eaf85f423ad8a0e3fff085bef0dd32f0f0d07dad1638459a4c15d676364) 16:15:27 Analyzing: target //kernel_device_modules-6.12:mgk_64_k612_customer_modules_install.userdebug (161 packages loaded, 16228 targets configured) 16:15:27 16:15:27 ERROR: Analysis of target '//kernel_device_modules-6.12:mgk_64_k612_customer_modules_install.userdebug' failed; build aborted 16:15:27 INFO: Elapsed time: 14.083s, Critical Path: 0.56s 16:15:27 INFO: 1 process: 1 internal. 16:15:27 ERROR: Build did NOT complete successfully 16:15:27 ninja: build stopped: subcommand failed.
最新发布
07-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值