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:
094fcb157d
a7d366e958
ba8d50d08b

The alignment example d9711c28ef
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.
This commit is contained in:
Marius Strobl 2023-07-26 13:08:37 +02:00
parent 29fe5efc8a
commit 4ef1c6f75d
19 changed files with 58 additions and 1126 deletions

View file

@ -52,6 +52,10 @@
# xargs -n1 | sort | uniq -d;
# done
# 20230726: Removal of support for the VTOC8 partitioning scheme
OLD_FILES+=usr/include/sys/disk/vtoc.h
OLD_FILES+=usr/include/sys/vtoc.h
# 20230724: Remove unneeded arm headers
.if ${TARGET_ARCH} == "arm"
OLD_FILES+=usr/include/machine/atomic-v6.h

View file

@ -30,7 +30,6 @@
__FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <sys/vtoc.h>
#include <assert.h>
#include <ctype.h>
@ -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);

View file

@ -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"

View file

@ -34,7 +34,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd March 27, 2023
.Dd July 26, 2023
.Dt GEOM 4
.Os
.Sh NAME
@ -62,7 +62,6 @@
.Cd options GEOM_PART_GPT
.Cd options GEOM_PART_LDM
.Cd options GEOM_PART_MBR
.Cd options GEOM_PART_VTOC8
.Cd options GEOM_RAID
.Cd options GEOM_RAID3
.Cd options GEOM_SHSEC
@ -494,8 +493,6 @@ Use
.Cd GEOM_MULTIPATH ,
.It
.Cd GEOM_PART_MBR ,
.It
.Cd GEOM_PART_VTOC8 ,
and
.It
.Cd GEOM_LABEL

View file

@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$");
#include <sys/gpt.h>
#include <sys/stddef.h>
#include <sys/queue.h>
#include <sys/vtoc.h>
#include <fs/cd9660/iso.h>
@ -70,7 +69,6 @@ struct pentry {
uint8_t bsd;
uint8_t mbr;
uuid_t gpt;
uint16_t vtoc8;
} type;
STAILQ_ENTRY(pentry) entry;
};
@ -519,88 +517,6 @@ ptable_bsdread(struct ptable *table, void *dev, diskread_t dread)
return (table);
}
#ifdef LOADER_VTOC8_SUPPORT
static enum partition_type
vtoc8_parttype(uint16_t type)
{
switch (type) {
case VTOC_TAG_FREEBSD_SWAP:
return (PART_FREEBSD_SWAP);
case VTOC_TAG_FREEBSD_UFS:
return (PART_FREEBSD_UFS);
case VTOC_TAG_FREEBSD_VINUM:
return (PART_FREEBSD_VINUM);
case VTOC_TAG_FREEBSD_ZFS:
return (PART_FREEBSD_ZFS);
}
return (PART_UNKNOWN);
}
static struct ptable *
ptable_vtoc8read(struct ptable *table, void *dev, diskread_t dread)
{
struct pentry *entry;
struct vtoc8 *dl;
uint8_t *buf;
uint16_t sum, heads, sectors;
int i;
if (table->sectorsize != sizeof(struct vtoc8))
return (table);
buf = malloc(table->sectorsize);
if (buf == NULL)
return (table);
if (dread(dev, buf, 1, 0) != 0) {
DPRINTF("read failed");
ptable_close(table);
table = NULL;
goto out;
}
dl = (struct vtoc8 *)buf;
/* Check the sum */
for (i = sum = 0; i < sizeof(struct vtoc8); i += sizeof(sum))
sum ^= be16dec(buf + i);
if (sum != 0) {
DPRINTF("incorrect checksum");
goto out;
}
if (be16toh(dl->nparts) != VTOC8_NPARTS) {
DPRINTF("invalid number of entries");
goto out;
}
sectors = be16toh(dl->nsecs);
heads = be16toh(dl->nheads);
if (sectors * heads == 0) {
DPRINTF("invalid geometry");
goto out;
}
DPRINTF("VTOC8 detected");
for (i = 0; i < VTOC8_NPARTS; i++) {
dl->part[i].tag = be16toh(dl->part[i].tag);
if (i == VTOC_RAW_PART ||
dl->part[i].tag == VTOC_TAG_UNASSIGNED)
continue;
entry = malloc(sizeof(*entry));
if (entry == NULL)
break;
entry->part.start = be32toh(dl->map[i].cyl) * heads * sectors;
entry->part.end = be32toh(dl->map[i].nblks) +
entry->part.start - 1;
entry->part.type = vtoc8_parttype(dl->part[i].tag);
entry->part.index = i; /* starts from zero */
entry->type.vtoc8 = dl->part[i].tag;
STAILQ_INSERT_TAIL(&table->entries, entry, entry);
DPRINTF("new VTOC8 partition added");
}
table->type = PTABLE_VTOC8;
out:
free(buf);
return (table);
}
#endif /* LOADER_VTOC8_SUPPORT */
#define cdb2devb(bno) ((bno) * ISO_DEFAULT_BLOCK_SIZE / table->sectorsize)
static struct ptable *
@ -678,16 +594,6 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize,
} else if (table->type == PTABLE_ISO9660)
goto out;
#ifdef LOADER_VTOC8_SUPPORT
if (be16dec(buf + offsetof(struct vtoc8, magic)) == VTOC_MAGIC) {
if (ptable_vtoc8read(table, dev, dread) == NULL) {
/* Read error. */
table = NULL;
goto out;
} else if (table->type == PTABLE_VTOC8)
goto out;
}
#endif
/* Check the BSD label. */
if (ptable_bsdread(table, dev, dread) == NULL) { /* Read error. */
table = NULL;
@ -928,12 +834,6 @@ ptable_iterate(const struct ptable *table, void *arg, ptable_iterate_t *iter)
if (table->type == PTABLE_GPT)
sprintf(name, "p%d", entry->part.index);
else
#endif
#ifdef LOADER_VTOC8_SUPPORT
if (table->type == PTABLE_VTOC8)
sprintf(name, "%c", (uint8_t) 'a' +
entry->part.index);
else
#endif
if (table->type == PTABLE_BSD)
sprintf(name, "%c", (uint8_t) 'a' +

View file

@ -36,7 +36,6 @@ enum ptable_type {
PTABLE_BSD,
PTABLE_MBR,
PTABLE_GPT,
PTABLE_VTOC8,
PTABLE_ISO9660
};

View file

@ -174,7 +174,6 @@ options GEOM_PART_EBR # Extended Boot Records
options GEOM_PART_GPT # GPT partitioning
options GEOM_PART_LDM # Logical Disk Manager
options GEOM_PART_MBR # MBR partitioning
options GEOM_PART_VTOC8 # SMI VTOC8 disk label
options GEOM_RAID # Soft RAID functionality.
options GEOM_RAID3 # RAID3 functionality.
options GEOM_SHSEC # Shared secret.

View file

@ -3661,7 +3661,6 @@ geom/part/g_part_ebr.c optional geom_part_ebr
geom/part/g_part_gpt.c optional geom_part_gpt
geom/part/g_part_ldm.c optional geom_part_ldm
geom/part/g_part_mbr.c optional geom_part_mbr
geom/part/g_part_vtoc8.c optional geom_part_vtoc8
geom/raid/g_raid.c optional geom_raid
geom/raid/g_raid_ctl.c optional geom_raid
geom/raid/g_raid_md_if.m optional geom_raid

View file

@ -133,7 +133,6 @@ GEOM_PART_EBR opt_geom.h
GEOM_PART_GPT opt_geom.h
GEOM_PART_LDM opt_geom.h
GEOM_PART_MBR opt_geom.h
GEOM_PART_VTOC8 opt_geom.h
GEOM_RAID opt_geom.h
GEOM_RAID3 opt_geom.h
GEOM_SHSEC opt_geom.h

View file

@ -1,604 +0,0 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2008 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/bio.h>
#include <sys/endian.h>
#include <sys/kernel.h>
#include <sys/kobj.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/queue.h>
#include <sys/sbuf.h>
#include <sys/systm.h>
#include <sys/sysctl.h>
#include <sys/vtoc.h>
#include <geom/geom.h>
#include <geom/geom_int.h>
#include <geom/part/g_part.h>
#include "g_part_if.h"
FEATURE(geom_part_vtoc8, "GEOM partitioning class for SMI VTOC8 disk labels");
struct g_part_vtoc8_table {
struct g_part_table base;
struct vtoc8 vtoc;
uint32_t secpercyl;
};
static int g_part_vtoc8_add(struct g_part_table *, struct g_part_entry *,
struct g_part_parms *);
static int g_part_vtoc8_create(struct g_part_table *, struct g_part_parms *);
static int g_part_vtoc8_destroy(struct g_part_table *, struct g_part_parms *);
static void g_part_vtoc8_dumpconf(struct g_part_table *,
struct g_part_entry *, struct sbuf *, const char *);
static int g_part_vtoc8_dumpto(struct g_part_table *, struct g_part_entry *);
static int g_part_vtoc8_modify(struct g_part_table *, struct g_part_entry *,
struct g_part_parms *);
static const char *g_part_vtoc8_name(struct g_part_table *,
struct g_part_entry *, char *, size_t);
static int g_part_vtoc8_probe(struct g_part_table *, struct g_consumer *);
static int g_part_vtoc8_read(struct g_part_table *, struct g_consumer *);
static const char *g_part_vtoc8_type(struct g_part_table *,
struct g_part_entry *, char *, size_t);
static int g_part_vtoc8_write(struct g_part_table *, struct g_consumer *);
static int g_part_vtoc8_resize(struct g_part_table *, struct g_part_entry *,
struct g_part_parms *);
static kobj_method_t g_part_vtoc8_methods[] = {
KOBJMETHOD(g_part_add, g_part_vtoc8_add),
KOBJMETHOD(g_part_create, g_part_vtoc8_create),
KOBJMETHOD(g_part_destroy, g_part_vtoc8_destroy),
KOBJMETHOD(g_part_dumpconf, g_part_vtoc8_dumpconf),
KOBJMETHOD(g_part_dumpto, g_part_vtoc8_dumpto),
KOBJMETHOD(g_part_modify, g_part_vtoc8_modify),
KOBJMETHOD(g_part_resize, g_part_vtoc8_resize),
KOBJMETHOD(g_part_name, g_part_vtoc8_name),
KOBJMETHOD(g_part_probe, g_part_vtoc8_probe),
KOBJMETHOD(g_part_read, g_part_vtoc8_read),
KOBJMETHOD(g_part_type, g_part_vtoc8_type),
KOBJMETHOD(g_part_write, g_part_vtoc8_write),
{ 0, 0 }
};
static struct g_part_scheme g_part_vtoc8_scheme = {
"VTOC8",
g_part_vtoc8_methods,
sizeof(struct g_part_vtoc8_table),
.gps_entrysz = sizeof(struct g_part_entry),
.gps_minent = VTOC8_NPARTS,
.gps_maxent = VTOC8_NPARTS,
};
G_PART_SCHEME_DECLARE(g_part_vtoc8);
MODULE_VERSION(geom_part_vtoc8, 0);
static int
vtoc8_parse_type(const char *type, uint16_t *tag)
{
const char *alias;
char *endp;
long lt;
if (type[0] == '!') {
lt = strtol(type + 1, &endp, 0);
if (type[1] == '\0' || *endp != '\0' || lt <= 0 ||
lt >= 65536)
return (EINVAL);
*tag = (uint16_t)lt;
return (0);
}
alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_NANDFS);
if (!strcasecmp(type, alias)) {
*tag = VTOC_TAG_FREEBSD_NANDFS;
return (0);
}
alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP);
if (!strcasecmp(type, alias)) {
*tag = VTOC_TAG_FREEBSD_SWAP;
return (0);
}
alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_UFS);
if (!strcasecmp(type, alias)) {
*tag = VTOC_TAG_FREEBSD_UFS;
return (0);
}
alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_VINUM);
if (!strcasecmp(type, alias)) {
*tag = VTOC_TAG_FREEBSD_VINUM;
return (0);
}
alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_ZFS);
if (!strcasecmp(type, alias)) {
*tag = VTOC_TAG_FREEBSD_ZFS;
return (0);
}
return (EINVAL);
}
static int
vtoc8_align(struct g_part_vtoc8_table *table, uint64_t *start, uint64_t *size)
{
if (*size < table->secpercyl)
return (EINVAL);
if (start != NULL && (*start % table->secpercyl)) {
*size += (*start % table->secpercyl) - table->secpercyl;
*start -= (*start % table->secpercyl) - table->secpercyl;
}
if (*size % table->secpercyl)
*size -= (*size % table->secpercyl);
if (*size < table->secpercyl)
return (EINVAL);
return (0);
}
static int
g_part_vtoc8_add(struct g_part_table *basetable, struct g_part_entry *entry,
struct g_part_parms *gpp)
{
struct g_part_vtoc8_table *table;
int error, index;
uint64_t start, size;
uint16_t tag;
if (gpp->gpp_parms & G_PART_PARM_LABEL)
return (EINVAL);
error = vtoc8_parse_type(gpp->gpp_type, &tag);
if (error)
return (error);
table = (struct g_part_vtoc8_table *)basetable;
index = entry->gpe_index - 1;
start = gpp->gpp_start;
size = gpp->gpp_size;
if (vtoc8_align(table, &start, &size) != 0)
return (EINVAL);
KASSERT(entry->gpe_start <= start, (__func__));
KASSERT(entry->gpe_end >= start + size - 1, (__func__));
entry->gpe_start = start;
entry->gpe_end = start + size - 1;
be16enc(&table->vtoc.part[index].tag, tag);
be16enc(&table->vtoc.part[index].flag, 0);
be32enc(&table->vtoc.timestamp[index], 0);
be32enc(&table->vtoc.map[index].cyl, start / table->secpercyl);
be32enc(&table->vtoc.map[index].nblks, size);
return (0);
}
static int
g_part_vtoc8_create(struct g_part_table *basetable, struct g_part_parms *gpp)
{
struct g_provider *pp;
struct g_part_entry *entry;
struct g_part_vtoc8_table *table;
uint64_t msize;
uint32_t acyls, ncyls, pcyls;
pp = gpp->gpp_provider;
if (pp->sectorsize < sizeof(struct vtoc8))
return (ENOSPC);
if (pp->sectorsize > sizeof(struct vtoc8))
return (ENXIO);
table = (struct g_part_vtoc8_table *)basetable;
msize = MIN(pp->mediasize / pp->sectorsize, UINT32_MAX);
table->secpercyl = basetable->gpt_sectors * basetable->gpt_heads;
pcyls = msize / table->secpercyl;
acyls = 2;
ncyls = pcyls - acyls;
msize = ncyls * table->secpercyl;
snprintf(table->vtoc.ascii, sizeof(table->vtoc.ascii),
"FreeBSD%lldM cyl %u alt %u hd %u sec %u",
(long long)(msize / 2048), ncyls, acyls, basetable->gpt_heads,
basetable->gpt_sectors);
be32enc(&table->vtoc.version, VTOC_VERSION);
be16enc(&table->vtoc.nparts, VTOC8_NPARTS);
be32enc(&table->vtoc.sanity, VTOC_SANITY);
be16enc(&table->vtoc.rpm, 3600);
be16enc(&table->vtoc.physcyls, pcyls);
be16enc(&table->vtoc.ncyls, ncyls);
be16enc(&table->vtoc.altcyls, acyls);
be16enc(&table->vtoc.nheads, basetable->gpt_heads);
be16enc(&table->vtoc.nsecs, basetable->gpt_sectors);
be16enc(&table->vtoc.magic, VTOC_MAGIC);
basetable->gpt_first = 0;
basetable->gpt_last = msize - 1;
basetable->gpt_isleaf = 1;
entry = g_part_new_entry(basetable, VTOC_RAW_PART + 1,
basetable->gpt_first, basetable->gpt_last);
entry->gpe_internal = 1;
be16enc(&table->vtoc.part[VTOC_RAW_PART].tag, VTOC_TAG_BACKUP);
be32enc(&table->vtoc.map[VTOC_RAW_PART].nblks, msize);
return (0);
}
static int
g_part_vtoc8_destroy(struct g_part_table *basetable, struct g_part_parms *gpp)
{
/* Wipe the first sector to clear the partitioning. */
basetable->gpt_smhead |= 1;
return (0);
}
static void
g_part_vtoc8_dumpconf(struct g_part_table *basetable,
struct g_part_entry *entry, struct sbuf *sb, const char *indent)
{
struct g_part_vtoc8_table *table;
table = (struct g_part_vtoc8_table *)basetable;
if (indent == NULL) {
/* conftxt: libdisk compatibility */
sbuf_printf(sb, " xs SUN sc %u hd %u alt %u",
be16dec(&table->vtoc.nsecs), be16dec(&table->vtoc.nheads),
be16dec(&table->vtoc.altcyls));
} else if (entry != NULL) {
/* confxml: partition entry information */
sbuf_printf(sb, "%s<rawtype>%u</rawtype>\n", indent,
be16dec(&table->vtoc.part[entry->gpe_index - 1].tag));
} else {
/* confxml: scheme information */
}
}
static int
g_part_vtoc8_dumpto(struct g_part_table *basetable,
struct g_part_entry *entry)
{
struct g_part_vtoc8_table *table;
uint16_t tag;
/*
* Allow dumping to a swap partition or a partition that
* has no type.
*/
table = (struct g_part_vtoc8_table *)basetable;
tag = be16dec(&table->vtoc.part[entry->gpe_index - 1].tag);
return ((tag == 0 || tag == VTOC_TAG_FREEBSD_SWAP ||
tag == VTOC_TAG_SWAP) ? 1 : 0);
}
static int
g_part_vtoc8_modify(struct g_part_table *basetable,
struct g_part_entry *entry, struct g_part_parms *gpp)
{
struct g_part_vtoc8_table *table;
int error;
uint16_t tag;
if (gpp->gpp_parms & G_PART_PARM_LABEL)
return (EINVAL);
table = (struct g_part_vtoc8_table *)basetable;
if (gpp->gpp_parms & G_PART_PARM_TYPE) {
error = vtoc8_parse_type(gpp->gpp_type, &tag);
if (error)
return(error);
be16enc(&table->vtoc.part[entry->gpe_index - 1].tag, tag);
}
return (0);
}
static int
vtoc8_set_rawsize(struct g_part_table *basetable, struct g_provider *pp)
{
struct g_part_vtoc8_table *table;
struct g_part_entry *baseentry;
off_t msize;
uint32_t acyls, ncyls, pcyls;
table = (struct g_part_vtoc8_table *)basetable;
msize = MIN(pp->mediasize / pp->sectorsize, UINT32_MAX);
pcyls = msize / table->secpercyl;
if (pcyls > UINT16_MAX)
return (ERANGE);
acyls = be16dec(&table->vtoc.altcyls);
ncyls = pcyls - acyls;
msize = ncyls * table->secpercyl;
basetable->gpt_last = msize - 1;
bzero(table->vtoc.ascii, sizeof(table->vtoc.ascii));
snprintf(table->vtoc.ascii, sizeof(table->vtoc.ascii),
"FreeBSD%lldM cyl %u alt %u hd %u sec %u",
(long long)(msize / 2048), ncyls, acyls, basetable->gpt_heads,
basetable->gpt_sectors);
be16enc(&table->vtoc.physcyls, pcyls);
be16enc(&table->vtoc.ncyls, ncyls);
be32enc(&table->vtoc.map[VTOC_RAW_PART].nblks, msize);
if (be32dec(&table->vtoc.sanity) == VTOC_SANITY)
be16enc(&table->vtoc.part[VTOC_RAW_PART].tag, VTOC_TAG_BACKUP);
LIST_FOREACH(baseentry, &basetable->gpt_entry, gpe_entry) {
if (baseentry->gpe_index == VTOC_RAW_PART + 1) {
baseentry->gpe_end = basetable->gpt_last;
return (0);
}
}
return (ENXIO);
}
static int
g_part_vtoc8_resize(struct g_part_table *basetable,
struct g_part_entry *entry, struct g_part_parms *gpp)
{
struct g_part_vtoc8_table *table;
struct g_provider *pp;
uint64_t size;
if (entry == NULL) {
pp = LIST_FIRST(&basetable->gpt_gp->consumer)->provider;
return (vtoc8_set_rawsize(basetable, pp));
}
table = (struct g_part_vtoc8_table *)basetable;
size = gpp->gpp_size;
if (vtoc8_align(table, NULL, &size) != 0)
return (EINVAL);
/* XXX: prevent unexpected shrinking. */
pp = entry->gpe_pp;
if ((g_debugflags & G_F_FOOTSHOOTING) == 0 && size < gpp->gpp_size &&
pp->mediasize / pp->sectorsize > size)
return (EBUSY);
entry->gpe_end = entry->gpe_start + size - 1;
be32enc(&table->vtoc.map[entry->gpe_index - 1].nblks, size);
return (0);
}
static const char *
g_part_vtoc8_name(struct g_part_table *table, struct g_part_entry *baseentry,
char *buf, size_t bufsz)
{
snprintf(buf, bufsz, "%c", 'a' + baseentry->gpe_index - 1);
return (buf);
}
static int
g_part_vtoc8_probe(struct g_part_table *table, struct g_consumer *cp)
{
struct g_provider *pp;
u_char *buf;
int error, ofs, res;
uint16_t cksum, magic;
pp = cp->provider;
/* Sanity-check the provider. */
if (pp->sectorsize != sizeof(struct vtoc8))
return (ENOSPC);
/* Check that there's a disklabel. */
buf = g_read_data(cp, 0, pp->sectorsize, &error);
if (buf == NULL)
return (error);
res = ENXIO; /* Assume mismatch */
/* Check the magic */
magic = be16dec(buf + offsetof(struct vtoc8, magic));
if (magic != VTOC_MAGIC)
goto out;
/* Check the sum */
cksum = 0;
for (ofs = 0; ofs < sizeof(struct vtoc8); ofs += 2)
cksum ^= be16dec(buf + ofs);
if (cksum != 0)
goto out;
res = G_PART_PROBE_PRI_NORM;
out:
g_free(buf);
return (res);
}
static int
g_part_vtoc8_read(struct g_part_table *basetable, struct g_consumer *cp)
{
struct g_provider *pp;
struct g_part_vtoc8_table *table;
struct g_part_entry *entry;
u_char *buf;
off_t chs, msize;
uint64_t offset, size;
u_int cyls, heads, sectors;
int error, index, withtags;
uint16_t tag;
pp = cp->provider;
buf = g_read_data(cp, 0, pp->sectorsize, &error);
if (buf == NULL)
return (error);
table = (struct g_part_vtoc8_table *)basetable;
bcopy(buf, &table->vtoc, sizeof(table->vtoc));
g_free(buf);
msize = MIN(pp->mediasize / pp->sectorsize, UINT32_MAX);
sectors = be16dec(&table->vtoc.nsecs);
if (sectors < 1)
goto invalid_label;
if (sectors != basetable->gpt_sectors && !basetable->gpt_fixgeom) {
g_part_geometry_heads(msize, sectors, &chs, &heads);
if (chs != 0) {
basetable->gpt_sectors = sectors;
basetable->gpt_heads = heads;
}
}
heads = be16dec(&table->vtoc.nheads);
if (heads < 1)
goto invalid_label;
if (heads != basetable->gpt_heads && !basetable->gpt_fixgeom)
basetable->gpt_heads = heads;
/*
* Except for ATA disks > 32GB, Solaris uses the native geometry
* as reported by the target for the labels while da(4) typically
* uses a synthetic one so we don't complain too loudly if these
* geometries don't match.
*/
if (bootverbose && (sectors != basetable->gpt_sectors ||
heads != basetable->gpt_heads))
printf("GEOM: %s: geometry does not match VTOC8 label "
"(label: %uh,%us GEOM: %uh,%us).\n", pp->name, heads,
sectors, basetable->gpt_heads, basetable->gpt_sectors);
table->secpercyl = heads * sectors;
cyls = be16dec(&table->vtoc.ncyls);
chs = cyls * table->secpercyl;
if (chs < 1 || chs > msize)
goto invalid_label;
basetable->gpt_first = 0;
basetable->gpt_last = chs - 1;
basetable->gpt_isleaf = 1;
withtags = (be32dec(&table->vtoc.sanity) == VTOC_SANITY) ? 1 : 0;
if (!withtags) {
printf("GEOM: %s: adding VTOC8 information.\n", pp->name);
be32enc(&table->vtoc.version, VTOC_VERSION);
bzero(&table->vtoc.volume, VTOC_VOLUME_LEN);
be16enc(&table->vtoc.nparts, VTOC8_NPARTS);
bzero(&table->vtoc.part, sizeof(table->vtoc.part));
be32enc(&table->vtoc.sanity, VTOC_SANITY);
}
basetable->gpt_entries = be16dec(&table->vtoc.nparts);
if (basetable->gpt_entries < g_part_vtoc8_scheme.gps_minent ||
basetable->gpt_entries > g_part_vtoc8_scheme.gps_maxent)
goto invalid_label;
for (index = basetable->gpt_entries - 1; index >= 0; index--) {
offset = be32dec(&table->vtoc.map[index].cyl) *
table->secpercyl;
size = be32dec(&table->vtoc.map[index].nblks);
if (size == 0)
continue;
if (withtags)
tag = be16dec(&table->vtoc.part[index].tag);
else
tag = (index == VTOC_RAW_PART)
? VTOC_TAG_BACKUP
: VTOC_TAG_UNASSIGNED;
if (index == VTOC_RAW_PART && tag != VTOC_TAG_BACKUP)
continue;
if (index != VTOC_RAW_PART && tag == VTOC_TAG_BACKUP)
continue;
entry = g_part_new_entry(basetable, index + 1, offset,
offset + size - 1);
if (tag == VTOC_TAG_BACKUP)
entry->gpe_internal = 1;
if (!withtags)
be16enc(&table->vtoc.part[index].tag, tag);
}
return (0);
invalid_label:
printf("GEOM: %s: invalid VTOC8 label.\n", pp->name);
return (EINVAL);
}
static const char *
g_part_vtoc8_type(struct g_part_table *basetable, struct g_part_entry *entry,
char *buf, size_t bufsz)
{
struct g_part_vtoc8_table *table;
uint16_t tag;
table = (struct g_part_vtoc8_table *)basetable;
tag = be16dec(&table->vtoc.part[entry->gpe_index - 1].tag);
if (tag == VTOC_TAG_FREEBSD_NANDFS)
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_NANDFS));
if (tag == VTOC_TAG_FREEBSD_SWAP)
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP));
if (tag == VTOC_TAG_FREEBSD_UFS)
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_UFS));
if (tag == VTOC_TAG_FREEBSD_VINUM)
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_VINUM));
if (tag == VTOC_TAG_FREEBSD_ZFS)
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_ZFS));
snprintf(buf, bufsz, "!%d", tag);
return (buf);
}
static int
g_part_vtoc8_write(struct g_part_table *basetable, struct g_consumer *cp)
{
struct g_provider *pp;
struct g_part_entry *entry;
struct g_part_vtoc8_table *table;
uint16_t sum;
u_char *p;
int error, index, match, offset;
pp = cp->provider;
table = (struct g_part_vtoc8_table *)basetable;
entry = LIST_FIRST(&basetable->gpt_entry);
for (index = 0; index < basetable->gpt_entries; index++) {
match = (entry != NULL && index == entry->gpe_index - 1)
? 1 : 0;
if (match) {
if (entry->gpe_deleted) {
be16enc(&table->vtoc.part[index].tag, 0);
be16enc(&table->vtoc.part[index].flag, 0);
be32enc(&table->vtoc.map[index].cyl, 0);
be32enc(&table->vtoc.map[index].nblks, 0);
}
entry = LIST_NEXT(entry, gpe_entry);
}
}
/* Calculate checksum. */
sum = 0;
p = (void *)&table->vtoc;
for (offset = 0; offset < sizeof(table->vtoc) - 2; offset += 2)
sum ^= be16dec(p + offset);
be16enc(&table->vtoc.cksum, sum);
error = g_write_data(cp, 0, p, pp->sectorsize);
return (error);
}

View file

@ -6,7 +6,6 @@ SUBDIR= geom_part_apm \
geom_part_ebr \
geom_part_gpt \
geom_part_ldm \
geom_part_mbr \
geom_part_vtoc8
geom_part_mbr
.include <bsd.subdir.mk>

View file

@ -1,10 +0,0 @@
# $FreeBSD$
.PATH: ${SRCTOP}/sys/geom/part
KMOD= geom_part_vtoc8
SRCS= g_part_vtoc8.c
SRCS+= bus_if.h device_if.h g_part_if.h
.include <bsd.kmod.mk>

View file

@ -1,110 +0,0 @@
/*-
* Copyright (c) 2008 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _SYS_DISK_VTOC_H_
#define _SYS_DISK_VTOC_H_
#include <sys/types.h>
#define VTOC_TAG_UNASSIGNED 0x00
#define VTOC_TAG_BOOT 0x01
#define VTOC_TAG_ROOT 0x02
#define VTOC_TAG_SWAP 0x03
#define VTOC_TAG_USR 0x04
#define VTOC_TAG_BACKUP 0x05 /* "c" partition */
#define VTOC_TAG_STAND 0x06
#define VTOC_TAG_VAR 0x07
#define VTOC_TAG_HOME 0x08
#define VTOC_TAG_ALTSCTR 0x09 /* alternate sector partition */
#define VTOC_TAG_CACHE 0x0a /* Solaris cachefs partition */
#define VTOC_TAG_VXVM_PUB 0x0e /* VxVM public region */
#define VTOC_TAG_VXVM_PRIV 0x0f /* VxVM private region */
/* NetBSD/mips defines this */
#define VTOC_TAG_NETBSD_FFS 0xff
/* FreeBSD tags: the high byte equals ELFOSABI_FREEBSD */
#define VTOC_TAG_FREEBSD_SWAP 0x0901
#define VTOC_TAG_FREEBSD_UFS 0x0902
#define VTOC_TAG_FREEBSD_VINUM 0x0903
#define VTOC_TAG_FREEBSD_ZFS 0x0904
#define VTOC_TAG_FREEBSD_NANDFS 0x0905
#define VTOC_FLAG_UNMNT 0x01 /* unmountable partition */
#define VTOC_FLAG_RDONLY 0x10 /* partition is read/only */
#define VTOC_ASCII_LEN 128
#define VTOC_BOOTSIZE 8192 /* 16 sectors */
#define VTOC_MAGIC 0xdabe
#define VTOC_RAW_PART 2
#define VTOC_SANITY 0x600ddeee
#define VTOC_VERSION 1
#define VTOC_VOLUME_LEN 8
#define VTOC8_NPARTS 8
struct vtoc8 {
char ascii[VTOC_ASCII_LEN];
uint32_t version;
char volume[VTOC_VOLUME_LEN];
uint16_t nparts;
struct {
uint16_t tag;
uint16_t flag;
} part[VTOC8_NPARTS];
uint16_t __alignment;
uint32_t bootinfo[3];
uint32_t sanity;
uint32_t reserved[10];
uint32_t timestamp[VTOC8_NPARTS];
uint16_t wskip;
uint16_t rskip;
char padding[152];
uint16_t rpm;
uint16_t physcyls;
uint16_t sparesecs;
uint16_t spare1[2];
uint16_t interleave;
uint16_t ncyls;
uint16_t altcyls;
uint16_t nheads;
uint16_t nsecs;
uint16_t spare2[2];
struct {
uint32_t cyl;
uint32_t nblks;
} map[VTOC8_NPARTS];
uint16_t magic;
uint16_t cksum;
};
#ifdef CTASSERT
CTASSERT(sizeof(struct vtoc8) == 512);
#endif
#endif /* _SYS_DISK_VTOC_H_ */

View file

@ -1,5 +0,0 @@
/*-
* This file is in the public domain.
*/
/* $FreeBSD$ */
#include <sys/disk/vtoc.h>

View file

@ -353,15 +353,6 @@ boot_geli_mbr_zfs_both() {
exit 1
}
boot_nogeli_vtoc8_ufs_ofw() {
dev=$1
dst=$2
# For non-native builds, ensure that geom_part(4) supports VTOC8.
kldload geom_part_vtoc8.ko
doit gpart bootcode -p ${vtoc8} ${dev}
}
usage() {
printf 'Usage: %s -b bios [-d destdir] -f fs [-g geli] [-h] [-o optargs] -s scheme <bootdev>\n' "$0"
printf 'Options:\n'
@ -431,9 +422,6 @@ gptzfs2=${srcroot}/boot/gptzfsboot
mbr0=${srcroot}/boot/mbr
mbr2=${srcroot}/boot/boot
# VTOC8
vtoc8=${srcroot}/boot/boot1
# sanity check here
# Check if we've been given arguments. If not, this script is probably being

View file

@ -27,8 +27,7 @@ SRCS+= \
bsd.c \
ebr.c \
gpt.c \
mbr.c \
vtoc8.c
mbr.c
BINDIR?=/usr/bin

View file

@ -3,7 +3,7 @@
mkimg_blksz_list="512 4096"
mkimg_format_list="qcow qcow2 raw vhd vhdf vhdx vmdk"
mkimg_geom_list="1x1 63x255"
mkimg_scheme_list="apm bsd ebr gpt mbr vtoc8"
mkimg_scheme_list="apm bsd ebr gpt mbr"
bootcode()
{

View file

@ -1,113 +0,0 @@
/*-
* Copyright (c) 2014 Juniper Networks, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/errno.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <vtoc.h>
#include "endian.h"
#include "image.h"
#include "mkimg.h"
#include "scheme.h"
static struct mkimg_alias vtoc8_aliases[] = {
{ ALIAS_FREEBSD_NANDFS, ALIAS_INT2TYPE(VTOC_TAG_FREEBSD_NANDFS) },
{ ALIAS_FREEBSD_SWAP, ALIAS_INT2TYPE(VTOC_TAG_FREEBSD_SWAP) },
{ ALIAS_FREEBSD_UFS, ALIAS_INT2TYPE(VTOC_TAG_FREEBSD_UFS) },
{ ALIAS_FREEBSD_VINUM, ALIAS_INT2TYPE(VTOC_TAG_FREEBSD_VINUM) },
{ ALIAS_FREEBSD_ZFS, ALIAS_INT2TYPE(VTOC_TAG_FREEBSD_NANDFS) },
{ ALIAS_NONE, 0 }
};
static lba_t
vtoc8_metadata(u_int where, lba_t blk)
{
blk += (where == SCHEME_META_IMG_START) ? 1 : 0;
return (round_cylinder(blk));
}
static int
vtoc8_write(lba_t imgsz, void *bootcode __unused)
{
struct vtoc8 vtoc8;
struct part *part;
u_char *p;
int error, n;
uint16_t ofs, sum;
imgsz = (lba_t)ncyls * nheads * nsecs;
memset(&vtoc8, 0, sizeof(vtoc8));
sprintf(vtoc8.ascii, "FreeBSD%lldM",
(long long)(imgsz * secsz / 1048576));
be32enc(&vtoc8.version, VTOC_VERSION);
be16enc(&vtoc8.nparts, VTOC8_NPARTS);
be32enc(&vtoc8.sanity, VTOC_SANITY);
be16enc(&vtoc8.rpm, 3600);
be16enc(&vtoc8.physcyls, ncyls);
be16enc(&vtoc8.ncyls, ncyls);
be16enc(&vtoc8.altcyls, 0);
be16enc(&vtoc8.nheads, nheads);
be16enc(&vtoc8.nsecs, nsecs);
be16enc(&vtoc8.magic, VTOC_MAGIC);
be32enc(&vtoc8.map[VTOC_RAW_PART].nblks, imgsz);
TAILQ_FOREACH(part, &partlist, link) {
n = part->index + ((part->index >= VTOC_RAW_PART) ? 1 : 0);
be16enc(&vtoc8.part[n].tag, ALIAS_TYPE2INT(part->type));
be32enc(&vtoc8.map[n].cyl, part->block / (nsecs * nheads));
be32enc(&vtoc8.map[n].nblks, part->size);
}
/* Calculate checksum. */
sum = 0;
p = (void *)&vtoc8;
for (ofs = 0; ofs < sizeof(vtoc8) - 2; ofs += 2)
sum ^= be16dec(p + ofs);
be16enc(&vtoc8.cksum, sum);
error = image_write(0, &vtoc8, 1);
return (error);
}
static struct mkimg_scheme vtoc8_scheme = {
.name = "vtoc8",
.description = "SMI VTOC8 disk labels",
.aliases = vtoc8_aliases,
.metadata = vtoc8_metadata,
.write = vtoc8_write,
.nparts = VTOC8_NPARTS - 1,
.maxsecsz = 512
};
SCHEME_DEFINE(vtoc8_scheme);

View file

@ -27,7 +27,6 @@
__FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <sys/vtoc.h>
#include <sys/param.h>
#include <assert.h>
#include <ctype.h>