2 * fs/kernfs/kernfs-internal.h - kernfs internal header file
4 * Copyright (c) 2001-3 Patrick Mochel
5 * Copyright (c) 2007 SUSE Linux Products GmbH
6 * Copyright (c) 2007, 2013 Tejun Heo <teheo@suse.de>
8 * This file is released under the GPLv2.
11 #ifndef __KERNFS_INTERNAL_H
12 #define __KERNFS_INTERNAL_H
14 #include <linux/lockdep.h>
16 #include <linux/rbtree.h>
18 #include <linux/kernfs.h>
20 struct sysfs_open_dirent;
22 /* type-specific structures for sysfs_dirent->s_* union members */
23 struct sysfs_elem_dir {
24 unsigned long subdirs;
25 /* children rbtree starts here and goes through sd->s_rb */
26 struct rb_root children;
29 struct sysfs_elem_symlink {
30 struct sysfs_dirent *target_sd;
33 struct sysfs_elem_attr {
34 const struct kernfs_ops *ops;
35 struct sysfs_open_dirent *open;
39 struct sysfs_inode_attrs {
40 struct iattr ia_iattr;
46 * sysfs_dirent - the building block of sysfs hierarchy. Each and
47 * every sysfs node is represented by single sysfs_dirent.
49 * As long as s_count reference is held, the sysfs_dirent itself is
50 * accessible. Dereferencing s_elem or any other outer entity
51 * requires s_active reference.
56 #ifdef CONFIG_DEBUG_LOCK_ALLOC
57 struct lockdep_map dep_map;
59 struct sysfs_dirent *s_parent;
65 struct completion *completion;
66 struct sysfs_dirent *removed_list;
69 const void *s_ns; /* namespace tag */
70 unsigned int s_hash; /* ns + name hash */
72 struct sysfs_elem_dir s_dir;
73 struct sysfs_elem_symlink s_symlink;
74 struct sysfs_elem_attr s_attr;
79 unsigned short s_flags;
82 struct sysfs_inode_attrs *s_iattr;
85 #define SD_DEACTIVATED_BIAS INT_MIN
87 #define SYSFS_TYPE_MASK 0x000f
88 #define SYSFS_DIR 0x0001
89 #define SYSFS_KOBJ_ATTR 0x0002
90 #define SYSFS_KOBJ_LINK 0x0004
91 #define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK)
92 #define SYSFS_ACTIVE_REF SYSFS_KOBJ_ATTR
94 #define SYSFS_FLAG_MASK ~SYSFS_TYPE_MASK
95 #define SYSFS_FLAG_REMOVED 0x0010
96 #define SYSFS_FLAG_NS 0x0020
97 #define SYSFS_FLAG_HAS_SEQ_SHOW 0x0040
98 #define SYSFS_FLAG_HAS_MMAP 0x0080
99 #define SYSFS_FLAG_LOCKDEP 0x0100
101 static inline unsigned int sysfs_type(struct sysfs_dirent *sd)
103 return sd->s_flags & SYSFS_TYPE_MASK;
107 * Context structure to be used while adding/removing nodes.
109 struct sysfs_addrm_cxt {
110 struct sysfs_dirent *removed;
113 #include "../sysfs/sysfs.h"
118 struct inode *sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd);
119 void sysfs_evict_inode(struct inode *inode);
120 int sysfs_permission(struct inode *inode, int mask);
121 int sysfs_setattr(struct dentry *dentry, struct iattr *iattr);
122 int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
124 int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
125 size_t size, int flags);
126 int sysfs_inode_init(void);
128 #endif /* __KERNFS_INTERNAL_H */