IORING_OP_GETDENTS: add opcode, prep function, test, man page section
PATCH 1/1 IORING_OP_GETDENTS: add opcode, prep function, test, man page section
Signed-off-by Lennert Buytenhek <[email protected]>
--- man/io_uring_enter.2 | 26 +++++ src/include/liburing.h | 7 ++ src/include/liburing/io_uring.h | 1 + test/Makefile | 1 + test/getdents.c | 180 ++++++++++++++++++++++++++++++++ 5 files changed, 215 insertions(+) create mode 100644 test/getdents.c
man/io_uring_enter.2 +26 -0
@@ -759,6 +759,32 @@ being passed in to .BR unlinkat(2). Available since 5.11. +.TP +.B IORING_OP_GETDENTS +Issue the equivalent of an +.BR lseek(2) +system call plus a +.BR getdents64(2) +system call. +.I fd +should be set to the fd of the directory being operated on, +.I off +should be set to the offset in the directory to start reading from, +.I addr +should be set to the +.I dirp, +and +.I len +should be set to the +.I count. + +.B IORING_OP_GETDENTS +may or may not change the specified directory's file offset, and the +file offset should not be relied upon having any particular value during +or after an +.B IORING_OP_GETDENTS +operation. + .PP The .I flags
src/include/liburing.h +7 -0
@@ -535,6 +535,13 @@ static inline void io_uring_prep_sync_file_range(struct io_uring_sqe *sqe, sqe->sync_range_flags = flags; } +static inline void io_uring_prep_getdents (struct io_uring_sqe *sqe,int fd, +void *buf,unsigned int count, +uint64_t off) +{ +io_uring_prep_rw (IORING_OP_GETDENTS , sqe, fd, buf, count, off); +} +/* * Returns number of unconsumed (if SQPOLL) or unsubmitted entries exist in * the SQ ring
src/include/liburing/io_uring.h +1 -0
@@ -142,6 +142,7 @@ enum {IORING_OP_RENAMEAT ,IORING_OP_UNLINKAT ,IORING_OP_MKDIRAT , +IORING_OP_GETDENTS ,/* this goes last, obviously */ IORING_OP_LAST,
test/Makefile +1 -0
@@ -55,6 +55,7 @@ test_targets += \ files-exit-hang-timeout \ fixed-link \ fsync \ + getdents \ io-cancel \ io_uring_enter \ io_uring_register \
test/getdents.c new file +180 -0
180 lines not on this page · raw message
Signature · 1 line
2.29.2
Quoted 2 lines · Lennert Buytenhek
Signed-off-by Lennert Buytenhek <[email protected]>---
I'll shortly send a v2 of this that will:
- update the man page to specify that the file offset is updated unconditionally by IORING_OP_GETDENTS;
- update the man pages to indicate that IORING_FEAT_RW_CUR_POS also applies to IORING_OP_GETDENTS;
- update the getdents test to verify that offset == -1 reads from the current directory offset.