aboutsummaryrefslogtreecommitdiff
path: root/modutils/lsmod.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-09-16 05:30:24 +0000
committerEric Andersen <andersen@codepoet.org>2002-09-16 05:30:24 +0000
commit166fa4684f33579277f34d887537c2abefc9deb0 (patch)
treec3f4a401ceb2cce8799929aa64e509f964b933ea /modutils/lsmod.c
parent061c9001763f4a19d8104d5be61bbb09b50b1dae (diff)
downloadbusybox-166fa4684f33579277f34d887537c2abefc9deb0.tar.gz
Support module tainting
-Erik
Diffstat (limited to 'modutils/lsmod.c')
-rw-r--r--modutils/lsmod.c34
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 @@
+#define TAINT_FILENAME "/proc/sys/kernel/tainted"
+#define TAINT_PROPRIETORY_MODULE (1<<0)
+#define TAINT_FORCED_MODULE (1<<1)
+#define TAINT_UNSAFE_SMP (1<<2)
+
+void check_tainted(void)
+{
+ int tainted;
+ FILE *f;
+
+ tainted = 0;
+ if ((f = fopen(TAINT_FILENAME, "r"))) {
+ fscanf(f, "%d", &tainted);
+ fclose(f);
+ }
+ if (f && tainted) {
+ printf(" Tainted: %c%c%c",
+ tainted & TAINT_PROPRIETORY_MODULE ? 'P' : 'G',
+ tainted & TAINT_FORCED_MODULE ? 'F' : ' ',
+ tainted & TAINT_UNSAFE_SMP ? 'S' : ' ');
+ }
+ else {
+ printf(" Not tainted");
+ }
+}
+
#ifdef CONFIG_FEATURE_QUERY_MODULE_INTERFACE
struct module_info
@@ -99,7 +125,10 @@ extern int lsmod_main(int argc, char **argv)
}
deps = xmalloc(depsize = 256);
- printf("Module Size Used by\n");
+ printf("Module Size Used by");
+ check_tainted();
+ printf("\n");
+
for (i = 0, mn = module_names; i < nmod; mn += strlen(mn) + 1, i++) {
if (query_module(mn, QM_INFO, &info, sizeof(info), &count)) {
if (errno == ENOENT) {
@@ -149,7 +178,8 @@ extern int lsmod_main(int argc, char **argv)
int fd, i;
char line[128];
- puts("Module Size Used by");
+ printf("Module Size Used by");
+ check_tainted();
fflush(stdout);
if ((fd = open("/proc/modules", O_RDONLY)) >= 0 ) {