diff options
| author | Alexander Motin <mav@FreeBSD.org> | 2022-03-08 18:44:22 +0000 |
|---|---|---|
| committer | Alexander Motin <mav@FreeBSD.org> | 2022-04-06 02:07:40 +0000 |
| commit | e3b3dfa77964b235a768534c174a54df03080096 (patch) | |
| tree | 3329308741621f39a1978e1929c73fcb3e2dbea7 /lib/geom | |
| parent | 59c15b83be875bf0b4c09bf2c49e133d8f21a911 (diff) | |
Diffstat (limited to 'lib/geom')
| -rw-r--r-- | lib/geom/part/geom_part.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/lib/geom/part/geom_part.c b/lib/geom/part/geom_part.c index 41131646e246..330a4708251d 100644 --- a/lib/geom/part/geom_part.c +++ b/lib/geom/part/geom_part.c @@ -1217,6 +1217,14 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl) } else bootcode = NULL; + if (!gctl_has_param(req, GPART_PARAM_PARTCODE)) { + if (bootcode == NULL) + errx(EXIT_FAILURE, "neither -b nor -p specified"); + if (gctl_has_param(req, GPART_PARAM_INDEX)) + errx(EXIT_FAILURE, "-i is only valid with -p"); + goto nopartcode; + } + s = gctl_get_ascii(req, "class"); if (s == NULL) abort(); @@ -1244,22 +1252,7 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl) else vtoc8 = 0; - if (gctl_has_param(req, GPART_PARAM_PARTCODE)) { - s = gctl_get_ascii(req, GPART_PARAM_PARTCODE); - 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 - partcode = NULL; - if (gctl_has_param(req, GPART_PARAM_INDEX)) { - if (partcode == NULL) - errx(EXIT_FAILURE, "-i is only valid with -p"); idx = (int)gctl_get_intmax(req, GPART_PARAM_INDEX); if (idx < 1) errx(EXIT_FAILURE, "invalid partition index"); @@ -1269,7 +1262,16 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl) } else idx = 0; - if (partcode != NULL) { + if (gctl_has_param(req, GPART_PARAM_PARTCODE)) { + s = gctl_get_ascii(req, GPART_PARAM_PARTCODE); + 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"); if (vtoc8 == 0) { if (idx == 0) errx(EXIT_FAILURE, "missing -i option"); @@ -1279,15 +1281,14 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl) errx(EXIT_FAILURE, "invalid bootcode"); gpart_write_partcode_vtoc8(gp, idx, partcode); } - } else - if (bootcode == NULL) - errx(EXIT_FAILURE, "no -b nor -p"); + free(partcode); + } + geom_deletetree(&mesh); + +nopartcode: if (bootcode != NULL) gpart_issue(req, fl); - - geom_deletetree(&mesh); - free(partcode); } static void |
