Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * dir.c - Operations for sysfs directories. | |
3 | */ | |
4 | ||
5 | #undef DEBUG | |
6 | ||
7 | #include <linux/fs.h> | |
8 | #include <linux/mount.h> | |
9 | #include <linux/module.h> | |
10 | #include <linux/kobject.h> | |
5f45f1a7 | 11 | #include <linux/namei.h> |
94bebf4d | 12 | #include <asm/semaphore.h> |
1da177e4 LT |
13 | #include "sysfs.h" |
14 | ||
15 | DECLARE_RWSEM(sysfs_rename_sem); | |
16 | ||
17 | static void sysfs_d_iput(struct dentry * dentry, struct inode * inode) | |
18 | { | |
19 | struct sysfs_dirent * sd = dentry->d_fsdata; | |
20 | ||
21 | if (sd) { | |
22 | BUG_ON(sd->s_dentry != dentry); | |
23 | sd->s_dentry = NULL; | |
24 | sysfs_put(sd); | |
25 | } | |
26 | iput(inode); | |
27 | } | |
28 | ||
29 | static struct dentry_operations sysfs_dentry_ops = { | |
30 | .d_iput = sysfs_d_iput, | |
31 | }; | |
32 | ||
33 | /* | |
34 | * Allocates a new sysfs_dirent and links it to the parent sysfs_dirent | |
35 | */ | |
b592fcfe | 36 | static struct sysfs_dirent * __sysfs_new_dirent(void * element) |
1da177e4 LT |
37 | { |
38 | struct sysfs_dirent * sd; | |
39 | ||
c3762229 | 40 | sd = kmem_cache_zalloc(sysfs_dir_cachep, GFP_KERNEL); |
1da177e4 LT |
41 | if (!sd) |
42 | return NULL; | |
43 | ||
1da177e4 | 44 | atomic_set(&sd->s_count, 1); |