src/aio-dio-regress/: spdx license conversion
[xfstests-dev.git] / src / aio-dio-regress / aio-io-setup-with-nonwritable-context-pointer.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2007 Jeff Moyer
4  */
5
6 /*
7  *  Test what happens when a non-writable context pointer is passed to io_setup
8  *
9  *  Description: Pass a non-writable context pointer to io_setup to see if
10  *  the kernel deals with it correctly.  In the past, the reference counting
11  *  in this particular error path was off and this operation would cause an
12  *  oops.
13  *
14  *  This is a destructive test.
15  */
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <sys/mman.h>
19 #include <libgen.h>
20 #include <libaio.h>
21
22 int
23 main(int __attribute__((unused)) argc, char **argv)
24 {
25         void *addr;
26
27         addr = mmap(NULL, 4096, PROT_READ, MAP_SHARED|MAP_ANONYMOUS, 0, 0);
28         if (addr == MAP_FAILED) {
29                 perror("mmap");
30                 exit(1);
31         }
32         io_setup(1, addr /* un-writable pointer */);
33
34         printf("%s: Success!\n", basename(argv[0]));
35         return 0;
36 }