1query_module(2) System Calls Manual query_module(2)
2
3
4
6 query_module - query the kernel for various bits pertaining to modules
7
9 #include <linux/module.h>
10
11 [[deprecated]] int query_module(const char *name, int which,
12 void buf[.bufsize], size_t bufsize,
13 size_t *ret);
14
16 Note: This system call is present only before Linux 2.6.
17
18 query_module() requests information from the kernel about loadable mod‐
19 ules. The returned information is placed in the buffer pointed to by
20 buf. The caller must specify the size of buf in bufsize. The precise
21 nature and format of the returned information depend on the operation
22 specified by which. Some operations require name to identify a cur‐
23 rently loaded module, some allow name to be NULL, indicating the kernel
24 proper.
25
26 The following values can be specified for which:
27
28 0 Returns success, if the kernel supports query_module(). Used to
29 probe for availability of the system call.
30
31 QM_MODULES
32 Returns the names of all loaded modules. The returned buffer
33 consists of a sequence of null-terminated strings; ret is set to
34 the number of modules.
35
36 QM_DEPS
37 Returns the names of all modules used by the indicated module.
38 The returned buffer consists of a sequence of null-terminated
39 strings; ret is set to the number of modules.
40
41 QM_REFS
42 Returns the names of all modules using the indicated module.
43 This is the inverse of QM_DEPS. The returned buffer consists of
44 a sequence of null-terminated strings; ret is set to the number
45 of modules.
46
47 QM_SYMBOLS
48 Returns the symbols and values exported by the kernel or the in‐
49 dicated module. The returned buffer is an array of structures
50 of the following form
51
52 struct module_symbol {
53 unsigned long value;
54 unsigned long name;
55 };
56
57 followed by null-terminated strings. The value of name is the
58 character offset of the string relative to the start of buf; ret
59 is set to the number of symbols.
60
61 QM_INFO
62 Returns miscellaneous information about the indicated module.
63 The output buffer format is:
64
65 struct module_info {
66 unsigned long address;
67 unsigned long size;
68 unsigned long flags;
69 };
70
71 where address is the kernel address at which the module resides,
72 size is the size of the module in bytes, and flags is a mask of
73 MOD_RUNNING, MOD_AUTOCLEAN, and so on, that indicates the cur‐
74 rent status of the module (see the Linux kernel source file in‐
75 clude/linux/module.h). ret is set to the size of the mod‐
76 ule_info structure.
77
79 On success, zero is returned. On error, -1 is returned and errno is
80 set to indicate the error.
81
83 EFAULT At least one of name, buf, or ret was outside the program's ac‐
84 cessible address space.
85
86 EINVAL Invalid which; or name is NULL (indicating "the kernel"), but
87 this is not permitted with the specified value of which.
88
89 ENOENT No module by that name exists.
90
91 ENOSPC The buffer size provided was too small. ret is set to the mini‐
92 mum size needed.
93
94 ENOSYS query_module() is not supported in this version of the kernel
95 (e.g., Linux 2.6 or later).
96
98 Linux.
99
101 Removed in Linux 2.6.
102
103 Some of the information that was formerly available via query_module()
104 can be obtained from /proc/modules, /proc/kallsyms, and the files under
105 the directory /sys/module.
106
107 The query_module() system call is not supported by glibc. No declara‐
108 tion is provided in glibc headers, but, through a quirk of history,
109 glibc does export an ABI for this system call. Therefore, in order to
110 employ this system call, it is sufficient to manually declare the in‐
111 terface in your code; alternatively, you can invoke the system call us‐
112 ing syscall(2).
113
115 create_module(2), delete_module(2), get_kernel_syms(2), init_module(2),
116 lsmod(8), modinfo(8)
117
118
119
120Linux man-pages 6.05 2023-03-30 query_module(2)