xiaoxiang781216 commented on code in PR #19238: URL: https://github.com/apache/nuttx/pull/19238#discussion_r3493155767
########## include/nuttx/fs/hostfs.h: ########## @@ -76,20 +76,34 @@ /* These must exactly match the definitions from include/fcntl.h: */ -#define NUTTX_O_RDONLY (1 << 0) /* Open for read access (only) */ -#define NUTTX_O_WRONLY (1 << 1) /* Open for write access (only) */ -#define NUTTX_O_CREAT (1 << 2) /* Create file/sem/mq object */ -#define NUTTX_O_EXCL (1 << 3) /* Name must not exist when opened */ -#define NUTTX_O_APPEND (1 << 4) /* Keep contents, append to end */ -#define NUTTX_O_TRUNC (1 << 5) /* Delete contents */ -#define NUTTX_O_NONBLOCK (1 << 6) /* Don't wait for data */ -#define NUTTX_O_SYNC (1 << 7) /* Synchronize output on write */ -#define NUTTX_O_TEXT (1 << 8) /* Open the file in text (translated) mode. */ -#define NUTTX_O_DIRECT (1 << 9) /* Avoid caching, write directly to hardware */ -#define NUTTX_O_CLOEXEC (1 << 10) /* Close on execute */ -#define NUTTX_O_DIRECTORY (1 << 11) /* Must be a directory */ - -#define NUTTX_O_RDWR (NUTTX_O_RDONLY | NUTTX_O_WRONLY) +#define NUTTX_O_RDONLY (0 << 0) /* Open for read access (only) */ +#define NUTTX_O_WRONLY (1 << 0) /* Open for write access (only) */ +#define NUTTX_O_RDWR (2 << 0) /* Open for both read & write access */ +#define NUTTX_O_ACCMODE (3 << 0) /* Mask for access mode */ +#define NUTTX_O_TEXT (1 << 5) /* Open the file in text (translated) mode. */ Review Comment: This change actually improve the compatibility with other major OS: | Constant | NuttX (before) | NuttX (after) | Linux | glibc | FreeBSD | macOS | |-------------|---------------|---------------|-------|-------|---------|-------| | `O_RDONLY` | `1` | `0` | `0` | `0` | `0` | `0` | | `O_WRONLY` | `2` | `1` | `1` | `1` | `1` | `1` | | `O_RDWR` | `3` | `2` | `2` | `2` | `2` | `2` | | `O_ACCMODE` | `3` | `3` | `3` | `3` | `3` | `3` | Many 3rd party libraries have to modified to work with NuttX just because NuttX defines O_RDONLY/O_WRONLY/O_RDWR to different values. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
