summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2012-11-01 17:01:05 +0000
committeralfred <alfred@FreeBSD.org>2012-11-01 17:01:05 +0000
commit4a74d2e51a5c00dd3b2ee1ac5829aace6d13d817 (patch)
treee8b52ec5f3f944661c5f829b80fa86f03ac121a8 /sys
parent768e7f7830fb52401cfc9229634414aaab2d31ab (diff)
downloadFreeBSD-src-4a74d2e51a5c00dd3b2ee1ac5829aace6d13d817.zip
FreeBSD-src-4a74d2e51a5c00dd3b2ee1ac5829aace6d13d817.tar.gz
Provide a device name in the sysctl tree for programs to query the
state of crashdump target devices. This will be used to add a "-l" (ell) flag to dumpon(8) to list the currently configured dumpdev. Reviewed by: phk
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/null/null.c2
-rw-r--r--sys/geom/geom_dev.c6
-rw-r--r--sys/kern/kern_shutdown.c12
-rw-r--r--sys/sys/conf.h2
4 files changed, 16 insertions, 6 deletions
diff --git a/sys/dev/null/null.c b/sys/dev/null/null.c
index 0fe46fa..c1208c11 100644
--- a/sys/dev/null/null.c
+++ b/sys/dev/null/null.c
@@ -91,7 +91,7 @@ null_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t data __unused,
case DIOCSKERNELDUMP:
error = priv_check(td, PRIV_SETDUMPER);
if (error == 0)
- error = set_dumper(NULL);
+ error = set_dumper(NULL, NULL);
break;
case FIONBIO:
break;
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c
index fcec134..a32aaa1 100644
--- a/sys/geom/geom_dev.c
+++ b/sys/geom/geom_dev.c
@@ -359,7 +359,7 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread
case DIOCSKERNELDUMP:
u = *((u_int *)data);
if (!u) {
- set_dumper(NULL);
+ set_dumper(NULL, NULL);
error = 0;
break;
}
@@ -368,7 +368,7 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread
i = sizeof kd;
error = g_io_getattr("GEOM::kerneldump", cp, &i, &kd);
if (!error) {
- error = set_dumper(&kd.di);
+ error = set_dumper(&kd.di, devtoname(dev));
if (!error)
dev->si_flags |= SI_DUMPDEV;
}
@@ -526,7 +526,7 @@ g_dev_orphan(struct g_consumer *cp)
/* Reset any dump-area set on this device */
if (dev->si_flags & SI_DUMPDEV)
- set_dumper(NULL);
+ set_dumper(NULL, NULL);
/* Destroy the struct cdev *so we get no more requests */
destroy_dev(dev);
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index d676136..d6c8b2d 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -712,18 +712,28 @@ kthread_shutdown(void *arg, int howto)
printf("done\n");
}
+static char dumpdevname[sizeof(((struct cdev*)NULL)->si_name)];
+SYSCTL_STRING(_kern_shutdown, OID_AUTO, dumpdevname, CTLFLAG_RD,
+ dumpdevname, 0, "Device for kernel dumps");
+
/* Registration of dumpers */
int
-set_dumper(struct dumperinfo *di)
+set_dumper(struct dumperinfo *di, const char *devname)
{
if (di == NULL) {
bzero(&dumper, sizeof dumper);
+ dumpdevname[0] = '\0';
return (0);
}
if (dumper.dumper != NULL)
return (EBUSY);
dumper = *di;
+ strlcpy(dumpdevname, devname, sizeof(dumpdevname));
+ if (strlen(dumpdevname) != strlen(devname)) {
+ printf("set_dumper: device name truncated from '%s' -> '%s'\n",
+ devname, dumpdevname);
+ }
return (0);
}
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index 96d835b..e818722 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -331,7 +331,7 @@ struct dumperinfo {
off_t mediasize; /* Space available in bytes. */
};
-int set_dumper(struct dumperinfo *);
+int set_dumper(struct dumperinfo *, const char *_devname);
int dump_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t);
void dumpsys(struct dumperinfo *);
int doadump(boolean_t);
OpenPOWER on IntegriCloud