Implement the G_PART_DUMPCONF method for all 6 schemes. Also call

the method for the (indent == NULL) case (i.e. the kern.geom.conftxt
sysctl). The purpose is to extend the conftxt output with scheme-
specific fields which can be used by libdisk. In particular, have
the schemes dump the xs and xt fields, which contain the backward
compatible values for class type and partition type. This allows
libdisk to work with the legacy slicers as well as with gpart and
helps/promotes migration.
This commit is contained in:
Marcel Moolenaar 2008-04-23 20:13:05 +00:00
parent 526bd70425
commit 5db670520f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=178444
7 changed files with 113 additions and 0 deletions

View file

@ -1489,6 +1489,13 @@ g_part_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
sbuf_printf(sb, " i %u o %ju ty %s", entry->gpe_index,
(uintmax_t)entry->gpe_offset,
G_PART_TYPE(table, entry, buf, sizeof(buf)));
/*
* libdisk compatibility quirk - the scheme dumps the
* slicer name and partition type in a way that is
* compatible with libdisk. When libdisk is not used
* anymore, this should go away.
*/
G_PART_DUMPCONF(table, entry, sb, indent);
} else if (cp != NULL) { /* Consumer configuration. */
KASSERT(pp == NULL, (__func__));
/* none */

View file

@ -61,6 +61,8 @@ static int g_part_apm_add(struct g_part_table *, struct g_part_entry *,
struct g_part_parms *);
static int g_part_apm_create(struct g_part_table *, struct g_part_parms *);
static int g_part_apm_destroy(struct g_part_table *, struct g_part_parms *);
static int g_part_apm_dumpconf(struct g_part_table *, struct g_part_entry *,
struct sbuf *, const char *);
static int g_part_apm_dumpto(struct g_part_table *, struct g_part_entry *);
static int g_part_apm_modify(struct g_part_table *, struct g_part_entry *,
struct g_part_parms *);
@ -76,6 +78,7 @@ static kobj_method_t g_part_apm_methods[] = {
KOBJMETHOD(g_part_add, g_part_apm_add),
KOBJMETHOD(g_part_create, g_part_apm_create),
KOBJMETHOD(g_part_destroy, g_part_apm_destroy),
KOBJMETHOD(g_part_dumpconf, g_part_apm_dumpconf),
KOBJMETHOD(g_part_dumpto, g_part_apm_dumpto),
KOBJMETHOD(g_part_modify, g_part_apm_modify),
KOBJMETHOD(g_part_name, g_part_apm_name),
@ -228,6 +231,20 @@ g_part_apm_destroy(struct g_part_table *basetable, struct g_part_parms *gpp)
return (0);
}
static int
g_part_apm_dumpconf(struct g_part_table *table, struct g_part_entry *baseentry,
struct sbuf *sb, const char *indent)
{
struct g_part_apm_entry *entry;
if (indent != NULL)
return (0);
entry = (struct g_part_apm_entry *)baseentry;
sbuf_printf(sb, " xs APPLE xt %s", entry->ent.ent_type);
return (0);
}
static int
g_part_apm_dumpto(struct g_part_table *table, struct g_part_entry *baseentry)
{

View file

@ -60,6 +60,8 @@ static int g_part_bsd_add(struct g_part_table *, struct g_part_entry *,
struct g_part_parms *);
static int g_part_bsd_create(struct g_part_table *, struct g_part_parms *);
static int g_part_bsd_destroy(struct g_part_table *, struct g_part_parms *);
static int g_part_bsd_dumpconf(struct g_part_table *, struct g_part_entry *,
struct sbuf *, const char *);
static int g_part_bsd_dumpto(struct g_part_table *, struct g_part_entry *);
static int g_part_bsd_modify(struct g_part_table *, struct g_part_entry *,
struct g_part_parms *);
@ -75,6 +77,7 @@ static kobj_method_t g_part_bsd_methods[] = {
KOBJMETHOD(g_part_add, g_part_bsd_add),
KOBJMETHOD(g_part_create, g_part_bsd_create),
KOBJMETHOD(g_part_destroy, g_part_bsd_destroy),
KOBJMETHOD(g_part_dumpconf, g_part_bsd_dumpconf),
KOBJMETHOD(g_part_dumpto, g_part_bsd_dumpto),
KOBJMETHOD(g_part_modify, g_part_bsd_modify),
KOBJMETHOD(g_part_name, g_part_bsd_name),
@ -213,6 +216,20 @@ g_part_bsd_destroy(struct g_part_table *basetable, struct g_part_parms *gpp)
return (0);
}
static int
g_part_bsd_dumpconf(struct g_part_table *table, struct g_part_entry *baseentry,
struct sbuf *sb, const char *indent)
{
struct g_part_bsd_entry *entry;
if (indent != NULL)
return (0);
entry = (struct g_part_bsd_entry *)baseentry;
sbuf_printf(sb, " xs BSD xt %u", entry->part.p_fstype);
return (0);
}
static int
g_part_bsd_dumpto(struct g_part_table *table, struct g_part_entry *baseentry)
{

View file

@ -88,6 +88,8 @@ static int g_part_gpt_add(struct g_part_table *, struct g_part_entry *,
static int g_part_gpt_bootcode(struct g_part_table *, struct g_part_parms *);
static int g_part_gpt_create(struct g_part_table *, struct g_part_parms *);
static int g_part_gpt_destroy(struct g_part_table *, struct g_part_parms *);
static int g_part_gpt_dumpconf(struct g_part_table *, struct g_part_entry *,
struct sbuf *, const char *);
static int g_part_gpt_dumpto(struct g_part_table *, struct g_part_entry *);
static int g_part_gpt_modify(struct g_part_table *, struct g_part_entry *,
struct g_part_parms *);
@ -104,6 +106,7 @@ static kobj_method_t g_part_gpt_methods[] = {
KOBJMETHOD(g_part_bootcode, g_part_gpt_bootcode),
KOBJMETHOD(g_part_create, g_part_gpt_create),
KOBJMETHOD(g_part_destroy, g_part_gpt_destroy),
KOBJMETHOD(g_part_dumpconf, g_part_gpt_dumpconf),
KOBJMETHOD(g_part_dumpto, g_part_gpt_dumpto),
KOBJMETHOD(g_part_modify, g_part_gpt_modify),
KOBJMETHOD(g_part_name, g_part_gpt_name),
@ -429,6 +432,21 @@ g_part_gpt_destroy(struct g_part_table *basetable, struct g_part_parms *gpp)
return (0);
}
static int
g_part_gpt_dumpconf(struct g_part_table *table, struct g_part_entry *baseentry,
struct sbuf *sb, const char *indent)
{
struct g_part_gpt_entry *entry;
if (indent != NULL)
return (0);
entry = (struct g_part_gpt_entry *)baseentry;
sbuf_printf(sb, " xs GPT xt ");
sbuf_printf_uuid(sb, &entry->ent.ent_type);
return (0);
}
static int
g_part_gpt_dumpto(struct g_part_table *table, struct g_part_entry *baseentry)
{

View file

@ -62,6 +62,8 @@ static int g_part_mbr_add(struct g_part_table *, struct g_part_entry *,
static int g_part_mbr_bootcode(struct g_part_table *, struct g_part_parms *);
static int g_part_mbr_create(struct g_part_table *, struct g_part_parms *);
static int g_part_mbr_destroy(struct g_part_table *, struct g_part_parms *);
static int g_part_mbr_dumpconf(struct g_part_table *, struct g_part_entry *,
struct sbuf *, const char *);
static int g_part_mbr_dumpto(struct g_part_table *, struct g_part_entry *);
static int g_part_mbr_modify(struct g_part_table *, struct g_part_entry *,
struct g_part_parms *);
@ -78,6 +80,7 @@ static kobj_method_t g_part_mbr_methods[] = {
KOBJMETHOD(g_part_bootcode, g_part_mbr_bootcode),
KOBJMETHOD(g_part_create, g_part_mbr_create),
KOBJMETHOD(g_part_destroy, g_part_mbr_destroy),
KOBJMETHOD(g_part_dumpconf, g_part_mbr_dumpconf),
KOBJMETHOD(g_part_dumpto, g_part_mbr_dumpto),
KOBJMETHOD(g_part_modify, g_part_mbr_modify),
KOBJMETHOD(g_part_name, g_part_mbr_name),
@ -245,6 +248,20 @@ g_part_mbr_destroy(struct g_part_table *basetable, struct g_part_parms *gpp)
return (0);
}
static int
g_part_mbr_dumpconf(struct g_part_table *table, struct g_part_entry *baseentry,
struct sbuf *sb, const char *indent)
{
struct g_part_mbr_entry *entry;
if (indent != NULL)
return (0);
entry = (struct g_part_mbr_entry *)baseentry;
sbuf_printf(sb, " xs MBR xt %u", entry->ent.dp_typ);
return (0);
}
static int
g_part_mbr_dumpto(struct g_part_table *table, struct g_part_entry *baseentry)
{

View file

@ -63,6 +63,8 @@ static int g_part_pc98_add(struct g_part_table *, struct g_part_entry *,
static int g_part_pc98_bootcode(struct g_part_table *, struct g_part_parms *);
static int g_part_pc98_create(struct g_part_table *, struct g_part_parms *);
static int g_part_pc98_destroy(struct g_part_table *, struct g_part_parms *);
static int g_part_pc98_dumpconf(struct g_part_table *, struct g_part_entry *,
struct sbuf *, const char *);
static int g_part_pc98_dumpto(struct g_part_table *, struct g_part_entry *);
static int g_part_pc98_modify(struct g_part_table *, struct g_part_entry *,
struct g_part_parms *);
@ -79,6 +81,7 @@ static kobj_method_t g_part_pc98_methods[] = {
KOBJMETHOD(g_part_bootcode, g_part_pc98_bootcode),
KOBJMETHOD(g_part_create, g_part_pc98_create),
KOBJMETHOD(g_part_destroy, g_part_pc98_destroy),
KOBJMETHOD(g_part_dumpconf, g_part_pc98_dumpconf),
KOBJMETHOD(g_part_dumpto, g_part_pc98_dumpto),
KOBJMETHOD(g_part_modify, g_part_pc98_modify),
KOBJMETHOD(g_part_name, g_part_pc98_name),
@ -233,6 +236,21 @@ g_part_pc98_destroy(struct g_part_table *basetable, struct g_part_parms *gpp)
return (0);
}
static int
g_part_pc98_dumpconf(struct g_part_table *table,
struct g_part_entry *baseentry, struct sbuf *sb, const char *indent)
{
struct g_part_pc98_entry *entry;
u_int type;
if (indent != NULL)
return (0);
entry = (struct g_part_pc98_entry *)baseentry;
type = entry->ent.dp_mid + (entry->ent.dp_sid << 8);
sbuf_printf(sb, " xs PC98 xt %u", type);
return (0);
}
static int
g_part_pc98_dumpto(struct g_part_table *table, struct g_part_entry *baseentry)
{

View file

@ -55,6 +55,8 @@ 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 int 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 *);
@ -70,6 +72,7 @@ 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_name, g_part_vtoc8_name),
@ -235,6 +238,22 @@ g_part_vtoc8_destroy(struct g_part_table *basetable, struct g_part_parms *gpp)
return (0);
}
static int
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;
if (indent != NULL)
return (0);
table = (struct g_part_vtoc8_table *)basetable;
sbuf_printf(sb, " xs SUN sc %u hd %u alt %u",
be16dec(&table->vtoc.nsecs), be16dec(&table->vtoc.nheads),
be16dec(&table->vtoc.altcyls));
return (0);
}
static int
g_part_vtoc8_dumpto(struct g_part_table *basetable, struct g_part_entry *entry)
{