Skip to content

Commit

Permalink
Merge branch 'open_helper' of https://github.com/CPestka/liburing
Browse files Browse the repository at this point in the history
* 'open_helper' of https://github.com/CPestka/liburing:
  man/prep_open: Add man entry for io_uring_prep_open(_direct)
  liburing/sqe_helper: Add helper to prep sqe for an open
  • Loading branch information
axboe committed Sep 29, 2024
2 parents 4a581ec + 48ca808 commit 3ca941c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions man/io_uring_prep_open.3
1 change: 1 addition & 0 deletions man/io_uring_prep_open_direct.3
16 changes: 16 additions & 0 deletions man/io_uring_prep_openat.3
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ io_uring_prep_openat \- prepare an openat request
.B #include <fcntl.h>
.B #include <liburing.h>
.PP
.BI "void io_uring_prep_open(struct io_uring_sqe *" sqe ","
.BI " const char *" path ","
.BI " int " flags ","
.BI " mode_t " mode ");"
.PP
.BI "void io_uring_prep_open_direct(struct io_uring_sqe *" sqe ","
.BI " const char *" path ","
.BI " int " flags ","
.BI " mode_t " mode ","
.BI " unsigned " file_index ");"
.PP
.BI "void io_uring_prep_openat(struct io_uring_sqe *" sqe ","
.BI " int " dfd ","
.BI " const char *" path ","
Expand Down Expand Up @@ -39,6 +50,9 @@ and using the open flags in
.I flags
and using the file mode bits specified in
.IR mode .
Similarly
.BR io_uring_prep_open (3)
prepares an open request.

For a direct descriptor open request, the offset is specified by the
.I file_index
Expand Down Expand Up @@ -81,6 +95,8 @@ is returned instead.

These functions prepare an async
.BR openat (2)
or
.BR open (2)
request. See that man page for details.

.SH RETURN VALUE
Expand Down
14 changes: 14 additions & 0 deletions src/include/liburing.h
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,20 @@ IOURINGINLINE void io_uring_prep_openat_direct(struct io_uring_sqe *sqe,
__io_uring_set_target_fixed_file(sqe, file_index);
}

IOURINGINLINE void io_uring_prep_open(struct io_uring_sqe *sqe,
const char *path, int flags, mode_t mode)
{
io_uring_prep_openat(sqe, AT_FDCWD, path, flags, mode);
}

/* open directly into the fixed file table */
IOURINGINLINE void io_uring_prep_open_direct(struct io_uring_sqe *sqe,
const char *path, int flags, mode_t mode,
unsigned file_index)
{
io_uring_prep_openat_direct(sqe, AT_FDCWD, path, flags, mode, file_index);
}

IOURINGINLINE void io_uring_prep_close(struct io_uring_sqe *sqe, int fd)
{
io_uring_prep_rw(IORING_OP_CLOSE, sqe, fd, NULL, 0, 0);
Expand Down
2 changes: 2 additions & 0 deletions src/liburing-ffi.map
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,6 @@ LIBURING_2.8 {
io_uring_submit_and_wait_min_timeout;
io_uring_wait_cqes_min_timeout;
io_uring_clone_buffers;
io_uring_prep_open;
io_uring_prep_open_direct;
} LIBURING_2.7;

0 comments on commit 3ca941c

Please sign in to comment.