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
This commit is contained in:
Eric Andersen
2000-12-06 18:18:26 +00:00
parent e884970c87
commit 21adca750a
6 changed files with 512 additions and 205 deletions

38
lsmod.c
View File

@ -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,9 +36,16 @@
#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
{
unsigned long addr;
@ -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*/