diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-09-16 05:30:24 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-09-16 05:30:24 +0000 |
commit | 166fa4684f33579277f34d887537c2abefc9deb0 (patch) | |
tree | c3f4a401ceb2cce8799929aa64e509f964b933ea /modutils/lsmod.c | |
parent | 061c9001763f4a19d8104d5be61bbb09b50b1dae (diff) | |
download | busybox-w32-166fa4684f33579277f34d887537c2abefc9deb0.tar.gz busybox-w32-166fa4684f33579277f34d887537c2abefc9deb0.tar.bz2 busybox-w32-166fa4684f33579277f34d887537c2abefc9deb0.zip |
Support module tainting
-Erik
Diffstat (limited to 'modutils/lsmod.c')
-rw-r--r-- | modutils/lsmod.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/modutils/lsmod.c b/modutils/lsmod.c index 5cb585bab..3618ebe0b 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c | |||
@@ -41,6 +41,32 @@ | |||
41 | 41 | ||
42 | 42 | ||
43 | 43 | ||
44 | #define TAINT_FILENAME "/proc/sys/kernel/tainted" | ||
45 | #define TAINT_PROPRIETORY_MODULE (1<<0) | ||
46 | #define TAINT_FORCED_MODULE (1<<1) | ||
47 | #define TAINT_UNSAFE_SMP (1<<2) | ||
48 | |||
49 | void check_tainted(void) | ||
50 | { | ||
51 | int tainted; | ||
52 | FILE *f; | ||
53 | |||
54 | tainted = 0; | ||
55 | if ((f = fopen(TAINT_FILENAME, "r"))) { | ||
56 | fscanf(f, "%d", &tainted); | ||
57 | fclose(f); | ||
58 | } | ||
59 | if (f && tainted) { | ||
60 | printf(" Tainted: %c%c%c", | ||
61 | tainted & TAINT_PROPRIETORY_MODULE ? 'P' : 'G', | ||
62 | tainted & TAINT_FORCED_MODULE ? 'F' : ' ', | ||
63 | tainted & TAINT_UNSAFE_SMP ? 'S' : ' '); | ||
64 | } | ||
65 | else { | ||
66 | printf(" Not tainted"); | ||
67 | } | ||
68 | } | ||
69 | |||
44 | #ifdef CONFIG_FEATURE_QUERY_MODULE_INTERFACE | 70 | #ifdef CONFIG_FEATURE_QUERY_MODULE_INTERFACE |
45 | 71 | ||
46 | struct module_info | 72 | struct module_info |
@@ -99,7 +125,10 @@ extern int lsmod_main(int argc, char **argv) | |||
99 | } | 125 | } |
100 | 126 | ||
101 | deps = xmalloc(depsize = 256); | 127 | deps = xmalloc(depsize = 256); |
102 | printf("Module Size Used by\n"); | 128 | printf("Module Size Used by"); |
129 | check_tainted(); | ||
130 | printf("\n"); | ||
131 | |||
103 | for (i = 0, mn = module_names; i < nmod; mn += strlen(mn) + 1, i++) { | 132 | for (i = 0, mn = module_names; i < nmod; mn += strlen(mn) + 1, i++) { |
104 | if (query_module(mn, QM_INFO, &info, sizeof(info), &count)) { | 133 | if (query_module(mn, QM_INFO, &info, sizeof(info), &count)) { |
105 | if (errno == ENOENT) { | 134 | if (errno == ENOENT) { |
@@ -149,7 +178,8 @@ extern int lsmod_main(int argc, char **argv) | |||
149 | int fd, i; | 178 | int fd, i; |
150 | char line[128]; | 179 | char line[128]; |
151 | 180 | ||
152 | puts("Module Size Used by"); | 181 | printf("Module Size Used by"); |
182 | check_tainted(); | ||
153 | fflush(stdout); | 183 | fflush(stdout); |
154 | 184 | ||
155 | if ((fd = open("/proc/modules", O_RDONLY)) >= 0 ) { | 185 | if ((fd = open("/proc/modules", O_RDONLY)) >= 0 ) { |