liburing: add getdents64 support
cover liburing: add getdents64 support
This adds the getdents support to liburing.
Patch 1: liburing: update io_uring.h header file
This updates the io_uring header file with the new enum for the getdents support.
Patch 2: liburing: add prepare function for getdents
Adds the io_uring_prep_getdents() function.
Patch 3: liburing: add test program for getdents
Adds a new test program to test the getdents support. It queries the current directory and all its subdirectories.
Patch 4: liburing: add new man page
Adds a new man page for the io_uring_prep_getdents call.
Stefan Roesch (4):
liburing: update io_uring.h header file
liburing: add prepare function for getdents64
liburing: Add test program for getdents call
liburing: Add man page for io_uring_prep_getdents call
man/io_uring_prep_getdents.3 | 64 ++++++++ src/include/liburing.h | 6 + src/include/liburing/io_uring.h | 1 + test/Makefile | 1 + test/getdents.c | 258 ++++++++++++++++++++++++++++++++ 5 files changed, 330 insertions(+) create mode 100644 man/io_uring_prep_getdents.3 create mode 100644 test/getdents.c
Signature · 1 line
2.30.2
PATCH 1/4 liburing: update io_uring.h header file
Update io_uring.h header file with new op code for getdents64.
--- src/include/liburing/io_uring.h | 1 + 1 file changed, 1 insertion(+)
src/include/liburing/io_uring.h +1 -0
@@ -144,6 +144,7 @@ enum {IORING_OP_MKDIRAT ,IORING_OP_SYMLINKAT ,IORING_OP_LINKAT , +IORING_OP_GETDENTS ,/* this goes last, obviously */ IORING_OP_LAST,
Signature · 1 line
2.30.2
PATCH 2/4 liburing: add prepare function for getdents64
In reply to Stefan RoeschAdds the io_uring_prep_getdents() function to setup a getdents64 call.
--- src/include/liburing.h | 6 ++++++ 1 file changed, 6 insertions(+)
src/include/liburing.h +6 -0
@@ -672,6 +672,12 @@ static inline void io_uring_prep_linkat(struct io_uring_sqe *sqe, int olddfd, sqe->hardlink_flags = (__u32 ) flags; } +static inline void io_uring_prep_getdents (struct io_uring_sqe *sqe,int fd, +void *buf,unsigned int count,uint64_t offset) +{ +io_uring_prep_rw (IORING_OP_GETDENTS , sqe, fd, buf, count, offset); +} +/* * Returns number of unconsumed (if SQPOLL) or unsubmitted entries exist in * the SQ ring
Signature · 1 line
2.30.2
PATCH 3/4 liburing: Add test program for getdents call
In reply to Stefan RoeschAdd test program for getdents64 call.
--- test/Makefile | 1 + test/getdents.c | 258 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 test/getdents.c
test/Makefile +1 -0
@@ -77,6 +77,7 @@ test_srcs := \ file-verify.c \ fixed-link.c \ fsync.c \ + getdents.c \ hardlink.c \ io-cancel.c \ iopoll.c \
test/getdents.c new file +258 -0
258 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH 4/4 liburing: Add man page for io_uring_prep_getdents call
In reply to Stefan RoeschAdds the man page for the io_uring_prep_getdents call.
--- man/io_uring_prep_getdents.3 | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 man/io_uring_prep_getdents.3
man/io_uring_prep_getdents.3 new file +64 -0
@@ -0,0 +1,64 @@ +.\" Copyright (C) 2021 Stefan Roesch <[email protected]> +.\" +.\" SPDX-License-Identifier: LGPL-2.0-or-later +.\" +.TH io_uring_prep_getdents 3 "November 19, 2021" "liburing-2.1" "liburing Manual" +.SH NAME +io_uring_prep_getdents - prepare getdents64 call + +.SH SYNOPSIS +.nf +.BR "#include <liburing.h>" +.PP +.BI "void io_uring_prep_getdents(struct io_uring_sqe *sqe," +.BI " int fd," +.BI " void *buf," +.BI " unsigned int count," +.BI " uint64_t offset)" + +.SH DESCRIPTION +.PP +The io_uring_prep_getdents() prepares a getdents64 request. The submission queue +entry +.I sqe +is setup to use the file descriptor +.I fd +to start writing up to +.I count +bytes into the buffer +.I buf +starting at +.I offset. + +After the getdents call has been prepared it can be submitted with one of the submit +functions. + +.SH RETURN VALUE +None + +.SH EXAMPLE +A getdents io_uring call can be prepared like in the following code snippet. +The io_uring_sqe_set_data(3) call is not necessary, but it helps to correlate the +request with the results. + +.BI "void schedule_readdir(struct io_uring_sqe *sqe, struct dir *dir)" +.fi +.BI "{" +.fi +.BI " io_uring_prep_getdents(sqe," +.fi +.BI " dir->fd," +.fi +.BI " dir->buf," +.fi +.BI " sizeof(dir->buf)," +.fi +.BI " dir->off);" +.fi +.BI " io_uring_sqe_set_data(sqe, dir); +.fi +.BI "}" + + +.SH SEE ALSO +.BR io_uring_get_sqe (3), io_uring_sqe_set_data (3), io_uring_submit (3), io_uring_sqe_get_data (3)
Signature · 1 line
2.30.2