From: "Pali Rohár" <pali.rohar@gmail.com>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH] fat: Relax checks for sector size and media type
Date: Sun, 2 Sep 2018 15:19:32 +0200 [thread overview]
Message-ID: <20180902131932.11558-1-pali.rohar@gmail.com> (raw)
Windows fastfat.sys driver accepts also media types 0x00 and 0x01 and
sector sizes 128 and 256 bytes. Linux mkfs.fat can format disk also to
larger FAT sector sizes then 4096 bytes, therefore relax also upper limit
restriction.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
Source code of Windows 10 Anniversary Update fastfat.sys driver is now
available on github.
Check for valid media types in fastfat.sys is there:
https://github.com/Microsoft/Windows-driver-samples/blob/96eb96dfb613e4c745db6bd1f53a92fe7e2290fc/filesys/fastfat/fsctrl.c#L2601-L2611
And check for valid sector size is there:
https://github.com/Microsoft/Windows-driver-samples/blob/96eb96dfb613e4c745db6bd1f53a92fe7e2290fc/filesys/fastfat/fsctrl.c#L2542-L2547
---
fs/fat/inode.c | 4 +---
include/linux/msdos_fs.h | 2 +-
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index d6b81e31..f2556f71 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1506,9 +1506,7 @@ static int fat_read_bpb(struct super_block *sb, struct fat_boot_sector *b,
goto out;
}
- if (!is_power_of_2(bpb->fat_sector_size)
- || (bpb->fat_sector_size < 512)
- || (bpb->fat_sector_size > 4096)) {
+ if (!is_power_of_2(bpb->fat_sector_size)) {
if (!silent)
fat_msg(sb, KERN_ERR, "bogus logical sector size %u",
(unsigned)bpb->fat_sector_size);
diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
index b7a5d4c7..e5b3f613 100644
--- a/include/linux/msdos_fs.h
+++ b/include/linux/msdos_fs.h
@@ -7,6 +7,6 @@
/* media of boot sector */
static inline int fat_valid_media(u8 media)
{
- return 0xf8 <= media || media == 0xf0;
+ return 0xf8 <= media || media == 0xf0 || media == 0x00 || media == 0x01;
}
#endif /* !_LINUX_MSDOS_FS_H */
--
2.11.0
next reply other threads:[~2018-09-02 17:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-02 13:19 Pali Rohár [this message]
2018-09-03 7:17 ` [PATCH] fat: Relax checks for sector size and media type OGAWA Hirofumi
2018-09-03 7:40 ` Pali Rohár
2018-09-03 8:01 ` OGAWA Hirofumi
2018-09-03 8:04 ` Pali Rohár
2018-09-03 8:19 ` OGAWA Hirofumi
2018-09-12 10:17 ` Pali Rohár
2018-09-12 10:36 ` 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=20180902131932.11558-1-pali.rohar@gmail.com \
--to=pali.rohar@gmail.com \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-fsdevel@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).