]> git.pld-linux.org Git - packages/busybox.git/blob - busybox-insmod_ng.patch
- support 2.5 kernels
[packages/busybox.git] / busybox-insmod_ng.patch
1 diff -ur busybox-0.60.5/Config.h busybox-0.60.5-ng/Config.h
2 --- busybox-0.60.5/Config.h     2003-07-01 02:56:02.000000000 +0200
3 +++ busybox-0.60.5-ng/Config.h  2003-07-01 02:55:01.000000000 +0200
4 @@ -57,6 +57,7 @@
5  //#define BB_IFCONFIG
6  #define BB_INIT
7  //#define BB_INSMOD
8 +#define BB_INSMOD_NG
9  #define BB_KILL
10  #define BB_KILLALL
11  #define BB_KLOGD
12 diff -ur busybox-0.60.5/applets.h busybox-0.60.5-ng/applets.h
13 --- busybox-0.60.5/applets.h    2003-07-01 02:56:02.000000000 +0200
14 +++ busybox-0.60.5-ng/applets.h 2003-07-01 02:54:47.000000000 +0200
15 @@ -203,6 +203,9 @@
16  #ifdef BB_INSMOD
17         APPLET(insmod, insmod_main, _BB_DIR_SBIN)
18  #endif
19 +#ifdef BB_INSMOD_NG
20 +       APPLET(insmod_ng, insmod_ng_main, _BB_DIR_SBIN)
21 +#endif
22  #ifdef BB_KILL
23         APPLET(kill, kill_main, _BB_DIR_BIN)
24  #endif
25 diff -ur busybox-0.60.5/insmod.c busybox-0.60.5-ng/insmod.c
26 --- busybox-0.60.5/insmod.c     2002-09-16 07:30:10.000000000 +0200
27 +++ busybox-0.60.5-ng/insmod.c  2003-07-01 02:37:14.000000000 +0200
28 @@ -3567,6 +3567,14 @@
29  
30         printf("Using %s\n", m_filename);
31  
32 +#ifdef BB_INSMOD_NG
33 +    if (create_module(NULL, 0) < 0 && errno == ENOSYS) {
34 +               optind--;
35 +               argv[optind] = m_filename;
36 +               return insmod_ng_main(argc - optind, argv + optind);
37 +    }
38 +#endif
39 +
40         if ((f = obj_load(fp, LOADBITS)) == NULL)
41                 perror_msg_and_die("Could not load the module");
42  
43 Only in busybox-0.60.5-ng: insmod.o
44 diff -ur busybox-0.60.5/insmod_ng.c busybox-0.60.5-ng/insmod_ng.c
45 --- busybox-0.60.5/insmod_ng.c  2003-07-01 02:56:12.000000000 +0200
46 +++ busybox-0.60.5-ng/insmod_ng.c       2003-07-01 02:54:18.000000000 +0200
47 @@ -0,0 +1,110 @@
48 +/* vi: set sw=4 ts=4: */
49 +/*
50 + * insmod for 2.5 kernels implementation for busybox
51 + * busybox version by Michal Moskal <malekith@pld-linux.org>
52 + *
53 + * Copyright (C) 2001  Rusty Russell.
54 + * Copyright (C) 2002  Rusty Russell, IBM Corporation.
55 + *
56 + * This program is free software; you can redistribute it and/or modify
57 + * it under the terms of the GNU General Public License as published by
58 + * the Free Software Foundation; either version 2 of the License, or
59 + * (at your option) any later version.
60 + *
61 + * This program is distributed in the hope that it will be useful,
62 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
63 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
64 + * GNU General Public License for more details.
65 + *
66 + * You should have received a copy of the GNU General Public License
67 + * along with this program; if not, write to the Free Software
68 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
69 + */
70 +
71 +#include <string.h>
72 +#include <stdlib.h>
73 +#include <unistd.h>
74 +#include <fcntl.h>
75 +#include <sys/mman.h>
76 +#include <sys/types.h>
77 +#include <sys/stat.h>
78 +#include <unistd.h>
79 +#include <errno.h>
80 +#include <asm/unistd.h>
81 +#include <sys/syscall.h>
82 +
83 +#include "busybox.h"
84 +
85 +#define __NR_init_module_25 __NR_init_module
86 +static _syscall3(long, init_module_25, void *, map, size_t, len, char *, options)
87 +
88 +/* We use error numbers in a loose translation... */
89 +static const char *moderror(int err)
90 +{
91 +       switch (err) {
92 +       case ENOEXEC:
93 +               return "Invalid module format";
94 +       case ENOENT:
95 +               return "Unknown symbol in module";
96 +       case ESRCH:
97 +               return "Module has wrong symbol version";
98 +       case EINVAL:
99 +               return "Invalid parameters";
100 +       default:
101 +               return strerror(err);
102 +       }
103 +}
104 +
105 +extern int insmod_ng_main(int argc, char **argv)
106 +{
107 +       int i;
108 +       int fd;
109 +       long int ret;
110 +       struct stat st;
111 +       unsigned long len;
112 +       void *map;
113 +       char *filename, *options = xstrdup("");
114 +       
115 +       filename = argv[1];
116 +       if (!filename)
117 +               show_usage();
118 +
119 +       /* Rest is options */
120 +       for (i = 2; i < argc; i++) {
121 +               options = xrealloc(options,
122 +                                 strlen(options) + 2 + strlen(argv[i]) + 2);
123 +               /* Spaces handled by "" pairs, but no way of escaping quotes */
124 +               if (strchr(argv[i], ' ')) {
125 +                       strcat(options, "\"");
126 +                       strcat(options, argv[i]);
127 +                       strcat(options, "\"");
128 +               } else {
129 +                       strcat(options, argv[i]);
130 +               }
131 +               strcat(options, " ");
132 +       }
133 +
134 +       if ((fd = open(filename, O_RDONLY, 0)) < 0)
135 +               perror_msg_and_die("cannot open module `%s'", filename);
136 +
137 +       fstat(fd, &st);
138 +       len = st.st_size;
139 +       map = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
140 +       if (map == MAP_FAILED)
141 +               perror_msg_and_die("cannot mmap `%s'", filename);
142 +
143 +       ret = init_module_25(map, len, options);
144 +       if (ret != 0)
145 +               perror_msg_and_die("cannot insert `%s': %s (%li)",
146 +                                                  filename, moderror(errno), ret);
147 +       
148 +       return 0;
149 +}
150 +
151 +/*
152 +Local Variables:
153 +c-file-style: "linux"
154 +c-basic-offset: 4
155 +tab-width: 4
156 +End:
157 +*/
158 diff -ur busybox-0.60.5/usage.h busybox-0.60.5-ng/usage.h
159 --- busybox-0.60.5/usage.h      2003-07-01 02:56:02.000000000 +0200
160 +++ busybox-0.60.5-ng/usage.h   2003-07-01 02:55:44.000000000 +0200
161 @@ -818,6 +818,11 @@
162         "\t-L\tLock to prevent simultaneous loads of a module\n" \
163         "\t-x\tdo not export externs"
164  
165 +#define insmod_ng_trivial_usage \
166 +       "MODULE [symbol=value]..."
167 +#define insmod_ng_full_usage \
168 +       "Loads the specified kernel modules into the kernel."
169 +
170  #define kill_trivial_usage \
171         "[-signal] process-id [process-id ...]"
172  #define kill_full_usage \
This page took 0.054068 seconds and 4 git commands to generate.