summaryrefslogtreecommitdiffstats
path: root/man2/query_module.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/query_module.2')
-rw-r--r--man2/query_module.2194
1 files changed, 194 insertions, 0 deletions
diff --git a/man2/query_module.2 b/man2/query_module.2
new file mode 100644
index 0000000..519650a
--- /dev/null
+++ b/man2/query_module.2
@@ -0,0 +1,194 @@
+.\" Copyright (C) 1996 Free Software Foundation, Inc.
+.\"
+.\" SPDX-License-Identifier: GPL-1.0-or-later
+.\"
+.\" 2006-02-09, some reformatting by Luc Van Oostenryck; some
+.\" reformatting and rewordings by mtk
+.\"
+.TH query_module 2 2023-03-30 "Linux man-pages 6.05.01"
+.SH NAME
+query_module \- query the kernel for various bits pertaining to modules
+.SH SYNOPSIS
+.nf
+.B #include <linux/module.h>
+.PP
+.BI "[[deprecated]] int query_module(const char *" name ", int " which ,
+.BI " void " buf [. bufsize "], \
+size_t " bufsize ,
+.BI " size_t *" ret );
+.fi
+.SH DESCRIPTION
+.IR Note :
+This system call is present only 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
+.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.
+.PP
+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
+.IP
+.in +4n
+.EX
+struct module_symbol {
+ unsigned long value;
+ unsigned long name;
+};
+.EE
+.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:
+.IP
+.in +4n
+.EX
+struct module_info {
+ unsigned long address;
+ unsigned long size;
+ unsigned long flags;
+};
+.EE
+.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 ,
+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.
+.SH RETURN VALUE
+On success, zero is returned.
+On error, \-1 is returned and
+.I errno
+is set to indicate the error.
+.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
+(e.g., Linux 2.6 or later).
+.SH STANDARDS
+Linux.
+.SH VERSIONS
+Removed in Linux 2.6.
+.\" Removed in Linux 2.5.48
+.PP
+Some of the information that was formerly available via
+.BR query_module ()
+can be obtained from
+.IR /proc/modules ,
+.IR /proc/kallsyms ,
+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 lsmod (8),
+.BR modinfo (8)