diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-12-06 21:18:26 +0300 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-12-06 21:18:26 +0300 |
commit | 21adca750a9a1ae47da2bd058574795089406f25 (patch) | |
tree | 6157527825001c910fa9bd2b2ce519ac212e9e50 /lsmod.c | |
parent | e884970c87b921542fb9351b7a907796a0a4de23 (diff) |
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 'lsmod.c')
-rw-r--r-- | lsmod.c | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -5,6 +5,10 @@ * Copyright (C) 1999,2000 by Lineo, inc. * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> * + * Modified by Alcove, Julien Gaulmin <julien.gaulmin@alcove.fr> and + * Nicolas Ferre <nicolas.ferre@alcove.fr> to support pre 2.1 kernels + * (which lack the query_module() interface). + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -32,8 +36,15 @@ #include <assert.h> #include <getopt.h> #include <sys/utsname.h> +#include <sys/file.h> + +#if !defined(BB_FEATURE_LSMOD_NEW_KERNEL) && !defined(BB_FEATURE_LSMOD_OLD_KERNEL) +#error "Must have ether BB_FEATURE_LSMOD_NEW_KERNEL or BB_FEATURE_LSMOD_OLD_KERNEL defined" +#endif + +#ifdef BB_FEATURE_LSMOD_NEW_KERNEL struct module_info { @@ -120,3 +131,30 @@ extern int lsmod_main(int argc, char **argv) return( 0); } + +#else /*BB_FEATURE_LSMOD_OLD_KERNEL*/ + +#if ! defined BB_FEATURE_USE_PROCFS +#error Sorry, I depend on the /proc filesystem right now. +#endif + +extern int lsmod_main(int argc, char **argv) +{ + int fd, i; + char line[128]; + + puts("Module Size Used by"); + fflush(stdout); + + if ((fd = open("/proc/modules", O_RDONLY)) >= 0 ) { + while ((i = read(fd, line, sizeof(line))) > 0) { + write(fileno(stdout), line, i); + } + close(fd); + return 0; + } + fatalError("/proc/modules: %s\n", strerror(errno)); + return 1; +} + +#endif /*BB_FEATURE_LSMOD_OLD_KERNEL*/ |