This has the following advantages:
- faster and leaner when C11 atomics are not efficient (e.g. on LLVM
this is almost always the case, as LLVM will only use efficient
atomics if it doesn't has to bail out to library calls even for
exotic things)
- Even for GCC e.g. on the nucleo-f429zi this safes 72 B of .text
for examples/filesystem despite runtime checks added for
over- and underflow
- less pain in the ass for C++ and rust users, as both C++ and
c2rust are incompatible with C11 atomics
- adds test for overflow of the open file counter for more robust
operation
- adds `assumes()` so that underflows are detected in non-production
code
Adds a separate board for native64 instead of the `NATIVE_64BIT` workaround.
The files in `boards/native64` are more or less dummy files and just include
the `boards/native` logic (similar to `openlabs-kw41z-mini-256kib`).
The main logic for native is in `makefiles/arch/native.inc.mk`, `cpu/native`
and `boards/native`.
The remaining changes concern the build system, and change native board checks
to native CPU checks to cover both boards.
18682: pkg/lwext4: add lightweight implementation of the ext2/3/4 filesystem r=benpicco a=benpicco
Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
`vfs_sysop_stat_from_fstat()` is a fallback implementation of `stat()`
based on `fstat()`.
It will open a file and call `fstat()`.
This fails if the target is not a file but a directory, which means that
directories are not recognized as such.
To fix this, try to open the path as a directory if opening it as a file
fails. If this succeeds, set the `S_IFDIR` flag.
This is a cosmetic change when considering vfs_iterate_mounts alone
(which now reports FSs in precise mount order rather than reporting the
most recently mounted, followed by the rest in mount order), but is
helpful for uses of it that need some guarantees in order to produce
reliable results even when iteration and (un)mounting interact.
No current file system implements it, there is no defined semantic
difference between running fstatfs and the fallback currently
implemented, and there is practically no optimization gained from not
just running it through a single statvfs.
When a file system has `fstat` and `open` implemented, `stat` can still
be missing. The new function is a generic implementation, and used in
fatfs to provide a `stat`.