summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2004-06-07 13:33:09 +0000
committerpjd <pjd@FreeBSD.org>2004-06-07 13:33:09 +0000
commit3b62f6e040378d864cde9a9e39d22393b6f611ea (patch)
treee0282cbd68b7fc2c1797b882c1cc3dd9ffed677e /sys/geom
parented5bc9730f0d5119229990cff3aec71c082c7b40 (diff)
downloadFreeBSD-src-3b62f6e040378d864cde9a9e39d22393b6f611ea.zip
FreeBSD-src-3b62f6e040378d864cde9a9e39d22393b6f611ea.tar.gz
Don't allow for duplicated entries creation.
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/nop/g_nop.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/geom/nop/g_nop.c b/sys/geom/nop/g_nop.c
index df666bf..52f4549 100644
--- a/sys/geom/nop/g_nop.c
+++ b/sys/geom/nop/g_nop.c
@@ -124,6 +124,7 @@ g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
struct g_geom *gp;
struct g_provider *newpp;
struct g_consumer *cp;
+ char name[64];
int error;
g_topology_assert();
@@ -132,10 +133,16 @@ g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
newpp = NULL;
cp = NULL;
- gp = g_new_geomf(mp, "%s%s", pp->name, G_NOP_SUFFIX);
+ snprintf(name, sizeof(name), "%s%s", pp->name, G_NOP_SUFFIX);
+ LIST_FOREACH(gp, &mp->geom, geom) {
+ if (strcmp(gp->name, name) == 0) {
+ gctl_error(req, "Provider %s already exists.", name);
+ return (EEXIST);
+ }
+ }
+ gp = g_new_geomf(mp, name);
if (gp == NULL) {
- gctl_error(req, "Cannot create geom %s%s.", pp->name,
- G_NOP_SUFFIX);
+ gctl_error(req, "Cannot create geom %s%s.", name);
return (ENOMEM);
}
gp->softc = NULL;
@@ -147,8 +154,7 @@ g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
newpp = g_new_providerf(gp, gp->name);
if (newpp == NULL) {
- gctl_error(req, "Cannot create provider %s%s.", pp->name,
- G_NOP_SUFFIX);
+ gctl_error(req, "Cannot create provider %s%s.", name);
error = ENOMEM;
goto fail;
}
OpenPOWER on IntegriCloud