diff options
author | Erik Andersen <andersen@codepoet.org> | 1999-12-17 18:57:34 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 1999-12-17 18:57:34 +0000 |
commit | 021043205c55677a31929594977342e96d459a6c (patch) | |
tree | fc79ac9596a93bfb1d4c02b121e5dc954fcd94a9 | |
parent | 10c341af3500531f2bc838841c44a0542f39e59f (diff) | |
download | busybox-w32-021043205c55677a31929594977342e96d459a6c.tar.gz busybox-w32-021043205c55677a31929594977342e96d459a6c.tar.bz2 busybox-w32-021043205c55677a31929594977342e96d459a6c.zip |
Add in first draft of insmod. Not yet working (but will Real Soon Now(tm))
-Erik
-rw-r--r-- | insmod.c | 113 | ||||
-rw-r--r-- | modutils/insmod.c | 113 |
2 files changed, 226 insertions, 0 deletions
diff --git a/insmod.c b/insmod.c new file mode 100644 index 000000000..9a0daa73b --- /dev/null +++ b/insmod.c | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * Mini insmod implementation for busybox | ||
3 | * | ||
4 | * Copyright (C) 1999 by Lineo, inc. | ||
5 | * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include "internal.h" | ||
24 | #include <stdlib.h> | ||
25 | #include <stdio.h> | ||
26 | #include <errno.h> | ||
27 | #include <unistd.h> | ||
28 | #include <dirent.h> | ||
29 | #include <sys/syscall.h> | ||
30 | #include <linux/module.h> | ||
31 | |||
32 | /* Some firendly syscalls to cheer everyone's day... */ | ||
33 | _syscall2(int, init_module, const char *, name, | ||
34 | const struct module *, info) | ||
35 | |||
36 | #ifndef BB_RMMOD | ||
37 | _syscall1(int, delete_module, const char *, name) | ||
38 | #else | ||
39 | extern int delete_module(const char *); | ||
40 | #endif | ||
41 | |||
42 | #if defined(__i386__) || defined(__m68k__) || defined(__arm__) | ||
43 | /* Jump through hoops to fixup error return codes */ | ||
44 | #define __NR__create_module __NR_create_module | ||
45 | static inline _syscall2(long, _create_module, const char *, name, size_t, size) | ||
46 | unsigned long create_module(const char *name, size_t size) | ||
47 | { | ||
48 | long ret = _create_module(name, size); | ||
49 | if (ret == -1 && errno > 125) { | ||
50 | ret = -errno; | ||
51 | errno = 0; | ||
52 | } | ||
53 | return ret; | ||
54 | } | ||
55 | #else | ||
56 | _syscall2(unsigned long, create_module, const char *, name, size_t, size) | ||
57 | #endif | ||
58 | |||
59 | |||
60 | static const char insmod_usage[] = | ||
61 | "insmod [OPTION]... MODULE [symbol=value]...\n\n" | ||
62 | "Loads the specified kernel modules into the kernel.\n\n" | ||
63 | "Options:\n" | ||
64 | "\t-f\tForce module to load into the wrong kernel version.\n" | ||
65 | "\t-k\tMake module autoclean-able.\n"; | ||
66 | |||
67 | |||
68 | |||
69 | extern int insmod_main(int argc, char **argv) | ||
70 | { | ||
71 | int len; | ||
72 | char m_name[PATH_MAX]; | ||
73 | char* tmp; | ||
74 | |||
75 | |||
76 | |||
77 | if (argc<=1) { | ||
78 | usage( insmod_usage); | ||
79 | } | ||
80 | |||
81 | /* Parse any options */ | ||
82 | while (--argc > 0 && **(++argv) == '-') { | ||
83 | while (*(++(*argv))) { | ||
84 | switch (**argv) { | ||
85 | case 'f': | ||
86 | break; | ||
87 | case 'k': | ||
88 | break; | ||
89 | default: | ||
90 | usage(insmod_usage); | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | |||
95 | if (argc <= 0 ) | ||
96 | usage(insmod_usage); | ||
97 | |||
98 | /* Grab the module name */ | ||
99 | if ((tmp = strrchr(*argv, '/')) != NULL) | ||
100 | tmp++; | ||
101 | else | ||
102 | tmp = *argv; | ||
103 | len = strlen(tmp); | ||
104 | |||
105 | if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') | ||
106 | len -= 2; | ||
107 | memcpy(m_name, tmp, len); | ||
108 | |||
109 | fprintf(stderr, "m_name='%s'\n", m_name); | ||
110 | |||
111 | |||
112 | exit( TRUE); | ||
113 | } | ||
diff --git a/modutils/insmod.c b/modutils/insmod.c new file mode 100644 index 000000000..9a0daa73b --- /dev/null +++ b/modutils/insmod.c | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * Mini insmod implementation for busybox | ||
3 | * | ||
4 | * Copyright (C) 1999 by Lineo, inc. | ||
5 | * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include "internal.h" | ||
24 | #include <stdlib.h> | ||
25 | #include <stdio.h> | ||
26 | #include <errno.h> | ||
27 | #include <unistd.h> | ||
28 | #include <dirent.h> | ||
29 | #include <sys/syscall.h> | ||
30 | #include <linux/module.h> | ||
31 | |||
32 | /* Some firendly syscalls to cheer everyone's day... */ | ||
33 | _syscall2(int, init_module, const char *, name, | ||
34 | const struct module *, info) | ||
35 | |||
36 | #ifndef BB_RMMOD | ||
37 | _syscall1(int, delete_module, const char *, name) | ||
38 | #else | ||
39 | extern int delete_module(const char *); | ||
40 | #endif | ||
41 | |||
42 | #if defined(__i386__) || defined(__m68k__) || defined(__arm__) | ||
43 | /* Jump through hoops to fixup error return codes */ | ||
44 | #define __NR__create_module __NR_create_module | ||
45 | static inline _syscall2(long, _create_module, const char *, name, size_t, size) | ||
46 | unsigned long create_module(const char *name, size_t size) | ||
47 | { | ||
48 | long ret = _create_module(name, size); | ||
49 | if (ret == -1 && errno > 125) { | ||
50 | ret = -errno; | ||
51 | errno = 0; | ||
52 | } | ||
53 | return ret; | ||
54 | } | ||
55 | #else | ||
56 | _syscall2(unsigned long, create_module, const char *, name, size_t, size) | ||
57 | #endif | ||
58 | |||
59 | |||
60 | static const char insmod_usage[] = | ||
61 | "insmod [OPTION]... MODULE [symbol=value]...\n\n" | ||
62 | "Loads the specified kernel modules into the kernel.\n\n" | ||
63 | "Options:\n" | ||
64 | "\t-f\tForce module to load into the wrong kernel version.\n" | ||
65 | "\t-k\tMake module autoclean-able.\n"; | ||
66 | |||
67 | |||
68 | |||
69 | extern int insmod_main(int argc, char **argv) | ||
70 | { | ||
71 | int len; | ||
72 | char m_name[PATH_MAX]; | ||
73 | char* tmp; | ||
74 | |||
75 | |||
76 | |||
77 | if (argc<=1) { | ||
78 | usage( insmod_usage); | ||
79 | } | ||
80 | |||
81 | /* Parse any options */ | ||
82 | while (--argc > 0 && **(++argv) == '-') { | ||
83 | while (*(++(*argv))) { | ||
84 | switch (**argv) { | ||
85 | case 'f': | ||
86 | break; | ||
87 | case 'k': | ||
88 | break; | ||
89 | default: | ||
90 | usage(insmod_usage); | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | |||
95 | if (argc <= 0 ) | ||
96 | usage(insmod_usage); | ||
97 | |||
98 | /* Grab the module name */ | ||
99 | if ((tmp = strrchr(*argv, '/')) != NULL) | ||
100 | tmp++; | ||
101 | else | ||
102 | tmp = *argv; | ||
103 | len = strlen(tmp); | ||
104 | |||
105 | if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') | ||
106 | len -= 2; | ||
107 | memcpy(m_name, tmp, len); | ||
108 | |||
109 | fprintf(stderr, "m_name='%s'\n", m_name); | ||
110 | |||
111 | |||
112 | exit( TRUE); | ||
113 | } | ||