diff options
Diffstat (limited to 'fs/sysfs/sysfs.h')
-rw-r--r-- | fs/sysfs/sysfs.h | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h index af4c4e7482ac..30f5a44fb5d3 100644 --- a/fs/sysfs/sysfs.h +++ b/fs/sysfs/sysfs.h | |||
@@ -8,6 +8,7 @@ | |||
8 | * This file is released under the GPLv2. | 8 | * This file is released under the GPLv2. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/lockdep.h> | ||
11 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
12 | 13 | ||
13 | struct sysfs_open_dirent; | 14 | struct sysfs_open_dirent; |
@@ -50,6 +51,9 @@ struct sysfs_inode_attrs { | |||
50 | struct sysfs_dirent { | 51 | struct sysfs_dirent { |
51 | atomic_t s_count; | 52 | atomic_t s_count; |
52 | atomic_t s_active; | 53 | atomic_t s_active; |
54 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
55 | struct lockdep_map dep_map; | ||
56 | #endif | ||
53 | struct sysfs_dirent *s_parent; | 57 | struct sysfs_dirent *s_parent; |
54 | struct sysfs_dirent *s_sibling; | 58 | struct sysfs_dirent *s_sibling; |
55 | const char *s_name; | 59 | const char *s_name; |
@@ -62,8 +66,8 @@ struct sysfs_dirent { | |||
62 | }; | 66 | }; |
63 | 67 | ||
64 | unsigned int s_flags; | 68 | unsigned int s_flags; |
69 | unsigned short s_mode; | ||
65 | ino_t s_ino; | 70 | ino_t s_ino; |
66 | umode_t s_mode; | ||
67 | struct sysfs_inode_attrs *s_iattr; | 71 | struct sysfs_inode_attrs *s_iattr; |
68 | }; | 72 | }; |
69 | 73 | ||
@@ -75,6 +79,7 @@ struct sysfs_dirent { | |||
75 | #define SYSFS_KOBJ_BIN_ATTR 0x0004 | 79 | #define SYSFS_KOBJ_BIN_ATTR 0x0004 |
76 | #define SYSFS_KOBJ_LINK 0x0008 | 80 | #define SYSFS_KOBJ_LINK 0x0008 |
77 | #define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK) | 81 | #define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK) |
82 | #define SYSFS_ACTIVE_REF (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR) | ||
78 | 83 | ||
79 | #define SYSFS_FLAG_MASK ~SYSFS_TYPE_MASK | 84 | #define SYSFS_FLAG_MASK ~SYSFS_TYPE_MASK |
80 | #define SYSFS_FLAG_REMOVED 0x0200 | 85 | #define SYSFS_FLAG_REMOVED 0x0200 |
@@ -84,36 +89,46 @@ static inline unsigned int sysfs_type(struct sysfs_dirent *sd) | |||
84 | return sd->s_flags & SYSFS_TYPE_MASK; | 89 | return sd->s_flags & SYSFS_TYPE_MASK; |
85 | } | 90 | } |
86 | 91 | ||
92 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
93 | #define sysfs_dirent_init_lockdep(sd) \ | ||
94 | do { \ | ||
95 | struct attribute *attr = sd->s_attr.attr; \ | ||
96 | struct lock_class_key *key = attr->key; \ | ||
97 | if (!key) \ | ||
98 | key = &attr->skey; \ | ||
99 | \ | ||
100 | lockdep_init_map(&sd->dep_map, "s_active", key, 0); \ | ||
101 | } while(0) | ||
102 | #else | ||
103 | #define sysfs_dirent_init_lockdep(sd) do {} while(0) | ||
104 | #endif | ||
105 | |||
87 | /* | 106 | /* |
88 | * Context structure to be used while adding/removing nodes. | 107 | * Context structure to be used while adding/removing nodes. |
89 | */ | 108 | */ |
90 | struct sysfs_addrm_cxt { | 109 | struct sysfs_addrm_cxt { |
91 | struct sysfs_dirent *parent_sd; | 110 | struct sysfs_dirent *parent_sd; |
92 | struct inode *parent_inode; | ||
93 | struct sysfs_dirent *removed; | 111 | struct sysfs_dirent *removed; |
94 | int cnt; | ||
95 | }; | 112 | }; |
96 | 113 | ||
97 | /* | 114 | /* |
98 | * mount.c | 115 | * mount.c |
99 | */ | 116 | */ |
100 | extern struct sysfs_dirent sysfs_root; | 117 | extern struct sysfs_dirent sysfs_root; |
101 | extern struct super_block *sysfs_sb; | ||
102 | extern struct kmem_cache *sysfs_dir_cachep; | 118 | extern struct kmem_cache *sysfs_dir_cachep; |
103 | 119 | ||
104 | /* | 120 | /* |
105 | * dir.c | 121 | * dir.c |
106 | */ | 122 | */ |
107 | extern struct mutex sysfs_mutex; | 123 | extern struct mutex sysfs_mutex; |
108 | extern struct mutex sysfs_rename_mutex; | ||
109 | extern spinlock_t sysfs_assoc_lock; | 124 | extern spinlock_t sysfs_assoc_lock; |
110 | 125 | ||
111 | extern const struct file_operations sysfs_dir_operations; | 126 | extern const struct file_operations sysfs_dir_operations; |
112 | extern const struct inode_operations sysfs_dir_inode_operations; | 127 | extern const struct inode_operations sysfs_dir_inode_operations; |
113 | 128 | ||
114 | struct dentry *sysfs_get_dentry(struct sysfs_dirent *sd); | 129 | struct dentry *sysfs_get_dentry(struct sysfs_dirent *sd); |
115 | struct sysfs_dirent *sysfs_get_active_two(struct sysfs_dirent *sd); | 130 | struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd); |
116 | void sysfs_put_active_two(struct sysfs_dirent *sd); | 131 | void sysfs_put_active(struct sysfs_dirent *sd); |
117 | void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, | 132 | void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, |
118 | struct sysfs_dirent *parent_sd); | 133 | struct sysfs_dirent *parent_sd); |
119 | int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd); | 134 | int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd); |
@@ -133,6 +148,9 @@ int sysfs_create_subdir(struct kobject *kobj, const char *name, | |||
133 | struct sysfs_dirent **p_sd); | 148 | struct sysfs_dirent **p_sd); |
134 | void sysfs_remove_subdir(struct sysfs_dirent *sd); | 149 | void sysfs_remove_subdir(struct sysfs_dirent *sd); |
135 | 150 | ||
151 | int sysfs_rename(struct sysfs_dirent *sd, | ||
152 | struct sysfs_dirent *new_parent_sd, const char *new_name); | ||
153 | |||
136 | static inline struct sysfs_dirent *__sysfs_get(struct sysfs_dirent *sd) | 154 | static inline struct sysfs_dirent *__sysfs_get(struct sysfs_dirent *sd) |
137 | { | 155 | { |
138 | if (sd) { | 156 | if (sd) { |
@@ -153,9 +171,12 @@ static inline void __sysfs_put(struct sysfs_dirent *sd) | |||
153 | /* | 171 | /* |
154 | * inode.c | 172 | * inode.c |
155 | */ | 173 | */ |
156 | struct inode *sysfs_get_inode(struct sysfs_dirent *sd); | 174 | struct inode *sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd); |
157 | void sysfs_delete_inode(struct inode *inode); | 175 | void sysfs_delete_inode(struct inode *inode); |
176 | int sysfs_sd_setattr(struct sysfs_dirent *sd, struct iattr *iattr); | ||
177 | int sysfs_permission(struct inode *inode, int mask); | ||
158 | int sysfs_setattr(struct dentry *dentry, struct iattr *iattr); | 178 | int sysfs_setattr(struct dentry *dentry, struct iattr *iattr); |
179 | int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat); | ||
159 | int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, | 180 | int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, |
160 | size_t size, int flags); | 181 | size_t size, int flags); |
161 | int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name); | 182 | int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name); |