diff options
author | smh <smh@FreeBSD.org> | 2015-12-01 00:53:03 +0000 |
---|---|---|
committer | smh <smh@FreeBSD.org> | 2015-12-01 00:53:03 +0000 |
commit | ee4f71729301a1493ad1cdae15cf8e8ce7d84a4f (patch) | |
tree | 081ad3bbf3d710d3e097dd316d7290d29138dc74 /sys/geom | |
parent | acd245f48b0de0fc33de0b76b5d8c4306c16b7ab (diff) | |
download | FreeBSD-src-ee4f71729301a1493ad1cdae15cf8e8ce7d84a4f.zip FreeBSD-src-ee4f71729301a1493ad1cdae15cf8e8ce7d84a4f.tar.gz |
MFC r291004:
Fix early kernel dump via dumpdev env
Sponsored by: Multiplay
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/geom_dev.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index bd8eb74..cd40abe 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -150,24 +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; + return (0); + len = strlen(devprefix); devname = devtoname(dev); if (strcmp(devname, dumpdev) != 0 && (strncmp(dumpdev, devprefix, len) != 0 || strcmp(devname, dumpdev + len) != 0)) - return; - if (g_dev_setdumpdev(dev, curthread) == 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 @@ -329,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; |