diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2007-02-20 15:02:44 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-23 18:03:46 -0500 |
commit | dfa87c824a9a5430008acd1ed2e8111ed164fcbe (patch) | |
tree | 1e25c9d6a00b409e3cd6a7d304fe2b98eb955309 /fs | |
parent | b5e795f8df42936590ba9c606edc715fe3593284 (diff) |
sysfs: allow attributes to be added to groups
This patch (as860) adds two new sysfs routines:
sysfs_add_file_to_group() and sysfs_remove_file_from_group().
A later patch adds code that uses the new routines.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Maneesh Soni <maneesh@in.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/sysfs/file.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 98b0910ad80c..8d4d839a9d88 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -502,6 +502,30 @@ int sysfs_create_file(struct kobject * kobj, const struct attribute * attr) | |||
502 | 502 | ||
503 | 503 | ||
504 | /** | 504 | /** |
505 | * sysfs_add_file_to_group - add an attribute file to a pre-existing group. | ||
506 | * @kobj: object we're acting for. | ||
507 | * @attr: attribute descriptor. | ||
508 | * @group: group name. | ||
509 | */ | ||
510 | int sysfs_add_file_to_group(struct kobject *kobj, | ||
511 | const struct attribute *attr, const char *group) | ||
512 | { | ||
513 | struct dentry *dir; | ||
514 | int error; | ||
515 | |||
516 | dir = lookup_one_len(group, kobj->dentry, strlen(group)); | ||
517 | if (IS_ERR(dir)) | ||
518 | error = PTR_ERR(dir); | ||
519 | else { | ||
520 | error = sysfs_add_file(dir, attr, SYSFS_KOBJ_ATTR); | ||
521 | dput(dir); | ||
522 | } | ||
523 | return error; | ||
524 | } | ||
525 | EXPORT_SYMBOL_GPL(sysfs_add_file_to_group); | ||
526 | |||
527 | |||
528 | /** | ||
505 | * sysfs_update_file - update the modified timestamp on an object attribute. | 529 | * sysfs_update_file - update the modified timestamp on an object attribute. |
506 | * @kobj: object we're acting for. | 530 | * @kobj: object we're acting for. |
507 | * @attr: attribute descriptor. | 531 | * @attr: attribute descriptor. |
@@ -586,6 +610,26 @@ void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr) | |||
586 | } | 610 | } |
587 | 611 | ||
588 | 612 | ||
613 | /** | ||
614 | * sysfs_remove_file_from_group - remove an attribute file from a group. | ||
615 | * @kobj: object we're acting for. | ||
616 | * @attr: attribute descriptor. | ||
617 | * @group: group name. | ||
618 | */ | ||
619 | void sysfs_remove_file_from_group(struct kobject *kobj, | ||
620 | const struct attribute *attr, const char *group) | ||
621 | { | ||
622 | struct dentry *dir; | ||
623 | |||
624 | dir = lookup_one_len(group, kobj->dentry, strlen(group)); | ||
625 | if (!IS_ERR(dir)) { | ||
626 | sysfs_hash_and_remove(dir, attr->name); | ||
627 | dput(dir); | ||
628 | } | ||
629 | } | ||
630 | EXPORT_SYMBOL_GPL(sysfs_remove_file_from_group); | ||
631 | |||
632 | |||
589 | EXPORT_SYMBOL_GPL(sysfs_create_file); | 633 | EXPORT_SYMBOL_GPL(sysfs_create_file); |
590 | EXPORT_SYMBOL_GPL(sysfs_remove_file); | 634 | EXPORT_SYMBOL_GPL(sysfs_remove_file); |
591 | EXPORT_SYMBOL_GPL(sysfs_update_file); | 635 | EXPORT_SYMBOL_GPL(sysfs_update_file); |