diff options
Diffstat (limited to 'fs/sysfs/dir.c')
| -rw-r--r-- | fs/sysfs/dir.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index e068e744dbdd..99ec5b40e977 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
| @@ -46,7 +46,7 @@ static unsigned int sysfs_name_hash(const void *ns, const char *name) | |||
| 46 | unsigned int len = strlen(name); | 46 | unsigned int len = strlen(name); |
| 47 | while (len--) | 47 | while (len--) |
| 48 | hash = partial_name_hash(*name++, hash); | 48 | hash = partial_name_hash(*name++, hash); |
| 49 | hash = ( end_name_hash(hash) ^ hash_ptr( (void *)ns, 31 ) ); | 49 | hash = (end_name_hash(hash) ^ hash_ptr((void *)ns, 31)); |
| 50 | hash &= 0x7fffffffU; | 50 | hash &= 0x7fffffffU; |
| 51 | /* Reserve hash numbers 0, 1 and INT_MAX for magic directory entries */ | 51 | /* Reserve hash numbers 0, 1 and INT_MAX for magic directory entries */ |
| 52 | if (hash < 1) | 52 | if (hash < 1) |
| @@ -258,7 +258,7 @@ static void sysfs_free_ino(unsigned int ino) | |||
| 258 | spin_unlock(&sysfs_ino_lock); | 258 | spin_unlock(&sysfs_ino_lock); |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | void release_sysfs_dirent(struct sysfs_dirent * sd) | 261 | void release_sysfs_dirent(struct sysfs_dirent *sd) |
| 262 | { | 262 | { |
| 263 | struct sysfs_dirent *parent_sd; | 263 | struct sysfs_dirent *parent_sd; |
| 264 | 264 | ||
| @@ -451,7 +451,7 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | |||
| 451 | 451 | ||
| 452 | if (!!sysfs_ns_type(acxt->parent_sd) != !!sd->s_ns) { | 452 | if (!!sysfs_ns_type(acxt->parent_sd) != !!sd->s_ns) { |
| 453 | WARN(1, KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n", | 453 | WARN(1, KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n", |
| 454 | sysfs_ns_type(acxt->parent_sd)? "required": "invalid", | 454 | sysfs_ns_type(acxt->parent_sd) ? "required" : "invalid", |
| 455 | acxt->parent_sd->s_name, sd->s_name); | 455 | acxt->parent_sd->s_name, sd->s_name); |
| 456 | return -EINVAL; | 456 | return -EINVAL; |
| 457 | } | 457 | } |
| @@ -619,7 +619,7 @@ struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, | |||
| 619 | 619 | ||
| 620 | if (!!sysfs_ns_type(parent_sd) != !!ns) { | 620 | if (!!sysfs_ns_type(parent_sd) != !!ns) { |
| 621 | WARN(1, KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n", | 621 | WARN(1, KERN_WARNING "sysfs: ns %s in '%s' for '%s'\n", |
| 622 | sysfs_ns_type(parent_sd)? "required": "invalid", | 622 | sysfs_ns_type(parent_sd) ? "required" : "invalid", |
| 623 | parent_sd->s_name, name); | 623 | parent_sd->s_name, name); |
| 624 | return NULL; | 624 | return NULL; |
| 625 | } | 625 | } |
| @@ -674,7 +674,7 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd, | |||
| 674 | enum kobj_ns_type type, const void *ns, const char *name, | 674 | enum kobj_ns_type type, const void *ns, const char *name, |
| 675 | struct sysfs_dirent **p_sd) | 675 | struct sysfs_dirent **p_sd) |
| 676 | { | 676 | { |
| 677 | umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO; | 677 | umode_t mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; |
| 678 | struct sysfs_addrm_cxt acxt; | 678 | struct sysfs_addrm_cxt acxt; |
| 679 | struct sysfs_dirent *sd; | 679 | struct sysfs_dirent *sd; |
| 680 | int rc; | 680 | int rc; |
| @@ -735,9 +735,9 @@ static enum kobj_ns_type sysfs_read_ns_type(struct kobject *kobj) | |||
| 735 | 735 | ||
| 736 | /** | 736 | /** |
| 737 | * sysfs_create_dir - create a directory for an object. | 737 | * sysfs_create_dir - create a directory for an object. |
| 738 | * @kobj: object we're creating directory for. | 738 | * @kobj: object we're creating directory for. |
| 739 | */ | 739 | */ |
| 740 | int sysfs_create_dir(struct kobject * kobj) | 740 | int sysfs_create_dir(struct kobject *kobj) |
| 741 | { | 741 | { |
| 742 | enum kobj_ns_type type; | 742 | enum kobj_ns_type type; |
| 743 | struct sysfs_dirent *parent_sd, *sd; | 743 | struct sysfs_dirent *parent_sd, *sd; |
| @@ -764,8 +764,8 @@ int sysfs_create_dir(struct kobject * kobj) | |||
| 764 | return error; | 764 | return error; |
| 765 | } | 765 | } |
| 766 | 766 | ||
| 767 | static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry, | 767 | static struct dentry *sysfs_lookup(struct inode *dir, struct dentry *dentry, |
| 768 | unsigned int flags) | 768 | unsigned int flags) |
| 769 | { | 769 | { |
| 770 | struct dentry *ret = NULL; | 770 | struct dentry *ret = NULL; |
| 771 | struct dentry *parent = dentry->d_parent; | 771 | struct dentry *parent = dentry->d_parent; |
| @@ -857,7 +857,7 @@ static void __sysfs_remove_dir(struct sysfs_dirent *dir_sd) | |||
| 857 | * what used to be sysfs_rmdir() below, instead of calling separately. | 857 | * what used to be sysfs_rmdir() below, instead of calling separately. |
| 858 | */ | 858 | */ |
| 859 | 859 | ||
| 860 | void sysfs_remove_dir(struct kobject * kobj) | 860 | void sysfs_remove_dir(struct kobject *kobj) |
| 861 | { | 861 | { |
| 862 | struct sysfs_dirent *sd = kobj->sd; | 862 | struct sysfs_dirent *sd = kobj->sd; |
| 863 | 863 | ||
| @@ -896,7 +896,9 @@ int sysfs_rename(struct sysfs_dirent *sd, | |||
| 896 | sd->s_name = new_name; | 896 | sd->s_name = new_name; |
| 897 | } | 897 | } |
| 898 | 898 | ||
| 899 | /* Move to the appropriate place in the appropriate directories rbtree. */ | 899 | /* |
| 900 | * Move to the appropriate place in the appropriate directories rbtree. | ||
| 901 | */ | ||
| 900 | sysfs_unlink_sibling(sd); | 902 | sysfs_unlink_sibling(sd); |
| 901 | sysfs_get(new_parent_sd); | 903 | sysfs_get(new_parent_sd); |
| 902 | sysfs_put(sd->s_parent); | 904 | sysfs_put(sd->s_parent); |
| @@ -988,20 +990,21 @@ static struct sysfs_dirent *sysfs_dir_next_pos(const void *ns, | |||
| 988 | struct sysfs_dirent *parent_sd, ino_t ino, struct sysfs_dirent *pos) | 990 | struct sysfs_dirent *parent_sd, ino_t ino, struct sysfs_dirent *pos) |
| 989 | { | 991 | { |
| 990 | pos = sysfs_dir_pos(ns, parent_sd, ino, pos); | 992 | pos = sysfs_dir_pos(ns, parent_sd, ino, pos); |
| 991 | if (pos) do { | 993 | if (pos) |
| 992 | struct rb_node *node = rb_next(&pos->s_rb); | 994 | do { |
| 993 | if (!node) | 995 | struct rb_node *node = rb_next(&pos->s_rb); |
| 994 | pos = NULL; | 996 | if (!node) |
| 995 | else | 997 | pos = NULL; |
| 996 | pos = to_sysfs_dirent(node); | 998 | else |
| 997 | } while (pos && pos->s_ns != ns); | 999 | pos = to_sysfs_dirent(node); |
| 1000 | } while (pos && pos->s_ns != ns); | ||
| 998 | return pos; | 1001 | return pos; |
| 999 | } | 1002 | } |
| 1000 | 1003 | ||
| 1001 | static int sysfs_readdir(struct file *file, struct dir_context *ctx) | 1004 | static int sysfs_readdir(struct file *file, struct dir_context *ctx) |
| 1002 | { | 1005 | { |
| 1003 | struct dentry *dentry = file->f_path.dentry; | 1006 | struct dentry *dentry = file->f_path.dentry; |
| 1004 | struct sysfs_dirent * parent_sd = dentry->d_fsdata; | 1007 | struct sysfs_dirent *parent_sd = dentry->d_fsdata; |
| 1005 | struct sysfs_dirent *pos = file->private_data; | 1008 | struct sysfs_dirent *pos = file->private_data; |
| 1006 | enum kobj_ns_type type; | 1009 | enum kobj_ns_type type; |
| 1007 | const void *ns; | 1010 | const void *ns; |
