MCPcopy Create free account
hub / github.com/axboe/liburing / main

Function main

test/mkdir.c:56–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56int main(int argc, char *argv[])
57{
58 static const char fn[] = "io_uring-mkdirat-test";
59 int ret;
60 struct io_uring ring;
61
62 if (argc > 1)
63 return T_EXIT_SKIP;
64
65 ret = io_uring_queue_init(8, &ring, 0);
66 if (ret) {
67 fprintf(stderr, "queue init failed: %d\n", ret);
68 return ret;
69 }
70
71 ret = do_mkdirat(&ring, fn);
72 if (ret < 0) {
73 if (ret == -EBADF || ret == -EINVAL) {
74 fprintf(stdout, "mkdirat not supported, skipping\n");
75 goto skip;
76 }
77 fprintf(stderr, "mkdirat: %s\n", strerror(-ret));
78 goto err;
79 } else if (ret) {
80 goto err;
81 }
82
83 if (stat_file(fn)) {
84 perror("stat");
85 goto err;
86 }
87
88 ret = do_mkdirat(&ring, fn);
89 if (ret != -EEXIST) {
90 fprintf(stderr, "do_mkdirat already exists failed: %d\n", ret);
91 goto err1;
92 }
93
94 ret = do_mkdirat(&ring, "surely/this/wont/exist");
95 if (ret != -ENOENT) {
96 fprintf(stderr, "do_mkdirat no parent failed: %d\n", ret);
97 goto err1;
98 }
99
100 ret = do_mkdirat(&ring, (const char *) (uintptr_t) 0x1234);
101 if (ret != -EFAULT) {
102 fprintf(stderr, "do_mkdirat bad address: %d\n", ret);
103 goto err1;
104 }
105
106 unlinkat(AT_FDCWD, fn, AT_REMOVEDIR);
107 io_uring_queue_exit(&ring);
108 return T_EXIT_PASS;
109skip:
110 unlinkat(AT_FDCWD, fn, AT_REMOVEDIR);
111 io_uring_queue_exit(&ring);
112 return T_EXIT_SKIP;
113err1:

Callers

nothing calls this directly

Calls 4

io_uring_queue_initFunction · 0.85
do_mkdiratFunction · 0.85
io_uring_queue_exitFunction · 0.85
stat_fileFunction · 0.70

Tested by

no test coverage detected