diff options
| -rw-r--r-- | fs/sysfs/file.c | 44 | ||||
| -rw-r--r-- | include/linux/sysfs.h | 17 |
2 files changed, 61 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); |
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 192de3afa96b..f45450b295c0 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h | |||
| @@ -126,6 +126,11 @@ void sysfs_remove_bin_file(struct kobject *kobj, struct bin_attribute *attr); | |||
| 126 | int __must_check sysfs_create_group(struct kobject *, | 126 | int __must_check sysfs_create_group(struct kobject *, |
| 127 | const struct attribute_group *); | 127 | const struct attribute_group *); |
| 128 | void sysfs_remove_group(struct kobject *, const struct attribute_group *); | 128 | void sysfs_remove_group(struct kobject *, const struct attribute_group *); |
| 129 | int sysfs_add_file_to_group(struct kobject *kobj, | ||
| 130 | const struct attribute *attr, const char *group); | ||
| 131 | void sysfs_remove_file_from_group(struct kobject *kobj, | ||
| 132 | const struct attribute *attr, const char *group); | ||
| 133 | |||
| 129 | void sysfs_notify(struct kobject * k, char *dir, char *attr); | 134 | void sysfs_notify(struct kobject * k, char *dir, char *attr); |
| 130 | 135 | ||
| 131 | 136 | ||
| @@ -210,6 +215,18 @@ static inline void sysfs_remove_group(struct kobject * k, const struct attribute | |||
| 210 | ; | 215 | ; |
| 211 | } | 216 | } |
| 212 | 217 | ||
| 218 | static inline int sysfs_add_file_to_group(struct kobject *kobj, | ||
| 219 | const struct attribute *attr, const char *group) | ||
| 220 | { | ||
| 221 | return 0; | ||
| 222 | } | ||
| 223 | |||
| 224 | static inline void sysfs_remove_file_from_group(struct kobject *kobj, | ||
| 225 | const struct attribute *attr, const char *group); | ||
| 226 | { | ||
| 227 | ; | ||
| 228 | } | ||
| 229 | |||
| 213 | static inline void sysfs_notify(struct kobject * k, char *dir, char *attr) | 230 | static inline void sysfs_notify(struct kobject * k, char *dir, char *attr) |
| 214 | { | 231 | { |
| 215 | } | 232 | } |
