diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2012-01-12 18:02:15 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-01-12 18:02:15 -0500 |
commit | cca3e707301862ca9b9327e6a732463982f8cd1b (patch) | |
tree | 5cc4767c5167e430209bcea7e43400a9f2e471ab /kernel | |
parent | 8487bfd954928660a52e91384a9b1f1049217e35 (diff) |
modules: sysfs - export: taint, coresize, initsize
Recent tools do not want to use /proc to retrieve module information. A few
values are currently missing from sysfs to replace the information available
in /proc/modules.
This adds /sys/module/*/{coresize,initsize,taint} attributes.
TAINT_PROPRIETARY_MODULE (P) and TAINT_OOT_MODULE (O) flags are both always
shown now, and do no longer exclude each other, also in /proc/modules.
Replace the open-coded sysfs attribute initializers with the __ATTR() macro.
Add the new attributes to Documentation/ABI.
Cc: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/module.c | 93 |
1 files changed, 64 insertions, 29 deletions
diff --git a/kernel/module.c b/kernel/module.c index b02d6335f8a6..acf6ed3ebe81 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -842,6 +842,26 @@ out: | |||
842 | return ret; | 842 | return ret; |
843 | } | 843 | } |
844 | 844 | ||
845 | static size_t module_flags_taint(struct module *mod, char *buf) | ||
846 | { | ||
847 | size_t l = 0; | ||
848 | |||
849 | if (mod->taints & (1 << TAINT_PROPRIETARY_MODULE)) | ||
850 | buf[l++] = 'P'; | ||
851 | if (mod->taints & (1 << TAINT_OOT_MODULE)) | ||
852 | buf[l++] = 'O'; | ||
853 | if (mod->taints & (1 << TAINT_FORCED_MODULE)) | ||
854 | buf[l++] = 'F'; | ||
855 | if (mod->taints & (1 << TAINT_CRAP)) | ||
856 | buf[l++] = 'C'; | ||
857 | /* | ||
858 | * TAINT_FORCED_RMMOD: could be added. | ||
859 | * TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't | ||
860 | * apply to modules. | ||
861 | */ | ||
862 | return l; | ||
863 | } | ||
864 | |||
845 | static inline void print_unload_info(struct seq_file *m, struct module *mod) | 865 | static inline void print_unload_info(struct seq_file *m, struct module *mod) |
846 | { | 866 | { |
847 | struct module_use *use; | 867 | struct module_use *use; |
@@ -900,10 +920,8 @@ static ssize_t show_refcnt(struct module_attribute *mattr, | |||
900 | return sprintf(buffer, "%lu\n", module_refcount(mk->mod)); | 920 | return sprintf(buffer, "%lu\n", module_refcount(mk->mod)); |
901 | } | 921 | } |
902 | 922 | ||
903 | static struct module_attribute refcnt = { | 923 | static struct module_attribute modinfo_refcnt = |
904 | .attr = { .name = "refcnt", .mode = 0444 }, | 924 | __ATTR(refcnt, 0444, show_refcnt, NULL); |
905 | .show = show_refcnt, | ||
906 | }; | ||
907 | 925 | ||
908 | void module_put(struct module *module) | 926 | void module_put(struct module *module) |
909 | { | 927 | { |
@@ -963,10 +981,8 @@ static ssize_t show_initstate(struct module_attribute *mattr, | |||
963 | return sprintf(buffer, "%s\n", state); | 981 | return sprintf(buffer, "%s\n", state); |
964 | } | 982 | } |
965 | 983 | ||
966 | static struct module_attribute initstate = { | 984 | static struct module_attribute modinfo_initstate = |
967 | .attr = { .name = "initstate", .mode = 0444 }, | 985 | __ATTR(initstate, 0444, show_initstate, NULL); |
968 | .show = show_initstate, | ||
969 | }; | ||
970 | 986 | ||
971 | static ssize_t store_uevent(struct module_attribute *mattr, | 987 | static ssize_t store_uevent(struct module_attribute *mattr, |
972 | struct module_kobject *mk, | 988 | struct module_kobject *mk, |
@@ -979,18 +995,50 @@ static ssize_t store_uevent(struct module_attribute *mattr, | |||
979 | return count; | 995 | return count; |
980 | } | 996 | } |
981 | 997 | ||
982 | struct module_attribute module_uevent = { | 998 | struct module_attribute module_uevent = |
983 | .attr = { .name = "uevent", .mode = 0200 }, | 999 | __ATTR(uevent, 0200, NULL, store_uevent); |
984 | .store = store_uevent, | 1000 | |
985 | }; | 1001 | static ssize_t show_coresize(struct module_attribute *mattr, |
1002 | struct module_kobject *mk, char *buffer) | ||
1003 | { | ||
1004 | return sprintf(buffer, "%u\n", mk->mod->core_size); | ||
1005 | } | ||
1006 | |||
1007 | static struct module_attribute modinfo_coresize = | ||
1008 | __ATTR(coresize, 0444, show_coresize, NULL); | ||
1009 | |||
1010 | static ssize_t show_initsize(struct module_attribute *mattr, | ||
1011 | struct module_kobject *mk, char *buffer) | ||
1012 | { | ||
1013 | return sprintf(buffer, "%u\n", mk->mod->init_size); | ||
1014 | } | ||
1015 | |||
1016 | static struct module_attribute modinfo_initsize = | ||
1017 | __ATTR(initsize, 0444, show_initsize, NULL); | ||
1018 | |||
1019 | static ssize_t show_taint(struct module_attribute *mattr, | ||
1020 | struct module_kobject *mk, char *buffer) | ||
1021 | { | ||
1022 | size_t l; | ||
1023 | |||
1024 | l = module_flags_taint(mk->mod, buffer); | ||
1025 | buffer[l++] = '\n'; | ||
1026 | return l; | ||
1027 | } | ||
1028 | |||
1029 | static struct module_attribute modinfo_taint = | ||
1030 | __ATTR(taint, 0444, show_taint, NULL); | ||
986 | 1031 | ||
987 | static struct module_attribute *modinfo_attrs[] = { | 1032 | static struct module_attribute *modinfo_attrs[] = { |
1033 | &module_uevent, | ||
988 | &modinfo_version, | 1034 | &modinfo_version, |
989 | &modinfo_srcversion, | 1035 | &modinfo_srcversion, |
990 | &initstate, | 1036 | &modinfo_initstate, |
991 | &module_uevent, | 1037 | &modinfo_coresize, |
1038 | &modinfo_initsize, | ||
1039 | &modinfo_taint, | ||
992 | #ifdef CONFIG_MODULE_UNLOAD | 1040 | #ifdef CONFIG_MODULE_UNLOAD |
993 | &refcnt, | 1041 | &modinfo_refcnt, |
994 | #endif | 1042 | #endif |
995 | NULL, | 1043 | NULL, |
996 | }; | 1044 | }; |
@@ -3236,20 +3284,7 @@ static char *module_flags(struct module *mod, char *buf) | |||
3236 | mod->state == MODULE_STATE_GOING || | 3284 | mod->state == MODULE_STATE_GOING || |
3237 | mod->state == MODULE_STATE_COMING) { | 3285 | mod->state == MODULE_STATE_COMING) { |
3238 | buf[bx++] = '('; | 3286 | buf[bx++] = '('; |
3239 | if (mod->taints & (1 << TAINT_PROPRIETARY_MODULE)) | 3287 | bx += module_flags_taint(mod, buf + bx); |
3240 | buf[bx++] = 'P'; | ||
3241 | else if (mod->taints & (1 << TAINT_OOT_MODULE)) | ||
3242 | buf[bx++] = 'O'; | ||
3243 | if (mod->taints & (1 << TAINT_FORCED_MODULE)) | ||
3244 | buf[bx++] = 'F'; | ||
3245 | if (mod->taints & (1 << TAINT_CRAP)) | ||
3246 | buf[bx++] = 'C'; | ||
3247 | /* | ||
3248 | * TAINT_FORCED_RMMOD: could be added. | ||
3249 | * TAINT_UNSAFE_SMP, TAINT_MACHINE_CHECK, TAINT_BAD_PAGE don't | ||
3250 | * apply to modules. | ||
3251 | */ | ||
3252 | |||
3253 | /* Show a - for module-is-being-unloaded */ | 3288 | /* Show a - for module-is-being-unloaded */ |
3254 | if (mod->state == MODULE_STATE_GOING) | 3289 | if (mod->state == MODULE_STATE_GOING) |
3255 | buf[bx++] = '-'; | 3290 | buf[bx++] = '-'; |