[FEATURE] FAT: Add compile-time read-only configuration to reduce binary size

Abierto
#21,390 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
c

Línea de trabajo

Start with the g_fat_operations table in fs/fat/fs_fat32.c to see which write entry points it references, then read fs/fat/Kconfig to see where a new CONFIG_FS_FAT_READONLY option would sit. Done means that with the option enabled, write operations return -EROFS, the write-only helpers are compiled out, and read and directory paths behave as before. With the option disabled, the build should be unchanged. Agree the scope with maintainers first, since the issue does not list which functions to remove.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Type: Enhancement
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
  • I have verified before submitting the report.
Lenguaje dominante
C
Estrellas
4.1k
Forks
1.7k
Merge medio
1 d 3 h
PR fusionados (30 d)
786

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/nuttx

Todos los issues de apache/nuttx

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.