summaryrefslogtreecommitdiffstats
path: root/sys/geom/geom_dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/geom/geom_dev.c')
-rw-r--r--sys/geom/geom_dev.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c
index 8ee9ed8..cd40abe 100644
--- a/sys/geom/geom_dev.c
+++ b/sys/geom/geom_dev.c
@@ -124,6 +124,7 @@ g_dev_fini(struct g_class *mp)
{
freeenv(dumpdev);
+ dumpdev = NULL;
}
static int
@@ -149,18 +150,38 @@ g_dev_setdumpdev(struct cdev *dev, struct thread *td)
return (error);
}
-static void
+static int
init_dumpdev(struct cdev *dev)
{
+ struct g_consumer *cp;
+ const char *devprefix = "/dev/", *devname;
+ int error;
+ size_t len;
if (dumpdev == NULL)
- return;
- if (strcmp(devtoname(dev), dumpdev) != 0)
- return;
- if (g_dev_setdumpdev(dev, curthread) == 0) {
+ return (0);
+
+ len = strlen(devprefix);
+ devname = devtoname(dev);
+ if (strcmp(devname, dumpdev) != 0 &&
+ (strncmp(dumpdev, devprefix, len) != 0 ||
+ strcmp(devname, dumpdev + len) != 0))
+ return (0);
+
+ cp = (struct g_consumer *)dev->si_drv2;
+ error = g_access(cp, 1, 0, 0);
+ if (error != 0)
+ return (error);
+
+ error = g_dev_setdumpdev(dev, curthread);
+ if (error == 0) {
freeenv(dumpdev);
dumpdev = NULL;
}
+
+ (void)g_access(cp, -1, 0, 0);
+
+ return (error);
}
static void
@@ -322,7 +343,10 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
dev->si_iosize_max = MAXPHYS;
dev->si_drv2 = cp;
- init_dumpdev(dev);
+ error = init_dumpdev(dev);
+ if (error != 0)
+ printf("%s: init_dumpdev() failed (gp->name=%s, error=%d)\n",
+ __func__, gp->name, error);
if (adev != NULL) {
adev->si_iosize_max = MAXPHYS;
adev->si_drv2 = cp;
OpenPOWER on IntegriCloud