From 5d76604145789b4624c77e8e5ddd9f9a43bc4b44 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Sun, 27 Oct 2013 16:18:48 +0000 Subject: [PATCH] If the initial attempt to open /dev/ksyms fails, kldload the ksyms module and retry. --- cddl/contrib/opensolaris/cmd/lockstat/sym.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cddl/contrib/opensolaris/cmd/lockstat/sym.c b/cddl/contrib/opensolaris/cmd/lockstat/sym.c index 78b27d2bdcd2..1aa77ad3f314 100644 --- a/cddl/contrib/opensolaris/cmd/lockstat/sym.c +++ b/cddl/contrib/opensolaris/cmd/lockstat/sym.c @@ -179,8 +179,19 @@ symtab_init(void) size_t sz; #endif +#if defined(__FreeBSD__) + if ((fd = open("/dev/ksyms", O_RDONLY)) == -1) { + if (errno == ENOENT && modfind("ksyms") == -1) { + kldload("ksyms"); + fd = open("/dev/ksyms", O_RDONLY); + } + if (fd == -1) + return (-1); + } +#else if ((fd = open("/dev/ksyms", O_RDONLY)) == -1) return (-1); +#endif #if defined(sun) (void) elf_version(EV_CURRENT);