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
This commit is contained in:
Alfred Perlstein 2012-11-01 17:01:05 +00:00
parent 902514f628
commit bad7e7f3dd
4 changed files with 16 additions and 6 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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);