summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDaniel Palmer <[email protected]>2026-03-11 07:06:18 +0900
committerTom Rini <[email protected]>2026-03-27 13:14:18 -0600
commit29cb951e8ca6a9feecd920da31af9f18918057fe (patch)
tree0d18f0274b747c0e454c8d32efbc4912b1627e40 /include
parentce98d46395b748ecaf9ca1398d3b7e78e123bfd7 (diff)
fs: fat: Refactor dirty flag handling
Refactor the dirty flag handling a little bit so an inline function is called instead of directly stuffing a value into the variable. This allows variable that holds the flag to be completely removed if its not used i.e. CONFIG_FAT_WIRTE=n Signed-off-by: Daniel Palmer <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/fat.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/fat.h b/include/fat.h
index bdf430f7067..40da0370a44 100644
--- a/include/fat.h
+++ b/include/fat.h
@@ -165,7 +165,9 @@ typedef struct {
int fatsize; /* Size of FAT in bits */
__u32 fatlength; /* Length of FAT in sectors */
__u16 fat_sect; /* Starting sector of the FAT */
+#ifdef CONFIG_FAT_WRITE
__u8 fat_dirty; /* Set if fatbuf has been modified */
+#endif
__u32 rootdir_sect; /* Start sector of root directory */
__u16 sect_size; /* Size of sectors in bytes */
__u16 clust_size; /* Size of clusters in sectors */
@@ -190,6 +192,30 @@ static inline u32 sect_to_clust(fsdata *fsdata, int sect)
return (sect - fsdata->data_begin) / fsdata->clust_size;
}
+static inline void fat_mark_clean(fsdata *fsdata)
+{
+#ifdef CONFIG_FAT_WRITE
+ fsdata->fat_dirty = 0;
+#endif
+}
+
+static inline void fat_mark_dirty(fsdata *fsdata)
+{
+#ifdef CONFIG_FAT_WRITE
+ fsdata->fat_dirty = 1;
+#endif
+}
+
+static inline bool fat_is_dirty(fsdata *fsdata)
+{
+#ifdef CONFIG_FAT_WRITE
+ if (fsdata->fat_dirty)
+ return true;
+#endif
+
+ return false;
+}
+
int file_fat_detectfs(void);
int fat_exists(const char *filename);
int fat_size(const char *filename, loff_t *size);