.\" Copyright (C) 1996 Free Software Foundation, Inc.
+.\"
+.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
.\" This file is distributed according to the GNU General Public License.
-.\" See the file COPYING in the top level source directory for details.
+.\" %%%LICENSE_END
.\"
.\" 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"
+.TH QUERY_MODULE 2 2017-09-15 "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
+.PP
.BI "int query_module(const char *" name ", int " which ", void *" buf ,
.BI " size_t " bufsize ", size_t *" ret );
.fi
+.PP
+.IR Note :
+No declaration of this system call is provided in glibc headers; see NOTES.
.SH DESCRIPTION
+.IR Note :
+This system call is present only in kernels before Linux 2.6.
+.PP
.BR query_module ()
requests information from the kernel about loadable modules.
The returned information is placed in the buffer pointed to by
to identify a currently loaded module, some allow
.I name
to be NULL, indicating the kernel proper.
-
+.PP
The following values can be specified for
.IR which :
.TP
module.
The returned buffer is an array of structures of the following form
.\" ret is set on ENOSPC
+.IP
.in +4n
-.nf
-
+.EX
struct module_symbol {
unsigned long value;
unsigned long name;
};
-.fi
+.EE
.in
.IP
followed by null-terminated strings.
.B QM_INFO
Returns miscellaneous information about the indicated module.
The output buffer format is:
+.IP
.in +4n
-.nf
-
+.EX
struct module_info {
unsigned long address;
unsigned long size;
unsigned long flags;
};
-.fi
+.EE
.in
.IP
where
is a mask of
.BR MOD_RUNNING ,
.BR MOD_AUTOCLEAN ,
-etc. that indicates the current status of the module
-(see the kernel source file
+and so on, that indicates the current status of the module
+(see the Linux kernel source file
.IR include/linux/module.h ).
.I ret
is set to the size of the
.I module_info
structure.
-.RE
-.SH "RETURN VALUE"
+.SH RETURN VALUE
On success, zero is returned.
On error, \-1 is returned and
.I errno
.TP
.B ENOSYS
.BR query_module ()
-is not supported in this version of the kernel.
-.SH "CONFORMING TO"
+is not supported in this version of the kernel
+(e.g., the kernel is version 2.6 or later).
+.SH VERSIONS
+This system call is present on Linux only up until kernel 2.4;
+it was removed in Linux 2.6.
+.\" Removed in Linux 2.5.48
+.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
+Some of the information that was formerly available via
.BR query_module ()
can be obtained from
.IR /proc/modules ,
.IR /proc/kallsyms ,
-and
-.IR /sys/modules .
-.SH "SEE ALSO"
+and the files under the directory
+.IR /sys/module .
+.PP
+The
+.BR query_module ()
+system call is not supported by glibc.
+No declaration is provided in glibc headers, but,
+through a quirk of history, glibc does export an ABI for this system call.
+Therefore, in order to employ this system call,
+it is sufficient to manually declare the interface in your code;
+alternatively, you can invoke the system call using
+.BR syscall (2).
+.SH SEE ALSO
.BR create_module (2),
.BR delete_module (2),
.BR get_kernel_syms (2),
-.BR init_module (2)
+.BR init_module (2),
+.BR lsmod (8),
+.BR modinfo (8)