summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2016-04-26 11:55:28 +0000
committerae <ae@FreeBSD.org>2016-04-26 11:55:28 +0000
commit437e80c6fb7d22ef50bfa5f9b9b5c811a1dd4e85 (patch)
treedf29dcb7557f3b1ca4377f2c213d6ab92e4cf7d1 /sbin
parentd401a99e6492ed4f9e9f5611f22325e69ae3d51e (diff)
downloadFreeBSD-src-437e80c6fb7d22ef50bfa5f9b9b5c811a1dd4e85.zip
FreeBSD-src-437e80c6fb7d22ef50bfa5f9b9b5c811a1dd4e85.tar.gz
MFC r297820:
Fix the problem, when gpart(8) can't write both bootcode and partcode in one command due to wrong file size limit. Do not use bootcode size to calculate partsize limit. Also add report message about successful partcode writing.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/geom/class/part/geom_part.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c
index 521ac23..14827f6 100644
--- a/sbin/geom/class/part/geom_part.c
+++ b/sbin/geom/class/part/geom_part.c
@@ -1115,6 +1115,7 @@ gpart_write_partcode(struct ggeom *gp, int idx, void *code, ssize_t size)
err(EXIT_FAILURE, "%s", dsf);
free(buf);
close(fd);
+ printf("partcode written to %s\n", pp->lg_name);
} else
errx(EXIT_FAILURE, "invalid partition index");
}
@@ -1161,6 +1162,9 @@ gpart_write_partcode_vtoc8(struct ggeom *gp, int idx, void *code)
}
if (installed == 0)
errx(EXIT_FAILURE, "%s: no partitions", gp->lg_name);
+ else
+ printf("partcode written to %s\n",
+ idx != 0 ? pp->lg_name: gp->lg_name);
}
static void
@@ -1182,10 +1186,8 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl)
bootcode);
if (error)
errc(EXIT_FAILURE, error, "internal error");
- } else {
+ } else
bootcode = NULL;
- bootsize = 0;
- }
s = gctl_get_ascii(req, "class");
if (s == NULL)
@@ -1209,21 +1211,23 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl)
s = find_geomcfg(gp, "scheme");
if (s == NULL)
errx(EXIT_FAILURE, "Scheme not found for geom %s", gp->lg_name);
- vtoc8 = 0;
if (strcmp(s, "VTOC8") == 0)
vtoc8 = 1;
+ else
+ vtoc8 = 0;
if (gctl_has_param(req, GPART_PARAM_PARTCODE)) {
s = gctl_get_ascii(req, GPART_PARAM_PARTCODE);
- partsize = vtoc8 != 0 ? VTOC_BOOTSIZE : bootsize * 1024;
+ if (vtoc8 != 0)
+ partsize = VTOC_BOOTSIZE;
+ else
+ partsize = 1024 * 1024; /* Arbitrary limit. */
partcode = gpart_bootfile_read(s, &partsize);
error = gctl_delete_param(req, GPART_PARAM_PARTCODE);
if (error)
errc(EXIT_FAILURE, error, "internal error");
- } else {
+ } else
partcode = NULL;
- partsize = 0;
- }
if (gctl_has_param(req, GPART_PARAM_INDEX)) {
if (partcode == NULL)
OpenPOWER on IntegriCloud