1QUERY_MODULE(2)            Linux Programmer's Manual           QUERY_MODULE(2)
2
3
4

NAME

6       query_module - query the kernel for various bits pertaining to modules
7

SYNOPSIS

9       #include <linux/module.h>
10
11       int query_module(const char *name, int which, void *buf,
12                        size_t bufsize, size_t *ret);
13
14       Note:  No declaration of this system call is provided in glibc headers;
15       see NOTES.
16

DESCRIPTION

18       Note: This system call is present only in kernels before Linux 2.6.
19
20       query_module() requests information from the kernel about loadable mod‐
21       ules.   The  returned information is placed in the buffer pointed to by
22       buf.  The caller must specify the size of buf in bufsize.  The  precise
23       nature  and  format of the returned information depend on the operation
24       specified by which.  Some operations require name to  identify  a  cur‐
25       rently loaded module, some allow name to be NULL, indicating the kernel
26       proper.
27
28       The following values can be specified for which:
29
30       0      Returns success, if the kernel supports query_module().  Used to
31              probe for availability of the system call.
32
33       QM_MODULES
34              Returns  the  names  of all loaded modules.  The returned buffer
35              consists of a sequence of null-terminated strings; ret is set to
36              the number of modules.
37
38       QM_DEPS
39              Returns  the  names of all modules used by the indicated module.
40              The returned buffer consists of a  sequence  of  null-terminated
41              strings; ret is set to the number of modules.
42
43       QM_REFS
44              Returns  the  names  of  all modules using the indicated module.
45              This is the inverse of QM_DEPS.  The returned buffer consists of
46              a  sequence of null-terminated strings; ret is set to the number
47              of modules.
48
49       QM_SYMBOLS
50              Returns the symbols and values exported by  the  kernel  or  the
51              indicated module.  The returned buffer is an array of structures
52              of the following form
53
54                  struct module_symbol {
55                      unsigned long value;
56                      unsigned long name;
57                  };
58
59              followed by null-terminated strings.  The value of name  is  the
60              character offset of the string relative to the start of buf; ret
61              is set to the number of symbols.
62
63       QM_INFO
64              Returns miscellaneous information about  the  indicated  module.
65              The output buffer format is:
66
67                  struct module_info {
68                      unsigned long address;
69                      unsigned long size;
70                      unsigned long flags;
71                  };
72
73              where address is the kernel address at which the module resides,
74              size is the size of the module in bytes, and flags is a mask  of
75              MOD_RUNNING,  MOD_AUTOCLEAN,  and so on, that indicates the cur‐
76              rent status of the module (see  the  Linux  kernel  source  file
77              include/linux/module.h).   ret  is  set  to the size of the mod‐
78              ule_info structure.
79

RETURN VALUE

81       On success, zero is returned.  On error, -1 is returned  and  errno  is
82       set appropriately.
83

ERRORS

85       EFAULT At  least  one  of  name,  buf, or ret was outside the program's
86              accessible address space.
87
88       EINVAL Invalid which; or name is NULL (indicating  "the  kernel"),  but
89              this is not permitted with the specified value of which.
90
91       ENOENT No module by that name exists.
92
93       ENOSPC The buffer size provided was too small.  ret is set to the mini‐
94              mum size needed.
95
96       ENOSYS query_module() is not supported in this version  of  the  kernel
97              (e.g., the kernel is version 2.6 or later).
98

VERSIONS

100       This  system  call is present on Linux only up until kernel 2.4; it was
101       removed in Linux 2.6.
102

CONFORMING TO

104       query_module() is Linux-specific.
105

NOTES

107       Some of the information that was formerly available via  query_module()
108       can be obtained from /proc/modules, /proc/kallsyms, and the files under
109       the directory /sys/module.
110
111       The query_module() system call is not supported by glibc.  No  declara‐
112       tion  is  provided  in  glibc headers, but, through a quirk of history,
113       glibc does export an ABI for this system call.  Therefore, in order  to
114       employ  this  system  call,  it  is  sufficient to manually declare the
115       interface in your code; alternatively, you can invoke the  system  call
116       using syscall(2).
117

SEE ALSO

119       create_module(2), delete_module(2), get_kernel_syms(2), init_module(2),
120       lsmod(8), modinfo(8)
121

COLOPHON

123       This page is part of release 4.15 of the Linux  man-pages  project.   A
124       description  of  the project, information about reporting bugs, and the
125       latest    version    of    this    page,    can     be     found     at
126       https://www.kernel.org/doc/man-pages/.
127
128
129
130Linux                             2017-09-15                   QUERY_MODULE(2)
Impressum