uringmachine 0.3 → 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +2 -1
- data/CHANGELOG.md +23 -0
- data/README.md +128 -0
- data/TODO.md +14 -0
- data/examples/bm_snooze.rb +89 -0
- data/examples/bm_write.rb +56 -0
- data/examples/dns_client.rb +12 -0
- data/examples/echo_server.rb +18 -40
- data/examples/http_server.rb +42 -43
- data/examples/inout.rb +19 -0
- data/examples/nc.rb +36 -0
- data/examples/server_client.rb +64 -0
- data/examples/snooze.rb +44 -0
- data/examples/write_dev_null.rb +16 -0
- data/ext/um/extconf.rb +24 -23
- data/ext/um/um.c +524 -278
- data/ext/um/um.h +146 -44
- data/ext/um/um_buffer.c +49 -0
- data/ext/um/um_class.c +217 -106
- data/ext/um/um_const.c +213 -0
- data/ext/um/um_ext.c +4 -0
- data/ext/um/um_mutex_class.c +47 -0
- data/ext/um/um_op.c +86 -114
- data/ext/um/um_queue_class.c +58 -0
- data/ext/um/um_sync.c +273 -0
- data/ext/um/um_utils.c +49 -4
- data/lib/uringmachine/dns_resolver.rb +84 -0
- data/lib/uringmachine/version.rb +1 -1
- data/lib/uringmachine.rb +28 -0
- data/supressions/ruby.supp +71 -0
- data/test/helper.rb +8 -0
- data/test/test_um.rb +685 -46
- data/vendor/liburing/.github/workflows/build.yml +29 -1
- data/vendor/liburing/.gitignore +6 -0
- data/vendor/liburing/CHANGELOG +16 -0
- data/vendor/liburing/CONTRIBUTING.md +165 -0
- data/vendor/liburing/configure +64 -0
- data/vendor/liburing/examples/Makefile +9 -1
- data/vendor/liburing/examples/kdigest.c +405 -0
- data/vendor/liburing/examples/proxy.c +75 -8
- data/vendor/liburing/examples/reg-wait.c +159 -0
- data/vendor/liburing/liburing.pc.in +1 -1
- data/vendor/liburing/liburing.spec +1 -1
- data/vendor/liburing/src/Makefile +16 -2
- data/vendor/liburing/src/include/liburing/io_uring.h +77 -0
- data/vendor/liburing/src/include/liburing/sanitize.h +39 -0
- data/vendor/liburing/src/include/liburing.h +59 -6
- data/vendor/liburing/src/int_flags.h +10 -3
- data/vendor/liburing/src/liburing-ffi.map +16 -0
- data/vendor/liburing/src/liburing.map +10 -0
- data/vendor/liburing/src/queue.c +28 -16
- data/vendor/liburing/src/register.c +106 -1
- data/vendor/liburing/src/sanitize.c +176 -0
- data/vendor/liburing/src/setup.c +47 -19
- data/vendor/liburing/src/setup.h +6 -0
- data/vendor/liburing/test/35fa71a030ca.c +7 -0
- data/vendor/liburing/test/500f9fbadef8.c +2 -0
- data/vendor/liburing/test/7ad0e4b2f83c.c +0 -25
- data/vendor/liburing/test/917257daa0fe.c +7 -0
- data/vendor/liburing/test/Makefile +38 -4
- data/vendor/liburing/test/a0908ae19763.c +7 -0
- data/vendor/liburing/test/a4c0b3decb33.c +7 -0
- data/vendor/liburing/test/accept.c +14 -4
- data/vendor/liburing/test/b19062a56726.c +7 -0
- data/vendor/liburing/test/bind-listen.c +2 -2
- data/vendor/liburing/test/buf-ring-nommap.c +10 -3
- data/vendor/liburing/test/buf-ring.c +2 -0
- data/vendor/liburing/test/cmd-discard.c +427 -0
- data/vendor/liburing/test/coredump.c +7 -0
- data/vendor/liburing/test/cq-overflow.c +13 -1
- data/vendor/liburing/test/d4ae271dfaae.c +11 -3
- data/vendor/liburing/test/defer-taskrun.c +2 -2
- data/vendor/liburing/test/defer-tw-timeout.c +4 -1
- data/vendor/liburing/test/defer.c +2 -2
- data/vendor/liburing/test/double-poll-crash.c +1 -1
- data/vendor/liburing/test/eeed8b54e0df.c +2 -0
- data/vendor/liburing/test/eventfd.c +0 -1
- data/vendor/liburing/test/exit-no-cleanup.c +11 -0
- data/vendor/liburing/test/fadvise.c +9 -26
- data/vendor/liburing/test/fdinfo.c +9 -1
- data/vendor/liburing/test/fifo-nonblock-read.c +69 -0
- data/vendor/liburing/test/file-exit-unreg.c +48 -0
- data/vendor/liburing/test/file-register.c +14 -2
- data/vendor/liburing/test/file-update.c +1 -1
- data/vendor/liburing/test/file-verify.c +27 -16
- data/vendor/liburing/test/files-exit-hang-timeout.c +1 -2
- data/vendor/liburing/test/fixed-buf-iter.c +3 -1
- data/vendor/liburing/test/fixed-hugepage.c +12 -1
- data/vendor/liburing/test/fsnotify.c +1 -0
- data/vendor/liburing/test/futex.c +16 -4
- data/vendor/liburing/test/helpers.c +47 -0
- data/vendor/liburing/test/helpers.h +6 -0
- data/vendor/liburing/test/init-mem.c +5 -3
- data/vendor/liburing/test/io-cancel.c +0 -24
- data/vendor/liburing/test/io_uring_passthrough.c +4 -0
- data/vendor/liburing/test/io_uring_register.c +38 -8
- data/vendor/liburing/test/iopoll-leak.c +4 -0
- data/vendor/liburing/test/iopoll-overflow.c +1 -1
- data/vendor/liburing/test/iopoll.c +3 -3
- data/vendor/liburing/test/kallsyms.c +203 -0
- data/vendor/liburing/test/link-timeout.c +159 -0
- data/vendor/liburing/test/linked-defer-close.c +224 -0
- data/vendor/liburing/test/madvise.c +12 -25
- data/vendor/liburing/test/min-timeout-wait.c +0 -25
- data/vendor/liburing/test/min-timeout.c +0 -25
- data/vendor/liburing/test/mkdir.c +6 -0
- data/vendor/liburing/test/msg-ring.c +8 -2
- data/vendor/liburing/test/napi-test.c +16 -3
- data/vendor/liburing/test/no-mmap-inval.c +3 -1
- data/vendor/liburing/test/nop.c +44 -0
- data/vendor/liburing/test/ooo-file-unreg.c +1 -1
- data/vendor/liburing/test/open-close.c +40 -0
- data/vendor/liburing/test/openat2.c +37 -14
- data/vendor/liburing/test/poll-many.c +13 -7
- data/vendor/liburing/test/poll-mshot-update.c +17 -10
- data/vendor/liburing/test/poll-v-poll.c +6 -3
- data/vendor/liburing/test/pollfree.c +148 -0
- data/vendor/liburing/test/read-mshot-empty.c +158 -153
- data/vendor/liburing/test/read-mshot-stdin.c +121 -0
- data/vendor/liburing/test/read-mshot.c +282 -27
- data/vendor/liburing/test/read-write.c +78 -13
- data/vendor/liburing/test/recv-msgall-stream.c +3 -0
- data/vendor/liburing/test/recv-msgall.c +5 -0
- data/vendor/liburing/test/recvsend_bundle-inc.c +680 -0
- data/vendor/liburing/test/recvsend_bundle.c +94 -31
- data/vendor/liburing/test/reg-fd-only.c +15 -5
- data/vendor/liburing/test/reg-wait.c +251 -0
- data/vendor/liburing/test/regbuf-clone.c +645 -0
- data/vendor/liburing/test/regbuf-merge.c +7 -0
- data/vendor/liburing/test/register-restrictions.c +86 -85
- data/vendor/liburing/test/rename.c +59 -1
- data/vendor/liburing/test/resize-rings.c +643 -0
- data/vendor/liburing/test/ringbuf-read.c +5 -0
- data/vendor/liburing/test/ringbuf-status.c +5 -1
- data/vendor/liburing/test/rsrc_tags.c +1 -1
- data/vendor/liburing/test/runtests.sh +16 -1
- data/vendor/liburing/test/send-zerocopy.c +59 -0
- data/vendor/liburing/test/short-read.c +1 -0
- data/vendor/liburing/test/socket.c +43 -0
- data/vendor/liburing/test/splice.c +3 -1
- data/vendor/liburing/test/sq-poll-dup.c +1 -1
- data/vendor/liburing/test/sq-poll-share.c +2 -0
- data/vendor/liburing/test/sqpoll-disable-exit.c +8 -0
- data/vendor/liburing/test/sqpoll-exit-hang.c +1 -25
- data/vendor/liburing/test/sqpoll-sleep.c +40 -33
- data/vendor/liburing/test/sqwait.c +136 -0
- data/vendor/liburing/test/statx.c +89 -0
- data/vendor/liburing/test/stdout.c +2 -0
- data/vendor/liburing/test/submit-and-wait.c +1 -25
- data/vendor/liburing/test/submit-reuse.c +4 -26
- data/vendor/liburing/test/symlink.c +12 -1
- data/vendor/liburing/test/sync-cancel.c +56 -22
- data/vendor/liburing/test/thread-exit.c +5 -0
- data/vendor/liburing/test/timeout-new.c +1 -26
- data/vendor/liburing/test/timeout.c +25 -34
- data/vendor/liburing/test/unlink.c +94 -1
- data/vendor/liburing/test/uring_cmd_ublk.c +1252 -0
- data/vendor/liburing/test/waitid.c +62 -8
- data/vendor/liburing/test/wq-aff.c +35 -0
- data/vendor/liburing/test/xfail_prep_link_timeout_out_of_scope.c +46 -0
- data/vendor/liburing/test/xfail_register_buffers_out_of_scope.c +51 -0
- metadata +37 -6
- data/examples/event_loop.rb +0 -69
- data/examples/fibers.rb +0 -105
- data/examples/http_server_multishot.rb +0 -57
- data/examples/http_server_simpler.rb +0 -34
@@ -13,12 +13,7 @@
|
|
13
13
|
#include <sys/eventfd.h>
|
14
14
|
|
15
15
|
#include "liburing.h"
|
16
|
-
|
17
|
-
enum {
|
18
|
-
TEST_OK,
|
19
|
-
TEST_SKIPPED,
|
20
|
-
TEST_FAILED
|
21
|
-
};
|
16
|
+
#include "helpers.h"
|
22
17
|
|
23
18
|
static int test_restrictions_sqe_op(void)
|
24
19
|
{
|
@@ -36,15 +31,15 @@ static int test_restrictions_sqe_op(void)
|
|
36
31
|
|
37
32
|
if (pipe(pipe1) != 0) {
|
38
33
|
perror("pipe");
|
39
|
-
return
|
34
|
+
return T_EXIT_FAIL;
|
40
35
|
}
|
41
36
|
|
42
37
|
ret = io_uring_queue_init(8, &ring, IORING_SETUP_R_DISABLED);
|
43
38
|
if (ret) {
|
44
39
|
if (ret == -EINVAL)
|
45
|
-
return
|
40
|
+
return T_EXIT_SKIP;
|
46
41
|
fprintf(stderr, "ring setup failed: %d\n", ret);
|
47
|
-
return
|
42
|
+
return T_EXIT_FAIL;
|
48
43
|
}
|
49
44
|
|
50
45
|
res[0].opcode = IORING_RESTRICTION_SQE_OP;
|
@@ -56,16 +51,16 @@ static int test_restrictions_sqe_op(void)
|
|
56
51
|
ret = io_uring_register_restrictions(&ring, res, 2);
|
57
52
|
if (ret) {
|
58
53
|
if (ret == -EINVAL)
|
59
|
-
return
|
54
|
+
return T_EXIT_SKIP;
|
60
55
|
|
61
56
|
fprintf(stderr, "failed to register restrictions: %d\n", ret);
|
62
|
-
return
|
57
|
+
return T_EXIT_FAIL;
|
63
58
|
}
|
64
59
|
|
65
60
|
ret = io_uring_enable_rings(&ring);
|
66
61
|
if (ret) {
|
67
62
|
fprintf(stderr, "ring enabling failed: %d\n", ret);
|
68
|
-
return
|
63
|
+
return T_EXIT_FAIL;
|
69
64
|
}
|
70
65
|
|
71
66
|
sqe = io_uring_get_sqe(&ring);
|
@@ -79,28 +74,28 @@ static int test_restrictions_sqe_op(void)
|
|
79
74
|
ret = io_uring_submit(&ring);
|
80
75
|
if (ret != 2) {
|
81
76
|
fprintf(stderr, "submit: %d\n", ret);
|
82
|
-
return
|
77
|
+
return T_EXIT_FAIL;
|
83
78
|
}
|
84
79
|
|
85
80
|
for (int i = 0; i < 2; i++) {
|
86
81
|
ret = io_uring_wait_cqe(&ring, &cqe);
|
87
82
|
if (ret) {
|
88
83
|
fprintf(stderr, "wait: %d\n", ret);
|
89
|
-
return
|
84
|
+
return T_EXIT_FAIL;
|
90
85
|
}
|
91
86
|
|
92
87
|
switch (cqe->user_data) {
|
93
88
|
case 1: /* writev */
|
94
89
|
if (cqe->res != sizeof(ptr)) {
|
95
90
|
fprintf(stderr, "write res: %d\n", cqe->res);
|
96
|
-
return
|
91
|
+
return T_EXIT_FAIL;
|
97
92
|
}
|
98
93
|
|
99
94
|
break;
|
100
95
|
case 2: /* readv should be denied */
|
101
96
|
if (cqe->res != -EACCES) {
|
102
97
|
fprintf(stderr, "read res: %d\n", cqe->res);
|
103
|
-
return
|
98
|
+
return T_EXIT_FAIL;
|
104
99
|
}
|
105
100
|
break;
|
106
101
|
}
|
@@ -108,7 +103,7 @@ static int test_restrictions_sqe_op(void)
|
|
108
103
|
}
|
109
104
|
|
110
105
|
io_uring_queue_exit(&ring);
|
111
|
-
return
|
106
|
+
return T_EXIT_PASS;
|
112
107
|
}
|
113
108
|
|
114
109
|
static int test_restrictions_register_op(void)
|
@@ -125,13 +120,13 @@ static int test_restrictions_register_op(void)
|
|
125
120
|
|
126
121
|
if (pipe(pipe1) != 0) {
|
127
122
|
perror("pipe");
|
128
|
-
return
|
123
|
+
return T_EXIT_FAIL;
|
129
124
|
}
|
130
125
|
|
131
126
|
ret = io_uring_queue_init(8, &ring, IORING_SETUP_R_DISABLED);
|
132
127
|
if (ret) {
|
133
128
|
fprintf(stderr, "ring setup failed: %d\n", ret);
|
134
|
-
return
|
129
|
+
return T_EXIT_FAIL;
|
135
130
|
}
|
136
131
|
|
137
132
|
res[0].opcode = IORING_RESTRICTION_REGISTER_OP;
|
@@ -140,32 +135,32 @@ static int test_restrictions_register_op(void)
|
|
140
135
|
ret = io_uring_register_restrictions(&ring, res, 1);
|
141
136
|
if (ret) {
|
142
137
|
if (ret == -EINVAL)
|
143
|
-
return
|
138
|
+
return T_EXIT_SKIP;
|
144
139
|
|
145
140
|
fprintf(stderr, "failed to register restrictions: %d\n", ret);
|
146
|
-
return
|
141
|
+
return T_EXIT_FAIL;
|
147
142
|
}
|
148
143
|
|
149
144
|
ret = io_uring_enable_rings(&ring);
|
150
145
|
if (ret) {
|
151
146
|
fprintf(stderr, "ring enabling failed: %d\n", ret);
|
152
|
-
return
|
147
|
+
return T_EXIT_FAIL;
|
153
148
|
}
|
154
149
|
|
155
150
|
ret = io_uring_register_buffers(&ring, &vec, 1);
|
156
151
|
if (ret) {
|
157
152
|
fprintf(stderr, "io_uring_register_buffers failed: %d\n", ret);
|
158
|
-
return
|
153
|
+
return T_EXIT_FAIL;
|
159
154
|
}
|
160
155
|
|
161
156
|
ret = io_uring_register_files(&ring, pipe1, 2);
|
162
157
|
if (ret != -EACCES) {
|
163
158
|
fprintf(stderr, "io_uring_register_files ret: %d\n", ret);
|
164
|
-
return
|
159
|
+
return T_EXIT_FAIL;
|
165
160
|
}
|
166
161
|
|
167
162
|
io_uring_queue_exit(&ring);
|
168
|
-
return
|
163
|
+
return T_EXIT_PASS;
|
169
164
|
}
|
170
165
|
|
171
166
|
static int test_restrictions_fixed_file(void)
|
@@ -184,13 +179,13 @@ static int test_restrictions_fixed_file(void)
|
|
184
179
|
|
185
180
|
if (pipe(pipe1) != 0) {
|
186
181
|
perror("pipe");
|
187
|
-
return
|
182
|
+
return T_EXIT_FAIL;
|
188
183
|
}
|
189
184
|
|
190
185
|
ret = io_uring_queue_init(8, &ring, IORING_SETUP_R_DISABLED);
|
191
186
|
if (ret) {
|
192
187
|
fprintf(stderr, "ring setup failed: %d\n", ret);
|
193
|
-
return
|
188
|
+
return T_EXIT_FAIL;
|
194
189
|
}
|
195
190
|
|
196
191
|
res[0].opcode = IORING_RESTRICTION_SQE_OP;
|
@@ -208,22 +203,22 @@ static int test_restrictions_fixed_file(void)
|
|
208
203
|
ret = io_uring_register_restrictions(&ring, res, 4);
|
209
204
|
if (ret) {
|
210
205
|
if (ret == -EINVAL)
|
211
|
-
return
|
206
|
+
return T_EXIT_SKIP;
|
212
207
|
|
213
208
|
fprintf(stderr, "failed to register restrictions: %d\n", ret);
|
214
|
-
return
|
209
|
+
return T_EXIT_FAIL;
|
215
210
|
}
|
216
211
|
|
217
212
|
ret = io_uring_enable_rings(&ring);
|
218
213
|
if (ret) {
|
219
214
|
fprintf(stderr, "ring enabling failed: %d\n", ret);
|
220
|
-
return
|
215
|
+
return T_EXIT_FAIL;
|
221
216
|
}
|
222
217
|
|
223
218
|
ret = io_uring_register_files(&ring, pipe1, 2);
|
224
219
|
if (ret) {
|
225
220
|
fprintf(stderr, "io_uring_register_files ret: %d\n", ret);
|
226
|
-
return
|
221
|
+
return T_EXIT_FAIL;
|
227
222
|
}
|
228
223
|
|
229
224
|
sqe = io_uring_get_sqe(&ring);
|
@@ -243,34 +238,34 @@ static int test_restrictions_fixed_file(void)
|
|
243
238
|
ret = io_uring_submit(&ring);
|
244
239
|
if (ret != 3) {
|
245
240
|
fprintf(stderr, "submit: %d\n", ret);
|
246
|
-
return
|
241
|
+
return T_EXIT_FAIL;
|
247
242
|
}
|
248
243
|
|
249
244
|
for (int i = 0; i < 3; i++) {
|
250
245
|
ret = io_uring_wait_cqe(&ring, &cqe);
|
251
246
|
if (ret) {
|
252
247
|
fprintf(stderr, "wait: %d\n", ret);
|
253
|
-
return
|
248
|
+
return T_EXIT_FAIL;
|
254
249
|
}
|
255
250
|
|
256
251
|
switch (cqe->user_data) {
|
257
252
|
case 1: /* writev */
|
258
253
|
if (cqe->res != sizeof(ptr)) {
|
259
254
|
fprintf(stderr, "write res: %d\n", cqe->res);
|
260
|
-
return
|
255
|
+
return T_EXIT_FAIL;
|
261
256
|
}
|
262
257
|
|
263
258
|
break;
|
264
259
|
case 2: /* readv */
|
265
260
|
if (cqe->res != sizeof(ptr)) {
|
266
261
|
fprintf(stderr, "read res: %d\n", cqe->res);
|
267
|
-
return
|
262
|
+
return T_EXIT_FAIL;
|
268
263
|
}
|
269
264
|
break;
|
270
265
|
case 3: /* writev without fixed_file should be denied */
|
271
266
|
if (cqe->res != -EACCES) {
|
272
267
|
fprintf(stderr, "write res: %d\n", cqe->res);
|
273
|
-
return
|
268
|
+
return T_EXIT_FAIL;
|
274
269
|
}
|
275
270
|
break;
|
276
271
|
}
|
@@ -278,7 +273,7 @@ static int test_restrictions_fixed_file(void)
|
|
278
273
|
}
|
279
274
|
|
280
275
|
io_uring_queue_exit(&ring);
|
281
|
-
return
|
276
|
+
return T_EXIT_PASS;
|
282
277
|
}
|
283
278
|
|
284
279
|
static int test_restrictions_flags(void)
|
@@ -297,13 +292,13 @@ static int test_restrictions_flags(void)
|
|
297
292
|
|
298
293
|
if (pipe(pipe1) != 0) {
|
299
294
|
perror("pipe");
|
300
|
-
return
|
295
|
+
return T_EXIT_FAIL;
|
301
296
|
}
|
302
297
|
|
303
298
|
ret = io_uring_queue_init(8, &ring, IORING_SETUP_R_DISABLED);
|
304
299
|
if (ret) {
|
305
300
|
fprintf(stderr, "ring setup failed: %d\n", ret);
|
306
|
-
return
|
301
|
+
return T_EXIT_FAIL;
|
307
302
|
}
|
308
303
|
|
309
304
|
res[0].opcode = IORING_RESTRICTION_SQE_OP;
|
@@ -318,22 +313,22 @@ static int test_restrictions_flags(void)
|
|
318
313
|
ret = io_uring_register_restrictions(&ring, res, 3);
|
319
314
|
if (ret) {
|
320
315
|
if (ret == -EINVAL)
|
321
|
-
return
|
316
|
+
return T_EXIT_SKIP;
|
322
317
|
|
323
318
|
fprintf(stderr, "failed to register restrictions: %d\n", ret);
|
324
|
-
return
|
319
|
+
return T_EXIT_FAIL;
|
325
320
|
}
|
326
321
|
|
327
322
|
ret = io_uring_register_files(&ring, pipe1, 2);
|
328
323
|
if (ret) {
|
329
324
|
fprintf(stderr, "io_uring_register_files ret: %d\n", ret);
|
330
|
-
return
|
325
|
+
return T_EXIT_FAIL;
|
331
326
|
}
|
332
327
|
|
333
328
|
ret = io_uring_enable_rings(&ring);
|
334
329
|
if (ret) {
|
335
330
|
fprintf(stderr, "ring enabling failed: %d\n", ret);
|
336
|
-
return
|
331
|
+
return T_EXIT_FAIL;
|
337
332
|
}
|
338
333
|
|
339
334
|
sqe = io_uring_get_sqe(&ring);
|
@@ -354,7 +349,7 @@ static int test_restrictions_flags(void)
|
|
354
349
|
ret = io_uring_submit(&ring);
|
355
350
|
if (ret != 3) {
|
356
351
|
fprintf(stderr, "submit: %d\n", ret);
|
357
|
-
return
|
352
|
+
return T_EXIT_FAIL;
|
358
353
|
}
|
359
354
|
|
360
355
|
sqe = io_uring_get_sqe(&ring);
|
@@ -365,7 +360,7 @@ static int test_restrictions_flags(void)
|
|
365
360
|
ret = io_uring_submit(&ring);
|
366
361
|
if (ret != 1) {
|
367
362
|
fprintf(stderr, "submit: %d\n", ret);
|
368
|
-
return
|
363
|
+
return T_EXIT_FAIL;
|
369
364
|
}
|
370
365
|
|
371
366
|
sqe = io_uring_get_sqe(&ring);
|
@@ -376,7 +371,7 @@ static int test_restrictions_flags(void)
|
|
376
371
|
ret = io_uring_submit(&ring);
|
377
372
|
if (ret != 1) {
|
378
373
|
fprintf(stderr, "submit: %d\n", ret);
|
379
|
-
return
|
374
|
+
return T_EXIT_FAIL;
|
380
375
|
}
|
381
376
|
|
382
377
|
sqe = io_uring_get_sqe(&ring);
|
@@ -387,7 +382,7 @@ static int test_restrictions_flags(void)
|
|
387
382
|
ret = io_uring_submit(&ring);
|
388
383
|
if (ret != 1) {
|
389
384
|
fprintf(stderr, "submit: %d\n", ret);
|
390
|
-
return
|
385
|
+
return T_EXIT_FAIL;
|
391
386
|
}
|
392
387
|
|
393
388
|
sqe = io_uring_get_sqe(&ring);
|
@@ -397,14 +392,14 @@ static int test_restrictions_flags(void)
|
|
397
392
|
ret = io_uring_submit(&ring);
|
398
393
|
if (ret != 1) {
|
399
394
|
fprintf(stderr, "submit: %d\n", ret);
|
400
|
-
return
|
395
|
+
return T_EXIT_FAIL;
|
401
396
|
}
|
402
397
|
|
403
398
|
for (int i = 0; i < 7; i++) {
|
404
399
|
ret = io_uring_wait_cqe(&ring, &cqe);
|
405
400
|
if (ret) {
|
406
401
|
fprintf(stderr, "wait: %d\n", ret);
|
407
|
-
return
|
402
|
+
return T_EXIT_FAIL;
|
408
403
|
}
|
409
404
|
|
410
405
|
switch (cqe->user_data) {
|
@@ -414,7 +409,7 @@ static int test_restrictions_flags(void)
|
|
414
409
|
if (cqe->res != sizeof(ptr)) {
|
415
410
|
fprintf(stderr, "write res: %d user_data %" PRIu64 "\n",
|
416
411
|
cqe->res, (uint64_t) cqe->user_data);
|
417
|
-
return
|
412
|
+
return T_EXIT_FAIL;
|
418
413
|
}
|
419
414
|
|
420
415
|
break;
|
@@ -425,7 +420,7 @@ static int test_restrictions_flags(void)
|
|
425
420
|
if (cqe->res != -EACCES) {
|
426
421
|
fprintf(stderr, "write res: %d user_data %" PRIu64 "\n",
|
427
422
|
cqe->res, (uint64_t) cqe->user_data);
|
428
|
-
return
|
423
|
+
return T_EXIT_FAIL;
|
429
424
|
}
|
430
425
|
break;
|
431
426
|
}
|
@@ -433,7 +428,7 @@ static int test_restrictions_flags(void)
|
|
433
428
|
}
|
434
429
|
|
435
430
|
io_uring_queue_exit(&ring);
|
436
|
-
return
|
431
|
+
return T_EXIT_PASS;
|
437
432
|
}
|
438
433
|
|
439
434
|
static int test_restrictions_empty(void)
|
@@ -452,40 +447,40 @@ static int test_restrictions_empty(void)
|
|
452
447
|
|
453
448
|
if (pipe(pipe1) != 0) {
|
454
449
|
perror("pipe");
|
455
|
-
return
|
450
|
+
return T_EXIT_FAIL;
|
456
451
|
}
|
457
452
|
|
458
453
|
ret = io_uring_queue_init(8, &ring, IORING_SETUP_R_DISABLED);
|
459
454
|
if (ret) {
|
460
455
|
fprintf(stderr, "ring setup failed: %d\n", ret);
|
461
|
-
return
|
456
|
+
return T_EXIT_FAIL;
|
462
457
|
}
|
463
458
|
|
464
459
|
ret = io_uring_register_restrictions(&ring, res, 0);
|
465
460
|
if (ret) {
|
466
461
|
if (ret == -EINVAL)
|
467
|
-
return
|
462
|
+
return T_EXIT_SKIP;
|
468
463
|
|
469
464
|
fprintf(stderr, "failed to register restrictions: %d\n", ret);
|
470
|
-
return
|
465
|
+
return T_EXIT_FAIL;
|
471
466
|
}
|
472
467
|
|
473
468
|
ret = io_uring_enable_rings(&ring);
|
474
469
|
if (ret) {
|
475
470
|
fprintf(stderr, "ring enabling failed: %d\n", ret);
|
476
|
-
return
|
471
|
+
return T_EXIT_FAIL;
|
477
472
|
}
|
478
473
|
|
479
474
|
ret = io_uring_register_buffers(&ring, &vec, 1);
|
480
475
|
if (ret != -EACCES) {
|
481
476
|
fprintf(stderr, "io_uring_register_buffers ret: %d\n", ret);
|
482
|
-
return
|
477
|
+
return T_EXIT_FAIL;
|
483
478
|
}
|
484
479
|
|
485
480
|
ret = io_uring_register_files(&ring, pipe1, 2);
|
486
481
|
if (ret != -EACCES) {
|
487
482
|
fprintf(stderr, "io_uring_register_files ret: %d\n", ret);
|
488
|
-
return
|
483
|
+
return T_EXIT_FAIL;
|
489
484
|
}
|
490
485
|
|
491
486
|
sqe = io_uring_get_sqe(&ring);
|
@@ -494,24 +489,24 @@ static int test_restrictions_empty(void)
|
|
494
489
|
ret = io_uring_submit(&ring);
|
495
490
|
if (ret != 1) {
|
496
491
|
fprintf(stderr, "submit: %d\n", ret);
|
497
|
-
return
|
492
|
+
return T_EXIT_FAIL;
|
498
493
|
}
|
499
494
|
|
500
495
|
ret = io_uring_wait_cqe(&ring, &cqe);
|
501
496
|
if (ret) {
|
502
497
|
fprintf(stderr, "wait: %d\n", ret);
|
503
|
-
return
|
498
|
+
return T_EXIT_FAIL;
|
504
499
|
}
|
505
500
|
|
506
501
|
if (cqe->res != -EACCES) {
|
507
502
|
fprintf(stderr, "write res: %d\n", cqe->res);
|
508
|
-
return
|
503
|
+
return T_EXIT_FAIL;
|
509
504
|
}
|
510
505
|
|
511
506
|
io_uring_cqe_seen(&ring, cqe);
|
512
507
|
|
513
508
|
io_uring_queue_exit(&ring);
|
514
|
-
return
|
509
|
+
return T_EXIT_PASS;
|
515
510
|
}
|
516
511
|
|
517
512
|
static int test_restrictions_rings_not_disabled(void)
|
@@ -523,7 +518,7 @@ static int test_restrictions_rings_not_disabled(void)
|
|
523
518
|
ret = io_uring_queue_init(8, &ring, 0);
|
524
519
|
if (ret) {
|
525
520
|
fprintf(stderr, "ring setup failed: %d\n", ret);
|
526
|
-
return
|
521
|
+
return T_EXIT_FAIL;
|
527
522
|
}
|
528
523
|
|
529
524
|
res[0].opcode = IORING_RESTRICTION_SQE_OP;
|
@@ -533,11 +528,11 @@ static int test_restrictions_rings_not_disabled(void)
|
|
533
528
|
if (ret != -EBADFD) {
|
534
529
|
fprintf(stderr, "io_uring_register_restrictions ret: %d\n",
|
535
530
|
ret);
|
536
|
-
return
|
531
|
+
return T_EXIT_FAIL;
|
537
532
|
}
|
538
533
|
|
539
534
|
io_uring_queue_exit(&ring);
|
540
|
-
return
|
535
|
+
return T_EXIT_PASS;
|
541
536
|
}
|
542
537
|
|
543
538
|
static int test_restrictions_rings_disabled(void)
|
@@ -549,7 +544,7 @@ static int test_restrictions_rings_disabled(void)
|
|
549
544
|
ret = io_uring_queue_init(8, &ring, IORING_SETUP_R_DISABLED);
|
550
545
|
if (ret) {
|
551
546
|
fprintf(stderr, "ring setup failed: %d\n", ret);
|
552
|
-
return
|
547
|
+
return T_EXIT_FAIL;
|
553
548
|
}
|
554
549
|
|
555
550
|
sqe = io_uring_get_sqe(&ring);
|
@@ -558,11 +553,11 @@ static int test_restrictions_rings_disabled(void)
|
|
558
553
|
ret = io_uring_submit(&ring);
|
559
554
|
if (ret != -EBADFD) {
|
560
555
|
fprintf(stderr, "submit: %d\n", ret);
|
561
|
-
return
|
556
|
+
return T_EXIT_FAIL;
|
562
557
|
}
|
563
558
|
|
564
559
|
io_uring_queue_exit(&ring);
|
565
|
-
return
|
560
|
+
return T_EXIT_PASS;
|
566
561
|
}
|
567
562
|
|
568
563
|
int main(int argc, char *argv[])
|
@@ -573,61 +568,67 @@ int main(int argc, char *argv[])
|
|
573
568
|
return 0;
|
574
569
|
|
575
570
|
ret = test_restrictions_sqe_op();
|
576
|
-
if (ret ==
|
571
|
+
if (ret == T_EXIT_SKIP) {
|
577
572
|
printf("test_restrictions_sqe_op: skipped\n");
|
578
|
-
return
|
579
|
-
} else if (ret ==
|
573
|
+
return T_EXIT_SKIP;
|
574
|
+
} else if (ret == T_EXIT_FAIL) {
|
580
575
|
fprintf(stderr, "test_restrictions_sqe_op failed\n");
|
581
576
|
return ret;
|
582
577
|
}
|
583
578
|
|
584
579
|
ret = test_restrictions_register_op();
|
585
|
-
if (ret ==
|
580
|
+
if (ret == T_EXIT_SKIP) {
|
586
581
|
printf("test_restrictions_register_op: skipped\n");
|
587
|
-
|
582
|
+
return T_EXIT_SKIP;
|
583
|
+
} else if (ret == T_EXIT_FAIL) {
|
588
584
|
fprintf(stderr, "test_restrictions_register_op failed\n");
|
589
585
|
return ret;
|
590
586
|
}
|
591
587
|
|
592
588
|
ret = test_restrictions_fixed_file();
|
593
|
-
if (ret ==
|
589
|
+
if (ret == T_EXIT_SKIP) {
|
594
590
|
printf("test_restrictions_fixed_file: skipped\n");
|
595
|
-
|
591
|
+
return T_EXIT_SKIP;
|
592
|
+
} else if (ret == T_EXIT_FAIL) {
|
596
593
|
fprintf(stderr, "test_restrictions_fixed_file failed\n");
|
597
594
|
return ret;
|
598
595
|
}
|
599
596
|
|
600
597
|
ret = test_restrictions_flags();
|
601
|
-
if (ret ==
|
598
|
+
if (ret == T_EXIT_SKIP) {
|
602
599
|
printf("test_restrictions_flags: skipped\n");
|
603
|
-
|
600
|
+
return T_EXIT_SKIP;
|
601
|
+
} else if (ret == T_EXIT_FAIL) {
|
604
602
|
fprintf(stderr, "test_restrictions_flags failed\n");
|
605
603
|
return ret;
|
606
604
|
}
|
607
605
|
|
608
606
|
ret = test_restrictions_empty();
|
609
|
-
if (ret ==
|
607
|
+
if (ret == T_EXIT_SKIP) {
|
610
608
|
printf("test_restrictions_empty: skipped\n");
|
611
|
-
|
609
|
+
return T_EXIT_SKIP;
|
610
|
+
} else if (ret == T_EXIT_FAIL) {
|
612
611
|
fprintf(stderr, "test_restrictions_empty failed\n");
|
613
612
|
return ret;
|
614
613
|
}
|
615
614
|
|
616
615
|
ret = test_restrictions_rings_not_disabled();
|
617
|
-
if (ret ==
|
616
|
+
if (ret == T_EXIT_SKIP) {
|
618
617
|
printf("test_restrictions_rings_not_disabled: skipped\n");
|
619
|
-
|
618
|
+
return T_EXIT_SKIP;
|
619
|
+
} else if (ret == T_EXIT_FAIL) {
|
620
620
|
fprintf(stderr, "test_restrictions_rings_not_disabled failed\n");
|
621
621
|
return ret;
|
622
622
|
}
|
623
623
|
|
624
624
|
ret = test_restrictions_rings_disabled();
|
625
|
-
if (ret ==
|
625
|
+
if (ret == T_EXIT_SKIP) {
|
626
626
|
printf("test_restrictions_rings_disabled: skipped\n");
|
627
|
-
|
627
|
+
return T_EXIT_SKIP;
|
628
|
+
} else if (ret == T_EXIT_FAIL) {
|
628
629
|
fprintf(stderr, "test_restrictions_rings_disabled failed\n");
|
629
630
|
return ret;
|
630
631
|
}
|
631
632
|
|
632
|
-
return
|
633
|
+
return T_EXIT_PASS;
|
633
634
|
}
|
@@ -13,6 +13,51 @@
|
|
13
13
|
|
14
14
|
#include "liburing.h"
|
15
15
|
|
16
|
+
/* test using a bad address for either old or new path */
|
17
|
+
static int test_rename_badaddr(struct io_uring *ring, bool bad_old)
|
18
|
+
{
|
19
|
+
struct io_uring_cqe *cqe;
|
20
|
+
struct io_uring_sqe *sqe;
|
21
|
+
const char *path = ".foo.bar";
|
22
|
+
const char *old, *new;
|
23
|
+
int ret;
|
24
|
+
|
25
|
+
if (bad_old) {
|
26
|
+
old = (void *) (uintptr_t) 0x1234;
|
27
|
+
new = path;
|
28
|
+
} else {
|
29
|
+
old = path;
|
30
|
+
new = (void *) (uintptr_t) 0x1234;
|
31
|
+
}
|
32
|
+
|
33
|
+
sqe = io_uring_get_sqe(ring);
|
34
|
+
if (!sqe) {
|
35
|
+
fprintf(stderr, "get sqe failed\n");
|
36
|
+
goto err;
|
37
|
+
}
|
38
|
+
|
39
|
+
memset(sqe, 0, sizeof(*sqe));
|
40
|
+
|
41
|
+
io_uring_prep_rename(sqe, old, new);
|
42
|
+
|
43
|
+
ret = io_uring_submit(ring);
|
44
|
+
if (ret <= 0) {
|
45
|
+
fprintf(stderr, "sqe submit failed: %d\n", ret);
|
46
|
+
goto err;
|
47
|
+
}
|
48
|
+
|
49
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
50
|
+
if (ret < 0) {
|
51
|
+
fprintf(stderr, "wait completion %d\n", ret);
|
52
|
+
goto err;
|
53
|
+
}
|
54
|
+
ret = cqe->res;
|
55
|
+
io_uring_cqe_seen(ring, cqe);
|
56
|
+
return ret;
|
57
|
+
err:
|
58
|
+
return 1;
|
59
|
+
}
|
60
|
+
|
16
61
|
static int test_rename(struct io_uring *ring, const char *old, const char *new)
|
17
62
|
{
|
18
63
|
struct io_uring_cqe *cqe;
|
@@ -28,7 +73,7 @@ static int test_rename(struct io_uring *ring, const char *old, const char *new)
|
|
28
73
|
memset(sqe, 0, sizeof(*sqe));
|
29
74
|
|
30
75
|
io_uring_prep_rename(sqe, old, new);
|
31
|
-
|
76
|
+
|
32
77
|
ret = io_uring_submit(ring);
|
33
78
|
if (ret <= 0) {
|
34
79
|
fprintf(stderr, "sqe submit failed: %d\n", ret);
|
@@ -122,6 +167,19 @@ int main(int argc, char *argv[])
|
|
122
167
|
fprintf(stderr, "test_rename invalid failed: %d\n", ret);
|
123
168
|
return ret;
|
124
169
|
}
|
170
|
+
|
171
|
+
ret = test_rename_badaddr(&ring, 0);
|
172
|
+
if (ret != -EFAULT) {
|
173
|
+
fprintf(stderr, "test_badaddr 0 failed: %d\n", ret);
|
174
|
+
return ret;
|
175
|
+
}
|
176
|
+
|
177
|
+
ret = test_rename_badaddr(&ring, 1);
|
178
|
+
if (ret != -EFAULT) {
|
179
|
+
fprintf(stderr, "test_badaddr 1 failed: %d\n", ret);
|
180
|
+
return ret;
|
181
|
+
}
|
182
|
+
|
125
183
|
out:
|
126
184
|
unlink(dst);
|
127
185
|
return 0;
|