xref: /minix3/lib/libc/sys/modctl.2 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: modctl.2,v 1.11 2015/05/09 08:10:01 pgoyette Exp $
22fe8fb19SBen Gras.\"
32fe8fb19SBen Gras.\" Copyright (c) 2009 The NetBSD Foundation, Inc.
42fe8fb19SBen Gras.\" All rights reserved.
52fe8fb19SBen Gras.\"
62fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
72fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
82fe8fb19SBen Gras.\" are met:
92fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
102fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
112fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
122fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
132fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
142fe8fb19SBen Gras.\"
152fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
162fe8fb19SBen Gras.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
172fe8fb19SBen Gras.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
182fe8fb19SBen Gras.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
192fe8fb19SBen Gras.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
202fe8fb19SBen Gras.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
212fe8fb19SBen Gras.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
222fe8fb19SBen Gras.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
232fe8fb19SBen Gras.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
242fe8fb19SBen Gras.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
252fe8fb19SBen Gras.\" POSSIBILITY OF SUCH DAMAGE.
262fe8fb19SBen Gras.\"
27*0a6a1f1dSLionel Sambuc.Dd May 9, 2015
282fe8fb19SBen Gras.Dt MODCTL 2
292fe8fb19SBen Gras.Os
302fe8fb19SBen Gras.Sh NAME
312fe8fb19SBen Gras.Nm modctl
322fe8fb19SBen Gras.Nd module control
332fe8fb19SBen Gras.Sh LIBRARY
342fe8fb19SBen Gras.Lb libc
352fe8fb19SBen Gras.Sh SYNOPSIS
362fe8fb19SBen Gras.In sys/module.h
372fe8fb19SBen Gras.Ft int
382fe8fb19SBen Gras.Fn modctl "int operation" "void *argp"
392fe8fb19SBen Gras.Sh DESCRIPTION
402fe8fb19SBen Gras.Fn modctl
412fe8fb19SBen Grasprovides control over loaded kernel modules.
422fe8fb19SBen GrasThe argument
432fe8fb19SBen Gras.Fa operation
442fe8fb19SBen Grasis one of
452fe8fb19SBen Gras.Dv MODCTL_LOAD ,
462fe8fb19SBen Gras.Dv MODCTL_UNLOAD ,
47f14fb602SLionel Sambuc.Dv MODCTL_STAT ,
482fe8fb19SBen Grasor
49f14fb602SLionel Sambuc.Dv MODCTL_EXISTS .
502fe8fb19SBen GrasThe argument
512fe8fb19SBen Gras.Fa argp
522fe8fb19SBen Grasdepends on the
532fe8fb19SBen Gras.Fa operation
542fe8fb19SBen Grasto be performed.
552fe8fb19SBen Gras.Pp
562fe8fb19SBen GrasOperations are:
572fe8fb19SBen Gras.Bl -tag -width MODCTL_UNLOAD
582fe8fb19SBen Gras.It Dv MODCTL_LOAD
592fe8fb19SBen GrasLoad a module.
602fe8fb19SBen GrasThe
612fe8fb19SBen Gras.Fa argp
622fe8fb19SBen Grasargument should be a pointer to a
632fe8fb19SBen Gras.Em modctl_load_t
642fe8fb19SBen Grasstructure, described below.
652fe8fb19SBen Gras.It Dv MODCTL_UNLOAD
662fe8fb19SBen GrasUnload a module.
672fe8fb19SBen GrasIn this case,
682fe8fb19SBen Gras.Fa argp
692fe8fb19SBen Grasshould be a string containing the name of the module to be unloaded.
702fe8fb19SBen Gras.It Dv MODCTL_STAT
712fe8fb19SBen GrasReturn a list of loaded modules.
722fe8fb19SBen GrasIn this case, the
732fe8fb19SBen Gras.Fa argp
742fe8fb19SBen Grasargument should be a
752fe8fb19SBen Gras.Em struct iovec
762fe8fb19SBen Graspointing to a suitable block of memory.
772fe8fb19SBen GrasThe kernel will fill this block with an array of
782fe8fb19SBen Gras.Em modstat_t
792fe8fb19SBen Grasstructures, one per loaded module.
802fe8fb19SBen GrasIf the block is not large enough, the data returned will be truncated
812fe8fb19SBen Grasto fit.
822fe8fb19SBen GrasThe kernel will then update the
832fe8fb19SBen Gras.Fa iov_len
842fe8fb19SBen Grasmember of the
852fe8fb19SBen Gras.Em iovec
862fe8fb19SBen Grasto reflect the size of the complete report, regardless of whether this
872fe8fb19SBen Grasis larger or smaller than the size passed in.
88f14fb602SLionel Sambuc.It Dv MODCTL_EXISTS
89f14fb602SLionel SambucTest to see if the kernel was compiled with
90f14fb602SLionel Sambuc.Dq options MODULAR
91f14fb602SLionel Sambucand whether or
92f14fb602SLionel Sambucnot modules may be loaded at the moment.
93f14fb602SLionel SambucIn this case,
94f14fb602SLionel Sambuc.Fa argp
95f14fb602SLionel Sambucshould be an integer.
96f14fb602SLionel SambucIt should be
97f14fb602SLionel Sambuc.Dq 0
98f14fb602SLionel Sambucto test if a user can load a module via
99f14fb602SLionel Sambuc.Dv MODCTL_LOAD ,
100f14fb602SLionel Sambucor it should be
101f14fb602SLionel Sambuc.Dq 1
102f14fb602SLionel Sambucto test if the system can autoload modules.
103f14fb602SLionel SambucNote that this
104f14fb602SLionel Sambuctest does not consider the sysctl
105f14fb602SLionel Sambuc.Li kern.module.autoload .
1062fe8fb19SBen Gras.El
1072fe8fb19SBen Gras.Ss Data Types
1082fe8fb19SBen GrasThe
1092fe8fb19SBen Gras.Em modctl_load_t
1102fe8fb19SBen Grasstructure used with
1112fe8fb19SBen Gras.Dv MODCTL_LOAD
1122fe8fb19SBen Grascontains the following elements, which should be filled in by the caller:
1132fe8fb19SBen Gras.Bl -tag -width aaaaaaaa
1142fe8fb19SBen Gras.It Fa "const char *ml_filename"
1152fe8fb19SBen GrasThe name/path of the module to load.
1162fe8fb19SBen Gras.It Fa "int ml_flags"
1172fe8fb19SBen GrasZero or more of the following flag values:
1182fe8fb19SBen Gras.Bl -tag -compact -width "MODCTL_LOAD_FORCE"
1192fe8fb19SBen Gras.It Dv MODCTL_NO_PROP
120f14fb602SLionel SambucDon't load
121f14fb602SLionel Sambuc.Ao module Ac Ns Pa .plist .
1222fe8fb19SBen Gras.It Dv MODCTL_LOAD_FORCE
1232fe8fb19SBen GrasIgnore kernel version mismatch.
1242fe8fb19SBen Gras.El
1252fe8fb19SBen Gras.It Fa "const char *ml_props"
1262fe8fb19SBen GrasExternalized proplib dictionary to pass to module.
1272fe8fb19SBen Gras.It Fa "size_t ml_propslen"
1282fe8fb19SBen GrasSize of the dictionary blob.
1292fe8fb19SBen Gras.Fa ml_props
1302fe8fb19SBen Grasmay be
1312fe8fb19SBen Gras.Dv NULL
1322fe8fb19SBen Grasin which case
1332fe8fb19SBen Gras.Fa ml_propslen
1342fe8fb19SBen Grasmust be
1352fe8fb19SBen Gras.Dv 0 .
136*0a6a1f1dSLionel SambucAn upper limit of 4096 bytes is imposed on the value of ml_propslen.
137*0a6a1f1dSLionel SambucAttempting to load a proplib dictionary larger than this size will return
138*0a6a1f1dSLionel Sambuc.Er ENOMEM .
1392fe8fb19SBen Gras.El
1402fe8fb19SBen Gras.Pp
1412fe8fb19SBen GrasThe
1422fe8fb19SBen Gras.Em modstat_t
1432fe8fb19SBen Grasstructure used with
1442fe8fb19SBen Gras.Dv MODCTL_STAT
1452fe8fb19SBen Grascontains the following elements, which are filled in by the kernel:
1462fe8fb19SBen Gras.Bl -tag -width aaaaaaaa
1472fe8fb19SBen Gras.It Fa "char ms_name[MAXMODNAME]"
1482fe8fb19SBen GrasThe name of the module.
1492fe8fb19SBen Gras.It Fa "char ms_required[MAXMODNAME * MAXMODDEPS]"
1502fe8fb19SBen GrasThe list of modules required by this module
1512fe8fb19SBen Grasas a comma-delimited list of module names.
1522fe8fb19SBen Gras.It Fa "modsrc_t ms_source"
1532fe8fb19SBen GrasOne of the following enumerated constants:
1542fe8fb19SBen Gras.Bl -tag -compact -width "MODULE_SOURCE_FILESYS"
1552fe8fb19SBen Gras.It Dv MODULE_SOURCE_KERNEL
1562fe8fb19SBen GrasThe module is compiled into the kernel.
1572fe8fb19SBen Gras.It Dv MODULE_SOURCE_BOOT
1582fe8fb19SBen GrasThe module was provided by the bootstrap loader.
1592fe8fb19SBen Gras.It Dv MODULE_SOURCE_FILESYS
1602fe8fb19SBen GrasThe module was loaded from the file system.
1612fe8fb19SBen Gras.El
1622fe8fb19SBen Gras.It Fa "modclass_t ms_class"
1632fe8fb19SBen GrasOne of the following enumerated constants:
1642fe8fb19SBen Gras.Bl -tag -compact -width "MODULE_SOURCE_FILESYS"
1652fe8fb19SBen Gras.It Dv MODULE_CLASS_SECMODEL
1662fe8fb19SBen GrasSecurity model.
1672fe8fb19SBen Gras.It Dv MODULE_CLASS_VFS
1682fe8fb19SBen GrasFile system.
1692fe8fb19SBen Gras.It Dv MODULE_CLASS_DRIVER
1702fe8fb19SBen GrasDevice driver.
1712fe8fb19SBen Gras.It Dv MODULE_CLASS_EXEC
1722fe8fb19SBen GrasExecutable file format.
1732fe8fb19SBen Gras.It Dv MODULE_CLASS_MISC
1742fe8fb19SBen GrasMiscellaneous.
1752fe8fb19SBen Gras.It Dv MODULE_CLASS_ANY
1762fe8fb19SBen GrasAny module class.
1772fe8fb19SBen Gras.\" XXX: is MODULE_CLASS_ANY ever returned by this interface?
1782fe8fb19SBen Gras.El
1792fe8fb19SBen Gras.It Fa "uint64_t ms_addr"
1802fe8fb19SBen GrasThe load address within the kernel.
1812fe8fb19SBen Gras.It Fa "u_int ms_size"
1822fe8fb19SBen GrasLoaded size of the module.
1832fe8fb19SBen Gras.It Fa "u_int ms_refcnt"
1842fe8fb19SBen GrasCurrent number of live references to this module.
1852fe8fb19SBen Gras.El
1862fe8fb19SBen Gras.Sh RETURN VALUES
1872fe8fb19SBen GrasUpon successful completion, the value returned is 0.
1882fe8fb19SBen Gras.Pp
1892fe8fb19SBen GrasOtherwise, a value of \-1 is returned and
1902fe8fb19SBen Gras.Va errno
1912fe8fb19SBen Grasis set to indicate the error.
1922fe8fb19SBen Gras.Sh ERRORS
1932fe8fb19SBen Gras.Fn modctl
1942fe8fb19SBen Graswill fail if:
1952fe8fb19SBen Gras.Bl -tag -width Er
1962fe8fb19SBen Gras.It Bq Er EBUSY
1972fe8fb19SBen GrasThe argument
1982fe8fb19SBen Gras.Fa operation
1992fe8fb19SBen Grasis
2002fe8fb19SBen Gras.Dv MODCTL_UNLOAD
2012fe8fb19SBen Grasand the module is in use or the module is compiled into the kernel.
2022fe8fb19SBen Gras.It Bq Er EDEADLK
2032fe8fb19SBen GrasThe argument
2042fe8fb19SBen Gras.Fa operation
2052fe8fb19SBen Grasis
2062fe8fb19SBen Gras.Dv MODCTL_LOAD
2072fe8fb19SBen Grasand there is a circular dependency in the module's dependency chain.
2082fe8fb19SBen Gras.It Bq Er EEXIST
2092fe8fb19SBen GrasThe argument
2102fe8fb19SBen Gras.Fa operation
2112fe8fb19SBen Grasis
2122fe8fb19SBen Gras.Dv MODCTL_LOAD
2132fe8fb19SBen Grasand the module is already loaded.
2142fe8fb19SBen Gras.It Bq Er EFAULT
2152fe8fb19SBen GrasA bad address was given for
2162fe8fb19SBen Gras.Fa argp .
2172fe8fb19SBen Gras.It Bq Er EFBIG
2182fe8fb19SBen GrasThe argument
2192fe8fb19SBen Gras.Fa operation
2202fe8fb19SBen Grasis
2212fe8fb19SBen Gras.Dv MODCTL_LOAD ,
2222fe8fb19SBen Grasthe specified module resides in the file system, and the module's default
2232fe8fb19SBen Grasproplib file was too large.
2242fe8fb19SBen Gras.It Bq Er EINVAL
2252fe8fb19SBen GrasThe argument
2262fe8fb19SBen Gras.Fa operation
2272fe8fb19SBen Grasis invalid.
2282fe8fb19SBen Gras.Pp
2292fe8fb19SBen GrasThe argument
2302fe8fb19SBen Gras.Fa operation
2312fe8fb19SBen Grasis
2322fe8fb19SBen Gras.Dv MODCTL_LOAD
2332fe8fb19SBen Grasand ml_props is not
2342fe8fb19SBen Gras.Dv NULL
2352fe8fb19SBen Grasand
2362fe8fb19SBen Gras.Dq ml_propslen
2372fe8fb19SBen Grasis
2382fe8fb19SBen Gras.Dv 0 ,
2392fe8fb19SBen Grasor
2402fe8fb19SBen Grasml_props is
2412fe8fb19SBen Gras.Dv NULL
2422fe8fb19SBen Grasand
2432fe8fb19SBen Gras.Dq ml_propslen
2442fe8fb19SBen Grasis not
2452fe8fb19SBen Gras.Dv 0 .
2462fe8fb19SBen GrasThe kernel is unable to internalize the plist.
2472fe8fb19SBen GrasOr, there is a problem with the module or \*[Lt]module\*[Gt].plist.
2482fe8fb19SBen Gras.It Bq Er EMLINK
2492fe8fb19SBen GrasThe argument
2502fe8fb19SBen Gras.Fa operation
2512fe8fb19SBen Grasis
2522fe8fb19SBen Gras.Dv MODCTL_LOAD
2532fe8fb19SBen Grasand the module has too many dependencies.
2542fe8fb19SBen Gras.It Bq Er ENAMETOOLONG
2552fe8fb19SBen GrasA module name/path is too long.
2562fe8fb19SBen Gras.It Bq Er ENOENT
2572fe8fb19SBen GrasThe argument
2582fe8fb19SBen Gras.Fa operation
2592fe8fb19SBen Grasis
2602fe8fb19SBen Gras.Dv MODCTL_LOAD
2612fe8fb19SBen Grasand the module or a dependency can't be found.
2622fe8fb19SBen GrasThe argument
2632fe8fb19SBen Gras.Fa operation
2642fe8fb19SBen Grasis
2652fe8fb19SBen Gras.Dv MODCTL_UNLOAD
2662fe8fb19SBen Grasand no module by the name of
2672fe8fb19SBen Gras.Fa argp
2682fe8fb19SBen Grasis loaded.
2692fe8fb19SBen Gras.It Bq Er ENOEXEC
2702fe8fb19SBen GrasThe argument
2712fe8fb19SBen Gras.Fa operation
2722fe8fb19SBen Grasis
2732fe8fb19SBen Gras.Dv MODCTL_LOAD
2742fe8fb19SBen Grasand the module is not a valid object for the system.
275*0a6a1f1dSLionel SambucMost likely, one or more undefined symbols could not be resolved by the
276*0a6a1f1dSLionel Sambucin-kernel linker.
2772fe8fb19SBen Gras.It Bq Er ENOMEM
2782fe8fb19SBen GrasThere was not enough memory to perform the
2792fe8fb19SBen Gras.Fa operation .
2802fe8fb19SBen Gras.It Bq Er EPERM
2812fe8fb19SBen GrasNot allowed to perform the
2822fe8fb19SBen Gras.Fa operation .
2832fe8fb19SBen Gras.It Bq Er EPROGMISMATCH
2842fe8fb19SBen GrasThe argument
2852fe8fb19SBen Gras.Fa operation
2862fe8fb19SBen Grasis
2872fe8fb19SBen Gras.Dv MODCTL_LOAD ,
2882fe8fb19SBen Grasthe
2892fe8fb19SBen Gras.Fa ml_flags
2902fe8fb19SBen Grasfield in the
2912fe8fb19SBen Gras.Em modctl_load_t
2922fe8fb19SBen Grasstructure does not include
2932fe8fb19SBen Gras.Dv MODCTL_LOAD_FORCE ,
2942fe8fb19SBen Grasand the requested module does not match the current kernel's version
2952fe8fb19SBen Grasinformation.
2962fe8fb19SBen Gras.El
2972fe8fb19SBen Gras.Sh SEE ALSO
2982fe8fb19SBen Gras.Xr module 7 ,
299f14fb602SLionel Sambuc.Xr sysctl 7 ,
3002fe8fb19SBen Gras.Xr module 9
3012fe8fb19SBen Gras.Sh HISTORY
3022fe8fb19SBen GrasThe
3032fe8fb19SBen Gras.Fn modctl
3042fe8fb19SBen Grasfunction call first appeared in
3052fe8fb19SBen Gras.Nx 5.0 .
306