Pre-existing violations in this file, reported by checkpatch because the
preceding commit touches it, and requested by a reviewer.
Three "Missing blank line after declarations", in the BIOC_PARTINFO,
MTDIOC_ERASESTATE and register-time-erase blocks.
The rest were one problem: the whole mtd_loop_ioctl() switch body sits two
columns short of NuttX style. With `switch` at 2 and its brace at 4, case
labels belong at 6 — as they already are in filemtd_ioctl() earlier in this
same file — but here the comments and cases sit at 4 and everything under
them follows suit, which checkpatch reports as 21 separate comment,
alignment and brace errors. Reindented the block to match, including the
two stray closing lines that had drifted to seven and five columns.
Whitespace only: `git diff -w` is empty apart from the three added blank
lines, and the brace count is unchanged. checkpatch is clean against
master.
Signed-off-by: AlmAck <gluca86@gmail.com>
filemtd_initialize() opens its backing file with
mode = O_RDONLY | O_WRONLY | O_CLOEXEC;
Commit 6161c73639 introduced this when it replaced the non-standard
O_RDOK | O_WROK pair, describing the change as a pure text substitution.
That held while the access mode was a genuine bitmask: O_RDONLY was
(1 << 0), O_WRONLY was (1 << 1), and O_RDWR was both bits, so the OR
produced O_RDWR. O_ACCMODE was defined as an alias for O_RDWR.
Commit 9e141acab3 then aligned the flags with Linux. The low two bits
became an enumeration -- O_RDONLY 0, O_WRONLY 1, O_RDWR 2 -- and
O_ACCMODE stopped being an alias for O_RDWR and became an independent
mask of 3. OR-ing two members of that enumeration is no longer
meaningful: O_RDONLY | O_WRONLY evaluates to 1, and masking it with
O_ACCMODE yields O_WRONLY.
The file is therefore opened write-only, and fs_read.c rejects every
read on it with -EACCES. The failure does not name filemtd: on the
simulator it surfaces as a LittleFS mount of a filemtd-backed partition
returning -ENOSPC, after which nothing on that volume works.
This appears to be an isolated miss rather than a pattern. Grepping the
tree for the same construct -- two access-mode constants OR-ed together
-- finds only this one call site. The one remaining place that
bit-tests the mode, fs/xipfs/xipfs_vfs.c:606, happens to be correct
under the new values (and would have been wrong under the old ones).
The hostfs NUTTX_O_* mirror and host_oflags_convert() were updated in
lockstep and switch on the masked value.
Signed-off-by: AlmAck <gluca86@gmail.com>
Permissions (Part 2)
Description:
In kernel builds, any unprivileged process running on the NuttX
device can open /dev/efuse and attempt to read/write fuse content.
Reading the fuses may provide valuable information to an attacker
controlling the user process. The write operation, in extreme cases
where the fuse blocks are not locked, may brick the device.
DISCLAIMER: I tried to be strict with the settings, better to relax them
later if it's needed.
This is part of https://github.com/apache/nuttx/issues/19410
See https://github.com/apache/nuttx/issues/19410
Compiles ok.
Signed-off-by: Catalin Visinescu <catalin_visinescu@yahoo.com>
O_RDOK and O_WROK are non-standard aliases for O_RDONLY and O_WRONLY
respectively. Having two names for the same flag creates confusion,
especially when aligning the flag values with Linux. Remove the
aliases and replace all uses with the standard O_RDONLY/O_WRONLY.
No functional change — O_RDOK was defined as O_RDONLY and O_WROK as
O_WRONLY, so the replacement is a pure text substitution.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
debug.h is a NuttX-specific, non-POSIX header. Placing it in the
top-level include/ directory creates naming conflicts with external
projects that define their own debug.h.
This commit moves the canonical header to include/nuttx/debug.h,
following the NuttX convention for non-POSIX/non-standard headers,
and updates all in-tree references.
A backward-compatibility shim is left at include/debug.h that
emits a deprecation #warning and re-includes <nuttx/debug.h>,
allowing out-of-tree code to continue building while migrating.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
In previous versions, during the teardown phase, the "open_blockdriver" would call the "mtd proxy" causing the "file mtd" node to be registered in the ftl. " node is registered in ftl.
Therefore, we changed the behavior to find the corresponding inode by node name.
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
- fix memory leak during RAM MTD initialization
- fix calculations for FILE MTD device with customized
block and erase sizes
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
Ken Pettit has submitted the ICLA and we can migrate the licenses
to Apache.
Sebastien Lorquet has submitted the ICLA and we can migrate the licenses
to Apache.
Gregory Nutt has submitted the SGA and we can migrate the licenses
to Apache.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
* Simplify EINTR/ECANCEL error handling
1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx
* Unify the void cast usage
1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
many locations: Change occurences of open() followed by file_detach() to file_open(). Change most non-controversion calls to open() to nx_open().
fs/inode/fs_fileopen.c: Flesh out file_open() with some interim, placeholder logic.
fs/inode/fs_fileopen.c: Add a framework for a file_open() implementation (no real logic in place yet).
fs/vfs/fs_open.c: Add nx_open() which is the same as open() except that it does not create a cancellation point nor does it modify the errno variable.
drivers/mtd/filemtd.c: New new MTD conversion layer that will convert a regular file (or driver file) to an MTD device. This is useful for testing on the simulation using the hostfs.
From Ken Petit