relay: add relay_kernel_read()
Subsystems (2)
RFC PATCH 5/6 relay: add relay_kernel_read()
This patch adds a relay_kernel_read() function to relay, which allows kernel clients to easily extract only the data (i.e. and skip over padding) from a channel buffer.
Signed-off-by Tom Zanussi <[email protected]>
Signed-off-by David Wilder <[email protected]>
--- Documentation/filesystems/relay.txt | 14 ++++++ include/linux/relay.h | 5 ++ kernel/relay.c | 79 ++++++++++++++++++++++++++++++++---- 3 files changed, 90 insertions(+), 8 deletions(-)
Documentation/filesystems/relay.txt +14 -0
@@ -185,6 +185,7 @@ TBD(curr. line MT:/API/) relay_buf_full(buf) subbuf_start_reserve(buf, length) + relay_kernel_read(rbuf, buffer, count, ppos) Creating a channel
@@ -446,6 +447,19 @@ closed. Misc ---- +relay_kernel_read() provides the same functionality as the userspace +read(2) implementation, but instead of copying the relay buffer data +to a buffer in user space, the data is copied to the supplied kernel +buffer target. As with user space read(), the sub-buffer padding is +automatically removed from the output and is not seen by the reader. +In the case of relay_kernel_read(), there is no file object associated +with the reader, so it needs to supply a pointer to a ppos variable, +which will be used to maintain the current read position instead. +This is useful for applications that may want to provide an +alternative interface to the relay buffer data or who want access to +the buffer data without needing to know anything about buffer +internals. + Some applications may want to keep a channel around and re-use it rather than open and close a new channel for each use. relay_reset() can be used for this purpose - it resets a channel to its initial
include/linux/relay.h +5 -0
@@ -181,6 +181,11 @@ extern int relay_buf_full(struct rchan_buf *buf);extern size_t relay_switch_subbuf (struct rchan_buf *buf,size_t length); +extern ssize_t relay_kernel_read (struct rchan_buf *rbuf, +char *buffer, +size_t count, +loff_t *ppos); +/** * relay_write - write data into the channel * @chan: relay channel
kernel/relay.c +71 -8
132 lines not on this page · raw message