]> Pileus Git - ~andy/linux/blob - fs/sysfs/sysfs.h
f8c936f31b37ddaeb30086e5deeccfd5e4bde70c
[~andy/linux] / fs / sysfs / sysfs.h
1 /*
2  * fs/sysfs/sysfs.h - sysfs internal header file
3  *
4  * Copyright (c) 2001-3 Patrick Mochel
5  * Copyright (c) 2007 SUSE Linux Products GmbH
6  * Copyright (c) 2007 Tejun Heo <teheo@suse.de>
7  *
8  * This file is released under the GPLv2.
9  */
10
11 #ifndef __SYSFS_INTERNAL_H
12 #define __SYSFS_INTERNAL_H
13
14 #include "../kernfs/kernfs-internal.h"
15 #include <linux/sysfs.h>
16
17 /*
18  * mount.c
19  */
20
21 /*
22  * Each sb is associated with one namespace tag, currently the network
23  * namespace of the task which mounted this sysfs instance.  If multiple
24  * tags become necessary, make the following an array and compare
25  * sysfs_dirent tag against every entry.
26  */
27 struct sysfs_super_info {
28         void *ns;
29 };
30 #define sysfs_info(SB) ((struct sysfs_super_info *)(SB->s_fs_info))
31 extern struct sysfs_dirent sysfs_root;
32 extern struct kmem_cache *sysfs_dir_cachep;
33
34 /*
35  * dir.c
36  */
37 extern struct mutex sysfs_mutex;
38 extern spinlock_t sysfs_symlink_target_lock;
39 extern const struct dentry_operations sysfs_dentry_ops;
40
41 extern const struct file_operations sysfs_dir_operations;
42 extern const struct inode_operations sysfs_dir_inode_operations;
43
44 struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd);
45 void sysfs_put_active(struct sysfs_dirent *sd);
46 void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt);
47 void sysfs_warn_dup(struct sysfs_dirent *parent, const char *name);
48 int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd,
49                   struct sysfs_dirent *parent_sd);
50 void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
51
52 struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type);
53
54 /*
55  * inode.c
56  */
57 struct inode *sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd);
58 void sysfs_evict_inode(struct inode *inode);
59 int sysfs_permission(struct inode *inode, int mask);
60 int sysfs_setattr(struct dentry *dentry, struct iattr *iattr);
61 int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
62                   struct kstat *stat);
63 int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
64                    size_t size, int flags);
65 int sysfs_inode_init(void);
66
67 /*
68  * file.c
69  */
70 extern const struct file_operations kernfs_file_operations;
71
72 int sysfs_add_file(struct sysfs_dirent *dir_sd,
73                    const struct attribute *attr, bool is_bin);
74
75 int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,
76                            const struct attribute *attr, bool is_bin,
77                            umode_t amode, const void *ns);
78 void sysfs_unmap_bin_file(struct sysfs_dirent *sd);
79
80 /*
81  * symlink.c
82  */
83 extern const struct inode_operations sysfs_symlink_inode_operations;
84 int sysfs_create_link_sd(struct sysfs_dirent *sd, struct kobject *target,
85                          const char *name);
86
87 #endif  /* __SYSFS_INTERNAL_H */