1 /* vi: set sw=4 ts=4: */
3 * Mini lsmod implementation for busybox
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
13 #if ENABLE_FEATURE_CHECK_TAINTED_MODULE
15 TAINT_PROPRIETORY_MODULE = (1 << 0),
16 TAINT_FORCED_MODULE = (1 << 1),
17 TAINT_UNSAFE_SMP = (1 << 2),
20 static void check_tainted(void)
23 char *buf = xmalloc_open_read_close("/proc/sys/kernel/tainted", NULL);
26 if (ENABLE_FEATURE_CLEAN_UP)
31 printf(" Tainted: %c%c%c\n",
32 tainted & TAINT_PROPRIETORY_MODULE ? 'P' : 'G',
33 tainted & TAINT_FORCED_MODULE ? 'F' : ' ',
34 tainted & TAINT_UNSAFE_SMP ? 'S' : ' ');
40 static void check_tainted(void) { putchar('\n'); }
43 int lsmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
44 int lsmod_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
46 #if ENABLE_FEATURE_LSMOD_PRETTY_2_6_OUTPUT
48 parser_t *parser = config_open("/proc/modules");
49 printf("%-24sSize Used by", "Module");
52 if (ENABLE_FEATURE_2_4_MODULES
53 && get_linux_version_code() < KERNEL_VERSION(2,6,0)
55 while (config_read(parser, token, 4, 3, "# \t", PARSE_NORMAL)) {
56 if (token[3] != NULL && token[3][0] == '[') {
58 token[3][strlen(token[3])-1] = '\0';
60 token[3] = (char *) "";
61 printf("%-19s %8s %2s %s\n", token[0], token[1], token[2], token[3]);
64 while (config_read(parser, token, 4, 4, "# \t", PARSE_NORMAL & ~PARSE_GREEDY)) {
65 // N.B. token[3] is either '-' (module is not used by others)
66 // or comma-separated list ended by comma
67 // so trimming the trailing char is just what we need!
68 token[3][strlen(token[3])-1] = '\0';
69 printf("%-19s %8s %2s %s\n", token[0], token[1], token[2], token[3]);
72 if (ENABLE_FEATURE_CLEAN_UP)
76 xprint_and_close_file(xfopen_for_read("/proc/modules"));