summaryrefslogtreecommitdiff
path: root/src/fcntl/open.c
blob: 14c12e1bd0095e98cf2d33f26e94a43e2b052d4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "sys/types.h"
#include <fcntl.h>
#include "sys/stat.h"	/* OH */
#include "errno.h"
#include "stdarg.h"
#include "_syscall.h"

int open(const char *path, int oflag, ...)
{
	SYSCALL_NUMBER(scno, open, -1);

	mode_t mode = 0;
	if (oflag & O_CREAT) {
		va_list ap;
		va_start(ap, oflag);
		mode = va_arg(ap, mode_t);
		va_end(ap);
	}

	int r = __syscall(scno, path, oflag, mode);
	if (r < 0) {
		errno = -r;
		return -1;
	}

	return r;
}
/*
POSIX(1)
*/