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

   ## Summary
   
   This PR adds an optional compile-time read-only mode for the FAT filesystem 
through `CONFIG_FS_FAT_READONLY`.
   
   When enabled:
   - Write-related operations (`write`, `truncate`, `sync`, `unlink`, `mkdir`, 
`rmdir`, and `rename`) are disabled in `g_fat_operations`.
   - `fat_open()` rejects write-capable and mutating open requests with 
`-EROFS`.
   - Read operations, directory enumeration, filesystem metadata access, and 
mount/unmount functionality remain available.
   
   The option defaults to `n`, so existing FAT behaviour remains unchanged 
unless explicitly enabled.
   
   The goal is to allow the linker to eliminate unused write-side functions and 
their helper call graph, reducing binary size on resource-constrained targets.
   
   The implementation follows the existing NULL-callback pattern used by ROMFS.
   
   ## Implementation
   
   - Added `CONFIG_FS_FAT_READONLY` to `fs/fat/Kconfig`, depending on `FS_FAT`.
   - Added conditional entries in `g_fat_operations` in `fs/fat/fs_fat32.c`.
   - Added checks in `fat_open()` to reject write-capable and mutating flags, 
including `O_WRONLY`, `O_RDWR`, `O_CREAT`, `O_TRUNC`, and `O_APPEND`.
   - Marked write-side functions as `unused` to avoid compiler warnings when 
they are not referenced.
   
   No changes were made to the default writable configuration.
   
   ## Testing
   
   **Completed:**
   - Compiled `fs/fat/fs_fat32.c` with `CONFIG_FS_FAT_READONLY=1` using NuttX 
compiler flags.
   - Verified conditional operations-table initializers compile successfully.
   - Reviewed FAT cache flags and writeback paths, including `fat_close()`, 
`fat_seek()`, and `fat_shared_release()`.
   - Traced VFS handling of NULL mountpoint callbacks.
   - Reviewed the implementation against the existing ROMFS read-only pattern.
   
   **Integration build status:**
   
   A full `sim:nsh` build was attempted but could not complete due to errors in 
`apps/nshlib/nsh_fscmds.c`:
   
   ```text
   call to undeclared function 'lib_get_pathbuffer'
   call to undeclared function 'lib_put_pathbuffer'
   ```
   
   These errors occur outside the FAT filesystem code and appear to be related 
to the build environment or repository version mismatch.
   
   **Pending validation:**
   - Build `sim:nsh` with read-only mode both enabled and disabled.
   - Test read operations and write rejection at runtime.
   - Verify the FAT image remains unchanged after read-only operations.
   - Compare binary sizes and linker symbols to confirm write-side code 
elimination.
   
   Full integration, runtime, and binary-size results are not yet available.


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