]> err.no Git - linux-2.6/commitdiff
[PATCH] relayfs: add support for relay files in other filesystems
authorTom Zanussi <zanussi@us.ibm.com>
Sun, 8 Jan 2006 09:02:28 +0000 (01:02 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 9 Jan 2006 04:13:50 +0000 (20:13 -0800)
This patch adds a couple of callback functions that allow a client to hook
into relay_open()/close() and supply the files that will be used to represent
the channel buffers; the default implementation if no callbacks are defined is
to create the files in relayfs.  This is to support the creation and use of
relay files in other filesystems such as debugfs, as implied by the fact that
relayfs_file_operations are exported.

Signed-off-by: Tom Zanussi <zanussi@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/relayfs/buffers.c
fs/relayfs/relay.c
include/linux/relayfs_fs.h

index 667b529944c504d3de90ef3f77c20c93d26dee10..10187812771ef54960d8038046e5a6e60952ee42 100644 (file)
@@ -185,6 +185,6 @@ void relay_destroy_buf(struct rchan_buf *buf)
 void relay_remove_buf(struct kref *kref)
 {
        struct rchan_buf *buf = container_of(kref, struct rchan_buf, kref);
-       relayfs_remove(buf->dentry);
+       buf->chan->cb->remove_buf_file(buf->dentry);
        relay_destroy_buf(buf);
 }
index a9cd5585c45ca33133dda7a31b64e5681d4175eb..b9bb569032729ec541124855a169d96589214eff 100644 (file)
@@ -80,11 +80,33 @@ static void buf_unmapped_default_callback(struct rchan_buf *buf,
 {
 }
 
+/*
+ * create_buf_file_create() default callback.  Creates file to represent buf.
+ */
+static struct dentry *create_buf_file_default_callback(const char *filename,
+                                                      struct dentry *parent,
+                                                      int mode,
+                                                      struct rchan_buf *buf)
+{
+       return relayfs_create_file(filename, parent, mode,
+                                  &relayfs_file_operations, buf);
+}
+
+/*
+ * remove_buf_file() default callback.  Removes file representing relay buffer.
+ */
+static int remove_buf_file_default_callback(struct dentry *dentry)
+{
+       return relayfs_remove(dentry);
+}
+
 /* relay channel default callbacks */
 static struct rchan_callbacks default_channel_callbacks = {
        .subbuf_start = subbuf_start_default_callback,
        .buf_mapped = buf_mapped_default_callback,
        .buf_unmapped = buf_unmapped_default_callback,
+       .create_buf_file = create_buf_file_default_callback,
+       .remove_buf_file = remove_buf_file_default_callback,
 };
 
 /**
@@ -176,8 +198,8 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan,
                return NULL;
 
        /* Create file in fs */
-       dentry = relayfs_create_file(filename, parent, S_IRUSR,
-                                    &relayfs_file_operations, buf);
+       dentry = chan->cb->create_buf_file(filename, parent, S_IRUSR,
+                                          buf);
        if (!dentry) {
                relay_destroy_buf(buf);
                return NULL;
@@ -220,6 +242,10 @@ static inline void setup_callbacks(struct rchan *chan,
                cb->buf_mapped = buf_mapped_default_callback;
        if (!cb->buf_unmapped)
                cb->buf_unmapped = buf_unmapped_default_callback;
+       if (!cb->create_buf_file)
+               cb->create_buf_file = create_buf_file_default_callback;
+       if (!cb->remove_buf_file)
+               cb->remove_buf_file = remove_buf_file_default_callback;
        chan->cb = cb;
 }
 
index 8200ecbe6e0f51f039a8b73390c0cb55a2b3a1ec..8c21771058571ffa29053250411f168812670a51 100644 (file)
@@ -110,6 +110,40 @@ struct rchan_callbacks
         */
         void (*buf_unmapped)(struct rchan_buf *buf,
                             struct file *filp);
+       /*
+        * create_buf_file - create file to represent a relayfs channel buffer
+        * @filename: the name of the file to create
+        * @parent: the parent of the file to create
+        * @mode: the mode of the file to create
+        * @buf: the channel buffer
+        *
+        * Called during relay_open(), once for each per-cpu buffer,
+        * to allow the client to create a file to be used to
+        * represent the corresponding channel buffer.  If the file is
+        * created outside of relayfs, the parent must also exist in
+        * that filesystem.
+        *
+        * The callback should return the dentry of the file created
+        * to represent the relay buffer.
+        *
+        * See Documentation/filesystems/relayfs.txt for more info.
+        */
+       struct dentry *(*create_buf_file)(const char *filename,
+                                         struct dentry *parent,
+                                         int mode,
+                                         struct rchan_buf *buf);
+
+       /*
+        * remove_buf_file - remove file representing a relayfs channel buffer
+        * @dentry: the dentry of the file to remove
+        *
+        * Called during relay_close(), once for each per-cpu buffer,
+        * to allow the client to remove a file used to represent a
+        * channel buffer.
+        *
+        * The callback should return 0 if successful, negative if not.
+        */
+       int (*remove_buf_file)(struct dentry *dentry);
 };
 
 /*