svn commit: r322197 - head/sys/geom/part
Warner Losh
imp at FreeBSD.org
Mon Aug 7 21:12:34 UTC 2017
Author: imp
Date: Mon Aug 7 21:12:33 2017
New Revision: 322197
URL: https://svnweb.freebsd.org/changeset/base/322197
Log:
Add alias support to gpart.
When we're creating new providers for each of the partitions, add
aliases to the geom before we create the provider so when geom_dev
tastes the provider, the aliases are in place so the proper /dev
entries are created. So foo5p6 gets created as an alias for bar5p6
when foo is an alias for bar in the geom we're partitioning with
g_part. This also copies aliases from the container geom (eg disk) to
the label geom (the disk with GPT partitioning) so that aliases nest
properly.
Differential Revision: https://reviews.freebsd.org/D11873
Modified:
head/sys/geom/part/g_part.c
Modified: head/sys/geom/part/g_part.c
==============================================================================
--- head/sys/geom/part/g_part.c Mon Aug 7 21:12:28 2017 (r322196)
+++ head/sys/geom/part/g_part.c Mon Aug 7 21:12:33 2017 (r322197)
@@ -429,6 +429,7 @@ g_part_new_provider(struct g_geom *gp, struct g_part_t
struct g_consumer *cp;
struct g_provider *pp;
struct sbuf *sb;
+ struct g_geom_alias *gap;
off_t offset;
cp = LIST_FIRST(&gp->consumer);
@@ -439,6 +440,19 @@ g_part_new_provider(struct g_geom *gp, struct g_part_t
entry->gpe_offset = offset;
if (entry->gpe_pp == NULL) {
+ /*
+ * Add aliases to the geom before we create the provider so that
+ * geom_dev can taste it with all the aliases in place so all
+ * the aliased dev_t instances get created for each partition
+ * (eg foo5p7 gets created for bar5p7 when foo is an alias of bar).
+ */
+ LIST_FOREACH(gap, &table->gpt_gp->aliases, ga_next) {
+ sb = sbuf_new_auto();
+ G_PART_FULLNAME(table, entry, sb, gap->ga_alias);
+ sbuf_finish(sb);
+ g_geom_add_alias(gp, sbuf_data(sb));
+ sbuf_delete(sb);
+ }
sb = sbuf_new_auto();
G_PART_FULLNAME(table, entry, sb, gp->name);
sbuf_finish(sb);
@@ -1901,6 +1915,7 @@ g_part_taste(struct g_class *mp, struct g_provider *pp
struct g_part_entry *entry;
struct g_part_table *table;
struct root_hold_token *rht;
+ struct g_geom_alias *gap;
int attr, depth;
int error;
@@ -1913,10 +1928,12 @@ g_part_taste(struct g_class *mp, struct g_provider *pp
/*
* Create a GEOM with consumer and hook it up to the provider.
- * With that we become part of the topology. Optain read access
+ * With that we become part of the topology. Obtain read access
* to the provider.
*/
gp = g_new_geomf(mp, "%s", pp->name);
+ LIST_FOREACH(gap, &pp->geom->aliases, ga_next)
+ g_geom_add_alias(gp, gap->ga_alias);
cp = g_new_consumer(gp);
cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
error = g_attach(cp, pp);
More information about the svn-src-all
mailing list