fcntl.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Eistec AB
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
18 #ifndef DOXYGEN
19 #if defined(CPU_NATIVE) || MODULE_NEWLIB
20 /* If building on native or newlib we need to use the system header instead */
21 #pragma GCC system_header
22 /* without the GCC pragma above #include_next will trigger a pedantic error */
23 #include_next <fcntl.h>
24 #else
25 #ifndef FCNTL_H_
26 #define FCNTL_H_
27 
28 #include <sys/types.h> /* for mode_t, off_t */
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /* Constants used for the flags in fcntl and open */
35 /* The names of the constants are defined by POSIX but most of these numbers
36  * were chosen somewhat arbitrarily */
37 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
38 #define O_RDONLY 0 /* Read only */
39 #define O_WRONLY 1 /* Write only */
40 #define O_RDWR 2 /* Read+write */
41 #define O_APPEND 0x0008 /* Set append mode */
42 #define O_CREAT 0x0010 /* Create file if it does not exist */
43 #define O_TRUNC 0x0020 /* Truncate flag */
44 #define O_EXCL 0x0040 /* Exclusive use flag */
45 
46 #define F_DUPFD 0 /* Duplicate file descriptor */
47 #define F_GETFD 1 /* Get file descriptor flags */
48 #define F_SETFD 2 /* Set file descriptor flags */
49 #define F_GETFL 3 /* Get file status flags */
50 #define F_SETFL 4 /* Set file status flags */
51 #define F_GETOWN 5 /* Get owner */
52 #define F_SETOWN 6 /* Set owner */
53 #define F_GETLK 7 /* Get record-locking information */
54 #define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
55 #define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
56 
57 #define FD_CLOEXEC 1 /* Close the file descriptor upon execution of an exec family function */
58 
59 int creat(const char *, mode_t);
60 int fcntl(int, int, ...);
61 int open(const char *, int, ...);
62 int openat(int, const char *, int, ...);
63 int posix_fadvise(int, off_t, off_t, int);
64 int posix_fallocate(int, off_t, off_t);
65 
66 #ifdef __cplusplus
67 }
68 #endif
69 
70 #endif /* FCNTL_H_ */
71 
72 #endif /* CPU_NATIVE */
73 
74 #endif /* DOXYGEN */
75 
int32_t off_t
Used for file sizes and offsets.
Definition: msp430_types.h:86
uint32_t mode_t
Used for some file attributes.
Definition: msp430_types.h:84