git: a1424b75453f - main - uio: provide uioadvance()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 30 Apr 2025 21:23:55 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=a1424b75453fe0bcf24a9794378287b675ee4517
commit a1424b75453fe0bcf24a9794378287b675ee4517
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-04-30 21:23:25 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-04-30 21:23:25 +0000
uio: provide uioadvance()
The function advances data pointers forward in given uio by offset. It
is planned to be used for interaction between aio(4) and unix(4).
Differential Revision: https://reviews.freebsd.org/D48920
---
sys/kern/subr_uio.c | 31 +++++++++++++++++++++++++++++++
sys/sys/uio.h | 1 +
2 files changed, 32 insertions(+)
diff --git a/sys/kern/subr_uio.c b/sys/kern/subr_uio.c
index ff63ac3e2dc0..6ac932fb6690 100644
--- a/sys/kern/subr_uio.c
+++ b/sys/kern/subr_uio.c
@@ -287,6 +287,37 @@ out:
return (error);
}
+/*
+ * Advance the pointer in the uio by offset.
+ */
+void
+uioadvance(struct uio *uio, size_t offset)
+{
+
+ while (offset > 0) {
+ struct iovec *iov;
+ size_t cnt;
+
+ MPASS(uio->uio_resid >= 0);
+ MPASS((size_t)uio->uio_resid >= offset);
+ MPASS(uio->uio_iovcnt > 0);
+
+ iov = uio->uio_iov;
+ if ((cnt = iov->iov_len) == 0) {
+ uio->uio_iov++;
+ uio->uio_iovcnt--;
+ continue;
+ }
+ if (cnt > offset)
+ cnt = offset;
+ iov->iov_base = (char *)iov->iov_base + cnt;
+ iov->iov_len -= cnt;
+ uio->uio_resid -= cnt;
+ uio->uio_offset += cnt;
+ offset -= cnt;
+ }
+}
+
/*
* Wrapper for uiomove() that validates the arguments against a known-good
* kernel buffer. Currently, uiomove accepts a signed (n) argument, which
diff --git a/sys/sys/uio.h b/sys/sys/uio.h
index 1c9d2d39cf57..ec4e92d852a6 100644
--- a/sys/sys/uio.h
+++ b/sys/sys/uio.h
@@ -90,6 +90,7 @@ int physcopyin_vlist(struct bus_dma_segment *src, off_t offset,
vm_paddr_t dst, size_t len);
int physcopyout_vlist(vm_paddr_t src, struct bus_dma_segment *dst,
off_t offset, size_t len);
+void uioadvance(struct uio *, size_t);
int uiomove(void *cp, int n, struct uio *uio);
int uiomove_frombuf(void *buf, int buflen, struct uio *uio);
int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n,