Skip to content

Commit 6b46419

Browse files
oleremtorvalds
authored andcommitted
fat: add extended fileds to struct fat_boot_sector
Later we will need "state" field to check if volume was cleanly unmounted. Signed-off-by: Oleksij Rempel <bug-track@fisher-privat.net> Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 899bed0 commit 6b46419

2 files changed

Lines changed: 32 additions & 12 deletions

File tree

‎fs/fat/inode.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,17 +1298,17 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
12981298
sbi->prev_free = FAT_START_ENT;
12991299
sb->s_maxbytes = 0xffffffff;
13001300

1301-
if (!sbi->fat_length && b->fat32_length) {
1301+
if (!sbi->fat_length && b->fat32.length) {
13021302
struct fat_boot_fsinfo *fsinfo;
13031303
struct buffer_head *fsinfo_bh;
13041304

13051305
/* Must be FAT32 */
13061306
sbi->fat_bits = 32;
1307-
sbi->fat_length = le32_to_cpu(b->fat32_length);
1308-
sbi->root_cluster = le32_to_cpu(b->root_cluster);
1307+
sbi->fat_length = le32_to_cpu(b->fat32.length);
1308+
sbi->root_cluster = le32_to_cpu(b->fat32.root_cluster);
13091309

13101310
/* MC - if info_sector is 0, don't multiply by 0 */
1311-
sbi->fsinfo_sector = le16_to_cpu(b->info_sector);
1311+
sbi->fsinfo_sector = le16_to_cpu(b->fat32.info_sector);
13121312
if (sbi->fsinfo_sector == 0)
13131313
sbi->fsinfo_sector = 1;
13141314

‎include/uapi/linux/msdos_fs.h‎

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,34 @@ struct fat_boot_sector {
120120
__le32 hidden; /* hidden sectors (unused) */
121121
__le32 total_sect; /* number of sectors (if sectors == 0) */
122122

123-
/* The following fields are only used by FAT32 */
124-
__le32 fat32_length; /* sectors/FAT */
125-
__le16 flags; /* bit 8: fat mirroring, low 4: active fat */
126-
__u8 version[2]; /* major, minor filesystem version */
127-
__le32 root_cluster; /* first cluster in root directory */
128-
__le16 info_sector; /* filesystem info sector */
129-
__le16 backup_boot; /* backup boot sector */
130-
__le16 reserved2[6]; /* Unused */
123+
union {
124+
struct {
125+
/* Extended BPB Fields for FAT16 */
126+
__u8 drive_number; /* Physical drive number */
127+
__u8 state; /* undocumented, but used
128+
for mount state. */
129+
/* other fiealds are not added here */
130+
} fat16;
131+
132+
struct {
133+
/* only used by FAT32 */
134+
__le32 length; /* sectors/FAT */
135+
__le16 flags; /* bit 8: fat mirroring,
136+
low 4: active fat */
137+
__u8 version[2]; /* major, minor filesystem
138+
version */
139+
__le32 root_cluster; /* first cluster in
140+
root directory */
141+
__le16 info_sector; /* filesystem info sector */
142+
__le16 backup_boot; /* backup boot sector */
143+
__le16 reserved2[6]; /* Unused */
144+
/* Extended BPB Fields for FAT32 */
145+
__u8 drive_number; /* Physical drive number */
146+
__u8 state; /* undocumented, but used
147+
for mount state. */
148+
/* other fiealds are not added here */
149+
} fat32;
150+
};
131151
};
132152

133153
struct fat_boot_fsinfo {

0 commit comments

Comments
 (0)