summaryrefslogtreecommitdiffstats
path: root/usr.sbin/asf/asf_kld.c
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2006-06-18 11:14:40 +0000
committeryar <yar@FreeBSD.org>2006-06-18 11:14:40 +0000
commitb8dd56e74a47ba3bfe3b0ba989e5ebf6b300773e (patch)
tree5e747828fd45e3c069a7166baad2734e67c1222f /usr.sbin/asf/asf_kld.c
parent7357250c8b4cf7980db9045c3186446ded299d15 (diff)
downloadFreeBSD-src-b8dd56e74a47ba3bfe3b0ba989e5ebf6b300773e.zip
FreeBSD-src-b8dd56e74a47ba3bfe3b0ba989e5ebf6b300773e.tar.gz
Give a major overhaul to asf(8).
The improvements are: - can get the kld info from core files via kvm(3); - can use kldstat(2) directly, which is a piece of cake; - can use .symbols or whatever, which allows for use by non-developers when reporting system crashes -- now asf(8) can be mentioned in the handbook at last; - speed (no more double fts(3) per loaded module); - various bugs fixed. At the same time, the new asf(8) should stay compatible with the old one, bar bugs. Perhaps some defaults may be changed later to match today's state of affairs. Reviewed by: grog MFC after: 1 month Sponsored by: RiNet (Cronyx Plus LLC)
Diffstat (limited to 'usr.sbin/asf/asf_kld.c')
-rw-r--r--usr.sbin/asf/asf_kld.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/usr.sbin/asf/asf_kld.c b/usr.sbin/asf/asf_kld.c
new file mode 100644
index 0000000..1d6a2b7
--- /dev/null
+++ b/usr.sbin/asf/asf_kld.c
@@ -0,0 +1,59 @@
+/*-
+ * Copyright (c) 2006 The FreeBSD Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/linker.h>
+#include <err.h>
+#include <string.h>
+
+#include "asf.h"
+
+/*
+ * Get the linker file list using the kld interface.
+ * Works with a live kernel only.
+ */
+void
+asf_kld()
+{
+ struct kld_file_stat kfs;
+ int fid = 0; /* indicates the beginning of the linker file list */
+
+ while ((fid = kldnext(fid)) != 0) {
+ if (fid == -1)
+ err(2, "kldnext");
+ kfs.version = sizeof(kfs); /* must be set for kldstat(2) */
+ /* Get info on this linker file */
+ if (kldstat(fid, &kfs) == -1)
+ err(2, "kldstat");
+ if (strcmp(kfs.name, KERNFILE) == 0)
+ continue;
+ /* Add to our list of linker files */
+ kfile_add(kfs.name, kfs.address);
+ }
+}
OpenPOWER on IntegriCloud