ref: 1e8c6d3d412ce472d3173a78e285697b71803fb5
parent: c9d2ce7b1c7156501793e4b7aa41862b1ade561a
author: cinap_lenrek <[email protected]>
date: Fri Mar 9 01:10:08 EST 2012
disk/mbr: always use 512 byte sectors (imported changes from sources)
--- a/sys/src/cmd/disk/mbr.c
+++ b/sys/src/cmd/disk/mbr.c
@@ -145,10 +145,16 @@
if(disk->type == Tfloppy)
fatal("will not install mbr on floppy");
- if(disk->secsize != 512)
- fatal("secsize %d invalid", disk->secsize);
+ /*
+ * we need to cope with 4k-byte sectors on some newer disks.
+ * we're only interested in 512 bytes of mbr, so
+ * on 4k disks, rely on /dev/sd to read-modify-write.
+ */
+ secsize = 512;
+ if(disk->secsize != secsize)
+ fprint(2, "%s: sector size %lld not %ld, should be okay\n",
+ argv0, disk->secsize, secsize);
- secsize = disk->secsize;
buf = malloc(secsize*(disk->s+1));
mbr = malloc(secsize*disk->s);
if(buf == nil || mbr == nil)