From 0367a74fd1e633c6f4cbb792cfa05a18d8cf6673 Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Sun, 9 Mar 2014 22:25:07 +0000 Subject: Instead of passing around 'char buf[DEV_BSIZE]' buffers, pass around 'struct dos_mbr' variables, since that is what the buffers were used for. Removes need to know about DEV_BSIZE and thus include param.h from all files but one so move the param.h #include to that file (mbr.c). Nuke a bunch of local MBR #defines in favour of the disklabel.h ones. Remove a bunch of unneeded #includes, replace the odd malloc/bzero with calloc, replace equally odd bcopy's with memcpy, remove a stray duplicate MBR parsing in MBR_pcopy(). No intentional functional change. --- sbin/fdisk/fdisk.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'sbin/fdisk/fdisk.c') diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index a139bfc9378..b780959c3fc 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdisk.c,v 1.57 2014/03/07 21:56:13 krw Exp $ */ +/* $OpenBSD: fdisk.c,v 1.58 2014/03/09 22:25:06 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -28,13 +28,13 @@ #include #include #include -#include #include #include #include #include #include #include + #include "disk.h" #include "user.h" @@ -80,7 +80,7 @@ main(int argc, char *argv[]) char *mbrfile = NULL; #endif struct mbr mbr; - char mbr_buf[DEV_BSIZE]; + struct dos_mbr dos_mbr; while ((ch = getopt(argc, argv, "ieuf:c:h:s:l:y")) != -1) { const char *errstr; @@ -177,14 +177,14 @@ main(int argc, char *argv[]) mbrfile = NULL; } if (mbrfile == NULL) { - memcpy(mbr_buf, builtin_mbr, sizeof(mbr_buf)); + memcpy(&dos_mbr, builtin_mbr, sizeof(dos_mbr)); } else { - error = MBR_read(fd, 0, mbr_buf); + error = MBR_read(fd, 0, &dos_mbr); if (error == -1) err(1, "Unable to read MBR"); close(fd); } - MBR_parse(&disk, mbr_buf, 0, 0, &mbr); + MBR_parse(&disk, &dos_mbr, 0, 0, &mbr); /* Now do what we are supposed to */ if (i_flag || u_flag) @@ -196,4 +196,3 @@ main(int argc, char *argv[]) return (0); } - -- cgit v1.2.3