following an invocation of MBR_read() with a call to MBR_parse().
No functional change.
-/* $OpenBSD: fdisk.c,v 1.124 2021/07/17 21:47:56 krw Exp $ */
+/* $OpenBSD: fdisk.c,v 1.125 2021/07/18 12:41:00 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
if (pledge("stdio rpath wpath disklabel proc exec", NULL) == -1)
err(1, "pledge");
- error = MBR_read(0, &dos_mbr);
+ error = MBR_read(0, 0, &mbr);
if (error)
- errx(1, "Can't read sector 0!");
- MBR_parse(&dos_mbr, 0, 0, &mbr);
+ errx(1, "Can't read MBR!");
/* Get the GPT if present. Either primary or secondary is ok. */
efi = MBR_protective_mbr(&mbr);
-/* $OpenBSD: mbr.c,v 1.87 2021/07/17 14:16:34 krw Exp $ */
+/* $OpenBSD: mbr.c,v 1.88 2021/07/18 12:41:00 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
}
int
-MBR_read(const uint64_t sector, struct dos_mbr *dos_mbr)
+MBR_read(const uint64_t lba_self, const uint64_t lba_firstembr, struct mbr *mbr)
{
+ struct dos_mbr dos_mbr;
char *secbuf;
- secbuf = DISK_readsector(sector);
+ secbuf = DISK_readsector(lba_self);
if (secbuf == NULL)
return -1;
- memcpy(dos_mbr, secbuf, sizeof(*dos_mbr));
+ memcpy(&dos_mbr, secbuf, sizeof(dos_mbr));
free(secbuf);
+ MBR_parse(&dos_mbr, lba_self, lba_firstembr, mbr);
+
return 0;
}
-/* $OpenBSD: mbr.h,v 1.35 2021/07/13 15:03:34 krw Exp $ */
+/* $OpenBSD: mbr.h,v 1.36 2021/07/18 12:41:00 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
void MBR_make(struct mbr *, struct dos_mbr *);
void MBR_init(struct mbr *);
void MBR_init_GPT(struct mbr *);
-int MBR_read(const uint64_t, struct dos_mbr *);
+int MBR_read(const uint64_t, const uint64_t, struct mbr *);
int MBR_write(const uint64_t, const struct dos_mbr *);
int MBR_protective_mbr(struct mbr *);
-/* $OpenBSD: user.c,v 1.63 2021/07/13 15:03:34 krw Exp $ */
+/* $OpenBSD: user.c,v 1.64 2021/07/18 12:41:00 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
void
USER_edit(const uint64_t lba_self, const uint64_t lba_firstembr)
{
- struct dos_mbr dos_mbr;
struct mbr mbr;
char *cmd, *args;
int i, st, efi, error;
/* One level deeper */
editlevel += 1;
- /* Read MBR & partition */
- error = MBR_read(lba_self, &dos_mbr);
+ error = MBR_read(lba_self, lba_firstembr, &mbr);
if (error == -1)
goto done;
- /* Parse the sucker */
- MBR_parse(&dos_mbr, lba_self, lba_firstembr, &mbr);
-
if (editlevel == 1) {
memset(&gh, 0, sizeof(gh));
memset(&gp, 0, sizeof(gp));
void
USER_print_disk(const int verbosity)
{
- struct dos_mbr dos_mbr;
struct mbr mbr;
uint64_t lba_self, lba_firstembr;
int i, efi, error;
lba_self = lba_firstembr = 0;
do {
- error = MBR_read(lba_self, &dos_mbr);
+ error = MBR_read(lba_self, lba_firstembr, &mbr);
if (error == -1)
break;
- MBR_parse(&dos_mbr, lba_self, lba_firstembr, &mbr);
if (lba_self == 0) {
efi = MBR_protective_mbr(&mbr);
if (efi == -1) {