* [PATCH] FAT: Rename ambiguous fat_sectors and fat_total_sect fields
@ 2026-04-18 13:08 Ziran Zhang
0 siblings, 0 replies; only message in thread
From: Ziran Zhang @ 2026-04-18 13:08 UTC (permalink / raw)
To: hirofumi; +Cc: linux-kernel, zhangcoder
The fields 'fat_sectors' (BPB_TotSec16) and 'fat_total_sect'
(BPB_TotSec32) in struct fat_bios_param_block have ambiguous
names that do not clearly indicate their size or purpose, often
leading to confusion with FAT table sectors.
These fields correspond to BPB_TotSec16 and BPB_TotSec32 as
defined in Microsoft's fatgen103.doc.
Rename them for clarity:
- fat_sectors → fat_total_sect16 (16-bit total sector count)
- fat_total_sect → fat_total_sect32 (32-bit total sector count)
This makes their roles immediately obvious. No functional change,
and the struct is internal to the kernel so ABI is unaffected.
Signed-off-by: Ziran Zhang <zhangcoder@yeah.net>
---
fs/fat/inode.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 28f78df08..90286ba0e 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -47,9 +47,9 @@ struct fat_bios_param_block {
u16 fat_reserved;
u8 fat_fats;
u16 fat_dir_entries;
- u16 fat_sectors;
+ u16 fat_total_sect16;
u16 fat_fat_length;
- u32 fat_total_sect;
+ u32 fat_total_sect32;
u8 fat16_state;
u32 fat16_vol_id;
@@ -1403,9 +1403,9 @@ static int fat_read_bpb(struct super_block *sb, struct fat_boot_sector *b,
bpb->fat_reserved = le16_to_cpu(b->reserved);
bpb->fat_fats = b->fats;
bpb->fat_dir_entries = get_unaligned_le16(&b->dir_entries);
- bpb->fat_sectors = get_unaligned_le16(&b->sectors);
+ bpb->fat_total_sect16 = get_unaligned_le16(&b->sectors);
bpb->fat_fat_length = le16_to_cpu(b->fat_length);
- bpb->fat_total_sect = le32_to_cpu(b->total_sect);
+ bpb->fat_total_sect32 = le32_to_cpu(b->total_sect);
bpb->fat16_state = b->fat16.state;
bpb->fat16_vol_id = get_unaligned_le32(b->fat16.vol_id);
@@ -1523,7 +1523,7 @@ static int fat_read_static_bpb(struct super_block *sb,
bpb->fat_reserved = 1;
bpb->fat_fats = 2;
bpb->fat_dir_entries = fdefaults->dir_entries;
- bpb->fat_sectors = fdefaults->nr_sectors;
+ bpb->fat_total_sect16 = fdefaults->nr_sectors;
bpb->fat_fat_length = fdefaults->fat_length;
error = 0;
@@ -1734,9 +1734,9 @@ int fat_fill_super(struct super_block *sb, struct fs_context *fc,
rootdir_sectors = sbi->dir_entries
* sizeof(struct msdos_dir_entry) / sb->s_blocksize;
sbi->data_start = sbi->dir_start + rootdir_sectors;
- total_sectors = bpb.fat_sectors;
+ total_sectors = bpb.fat_total_sect16;
if (total_sectors == 0)
- total_sectors = bpb.fat_total_sect;
+ total_sectors = bpb.fat_total_sect32;
total_clusters = (total_sectors - sbi->data_start) / sbi->sec_per_clus;
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-18 13:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-18 13:08 [PATCH] FAT: Rename ambiguous fat_sectors and fat_total_sect fields Ziran Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox