-.\" $OpenBSD: fdisk.8,v 1.101 2021/06/21 02:05:30 krw Exp $
+.\" $OpenBSD: fdisk.8,v 1.102 2021/06/22 14:01:58 krw Exp $
.\"
.\"
.\" Copyright (c) 1997 Tobias Weingartner
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 21 2021 $
+.Dd $Mdocdate: June 22 2021 $
.Dt FDISK 8
.Os
.Sh NAME
and
.Sq HiFive BBL .
.It Fl b Ar blocks Ns Op @ Ns Ar offset Ns Op : Ns Ar type
-A special boot partition of the specified size, offset and type will be written to disk.
+Configures a special boot partition of the specified number of blocks, offset
+and type.
+.Ar offset
+defaults to the first available block, and
+.Ar type
+defaults to
+.Sq EF .
+.Pp
The
.Ox
-partition will follow the boot partition and use the remaining space on the disk.
+partition will follow the boot partition and use the remaining
+available space.
.Pp
Can only be used when initializing a disk with
.Fl i Op Fl g
If a GPT is being initialized
only the
.Ar blocks
-value will be used, with the boot partition being placed at the first available LBA and
-given the type EFI SYS.
+value is used.
.It Xo
.Fl c Ar cylinders
.Fl h Ar heads
-/* $OpenBSD: fdisk.c,v 1.110 2021/06/21 02:05:30 krw Exp $ */
+/* $OpenBSD: fdisk.c,v 1.111 2021/06/22 14:01:58 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/types.h>
+#include <sys/param.h> /* DEV_BSIZE */
#include <sys/disklabel.h>
#include <err.h>
{
ssize_t len;
int ch, fd, efi, error;
+ unsigned int bps;
int e_flag = 0, g_flag = 0, i_flag = 0, u_flag = 0;
int verbosity = TERSE;
int c_arg = 0, h_arg = 0, s_arg = 0;
disk.name = argv[0];
DISK_open(A_flag || i_flag || u_flag || e_flag);
+ bps = DL_BLKSPERSEC(&dl);
+ if (b_sectors > 0) {
+ if (b_sectors % bps != 0)
+ b_sectors += bps - b_sectors % bps;
+ if (b_offset % bps != 0)
+ b_offset += bps - b_offset % bps;
+ b_sectors = DL_BLKTOSEC(&dl, b_sectors);
+ b_offset = DL_BLKTOSEC(&dl, b_offset);
+ }
/* "proc exec" for man page display */
if (pledge("stdio rpath wpath disklabel proc exec", NULL) == -1)