Loading...
Searching...
No Matches
fcntl.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Eistec AB
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#ifndef DOXYGEN
19#if defined(CPU_NATIVE) || MODULE_NEWLIB || MODULE_PICOLIBC
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
26#include <sys/types.h> /* for mode_t, off_t */
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/* Constants used for the flags in fcntl and open */
33/* The names of the constants are defined by POSIX but most of these numbers
34 * were chosen somewhat arbitrarily */
35#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
36#define O_RDONLY 0 /* Read only */
37#define O_WRONLY 1 /* Write only */
38#define O_RDWR 2 /* Read+write */
39#define O_APPEND 0x0008 /* Set append mode */
40#define O_CREAT 0x0010 /* Create file if it does not exist */
41#define O_TRUNC 0x0020 /* Truncate flag */
42#define O_EXCL 0x0040 /* Exclusive use flag */
43
44#define F_DUPFD 0 /* Duplicate file descriptor */
45#define F_GETFD 1 /* Get file descriptor flags */
46#define F_SETFD 2 /* Set file descriptor flags */
47#define F_GETFL 3 /* Get file status flags */
48#define F_SETFL 4 /* Set file status flags */
49#define F_GETOWN 5 /* Get owner */
50#define F_SETOWN 6 /* Set owner */
51#define F_GETLK 7 /* Get record-locking information */
52#define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
53#define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
54
55#define FD_CLOEXEC 1 /* Close the file descriptor upon execution of an exec family function */
56
57int creat(const char *, mode_t);
58int fcntl(int, int, ...);
59int open(const char *, int, ...);
60int openat(int, const char *, int, ...);
61int posix_fadvise(int, off_t, off_t, int);
62int posix_fallocate(int, off_t, off_t);
63
64#ifdef __cplusplus
65}
66#endif
67
68#endif /* CPU_NATIVE */
69
70#endif /* DOXYGEN */
71