arnavsharma990 opened a new issue, #21390:
URL: https://github.com/apache/nuttx/issues/21390

   ### Is your feature request related to a problem? Please describe.
   
   Currently, FAT keeps its write-side functions reachable through 
`g_fat_operations` in `fs/fat/fs_fat32.c`, even when an application only needs 
read access.
   
   This prevents the linker from removing unused write-related code, increasing 
binary size on resource-constrained targets.
   
   There is currently no compile-time read-only option in `fs/fat/Kconfig`. The 
existing `FATATTR_READONLY` attribute only applies to individual files.
   
   This also relates to the binary-size discussion in #20414.
   
   ### Describe the solution you'd like
   
   Introduce an optional `CONFIG_FS_FAT_READONLY` configuration.
   
   When enabled, it should:
   - Exclude unnecessary write-side functions and helpers at compile time.
   - Reject write operations gracefully, preferably with `-EROFS`.
   - Preserve normal read operations, directory enumeration and filesystem 
lifecycle.
   
   The implementation should also ensure that write-related references in 
`g_fat_operations` don't prevent dead-code elimination.
   
   The existing FAT behaviour should remain unchanged when the option is 
disabled.
   
   ### Describe alternatives you've considered
   
   - Relying on linker garbage collection alone, which cannot remove functions 
referenced by the operations table.
   - Using `FATATTR_READONLY`, which only protects individual files.
   - Runtime read-only handling, which doesn't eliminate the unused write-side 
code.
   
   A compile-time option seems more suitable for systems that never need FAT 
write functionality.
   
   ### Verification
   
   - [x] I have verified before submitting the report.


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