acassis opened a new pull request, #20419:
URL: https://github.com/apache/nuttx/pull/20419
## Summary
O_DIRECTORY, O_NOFOLLOW, O_NOATIME, O_CLOEXEC, __O_SYNC, O_PATH and
__O_TMPFILE are defined as shifts by 16 to 22 bits. Where int is 16 bits (AVR,
for example), these shifts exceed the width of the type: GCC evaluates them to
0, and the -Wshift-count-overflow warning is not shown because include/ is a
system include directory. The oflags argument of open() is an int, so it could
not carry those bits anyway.
As a result, on arch with int equal 16-bit opendir() opens directories
without O_DIRECTORY, so opening a mount point such as /proc fails with ENOENT,
and O_CLOEXEC and O_NOFOLLOW have no effect.
When UINT_MAX is 0xffff, use the unused bits 2 to 4 for O_DIRECTORY,
O_CLOEXEC and O_NOFOLLOW, define O_NOATIME and __O_SYNC as 0 (O_SYNC falls back
to O_DSYNC), and leave O_PATH and O_TMPFILE undefined, so that code which needs
them fails to build instead of silently opening with the wrong flags; nothing
in the tree uses them. _O_MAXBIT becomes
15. On bigger systems (32-bit, 64-bit) keep the original bit shift.
## Impact
Now opening /proc will work on AVR and on my retro computing CDP1802 port.
## Testing
```
$ cdp1802-unknown-elf-sim --rom nuttx.elf.bin --rom-size 32768 --banks 16
--symbols nuttx.elf
NuttShell (NSH) NuttX-13.1.0-RC0
nsh> ?
?
help usage: help [-v] [<cmd>]
? help quit uptime
free poweroff ps
nsh> free
free
total used free maxused maxfree nused nfree name
14376 3576 10800 4512 10000 16 2 Umem
nsh>
```
--
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]