OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / modutils / original / man2 / init_module.2
1 .\" Copyright (C) 1996 Free Software Foundation, Inc.
2 .\" This file is distributed according to the GNU General Public License.
3 .\" See the file COPYING in the top level source directory for details.
4 .\"
5 .TH INIT_MODULE 2 "26 Dec 1996" "Linux 2.1.17" "Linux Module Support"
6 .SH NAME
7 init_module \- initialize a loadable module entry
8 .SH SYNOPSIS
9 .nf
10 .B #include <linux/module.h>
11 .sp
12 .BI "int init_module(const char *" name ", struct module *" image );
13 .fi
14 .SH DESCRIPTION
15 .B init_module
16 loads the relocated module image into kernel space and runs the
17 module's \fIinit\fP function.
18 .PP
19 The module image begins with a module structure and is followed by
20 code and data as appropriate.  The module structure is defined as follows:
21 .PP
22 .RS
23 .nf
24 struct module
25 {
26   unsigned long size_of_struct;
27   struct module *next;
28   const char *name;
29   unsigned long size;
30   long usecount;
31   unsigned long flags;
32   unsigned int nsyms;
33   unsigned int ndeps;
34   struct module_symbol *syms;
35   struct module_ref *deps;
36   struct module_ref *refs;
37   int (*init)(void);
38   void (*cleanup)(void);
39   const struct exception_table_entry *ex_table_start;
40   const struct exception_table_entry *ex_table_end;
41 #ifdef __alpha__
42   unsigned long gp;
43 #endif
44 };
45 .fi
46 .RE
47 .PP
48 All of the pointer fields, with the exception of \fInext\fP and
49 \fIrefs\fP, are expected to point within the module body and be
50 initialized as appropriate for kernel space, i.e. relocated with
51 the rest of the module.
52 .PP
53 This system call is only open to the superuser.
54 .SH "RETURN VALUE"
55 On success, zero is returned.  On error, \-1 is returned and \fIerrno\fP
56 is set appropriately.
57 .SH ERRORS
58 .TP
59 .B EPERM
60 The user is not the superuser.
61 .TP
62 .B ENOENT
63 No module by that name exists.
64 .TP
65 .B EINVAL
66 Some \fIimage\fP slot filled in incorrectly, \fIimage->name\fP does not
67 correspond to the original module name, some \fIimage->deps\fP entry
68 does not correspond to a loaded module, or some other similar inconsistency.
69 .TP
70 .B EBUSY
71 The module's initialization routine failed.
72 .TP
73 .B EFAULT
74 \fIname\fP or \fIimage\fP
75 is outside the program's accessible address space.
76 .SH "SEE ALSO
77 .BR create_module "(2), " delete_module "(2), " query_module "(2)."