1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
.\" Copyright (C) 1996 Free Software Foundation, Inc.
.\" This file is distributed according to the GNU General Public License.
.\" See the file COPYING in the top level source directory for details.
.\"
.\" 2006-02-09, some reformatting by Luc Van Oostenryck; some
.\" reformatting and rewordings by mtk
.\"
.TH QUERY_MODULE 2 2007-06-03 "Linux" "Linux Programmer's Manual"
.SH NAME
query_module \- query the kernel for various bits pertaining to modules
.SH SYNOPSIS
.nf
.B #include <linux/module.h>
.sp
.BI "int query_module(const char *" name ", int " which ", void *" buf ,
.BI " size_t " bufsize ", size_t *" ret );
.fi
.SH DESCRIPTION
.BR query_module ()
requests information from the kernel about loadable modules.
The returned information is placed in the buffer pointed to by
.IR buf .
The caller must specify the size of
.I buf
in
.IR bufsize .
The precise nature and format of the returned information
depend on the operation specified by
.IR which .
Some operations require
.I name
to identify a currently loaded module, some allow
.I name
to be NULL, indicating the kernel proper.
The following values can be specified for
.IR which :
.TP
.B 0
Returns success, if the kernel supports
.BR query_module ().
Used to probe for availability of the system call.
.TP
.B QM_MODULES
Returns the names of all loaded modules.
The returned buffer consists of a sequence of null-terminated strings;
.I ret
is set to the number of
modules.
.\" ret is set on ENOSPC
.TP
.B QM_DEPS
Returns the names of all modules used by the indicated module.
The returned buffer consists of a sequence of null-terminated strings;
.I ret
is set to the number of modules.
.\" ret is set on ENOSPC
.TP
.B QM_REFS
Returns the names of all modules using the indicated module.
This is the inverse of
.BR QM_DEPS .
The returned buffer consists of a sequence of null-terminated strings;
.I ret
is set to the number of modules.
.\" ret is set on ENOSPC
.TP
.B QM_SYMBOLS
Returns the symbols and values exported by the kernel or the indicated
module.
The returned buffer is an array of structures of the following form
.\" ret is set on ENOSPC
.in +4n
.nf
struct module_symbol {
unsigned long value;
unsigned long name;
};
.fi
.in
.IP
followed by null-terminated strings.
The value of
.I name
is the character offset of the string relative to the start of
.IR buf ;
.I ret
is set to the number of symbols.
.TP
.B QM_INFO
Returns miscellaneous information about the indicated module.
The output buffer format is:
.in +4n
.nf
struct module_info {
unsigned long address;
unsigned long size;
unsigned long flags;
};
.fi
.in
.IP
where
.I address
is the kernel address at which the module resides,
.I size
is the size of the module in bytes, and
.I flags
is a mask of
.BR MOD_RUNNING ,
.BR MOD_AUTOCLEAN ,
etc. that indicates the current status of the module
(see the kernel source file
.IR include/linux/module.h ).
.I ret
is set to the size of the
.I module_info
structure.
.SH "RETURN VALUE"
On success, zero is returned.
On error, \-1 is returned and
.I errno
is set appropriately.
.SH ERRORS
.TP
.B EFAULT
At least one of
.IR name ,
.IR buf ,
or
.I ret
was outside the program's accessible address space.
.TP
.B EINVAL
Invalid
.IR which ;
or
.I name
is NULL (indicating "the kernel"),
but this is not permitted with the specified value of
.IR which .
.\" Not permitted with QM_DEPS, QM_REFS, or QM_INFO.
.TP
.B ENOENT
No module by that
.I name
exists.
.TP
.B ENOSPC
The buffer size provided was too small.
.I ret
is set to the minimum size needed.
.TP
.B ENOSYS
.BR query_module ()
is not supported in this version of the kernel.
.SH "CONFORMING TO"
.BR query_module ()
is Linux-specific.
.SH NOTES
This system call is only present on Linux up until kernel 2.4;
it was removed in Linux 2.6.
.\" Removed in Linux 2.5.48
Some of the information that was available via
.BR query_module ()
can be obtained from
.IR /proc/modules ,
.IR /proc/kallsyms ,
and
.IR /sys/modules .
.SH "SEE ALSO"
.BR create_module (2),
.BR delete_module (2),
.BR get_kernel_syms (2),
.BR init_module (2)
.SH COLOPHON
This page is part of release 3.27 of the Linux
.I man-pages
project.
A description of the project,
and information about reporting bugs,
can be found at
http://www.kernel.org/doc/man-pages/.
|