Tue Oct 20 04:41:28 2009 UTC ()
First pass at a manpage for modctl(2) (hi ad!).


(jnemeth)
diff -r1.201 -r1.202 src/lib/libc/sys/Makefile.inc
diff -r0 -r1.1 src/lib/libc/sys/modctl.2

cvs diff -r1.201 -r1.202 src/lib/libc/sys/Makefile.inc (expand / switch to unified diff)

--- src/lib/libc/sys/Makefile.inc 2009/04/10 23:14:58 1.201
+++ src/lib/libc/sys/Makefile.inc 2009/10/20 04:41:28 1.202
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile.inc,v 1.201 2009/04/10 23:14:58 christos Exp $ 1# $NetBSD: Makefile.inc,v 1.202 2009/10/20 04:41:28 jnemeth Exp $
2# @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 2# @(#)Makefile.inc 8.3 (Berkeley) 10/24/94
3 3
4# sys sources 4# sys sources
5.PATH: ${ARCHDIR}/sys ${.CURDIR}/sys 5.PATH: ${ARCHDIR}/sys ${.CURDIR}/sys
6 6
7# modules with non-default implementations on at least one architecture: 7# modules with non-default implementations on at least one architecture:
8SRCS+= __clone.S __vfork14.S brk.S exect.S fork.S pipe.S \ 8SRCS+= __clone.S __vfork14.S brk.S exect.S fork.S pipe.S \
9 getcontext.S \ 9 getcontext.S \
10 ptrace.S sbrk.S shmat.S \ 10 ptrace.S sbrk.S shmat.S \
11 syscall.S __syscall.S __clone.S cerror.S 11 syscall.S __syscall.S __clone.S cerror.S
12 12
13# other sources shared with the kernel, used in syscalls 13# other sources shared with the kernel, used in syscalls
14SRCS+= cpuset.c 14SRCS+= cpuset.c
@@ -209,27 +209,28 @@ MAN+= accept.2 access.2 acct.2 adjtime.2 @@ -209,27 +209,28 @@ MAN+= accept.2 access.2 acct.2 adjtime.2
209 getfh.2 getvfsstat.2 getgid.2 getgroups.2 \ 209 getfh.2 getvfsstat.2 getgid.2 getgroups.2 \
210 getitimer.2 getlogin.2 getpeername.2 getpgrp.2 getpid.2 \ 210 getitimer.2 getlogin.2 getpeername.2 getpgrp.2 getpid.2 \
211 getpriority.2 getrlimit.2 getrusage.2 getsid.2 getsockname.2 \ 211 getpriority.2 getrlimit.2 getrusage.2 getsid.2 getsockname.2 \
212 getsockopt.2 gettimeofday.2 getuid.2 intro.2 ioctl.2 issetugid.2 \ 212 getsockopt.2 gettimeofday.2 getuid.2 intro.2 ioctl.2 issetugid.2 \
213 kill.2 kqueue.2 ktrace.2 \ 213 kill.2 kqueue.2 ktrace.2 \
214 lfs_bmapv.2 lfs_markv.2 lfs_segclean.2 lfs_segwait.2 \ 214 lfs_bmapv.2 lfs_markv.2 lfs_segclean.2 lfs_segwait.2 \
215 link.2 listen.2 lseek.2 \ 215 link.2 listen.2 lseek.2 \
216 _lwp_create.2 _lwp_ctl.2 _lwp_detach.2 _lwp_exit.2 \ 216 _lwp_create.2 _lwp_ctl.2 _lwp_detach.2 _lwp_exit.2 \
217 _lwp_self.2 _lwp_setname.2 \ 217 _lwp_self.2 _lwp_setname.2 \
218 _lwp_suspend.2 _lwp_wakeup.2 _lwp_wait.2 _lwp_kill.2 \ 218 _lwp_suspend.2 _lwp_wakeup.2 _lwp_wait.2 _lwp_kill.2 \
219 _lwp_getname.2 _lwp_getprivate.2 \ 219 _lwp_getname.2 _lwp_getprivate.2 \
220 _lwp_park.2 _lwp_unpark.2 _lwp_unpark_all.2 \ 220 _lwp_park.2 _lwp_unpark.2 _lwp_unpark_all.2 \
221 mkdir.2 mkfifo.2 mknod.2 \ 221 mkdir.2 mkfifo.2 mknod.2 \
222 madvise.2 mincore.2 minherit.2 mlock.2 mlockall.2 mmap.2 mount.2 \ 222 madvise.2 mincore.2 minherit.2 mlock.2 mlockall.2 mmap.2 modctl.2 \
 223 mount.2 \
223 mprotect.2 mremap.2 msgctl.2 msgget.2 msgrcv.2 msgsnd.2 msync.2 \ 224 mprotect.2 mremap.2 msgctl.2 msgget.2 msgrcv.2 msgsnd.2 msync.2 \
224 munmap.2 nanosleep.2 nfssvc.2 ntp_adjtime.2 open.2 pathconf.2 pipe.2 \ 225 munmap.2 nanosleep.2 nfssvc.2 ntp_adjtime.2 open.2 pathconf.2 pipe.2 \
225 pmc_control.2 poll.2 posix_fadvise.2 profil.2 ptrace.2 quotactl.2 \ 226 pmc_control.2 poll.2 posix_fadvise.2 profil.2 ptrace.2 quotactl.2 \
226 rasctl.2 read.2 readlink.2 \ 227 rasctl.2 read.2 readlink.2 \
227 reboot.2 recv.2 rename.2 revoke.2 rmdir.2 \ 228 reboot.2 recv.2 rename.2 revoke.2 rmdir.2 \
228 select.2 semctl.2 \ 229 select.2 semctl.2 \
229 semget.2 semop.2 send.2 setgroups.2 setpgid.2 setregid.2 \ 230 semget.2 semop.2 send.2 setgroups.2 setpgid.2 setregid.2 \
230 setreuid.2 setsid.2 setuid.2 shmat.2 shmctl.2 shmget.2 \ 231 setreuid.2 setsid.2 setuid.2 shmat.2 shmctl.2 shmget.2 \
231 shutdown.2 sigaction.2 sigaltstack.2 sigpending.2 \ 232 shutdown.2 sigaction.2 sigaltstack.2 sigpending.2 \
232 sigprocmask.2 sigstack.2 sigsuspend.2 sigtimedwait.2 \ 233 sigprocmask.2 sigstack.2 sigsuspend.2 sigtimedwait.2 \
233 socket.2 \ 234 socket.2 \
234 socketpair.2 stat.2 statvfs.2 swapctl.2 swapon.3 symlink.2 \ 235 socketpair.2 stat.2 statvfs.2 swapctl.2 swapon.3 symlink.2 \
235 sync.2 sysarch.2 syscall.2 timer_create.2 timer_delete.2 \ 236 sync.2 sysarch.2 syscall.2 timer_create.2 timer_delete.2 \

File Added: src/lib/libc/sys/modctl.2
.\"	$NetBSD: modctl.2,v 1.1 2009/10/20 04:41:28 jnemeth Exp $
.\"
.\" Copyright (c) 2009 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 19, 2009
.Dt MODCTL 2
.Os
.Sh NAME
.Nm modctl
.Nd module control
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In sys/module.h
.Ft int
.Fn modctl "int operation" "void * argp"
.Sh DESCRIPTION
.Fn modctl
provides for control over modules.
The argument
.Fa operation
is one of
.Dv MODCTL_LOAD ,
.Dv MODCTL_UNLOAD ,
or
.Dv MODCTL_STAT .
The argument
.Fa argp
depends on the
.Fa operation
to be performed.
.Pp
Operations are:
.Bl -tag -width MODCTL_UNLOAD
.It Dv MODCTL_LOAD
Load a module.
The
.Fa argp
should be:
.Bd -literal
typedef struct modctl_load {
        const char *ml_filename;	/* the name/path of the module to load */

#define MODCTL_NO_PROP          0x2	/* don't load \*[Lt]module\*[Gt].prop */
#define MODCTL_LOAD_FORCE       0x1	/* ignore kernel version mismatch */
        int ml_flags;

        const char *ml_props;		/* externalised dictionary to pass to module */
        size_t ml_propslen;		/* length of dictionary */
} modctl_load_t;
.Ed
.Pp
.Dq ml_props
may be
.Dv NULL
in which case
.Dq ml_propslen
must be
.Dv 0 .
.It Dv MODCTL_UNLOAD
Unload a module.
In this case, the
.Fa argp
should be a
.Dq char *
containing the name of the module to be unloaded.
.It Dv MODCTL_STAT
Return a list of loaded modules.
In this case, the
.Fa argp
should be a
.Dq struct iovec .
The kernel will adjust the
.Dq iov_len
paramater to reflect the space required.
The
.Dq iov_base
will be a pointer to an array of
.Dq modstat_t
truncated to the passed in
.Dq iov_len .
.Dq modstat_t
looks like:
.Bd -literal
typedef struct modstat {
        char            ms_name[MAXMODNAME];
        char            ms_required[MAXMODNAME * MAXMODDEPS];
        uint64_t        ms_addr;
        modsrc_t        ms_source;
        modclass_t      ms_class;
        u_int           ms_size;
        u_int           ms_refcnt;
        u_int           ms_reserved[4];
} modstat_t;
.Ed
.Pp
.Dq modsrc_t
looks like:
.Bd -literal
typedef enum modsrc {
        MODULE_SOURCE_KERNEL,
        MODULE_SOURCE_BOOT,
        MODULE_SOURCE_FILESYS
} modsrc_t;
.Ed
.Pp
and
.Dq modclass_t
looks like:
.Bd -literal
typedef enum modclass {
        MODULE_CLASS_ANY,
        MODULE_CLASS_MISC,
        MODULE_CLASS_VFS,
        MODULE_CLASS_DRIVER,
        MODULE_CLASS_EXEC
} modclass_t;
.Ed
.El
.Sh RETURN VALUES
Upon successful completion, the value returned is 0.
.Pp
Otherwise, a value of \-1 is returned and
.Va errno
is set to indicate the error.
.Sh ERRORS
.Fn modctl
will fail if:
.Bl -tag -width Er
.It Bq Er EBUSY
The argument
.Fa operation
is
.Dv MODCTL_UNLOAD
and the module is in use or the module is compiled into the kernel.
.It Bq Er EDEADLK
The argument
.Fa operation
is
.Dv MODCTL_LOAD
and there is a circular dependency in the module's dependency chain.
.It Bq Er EEXIST
The argument
.Fa operation
is
.Dv MODCTL_LOAD
and the module is already loaded.
.It Bq Er EFAULT
A bad address was given for
.Fa argp .
.It Bq Er EINVAL
The argument
.Fa operation
is invalid.
.Pp
The argument
.Fa operation
is
.Dv MODCTL_LOAD
and ml_props is not
.Dv NULL
and
.Dq ml_propslen
is
.Dv 0 ,
or
ml_props is
.Dv NULL
and
.Dq ml_propslen
is not
.Dv 0 .
The kernel is unable to internalize the plist.
Or, there is a problem with the module or \*[Lt]module\*[Gt].prop.
.It Bq Er EMLINK
The argument
.Fa operation
is
.Dv MODCTL_LOAD
and the module has too many dependencies.
.It Bq Er ENAMETOOLONG
A module name/path is too long.
.It Bq Er ENOENT
The argument
.Fa operation
is
.Dv MODCTL_LOAD
and the module or a dependency can't be found.
The argument
.Fa operation
is
.Dv MODCTL_UNLOAD
and no module by the name of
.Fa argp
is loaded.
.It Bq Er ENOEXEC
The argument
.Fa operation
is
.Dv MODCTL_LOAD
and the module is not a valid object for the system.
.It Bq Er ENOMEM
There was not enough memory to perform the
.Fa operation .
.It Bq Er EPERM
Not allowed to perform the
.Fa operation .
.El
.Sh HISTORY
The
.Fn modctl
function call first appeared in
.Nx 5.0 .