summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorPatrick Mochel <mochel@osdl.org>2003-08-28 23:59:48 -0700
committerPatrick Mochel <mochel@osdl.org>2003-08-28 23:59:48 -0700
commite1f52606ea627c1d8ff8d18b2903ba0b4d94dc4f (patch)
tree199b155ff567193dc2afa1b26947562edde342d4 /include/linux
parent176ac30e3ce05041d80ad1b02d86c1d57256c8eb (diff)
[kobject] Support unlimited name lengths.
Add ->k_name pointer which points to the name for a kobject. By default, this points to ->name (the static name array). Users of kobjects may use the helper function kobject_set_name() (and are encouraged to do so in all cases). This function will determined whether or not the name is short enough to fit in ->name. If so, great. Otherwise, a dyanamic string is allocated and the name is stored there. ->k_name will point to that, and will be freed when the kobject is released. kobject_set_name() may take a format string, like: kobject_set_name(kobj,"%s%d",base_name,id); and will behave as expected (will put in ->name, unless it's too long, in which case a new string will be allocated and it will be stored in there).
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/kobject.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index e744a55d07d5..42174b623637 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -24,6 +24,7 @@
#define KOBJ_NAME_LEN 20
struct kobject {
+ char * k_name;
char name[KOBJ_NAME_LEN];
atomic_t refcount;
struct list_head entry;
@@ -33,6 +34,14 @@ struct kobject {
struct dentry * dentry;
};
+extern int kobject_set_name(struct kobject *, const char *, ...)
+ __attribute__((format(printf,2,3)));
+
+static inline char * kobject_name(struct kobject * kobj)
+{
+ return kobj->k_name;
+}
+
extern void kobject_init(struct kobject *);
extern void kobject_cleanup(struct kobject *);