diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 3873a51f7359..0ef204ca9e46 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -38,6 +38,9 @@ # xargs -n1 | sort | uniq -d; # done +# 20180615: asf(8) removed +OLD_FILES+=usr/bin/asf +OLD_FILES+=usr/share/man/man8/asf.8.gz # 20180609: obsolete libc++ files missed from the 5.0.0 import OLD_FILES+=usr/include/c++/v1/__refstring OLD_FILES+=usr/include/c++/v1/__undef_min_max diff --git a/targets/pseudo/userland/Makefile.depend b/targets/pseudo/userland/Makefile.depend index 893d8cbcc5da..470a57d10759 100644 --- a/targets/pseudo/userland/Makefile.depend +++ b/targets/pseudo/userland/Makefile.depend @@ -810,7 +810,6 @@ DIRDEPS.amd64= \ usr.sbin/acpi/acpidump \ usr.sbin/acpi/iasl \ usr.sbin/apm \ - usr.sbin/asf \ usr.sbin/bhyve \ usr.sbin/bhyvectl \ usr.sbin/bhyveload \ @@ -842,7 +841,6 @@ DIRDEPS.i386= \ sbin/sconfig \ usr.sbin/apm \ usr.sbin/apmd \ - usr.sbin/asf \ usr.sbin/btxld \ usr.sbin/cpucontrol \ usr.sbin/hyperv/tools \ diff --git a/usr.sbin/Makefile.amd64 b/usr.sbin/Makefile.amd64 index aa5c487f5425..c44b4401c89e 100644 --- a/usr.sbin/Makefile.amd64 +++ b/usr.sbin/Makefile.amd64 @@ -9,7 +9,6 @@ SUBDIR+= acpi .if ${MK_APM} != "no" SUBDIR+= apm .endif -SUBDIR+= asf .if ${MK_BHYVE} != "no" SUBDIR+= bhyve SUBDIR+= bhyvectl diff --git a/usr.sbin/Makefile.i386 b/usr.sbin/Makefile.i386 index 3d64cb2d6b29..4a4dcbea9558 100644 --- a/usr.sbin/Makefile.i386 +++ b/usr.sbin/Makefile.i386 @@ -7,7 +7,6 @@ SUBDIR+= acpi SUBDIR+= apm SUBDIR+= apmd .endif -SUBDIR+= asf SUBDIR+= boot0cfg .if ${MK_TOOLCHAIN} != "no" SUBDIR+= btxld diff --git a/usr.sbin/asf/Makefile b/usr.sbin/asf/Makefile deleted file mode 100644 index 49f93059923c..000000000000 --- a/usr.sbin/asf/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD$ - -PROG= asf -SRCS= asf.c asf_kld.c asf_kvm.c asf_prog.c -MAN= asf.8 - -LIBADD= kvm - -.include diff --git a/usr.sbin/asf/Makefile.depend b/usr.sbin/asf/Makefile.depend deleted file mode 100644 index 4a0ebeceed6f..000000000000 --- a/usr.sbin/asf/Makefile.depend +++ /dev/null @@ -1,19 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - lib/libelf \ - lib/libkvm \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/asf/asf.8 b/usr.sbin/asf/asf.8 deleted file mode 100644 index 62ecdca15a76..000000000000 --- a/usr.sbin/asf/asf.8 +++ /dev/null @@ -1,188 +0,0 @@ -.\" Copyright (c) 2003 Greg Lehey. 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 Greg Lehey ``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 Greg Lehey 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. -.\" -.\" $FreeBSD$ -.\" -.Dd December 20, 2006 -.Dt ASF 8 -.Os -.Sh NAME -.Nm asf -.Nd add symbol files -.Sh SYNOPSIS -.Nm -.Op Fl afKksVx -.Op Fl M Ar core -.Op Fl N Ar system -.Op Fl o Ar outfile -.Op Fl X Ar suffix -.Op Ar modules-path Op Ar outfile -.Sh DEPRECATION NOTICE -The -.Nm -utility is not present in -.Fx 12.0 -and later. -The -.Xr kgdb 1 -debugger handles kernel module state internally. -.Sh DESCRIPTION -By default, -.Nm -reads -.Xr kldstat 8 -output from standard input and writes to the -.Pa .asf -file a list of -.Xr gdb 1 -commands to add symbol files from KLDs in subdirectories of the subdirectory -.Pa modules -of the current directory, which is intended to be a kernel build directory. -This allows -.Xr gdb 1 -to load the symbols into the debugging environment. -.Pp -An optional -.Ar modules-path -argument can specify a semicolon-separated list of directory pathnames -similar to the -.Va kern.module_path -sysctl. -Each directory in the list will be searched in turn for modules. -The default list consists of just one element, -.Pa modules , -which is suitable if the current directory is a kernel build directory. -.Pp -If -.Ar outfile -is specified, -.Nm -writes to it instead of -.Pa .asf . -If -.Ar outfile -is a single dash -.Pq Sq Fl , -standard output is used. -.Sh OPTIONS -The following options modify the function of -.Nm : -.Bl -tag -width indent -.It Fl a -When writing to an explicit -.Ar outfile , -append to the file rather than overwriting it. -.It Fl f -Instead of trying to simplistically guess the path for each module, perform -a traversal in the same way that -.Xr find 1 -does to locate an exact path for each module, no matter where in -.Ar modules-path -it is located. -.It Fl K -Instead of reading from standard input, use the conventional -system interface to get the list of modules currently loaded. -.It Fl k -Instead of reading from standard input, start a -.Xr kldstat 8 -and read the information from it. -.It Fl M -Specify the core file for -.Xr kvm 3 . -Implies -.Fl V . -.It Fl N -Specify the system file for -.Xr kvm 3 . -Implies -.Fl V . -.It Fl o -Specify the file for -.Nm -to write or append its output to. -If -.Ar outfile -is a single dash -.Pq Sq Fl , -standard output is used. -.It Fl s -Do not prepend a (guessed) subdirectory of the module path. -.It Fl V -Instead of reading from standard input, use the -.Xr kvm 3 -interface to get the list of modules. -This interface allows for inspecting system crash dumps, -as well as the live system. -The -.Fl M -and -.Fl N -options will be of use if inspecting a crash dump. -Elevated privileges, e.g., those of a superuser, -may be needed to use this option. -.It Fl X -Add -.Ar suffix -to the list of suffixes -.Nm -tries to append to KLD file names. -The default list consists of -.Pa .debug , -.Pa .symbols , -and the null suffix. -The null suffix always stays at the list tail, after the suffix added. -Should it be needed in the middle of the list, -a blank suffix can be specified to -.Fl X -instead. -.It Fl x -Clear the list of suffixes -.Nm -tries to append to KLD file names. -Only the null suffix is left in the list. -.El -.Sh EXAMPLES -To add symbol files from the system search path specified by the -.Va kern.module_path -sysctl, the following command can be used: -.Pp -.Dl asf -s `sysctl -n kern.module_path` -.Sh SEE ALSO -.Xr gdb 1 , -.Xr kvm 3 , -.Xr kld 4 , -.Xr kldstat 8 , -.Xr sysctl 8 -.Sh HISTORY -The -.Nm -utility first appeared in -.Fx 5.2 . -.Sh AUTHORS -.An Greg Lehey Aq Mt grog@FreeBSD.org -.Sh BUGS -Module paths are guessed in a rather naive way by default. -It is likely to lag behind the changes to the build tree layout. -Using -.Fl f -is recommended. diff --git a/usr.sbin/asf/asf.c b/usr.sbin/asf/asf.c deleted file mode 100644 index 3bcbb2d9c80f..000000000000 --- a/usr.sbin/asf/asf.c +++ /dev/null @@ -1,429 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2002, 2003 Greg Lehey - * 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 ``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 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. - */ -/* $Id: asf.c,v 1.4 2003/05/04 02:55:20 grog Exp grog $ */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "asf.h" - -struct kfile { - char *name; - caddr_t addr; - int seen; - STAILQ_ENTRY(kfile) link; -}; - -static STAILQ_HEAD(,kfile) kfile_head = STAILQ_HEAD_INITIALIZER(kfile_head); - -void -kfile_add(const char *name, caddr_t addr) -{ - struct kfile *kfp; - - if ((kfp = malloc(sizeof(*kfp))) == NULL || - (kfp->name = strdup(name)) == NULL) - errx(2, "out of memory"); - kfp->addr = addr; - kfp->seen = 0; - STAILQ_INSERT_TAIL(&kfile_head, kfp, link); -} - -static struct kfile * -kfile_find(const char *name) -{ - struct kfile *kfp; - - STAILQ_FOREACH(kfp, &kfile_head, link) - if (strcmp(kfp->name, name) == 0) - return (kfp); /* found */ - - return (NULL); /* not found */ -} - -static int -kfile_allseen(void) -{ - struct kfile *kfp; - - STAILQ_FOREACH(kfp, &kfile_head, link) - if (!kfp->seen) - return (0); /* at least one unseen */ - - return (1); /* all seen */ -} - -static int -kfile_empty(void) -{ - return (STAILQ_EMPTY(&kfile_head)); -} - -/* - * Take a blank separated list of tokens and turn it into a list of - * individual nul-delimited strings. Build a list of pointers at - * token, which must have enough space for the tokens. Return the - * number of tokens, or -1 on error (typically a missing string - * delimiter). - */ -int -tokenize(char *cptr, char *token[], int maxtoken) -{ - char delim; /* delimiter to search for */ - int tokennr; /* index of this token */ - - for (tokennr = 0; tokennr < maxtoken;) { - while (isspace(*cptr)) - cptr++; /* skip initial white space */ - if ((*cptr == '\0') || (*cptr == '\n') - || (*cptr == '#')) /* end of line */ - return tokennr; /* return number of tokens found */ - delim = *cptr; - token[tokennr] = cptr; /* point to it */ - tokennr++; /* one more */ - if (tokennr == maxtoken) /* run off the end? */ - return tokennr; - if ((delim == '\'') || (delim == '"')) { /* delimitered */ - for (;;) { - cptr++; - if ((*cptr == delim) - && (cptr[-1] != '\\')) { /* found the partner */ - cptr++; /* move on past */ - if (!isspace(*cptr)) /* no space after closing quote */ - return -1; - *cptr++ = '\0'; /* delimit */ - } else if ((*cptr == '\0') - || (*cptr == '\n')) /* end of line */ - return -1; - } - } else { /* not quoted */ - while ((*cptr != '\0') && (!isspace(*cptr)) && (*cptr != '\n')) - cptr++; - if (*cptr != '\0') /* not end of the line, */ - *cptr++ = '\0'; /* delimit and move to the next */ - } - } - return maxtoken; /* can't get here */ -} - -static void -doobj(const char *path, caddr_t addr, FILE *out) -{ - uintmax_t base = (uintptr_t)addr; - uintmax_t textaddr = 0; - uintmax_t dataaddr = 0; - uintmax_t bssaddr = 0; - uintmax_t *up; - int octokens; - char *octoken[MAXTOKEN]; - char ocbuf[LINE_MAX + PATH_MAX]; - FILE *objcopy; - - snprintf(ocbuf, sizeof(ocbuf), - "/usr/bin/objdump --section-headers %s", path); - if ((objcopy = popen(ocbuf, "r")) == NULL) - err(2, "can't start %s", ocbuf); - while (fgets(ocbuf, sizeof(ocbuf), objcopy)) { - octokens = tokenize(ocbuf, octoken, MAXTOKEN); - if (octokens <= 1) - continue; - up = NULL; - if (strcmp(octoken[1], ".text") == 0) - up = &textaddr; - else if (strcmp(octoken[1], ".data") == 0) - up = &dataaddr; - else if (strcmp(octoken[1], ".bss") == 0) - up = &bssaddr; - if (up == NULL) - continue; - *up = strtoumax(octoken[3], NULL, 16) + base; - } - if (textaddr) { /* we must have a text address */ - fprintf(out, "add-symbol-file %s 0x%jx", path, textaddr); - if (dataaddr) - fprintf(out, " -s .data 0x%jx", dataaddr); - if (bssaddr) - fprintf(out, " -s .bss 0x%jx", bssaddr); - fprintf(out, "\n"); - } -} - -static void -findmodules(char *path_argv[], const char *sfx[], FILE *out) -{ - char *p; - FTS *fts; - FTSENT *ftsent; - struct kfile *kfp; - int i; - int sl; - - /* Have to fts once per suffix to find preferred suffixes first */ - do { - sl = *sfx ? strlen(*sfx) : 0; /* current suffix length */ - fts = fts_open(path_argv, FTS_PHYSICAL | FTS_NOCHDIR, NULL); - if (fts == NULL) - err(2, "can't begin traversing module path"); - while ((ftsent = fts_read(fts)) != NULL) { - if (ftsent->fts_info == FTS_DNR || - ftsent->fts_info == FTS_ERR || - ftsent->fts_info == FTS_NS) { - errno = ftsent->fts_errno; - err(2, "error while traversing path %s", ftsent->fts_path); - } - if (ftsent->fts_info != FTS_F) - continue; /* not a plain file */ - - if (sl > 0) { - /* non-blank suffix; see if file name has it */ - i = ftsent->fts_namelen - sl; - if (i <= 0 || strcmp(ftsent->fts_name + i, *sfx) != 0) - continue; /* no such suffix */ - if ((p = strdup(ftsent->fts_name)) == NULL) - errx(2, "out of memory"); - p[i] = '\0'; /* remove suffix in the copy */ - kfp = kfile_find(p); - free(p); - } else - kfp = kfile_find(ftsent->fts_name); - - if (kfp && !kfp->seen) { - doobj(ftsent->fts_path, kfp->addr, out); - kfp->seen = 1; - /* Optimization: stop fts as soon as seen all loaded modules */ - if (kfile_allseen()) { - fts_close(fts); - return; - } - } - } - if (ftsent == NULL && errno != 0) - err(2, "couldn't complete traversing module path"); - fts_close(fts); - } while (*sfx++); -} - -static void -usage(const char *myname) -{ - fprintf(stderr, - "Usage:\n" - "%s [-afKksVx] [-M core] [-N system] [-o outfile] [-X suffix]\n" - "%*s [modules-path [outfile]]\n\n" - "\t-a\tappend to outfile\n" - "\t-f\tfind the module in any subdirectory of modules-path\n" - "\t-K\tuse kld(2) to get the list of modules\n" - "\t-k\ttake input from kldstat(8)\n" - "\t-M\tspecify core name for kvm(3)\n" - "\t-N\tspecify system name for kvm(3)\n" - "\t-o\tuse outfile instead of \".asf\"\n" - "\t-s\tdon't prepend subdir for module path\n" - "\t-V\tuse kvm(3) to get the list of modules\n" - "\t-X\tappend suffix to list of possible module file name suffixes\n" - "\t-x\tclear list of possible module file name suffixes\n", - myname, (int)strlen(myname), ""); - exit(2); -} - -#define MAXPATHS 15 -#define MAXSUFFIXES 15 - -/* KLD file names end in this */ -static int nsuffixes = 2; -static const char *suffixes[MAXSUFFIXES + 1] = { - ".debug", - ".symbols", - NULL -}; - -int -main(int argc, char *argv[]) -{ - char basename[PATH_MAX]; - char path[PATH_MAX]; - char *modules_argv[MAXPATHS + 1]; - char *copy, *p; - char **ap; - const char *filemode = "w"; /* mode for outfile */ - const char *modules_path = "modules"; /* path to kernel build directory */ - const char *outfile = ".asf"; /* and where to write the output */ - const char *corefile = NULL; /* for kvm(3) */ - const char *sysfile = NULL; /* for kvm(3) */ - const char **sfx; - struct kfile *kfp; - struct stat st; - FILE *out; /* output file */ - int dofind = 0; - int dokld = 0; - int dokvm = 0; - int nosubdir = 0; - int runprog = 0; - int i; - const int sl = strlen(KLDSUFFIX); - - while ((i = getopt(argc, argv, "afKkM:N:o:sVX:x")) != -1) - switch (i) { - case 'a': - filemode = "a"; /* append to outfile */ - break; - case 'f': - dofind = 1; /* find .ko (recursively) */ - break; - case 'K': - dokld = 1; /* use kld(2) interface */ - break; - case 'k': - runprog = 1; /* get input from kldstat(8) */ - break; - case 'M': - corefile = optarg; /* core file for kvm(3) */ - break; - case 'N': - sysfile = optarg; /* system file (kernel) for kvm(3) */ - break; - case 'o': - outfile = optarg; /* output file name */ - break; - case 's': - nosubdir = 1; /* don't descend into subdirs */ - break; - case 'V': - dokvm = 1; /* use kvm(3) interface */ - break; - case 'X': - if (nsuffixes >= MAXSUFFIXES) - errx(2, "only %d suffixes can be specified", MAXSUFFIXES); - suffixes[nsuffixes++] = optarg; - suffixes[nsuffixes] = NULL; - break; - case 'x': - nsuffixes = 0; - suffixes[0] = NULL; - break; - default: - usage(argv[0]); - } - - argc -= optind; - argv += optind; - - if (argc > 0) { - modules_path = argv[0]; - argc--, argv++; - } - if (argc > 0) { - outfile = argv[0]; - argc--, argv++; - } - if (argc > 0) - usage(argv[0]); - - if (strcmp(outfile, "-") == 0) - out = stdout; - else - if ((out = fopen(outfile, filemode)) == NULL) - err(2, "can't open output file %s", outfile); - - if (dokvm || corefile || sysfile) { - if (dokld || runprog) - warnx("using kvm(3) instead"); - asf_kvm(sysfile, corefile); - } else if (dokld) { - if (runprog) - warnx("using kld(2) instead"); - asf_kld(); - } else - asf_prog(runprog); - - /* Avoid long operations like module tree traversal when nothing to do */ - if (kfile_empty()) { - warnx("no kernel modules loaded"); - return (0); - } - - if ((copy = strdup(modules_path)) == NULL) - errx(2, "out of memory"); - for ( - ap = modules_argv, p = copy; - (*ap = strsep(&p, ";")) != NULL && ap < &modules_argv[MAXPATHS]; - ap++ - ); - if (*ap) - errx(2, "only %d module path elements can be specified", MAXPATHS); - - if (!dofind) - STAILQ_FOREACH(kfp, &kfile_head, link) { - for (ap = modules_argv; *ap; ap++) { - if (!nosubdir) { - /* prepare basename of KLD, w/o suffix */ - strlcpy(basename, kfp->name, sizeof(basename) - 1); - i = strlen(basename); - if (i > sl && strcmp(basename + i - sl, KLDSUFFIX) == 0) - i -= sl; - basename[i] = '/'; - basename[i + 1] = '\0'; - } - for (sfx = suffixes;; sfx++) { - snprintf(path, sizeof(path), - "%s/%s%s%s", - *ap, - nosubdir ? "" : basename, - kfp->name, - *sfx ? *sfx : ""); - if (stat(path, &st) == 0) { - doobj(path, kfp->addr, out); - goto found; - } - if (*sfx == NULL) - break; - } - } - warnx("module %s not found in search path", kfp->name); -found: - ; - } - else - findmodules(modules_argv, suffixes, out); - - free(copy); - return (0); -} diff --git a/usr.sbin/asf/asf.h b/usr.sbin/asf/asf.h deleted file mode 100644 index 5f120a6238b0..000000000000 --- a/usr.sbin/asf/asf.h +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * 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. - * - * $FreeBSD$ - */ - -#define KERNFILE "kernel" -#define KLDSUFFIX ".ko" - -#define MAXTOKEN 10 - -int tokenize(char *cptr, char *token[], int maxtoken); - -void kfile_add(const char *name, caddr_t addr); - -void asf_kld(void); -void asf_kvm(const char *kernfile, const char *corefile); -void asf_prog(int run); diff --git a/usr.sbin/asf/asf_kld.c b/usr.sbin/asf/asf_kld.c deleted file mode 100644 index 6ce150219d6d..000000000000 --- a/usr.sbin/asf/asf_kld.c +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include "asf.h" - -/* - * Get the linker file list using the kld interface. - * Works with a live kernel only. - */ -void -asf_kld(void) -{ - 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); - } -} diff --git a/usr.sbin/asf/asf_kvm.c b/usr.sbin/asf/asf_kvm.c deleted file mode 100644 index ba1558d80e7f..000000000000 --- a/usr.sbin/asf/asf_kvm.c +++ /dev/null @@ -1,130 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include /* for with _KERNEL defined */ -#include -#include -#include -#include -#include -#include -#include - -#define _KERNEL -#include -#undef _KERNEL - -#include "asf.h" - -/* Name of the head of the linker file list in /sys/kern/kern_linker.c */ -#define LINKER_HEAD "linker_files" - -/* - * Get the list of linker files using kvm(3). - * Can work with a live kernel as well as with a crash dump. - */ -void -asf_kvm(const char *kernfile, const char *corefile) -{ - char errbuf[LINE_MAX]; - char name[PATH_MAX]; - kvm_t *kd; - struct nlist nl[2]; - struct linker_file lf; - linker_file_list_t linker_files; - ssize_t n; - void *kp; - - kd = kvm_openfiles(kernfile, corefile, NULL, O_RDONLY, errbuf); - if (kd == NULL) - errx(2, "open kernel memory: %s", errbuf); - - /* - * Locate the head of the linker file list using kernel symbols. - */ - strcpy(name, LINKER_HEAD); - nl[0].n_name = name; /* can't use LINKER_HEAD here because it's const */ - nl[1].n_name = NULL; /* terminate the array for kvm_nlist() */ - switch (kvm_nlist(kd, nl)) { - case 0: - break; - case -1: - warnx("%s: %s", LINKER_HEAD, kvm_geterr(kd)); - kvm_close(kd); - exit(2); - default: - kvm_close(kd); - errx(2, "%s: symbol not found", LINKER_HEAD); - } - - /* - * Read the head of the linker file list from kernel memory. - */ - n = kvm_read(kd, nl[0].n_value, &linker_files, sizeof(linker_files)); - if (n == -1) - goto read_err; - if (n != sizeof(linker_files)) { - kvm_close(kd); - errx(2, "%s: short read", LINKER_HEAD); - } - - /* - * Traverse the linker file list starting at its head. - */ - for (kp = linker_files.tqh_first; kp; kp = lf.link.tqe_next) { - /* Read a linker file structure */ - n = kvm_read(kd, (u_long)kp, &lf, sizeof(lf)); - if (n == -1) - goto read_err; - if (n != sizeof(lf)) { - kvm_close(kd); - errx(2, "kvm: short read"); - } - /* Read the name of the file stored separately */ - bzero(name, sizeof(name)); - n = kvm_read(kd, (u_long)lf.filename, name, sizeof(name) - 1); - if (n == -1) - goto read_err; - if (strcmp(name, KERNFILE) == 0) - continue; - /* Add this file to our list of linker files */ - kfile_add(name, lf.address); - } - kvm_close(kd); - return; - -read_err: /* A common error case */ - warnx("read kernel memory: %s", kvm_geterr(kd)); - kvm_close(kd); - exit(2); -} diff --git a/usr.sbin/asf/asf_prog.c b/usr.sbin/asf/asf_prog.c deleted file mode 100644 index 25b9f1dc77f7..000000000000 --- a/usr.sbin/asf/asf_prog.c +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2002, 2003 Greg Lehey - * 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 ``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 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include "asf.h" - -/* - * Get the linker file list from kldstat(8) output. - * The "run" flag tells if kldstat(8) should run now. - * Of course, kldstat(1) can run in a live system only, but its output - * can be saved beforehand and fed to this function later via stdin. - */ -void -asf_prog(int run) -{ - char buf[LINE_MAX]; - char *token[MAXTOKEN]; - char *endp; - FILE *kldstat; - caddr_t base; - int tokens; - - if (run) { - if ((kldstat = popen("kldstat", "r")) == NULL) - err(2, "can't start kldstat"); - } else - kldstat = stdin; - - while (fgets(buf, sizeof(buf), kldstat)) { - /* Skip header line and main kernel file */ - if (buf[0] == 'I' || strstr(buf, KERNFILE)) - continue; - tokens = tokenize(buf, token, MAXTOKEN); - if (tokens < 4) - continue; - base = (caddr_t)(uintptr_t)strtoumax(token[2], &endp, 16); - if (endp == NULL || *endp != '\0') - continue; - kfile_add(token[4], base); - } -}