diff options
author | Tejun Heo <tj@kernel.org> | 2013-11-28 14:54:31 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-29 20:55:10 -0500 |
commit | ae6621b0716852146e4655fef7f74a181faa6c81 (patch) | |
tree | 04b4e642dee773bc6acb4da51c56f0d19090de3e /fs | |
parent | ccf73cf336dc55bc52748205dee998d2fd4a8808 (diff) |
sysfs, kernfs: move internal decls to fs/kernfs/kernfs-internal.h
Move data structure, constant and basic accessor declarations from
fs/sysfs/sysfs.h to fs/kernfs/kernfs-internal.h. The two files
currently include each other. Once kernfs / sysfs separation is
complete, the cross inclusions will be removed. Inclusion protectors
are added to fs/sysfs/sysfs.h to allow cross-inclusion.
This patch doesn't introduce any functional changes.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/kernfs/kernfs-internal.h | 115 | ||||
-rw-r--r-- | fs/sysfs/sysfs.h | 102 |
2 files changed, 121 insertions, 96 deletions
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h new file mode 100644 index 000000000000..5a2c3a17d7cb --- /dev/null +++ b/fs/kernfs/kernfs-internal.h | |||
@@ -0,0 +1,115 @@ | |||
1 | /* | ||
2 | * fs/kernfs/kernfs-internal.h - kernfs internal header file | ||
3 | * | ||
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> | ||
7 | * | ||
8 | * This file is released under the GPLv2. | ||
9 | */ | ||
10 | |||
11 | #ifndef __KERNFS_INTERNAL_H | ||
12 | #define __KERNFS_INTERNAL_H | ||
13 | |||
14 | #include <linux/lockdep.h> | ||
15 | #include <linux/fs.h> | ||
16 | #include <linux/rbtree.h> | ||
17 | |||
18 | #include <linux/kernfs.h> | ||
19 | |||
20 | struct sysfs_open_dirent; | ||
21 | |||
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; | ||
27 | }; | ||
28 | |||
29 | struct sysfs_elem_symlink { | ||
30 | struct sysfs_dirent *target_sd; | ||
31 | }; | ||
32 | |||
33 | struct sysfs_elem_attr { | ||
34 | const struct kernfs_ops *ops; | ||
35 | struct sysfs_open_dirent *open; | ||
36 | loff_t size; | ||
37 | }; | ||
38 | |||
39 | struct sysfs_inode_attrs { | ||
40 | struct iattr ia_iattr; | ||
41 | void *ia_secdata; | ||
42 | u32 ia_secdata_len; | ||
43 | }; | ||
44 | |||
45 | /* | ||
46 | * sysfs_dirent - the building block of sysfs hierarchy. Each and | ||
47 | * every sysfs node is represented by single sysfs_dirent. | ||
48 | * | ||
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. | ||
52 | */ | ||
53 | struct sysfs_dirent { | ||
54 | atomic_t s_count; | ||
55 | atomic_t s_active; | ||
56 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
57 | struct lockdep_map dep_map; | ||
58 | #endif | ||
59 | struct sysfs_dirent *s_parent; | ||
60 | const char *s_name; | ||
61 | |||
62 | struct rb_node s_rb; | ||
63 | |||
64 | union { | ||
65 | struct completion *completion; | ||
66 | struct sysfs_dirent *removed_list; | ||
67 | } u; | ||
68 | |||
69 | const void *s_ns; /* namespace tag */ | ||
70 | unsigned int s_hash; /* ns + name hash */ | ||
71 | union { | ||
72 | struct sysfs_elem_dir s_dir; | ||
73 | struct sysfs_elem_symlink s_symlink; | ||
74 | struct sysfs_elem_attr s_attr; | ||
75 | }; | ||
76 | |||
77 | void *priv; | ||
78 | |||
79 | unsigned short s_flags; | ||
80 | umode_t s_mode; | ||
81 | unsigned int s_ino; | ||
82 | struct sysfs_inode_attrs *s_iattr; | ||
83 | }; | ||
84 | |||
85 | #define SD_DEACTIVATED_BIAS INT_MIN | ||
86 | |||
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 | ||
93 | |||
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 | ||
100 | |||
101 | static inline unsigned int sysfs_type(struct sysfs_dirent *sd) | ||
102 | { | ||
103 | return sd->s_flags & SYSFS_TYPE_MASK; | ||
104 | } | ||
105 | |||
106 | /* | ||
107 | * Context structure to be used while adding/removing nodes. | ||
108 | */ | ||
109 | struct sysfs_addrm_cxt { | ||
110 | struct sysfs_dirent *removed; | ||
111 | }; | ||
112 | |||
113 | #include "../sysfs/sysfs.h" | ||
114 | |||
115 | #endif /* __KERNFS_INTERNAL_H */ | ||
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h index 85315e228408..f8c936f31b37 100644 --- a/fs/sysfs/sysfs.h +++ b/fs/sysfs/sysfs.h | |||
@@ -8,103 +8,11 @@ | |||
8 | * This file is released under the GPLv2. | 8 | * This file is released under the GPLv2. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/lockdep.h> | 11 | #ifndef __SYSFS_INTERNAL_H |
12 | #include <linux/kobject_ns.h> | 12 | #define __SYSFS_INTERNAL_H |
13 | #include <linux/fs.h> | ||
14 | #include <linux/rbtree.h> | ||
15 | 13 | ||
16 | struct sysfs_open_dirent; | 14 | #include "../kernfs/kernfs-internal.h" |
17 | 15 | #include <linux/sysfs.h> | |
18 | /* type-specific structures for sysfs_dirent->s_* union members */ | ||
19 | struct sysfs_elem_dir { | ||
20 | unsigned long subdirs; | ||
21 | /* children rbtree starts here and goes through sd->s_rb */ | ||
22 | struct rb_root children; | ||
23 | }; | ||
24 | |||
25 | struct sysfs_elem_symlink { | ||
26 | struct sysfs_dirent *target_sd; | ||
27 | }; | ||
28 | |||
29 | struct sysfs_elem_attr { | ||
30 | const struct kernfs_ops *ops; | ||
31 | struct sysfs_open_dirent *open; | ||
32 | loff_t size; | ||
33 | }; | ||
34 | |||
35 | struct sysfs_inode_attrs { | ||
36 | struct iattr ia_iattr; | ||
37 | void *ia_secdata; | ||
38 | u32 ia_secdata_len; | ||
39 | }; | ||
40 | |||
41 | /* | ||
42 | * sysfs_dirent - the building block of sysfs hierarchy. Each and | ||
43 | * every sysfs node is represented by single sysfs_dirent. | ||
44 | * | ||
45 | * As long as s_count reference is held, the sysfs_dirent itself is | ||
46 | * accessible. Dereferencing s_elem or any other outer entity | ||
47 | * requires s_active reference. | ||
48 | */ | ||
49 | struct sysfs_dirent { | ||
50 | atomic_t s_count; | ||
51 | atomic_t s_active; | ||
52 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
53 | struct lockdep_map dep_map; | ||
54 | #endif | ||
55 | struct sysfs_dirent *s_parent; | ||
56 | const char *s_name; | ||
57 | |||
58 | struct rb_node s_rb; | ||
59 | |||
60 | union { | ||
61 | struct completion *completion; | ||
62 | struct sysfs_dirent *removed_list; | ||
63 | } u; | ||
64 | |||
65 | const void *s_ns; /* namespace tag */ | ||
66 | unsigned int s_hash; /* ns + name hash */ | ||
67 | union { | ||
68 | struct sysfs_elem_dir s_dir; | ||
69 | struct sysfs_elem_symlink s_symlink; | ||
70 | struct sysfs_elem_attr s_attr; | ||
71 | }; | ||
72 | |||
73 | void *priv; | ||
74 | |||
75 | unsigned short s_flags; | ||
76 | umode_t s_mode; | ||
77 | unsigned int s_ino; | ||
78 | struct sysfs_inode_attrs *s_iattr; | ||
79 | }; | ||
80 | |||
81 | #define SD_DEACTIVATED_BIAS INT_MIN | ||
82 | |||
83 | #define SYSFS_TYPE_MASK 0x000f | ||
84 | #define SYSFS_DIR 0x0001 | ||
85 | #define SYSFS_KOBJ_ATTR 0x0002 | ||
86 | #define SYSFS_KOBJ_LINK 0x0004 | ||
87 | #define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK) | ||
88 | #define SYSFS_ACTIVE_REF SYSFS_KOBJ_ATTR | ||
89 | |||
90 | #define SYSFS_FLAG_MASK ~SYSFS_TYPE_MASK | ||
91 | #define SYSFS_FLAG_REMOVED 0x0010 | ||
92 | #define SYSFS_FLAG_NS 0x0020 | ||
93 | #define SYSFS_FLAG_HAS_SEQ_SHOW 0x0040 | ||
94 | #define SYSFS_FLAG_HAS_MMAP 0x0080 | ||
95 | #define SYSFS_FLAG_LOCKDEP 0x0100 | ||
96 | |||
97 | static inline unsigned int sysfs_type(struct sysfs_dirent *sd) | ||
98 | { | ||
99 | return sd->s_flags & SYSFS_TYPE_MASK; | ||
100 | } | ||
101 | |||
102 | /* | ||
103 | * Context structure to be used while adding/removing nodes. | ||
104 | */ | ||
105 | struct sysfs_addrm_cxt { | ||
106 | struct sysfs_dirent *removed; | ||
107 | }; | ||
108 | 16 | ||
109 | /* | 17 | /* |
110 | * mount.c | 18 | * mount.c |
@@ -175,3 +83,5 @@ void sysfs_unmap_bin_file(struct sysfs_dirent *sd); | |||
175 | extern const struct inode_operations sysfs_symlink_inode_operations; | 83 | extern const struct inode_operations sysfs_symlink_inode_operations; |
176 | int sysfs_create_link_sd(struct sysfs_dirent *sd, struct kobject *target, | 84 | int sysfs_create_link_sd(struct sysfs_dirent *sd, struct kobject *target, |
177 | const char *name); | 85 | const char *name); |
86 | |||
87 | #endif /* __SYSFS_INTERNAL_H */ | ||