From a591adc6d5baa0de1f6240922e2b3e0f7e97ba4d Mon Sep 17 00:00:00 2001 From: Zhe Weng Date: Thu, 1 Feb 2024 11:14:27 +0800 Subject: [PATCH] drivers/pipes: Add offset support for PIPEIOC_PEEK Signed-off-by: Zhe Weng --- drivers/pipes/pipe_common.c | 4 +++- include/nuttx/fs/ioctl.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pipes/pipe_common.c b/drivers/pipes/pipe_common.c index bf715c9d92..0254c3a142 100644 --- a/drivers/pipes/pipe_common.c +++ b/drivers/pipes/pipe_common.c @@ -846,7 +846,9 @@ int pipecommon_ioctl(FAR struct file *filep, int cmd, unsigned long arg) DEBUGASSERT(peek && peek->buf); - ret = circbuf_peek(&dev->d_buffer, peek->buf, peek->size); + ret = circbuf_peekat(&dev->d_buffer, + dev->d_buffer.tail + peek->offset, + peek->buf, peek->size); } break; diff --git a/include/nuttx/fs/ioctl.h b/include/nuttx/fs/ioctl.h index 7e5a6951ab..ffd16f1082 100644 --- a/include/nuttx/fs/ioctl.h +++ b/include/nuttx/fs/ioctl.h @@ -717,6 +717,7 @@ struct pipe_peek_s { FAR void *buf; + size_t offset; size_t size; };