diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-12-06 18:18:26 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-12-06 18:18:26 +0000 |
commit | 21adca750a9a1ae47da2bd058574795089406f25 (patch) | |
tree | 6157527825001c910fa9bd2b2ce519ac212e9e50 /modutils/lsmod.c | |
parent | e884970c87b921542fb9351b7a907796a0a4de23 (diff) | |
download | busybox-w32-21adca750a9a1ae47da2bd058574795089406f25.tar.gz busybox-w32-21adca750a9a1ae47da2bd058574795089406f25.tar.bz2 busybox-w32-21adca750a9a1ae47da2bd058574795089406f25.zip |
Added insmod support for ARM, and lsmod support for older kernels,
thanks to Alcove, Julien Gaulmin <julien.gaulmin@alcove.fr> and
Nicolas Ferre <nicolas.ferre@alcove.fr>.
-Erik
Diffstat (limited to 'modutils/lsmod.c')
-rw-r--r-- | modutils/lsmod.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/modutils/lsmod.c b/modutils/lsmod.c index ab4726b9e..6fe505bf6 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c | |||
@@ -5,6 +5,10 @@ | |||
5 | * Copyright (C) 1999,2000 by Lineo, inc. | 5 | * Copyright (C) 1999,2000 by Lineo, inc. |
6 | * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> | 6 | * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> |
7 | * | 7 | * |
8 | * Modified by Alcove, Julien Gaulmin <julien.gaulmin@alcove.fr> and | ||
9 | * Nicolas Ferre <nicolas.ferre@alcove.fr> to support pre 2.1 kernels | ||
10 | * (which lack the query_module() interface). | ||
11 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | 12 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by | 13 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or | 14 | * the Free Software Foundation; either version 2 of the License, or |
@@ -32,8 +36,15 @@ | |||
32 | #include <assert.h> | 36 | #include <assert.h> |
33 | #include <getopt.h> | 37 | #include <getopt.h> |
34 | #include <sys/utsname.h> | 38 | #include <sys/utsname.h> |
39 | #include <sys/file.h> | ||
40 | |||
35 | 41 | ||
36 | 42 | ||
43 | #if !defined(BB_FEATURE_LSMOD_NEW_KERNEL) && !defined(BB_FEATURE_LSMOD_OLD_KERNEL) | ||
44 | #error "Must have ether BB_FEATURE_LSMOD_NEW_KERNEL or BB_FEATURE_LSMOD_OLD_KERNEL defined" | ||
45 | #endif | ||
46 | |||
47 | #ifdef BB_FEATURE_LSMOD_NEW_KERNEL | ||
37 | 48 | ||
38 | struct module_info | 49 | struct module_info |
39 | { | 50 | { |
@@ -120,3 +131,30 @@ extern int lsmod_main(int argc, char **argv) | |||
120 | 131 | ||
121 | return( 0); | 132 | return( 0); |
122 | } | 133 | } |
134 | |||
135 | #else /*BB_FEATURE_LSMOD_OLD_KERNEL*/ | ||
136 | |||
137 | #if ! defined BB_FEATURE_USE_PROCFS | ||
138 | #error Sorry, I depend on the /proc filesystem right now. | ||
139 | #endif | ||
140 | |||
141 | extern int lsmod_main(int argc, char **argv) | ||
142 | { | ||
143 | int fd, i; | ||
144 | char line[128]; | ||
145 | |||
146 | puts("Module Size Used by"); | ||
147 | fflush(stdout); | ||
148 | |||
149 | if ((fd = open("/proc/modules", O_RDONLY)) >= 0 ) { | ||
150 | while ((i = read(fd, line, sizeof(line))) > 0) { | ||
151 | write(fileno(stdout), line, i); | ||
152 | } | ||
153 | close(fd); | ||
154 | return 0; | ||
155 | } | ||
156 | fatalError("/proc/modules: %s\n", strerror(errno)); | ||
157 | return 1; | ||
158 | } | ||
159 | |||
160 | #endif /*BB_FEATURE_LSMOD_OLD_KERNEL*/ | ||