From 3bc331b9c5c202496e187823568ef2e287fb3b21 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sat, 21 Mar 2026 10:42:00 +0000 Subject: [PATCH] lib: c: io: add fcntl.h --- lib/libc/include/fcntl.h | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 lib/libc/include/fcntl.h diff --git a/lib/libc/include/fcntl.h b/lib/libc/include/fcntl.h new file mode 100644 index 0000000..d590e14 --- /dev/null +++ b/lib/libc/include/fcntl.h @@ -0,0 +1,53 @@ +#ifndef FCNTL_H_ +#define FCNTL_H_ + +#define O_RDONLY 0x0000 /* open for reading only */ +#define O_WRONLY 0x0001 /* open for writing only */ +#define O_RDWR 0x0002 /* open for reading and writing */ +#define O_ACCMODE 0x0003 /* mask for above modes */ + +#define O_NONBLOCK 0x00000004 /* no delay */ +#define O_APPEND 0x00000008 /* set append mode */ + +#define O_SHLOCK 0x00000010 /* open with shared file lock */ +#define O_EXLOCK 0x00000020 /* open with exclusive file lock */ +#define O_ASYNC 0x00000040 /* signal pgrp when data ready */ +#define O_FSYNC O_SYNC /* source compatibility: do not use */ +#define O_NOFOLLOW 0x00000100 /* don't follow symlinks */ +#define O_CREAT 0x00000200 /* create if nonexistant */ +#define O_TRUNC 0x00000400 /* truncate to zero length */ +#define O_EXCL 0x00000800 /* error if already exists */ +#define O_RESOLVE_BENEATH \ + 0x00001000 /* only for open(2), same value as FMARK \ + */ + +#define O_EVTONLY \ + 0x00008000 /* descriptor requested for event notifications only */ + +#define O_NOCTTY 0x00020000 /* don't assign controlling terminal */ + +#define O_DIRECTORY 0x00100000 +#define O_SYMLINK 0x00200000 /* allow open of a symlink */ + +#define O_CLOEXEC 0x01000000 /* implicitly set FD_CLOEXEC */ + +#define O_NOFOLLOW_ANY 0x20000000 /* no symlinks allowed in path */ + +#define O_EXEC 0x40000000 /* open file for execute only */ +#define O_SEARCH (O_EXEC | O_DIRECTORY) /* open directory for search only */ + +#define AT_FDCWD -2 + +#define AT_EACCESS 0x0010 /* Use effective ids in access check */ +#define AT_SYMLINK_NOFOLLOW \ + 0x0020 /* Act on the symlink itself not the target */ +#define AT_SYMLINK_FOLLOW 0x0040 /* Act on target of symlink */ +#define AT_REMOVEDIR 0x0080 /* Path refers to directory */ +#define AT_REALDEV \ + 0x0200 /* Return real device inodes resides on for fstatat(2) */ +#define AT_FDONLY \ + 0x0400 /* Use only the fd and Ignore the path for fstatat(2) */ +#define AT_SYMLINK_NOFOLLOW_ANY \ + 0x0800 /* Path should not contain any symlinks */ + +#endif