1 /** 2 * @file fcntl.h 3 * @author fslongjin (longjin@RinGoTek.cn) 4 * @brief 5 * @version 0.1 6 * @date 2022-04-26 7 * 8 * @copyright Copyright (c) 2022 9 * 10 */ 11 #pragma once 12 13 #define O_RDONLY 00000000 // Open Read-only 14 #define O_WRONLY 00000001 // Open Write-only 15 #define O_RDWR 00000002 // Open read/write 16 #define O_ACCMODE 00000003 // Mask for file access modes 17 18 #define O_CREAT 00000100 // Create file if it does not exist 19 #define O_EXCL 00000200 // Fail if file already exists 20 #define O_NOCTTY 00000400 // Do not assign controlling terminal 21 22 #define O_TRUNC 00001000 // 文件存在且是普通文件,并以O_RDWR或O_WRONLY打开,则它会被清空 23 24 #define O_APPEND 00002000 // 文件指针会被移动到文件末尾 25 26 #define O_NONBLOCK 00004000 // 非阻塞式IO模式 27 28 #define O_EXEC 00010000 // 以仅执行的方式打开(非目录文件) 29 #define O_SEARCH 00020000 // Open the directory for search only 30 #define O_DIRECTORY 00040000 // 打开的必须是一个目录 31 #define O_NOFOLLOW 00100000 // Do not follow symbolic links 32 33 /* 34 * The constants AT_REMOVEDIR and AT_EACCESS have the same value. AT_EACCESS is 35 * meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to 36 * unlinkat. The two functions do completely different things and therefore, 37 * the flags can be allowed to overlap. For example, passing AT_REMOVEDIR to 38 * faccessat would be undefined behavior and thus treating it equivalent to 39 * AT_EACCESS is valid undefined behavior. 40 */ 41 // 作为当前工作目录的文件描述符(用于指代cwd) 42 #define AT_FDCWD -100 43 #define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */ 44 #define AT_EACCESS 0x200 /* Test access permitted for effective IDs, not real IDs. */ 45 #define AT_REMOVEDIR 0x200 /* Remove directory instead of unlinking file. */ 46 #define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */ 47 #define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount traversal */ 48 #define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname */ 49 50 #define AT_STATX_SYNC_TYPE 0x6000 /* Type of synchronisation required from statx() */ 51 #define AT_STATX_SYNC_AS_STAT 0x0000 /* - Do whatever stat() does */ 52 #define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */ 53 #define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */ 54 55 #define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */