Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F136368453
D11873.id31724.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D11873.id31724.diff
View Options
Index: head/sys/geom/geom.h
===================================================================
--- head/sys/geom/geom.h
+++ head/sys/geom/geom.h
@@ -120,6 +120,15 @@
LIST_HEAD(,g_geom) geom;
};
+/*
+ * The g_geom_alias is a list node for aliases for the geom name
+ * for device node creation.
+ */
+struct g_geom_alias {
+ LIST_ENTRY(g_geom_alias) ga_next;
+ const char *ga_alias;
+};
+
#define G_VERSION_00 0x19950323
#define G_VERSION_01 0x20041207 /* add fflag to g_ioctl_t */
#define G_VERSION G_VERSION_01
@@ -150,6 +159,7 @@
unsigned flags;
#define G_GEOM_WITHER 1
#define G_GEOM_VOLATILE_BIO 2
+ LIST_HEAD(,g_geom_alias) aliases;
};
/*
@@ -269,6 +279,7 @@
void g_detach(struct g_consumer *cp);
void g_error_provider(struct g_provider *pp, int error);
struct g_provider *g_provider_by_name(char const *arg);
+void g_geom_add_alias(struct g_geom *gp, const char *alias);
int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len);
#define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v))
int g_handleattr(struct bio *bp, const char *attribute, const void *val,
Index: head/sys/geom/geom_dev.c
===================================================================
--- head/sys/geom/geom_dev.c
+++ head/sys/geom/geom_dev.c
@@ -315,10 +315,11 @@
g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
{
struct g_geom *gp;
+ struct g_geom_alias *gap;
struct g_consumer *cp;
struct g_dev_softc *sc;
int error;
- struct cdev *dev;
+ struct cdev *dev, *adev;
char buf[SPECNAMELEN + 6];
g_trace(G_T_TOPOLOGY, "dev_taste(%s,%s)", mp->name, pp->name);
@@ -357,6 +358,23 @@
g_dev_attrchanged(cp, "GEOM::physpath");
snprintf(buf, sizeof(buf), "cdev=%s", gp->name);
devctl_notify_f("GEOM", "DEV", "CREATE", buf, M_WAITOK);
+ /*
+ * Now add all the aliases for this drive
+ */
+ LIST_FOREACH(gap, &pp->geom->aliases, ga_next) {
+ error = make_dev_alias_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, &adev, dev,
+ "%s", gap->ga_alias);
+ if (error) {
+ printf("%s: make_dev_alias_p() failed (name=%s, error=%d)\n",
+ __func__, gap->ga_alias, error);
+ continue;
+ }
+ adev->si_flags |= SI_UNMAPPED;
+ adev->si_iosize_max = dev->si_iosize_max;
+ adev->si_drv2 = dev->si_drv2;
+ snprintf(buf, sizeof(buf), "cdev=%s", gap->ga_alias);
+ devctl_notify_f("GEOM", "DEV", "CREATE", buf, M_WAITOK);
+ }
return (gp);
}
Index: head/sys/geom/geom_dump.c
===================================================================
--- head/sys/geom/geom_dump.c
+++ head/sys/geom/geom_dump.c
@@ -234,6 +234,7 @@
{
struct g_consumer *cp2;
struct g_provider *pp2;
+ struct g_geom_alias *gap;
sbuf_printf(sb, " <geom id=\"%p\">\n", gp);
sbuf_printf(sb, " <class ref=\"%p\"/>\n", gp->class);
@@ -258,6 +259,11 @@
if (pp != NULL && pp != pp2)
continue;
g_conf_provider(sb, pp2);
+ }
+ LIST_FOREACH(gap, &gp->aliases, ga_next) {
+ sbuf_printf(sb, " <alias>\n");
+ g_conf_printf_escaped(sb, "%s", gap->ga_alias);
+ sbuf_printf(sb, " </alias>\n");
}
sbuf_printf(sb, " </geom>\n");
}
Index: head/sys/geom/geom_subr.c
===================================================================
--- head/sys/geom/geom_subr.c
+++ head/sys/geom/geom_subr.c
@@ -347,6 +347,7 @@
gp->rank = 1;
LIST_INIT(&gp->consumer);
LIST_INIT(&gp->provider);
+ LIST_INIT(&gp->aliases);
LIST_INSERT_HEAD(&mp->geom, gp, geom);
TAILQ_INSERT_HEAD(&geoms, gp, geoms);
strcpy(gp->name, sbuf_data(sb));
@@ -367,6 +368,7 @@
void
g_destroy_geom(struct g_geom *gp)
{
+ struct g_geom_alias *gap, *gaptmp;
g_topology_assert();
G_VALID_GEOM(gp);
@@ -380,6 +382,8 @@
g_cancel_event(gp);
LIST_REMOVE(gp, geom);
TAILQ_REMOVE(&geoms, gp, geoms);
+ LIST_FOREACH_SAFE(gap, &gp->aliases, ga_next, gaptmp)
+ g_free(gap);
g_free(gp->name);
g_free(gp);
}
@@ -1210,6 +1214,18 @@
if (strcmp(namea + deva, nameb + devb) == 0)
return (1);
return (0);
+}
+
+void
+g_geom_add_alias(struct g_geom *gp, const char *alias)
+{
+ struct g_geom_alias *gap;
+
+ gap = (struct g_geom_alias *)g_malloc(
+ sizeof(struct g_geom_alias) + strlen(alias) + 1, M_WAITOK);
+ strcpy((char *)(gap + 1), alias);
+ gap->ga_alias = (const char *)(gap + 1);
+ LIST_INSERT_HEAD(&gp->aliases, gap, ga_next);
}
#if defined(DIAGNOSTIC) || defined(DDB)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 18, 11:22 AM (7 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25502865
Default Alt Text
D11873.id31724.diff (4 KB)
Attached To
Mode
D11873: Create mechanism to allow nvd to be an alias for nda
Attached
Detach File
Event Timeline
Log In to Comment