casaroli opened a new pull request, #21824:
URL: https://github.com/apache/nuttx/pull/21824

   depends-on: apache/nuttx/pull/21819
   
   ## Summary
   
   `fs/mount/fs_procfs_mount.c` gives `g_mount_operations` for three procfs 
entries: `fs/mount`, `fs/blocks` and `fs/usage`. `fs/procfs/fs_procfs.c` uses 
it for each entry that is not excluded. But `fs/mount/Make.defs` and 
`fs/mount/CMakeLists.txt` build the file only when 
`CONFIG_FS_PROCFS_EXCLUDE_MOUNT` is not set. So 
`CONFIG_FS_PROCFS_EXCLUDE_MOUNT=y` alone does not link (qemu-armv8a:nsh, Make 
and CMake):
   
   ```
   aarch64-none-elf-ld: 
staging/libfs.a(fs_procfs.o):(.rodata.g_base_entries+0x50): undefined reference 
to `g_mount_operations'
   aarch64-none-elf-ld: 
staging/libfs.a(fs_procfs.o):(.rodata.g_base_entries+0x68): undefined reference 
to `g_mount_operations'
   ```
   
   This PR builds the file when at least one of the three entries is enabled, 
in Make and in CMake. In `mount_open()`, each relpath check gets its own `if`: 
with `fs/mount` excluded, the `else if` of `fs/blocks` attached to the 
`O_RDONLY` check above it, and `fs/usage` was accepted also when it was 
excluded. The file already compiles each entry under its own option, so nothing 
else changes.
   
   ## Impact
   
   - Configurations that exclude `fs/mount` but keep `fs/blocks` or `fs/usage` 
(NSH `df`) link again. No defconfig in the tree sets only 
`CONFIG_FS_PROCFS_EXCLUDE_MOUNT` (`DEFAULT_SMALL` sets all three), so no 
defconfig changes.
   - Other configurations build the same files as before.
   - Build-system and file-local change: the same for flat, protected and 
kernel builds and for every architecture.
   - Documentation/ does not name these options, so there is no documentation 
change.
   
   ## Testing
   
   qemu-armv8a:nsh, `EXTRAFLAGS="-Wno-cpp -Werror"` (CMake: `-DEXTRA_FLAGS`), 
master 562db43781f. M, B and U are `FS_PROCFS_EXCLUDE_MOUNT`, `_BLOCKS` and 
`_USAGE` (y = excluded). Make: aarch64-none-elf-gcc 14.2.1 on macOS. CMake: the 
CI docker image (`apache-nuttx-ci-linux`, aarch64-none-elf-gcc 13.2.1).
   
   | M B U | master, Make | this PR, Make | master, CMake | this PR, CMake |
   |---|---|---|---|---|
   | n n n (default) | OK | OK | - | OK |
   | y n n | undefined `g_mount_operations` | OK | undefined 
`g_mount_operations` | OK |
   | n y n | - | OK | - | - |
   | n n y | - | OK | - | - |
   | y y n | undefined `g_mount_operations` | OK | - | OK |
   | y n y | undefined `g_mount_operations` | OK | - | - |
   | n y y | - | OK | - | - |
   | y y y | - | OK | - | OK |
   
   The master builds use the nuttx-apps fix named below. All builds of this PR 
have no warnings. Run in QEMU (TCG), `cat` of the three files and the NSH `df`, 
`df -h` and `mount` commands:
   
   - default: `/proc/fs` has `blocks`, `mount` and `usage`; all three files and 
the three commands give the expected lists of /etc, /proc and /tmp.
   - `FS_PROCFS_EXCLUDE_MOUNT=y`: `/proc/fs` has `blocks` and `usage`; `cat 
/proc/fs/mount` fails with ENOENT; `fs/blocks`, `fs/usage`, `df` and `df -h` 
work; `mount` with no arguments prints its usage error, as NSH does without the 
mount list.
   
   nuttx-apps master does not build NSH with `FS_PROCFS_EXCLUDE_MOUNT=y` in 
this configuration either (`nsh_command.c: error: 'cmd_mount' undeclared`); the 
builds above use the fix for that, apache/nuttx-apps#NNNN. The other 
combinations do not need it.
   
   `tools/checkpatch.sh -c -u -m -g` passes. There is no test for the procfs 
entry options in nuttx-apps; a build of each combination is the check here.
   


-- 
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]

Reply via email to