diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2024-11-09 19:14:48 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2024-11-09 19:25:43 +0300 |
commit | 9ade466e8683a2e3b45dacf45f74fcf4a3c40cee (patch) | |
tree | 5386d43454d677cb1239ed7a889dfcf101e99136 /contrib/libs/liburing/test/openat2.c | |
parent | 1f59ab019232ff97a73c7c13736b254925fa8b0b (diff) | |
download | ydb-9ade466e8683a2e3b45dacf45f74fcf4a3c40cee.tar.gz |
Update contrib/libs/liburing to 2.8
commit_hash:761e2e80642a3d32073f0261b3f5b1992e54a74f
Diffstat (limited to 'contrib/libs/liburing/test/openat2.c')
-rw-r--r-- | contrib/libs/liburing/test/openat2.c | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/contrib/libs/liburing/test/openat2.c b/contrib/libs/liburing/test/openat2.c index 5206b73f3a..833026d31c 100644 --- a/contrib/libs/liburing/test/openat2.c +++ b/contrib/libs/liburing/test/openat2.c @@ -16,25 +16,32 @@ #include "liburing.h" static int test_openat2(struct io_uring *ring, const char *path, int dfd, - bool direct, int fixed_index) + bool direct, int fixed_index, int bad_how) { struct io_uring_cqe *cqe; struct io_uring_sqe *sqe; - struct open_how how; + struct open_how __how, *how; int ret; + if (bad_how) + how = (struct open_how *) (uintptr_t) 0x1234; + else + how = &__how; + sqe = io_uring_get_sqe(ring); if (!sqe) { fprintf(stderr, "get sqe failed\n"); return -1; } - memset(&how, 0, sizeof(how)); - how.flags = O_RDWR; + if (!bad_how) { + memset(how, 0, sizeof(*how)); + how->flags = O_RDWR; + } if (!direct) - io_uring_prep_openat2(sqe, dfd, path, &how); + io_uring_prep_openat2(sqe, dfd, path, how); else - io_uring_prep_openat2_direct(sqe, dfd, path, &how, fixed_index); + io_uring_prep_openat2_direct(sqe, dfd, path, how, fixed_index); ret = io_uring_submit(ring); if (ret <= 0) { @@ -79,7 +86,7 @@ static int test_open_fixed(const char *path, int dfd) return -1; } - ret = test_openat2(&ring, path, dfd, true, 0); + ret = test_openat2(&ring, path, dfd, true, 0, 0); if (ret == -EINVAL) { printf("fixed open isn't supported\n"); return 1; @@ -136,7 +143,7 @@ static int test_open_fixed_fail(const char *path, int dfd) return -1; } - ret = test_openat2(&ring, path, dfd, true, 0); + ret = test_openat2(&ring, path, dfd, true, 0, 0); if (ret != -ENXIO) { fprintf(stderr, "install into not existing table, %i\n", ret); return 1; @@ -150,19 +157,19 @@ static int test_open_fixed_fail(const char *path, int dfd) return -1; } - ret = test_openat2(&ring, path, dfd, true, 1); + ret = test_openat2(&ring, path, dfd, true, 1, 0); if (ret != -EINVAL) { fprintf(stderr, "install out of bounds, %i\n", ret); return -1; } - ret = test_openat2(&ring, path, dfd, true, (1u << 16)); + ret = test_openat2(&ring, path, dfd, true, (1u << 16), 0); if (ret != -EINVAL) { fprintf(stderr, "install out of bounds or u16 overflow, %i\n", ret); return -1; } - ret = test_openat2(&ring, path, dfd, true, (1u << 16) + 1); + ret = test_openat2(&ring, path, dfd, true, (1u << 16) + 1, 0); if (ret != -EINVAL) { fprintf(stderr, "install out of bounds or u16 overflow, %i\n", ret); return -1; @@ -197,7 +204,7 @@ static int test_direct_reinstall(const char *path, int dfd) } /* reinstall into the second slot */ - ret = test_openat2(&ring, path, dfd, true, 1); + ret = test_openat2(&ring, path, dfd, true, 1, 0); if (ret != 0) { fprintf(stderr, "reinstall failed, %i\n", ret); return -1; @@ -265,18 +272,22 @@ int main(int argc, char *argv[]) if (do_unlink) t_create_file(path_rel, 4096); - ret = test_openat2(&ring, path, -1, false, 0); + ret = test_openat2(&ring, path, -1, false, 0, 0); if (ret < 0) { if (ret == -EINVAL) { fprintf(stdout, "openat2 not supported, skipping\n"); goto done; } + if (ret == -EPERM || ret == -EACCES) + return T_EXIT_SKIP; fprintf(stderr, "test_openat2 absolute failed: %d\n", ret); goto err; } - ret = test_openat2(&ring, path_rel, AT_FDCWD, false, 0); + ret = test_openat2(&ring, path_rel, AT_FDCWD, false, 0, 0); if (ret < 0) { + if (ret == -EPERM || ret == -EACCES) + return T_EXIT_SKIP; fprintf(stderr, "test_openat2 relative failed: %d\n", ret); goto err; } @@ -300,6 +311,18 @@ int main(int argc, char *argv[]) goto err; } + ret = test_openat2(&ring, (const char *) (uintptr_t) 0x1234, AT_FDCWD, false, 0, 0); + if (ret != -EFAULT) { + fprintf(stderr, "test_openat2 bad address failed: %d\n", ret); + goto err; + } + + ret = test_openat2(&ring, path_rel, AT_FDCWD, false, 0, 1); + if (ret != -EFAULT) { + fprintf(stderr, "test_openat2 bad how failed: %d\n", ret); + goto err; + } + done: unlink(path); if (do_unlink) |