Blame view
fs/sysfs/sysfs.h
6.33 KB
6d66f5cd2 sysfs: add copyri... |
1 2 3 4 5 6 7 8 9 |
/* * fs/sysfs/sysfs.h - sysfs internal header file * * Copyright (c) 2001-3 Patrick Mochel * Copyright (c) 2007 SUSE Linux Products GmbH * Copyright (c) 2007 Tejun Heo <teheo@suse.de> * * This file is released under the GPLv2. */ |
846f99749 sysfs: Add lockde... |
10 |
#include <linux/lockdep.h> |
57cc7215b headers: kobject.... |
11 |
#include <linux/kobject_ns.h> |
ddd29ec65 sysfs: Add labeli... |
12 |
#include <linux/fs.h> |
85a4ffad3 sysfs: implement ... |
13 |
struct sysfs_open_dirent; |
59f690156 sysfs: clean up h... |
14 |
/* type-specific structures for sysfs_dirent->s_* union members */ |
3e5190380 sysfs: make sysfs... |
15 |
struct sysfs_elem_dir { |
59f690156 sysfs: clean up h... |
16 |
struct kobject *kobj; |
bc747f37a sysfs: move sysfs... |
17 18 |
/* children list starts here and goes through sd->s_sibling */ struct sysfs_dirent *children; |
3e5190380 sysfs: make sysfs... |
19 20 21 |
}; struct sysfs_elem_symlink { |
59f690156 sysfs: clean up h... |
22 |
struct sysfs_dirent *target_sd; |
3e5190380 sysfs: make sysfs... |
23 24 25 |
}; struct sysfs_elem_attr { |
59f690156 sysfs: clean up h... |
26 |
struct attribute *attr; |
85a4ffad3 sysfs: implement ... |
27 |
struct sysfs_open_dirent *open; |
3e5190380 sysfs: make sysfs... |
28 29 30 |
}; struct sysfs_elem_bin_attr { |
59f690156 sysfs: clean up h... |
31 |
struct bin_attribute *bin_attr; |
e0edd3c65 sysfs: don't bloc... |
32 |
struct hlist_head buffers; |
3e5190380 sysfs: make sysfs... |
33 |
}; |
ddd29ec65 sysfs: Add labeli... |
34 35 36 37 38 |
struct sysfs_inode_attrs { struct iattr ia_iattr; void *ia_secdata; u32 ia_secdata_len; }; |
0ab66088c sysfs: implement ... |
39 |
/* |
59f690156 sysfs: clean up h... |
40 41 42 |
* sysfs_dirent - the building block of sysfs hierarchy. Each and * every sysfs node is represented by single sysfs_dirent. * |
0ab66088c sysfs: implement ... |
43 44 45 46 |
* As long as s_count reference is held, the sysfs_dirent itself is * accessible. Dereferencing s_elem or any other outer entity * requires s_active reference. */ |
d56c3eae6 sysfs: move struc... |
47 48 |
struct sysfs_dirent { atomic_t s_count; |
8619f9798 sysfs: slim down ... |
49 |
atomic_t s_active; |
846f99749 sysfs: Add lockde... |
50 51 52 |
#ifdef CONFIG_DEBUG_LOCK_ALLOC struct lockdep_map dep_map; #endif |
59f690156 sysfs: clean up h... |
53 54 |
struct sysfs_dirent *s_parent; struct sysfs_dirent *s_sibling; |
59f690156 sysfs: clean up h... |
55 |
const char *s_name; |
3e5190380 sysfs: make sysfs... |
56 |
|
be867b194 sysfs: Comment sy... |
57 |
const void *s_ns; /* namespace tag */ |
3e5190380 sysfs: make sysfs... |
58 |
union { |
b1fc3d614 sysfs: make s_ele... |
59 60 61 62 63 |
struct sysfs_elem_dir s_dir; struct sysfs_elem_symlink s_symlink; struct sysfs_elem_attr s_attr; struct sysfs_elem_bin_attr s_bin_attr; }; |
3e5190380 sysfs: make sysfs... |
64 |
|
b402d72cf sysfs: rename sys... |
65 |
unsigned int s_flags; |
19c38b632 sysfs: Pack sysfs... |
66 |
unsigned short s_mode; |
dc351252b sysfs: store sysf... |
67 |
ino_t s_ino; |
ddd29ec65 sysfs: Add labeli... |
68 |
struct sysfs_inode_attrs *s_iattr; |
d56c3eae6 sysfs: move struc... |
69 |
}; |
1da177e4c Linux-2.6.12-rc2 |
70 |
|
59f690156 sysfs: clean up h... |
71 |
#define SD_DEACTIVATED_BIAS INT_MIN |
0ab66088c sysfs: implement ... |
72 |
|
59f690156 sysfs: clean up h... |
73 |
#define SYSFS_TYPE_MASK 0x00ff |
dc2f75f0e sysfs: make sysfs... |
74 75 76 77 |
#define SYSFS_DIR 0x0001 #define SYSFS_KOBJ_ATTR 0x0002 #define SYSFS_KOBJ_BIN_ATTR 0x0004 #define SYSFS_KOBJ_LINK 0x0008 |
59f690156 sysfs: clean up h... |
78 |
#define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK) |
a2db68428 sysfs: Only take ... |
79 |
#define SYSFS_ACTIVE_REF (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR) |
59f690156 sysfs: clean up h... |
80 |
|
be867b194 sysfs: Comment sy... |
81 |
/* identify any namespace tag on sysfs_dirents */ |
3ff195b01 sysfs: Implement ... |
82 83 84 85 86 |
#define SYSFS_NS_TYPE_MASK 0xff00 #define SYSFS_NS_TYPE_SHIFT 8 #define SYSFS_FLAG_MASK ~(SYSFS_NS_TYPE_MASK|SYSFS_TYPE_MASK) #define SYSFS_FLAG_REMOVED 0x020000 |
59f690156 sysfs: clean up h... |
87 88 89 90 91 |
static inline unsigned int sysfs_type(struct sysfs_dirent *sd) { return sd->s_flags & SYSFS_TYPE_MASK; } |
be867b194 sysfs: Comment sy... |
92 93 94 95 |
/* * Return any namespace tags on this dirent. * enum kobj_ns_type is defined in linux/kobject.h */ |
3ff195b01 sysfs: Implement ... |
96 97 98 99 |
static inline enum kobj_ns_type sysfs_ns_type(struct sysfs_dirent *sd) { return (sd->s_flags & SYSFS_NS_TYPE_MASK) >> SYSFS_NS_TYPE_SHIFT; } |
846f99749 sysfs: Add lockde... |
100 101 102 |
#ifdef CONFIG_DEBUG_LOCK_ALLOC #define sysfs_dirent_init_lockdep(sd) \ do { \ |
6992f5334 sysfs: Use one lo... |
103 104 105 106 |
struct attribute *attr = sd->s_attr.attr; \ struct lock_class_key *key = attr->key; \ if (!key) \ key = &attr->skey; \ |
846f99749 sysfs: Add lockde... |
107 |
\ |
6992f5334 sysfs: Use one lo... |
108 |
lockdep_init_map(&sd->dep_map, "s_active", key, 0); \ |
846f99749 sysfs: Add lockde... |
109 110 111 112 |
} while(0) #else #define sysfs_dirent_init_lockdep(sd) do {} while(0) #endif |
59f690156 sysfs: clean up h... |
113 114 115 |
/* * Context structure to be used while adding/removing nodes. */ |
fb6896da3 sysfs: restructur... |
116 117 |
struct sysfs_addrm_cxt { struct sysfs_dirent *parent_sd; |
fb6896da3 sysfs: restructur... |
118 |
struct sysfs_dirent *removed; |
fb6896da3 sysfs: restructur... |
119 |
}; |
59f690156 sysfs: clean up h... |
120 121 122 |
/* * mount.c */ |
be867b194 sysfs: Comment sy... |
123 124 125 126 127 128 |
/* * Each sb is associated with a set of namespace tags (i.e. * the network namespace of the task which mounted this sysfs * instance). */ |
9e7fdd25b sysfs: Basic supp... |
129 |
struct sysfs_super_info { |
3ff195b01 sysfs: Implement ... |
130 |
const void *ns[KOBJ_NS_TYPES]; |
9e7fdd25b sysfs: Basic supp... |
131 132 |
}; #define sysfs_info(SB) ((struct sysfs_super_info *)(SB->s_fs_info)) |
51225039f sysfs: make direc... |
133 |
extern struct sysfs_dirent sysfs_root; |
e18b890bb [PATCH] slab: rem... |
134 |
extern struct kmem_cache *sysfs_dir_cachep; |
1da177e4c Linux-2.6.12-rc2 |
135 |
|
59f690156 sysfs: clean up h... |
136 137 138 |
/* * dir.c */ |
3007e997d sysfs: use sysfs_... |
139 |
extern struct mutex sysfs_mutex; |
59f690156 sysfs: clean up h... |
140 |
extern spinlock_t sysfs_assoc_lock; |
4b6f5d20b [PATCH] Make most... |
141 |
extern const struct file_operations sysfs_dir_operations; |
c5ef1c42c [PATCH] mark stru... |
142 |
extern const struct inode_operations sysfs_dir_inode_operations; |
1da177e4c Linux-2.6.12-rc2 |
143 |
|
59f690156 sysfs: clean up h... |
144 |
struct dentry *sysfs_get_dentry(struct sysfs_dirent *sd); |
e72ceb8cc sysfs: Remove sys... |
145 146 |
struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd); void sysfs_put_active(struct sysfs_dirent *sd); |
59f690156 sysfs: clean up h... |
147 148 |
void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *parent_sd); |
36ce6dad6 driver core: Supp... |
149 |
int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd); |
59f690156 sysfs: clean up h... |
150 151 152 153 154 |
int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd); void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd); void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt); struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, |
3ff195b01 sysfs: Implement ... |
155 |
const void *ns, |
59f690156 sysfs: clean up h... |
156 157 |
const unsigned char *name); struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, |
3ff195b01 sysfs: Implement ... |
158 |
const void *ns, |
59f690156 sysfs: clean up h... |
159 160 161 162 163 164 165 166 |
const unsigned char *name); struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type); void release_sysfs_dirent(struct sysfs_dirent *sd); int sysfs_create_subdir(struct kobject *kobj, const char *name, struct sysfs_dirent **p_sd); void sysfs_remove_subdir(struct sysfs_dirent *sd); |
ca1bab381 sysfs: Factor out... |
167 |
int sysfs_rename(struct sysfs_dirent *sd, |
3ff195b01 sysfs: Implement ... |
168 |
struct sysfs_dirent *new_parent_sd, const void *ns, const char *new_name); |
ca1bab381 sysfs: Factor out... |
169 |
|
f1282c844 sysfs: Support sy... |
170 |
static inline struct sysfs_dirent *__sysfs_get(struct sysfs_dirent *sd) |
1da177e4c Linux-2.6.12-rc2 |
171 |
{ |
0ab66088c sysfs: implement ... |
172 173 174 175 176 |
if (sd) { WARN_ON(!atomic_read(&sd->s_count)); atomic_inc(&sd->s_count); } return sd; |
1da177e4c Linux-2.6.12-rc2 |
177 |
} |
f1282c844 sysfs: Support sy... |
178 |
#define sysfs_get(sd) __sysfs_get(sd) |
1da177e4c Linux-2.6.12-rc2 |
179 |
|
f1282c844 sysfs: Support sy... |
180 |
static inline void __sysfs_put(struct sysfs_dirent *sd) |
1da177e4c Linux-2.6.12-rc2 |
181 |
{ |
0ab66088c sysfs: implement ... |
182 183 184 |
if (sd && atomic_dec_and_test(&sd->s_count)) release_sysfs_dirent(sd); } |
f1282c844 sysfs: Support sy... |
185 |
#define sysfs_put(sd) __sysfs_put(sd) |
59f690156 sysfs: clean up h... |
186 187 188 189 |
/* * inode.c */ |
fac2622bb sysfs: Pass super... |
190 |
struct inode *sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd); |
01cd9fef6 switch sysfs to -... |
191 |
void sysfs_evict_inode(struct inode *inode); |
35df63c46 sysfs: Fix lockin... |
192 |
int sysfs_sd_setattr(struct sysfs_dirent *sd, struct iattr *iattr); |
b74c79e99 fs: provide rcu-w... |
193 |
int sysfs_permission(struct inode *inode, int mask, unsigned int flags); |
59f690156 sysfs: clean up h... |
194 |
int sysfs_setattr(struct dentry *dentry, struct iattr *iattr); |
e61ab4ae4 sysfs: Implement ... |
195 |
int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat); |
ddd29ec65 sysfs: Add labeli... |
196 197 |
int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags); |
3ff195b01 sysfs: Implement ... |
198 |
int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const void *ns, const char *name); |
e0bf68dde mm: bdi init hooks |
199 |
int sysfs_inode_init(void); |
59f690156 sysfs: clean up h... |
200 201 202 203 204 205 206 207 |
/* * file.c */ extern const struct file_operations sysfs_file_operations; int sysfs_add_file(struct sysfs_dirent *dir_sd, const struct attribute *attr, int type); |
0f4238958 [SCSI] sysfs: mak... |
208 209 |
int sysfs_add_file_mode(struct sysfs_dirent *dir_sd, const struct attribute *attr, int type, mode_t amode); |
59f690156 sysfs: clean up h... |
210 211 212 213 |
/* * bin.c */ extern const struct file_operations bin_fops; |
e0edd3c65 sysfs: don't bloc... |
214 |
void unmap_bin_file(struct sysfs_dirent *attr_sd); |
59f690156 sysfs: clean up h... |
215 216 217 218 219 |
/* * symlink.c */ extern const struct inode_operations sysfs_symlink_inode_operations; |