summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_msdosfs
diff options
context:
space:
mode:
authorambrisko <ambrisko@FreeBSD.org>2014-10-30 15:52:01 +0000
committerambrisko <ambrisko@FreeBSD.org>2014-10-30 15:52:01 +0000
commit37cb22f7f4cfc363dfe7e014ca1155275ac2e55c (patch)
treeb14d3cd492a751e0926e63430e86630a6ba98b5b /sbin/fsck_msdosfs
parent5246b4d3f358eaea830cccd1c8695c8f66cc0499 (diff)
downloadFreeBSD-src-37cb22f7f4cfc363dfe7e014ca1155275ac2e55c.zip
FreeBSD-src-37cb22f7f4cfc363dfe7e014ca1155275ac2e55c.tar.gz
Make UEFI booting of 4Kn disks work:
- convert boot1.efi to corrrectly calculate the lba for what the media reports and convert the size based on what FreeBSD uses. The existing code would use the 512 byte lba and convert the size using 4K byte size. - make fsck_msdosfs read the boot block as 4K so the read doesn't fail on a 4Kn drive since FreeBSD will error out parition reads of a block. Make the bpbBytesPerSec check a multiple of 512 since it can be 512 or 4K depending on the disk. This allows fsck to pass checking the EFI partition on a 4Kn disk. To create the EFI file system I used: newfs_msdos -F 32 -S 4096 -c 1 -m 0xf8 <partition> This works for booting 512 and 4Kn disks. Caveat is that loader.efi cannot read the 4Kn EFI partition. This isn't critical right now since boot1.efi will read loader.efi from the ufs partition. It looks like loader.efi can be fixed via making some of the 512 bytes reads more flexible. loader.efi doesn't have trouble reading the ufs partition. This is probably a simple fix. I now have FreeBSD installed on a system with 4Kn drives and tested the same code works on 512. MFC after: 1 week
Diffstat (limited to 'sbin/fsck_msdosfs')
-rw-r--r--sbin/fsck_msdosfs/boot.c2
-rw-r--r--sbin/fsck_msdosfs/dosfs.h4
2 files changed, 4 insertions, 2 deletions
diff --git a/sbin/fsck_msdosfs/boot.c b/sbin/fsck_msdosfs/boot.c
index 3195183..b1760c5 100644
--- a/sbin/fsck_msdosfs/boot.c
+++ b/sbin/fsck_msdosfs/boot.c
@@ -181,7 +181,7 @@ readboot(int dosfs, struct bootblock *boot)
boot->bpbResSectors + boot->bpbFATs * boot->FATsecs -
CLUST_FIRST * boot->bpbSecPerClust;
- if (boot->bpbBytesPerSec % DOSBOOTBLOCKSIZE != 0) {
+ if (boot->bpbBytesPerSec % DOSBOOTBLOCKSIZE_REAL != 0) {
pfatal("Invalid sector size: %u", boot->bpbBytesPerSec);
return FSFATAL;
}
diff --git a/sbin/fsck_msdosfs/dosfs.h b/sbin/fsck_msdosfs/dosfs.h
index bd01b24..485b3a1 100644
--- a/sbin/fsck_msdosfs/dosfs.h
+++ b/sbin/fsck_msdosfs/dosfs.h
@@ -30,7 +30,9 @@
#ifndef DOSFS_H
#define DOSFS_H
-#define DOSBOOTBLOCKSIZE 512
+/* support 4Kn disk reads */
+#define DOSBOOTBLOCKSIZE_REAL 512
+#define DOSBOOTBLOCKSIZE 4096
typedef u_int32_t cl_t; /* type holding a cluster number */
OpenPOWER on IntegriCloud