-/* $OpenBSD: disk.h,v 1.22 2021/05/07 22:15:13 krw Exp $ */
+/* $OpenBSD: disk.h,v 1.23 2021/06/25 19:24:53 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
uint32_t size;
};
+/* Align partition starts/sizes on 32K-byte boundaries. */
+#define BLOCKALIGNMENT 64
+
void DISK_open(int);
int DISK_printgeometry(char *);
char *DISK_readsector(off_t);
-/* $OpenBSD: fdisk.c,v 1.112 2021/06/23 13:07:13 krw Exp $ */
+/* $OpenBSD: fdisk.c,v 1.113 2021/06/25 19:24:53 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
parse_b(optarg, &b_sectors, &b_offset, &b_type);
break;
case 'l':
- l_arg = strtonum(optarg, 64, UINT32_MAX, &errstr);
+ l_arg = strtonum(optarg, BLOCKALIGNMENT, UINT32_MAX, &errstr);
if (errstr)
- errx(1, "Block argument %s [64..%u].", errstr,
- UINT32_MAX);
- disk.cylinders = l_arg / 64;
+ errx(1, "Block argument %s [%u..%u].", errstr,
+ BLOCKALIGNMENT, UINT32_MAX);
+ disk.cylinders = l_arg / BLOCKALIGNMENT;
disk.heads = 1;
- disk.sectors = 64;
+ disk.sectors = BLOCKALIGNMENT;
disk.size = l_arg;
break;
case 'y':
if (l_arg % bps != 0)
l_arg += bps - l_arg % bps;
l_arg = DL_BLKTOSEC(&dl, l_arg);
- disk.cylinders = l_arg / 64;
+ disk.cylinders = l_arg / BLOCKALIGNMENT;
disk.heads = 1;
- disk.sectors = 64;
+ disk.sectors = BLOCKALIGNMENT;
disk.size = l_arg;
}
-/* $OpenBSD: gpt.c,v 1.32 2021/06/21 02:05:30 krw Exp $ */
+/* $OpenBSD: gpt.c,v 1.33 2021/06/25 19:24:53 krw Exp $ */
/*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
if (rslt == -1)
goto done;
- if (start % 64)
- start += (64 - start % 64);
+ if (start % BLOCKALIGNMENT)
+ start += (BLOCKALIGNMENT - start % BLOCKALIGNMENT);
if (start >= end)
goto done;
needed = sizeof(gp) / secsize + 2;
- /* Start usable LBA area on 64 sector boundary. */
- if (needed % 64)
- needed += (64 - (needed % 64));
+ if (needed % BLOCKALIGNMENT)
+ needed += (needed - (needed % BLOCKALIGNMENT));
gh.gh_sig = htole64(GPTSIGNATURE);
gh.gh_rev = htole32(GPTREVISION);
-/* $OpenBSD: misc.c,v 1.68 2021/06/20 18:44:19 krw Exp $ */
+/* $OpenBSD: misc.c,v 1.69 2021/06/25 19:24:53 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
uint32_t blockcount, blockoffset;
uint8_t partitiontype;
- blockoffset = 64;
+ blockoffset = BLOCKALIGNMENT;
partitiontype = DOSPTYP_EFISYS;
ptype = NULL;
- /* First number: # of sectors in boot partition. */
+ /* First number: # of 512-byte blocks in boot partition. */
poffset = strchr(arg, '@');
if (poffset != NULL)
*poffset++ = '\0';
*ptype++ = '\0';
}
- blockcount = strtonum(arg, 64, UINT32_MAX, &errstr);
+ blockcount = strtonum(arg, BLOCKALIGNMENT, UINT32_MAX, &errstr);
if (errstr)
- errx(1, "Block argument %s [64..%u].",
- errstr, UINT32_MAX);
+ errx(1, "Block argument %s [%u..%u].", errstr, BLOCKALIGNMENT,
+ UINT32_MAX);
if (poffset == NULL)
goto done;
- blockoffset = strtonum(poffset, 64, UINT32_MAX, &errstr);
+ /* Second number: # of 512-byte blocks to offset partition start. */
+ blockoffset = strtonum(poffset, BLOCKALIGNMENT, UINT32_MAX, &errstr);
if (errstr)
- errx(1, "Block offset argument %s "
- "[64..%u].", errstr, UINT32_MAX);
+ errx(1, "Block offset argument %s [%u..%u].", errstr,
+ BLOCKALIGNMENT, UINT32_MAX);
if (ptype == NULL)
goto done;