1 struct sysfs_elem_dir
{
5 struct sysfs_elem_symlink
{
6 struct sysfs_dirent
* target_sd
;
9 struct sysfs_elem_attr
{
10 struct attribute
* attr
;
13 struct sysfs_elem_bin_attr
{
14 struct bin_attribute
* bin_attr
;
19 struct sysfs_dirent
* s_parent
;
20 struct list_head s_sibling
;
21 struct list_head s_children
;
25 struct sysfs_elem_dir dir
;
26 struct sysfs_elem_symlink symlink
;
27 struct sysfs_elem_attr attr
;
28 struct sysfs_elem_bin_attr bin_attr
;
34 struct dentry
* s_dentry
;
35 struct iattr
* s_iattr
;
39 extern struct vfsmount
* sysfs_mount
;
40 extern struct kmem_cache
*sysfs_dir_cachep
;
42 extern void sysfs_delete_inode(struct inode
*inode
);
43 extern struct inode
* sysfs_new_inode(mode_t mode
, struct sysfs_dirent
*);
44 extern int sysfs_create(struct dentry
*, int mode
, int (*init
)(struct inode
*));
46 extern void release_sysfs_dirent(struct sysfs_dirent
* sd
);
47 extern int sysfs_dirent_exist(struct sysfs_dirent
*, const unsigned char *);
48 extern struct sysfs_dirent
*sysfs_new_dirent(const char *name
, umode_t mode
,
50 extern void sysfs_attach_dirent(struct sysfs_dirent
*sd
,
51 struct sysfs_dirent
*parent_sd
,
52 struct dentry
*dentry
);
54 extern int sysfs_add_file(struct dentry
*, const struct attribute
*, int);
55 extern int sysfs_hash_and_remove(struct dentry
* dir
, const char * name
);
56 extern struct sysfs_dirent
*sysfs_find(struct sysfs_dirent
*dir
, const char * name
);
58 extern int sysfs_create_subdir(struct kobject
*, const char *, struct dentry
**);
59 extern void sysfs_remove_subdir(struct dentry
*);
61 extern void sysfs_drop_dentry(struct sysfs_dirent
*sd
, struct dentry
*parent
);
62 extern int sysfs_setattr(struct dentry
*dentry
, struct iattr
*iattr
);
64 extern spinlock_t sysfs_lock
;
65 extern spinlock_t kobj_sysfs_assoc_lock
;
66 extern struct rw_semaphore sysfs_rename_sem
;
67 extern struct super_block
* sysfs_sb
;
68 extern const struct file_operations sysfs_dir_operations
;
69 extern const struct file_operations sysfs_file_operations
;
70 extern const struct file_operations bin_fops
;
71 extern const struct inode_operations sysfs_dir_inode_operations
;
72 extern const struct inode_operations sysfs_symlink_inode_operations
;
75 struct list_head associates
;
79 struct sysfs_ops
* ops
;
86 struct sysfs_buffer_collection
{
87 struct list_head associates
;
90 static inline struct kobject
* to_kobj(struct dentry
* dentry
)
92 struct sysfs_dirent
* sd
= dentry
->d_fsdata
;
93 return sd
->s_elem
.dir
.kobj
;
96 static inline struct kobject
*sysfs_get_kobject(struct dentry
*dentry
)
98 struct kobject
* kobj
= NULL
;
100 spin_lock(&dcache_lock
);
101 if (!d_unhashed(dentry
)) {
102 struct sysfs_dirent
* sd
= dentry
->d_fsdata
;
104 if (sd
->s_type
& SYSFS_KOBJ_LINK
)
105 sd
= sd
->s_elem
.symlink
.target_sd
;
107 kobj
= kobject_get(sd
->s_elem
.dir
.kobj
);
109 spin_unlock(&dcache_lock
);
114 static inline struct sysfs_dirent
* sysfs_get(struct sysfs_dirent
* sd
)
117 WARN_ON(!atomic_read(&sd
->s_count
));
118 atomic_inc(&sd
->s_count
);
123 static inline void sysfs_put(struct sysfs_dirent
* sd
)
125 if (sd
&& atomic_dec_and_test(&sd
->s_count
))
126 release_sysfs_dirent(sd
);
129 static inline int sysfs_is_shadowed_inode(struct inode
*inode
)
131 return S_ISDIR(inode
->i_mode
) && inode
->i_op
->follow_link
;