summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2005-07-15 08:04:32 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2005-07-15 08:04:32 +0000
commitdfa5ad94211f9ff1f8f582cbc154759f5eefbad3 (patch)
treeda944144f0cf9d3e71303adab5a56855d6d86ae0
parentde78c288db085f012572d4721fb66a45578e696f (diff)
Notes
-rw-r--r--usr.sbin/boot0cfg/Makefile3
-rw-r--r--usr.sbin/boot0cfg/boot0cfg.c23
2 files changed, 25 insertions, 1 deletions
diff --git a/usr.sbin/boot0cfg/Makefile b/usr.sbin/boot0cfg/Makefile
index 3f87438a35a5..dc02cad7b41d 100644
--- a/usr.sbin/boot0cfg/Makefile
+++ b/usr.sbin/boot0cfg/Makefile
@@ -5,4 +5,7 @@ MAN= boot0cfg.8
WARNS?= 2
+DPADD= ${LIBGEOM}
+LDADD= -lgeom
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/boot0cfg/boot0cfg.c b/usr.sbin/boot0cfg/boot0cfg.c
index 67833602e6a8..6fd0587ba7cb 100644
--- a/usr.sbin/boot0cfg/boot0cfg.c
+++ b/usr.sbin/boot0cfg/boot0cfg.c
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <libgeom.h>
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
@@ -256,6 +257,8 @@ write_mbr(const char *fname, int flags, u_int8_t *mbr, int mbr_size)
int fd, p;
ssize_t n;
char *s;
+ const char *q;
+ struct gctl_req *grq;
fd = open(fname, O_WRONLY | flags, 0666);
if (fd != -1) {
@@ -265,12 +268,30 @@ write_mbr(const char *fname, int flags, u_int8_t *mbr, int mbr_size)
errx(1, "%s: short write", fname);
return;
}
+
if (flags != 0)
err(1, "%s", fname);
+ grq = gctl_get_handle();
+ gctl_ro_param(grq, "verb", -1, "write MBR");
+ gctl_ro_param(grq, "class", -1, "MBR");
+ q = strrchr(fname, '/');
+ if (q == NULL)
+ q = fname;
+ else
+ q++;
+ gctl_ro_param(grq, "geom", -1, q);
+ gctl_ro_param(grq, "data", mbr_size, mbr);
+ q = gctl_issue(grq);
+ if (q == NULL)
+ return;
+
+ warnx("%s: %s", fname, q);
+ gctl_free(grq);
+
#ifdef DIOCSMBR
for (p = 1; p < 5; p++) {
asprintf(&s, "%ss%d", fname, p);
- fd = open(s, O_RDWR);
+ fd = open(s, O_RDONLY);
if (fd < 0) {
free(s);
continue;