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

Function test_rdonly

test/cmd-discard.c:297–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297static int test_rdonly(struct io_uring *ring, int op)
298{
299 int ret, fd;
300 int ro;
301
302 if (!opcodes[op].test)
303 return T_EXIT_SKIP;
304
305 fd = open(filename, O_DIRECT | O_RDONLY | O_EXCL);
306 if (fd < 0) {
307 if (errno == EINVAL || errno == EBUSY)
308 return T_EXIT_SKIP;
309 fprintf(stderr, "open failed %i\n", errno);
310 return T_EXIT_FAIL;
311 }
312
313 ret = queue_discard_lba(ring, fd, 0, 1);
314 if (ret >= 0) {
315 fprintf(stderr, "discarded with O_RDONLY %i\n", ret);
316 return 1;
317 }
318 close(fd);
319
320 fd = open(filename, O_DIRECT | O_RDWR | O_EXCL);
321 if (fd < 0) {
322 if (errno == EINVAL || errno == EBUSY)
323 return T_EXIT_SKIP;
324 fprintf(stderr, "open failed %i\n", errno);
325 return T_EXIT_FAIL;
326 }
327
328 ro = 1;
329 ret = ioctl(fd, BLKROSET, &ro);
330 if (ret) {
331 fprintf(stderr, "BLKROSET 1 failed %i\n", errno);
332 return T_EXIT_FAIL;
333 }
334
335 ret = queue_discard_lba(ring, fd, 0, 1);
336 if (ret >= 0) {
337 fprintf(stderr, "discarded with O_RDONLY %i\n", ret);
338 return 1;
339 }
340
341 ro = 0;
342 ret = ioctl(fd, BLKROSET, &ro);
343 if (ret) {
344 fprintf(stderr, "BLKROSET 0 failed %i\n", errno);
345 return T_EXIT_FAIL;
346 }
347 close(fd);
348 return 0;
349}
350
351int main(int argc, char *argv[])
352{

Callers 1

mainFunction · 0.85

Calls 1

queue_discard_lbaFunction · 0.85

Tested by

no test coverage detected