summaryrefslogtreecommitdiffstats
path: root/include/fcntl.h
blob: a746471411b5f49ccc49e45e5832f4f66fd2074f (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __FCNTL_H
#define __FCNTL_H

#include <linux/types.h>

#define AT_FDCWD		-100    /* Special value used to indicate
                                           openat should use the current
                                           working directory. */

#define AT_REMOVEDIR		0x200   /* Remove directory instead of
                                           unlinking file.  */

/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
   located on an ext2 file system */
#define O_ACCMODE	00000003
#define O_RDONLY	00000000
#define O_WRONLY	00000001
#define O_RDWR		00000002
#define O_CREAT		00000100	/* not fcntl */
#define O_EXCL		00000200	/* not fcntl */
#define O_TRUNC		00001000	/* not fcntl */
#define O_APPEND	00002000
#define O_DIRECTORY	00200000	/* must be a directory */
#define O_NOFOLLOW	00400000	/* don't follow links */

/* barebox additional flags */
#define O_RWSIZE_MASK	017000000
#define O_RWSIZE_SHIFT	18
#define O_RWSIZE_1	001000000
#define O_RWSIZE_2	002000000
#define O_RWSIZE_4	004000000
#define O_RWSIZE_8	010000000

#define __O_TMPFILE	020000000
#define O_PATH		040000000	/* open as path */
#define O_CHROOT	0100000000	/* dirfd: stay within filesystem root */

#define O_TMPFILE       (__O_TMPFILE | O_DIRECTORY)

int openat(int dirfd, const char *pathname, int flags);

static inline int open(const char *pathname, int flags, ...)
{
	return openat(AT_FDCWD, pathname, flags);
}

static inline int creat(const char *pathname, mode_t mode)
{
	return open(pathname, O_CREAT | O_WRONLY | O_TRUNC);
}

#endif /* __FCNTL_H */