Skip to content

Commit

Permalink
fs/fat/: add support for DOS 1.x formatted volumes
Browse files Browse the repository at this point in the history
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

[[email protected]: fix missed error code]
Signed-off-by: Conrad Meyer <[email protected]>
Acked-by: OGAWA Hirofumi <[email protected]>
Signed-off-by: OGAWA Hirofumi <[email protected]>
Tested-by: Alan Cox <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
cemeyer authored and torvalds committed Jun 6, 2014
1 parent a19189e commit 190a884
Show file tree
Hide file tree
Showing 3 changed files with 274 additions and 77 deletions.
5 changes: 5 additions & 0 deletions Documentation/filesystems/vfat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion fs/fat/fat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 190a884

Please sign in to comment.