summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <greg@kroah.com>2004-05-07 00:22:49 -0700
committerGreg Kroah-Hartman <greg@kroah.com>2004-05-07 00:22:49 -0700
commitb863a25d3dca56d4c84c3cdcca089a42f1c088be (patch)
tree771d3eb3c75d8390d29e55dae242611710c8447b /include
parent009196b400ed5494adee8f093b2b3c360c579a09 (diff)
Add modules to sysfs
This patch adds basic kobject support to struct module, and it creates a /sys/module directory which contains all of the individual modules. Each module currently exports the refcount (if they are unloadable) and any module paramaters that are marked exportable in sysfs. Was written by me and Rusty over and over many times during the past 6 months.
Diffstat (limited to 'include')
-rw-r--r--include/linux/module.h25
-rw-r--r--include/linux/moduleparam.h4
2 files changed, 27 insertions, 2 deletions
diff --git a/include/linux/module.h b/include/linux/module.h
index 0a86652fb1cb..9a3eb2f1f95d 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -16,6 +16,8 @@
#include <linux/kmod.h>
#include <linux/elf.h>
#include <linux/stringify.h>
+#include <linux/kobject.h>
+#include <linux/moduleparam.h>
#include <asm/local.h>
#include <asm/module.h>
@@ -207,6 +209,23 @@ enum module_state
MODULE_STATE_GOING,
};
+/* sysfs stuff */
+struct module_attribute
+{
+ struct attribute attr;
+ struct kernel_param *param;
+};
+
+struct module_kobject
+{
+ /* Everyone should have one of these. */
+ struct kobject kobj;
+
+ /* We always have refcnt, we may have others from module_param(). */
+ unsigned int num_attributes;
+ struct module_attribute attr[0];
+};
+
struct module
{
enum module_state state;
@@ -217,6 +236,9 @@ struct module
/* Unique handle for this module */
char name[MODULE_NAME_LEN];
+ /* Sysfs stuff. */
+ struct module_kobject *mkobj;
+
/* Exported symbols */
const struct kernel_symbol *syms;
unsigned int num_syms;
@@ -267,6 +289,9 @@ struct module
/* Destruction function. */
void (*exit)(void);
+
+ /* Fake kernel param for refcnt. */
+ struct kernel_param refcnt_param;
#endif
#ifdef CONFIG_KALLSYMS
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index e9d6a16d3fef..f63de16cdf54 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -50,7 +50,7 @@ struct kparam_array
not there, read bits mean it's readable, write bits mean it's
writable. */
#define __module_param_call(prefix, name, set, get, arg, perm) \
- static char __param_str_##name[] __initdata = prefix #name; \
+ static char __param_str_##name[] = prefix #name; \
static struct kernel_param const __param_##name \
__attribute_used__ \
__attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
@@ -71,7 +71,7 @@ struct kparam_array
/* Actually copy string: maxlen param is usually sizeof(string). */
#define module_param_string(name, string, len, perm) \
- static struct kparam_string __param_string_##name __initdata \
+ static struct kparam_string __param_string_##name \
= { len, string }; \
module_param_call(name, param_set_copystring, param_get_charp, \
&__param_string_##name, perm)