xref: /haiku/src/system/libroot/posix/unistd/access.c (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
1 /*
2  * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <unistd.h>
8 #include <syscalls.h>
9 #include <errno.h>
10 
11 
12 #define RETURN_AND_SET_ERRNO(err) \
13 	if (err < 0) { \
14 		errno = err; \
15 		return -1; \
16 	} \
17 	return err;
18 
19 
20 int
21 access(const char* path, int accessMode)
22 {
23 	status_t status = _kern_access(path, accessMode);
24 
25 	RETURN_AND_SET_ERRNO(status);
26 }
27