Add test for creating a new file and add openc macro to use openat with the mode option
This commit is contained in:
20
sys.h
20
sys.h
@@ -13,11 +13,25 @@ intptr_t read(int32_t fd, const void* buf, intptr_t size);
|
||||
#define O_WRONLY 01
|
||||
#define O_RDWR 02
|
||||
#define AT_FDCWD -100
|
||||
|
||||
#if defined(__mips__)
|
||||
// linux/arch/mips/include/uapi/asm/fcntl.h
|
||||
#define O_APPEND 0x0008
|
||||
#define O_CREAT 0x0100 /* not fcntl */
|
||||
#define O_TRUNC 0x0200 /* not fcntl */
|
||||
#define O_EXCL 0x0400 /* not fcntl */
|
||||
#define O_NOCTTY 0x0800 /* not fcntl */
|
||||
#else
|
||||
// linux/include/uapi/asm-generic/fcntl.h
|
||||
#define O_CREAT 1<<6
|
||||
#define O_EXCL 1<<7
|
||||
#define O_NOCTTY 1<<8
|
||||
#define O_TRUNC 1<<9
|
||||
#define O_APPEND 1<<10
|
||||
#endif
|
||||
int32_t openat(int32_t fd, const char* filename, uint32_t flags, uint32_t mode);
|
||||
#define open(...) openat(AT_FDCWD, __VA_ARGS__, 0)
|
||||
//inline int32_t openat(int32_t fd, const char* filename, uint32_t flags) {return openat(fd, filename, flags, 0);}
|
||||
//inline int32_t open(const char* filename, uint32_t flags, uint32_t mode) {return openat(AT_FDCWD, filename, flags, mode);}
|
||||
//inline int32_t open(const char* filename, uint32_t flags) {return openat(AT_FDCWD, filename, flags, 0);}
|
||||
#define openc(...) openat(AT_FDCWD, __VA_ARGS__)
|
||||
|
||||
uint32_t fork();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user