hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/fat/fat.h
....@@ -142,6 +142,34 @@
142142 return sb->s_fs_info;
143143 }
144144
145
+/*
146
+ * Functions that determine the variant of the FAT file system (i.e.,
147
+ * whether this is FAT12, FAT16 or FAT32.
148
+ */
149
+static inline bool is_fat12(const struct msdos_sb_info *sbi)
150
+{
151
+ return sbi->fat_bits == 12;
152
+}
153
+
154
+static inline bool is_fat16(const struct msdos_sb_info *sbi)
155
+{
156
+ return sbi->fat_bits == 16;
157
+}
158
+
159
+static inline bool is_fat32(const struct msdos_sb_info *sbi)
160
+{
161
+ return sbi->fat_bits == 32;
162
+}
163
+
164
+/* Maximum number of clusters */
165
+static inline u32 max_fat(struct super_block *sb)
166
+{
167
+ struct msdos_sb_info *sbi = MSDOS_SB(sb);
168
+
169
+ return is_fat32(sbi) ? MAX_FAT32 :
170
+ is_fat16(sbi) ? MAX_FAT16 : MAX_FAT12;
171
+}
172
+
145173 static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
146174 {
147175 return container_of(inode, struct msdos_inode_info, vfs_inode);
....@@ -257,7 +285,7 @@
257285 const struct msdos_dir_entry *de)
258286 {
259287 int cluster = le16_to_cpu(de->start);
260
- if (sbi->fat_bits == 32)
288
+ if (is_fat32(sbi))
261289 cluster |= (le16_to_cpu(de->starthi) << 16);
262290 return cluster;
263291 }
....@@ -416,6 +444,10 @@
416444 __le16 __time, __le16 __date, u8 time_cs);
417445 extern void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts,
418446 __le16 *time, __le16 *date, u8 *time_cs);
447
+extern int fat_truncate_time(struct inode *inode, struct timespec64 *now,
448
+ int flags);
449
+extern int fat_update_time(struct inode *inode, struct timespec64 *now,
450
+ int flags);
419451 extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs);
420452
421453 int fat_cache_init(void);