diff options
Diffstat (limited to 'tests/unistd/access.c')
-rw-r--r-- | tests/unistd/access.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unistd/access.c b/tests/unistd/access.c new file mode 100644 index 00000000..89428610 --- /dev/null +++ b/tests/unistd/access.c @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <errno.h> +#include <unistd.h> + +int main() { + char* files[] = {"/readable", "/writeable", + "/allaccess", "/forbidden", "/nonexistent"}; + for (int i = 0; i < sizeof files / sizeof files[0]; i++) { + printf("F_OK(%s): %d\n", files[i], access(files[i], F_OK)); + printf("errno: %d\n", errno); + errno = 0; + printf("R_OK(%s): %d\n", files[i], access(files[i], R_OK)); + printf("errno: %d\n", errno); + errno = 0; + printf("X_OK(%s): %d\n", files[i], access(files[i], X_OK)); + printf("errno: %d\n", errno); + errno = 0; + printf("W_OK(%s): %d\n", files[i], access(files[i], W_OK)); + printf("errno: %d\n", errno); + errno = 0; + printf("\n"); + } + return 0; +} |