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:
38
lsmod.c
38
lsmod.c
@ -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*/
|
||||
|
Reference in New Issue
Block a user