OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / 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 .\" 2006-02-09, some reformatting by Luc Van Oostenryck; some
6 .\" reformatting and rewordings by mtk
7 .\"
8 .TH INIT_MODULE 2 2006-02-09 "Linux" "Linux Programmer's Manual"
9 .SH NAME
10 init_module \- initialize a loadable module entry
11 .SH SYNOPSIS
12 .nf
13 .B #include <linux/module.h>
14 .sp
15 .BI "int init_module(const char *" name ", struct module *" image );
16 .fi
17 .SH DESCRIPTION
18 .BR init_module ()
19 loads the relocated module image into kernel space and runs the
20 module's
21 .I init
22 function.
23 .PP
24 The module image begins with a module structure and is followed by
25 code and data as appropriate.
26 The module structure is defined as follows:
27 .PP
28 .in +4n
29 .nf
30 struct module {
31     unsigned long         size_of_struct;
32     struct module        *next;
33     const char           *name;
34     unsigned long         size;
35     long                  usecount;
36     unsigned long         flags;
37     unsigned int          nsyms;
38     unsigned int          ndeps;
39     struct module_symbol *syms;
40     struct module_ref    *deps;
41     struct module_ref    *refs;
42     int                 (*init)(void);
43     void                (*cleanup)(void);
44     const struct exception_table_entry *ex_table_start;
45     const struct exception_table_entry *ex_table_end;
46 #ifdef __alpha__
47     unsigned long gp;
48 #endif
49 };
50 .fi
51 .in
52 .PP
53 All of the pointer fields, with the exception of
54 .I next
55 and
56 .IR refs ,
57 are expected to point within the module body and be
58 initialized as appropriate for kernel space, that is, relocated with
59 the rest of the module.
60 .PP
61 This system call requires privilege.
62 .SH "RETURN VALUE"
63 On success, zero is returned.
64 On error, \-1 is returned and
65 .I errno
66 is set appropriately.
67 .SH ERRORS
68 .TP
69 .B EBUSY
70 The module's initialization routine failed.
71 .TP
72 .B EFAULT
73 .I name
74 or
75 .I image
76 is outside the program's accessible address space.
77 .TP
78 .B EINVAL
79 Some
80 .I image
81 slot is filled in incorrectly,
82 .I image\->name
83 does not correspond to the original module name, some
84 .I image\->deps
85 entry does not correspond to a loaded module,
86 or some other similar inconsistency.
87 .TP
88 .B ENOENT
89 No module by that name exists.
90 .TP
91 .B EPERM
92 The caller was not privileged
93 (did not have the
94 .B CAP_SYS_MODULE
95 capability).
96 .SH "CONFORMING TO"
97 .BR init_module ()
98 is Linux-specific.
99 .SH "SEE ALSO"
100 .BR create_module (2),
101 .BR delete_module (2),
102 .BR query_module (2)