diff options
Diffstat (limited to 'fs/configfs/dir.c')
-rw-r--r-- | fs/configfs/dir.c | 72 |
1 files changed, 32 insertions, 40 deletions
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index c9c298bd3058..cf0db005d2f5 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -240,60 +240,26 @@ int configfs_make_dirent(struct configfs_dirent * parent_sd, | |||
240 | return 0; | 240 | return 0; |
241 | } | 241 | } |
242 | 242 | ||
243 | static int init_dir(struct inode * inode) | 243 | static void init_dir(struct inode * inode) |
244 | { | 244 | { |
245 | inode->i_op = &configfs_dir_inode_operations; | 245 | inode->i_op = &configfs_dir_inode_operations; |
246 | inode->i_fop = &configfs_dir_operations; | 246 | inode->i_fop = &configfs_dir_operations; |
247 | 247 | ||
248 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 248 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ |
249 | inc_nlink(inode); | 249 | inc_nlink(inode); |
250 | return 0; | ||
251 | } | 250 | } |
252 | 251 | ||
253 | static int configfs_init_file(struct inode * inode) | 252 | static void configfs_init_file(struct inode * inode) |
254 | { | 253 | { |
255 | inode->i_size = PAGE_SIZE; | 254 | inode->i_size = PAGE_SIZE; |
256 | inode->i_fop = &configfs_file_operations; | 255 | inode->i_fop = &configfs_file_operations; |
257 | return 0; | ||
258 | } | 256 | } |
259 | 257 | ||
260 | static int init_symlink(struct inode * inode) | 258 | static void init_symlink(struct inode * inode) |
261 | { | 259 | { |
262 | inode->i_op = &configfs_symlink_inode_operations; | 260 | inode->i_op = &configfs_symlink_inode_operations; |
263 | return 0; | ||
264 | } | ||
265 | |||
266 | static int create_dir(struct config_item *k, struct dentry *d) | ||
267 | { | ||
268 | int error; | ||
269 | umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO; | ||
270 | struct dentry *p = d->d_parent; | ||
271 | |||
272 | BUG_ON(!k); | ||
273 | |||
274 | error = configfs_dirent_exists(p->d_fsdata, d->d_name.name); | ||
275 | if (!error) | ||
276 | error = configfs_make_dirent(p->d_fsdata, d, k, mode, | ||
277 | CONFIGFS_DIR | CONFIGFS_USET_CREATING); | ||
278 | if (!error) { | ||
279 | configfs_set_dir_dirent_depth(p->d_fsdata, d->d_fsdata); | ||
280 | error = configfs_create(d, mode, init_dir); | ||
281 | if (!error) { | ||
282 | inc_nlink(p->d_inode); | ||
283 | } else { | ||
284 | struct configfs_dirent *sd = d->d_fsdata; | ||
285 | if (sd) { | ||
286 | spin_lock(&configfs_dirent_lock); | ||
287 | list_del_init(&sd->s_sibling); | ||
288 | spin_unlock(&configfs_dirent_lock); | ||
289 | configfs_put(sd); | ||
290 | } | ||
291 | } | ||
292 | } | ||
293 | return error; | ||
294 | } | 261 | } |
295 | 262 | ||
296 | |||
297 | /** | 263 | /** |
298 | * configfs_create_dir - create a directory for an config_item. | 264 | * configfs_create_dir - create a directory for an config_item. |
299 | * @item: config_itemwe're creating directory for. | 265 | * @item: config_itemwe're creating directory for. |
@@ -303,11 +269,37 @@ static int create_dir(struct config_item *k, struct dentry *d) | |||
303 | * until it is validated by configfs_dir_set_ready() | 269 | * until it is validated by configfs_dir_set_ready() |
304 | */ | 270 | */ |
305 | 271 | ||
306 | static int configfs_create_dir(struct config_item * item, struct dentry *dentry) | 272 | static int configfs_create_dir(struct config_item *item, struct dentry *dentry) |
307 | { | 273 | { |
308 | int error = create_dir(item, dentry); | 274 | int error; |
309 | if (!error) | 275 | umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO; |
276 | struct dentry *p = dentry->d_parent; | ||
277 | |||
278 | BUG_ON(!item); | ||
279 | |||
280 | error = configfs_dirent_exists(p->d_fsdata, dentry->d_name.name); | ||
281 | if (unlikely(error)) | ||
282 | return error; | ||
283 | |||
284 | error = configfs_make_dirent(p->d_fsdata, dentry, item, mode, | ||
285 | CONFIGFS_DIR | CONFIGFS_USET_CREATING); | ||
286 | if (unlikely(error)) | ||
287 | return error; | ||
288 | |||
289 | configfs_set_dir_dirent_depth(p->d_fsdata, dentry->d_fsdata); | ||
290 | error = configfs_create(dentry, mode, init_dir); | ||
291 | if (!error) { | ||
292 | inc_nlink(p->d_inode); | ||
310 | item->ci_dentry = dentry; | 293 | item->ci_dentry = dentry; |
294 | } else { | ||
295 | struct configfs_dirent *sd = dentry->d_fsdata; | ||
296 | if (sd) { | ||
297 | spin_lock(&configfs_dirent_lock); | ||
298 | list_del_init(&sd->s_sibling); | ||
299 | spin_unlock(&configfs_dirent_lock); | ||
300 | configfs_put(sd); | ||
301 | } | ||
302 | } | ||
311 | return error; | 303 | return error; |
312 | } | 304 | } |
313 | 305 | ||