From: Ziran Zhang <zhangcoder@yeah.net>
To: hirofumi@mail.parknet.co.jp
Cc: linux-kernel@vger.kernel.org, zhangcoder@yeah.net
Subject: [PATCH] FAT: Rename ambiguous fat_sectors and fat_total_sect fields
Date: Sat, 18 Apr 2026 21:08:45 +0800 [thread overview]
Message-ID: <20260418130845.7365-1-zhangcoder@yeah.net> (raw)
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
next reply other threads:[~2026-04-18 13:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-18 13:08 Ziran Zhang [this message]
2026-04-25 17:56 ` [PATCH] FAT: Rename ambiguous fat_sectors and fat_total_sect fields OGAWA Hirofumi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260418130845.7365-1-zhangcoder@yeah.net \
--to=zhangcoder@yeah.net \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.