fs: FAT: Add support for DOS 1.x formatted volumes
Subsystems (2)
PATCH v7 1/1 fs: FAT: Add support for DOS 1.x formatted volumes
Add structure for parsed BPB information, struct fat_bios_param_block, and move all of the deserialization and validation logic from fat_fill_super() into fat_read_bpb().
Add a 'dos1xfloppy' mount option to infer DOS 2.x BIOS Parameter Block defaults from block device geometry for ancient floppies and floppy images, as a fall-back from the default BPB parsing logic.
When fat_read_bpb() finds an invalid FAT filesystem and dos1xfloppy is set, fall back to fat_read_static_bpb(). fat_read_static_bpb() validates that the entire BPB is zero, and that the floppy has a DOS-style 8086 code bootstrapping header. Then it fills in default BPB values from media size and a table.[0]
Media size is assumed to be static for archaic FAT volumes. See also:
[1].
Fixes kernel.org bug #42617.
[0]: https://en.wikipedia.org/wiki/File_Allocation_Table#Exceptions
[1]: http://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html
---
Changes since v6:
* Update show_options()
* Add option documentation to Doc/filesystems/vfat.txt
Thanks.
--- Documentation/filesystems/vfat.txt | 5 + fs/fat/fat.h | 28 +++- fs/fat/inode.c | 318 ++++++++++++++++++++++++++++--------- 3 files changed, 274 insertions(+), 77 deletions(-)
Documentation/filesystems/vfat.txt +5 -0
@@ -172,6 +172,11 @@ nfs=stale_rw|nostale_ro To maintain backward compatibility, '-o nfs' is also accepted, defaulting to stale_rw +dos1xfloppy -- If set, use a fallback default BIOS Parameter Block + configuration, determined by backing device size. These static + parameters match defaults assumed by DOS 1.x for 160 kiB, + 180 kiB, 320 kiB, and 360 kiB floppies and floppy images. + <bool>: 0,1,yes,no,true,false
fs/fat/fat.h +27 -1
@@ -52,7 +52,8 @@ struct fat_mount_options { usefree:1, /* Use free_clusters for FAT32 */ tz_set:1, /* Filesystem timestamps' offset set */ rodir:1, /* allow ATTR_RO for directory */ - discard:1; /* Issue discard requests on deletions */ + discard:1, /* Issue discard requests on deletions */ + dos1xfloppy:1; /* Assume default BPB for DOS 1.x floppies */ };#define FAT_HASH_BITS 8
@@ -139,6 +140,31 @@ struct fat_slot_info {struct buffer_head *bh; }; +/* +* A deserialized copy of the on-disk structure laid out in struct +* fat_boot_sector. +*/ +struct fat_bios_param_block { +u16 fat_sector_size; +u8 fat_sec_per_clus; +u16 fat_reserved; +u8 fat_fats; +u16 fat_dir_entries; +u16 fat_sectors; +u16 fat_fat_length; +u32 fat_total_sect; + +u8 fat16_state; +u32 fat16_vol_id; + +u32 fat32_length; +u32 fat32_root_cluster; +u16 fat32_info_sector; +u8 fat32_state; +u32 fat32_vol_id; + +}; +static inline struct msdos_sb_info *MSDOS_SB (struct super_block *sb) {return sb->s_fs_info;
fs/fat/inode.c +242 -76
460 lines not on this page · raw message
Signature · 1 line
1.9.0
Quoted 14 lines · Conrad Meyer
fs/fat/fat.h +14
-0+/* +* A deserialized copy of the on-disk structure laid out in struct +* fat_boot_sector. +*/ +struct fat_bios_param_block { +u16 fat_sector_size; +u8 fat_sec_per_clus; +u16 fat_reserved; +u8 fat_fats; +u16 fat_dir_entries; +u16 fat_sectors; +u16 fat_fat_length; +u32 fat_total_sect; +
fs/fat/fat.h struct fat_slot_info { · line 166
Quoted 10 lines
fs/fat/fat.h +10
-0+u8 fat16_state; +u32 fat16_vol_id; + +u32 fat32_length; +u32 fat32_root_cluster; +u16 fat32_info_sector; +u8 fat32_state; +u32 fat32_vol_id; + +};
Looks good. But nobody use this structure except fat_fill_inode(). So, please move this into inode.c.
With above last change,
Thanks.
Signature · 1 line
OGAWA Hirofumi <[email protected]>