From: Tom Zanussi <zanussi@us.ibm.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, karim@opersys.com
Subject: [PATCH 7/12] relayfs: add support for relay files in other filesystems
Date: Fri, 11 Nov 2005 10:51:01 -0600 [thread overview]
Message-ID: <17268.52213.571541.984505@tut.ibm.com> (raw)
In-Reply-To: <17268.51814.215178.281986@tut.ibm.com>
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>
---
fs/relayfs/buffers.c | 2 +-
fs/relayfs/relay.c | 30 ++++++++++++++++++++++++++++--
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
--- a/fs/relayfs/buffers.c
+++ b/fs/relayfs/buffers.c
@@ -185,6 +185,6 @@ void relay_destroy_buf(struct rchan_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);
}
diff --git a/fs/relayfs/relay.c b/fs/relayfs/relay.c
--- a/fs/relayfs/relay.c
+++ b/fs/relayfs/relay.c
@@ -80,11 +80,33 @@ static void buf_unmapped_default_callbac
{
}
+/*
+ * 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(
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(struc
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;
}
diff --git a/include/linux/relayfs_fs.h b/include/linux/relayfs_fs.h
--- a/include/linux/relayfs_fs.h
+++ b/include/linux/relayfs_fs.h
@@ -109,6 +109,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);
};
/*
next prev parent reply other threads:[~2005-11-11 16:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-11 16:44 [PATCH 0/12] relayfs: API additions and fixes Tom Zanussi
2005-11-11 16:46 ` [PATCH 1/12] relayfs: decouple buffer creation from inode creation Tom Zanussi
2005-11-11 16:47 ` [PATCH 2/12] relayfs: export relayfs_create_file() with fileops param Tom Zanussi
2005-11-11 19:37 ` Christoph Hellwig
2005-11-11 19:49 ` Tom Zanussi
2005-12-06 17:29 ` Christoph Hellwig
2005-12-06 19:51 ` Tom Zanussi
2005-11-12 2:10 ` Baruch Even
2005-11-11 16:47 ` [PATCH 3/12] relayfs: add relayfs_remove_file() Tom Zanussi
2005-11-11 16:48 ` [PATCH 4/12] relayfs: use generic_ip for private data Tom Zanussi
2005-11-11 16:49 ` [PATCH 5/12] relayfs: remove unused alloc/destroy_inode() Tom Zanussi
2005-11-11 16:50 ` [PATCH 6/12] relayfs: add Documention for non-relay files Tom Zanussi
2005-11-11 16:51 ` Tom Zanussi [this message]
2005-11-11 16:51 ` [PATCH 8/12] relayfs: add Documentation on relay files in other filesystems Tom Zanussi
2005-11-11 16:52 ` [PATCH 9/12] relayfs: add support for global relay buffers Tom Zanussi
2005-11-11 16:52 ` [PATCH 10/12] relayfs: add Documentation on " Tom Zanussi
2005-11-11 16:53 ` [PATCH 11/12] relayfs: cleanup, change relayfs_file_* to relay_file_* Tom Zanussi
2005-11-11 16:54 ` [PATCH 12/12] relayfs: Documentation cleanup, remove obsolete info Tom Zanussi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=17268.52213.571541.984505@tut.ibm.com \
--to=zanussi@us.ibm.com \
--cc=akpm@osdl.org \
--cc=karim@opersys.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®