mirror of
https://github.com/openharmony/third_party_liburing.git
synced 2026-08-28 05:10:09 -04:00
io_uring: add prep functions for current working directory
This is done for unlink, rename, mkdir, symlink and link. Signed-off-by: Usama Arif <usama.arif@bytedance.com>
This commit is contained in:
@@ -17,6 +17,11 @@ io_uring_prep_linkat \- prepare a linkat request
|
||||
.BI " int " newdirfd ","
|
||||
.BI " const char *" newpath ","
|
||||
.BI " int " flags ");"
|
||||
.PP
|
||||
.BI "void io_uring_prep_link(struct io_uring_sqe *" sqe ","
|
||||
.BI " const char *" oldpath ","
|
||||
.BI " const char *" newpath ","
|
||||
.BI " int " flags ");"
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -34,11 +39,24 @@ and the new path pointed to by
|
||||
.I newpath
|
||||
and using the specified flags in
|
||||
.IR flags .
|
||||
|
||||
This function prepares an async
|
||||
.BR linkat (2)
|
||||
request. See that man page for details.
|
||||
|
||||
The
|
||||
.BR io_uring_prep_link (3)
|
||||
function prepares a link request. The submission queue entry
|
||||
.I sqe
|
||||
is setup to use the old path pointed to by
|
||||
.I oldpath
|
||||
and the new path pointed to by
|
||||
.IR newpath ,
|
||||
both relative to the current working directory and using the specified flags in
|
||||
.IR flags .
|
||||
This function prepares an async
|
||||
.BR link (2)
|
||||
request. See that man page for details.
|
||||
|
||||
.SH RETURN VALUE
|
||||
None
|
||||
.SH ERRORS
|
||||
@@ -69,4 +87,5 @@ flag passed back from
|
||||
.SH SEE ALSO
|
||||
.BR io_uring_get_sqe (3),
|
||||
.BR io_uring_submit (3),
|
||||
.BR linkat (2)
|
||||
.BR linkat (2),
|
||||
.BR link (2)
|
||||
|
||||
@@ -15,24 +15,41 @@ io_uring_prep_mkdirat \- prepare an mkdirat request
|
||||
.BI " int " dirfd ","
|
||||
.BI " const char *" path ","
|
||||
.BI " mode_t " mode ");"
|
||||
.PP
|
||||
.BI "void io_uring_prep_mkdir(struct io_uring_sqe *" sqe ","
|
||||
.BI " const char *" path ","
|
||||
.BI " mode_t " mode ");"
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
The
|
||||
.BR io_uring_prep_mkdirat (3)
|
||||
function prepares an mkdirat request. The submission queue entry
|
||||
function prepares a mkdirat request. The submission queue entry
|
||||
.I sqe
|
||||
is setup to use the directory file descriptor pointed to by
|
||||
.I dirfd
|
||||
to start an mkdirat operation on the path identified by
|
||||
to start a mkdirat operation on the path identified by
|
||||
.I path
|
||||
with the mode given in
|
||||
.IR mode .
|
||||
|
||||
This function prepares an async
|
||||
.BR mkdirat (2)
|
||||
request. See that man page for details.
|
||||
|
||||
The
|
||||
.BR io_uring_prep_mkdir (3)
|
||||
function prepares a mkdir request. The submission queue entry
|
||||
.I sqe
|
||||
is setup to use the current working directory to start a mkdir
|
||||
operation on the path identified by
|
||||
.I path
|
||||
with the mode given in
|
||||
.IR mode .
|
||||
This function prepares an async
|
||||
.BR mkdir (2)
|
||||
request. See that man page for details.
|
||||
|
||||
|
||||
.SH RETURN VALUE
|
||||
None
|
||||
.SH ERRORS
|
||||
@@ -63,4 +80,5 @@ flag passed back from
|
||||
.SH SEE ALSO
|
||||
.BR io_uring_get_sqe (3),
|
||||
.BR io_uring_submit (3),
|
||||
.BR mkdirat (2)
|
||||
.BR mkdirat (2),
|
||||
.BR mkdir (2)
|
||||
|
||||
@@ -17,6 +17,11 @@ io_uring_prep_renameat \- prepare a renameat request
|
||||
.BI " int " newdirfd ","
|
||||
.BI " const char *" newpath ","
|
||||
.BI " int " flags ");"
|
||||
.PP
|
||||
.BI "void io_uring_prep_rename(struct io_uring_sqe *" sqe ","
|
||||
.BI " const char *" oldpath ","
|
||||
.BI " const char *" newpath ","
|
||||
.BI " int " flags ");"
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -34,7 +39,6 @@ and the new path pointed to by
|
||||
.I newpath
|
||||
and using the specified flags in
|
||||
.IR flags .
|
||||
|
||||
This function prepares an async
|
||||
.BR renameat2 (2)
|
||||
request. If
|
||||
@@ -43,6 +47,20 @@ is zero, then this call is similar to the
|
||||
.BR renameat (2)
|
||||
system call. See those man page for details.
|
||||
|
||||
The
|
||||
.BR io_uring_prep_rename (3)
|
||||
function prepares a rename request. The submission queue entry
|
||||
.I sqe
|
||||
is setup to use the old path pointed to by
|
||||
.I oldpath
|
||||
with the new path pointed to by
|
||||
.IR newpath ,
|
||||
both relative to the current working directory and using the specified flags in
|
||||
.IR flags .
|
||||
This function prepares an async
|
||||
.BR rename (2)
|
||||
request See that man page for details.
|
||||
|
||||
.SH RETURN VALUE
|
||||
None
|
||||
.SH ERRORS
|
||||
@@ -74,4 +92,5 @@ flag passed back from
|
||||
.BR io_uring_get_sqe (3),
|
||||
.BR io_uring_submit (3),
|
||||
.BR renameat (2),
|
||||
.BR renameat2 (2)
|
||||
.BR renameat2 (2),
|
||||
.BR rename (2)
|
||||
|
||||
@@ -15,6 +15,10 @@ io_uring_prep_symlinkat \- prepare a symlinkat request
|
||||
.BI " const char *" target ","
|
||||
.BI " int " newdirfd ","
|
||||
.BI " const char *" linkpath ");"
|
||||
.PP
|
||||
.BI "void io_uring_prep_symlink(struct io_uring_sqe *" sqe ","
|
||||
.BI " const char *" target ","
|
||||
.BI " const char *" linkpath ");"
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -28,11 +32,22 @@ to the new destination indicated by
|
||||
.I newdirfd
|
||||
and
|
||||
.IR linkpath .
|
||||
|
||||
This function prepares an async
|
||||
.BR symlinkat (2)
|
||||
request. See that man page for details.
|
||||
|
||||
The
|
||||
.BR io_uring_prep_symlink (3)
|
||||
function prepares a symlink request. The submission queue entry
|
||||
.I sqe
|
||||
is setup to symlink the target path pointed to by
|
||||
.I target
|
||||
to the new destination indicated by
|
||||
.I linkpath
|
||||
relative to the the current working directory. This function prepares an async
|
||||
.BR symlink (2)
|
||||
request. See that man page for details.
|
||||
|
||||
.SH RETURN VALUE
|
||||
None
|
||||
.SH ERRORS
|
||||
@@ -63,4 +78,5 @@ flag passed back from
|
||||
.SH SEE ALSO
|
||||
.BR io_uring_get_sqe (3),
|
||||
.BR io_uring_submit (3),
|
||||
.BR symlinkat (2)
|
||||
.BR symlinkat (2),
|
||||
.BR symlink (2)
|
||||
|
||||
@@ -15,6 +15,10 @@ io_uring_prep_unlinkat \- prepare an unlinkat request
|
||||
.BI " int " dirfd ","
|
||||
.BI " const char *" path ","
|
||||
.BI " int " flags ");"
|
||||
.PP
|
||||
.BI "void io_uring_prep_unlink(struct io_uring_sqe *" sqe ","
|
||||
.BI " const char *" path ","
|
||||
.BI " int " flags ");"
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -28,11 +32,23 @@ to start an unlinkat operation on the path identified by
|
||||
.I path
|
||||
and using the flags given in
|
||||
.IR flags .
|
||||
|
||||
This function prepares an async
|
||||
.BR unlinkat (2)
|
||||
request. See that man page for details.
|
||||
|
||||
The
|
||||
.BR io_uring_prep_unlink (3)
|
||||
function prepares an unlink request. The submission queue entry
|
||||
.I sqe
|
||||
is setup to start an unlinkat operation on the path identified by
|
||||
.I path
|
||||
relative to the current working directory and using the flags given in
|
||||
.IR flags .
|
||||
This function prepares an async
|
||||
.BR unlink (2)
|
||||
request. See that man page for details.
|
||||
|
||||
|
||||
.SH RETURN VALUE
|
||||
None
|
||||
.SH ERRORS
|
||||
@@ -63,4 +79,5 @@ flag passed back from
|
||||
.SH SEE ALSO
|
||||
.BR io_uring_get_sqe (3),
|
||||
.BR io_uring_submit (3),
|
||||
.BR unlinkat (2)
|
||||
.BR unlinkat (2),
|
||||
.BR unlink (2)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
#include <sched.h>
|
||||
#include <linux/swab.h>
|
||||
#include "liburing/compat.h"
|
||||
@@ -729,6 +730,12 @@ static inline void io_uring_prep_unlinkat(struct io_uring_sqe *sqe, int dfd,
|
||||
sqe->unlink_flags = (__u32) flags;
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_unlink(struct io_uring_sqe *sqe,
|
||||
const char *path, int flags)
|
||||
{
|
||||
io_uring_prep_unlinkat(sqe, AT_FDCWD, path, flags);
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_renameat(struct io_uring_sqe *sqe, int olddfd,
|
||||
const char *oldpath, int newdfd,
|
||||
const char *newpath, int flags)
|
||||
@@ -739,6 +746,12 @@ static inline void io_uring_prep_renameat(struct io_uring_sqe *sqe, int olddfd,
|
||||
sqe->rename_flags = (__u32) flags;
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_rename(struct io_uring_sqe *sqe,
|
||||
const char *oldpath, const char *newpath)
|
||||
{
|
||||
io_uring_prep_renameat(sqe, AT_FDCWD, oldpath, AT_FDCWD, newpath, 0);
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_sync_file_range(struct io_uring_sqe *sqe,
|
||||
int fd, unsigned len,
|
||||
__u64 offset, int flags)
|
||||
@@ -753,6 +766,12 @@ static inline void io_uring_prep_mkdirat(struct io_uring_sqe *sqe, int dfd,
|
||||
io_uring_prep_rw(IORING_OP_MKDIRAT, sqe, dfd, path, mode, 0);
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_mkdir(struct io_uring_sqe *sqe,
|
||||
const char *path, mode_t mode)
|
||||
{
|
||||
io_uring_prep_mkdirat(sqe, AT_FDCWD, path, mode);
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_symlinkat(struct io_uring_sqe *sqe,
|
||||
const char *target, int newdirfd,
|
||||
const char *linkpath)
|
||||
@@ -761,6 +780,12 @@ static inline void io_uring_prep_symlinkat(struct io_uring_sqe *sqe,
|
||||
(uint64_t) (uintptr_t) linkpath);
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_symlink(struct io_uring_sqe *sqe,
|
||||
const char *target, const char *linkpath)
|
||||
{
|
||||
io_uring_prep_symlinkat(sqe, target, AT_FDCWD, linkpath);
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_linkat(struct io_uring_sqe *sqe, int olddfd,
|
||||
const char *oldpath, int newdfd,
|
||||
const char *newpath, int flags)
|
||||
@@ -770,6 +795,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_link(struct io_uring_sqe *sqe,
|
||||
const char *oldpath, const char *newpath, int flags)
|
||||
{
|
||||
io_uring_prep_linkat(sqe, AT_FDCWD, oldpath, AT_FDCWD, newpath, flags);
|
||||
}
|
||||
|
||||
static inline void io_uring_prep_msg_ring(struct io_uring_sqe *sqe, int fd,
|
||||
unsigned int len, __u64 data,
|
||||
unsigned int flags)
|
||||
|
||||
+2
-5
@@ -26,11 +26,8 @@ static int test_rename(struct io_uring *ring, const char *old, const char *new)
|
||||
}
|
||||
|
||||
memset(sqe, 0, sizeof(*sqe));
|
||||
sqe->opcode = IORING_OP_RENAMEAT;
|
||||
sqe->fd = AT_FDCWD;
|
||||
sqe->addr2 = (unsigned long) new;
|
||||
sqe->addr = (unsigned long) old;
|
||||
sqe->len = AT_FDCWD;
|
||||
|
||||
io_uring_prep_rename(sqe, old, new);
|
||||
|
||||
ret = io_uring_submit(ring);
|
||||
if (ret <= 0) {
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ static int test_unlink(struct io_uring *ring, const char *old)
|
||||
fprintf(stderr, "get sqe failed\n");
|
||||
goto err;
|
||||
}
|
||||
io_uring_prep_unlinkat(sqe, AT_FDCWD, old, 0);
|
||||
io_uring_prep_unlink(sqe, old, 0);
|
||||
|
||||
ret = io_uring_submit(ring);
|
||||
if (ret <= 0) {
|
||||
|
||||
Reference in New Issue
Block a user