-/* $OpenBSD: mbr.c,v 1.92 2021/07/19 19:30:35 krw Exp $ */
+/* $OpenBSD: mbr.c,v 1.93 2021/07/19 23:24:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
PRT_fix_BN(&mbr->mbr_prt[3], 3);
#if defined(__powerpc__) || defined(__mips__)
- /* Now fix up for the MS-DOS boot partition on PowerPC. */
+ /* Now fix up for the MS-DOS boot partition on PowerPC/MIPS. */
mbr->mbr_prt[0].prt_flag = DOSACTIVE; /* Boot from dos part */
mbr->mbr_prt[3].prt_flag = 0;
mbr->mbr_prt[3].prt_ns += mbr->mbr_prt[3].prt_bs;
-/* $OpenBSD: part.c,v 1.100 2021/07/18 21:40:13 krw Exp $ */
+/* $OpenBSD: part.c,v 1.101 2021/07/19 23:24:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
uint32_t start = 0;
uint32_t end = 0;
- /* Zero out entry if not used */
if (prt->prt_id == DOSPTYP_UNUSED) {
memset(prt, 0, sizeof(*prt));
return;
}
- /* Disk geometry. */
spt = disk.dk_sectors;
tpc = disk.dk_heads;
spc = spt * tpc;
uint32_t start, end, size;
uint32_t cyl, head, sect;
- /* Zero out entry if not used */
if (prt->prt_id == DOSPTYP_UNUSED || prt->prt_ns == 0) {
memset(prt, 0, sizeof(*prt));
return;
}
- /* Disk geometry. */
spt = disk.dk_sectors;
tpc = disk.dk_heads;
spc = spt * tpc;
size = prt->prt_ns;
end = (start + size) - 1;
- /* Figure out starting CHS values */
cyl = (start / spc); start -= (cyl * spc);
head = (start / spt); start -= (head * spt);
sect = (start + 1);
prt->prt_shead = head;
prt->prt_ssect = sect;
- /* Figure out ending CHS values */
cyl = (end / spc); end -= (cyl * spc);
head = (end / spt); end -= (head * spt);
sect = (end + 1);
-/* $OpenBSD: user.c,v 1.65 2021/07/18 15:28:37 krw Exp $ */
+/* $OpenBSD: user.c,v 1.66 2021/07/19 23:24:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
#include "gpt.h"
#include "disk.h"
-/* Our command table */
const struct cmd cmd_table[] = {
{"help", 1, Xhelp, "Command help list"},
{"manual", 1, Xmanual, "Show entire OpenBSD man page for fdisk"},
printf("Enter 'help' for information\n");
- /* Edit cycle */
again:
do {
printf("%s%s: %d> ", disk.dk_name, modified ? "*" : "", editlevel);
if (!strcmp(cmd, "?"))
i = 0;
- /* Check for valid command */
if ((cmd_table[i].cmd_name == NULL) || (letoh64(gh.gh_sig) ==
GPTSIGNATURE && cmd_table[i].cmd_gpt == 0)) {
printf("Invalid command '%s'. Try 'help'.\n", cmd);
continue;
}
- /* Call function */
st = cmd_table[i].cmd_fcn(args, &mbr);
/* Update status */
modified = 1;
} while (1);
- /* Write out MBR */
if (modified) {
if (st == CMD_SAVE) {
if (Xwrite(NULL, &mbr) == CMD_CONT)
}
done:
- /* One level less */
editlevel -= 1;
}
GPT_print("s", verbosity);
return;
} else {
- /*. Read & print both primary and secondary GPT. */
printf("Primary GPT:\n");
GPT_read(PRIMARYGPT);
if (letoh64(gh.gh_sig) == GPTSIGNATURE)
MBR_print(&mbr, NULL);
- /* Print out extended partitions too */
for (lba_self = i = 0; i < 4; i++)
if (mbr.mbr_prt[i].prt_id == DOSPTYP_EXTEND ||
mbr.mbr_prt[i].prt_id == DOSPTYP_EXTENDL) {
static char lbuf[100];
size_t cmdstart, cmdend, argstart;
- /* Get NUL terminated string from stdin. */
if (string_from_line(lbuf, sizeof(lbuf)))
errx(1, "eof");