2 extern struct vfsmount * sysfs_mount;
4 extern struct inode * sysfs_new_inode(mode_t mode);
5 extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *));
7 extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *,
9 extern struct dentry * sysfs_get_dentry(struct dentry *, const char *);
11 extern int sysfs_add_file(struct dentry *, const struct attribute *, int);
12 extern void sysfs_hash_and_remove(struct dentry * dir, const char * name);
14 extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **);
15 extern void sysfs_remove_subdir(struct dentry *);
17 extern const unsigned char * sysfs_get_name(struct sysfs_dirent *sd);
18 extern void sysfs_drop_dentry(struct sysfs_dirent *sd, struct dentry *parent);
20 extern struct rw_semaphore sysfs_rename_sem;
21 extern struct super_block * sysfs_sb;
22 extern struct file_operations sysfs_dir_operations;
23 extern struct file_operations sysfs_file_operations;
24 extern struct file_operations bin_fops;
25 extern struct inode_operations sysfs_dir_inode_operations;
26 extern struct inode_operations sysfs_symlink_inode_operations;
28 struct sysfs_symlink {
30 struct kobject * target_kobj;
33 static inline struct kobject * to_kobj(struct dentry * dentry)
35 struct sysfs_dirent * sd = dentry->d_fsdata;
36 return ((struct kobject *) sd->s_element);
39 static inline struct attribute * to_attr(struct dentry * dentry)
41 struct sysfs_dirent * sd = dentry->d_fsdata;
42 return ((struct attribute *) sd->s_element);
45 static inline struct bin_attribute * to_bin_attr(struct dentry * dentry)
47 struct sysfs_dirent * sd = dentry->d_fsdata;
48 return ((struct bin_attribute *) sd->s_element);
51 static inline struct kobject *sysfs_get_kobject(struct dentry *dentry)
53 struct kobject * kobj = NULL;
55 spin_lock(&dcache_lock);
56 if (!d_unhashed(dentry)) {
57 struct sysfs_dirent * sd = dentry->d_fsdata;
58 if (sd->s_type & SYSFS_KOBJ_LINK) {
59 struct sysfs_symlink * sl = sd->s_element;
60 kobj = kobject_get(sl->target_kobj);
62 kobj = kobject_get(sd->s_element);
64 spin_unlock(&dcache_lock);
69 static inline void release_sysfs_dirent(struct sysfs_dirent * sd)
71 if (sd->s_type & SYSFS_KOBJ_LINK) {
72 struct sysfs_symlink * sl = sd->s_element;
74 kobject_put(sl->target_kobj);
80 static inline struct sysfs_dirent * sysfs_get(struct sysfs_dirent * sd)
83 WARN_ON(!atomic_read(&sd->s_count));
84 atomic_inc(&sd->s_count);
89 static inline void sysfs_put(struct sysfs_dirent * sd)
91 if (atomic_dec_and_test(&sd->s_count))
92 release_sysfs_dirent(sd);