1io_uring_prep_openat(3)         liburing Manual        io_uring_prep_openat(3)
2
3
4

NAME

6       io_uring_prep_openat - prepare an openat request
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <sys/stat.h>
11       #include <fcntl.h>
12       #include <liburing.h>
13
14       void io_uring_prep_openat(struct io_uring_sqe *sqe,
15                                 int dfd,
16                                 const char *path,
17                                 int flags,
18                                 mode_t mode);
19
20       void io_uring_prep_openat_direct(struct io_uring_sqe *sqe,
21                                        int dfd,
22                                        const char *path,
23                                        int flags,
24                                        mode_t mode,
25                                        unsigned file_index);
26

DESCRIPTION

28       The  io_uring_prep_openat(3)  function  prepares an openat request. The
29       submission queue entry sqe is setup to use the directory file  descrip‐
30       tor  dfd  to  start opening a file described by path and using the open
31       flags in flags and using the file mode bits specified in mode.
32
33       For a direct descriptor open request, the offset is  specified  by  the
34       file_index  argument.  Direct descriptors are io_uring private file de‐
35       scriptors. They avoid some  of  the  overhead  associated  with  thread
36       shared  file tables, and can be used in any io_uring request that takes
37       a file descriptor. To do so, IOSQE_FIXED_FILE must be set  in  the  SQE
38       flags  member,  and  the  SQE fd field should use the direct descriptor
39       value rather than the regular file descriptor. Direct  descriptors  are
40       managed like registered files.
41
42       If  the  direct variant is used, the application must first have regis‐
43       tered a file table using io_uring_register_files(3) of the  appropriate
44       size.  Once  registered,  a  direct accept request may use any entry in
45       that table, as long as it is within the size of the  registered  table.
46       If  a  specified  entry already contains a file, the file will first be
47       removed from the table and closed. It's consistent with the behavior of
48       updating an existing file with io_uring_register_files_update(3).  Note
49       that old kernels don't check the SQE file_index field, which is  not  a
50       problem  for  liburing helpers, but users of the raw io_uring interface
51       need to zero SQEs to avoid unexpected behavior.
52
53       If IORING_FILE_INDEX_ALLOC is used as the file_index for a direct open,
54       then  io_uring  will  allocate a free direct descriptor in the existing
55       table. The allocated descriptor is returned in the CQE res  field  just
56       like  it would be for a non-direct open request. If no more entries are
57       available in the direct descriptor table, -ENFILE is returned instead.
58
59       These functions prepare an async openat(2) request. See that  man  page
60       for details.
61
62

RETURN VALUE

64       None
65

ERRORS

67       The CQE res field will contain the result of the operation. See the re‐
68       lated man page for details on possible values. Note that where synchro‐
69       nous system calls will return -1 on failure and set errno to the actual
70       error value, io_uring never uses errno.  Instead it returns the negated
71       errno directly in the CQE res field.
72

NOTES

74       As with any request that passes in data in a struct, that data must re‐
75       main valid until the request has been successfully submitted.  It  need
76       not  remain  valid until completion. Once a request has been submitted,
77       the in-kernel state is stable. Very early kernels (5.4 and earlier) re‐
78       quired  state  to be stable until the completion occurred. Applications
79       can test for this behavior by inspecting the  IORING_FEAT_SUBMIT_STABLE
80       flag passed back from io_uring_queue_init_params(3).
81

SEE ALSO

83       io_uring_get_sqe(3),   io_uring_submit(3),  io_uring_register(2),  ope‐
84       nat(2)
85
86
87
88liburing-2.2                    March 13, 2022         io_uring_prep_openat(3)
Impressum