diff options
-rw-r--r-- | fs/relayfs/buffers.c | 2 | ||||
-rw-r--r-- | fs/relayfs/relay.c | 30 | ||||
-rw-r--r-- | include/linux/relayfs_fs.h | 34 |
3 files changed, 63 insertions, 3 deletions
diff --git a/fs/relayfs/buffers.c b/fs/relayfs/buffers.c index 667b529944c5..10187812771e 100644 --- a/fs/relayfs/buffers.c +++ b/fs/relayfs/buffers.c | |||
@@ -185,6 +185,6 @@ void relay_destroy_buf(struct rchan_buf *buf) | |||
185 | void relay_remove_buf(struct kref *kref) | 185 | void relay_remove_buf(struct kref *kref) |
186 | { | 186 | { |
187 | struct rchan_buf *buf = container_of(kref, struct rchan_buf, kref); | 187 | struct rchan_buf *buf = container_of(kref, struct rchan_buf, kref); |
188 | relayfs_remove(buf->dentry); | 188 | buf->chan->cb->remove_buf_file(buf->dentry); |
189 | relay_destroy_buf(buf); | 189 | relay_destroy_buf(buf); |
190 | } | 190 | } |
diff --git a/fs/relayfs/relay.c b/fs/relayfs/relay.c index a9cd5585c45c..b9bb56903272 100644 --- a/fs/relayfs/relay.c +++ b/fs/relayfs/relay.c | |||
@@ -80,11 +80,33 @@ static void buf_unmapped_default_callback(struct rchan_buf *buf, | |||
80 | { | 80 | { |
81 | } | 81 | } |
82 | 82 | ||
83 | /* | ||
84 | * create_buf_file_create() default callback. Creates file to represent buf. | ||
85 | */ | ||
86 | static struct dentry *create_buf_file_default_callback(const char *filename, | ||
87 | struct dentry *parent, | ||
88 | int mode, | ||
89 | struct rchan_buf *buf) | ||
90 | { | ||
91 | return relayfs_create_file(filename, parent, mode, | ||
92 | &relayfs_file_operations, buf); | ||
93 | } | ||
94 | |||
95 | /* | ||
96 | * remove_buf_file() default callback. Removes file representing relay buffer. | ||
97 | */ | ||
98 | static int remove_buf_file_default_callback(struct dentry *dentry) | ||
99 | { | ||
100 | return relayfs_remove(dentry); | ||
101 | } | ||
102 | |||
83 | /* relay channel default callbacks */ | 103 | /* relay channel default callbacks */ |
84 | static struct rchan_callbacks default_channel_callbacks = { | 104 | static struct rchan_callbacks default_channel_callbacks = { |
85 | .subbuf_start = subbuf_start_default_callback, | 105 | .subbuf_start = subbuf_start_default_callback, |
86 | .buf_mapped = buf_mapped_default_callback, | 106 | .buf_mapped = buf_mapped_default_callback, |
87 | .buf_unmapped = buf_unmapped_default_callback, | 107 | .buf_unmapped = buf_unmapped_default_callback, |
108 | .create_buf_file = create_buf_file_default_callback, | ||
109 | .remove_buf_file = remove_buf_file_default_callback, | ||
88 | }; | 110 | }; |
89 | 111 | ||
90 | /** | 112 | /** |
@@ -176,8 +198,8 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, | |||
176 | return NULL; | 198 | return NULL; |
177 | 199 | ||
178 | /* Create file in fs */ | 200 | /* Create file in fs */ |
179 | dentry = relayfs_create_file(filename, parent, S_IRUSR, | 201 | dentry = chan->cb->create_buf_file(filename, parent, S_IRUSR, |
180 | &relayfs_file_operations, buf); | 202 | buf); |
181 | if (!dentry) { | 203 | if (!dentry) { |
182 | relay_destroy_buf(buf); | 204 | relay_destroy_buf(buf); |
183 | return NULL; | 205 | return NULL; |
@@ -220,6 +242,10 @@ static inline void setup_callbacks(struct rchan *chan, | |||
220 | cb->buf_mapped = buf_mapped_default_callback; | 242 | cb->buf_mapped = buf_mapped_default_callback; |
221 | if (!cb->buf_unmapped) | 243 | if (!cb->buf_unmapped) |
222 | cb->buf_unmapped = buf_unmapped_default_callback; | 244 | cb->buf_unmapped = buf_unmapped_default_callback; |
245 | if (!cb->create_buf_file) | ||
246 | cb->create_buf_file = create_buf_file_default_callback; | ||
247 | if (!cb->remove_buf_file) | ||
248 | cb->remove_buf_file = remove_buf_file_default_callback; | ||
223 | chan->cb = cb; | 249 | chan->cb = cb; |
224 | } | 250 | } |
225 | 251 | ||
diff --git a/include/linux/relayfs_fs.h b/include/linux/relayfs_fs.h index 8200ecbe6e0f..8c2177105857 100644 --- a/include/linux/relayfs_fs.h +++ b/include/linux/relayfs_fs.h | |||
@@ -110,6 +110,40 @@ struct rchan_callbacks | |||
110 | */ | 110 | */ |
111 | void (*buf_unmapped)(struct rchan_buf *buf, | 111 | void (*buf_unmapped)(struct rchan_buf *buf, |
112 | struct file *filp); | 112 | struct file *filp); |
113 | /* | ||
114 | * create_buf_file - create file to represent a relayfs channel buffer | ||
115 | * @filename: the name of the file to create | ||
116 | * @parent: the parent of the file to create | ||
117 | * @mode: the mode of the file to create | ||
118 | * @buf: the channel buffer | ||
119 | * | ||
120 | * Called during relay_open(), once for each per-cpu buffer, | ||
121 | * to allow the client to create a file to be used to | ||
122 | * represent the corresponding channel buffer. If the file is | ||
123 | * created outside of relayfs, the parent must also exist in | ||
124 | * that filesystem. | ||
125 | * | ||
126 | * The callback should return the dentry of the file created | ||
127 | * to represent the relay buffer. | ||
128 | * | ||
129 | * See Documentation/filesystems/relayfs.txt for more info. | ||
130 | */ | ||
131 | struct dentry *(*create_buf_file)(const char *filename, | ||
132 | struct dentry *parent, | ||
133 | int mode, | ||
134 | struct rchan_buf *buf); | ||
135 | |||
136 | /* | ||
137 | * remove_buf_file - remove file representing a relayfs channel buffer | ||
138 | * @dentry: the dentry of the file to remove | ||
139 | * | ||
140 | * Called during relay_close(), once for each per-cpu buffer, | ||
141 | * to allow the client to remove a file used to represent a | ||
142 | * channel buffer. | ||
143 | * | ||
144 | * The callback should return 0 if successful, negative if not. | ||
145 | */ | ||
146 | int (*remove_buf_file)(struct dentry *dentry); | ||
113 | }; | 147 | }; |
114 | 148 | ||
115 | /* | 149 | /* |