Date: Thu, 1 Nov 2012 17:01:05 +0000 (UTC) From: Alfred Perlstein <alfred@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r242439 - in head/sys: dev/null geom kern sys Message-ID: <201211011701.qA1H15fb036810@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: alfred Date: Thu Nov 1 17:01:05 2012 New Revision: 242439 URL: http://svn.freebsd.org/changeset/base/242439 Log: 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 Modified: head/sys/dev/null/null.c head/sys/geom/geom_dev.c head/sys/kern/kern_shutdown.c head/sys/sys/conf.h Modified: head/sys/dev/null/null.c ============================================================================== --- head/sys/dev/null/null.c Thu Nov 1 16:54:26 2012 (r242438) +++ head/sys/dev/null/null.c Thu Nov 1 17:01:05 2012 (r242439) @@ -91,7 +91,7 @@ null_ioctl(struct cdev *dev __unused, u_ case DIOCSKERNELDUMP: error = priv_check(td, PRIV_SETDUMPER); if (error == 0) - error = set_dumper(NULL); + error = set_dumper(NULL, NULL); break; case FIONBIO: break; Modified: head/sys/geom/geom_dev.c ============================================================================== --- head/sys/geom/geom_dev.c Thu Nov 1 16:54:26 2012 (r242438) +++ head/sys/geom/geom_dev.c Thu Nov 1 17:01:05 2012 (r242439) @@ -359,7 +359,7 @@ g_dev_ioctl(struct cdev *dev, u_long cmd 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 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); Modified: head/sys/kern/kern_shutdown.c ============================================================================== --- head/sys/kern/kern_shutdown.c Thu Nov 1 16:54:26 2012 (r242438) +++ head/sys/kern/kern_shutdown.c Thu Nov 1 17:01:05 2012 (r242439) @@ -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); } Modified: head/sys/sys/conf.h ============================================================================== --- head/sys/sys/conf.h Thu Nov 1 16:54:26 2012 (r242438) +++ head/sys/sys/conf.h Thu Nov 1 17:01:05 2012 (r242439) @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211011701.qA1H15fb036810>