From 4ef1c6f75d25ba0c264ab274a1b449467a6ee817 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Wed, 26 Jul 2023 13:08:37 +0200 Subject: base: Remove support for the VTOC8 partitioning scheme The removal of the sparc64 support in February 2020 obsoleted the VTOC8 partitioning scheme as no other FreeBSD platform makes use of it. Moreover, the code is bitrotting as nothing defines e. g. LOADER_VTOC8_SUPPORT any more and, thus, should go now, too. With this change, the following commits are reverted as far as VTOC8 is concerned and parts haven't already previously been deleted along with prior sparc64 removals: 094fcb157d4c98211899cf09d06e2cf19149b7e0 a7d366e9589c95feda6f3bc78c59c6355d51f126 ba8d50d08b9df4e8213f9a6997ff6792ecebcd9b The alignment example d9711c28efc4ec89ba5ea11f8fd63e9d0a7fc81b added to the VTOC8 section of gpart.8 is folded into the MBR one. This should finally conclude the deorbit of sparc64-specific bits. We had joy, we had fun we ran Unix on a Sun. But that source and the song of FreeBSD have all gone. Credits to Michael Bueker for the original "Unix on a Sun" and Rod McKuen for the "Seasons in the Sun" lyrics. --- lib/geom/part/geom_part.c | 132 ++++++++++++---------------------------------- lib/geom/part/gpart.8 | 76 ++++++-------------------- 2 files changed, 50 insertions(+), 158 deletions(-) (limited to 'lib/geom') diff --git a/lib/geom/part/geom_part.c b/lib/geom/part/geom_part.c index 70eb83a66c97..04e730c7719e 100644 --- a/lib/geom/part/geom_part.c +++ b/lib/geom/part/geom_part.c @@ -30,7 +30,6 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include @@ -89,8 +88,7 @@ static _Noreturn void gpart_issue(struct gctl_req *, unsigned int); static void gpart_show(struct gctl_req *, unsigned int); static void gpart_show_geom(struct ggeom *, const char *, int); static int gpart_show_hasopt(struct gctl_req *, const char *, const char *); -static void gpart_write_partcode(struct ggeom *, int, void *, ssize_t); -static void gpart_write_partcode_vtoc8(struct ggeom *, int, void *); +static void gpart_write_partcode(struct gctl_req *, int, void *, ssize_t); static void gpart_print_error(const char *); static void gpart_backup(struct gctl_req *, unsigned int); static void gpart_restore(struct gctl_req *, unsigned int); @@ -1107,14 +1105,38 @@ gpart_bootfile_read(const char *bootfile, ssize_t *size) } static void -gpart_write_partcode(struct ggeom *gp, int idx, void *code, ssize_t size) +gpart_write_partcode(struct gctl_req *req, int idx, void *code, ssize_t size) { char dsf[128]; + struct gmesh mesh; + struct gclass *classp; + struct ggeom *gp; struct gprovider *pp; - const char *s; + const char *g, *s; char *buf; off_t bsize; - int fd; + int error, fd; + + s = gctl_get_ascii(req, "class"); + if (s == NULL) + abort(); + g = gctl_get_ascii(req, "arg0"); + if (g == NULL) + abort(); + error = geom_gettree_geom(&mesh, s, g, 0); + if (error != 0) + errc(EXIT_FAILURE, error, "Cannot get GEOM tree"); + classp = find_class(&mesh, s); + if (classp == NULL) { + geom_deletetree(&mesh); + errx(EXIT_FAILURE, "Class %s not found.", s); + } + gp = find_geom(classp, g); + if (gp == NULL) + errx(EXIT_FAILURE, "No such geom: %s.", g); + s = find_geomcfg(gp, "scheme"); + if (s == NULL) + errx(EXIT_FAILURE, "Scheme not found for geom %s", gp->lg_name); LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { s = find_provcfg(pp, "index"); @@ -1149,65 +1171,17 @@ gpart_write_partcode(struct ggeom *gp, int idx, void *code, ssize_t size) printf("partcode written to %s\n", pp->lg_name); } else errx(EXIT_FAILURE, "invalid partition index"); -} -static void -gpart_write_partcode_vtoc8(struct ggeom *gp, int idx, void *code) -{ - char dsf[128]; - struct gprovider *pp; - const char *s; - int installed, fd; - - installed = 0; - LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { - s = find_provcfg(pp, "index"); - if (s == NULL) - continue; - if (idx != 0 && atoi(s) != idx) - continue; - snprintf(dsf, sizeof(dsf), "/dev/%s", pp->lg_name); - if (pp->lg_sectorsize != sizeof(struct vtoc8)) - errx(EXIT_FAILURE, "%s: unexpected sector " - "size (%d)\n", dsf, pp->lg_sectorsize); - if (pp->lg_mediasize < VTOC_BOOTSIZE) - continue; - fd = open(dsf, O_WRONLY); - if (fd == -1) - err(EXIT_FAILURE, "%s", dsf); - /* - * We ignore the first VTOC_BOOTSIZE bytes of boot code in - * order to avoid overwriting the label. - */ - if (lseek(fd, sizeof(struct vtoc8), SEEK_SET) != - sizeof(struct vtoc8)) - err(EXIT_FAILURE, "%s", dsf); - if (write(fd, (caddr_t)code + sizeof(struct vtoc8), - VTOC_BOOTSIZE - sizeof(struct vtoc8)) != VTOC_BOOTSIZE - - sizeof(struct vtoc8)) - err(EXIT_FAILURE, "%s", dsf); - installed++; - close(fd); - if (idx != 0 && atoi(s) == idx) - break; - } - 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); + geom_deletetree(&mesh); } static void gpart_bootcode(struct gctl_req *req, unsigned int fl) { - struct gmesh mesh; - struct gclass *classp; - struct ggeom *gp; - const char *g, *s; + const char *s; void *bootcode, *partcode; size_t bootsize, partsize; - int error, idx, vtoc8; + int error, idx; if (gctl_get_int(req, "nargs") != 1) errx(EXIT_FAILURE, "Invalid number of arguments."); @@ -1231,31 +1205,6 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl) goto nopartcode; } - s = gctl_get_ascii(req, "class"); - if (s == NULL) - abort(); - g = gctl_get_ascii(req, "arg0"); - if (g == NULL) - abort(); - error = geom_gettree_geom(&mesh, s, g, 0); - if (error != 0) - errc(EXIT_FAILURE, error, "Cannot get GEOM tree"); - classp = find_class(&mesh, s); - if (classp == NULL) { - geom_deletetree(&mesh); - errx(EXIT_FAILURE, "Class %s not found.", s); - } - gp = find_geom(classp, g); - if (gp == NULL) - errx(EXIT_FAILURE, "No such geom: %s.", g); - s = find_geomcfg(gp, "scheme"); - if (s == NULL) - errx(EXIT_FAILURE, "Scheme not found for geom %s", gp->lg_name); - if (strcmp(s, "VTOC8") == 0) - vtoc8 = 1; - else - vtoc8 = 0; - if (gctl_has_param(req, GPART_PARAM_INDEX)) { idx = (int)gctl_get_intmax(req, GPART_PARAM_INDEX); if (idx < 1) @@ -1268,28 +1217,17 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl) 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. */ + 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"); - gpart_write_partcode(gp, idx, partcode, partsize); - } else { - if (partsize != VTOC_BOOTSIZE) - errx(EXIT_FAILURE, "invalid bootcode"); - gpart_write_partcode_vtoc8(gp, idx, partcode); - } + if (idx == 0) + errx(EXIT_FAILURE, "missing -i option"); + gpart_write_partcode(req, idx, partcode, partsize); free(partcode); } - geom_deletetree(&mesh); - nopartcode: if (bootcode != NULL) gpart_issue(req, fl); diff --git a/lib/geom/part/gpart.8 b/lib/geom/part/gpart.8 index 2bc1daba2ad6..a6f9fbd884a8 100644 --- a/lib/geom/part/gpart.8 +++ b/lib/geom/part/gpart.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 7, 2023 +.Dd July 26, 2023 .Dt GPART 8 .Os .Sh NAME @@ -544,7 +544,7 @@ See Several partitioning schemes are supported by the .Nm utility: -.Bl -tag -width ".Cm VTOC8" +.Bl -tag -width ".Cm BSD64" .It Cm APM Apple Partition Map, used by PowerPC(R) Macintosh(R) computers. Requires the @@ -599,15 +599,6 @@ The option enables backward compatibility for partition names in the EBR scheme. It also prevents any type of actions on such partitions. -.It Cm VTOC8 -Sun's SMI Volume Table Of Contents, used by -.Tn SPARC64 -and -.Tn UltraSPARC -computers. -Requires the -.Cm GEOM_PART_VTOC8 -kernel option. .El .Pp See @@ -680,36 +671,36 @@ A partition dedicated to swap space. The scheme-specific types are .Qq Li "!FreeBSD-swap" -for APM, +for APM, and .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b" -for GPT, and tag 0x0901 for VTOC8. +for GPT. .It Cm freebsd-ufs A .Fx partition that contains a UFS or UFS2 filesystem. The scheme-specific types are .Qq Li "!FreeBSD-UFS" -for APM, +for APM, and .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b" -for GPT, and tag 0x0902 for VTOC8. +for GPT. .It Cm freebsd-vinum A .Fx partition that contains a Vinum volume. The scheme-specific types are .Qq Li "!FreeBSD-Vinum" -for APM, +for APM, and .Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b" -for GPT, and tag 0x0903 for VTOC8. +for GPT. .It Cm freebsd-zfs A .Fx partition that contains a ZFS volume. The scheme-specific types are .Qq Li "!FreeBSD-ZFS" -for APM, +for APM, and .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b" -for GPT, and 0x0904 for VTOC8. +for GPT. .El .Pp Other symbolic names that can be used with the @@ -1196,18 +1187,6 @@ After all pools are detected, .Pa /boot/loader is started from the first one found set as bootable. .Pp -The VTOC8 scheme does not support embedding bootstrap code. -Instead, the 8 KBytes bootstrap code image -.Pa /boot/boot1 -should be written with the -.Cm gpart bootcode -command with the -.Fl p Ar bootcode -option to all sufficiently large VTOC8 partitions. -To do this the -.Fl i Ar index -option could be omitted. -.Pp The APM scheme also does not support embedding bootstrap code. Instead, the 800 KBytes bootstrap code image .Pa /boot/boot1.hfs @@ -1306,7 +1285,7 @@ GEOM class. The default value is shown next to each variable. .Bl -tag -width indent .It Va kern.geom.part.allow_nesting : No 0 -By default, some schemes (currently BSD, BSD64 and VTOC8) do not permit +By default, some schemes (currently BSD and BSD64) do not permit further nested partitioning. This variable overrides this restriction and allows arbitrary nesting (except within partitions created at offset 0). @@ -1443,12 +1422,12 @@ using a traditional .Bx disklabel. .Pp -First, we create the partition table and a single 64 GB partition, -then we mark that partition active (bootable) and install the -first-stage boot loader: +First, we create the partition table as well as a single partition 64 GB in +size and an alignment of 4 kB, then we mark that partition active (bootable) +and install the first-stage boot loader: .Bd -literal -offset indent /sbin/gpart create -s MBR ada0 -/sbin/gpart add -t freebsd -s 64G ada0 +/sbin/gpart add -t freebsd -s 64G -a 4k ada0 /sbin/gpart set -a active -i 1 ada0 /sbin/gpart bootcode -b /boot/boot0 ada0 .Ed @@ -1475,31 +1454,6 @@ label: .Bd -literal -offset indent /sbin/gpart bootcode -b /boot/boot ada0s1 .Ed -.Ss VTOC8 -Create a VTOC8 scheme on -.Pa da0 : -.Bd -literal -offset indent -/sbin/gpart create -s VTOC8 da0 -.Ed -.Pp -Create a 512MB-sized -.Cm freebsd-ufs -partition to contain a UFS filesystem from which the system can boot. -.Bd -literal -offset indent -/sbin/gpart add -s 512M -t freebsd-ufs da0 -.Ed -.Pp -Create a 15GB-sized -.Cm freebsd-ufs -partition to contain a UFS filesystem and aligned on 4KB boundaries: -.Bd -literal -offset indent -/sbin/gpart add -s 15G -t freebsd-ufs -a 4k da0 -.Ed -.Pp -After creating all required partitions, embed bootstrap code into them: -.Bd -literal -offset indent -/sbin/gpart bootcode -p /boot/boot1 da0 -.Ed .Ss Deleting Partitions and Destroying the Partitioning Scheme If a .Em "Device busy" -- cgit v1.2.3