summaryrefslogtreecommitdiff
path: root/sbin/fdisk/fdisk.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2014-03-09 22:25:07 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2014-03-09 22:25:07 +0000
commit0367a74fd1e633c6f4cbb792cfa05a18d8cf6673 (patch)
treef593904c63fcdd6a8e4e48f557661c77a0afa17a /sbin/fdisk/fdisk.c
parent2e46190af5d52f20442ff0e4c13017d9fab98844 (diff)
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.
Diffstat (limited to 'sbin/fdisk/fdisk.c')
-rw-r--r--sbin/fdisk/fdisk.c13
1 files changed, 6 insertions, 7 deletions
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 <sys/types.h>
#include <sys/fcntl.h>
#include <sys/disklabel.h>
-#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <paths.h>
#include <stdint.h>
+
#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);
}
-