xref: /haiku/src/system/libroot/posix/sys/mkdir.c (revision e6b30aee0fd7a23d6a6baab9f3718945a0cd838a)
1 /*
2  * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <sys/stat.h>
8 #include <syscalls.h>
9 #include <errno.h>
10 
11 
12 extern mode_t __gUmask;
13 	// declared in sys/umask.c
14 
15 
16 #define RETURN_AND_SET_ERRNO(err) \
17 	if (err < 0) { \
18 		errno = err; \
19 		return -1; \
20 	} \
21 	return err;
22 
23 
24 int
25 mkdir(const char* path, mode_t mode)
26 {
27 	status_t status = _kern_create_dir(-1, path, mode & ~__gUmask);
28 
29 	RETURN_AND_SET_ERRNO(status);
30 }
31