diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /fs/sysfs/sysfs.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'fs/sysfs/sysfs.h')
-rw-r--r-- | fs/sysfs/sysfs.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h new file mode 100644 index 000000000000..a8a24a0c0b3b --- /dev/null +++ b/fs/sysfs/sysfs.h | |||
@@ -0,0 +1,95 @@ | |||
1 | |||
2 | extern struct vfsmount * sysfs_mount; | ||
3 | extern kmem_cache_t *sysfs_dir_cachep; | ||
4 | |||
5 | extern struct inode * sysfs_new_inode(mode_t mode); | ||
6 | extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *)); | ||
7 | |||
8 | extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *, | ||
9 | umode_t, int); | ||
10 | extern struct dentry * sysfs_get_dentry(struct dentry *, const char *); | ||
11 | |||
12 | extern int sysfs_add_file(struct dentry *, const struct attribute *, int); | ||
13 | extern void sysfs_hash_and_remove(struct dentry * dir, const char * name); | ||
14 | |||
15 | extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **); | ||
16 | extern void sysfs_remove_subdir(struct dentry *); | ||
17 | |||
18 | extern const unsigned char * sysfs_get_name(struct sysfs_dirent *sd); | ||
19 | extern void sysfs_drop_dentry(struct sysfs_dirent *sd, struct dentry *parent); | ||
20 | |||
21 | extern struct rw_semaphore sysfs_rename_sem; | ||
22 | extern struct super_block * sysfs_sb; | ||
23 | extern struct file_operations sysfs_dir_operations; | ||
24 | extern struct file_operations sysfs_file_operations; | ||
25 | extern struct file_operations bin_fops; | ||
26 | extern struct inode_operations sysfs_dir_inode_operations; | ||
27 | extern struct inode_operations sysfs_symlink_inode_operations; | ||
28 | |||
29 | struct sysfs_symlink { | ||
30 | char * link_name; | ||
31 | struct kobject * target_kobj; | ||
32 | }; | ||
33 | |||
34 | static inline struct kobject * to_kobj(struct dentry * dentry) | ||
35 | { | ||
36 | struct sysfs_dirent * sd = dentry->d_fsdata; | ||
37 | return ((struct kobject *) sd->s_element); | ||
38 | } | ||
39 | |||
40 | static inline struct attribute * to_attr(struct dentry * dentry) | ||
41 | { | ||
42 | struct sysfs_dirent * sd = dentry->d_fsdata; | ||
43 | return ((struct attribute *) sd->s_element); | ||
44 | } | ||
45 | |||
46 | static inline struct bin_attribute * to_bin_attr(struct dentry * dentry) | ||
47 | { | ||
48 | struct sysfs_dirent * sd = dentry->d_fsdata; | ||
49 | return ((struct bin_attribute *) sd->s_element); | ||
50 | } | ||
51 | |||
52 | static inline struct kobject *sysfs_get_kobject(struct dentry *dentry) | ||
53 | { | ||
54 | struct kobject * kobj = NULL; | ||
55 | |||
56 | spin_lock(&dcache_lock); | ||
57 | if (!d_unhashed(dentry)) { | ||
58 | struct sysfs_dirent * sd = dentry->d_fsdata; | ||
59 | if (sd->s_type & SYSFS_KOBJ_LINK) { | ||
60 | struct sysfs_symlink * sl = sd->s_element; | ||
61 | kobj = kobject_get(sl->target_kobj); | ||
62 | } else | ||
63 | kobj = kobject_get(sd->s_element); | ||
64 | } | ||
65 | spin_unlock(&dcache_lock); | ||
66 | |||
67 | return kobj; | ||
68 | } | ||
69 | |||
70 | static inline void release_sysfs_dirent(struct sysfs_dirent * sd) | ||
71 | { | ||
72 | if (sd->s_type & SYSFS_KOBJ_LINK) { | ||
73 | struct sysfs_symlink * sl = sd->s_element; | ||
74 | kfree(sl->link_name); | ||
75 | kobject_put(sl->target_kobj); | ||
76 | kfree(sl); | ||
77 | } | ||
78 | kmem_cache_free(sysfs_dir_cachep, sd); | ||
79 | } | ||
80 | |||
81 | static inline struct sysfs_dirent * sysfs_get(struct sysfs_dirent * sd) | ||
82 | { | ||
83 | if (sd) { | ||
84 | WARN_ON(!atomic_read(&sd->s_count)); | ||
85 | atomic_inc(&sd->s_count); | ||
86 | } | ||
87 | return sd; | ||
88 | } | ||
89 | |||
90 | static inline void sysfs_put(struct sysfs_dirent * sd) | ||
91 | { | ||
92 | if (atomic_dec_and_test(&sd->s_count)) | ||
93 | release_sysfs_dirent(sd); | ||
94 | } | ||
95 | |||