From da819425b00ac8c1b5d1c3fa6448415569d0b42c Mon Sep 17 00:00:00 2001 From: Lucas Holt Date: Tue, 3 Dec 2024 15:27:17 -0500 Subject: [PATCH] no longer used files --- tools/tools/tinderbox/Makefile | 15 - tools/tools/tinderbox/etc/Makefile | 17 - tools/tools/tinderbox/etc/default.rc | 22 - tools/tools/tinderbox/etc/head-build.rc | 11 - .../tools/tinderbox/etc/head-noclang-build.rc | 8 - tools/tools/tinderbox/etc/head-update.rc | 12 - .../tinderbox/etc/midnightbsd0.4-build.rc | 9 - .../tinderbox/etc/midnightbsd0.4-update.rc | 10 - tools/tools/tinderbox/tbmaster.1 | 448 ----- tools/tools/tinderbox/tbmaster.pl | 755 -------- tools/tools/tinderbox/tinderbox.1 | 379 ---- tools/tools/tinderbox/tinderbox.pl | 905 --------- tools/tools/tinderbox/www/Makefile | 18 - tools/tools/tinderbox/www/index.cgi | 223 --- tools/tools/tinderbox/www/tb.css | 96 - usr.bin/dtc/string.hh | 147 -- usr.bin/gprof/PSD.doc/abstract.me | 66 - usr.bin/gprof/PSD.doc/gathering.me | 231 --- usr.bin/gprof/PSD.doc/header.me | 38 - usr.bin/gprof/PSD.doc/intro.me | 81 - usr.bin/gprof/PSD.doc/postp.me | 190 -- usr.bin/gprof/PSD.doc/postp1.pic | 54 - usr.bin/gprof/PSD.doc/postp2.pic | 56 - usr.bin/gprof/PSD.doc/postp3.pic | 51 - usr.bin/gprof/PSD.doc/pres1.pic | 56 - usr.bin/gprof/PSD.doc/pres2.pic | 52 - usr.bin/gprof/PSD.doc/present.me | 306 --- usr.bin/gprof/PSD.doc/profiling.me | 115 -- usr.bin/gprof/PSD.doc/refs.me | 63 - usr.bin/gprof/amd64.h | 41 - usr.bin/gprof/aout.c | 230 --- usr.bin/gprof/arm.h | 41 - usr.bin/gprof/i386.h | 41 - usr.bin/gprof/ia64.h | 40 - usr.bin/gprof/mips.h | 47 - usr.bin/gprof/powerpc.h | 41 - usr.bin/gprof/sparc64.h | 41 - usr.bin/indent/tests/nsac.0 | 4 - usr.bin/indent/tests/nsac.0.pro | 2 - usr.bin/indent/tests/nsac.0.stdout | 6 - usr.bin/kdump/linux32_syscalls.conf | 10 - usr.bin/kdump/linux_syscalls.conf | 10 - usr.bin/kdump/mkioctls | 119 -- usr.bin/kdump/mksubr | 761 -------- usr.bin/lastcomm/tests/v1-sparc64-acct.in | Bin 1568 -> 0 bytes usr.bin/lastcomm/tests/v1-sparc64.out | 28 - usr.bin/lastcomm/tests/v2-sparc64-acct.in | Bin 2592 -> 0 bytes usr.bin/lastcomm/tests/v2-sparc64.out | 36 - usr.bin/ldd/extern.h | 31 - usr.bin/ldd/sods.c | 572 ------ usr.bin/mail/USD.doc/mail0.nr | 72 - usr.bin/mail/USD.doc/mail1.nr | 92 - usr.bin/mail/USD.doc/mail2.nr | 617 ------ usr.bin/mail/USD.doc/mail3.nr | 133 -- usr.bin/mail/USD.doc/mail4.nr | 437 ----- usr.bin/mail/USD.doc/mail5.nr | 1042 ----------- usr.bin/mail/USD.doc/mail6.nr | 125 -- usr.bin/mail/USD.doc/mail7.nr | 107 -- usr.bin/mail/USD.doc/mail8.nr | 75 - usr.bin/mail/USD.doc/mail9.nr | 203 -- usr.bin/mail/USD.doc/maila.nr | 33 - usr.bin/mail/aux.c | 632 ------- usr.bin/netstat/flowtable.c | 87 - usr.bin/truss/aarch64-cloudabi64.c | 87 - usr.bin/truss/aarch64-freebsd.c | 109 -- usr.bin/truss/amd64-cloudabi64.c | 96 - usr.bin/truss/amd64-freebsd.c | 131 -- usr.bin/truss/amd64-freebsd32.c | 138 -- usr.bin/truss/amd64-linux.c | 106 -- usr.bin/truss/amd64-linux32.c | 116 -- usr.bin/truss/arm-freebsd.c | 138 -- usr.bin/truss/i386-freebsd.c | 132 -- usr.bin/truss/i386-linux.c | 113 -- usr.bin/truss/mips-freebsd.c | 142 -- usr.bin/truss/powerpc-freebsd.c | 122 -- usr.bin/truss/powerpc64-freebsd.c | 118 -- usr.bin/truss/powerpc64-freebsd32.c | 127 -- usr.bin/truss/sparc64-freebsd.c | 125 -- usr.bin/unifdef/unifdef.1 | 516 ----- usr.bin/unifdef/unifdef.c | 1663 ----------------- usr.bin/unifdef/unifdef.h | 53 - usr.bin/unifdef/unifdefall.sh | 61 - usr.bin/units/pathnames.h | 32 - usr.bin/units/units.lib | 731 -------- usr.bin/users/users.c | 114 -- usr.sbin/bhyve/consport.c | 176 -- usr.sbin/bhyve/dbgport.c | 176 -- usr.sbin/bhyve/dbgport.h | 35 - usr.sbin/bluetooth/ath3kfw/ath3kfw.c | 297 --- usr.sbin/bluetooth/bt3cfw/Makefile | 9 - usr.sbin/bluetooth/bt3cfw/Makefile.depend | 17 - usr.sbin/bluetooth/bt3cfw/bt3cfw.8 | 72 - usr.sbin/bluetooth/bt3cfw/bt3cfw.c | 229 --- usr.sbin/bsdinstall/partedit/partedit_arm64.c | 103 - usr.sbin/bsdinstall/partedit/partedit_pc98.c | 83 - .../bsdinstall/partedit/partedit_sparc64.c | 84 - .../snmp_atm/BEGEMOT-ATM-FREEBSD-MIB.txt | 101 - usr.sbin/bsnmpd/modules/snmp_atm/Makefile | 21 - .../bsnmpd/modules/snmp_atm/Makefile.depend | 22 - .../bsnmpd/modules/snmp_atm/atm_freebsd.def | 56 - usr.sbin/bsnmpd/modules/snmp_atm/atm_sys.c | 301 --- usr.sbin/crunch/crunchide/exec_aout.c | 197 -- usr.sbin/fdformat/fdformat.1 | 180 -- usr.sbin/iscsid/chap.c | 423 ----- usr.sbin/iscsid/keys.c | 199 -- usr.sbin/iscsid/log.c | 202 -- usr.sbin/iscsid/pdu.c | 309 --- usr.sbin/kldxref/ef_nop.c | 41 - usr.sbin/makefs/msdos/denode.h | 236 --- usr.sbin/makefs/msdos/fat.h | 109 -- usr.sbin/makefs/msdos/msdosfs_fat.c | 2 +- usr.sbin/makefs/msdos/msdosfsmount.h | 198 -- usr.sbin/mpsutil/mpr_ioctl.h | 386 ---- usr.sbin/mpsutil/mps_ioctl.h | 385 ---- usr.sbin/ndp/gnuc.h | 2 - usr.sbin/ppp/atm.c | 237 --- usr.sbin/ppp/atm.h | 35 - usr.sbin/rtadvd/dump.c | 252 --- usr.sbin/rtadvd/dump.h | 33 - usr.sbin/rtsold/probe.c | 189 -- usr.sbin/sa/tests/v1-sparc64-sav.in | Bin 16384 -> 0 bytes usr.sbin/sa/tests/v1-sparc64-sav.out | 5 - usr.sbin/sa/tests/v1-sparc64-u.out | 28 - usr.sbin/sa/tests/v1-sparc64-usr.in | Bin 16384 -> 0 bytes usr.sbin/sa/tests/v1-sparc64-usr.out | 1 - usr.sbin/sa/tests/v2-sparc64-sav.in | Bin 16384 -> 0 bytes usr.sbin/sa/tests/v2-sparc64-u.out | 36 - usr.sbin/sa/tests/v2-sparc64-usr.in | Bin 16384 -> 0 bytes 128 files changed, 1 insertion(+), 20626 deletions(-) delete mode 100644 tools/tools/tinderbox/Makefile delete mode 100644 tools/tools/tinderbox/etc/Makefile delete mode 100644 tools/tools/tinderbox/etc/default.rc delete mode 100644 tools/tools/tinderbox/etc/head-build.rc delete mode 100644 tools/tools/tinderbox/etc/head-noclang-build.rc delete mode 100644 tools/tools/tinderbox/etc/head-update.rc delete mode 100644 tools/tools/tinderbox/etc/midnightbsd0.4-build.rc delete mode 100644 tools/tools/tinderbox/etc/midnightbsd0.4-update.rc delete mode 100644 tools/tools/tinderbox/tbmaster.1 delete mode 100644 tools/tools/tinderbox/tbmaster.pl delete mode 100644 tools/tools/tinderbox/tinderbox.1 delete mode 100644 tools/tools/tinderbox/tinderbox.pl delete mode 100644 tools/tools/tinderbox/www/Makefile delete mode 100644 tools/tools/tinderbox/www/index.cgi delete mode 100644 tools/tools/tinderbox/www/tb.css delete mode 100644 usr.bin/dtc/string.hh delete mode 100644 usr.bin/gprof/PSD.doc/abstract.me delete mode 100644 usr.bin/gprof/PSD.doc/gathering.me delete mode 100644 usr.bin/gprof/PSD.doc/header.me delete mode 100644 usr.bin/gprof/PSD.doc/intro.me delete mode 100644 usr.bin/gprof/PSD.doc/postp.me delete mode 100644 usr.bin/gprof/PSD.doc/postp1.pic delete mode 100644 usr.bin/gprof/PSD.doc/postp2.pic delete mode 100644 usr.bin/gprof/PSD.doc/postp3.pic delete mode 100644 usr.bin/gprof/PSD.doc/pres1.pic delete mode 100644 usr.bin/gprof/PSD.doc/pres2.pic delete mode 100644 usr.bin/gprof/PSD.doc/present.me delete mode 100644 usr.bin/gprof/PSD.doc/profiling.me delete mode 100644 usr.bin/gprof/PSD.doc/refs.me delete mode 100644 usr.bin/gprof/amd64.h delete mode 100644 usr.bin/gprof/aout.c delete mode 100644 usr.bin/gprof/arm.h delete mode 100644 usr.bin/gprof/i386.h delete mode 100644 usr.bin/gprof/ia64.h delete mode 100644 usr.bin/gprof/mips.h delete mode 100644 usr.bin/gprof/powerpc.h delete mode 100644 usr.bin/gprof/sparc64.h delete mode 100644 usr.bin/indent/tests/nsac.0 delete mode 100644 usr.bin/indent/tests/nsac.0.pro delete mode 100644 usr.bin/indent/tests/nsac.0.stdout delete mode 100644 usr.bin/kdump/linux32_syscalls.conf delete mode 100644 usr.bin/kdump/linux_syscalls.conf delete mode 100644 usr.bin/kdump/mkioctls delete mode 100644 usr.bin/kdump/mksubr delete mode 100644 usr.bin/lastcomm/tests/v1-sparc64-acct.in delete mode 100644 usr.bin/lastcomm/tests/v1-sparc64.out delete mode 100644 usr.bin/lastcomm/tests/v2-sparc64-acct.in delete mode 100644 usr.bin/lastcomm/tests/v2-sparc64.out delete mode 100644 usr.bin/ldd/extern.h delete mode 100644 usr.bin/ldd/sods.c delete mode 100644 usr.bin/mail/USD.doc/mail0.nr delete mode 100644 usr.bin/mail/USD.doc/mail1.nr delete mode 100644 usr.bin/mail/USD.doc/mail2.nr delete mode 100644 usr.bin/mail/USD.doc/mail3.nr delete mode 100644 usr.bin/mail/USD.doc/mail4.nr delete mode 100644 usr.bin/mail/USD.doc/mail5.nr delete mode 100644 usr.bin/mail/USD.doc/mail6.nr delete mode 100644 usr.bin/mail/USD.doc/mail7.nr delete mode 100644 usr.bin/mail/USD.doc/mail8.nr delete mode 100644 usr.bin/mail/USD.doc/mail9.nr delete mode 100644 usr.bin/mail/USD.doc/maila.nr delete mode 100644 usr.bin/mail/aux.c delete mode 100644 usr.bin/netstat/flowtable.c delete mode 100644 usr.bin/truss/aarch64-cloudabi64.c delete mode 100644 usr.bin/truss/aarch64-freebsd.c delete mode 100644 usr.bin/truss/amd64-cloudabi64.c delete mode 100644 usr.bin/truss/amd64-freebsd.c delete mode 100644 usr.bin/truss/amd64-freebsd32.c delete mode 100644 usr.bin/truss/amd64-linux.c delete mode 100644 usr.bin/truss/amd64-linux32.c delete mode 100644 usr.bin/truss/arm-freebsd.c delete mode 100644 usr.bin/truss/i386-freebsd.c delete mode 100644 usr.bin/truss/i386-linux.c delete mode 100644 usr.bin/truss/mips-freebsd.c delete mode 100644 usr.bin/truss/powerpc-freebsd.c delete mode 100644 usr.bin/truss/powerpc64-freebsd.c delete mode 100644 usr.bin/truss/powerpc64-freebsd32.c delete mode 100644 usr.bin/truss/sparc64-freebsd.c delete mode 100644 usr.bin/unifdef/unifdef.1 delete mode 100644 usr.bin/unifdef/unifdef.c delete mode 100644 usr.bin/unifdef/unifdef.h delete mode 100644 usr.bin/unifdef/unifdefall.sh delete mode 100644 usr.bin/units/pathnames.h delete mode 100644 usr.bin/units/units.lib delete mode 100644 usr.bin/users/users.c delete mode 100644 usr.sbin/bhyve/consport.c delete mode 100644 usr.sbin/bhyve/dbgport.c delete mode 100644 usr.sbin/bhyve/dbgport.h delete mode 100644 usr.sbin/bluetooth/ath3kfw/ath3kfw.c delete mode 100644 usr.sbin/bluetooth/bt3cfw/Makefile delete mode 100644 usr.sbin/bluetooth/bt3cfw/Makefile.depend delete mode 100644 usr.sbin/bluetooth/bt3cfw/bt3cfw.8 delete mode 100644 usr.sbin/bluetooth/bt3cfw/bt3cfw.c delete mode 100644 usr.sbin/bsdinstall/partedit/partedit_arm64.c delete mode 100644 usr.sbin/bsdinstall/partedit/partedit_pc98.c delete mode 100644 usr.sbin/bsdinstall/partedit/partedit_sparc64.c delete mode 100644 usr.sbin/bsnmpd/modules/snmp_atm/BEGEMOT-ATM-FREEBSD-MIB.txt delete mode 100644 usr.sbin/bsnmpd/modules/snmp_atm/Makefile delete mode 100644 usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend delete mode 100644 usr.sbin/bsnmpd/modules/snmp_atm/atm_freebsd.def delete mode 100644 usr.sbin/bsnmpd/modules/snmp_atm/atm_sys.c delete mode 100644 usr.sbin/crunch/crunchide/exec_aout.c delete mode 100644 usr.sbin/fdformat/fdformat.1 delete mode 100644 usr.sbin/iscsid/chap.c delete mode 100644 usr.sbin/iscsid/keys.c delete mode 100644 usr.sbin/iscsid/log.c delete mode 100644 usr.sbin/iscsid/pdu.c delete mode 100644 usr.sbin/kldxref/ef_nop.c delete mode 100644 usr.sbin/makefs/msdos/denode.h delete mode 100644 usr.sbin/makefs/msdos/fat.h delete mode 100644 usr.sbin/makefs/msdos/msdosfsmount.h delete mode 100644 usr.sbin/mpsutil/mpr_ioctl.h delete mode 100644 usr.sbin/mpsutil/mps_ioctl.h delete mode 100644 usr.sbin/ndp/gnuc.h delete mode 100644 usr.sbin/ppp/atm.c delete mode 100644 usr.sbin/ppp/atm.h delete mode 100644 usr.sbin/rtadvd/dump.c delete mode 100644 usr.sbin/rtadvd/dump.h delete mode 100644 usr.sbin/rtsold/probe.c delete mode 100644 usr.sbin/sa/tests/v1-sparc64-sav.in delete mode 100644 usr.sbin/sa/tests/v1-sparc64-sav.out delete mode 100644 usr.sbin/sa/tests/v1-sparc64-u.out delete mode 100644 usr.sbin/sa/tests/v1-sparc64-usr.in delete mode 100644 usr.sbin/sa/tests/v1-sparc64-usr.out delete mode 100644 usr.sbin/sa/tests/v2-sparc64-sav.in delete mode 100644 usr.sbin/sa/tests/v2-sparc64-u.out delete mode 100644 usr.sbin/sa/tests/v2-sparc64-usr.in diff --git a/tools/tools/tinderbox/Makefile b/tools/tools/tinderbox/Makefile deleted file mode 100644 index 5f9371db5ac..00000000000 --- a/tools/tools/tinderbox/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# $MidnightBSD: src/tools/tools/tinderbox/Makefile,v 1.2 2008/03/06 20:23:45 laffer1 Exp $ - -BINDIR ?= ${HOME}/bin -BINOWN ?= ${USER} -BINGRP ?= ${USER} -SCRIPTS = tbmaster.pl tinderbox.pl - -MANDIR ?= ${HOME}/man/man -MANOWN ?= ${USER} -MANGRP ?= ${USER} -MAN = tbmaster.1 tinderbox.1 - -SUBDIR = etc www - -.include diff --git a/tools/tools/tinderbox/etc/Makefile b/tools/tools/tinderbox/etc/Makefile deleted file mode 100644 index 2f22a7eda7e..00000000000 --- a/tools/tools/tinderbox/etc/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# $MidnightBSD$ - -ETCFILES = -ETCFILES += default.rc -ETCFILES += midnightbsd0.4-build.rc midnightbsd0.4-update.rc -ETCFILES += head-build.rc head-update.rc -ETCFILES += head-noclang-build.rc -ETCDIR ?= ${HOME}/etc -ETCOWN ?= ${USER} -ETCGRP ?= ${USER} - -realinstall: -.for FILE in ${ETCFILES} - ${INSTALL} -m0644 -o${ETCOWN} -g${ETCGRP} ${.CURDIR}/${FILE} ${ETCDIR} -.endfor - -.include diff --git a/tools/tools/tinderbox/etc/default.rc b/tools/tools/tinderbox/etc/default.rc deleted file mode 100644 index d6f07d0d070..00000000000 --- a/tools/tools/tinderbox/etc/default.rc +++ /dev/null @@ -1,22 +0,0 @@ -# -# Tinderbox defaults -# -# $MidnightBSD$ -# $FreeBSD: user/des/tinderbox/etc/default.rc 256000 2013-10-02 18:23:46Z des $ -# - -comment = ${branch} tinderbox - -# Paths -sandbox = ${HOME} - -# Tinderbox options -options = --verbose -targets = precleanobj, update, world, lint, kernels, postcleanobj -#timeout = 7200 - -# Reporting -sender = MidnightBSD Tinderbox -recipient = ${SENDER} -subject = [${COMMENT}] failure on ${arch}/${machine} -urlbase = http://tinderbox.midnightbsd.org/ diff --git a/tools/tools/tinderbox/etc/head-build.rc b/tools/tools/tinderbox/etc/head-build.rc deleted file mode 100644 index a5e3c1842aa..00000000000 --- a/tools/tools/tinderbox/etc/head-build.rc +++ /dev/null @@ -1,11 +0,0 @@ -# -# HEAD tinderbox setup, shared source - build stage -# -# $FreeBSD: user/des/tinderbox/etc/head-build.rc 268247 2014-07-04 09:32:22Z des $ -# $MidnightBSD$ - -branches = HEAD -platforms = amd64, i386 -targets = precleanobj, version, world, lint, kernels, postcleanobj -srcdir = ${SANDBOX}/${BRANCH}/src -recipient += diff --git a/tools/tools/tinderbox/etc/head-noclang-build.rc b/tools/tools/tinderbox/etc/head-noclang-build.rc deleted file mode 100644 index f534d9708e7..00000000000 --- a/tools/tools/tinderbox/etc/head-noclang-build.rc +++ /dev/null @@ -1,8 +0,0 @@ -# -# HEAD tinderbox setup, shared source - build without clang -# -# $FreeBSD: user/des/tinderbox/etc/head-noclang-build.rc 257786 2013-11-07 10:32:37Z des $ -# $MidnightBSD$ - -include head-build -env += WITHOUT_CLANG=YES, WITHOUT_CLANG_IS_CC=YES, WITH_GCC=YES, WITH_GNUCXX=YES diff --git a/tools/tools/tinderbox/etc/head-update.rc b/tools/tools/tinderbox/etc/head-update.rc deleted file mode 100644 index 92d6cbb0a22..00000000000 --- a/tools/tools/tinderbox/etc/head-update.rc +++ /dev/null @@ -1,12 +0,0 @@ -# -# HEAD tinderbox setup, shared source - update stage -# -# $FreeBSD: user/des/tinderbox/etc/head-update.rc 266156 2014-05-15 16:24:20Z des $ -# $MidnightBSD$ - -branches = HEAD -platforms = none -srcdir = ${SANDBOX}/${BRANCH}/src -targets = revert, update, version -recipient += -subject = [${COMMENT}] source tree update failure diff --git a/tools/tools/tinderbox/etc/midnightbsd0.4-build.rc b/tools/tools/tinderbox/etc/midnightbsd0.4-build.rc deleted file mode 100644 index 78e7005b428..00000000000 --- a/tools/tools/tinderbox/etc/midnightbsd0.4-build.rc +++ /dev/null @@ -1,9 +0,0 @@ -# MidnightBSD 0.4 tinderbox setup, shared source - build stage -# -# $MidnightBSD: src/tools/tools/tinderbox/etc/releng_0_1.rc,v 1.2 2008/03/06 20:24:11 laffer1 Exp $ - -branches = RELENG_0_4 -platforms = amd64, i386, sparc64 -targets = precleanobj, version, world, lint, kernels, postcleanobj -srcdir = ${SANDBOX}/${BRANCH}/src -recipient += %%SENDER%%, diff --git a/tools/tools/tinderbox/etc/midnightbsd0.4-update.rc b/tools/tools/tinderbox/etc/midnightbsd0.4-update.rc deleted file mode 100644 index ec7896c4acb..00000000000 --- a/tools/tools/tinderbox/etc/midnightbsd0.4-update.rc +++ /dev/null @@ -1,10 +0,0 @@ -# MidnightBSD 0.4 tinderbox setup, shared source - update stage -# -# $MidnightBSD$ - -branches = RELENG_0_4 -platforms = none -srcdir = ${SANDBOX}/${BRANCH}/src -targets = update, version -recipient += -subject = [%%COMMENT%%] source tree update failure diff --git a/tools/tools/tinderbox/tbmaster.1 b/tools/tools/tinderbox/tbmaster.1 deleted file mode 100644 index 21656f80f80..00000000000 --- a/tools/tools/tinderbox/tbmaster.1 +++ /dev/null @@ -1,448 +0,0 @@ -.\"- -.\" Copyright (c) 2003-2014 Dag-Erling Smørgrav -.\" 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: user/des/tinderbox/tbmaster.1 263695 2014-03-24 22:34:22Z des $ -.\" -.Dd March 24, 2014 -.Dt TBMASTER 1 -.Os -.Sh NAME -.Nm tbmaster -.Nd manage tinderbox runs -.Sh SYNOPSIS -.Nm -.Op options -.Sh DESCRIPTION -The -.Nm -script manages -.Xr tinderbox 1 -runs, generates log summaries, and mails out failure reports. -.Pp -The following options are recognized: -.Bl -tag -width 12n -.It Fl a , Fl -abbreviate -Abbreviate path names in the log file. -Every occurrence of the source directory will be replaced with -.Dq /src , -and every occurrence of the object directory with -.Dq /obj . -The resulting output should be exactly the same as if the source and -object directories really were -.Pa /src -and -.Pa /obj , -respectively. -.It Fl c Ar NAME , Fl -config Ns = Ns Ar NAME -The name of the configuration to use. -If specified multiple times, all listed configurations will be run in -sequence. -The default value is the hostname minus the domain part. -.It Fl d , Fl -dump -Dumps the configuration and exits without running the tinderbox. -.It Fl e Ar DIR , Fl -etcdir Ns = Ns Ar DIR -The directory where configuration files are located. -The default value is -.Pa $HOME/etc . -.It Fl h Ar HOSTNAME , Fl -hostname Ns = Ns Ar HOSTNAME -The name of the host running the tinderbox, used in logs and reports. -Can be overridden by the -.Va HOSTNAME -configuration variable. -The default value is that reported by -.Xr uname 1 . -.It Fl l Ar FILE , Fl -lockfile Ns = Ns Ar FILE -The name of a file to lock upon startup. -If the lock is already held by another process, -.Nm -will terminate immediately rather than block. -.It Fl n Ar NUMBER , Fl -ncpu Ns = Ns Ar NUMBER -The maximum number of concurrent builds to run. -Can be overridden by the -.Va NCPU -configuration variable. -The default value is the number of cores in the machine, or 1 if that -number could not be determined. -See the -.Sx Concurrency -section for additional information. -.El -.Ss Configuration files -The -.Nm -script uses named configurations located in individual files named for -the setup they describe, with a -.Pa .rc -suffix. -For instance, the -.Dq snoosnoo -configuration is contained in -.Pa snoosnoo.rc . -.Pp -In addition, -.Nm -attempts to read -.Pa default.rc -and -.Pa site.rc -before and after the actual configuration file, respectively; thus, -they can be used to specify default values shared by multiple -configurations and to override the values set in the individual -configuration files. -.Pp -Each configuration file consists of a list of single- or -multiple-value variable assignments: -.Bl -tag -.It Va variable No = Ar value -Assigns -.Ar value -to the single-value variable -.Va variable . -.It Va variable No = Ar value1 Op No , Ar value2 ... -Assigns -.Ar value1 , -.Ar value2 -etc. to the multi-value variable -.Va variable . -.It Va variable No += Ar value3 Op No , Ar value4 ... -Appends -.Ar value3 , -.Ar value4 -etc. to the multi-value variable -.Va variable . -.It Va variable No -= Ar value5 Op No , Ar value6 ... -Removes -.Ar value5 , -.Ar value6 -etc. from the multi-value variable -.Va variable . -.El -.Pp -Whitespace around the assigment operator and around the commas -separating multiple values is optional. -.Pp -Blank lines are ignored, as is anything following a hash sign -.Pq Sq # . -.Pp -Additionally, -.Cm include -statements can be used to include one configuration in another: -.Bl -tag -.It Cm include Ar otherconfig -.El -.Ss Configuration variables -Below is a list of the configuration variables -.Nm -recognizes and their semantics. -.Pp -Note that many of these variables are passed on as command-line -arguments to -.Xr tinderbox 1 , -which may provide its own default values for variables which are left -undefined by -.Nm . -.Pp -Some variables are read-only and are provided so that other variables -may include them. -For instance, a common idiom is to derive -.Va OBJDIR -from a combination of -.Va BRANCH , -.Va ARCH -and -.Va MACHINE . -.Bl -tag -width 12n -.It ARCH -.Pq Vt single, read-only -The architecture currently being built for. -.It BRANCH -.Pq Vt single, read-only -The branch currently being built. -.It BRANCHES -.Pq Vt multiple -A list of source branches to build. -The default value is -.Dq HEAD . -.It CFLAGS -.Pq Vt single -The desired value for the -.Va CFLAGS -.Xr make 1 -variable. -This is equivalent to specifying -.Va CFLAGS -in -.Va ENV . -No default value. -.It COPTFLAGS -.Pq Vt single -The desired value for the -.Va COPTFLAGS -.Xr make 1 -variable. -This is equivalent to specifying -.Va COPTFLAGS -in -.Va ENV . -No default value. -.It COMMENT -.Pq Vt single -A terse comment describing the setup. -No default value. -.It ENV -.Pq Vt multiple -A list of environment variables to pass to the -.Xr tinderbox 1 -script. -Each value is the name and value of an environment variable, separated -by an equal sign -.Pq Sq = . -No default value. -.It HOME -.Pq Vt single, read-only -The current user's home directory, as specified by the -.Ev HOME -environment variable. -Note that it will not be defined unless it passes some simple sanity -checks. -.It HOSTNAME -.Pq Vt single -The name of the host running the tinderbox. -.It JOBS -The maximum number of concurrent -.Xr make 1 -processes to run within each build. -No default value. -See the -.Sx Concurrency -section for additional information. -.It LOGDIR -.Pq Vt single -The location of the log directory. -The default value is -.Pa ${SANDBOX}/logs . -.It MACHINE -.Pq Vt single, read-only -The machine currently being built for. -.It NCPU -.Pq Vt single -The maximum number of concurrent builds to run. -No default value. -See the -.Sx Concurrency -section for additional information. -.It OBJDIR -.Pq Vt single -The object directory. -No default value. -.It OPTIONS -.Pq Vt multiple -A list of additional options to pass to the -.Xr tinderbox 1 -script. -No default value. -.It PATCH -.Pq Vt single -The file name (either absolute, or relative to the sandbox directory) -of the patch to apply if the -.Dq patch -command is specified. -No default value. -.It PLATFORMS -.Pq Vt multiple -Which architectures and machines to build for. -Each value is the name of an architecture, optionally followed by a -forward slash -.Pq Sq / -and a machine name. -If the machine name is not specified, it is assumed to be identical to -the architecture name. -The default value is -.Dq i386 . -.It RECIPIENT -.Pq Vt multiple -The addresses to which failure reports should be mailed. -The default value is -.Dq ${SENDER} . -.Pp -To avoid unintentional spamming, -.Nm -will strip recipients in the -.Li freebsd.org -domain from this list unless the correct magic sauce is used. -.It SANDBOX -.Pq Vt single -The location of the sandbox directory. -The default value is -.Pa /tmp/tinderbox . -.It SENDER -.Pq Vt single -The envelope sender to use when mailing out failure reports. -This should be a single email address. -No default value. -.It SRCDIR -.Pq Vt single -The source directory. -No default value. -.Pp -Normally, a separate directory within the sandbox will be used for -each build. -Using a shared source directory for all builds reduces disk space -requirements and speeds up the build. -Note that it is generally not a good idea to combine this with any of -the -.Dq clean , -.Dq cleansrc -or -.Dq update -targets. -.It SUBJECT -.Pq Vt single -The subject to use on failure reports. -The default value is -.Dq Tinderbox failure on ${arch}/${machine} . -.It SVNBASE -.Pq Vt single -The URL to the base of the Subversion repository. -No default value. -.It TARGETS -.Pq Vt multiple -A list of targets (commands) to pass to the -.Xr tinderbox 1 -script. -The default value is -.Dq update, world . -.It TIMEOUT -.Pq Vt single -The number of seconds after which each tinderbox invocation will time -out. -No default value. -.It TINDERBOX -.Pq Vt single -The location of the -.Xr tinderbox 1 -script. -The default value is -.Dq ${HOME}/bin/tinderbox . -.It URLBASE -.Pq Vt single -If defined, a URL constructed by appending the file name of the full -log file to the expanded value of this variable will be included in -failure reports. -There is no default value. -.El -.Ss Variable Substitution -All configuration variables are subject to variable substitution -immediately before use: -.Bl -bullet -.It -If a single-value variable contains substrings of the form -.Va ${VAR} -or -.Va ${var} , -those substrings are replaced with the values of the corresponding -variables, after recursive substitution. -The difference between the first and the second form is that the -latter is converted to lower-case before use. -For instance, -.Dq ${BRANCH} -might expand to -.Dq RELENG_4 -while -.Dq ${branch} -would expand to -.Dq releng_4 . -.It -If a single-value varaible contains substrings of the form -.Va $ENV{VAR} , -those substrings are replaced with the values of the corresponding -environment variables. -Use this with care. -.It -If an element of a multiple-value variable is of the form -.Va ${VAR} -or -.Va ${var} -and the corresponding variable is a multiple-value variable, recursive -substitution is first performed on that variable, and the resulting -values are included individually in the result. -.It -Otherwise, elements of multiple-value variables are expanded -individually according to the same rules as single-value variables. -.El -.Pp -For backward compatibility with earlier versions, the forms -.Va %%VAR%% -and -.Va %%var%% -may be used instead of -.Va ${VAR} -and -.Va ${var} . -.Ss Concurrency -On multiprocessor machines, performance can generally be improved by -running multiple builds in parallel, up to a certain limit. -By default, -.Nm -will run one build for each processor core in the system. -This can be overridden with the -.Fl -ncpu -command-line option and the -.Va NCPU -configuration variable, the latter taking precedence. -.Pp -In addition, each build may run multiple -.Xr make 1 -processes in parallel, up to the number specified by the -.Va JOBS -configuration variable. -.Pp -The total number of parallel -.Xr make 1 -processes will vary, but can be as high as the product of of -.Va NCPU -and -.Va JOBS. -As a result of processor, memory and filesystem contention, an -excessively large value can have a significant negative impact on -performance. -.Pp -As a rule of thumb, -.Va NCPU -should not exceed one build per gigabyte of physical memory in the -system, and the -.Va NCPU -x -.Va JOBS -product should not exceed the number of processor cores in the system -by a large amount. -.Sh SEE ALSO -.Xr tinderbox 1 -.Sh AUTHORS -.Nm -was written by -.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org . -.Sh BUGS -- part of a complete breakfast! diff --git a/tools/tools/tinderbox/tbmaster.pl b/tools/tools/tinderbox/tbmaster.pl deleted file mode 100644 index 049fab8fc7b..00000000000 --- a/tools/tools/tinderbox/tbmaster.pl +++ /dev/null @@ -1,755 +0,0 @@ -#!/usr/bin/perl -Tw -#- -# Copyright (c) 2003-2014 Dag-Erling Smørgrav -# 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: user/des/tinderbox/tbmaster.pl 266153 2014-05-15 16:17:21Z des $ -# $MidnightBSD$ - -use v5.10.1; -use strict; -use Fcntl qw(:DEFAULT :flock); -use POSIX; -use Getopt::Long; -use Storable qw(dclone); - -my $VERSION = "2.22"; -my $COPYRIGHT = "Copyright (c) 2003-2014 Dag-Erling Smørgrav. " . - "All rights reserved."; - -my $BACKLOG = 20; - -my $abbreviate; # Abbreviate path names in log file -my @configs; # Names of requested configations -my $dump; # Dump configuration and exit -my $etcdir; # Configuration directory -my $lockfile; # Lock file name -my $lock; # Lock file descriptor -my $hostname; # Hostname -my $ncpu; # Number of CPUs -my %platforms; # Specific platforms to build - -my %INITIAL_CONFIG = ( - 'BRANCHES' => [ 'HEAD' ], - 'CFLAGS' => '', - 'COPTFLAGS' => '', - 'COMMENT' => '', - 'ENV' => [ ], - 'HOSTNAME' => '', - 'JOBS' => '', - 'LOGDIR' => '${SANDBOX}/logs', - 'NCPU' => '', - 'OBJDIR' => '', - 'OPTIONS' => [ ], - 'PATCH' => '', - 'PLATFORMS' => [ 'i386' ], - 'RECIPIENT' => [ '${SENDER}' ], - 'SANDBOX' => '/tmp/tinderbox', - 'SENDER' => '', - 'SRCDIR' => '', - 'SUBJECT' => 'Tinderbox failure on ${arch}/${machine}', - 'SVNBASE' => '', - 'TARGETS' => [ 'update', 'world' ], - 'TIMEOUT' => '', - 'TINDERBOX' => '${HOME}/bin/tinderbox', - 'URLBASE' => '', -); -my %NUMERIC_OPTIONS = map { $_ => 1 } qw(JOBS NCPU TIMEOUT); -my %PATHNAME_OPTIONS = - map { $_ => 1 } qw(LOGDIR OBJDIR PATCH SANDBOX SRCDIR TINDERBOX); -my %WORD_OPTIONS = map { $_ => 1 } qw(PLATFORMS TARGETS); -my %CONFIG; - -# -# Expand a path -# -sub realpath($;$); -sub realpath($;$) { - my $path = shift; - my $base = shift || ""; - - my $realpath = ($path =~ m|^/|) ? "" : $base; - foreach my $part (split('/', $path)) { - if ($part eq '' || $part eq '.') { - # nothing - } elsif ($part eq '..') { - $realpath =~ s|/[^/]+$|| - or die("'$path' is not a valid path relative to '$base'\n"); - } elsif (-l "$realpath/$part") { - my $target = readlink("$realpath/$part") - or die("unable to resolve symlink '$realpath/$part': $!\n"); - $realpath = realpath($target, $realpath); - } else { - $part =~ m/^([\w.-]+)$/ - or die("unsafe path '$realpath/$part'\n"); - $realpath .= "/$1"; - } - } - return $realpath; -} - -# -# Perform variable expansion -# -sub expand($); -sub expand($) { - my $key = shift; - - return "??$key??" - unless exists($CONFIG{uc($key)}); - my $value = $CONFIG{uc($key)}; - my @elements = ref($value) ? @{$value} : $value; - my @expanded; - while (@elements) { - my $elem = shift(@elements); - if (ref($elem)) { - # prepend to queue for further processing - unshift(@elements, @{$elem}); - } elsif ($elem =~ m/^\%\%(\w+)\%\%$/ || $elem =~ m/^\%\{(\w+)\}$/) { - # prepend to queue for further processing - # note - can expand to a list - unshift(@elements, expand($1)); - } else { - $elem =~ s/\$ENV\{(\w+)\}/$ENV{$1}/g; - $elem =~ s/\%\%(\w+)\%\%/expand($1)/eg; - $elem =~ s/\$\{(\w+)\}/expand($1)/eg; - push(@expanded, $elem); - } - } - - # Upper / lower case - if ($key !~ m/[A-Z]/) { - @expanded = map { lc($_) } @expanded; - } - - # Validate and untaint expanded value(s) - if ($NUMERIC_OPTIONS{uc($key)}) { - @expanded = map { - m/^(\d+|)$/ - or die("invalid value for numeric variable $key: $_\n"); - $1 - } @expanded; - } elsif ($PATHNAME_OPTIONS{uc($key)}) { - @expanded = map { - m@^((?:/+[\w.-]+)+/*|)$@ - or die("invalid value for pathname variable $key: $_\n"); - $1 - } @expanded; - } elsif ($WORD_OPTIONS{uc($key)}) { - @expanded = map { - # hack - support not only "word" but also "word/word" so - # platform designations will pass the test. - m@^([\w.-]+(?:/[\w.-]+)?|)$@ - or die("invalid value for word variable $key: $_\n"); - $1 - } @expanded; - } - - # Verify single / multiple and return result - if (ref($value)) { - return @expanded; - } elsif (@expanded != 1) { - die("expand($key): expected one value, got ", int(@expanded), "\n"); - } else { - return $expanded[0]; - } -} - -# -# Reset the configuration to initial values -# -sub clearconf() { - - %CONFIG = %{dclone(\%INITIAL_CONFIG)}; -} - -# -# Read in a configuration file -# -sub readconf($); -sub readconf($) { - my $fn = shift; - - open(my $fh, '<', $fn) - or return undef; - my $line = ""; - my $n = 0; - while (<$fh>) { - ++$n; - chomp(); - s/\s*(\#.*)?$//; - $line .= $_; - if (length($line) && $line !~ s/\\$/ /) { - if ($line =~ m/^include\s+([\w-]+)$/) { - readconf("$1.rc") - or die("$fn: include $1: $!\n"); - } elsif ($line =~ m/^(\w+)\s*([+-]?=)\s*(.*)$/) { - my ($key, $op, $val) = (uc($1), $2, $3); - $val = '' - unless defined($val); - die("$fn: $key is not a known keyword on line $n\n") - unless (exists($CONFIG{$key})); - if (ref($CONFIG{$key})) { - my @a = split(/\s*,\s*/, $val); - foreach (@a) { - s/^\'([^\']*)\'$/$1/; - } - if ($op eq '=') { - $CONFIG{$key} = \@a; - } elsif ($op eq '+=') { - push(@{$CONFIG{$key}}, @a); - } elsif ($op eq '-=') { - my %a = map { $_ => $_ } @a; - @{$CONFIG{$key}} = - grep { !exists($a{$_}) } @{$CONFIG{$key}}; - } else { - die("can't happen\n"); - } - } else { - $val =~ s/^\'([^\']*)\'$/$1/; - if ($op eq '=') { - $CONFIG{$key} = $val; - } elsif ($op eq '+=' || $op eq '-=') { - die("$fn: $key is not an array on line $n\n"); - } else { - die("can't happen\n"); - } - } - } else { - die("$fn: syntax error on line $n\n") - } - $line = ""; - } - } - close($fh); - return 1; -} - -# -# Record a tinderbox result in the history file -# -sub history($$$) { - my $start = shift; - my $end = shift; - my $success = shift; - - my $history = expand('HOSTNAME') . "\t"; - $history .= expand('CONFIG') . "\t"; - $history .= strftime("%Y-%m-%d %H:%M:%S\t", localtime($start)); - $history .= strftime("%Y-%m-%d %H:%M:%S\t", localtime($end)); - $history .= expand('ARCH') . "\t"; - $history .= expand('MACHINE') . "\t"; - $history .= expand('BRANCH') . "\t"; - $history .= $success ? "OK\n" : "FAIL\n"; - - my $fn = expand('LOGDIR') . "/history"; - if (open(my $fh, '>>', $fn)) { - print($fh $history); - close($fh); - } else { - print(STDERR "failed to record result to history file:\n$history\n"); - } -} - -# -# Report a tinderbox failure -# -sub report($$$$) { - my $sender = shift; - my $recipient = shift; - my $subject = shift; - my $message = shift; - - if (!$message) { - print(STDERR "[empty report, not sent by email]\n\n]"); - return; - } - if (length($message) < 128) { - print(STDERR "[suspiciously short report, not sent by email]\n\n"); - print(STDERR $message); - return; - } - - if (open(my $pipe, '|-', qw(/usr/sbin/sendmail -i -t -f), $sender)) { - print($pipe "Sender: $sender\n"); - print($pipe "From: $sender\n"); - print($pipe "To: $recipient\n"); - print($pipe "Subject: $subject\n"); - print($pipe "Precedence: bulk\n"); - print($pipe "\n"); - print($pipe "$message\n"); - close($pipe); - } else { - print(STDERR "[failed to send report by email]\n\n"); - print(STDERR $message); - } -} - -# -# Run the tinderbox -# -sub tinderbox($$$) { - my $branch = shift; - my $arch = shift; - my $machine = shift; - - my $config = expand('CONFIG'); - my $start = time(); - - $0 = "tbmaster [$config]: building $branch for $arch/$machine"; - - $CONFIG{'BRANCH'} = $branch; - $CONFIG{'ARCH'} = $arch; - $CONFIG{'MACHINE'} = $machine; - - # Open log files: one for the full log and one for the summary - my $logdir = expand('LOGDIR'); - if (!-d $logdir) { - die("nonexistent log directory: $logdir\n"); - } - my $logname = "tinderbox-$config-$branch-$arch-$machine"; - my $logbase = "$logdir/$logname"; - my $full; - if (!open($full, '>', "$logbase.full.$$")) { - warn("$logbase.full.$$: $!\n"); - return undef; - } - select($full); - $| = 1; - select(STDOUT); - my $brief; - if (!open($brief, '>', "$logbase.brief.$$")) { - warn("$logbase.brief.$$: $!\n"); - return undef; - } - select($brief); - $| = 1; - select(STDOUT); - - # Open a pipe for the tinderbox process - my ($rpipe, $wpipe); - if (!pipe($rpipe, $wpipe)) { - warn("pipe(): $!\n"); - unlink("$logbase.brief.$$"); - close($brief); - unlink("$logbase.full.$$"); - close($full); - return undef; - } - - # Fork and start the tinderbox - my @args = expand('OPTIONS'); - push(@args, "--hostname=" . expand('HOSTNAME')); - push(@args, "--sandbox=" . realpath(expand('SANDBOX'))); - push(@args, "--srcdir=" . realpath(expand('SRCDIR'))) - if ($CONFIG{'SRCDIR'}); - push(@args, "--objdir=" . realpath(expand('OBJDIR'))) - if ($CONFIG{'OBJDIR'}); - push(@args, "--arch=$arch"); - push(@args, "--machine=$machine"); - push(@args, "--repository=" . expand('REPOSITORY')) - if ($CONFIG{'REPOSITORY'}); - push(@args, "--branch=$branch"); - push(@args, "--patch=" . expand('PATCH')) - if ($CONFIG{'PATCH'}); - push(@args, "--jobs=" . expand('JOBS')) - if ($CONFIG{'JOBS'}); - push(@args, "--svnbase=" . expand('SVNBASE')) - if ($CONFIG{'SVNBASE'}); - push(@args, "--timeout=" . expand('TIMEOUT')) - if ($CONFIG{'TIMEOUT'}); - push(@args, expand('TARGETS')); - push(@args, expand('ENV')); - push(@args, "CFLAGS=" . expand('CFLAGS')) - if ($CONFIG{'CFLAGS'}); - push(@args, "COPTFLAGS=" . expand('COPTFLAGS')) - if ($CONFIG{'COPTFLAGS'}); - my $pid = fork(); - if (!defined($pid)) { - warn("fork(): $!\n"); - unlink("$logbase.brief.$$"); - close($brief); - unlink("$logbase.full.$$"); - close($full); - return undef; - } elsif ($pid == 0) { - close($rpipe); - open(STDOUT, '>&', $wpipe); - open(STDERR, '>&', $wpipe); - $| = 1; - exec(expand('TINDERBOX'), @args); - die("exec(): $!\n"); - } - - # Process the output - close($wpipe); - my @lines = (); - my $error = 0; - my $summary = ""; - my $root = realpath(expand('SANDBOX') . "/$branch/$arch/$machine"); - my $srcdir = realpath(expand('SRCDIR') || "$root/src"); - my $objdir = realpath(expand('OBJDIR') || "$root/obj"); - while (<$rpipe>) { - if ($abbreviate) { - s/\Q$srcdir\E/\/src/go; - s/\Q$objdir\E/\/obj/go; - } - print($full $_); - if (/^TB ---/ || /^>>> /) { - if ($error) { - $summary .= join('', @lines); - print($brief join('', @lines)); - @lines = (); - $error = 0; - } - $summary .= $_; - print($brief $_); - @lines = (); - next; - } - if (/^\*\*\*( \[.*?\])? (Error code|Stopped|Signal)/ && - !/\(ignored\)/) { - $error = 1; - } - if (@lines > $BACKLOG && !$error) { - shift(@lines); - $lines[0] = "[...]\n"; - } - push(@lines, $_); - } - close($rpipe); - if ($error) { - $summary .= join('', @lines); - print($brief join('', @lines)); - } - - # Done... - if (waitpid($pid, 0) == -1) { - warn("waitpid(): $!\n"); - } elsif ($? & 0xff) { - my $msg = "tinderbox caught signal " . ($? & 0x7f) . "\n"; - print($brief $msg); - print($full $msg); - $error = 1; - } elsif ($? >> 8) { - my $msg = "tinderbox returned exit code " . ($? >> 8) . "\n"; - print($brief $msg); - print($full $msg); - $error = 1; - } - close($brief); - close($full); - - my $end = time(); - - # Record result in history file - history($start, $end, !$error); - - # Filter recipients - my @recipients = expand('RECIPIENT'); - if (!$ENV{'MAGIC_SAUCE'} || - $ENV{'MAGIC_SAUCE'} ne 'MIDNIGHTBSD_TINDERBOX') { - @recipients = grep { ! m/\@midnightbsd.org\.org/i } @recipients; - } - - # Mail out error reports - if ($error && @recipients) { - my $sender = expand('SENDER'); - my $recipient = join(', ', @recipients); - my $subject = expand('SUBJECT'); - if ($CONFIG{'URLBASE'}) { - $summary .= "\n\n" . expand('URLBASE') . "$logname.full"; - } - report($sender, $recipient, $subject, $summary); - } - - rename("$logbase.full.$$", "$logbase.full"); - rename("$logbase.brief.$$", "$logbase.brief"); -} - -# -# Open and lock a file reliably -# -sub open_locked($;$$) { - my $fn = shift; # File name - my $mode = shift; # Open mode - my $perm = shift; # File permissions - - my $fh; # File handle - my (@sb1, @sb2); # File status - - for (;; close($fh)) { - open($fh, $mode, $fn) - or last; - if (!(@sb1 = stat($fh))) { - # Huh? shouldn't happen - last; - } - if (!flock($fh, LOCK_EX|LOCK_NB)) { - # A failure here means the file can't be locked, or - # something really weird happened, so just give up. - last; - } - if (!(@sb2 = stat($fn))) { - # File was pulled from under our feet, though it may - # reappear in the next pass - next; - } - if ($sb1[0] != $sb2[0] || $sb1[1] != $sb2[1]) { - # File changed under our feet, try again - next; - } - chmod($fh, $perm) - if defined($perm); - return $fh; - } - close($fh); - return undef; -} - -# -# Print a usage message and exit -# -sub usage() { - - (my $self = $0) =~ s|^.*/||; - print(STDERR "This is the MidnightBSD tinderbox manager, version $VERSION. -$COPYRIGHT - -Usage: - $self [options] [parameters] - -Options: - -d, --dump Dump the processed configuration - -Parameters: - -a, --abbreviate Abbreviate path names in log file - -c, --config=NAME Configuration name - -e, --etcdir=DIR Configuration directory - -l, --lockfile=FILE Lock file name - -n, --ncpu=NUM Number of CPUs available - -"); - exit(1); -} - -# -# Main loop -# -sub tbmaster($) { - my $config = shift; - - clearconf(); - readconf('default.rc'); - readconf("$config.rc") - or die("$config.rc: $!\n"); - readconf('site.rc'); - $CONFIG{'CONFIG'} = $config; - $CONFIG{'ETCDIR'} = $etcdir; - - if ($dump) { - foreach my $key (sort(keys(%CONFIG))) { - printf("%-12s = ", uc($key)); - if (ref($CONFIG{$key})) { - print(join(", ", @{$CONFIG{$key}})); - } else { - print($CONFIG{$key}); - } - print("\n"); - } - return; - } - - if (!length(expand('TINDERBOX')) || !-x expand('TINDERBOX')) { - die("Where is the tinderbox script?\n"); - } - - # Check stop file - my $stopfile = expand('SANDBOX') . "/stop"; - my @jobs; - foreach my $branch (expand('BRANCHES')) { - foreach my $platform (expand('PLATFORMS')) { - next if (%platforms && !$platforms{$platform}); - my ($arch, $machine) = split('/', $platform, 2); - $machine = $arch - unless defined($machine); - push(@jobs, [ $branch, $arch, $machine ]); - } - } - - # Main loop: start as many concurrent jobs as permitted, then keep - # starting new jobs as soon as existing jobs terminate, until all - # jobs have terminated and there are none left in the queue. - $0 = "tbmaster [$config]: supervisor"; - my %children; - my $done = 0; - while (@jobs || keys(%children)) { - # start more children if we can - while (@jobs && keys(%children) < expand('NCPU')) { - my ($branch, $arch, $machine) = @{shift(@jobs)}; - if (-e $stopfile || -e "$stopfile.$branch" || - -e "$stopfile.$arch" || -e "$stopfile.$arch.$machine") { - warn("stop file found, skipping $branch $arch/$machine\n"); - next; - } - my $child = fork(); - if (!defined($child)) { - die("fork(): $!\n"); - } elsif ($child == 0) { - tinderbox($branch, $arch, $machine); - exit(0); - } else { - $children{$child} = [ $branch, $arch, $machine ]; - } - warn("forked child $child for $branch $arch/$machine\n"); - } - $0 = "tbmaster [$config]: supervisor (" . - keys(%children) . " running, " . - @jobs . " pending, " . - $done . " completed)"; - # wait for a child to terminate - if (keys(%children)) { - my $child = wait(); - if ($child > 0) { - my ($branch, $arch, $machine) = @{$children{$child}}; - warn("child $child for $branch $arch/$machine terminated\n"); - delete($children{$child}); - ++$done; - } - } - } -} - -# -# Read the input from a command -# -sub slurp(@) { - my @cmdline = @_; - - if (open(my $pipe, '-|', @cmdline)) { - local $/; - my $input = <$pipe>; - close($pipe); - return $input; - } - return undef; -} - -# -# Main -# -MAIN:{ - # Set defaults - $ENV{'TZ'} = "UTC"; - $ENV{'PATH'} = "/usr/bin:/usr/sbin:/bin:/sbin"; - if ($ENV{'HOME'} =~ m/^((?:\/[\w\.-]+)+)\/*$/) { - $INITIAL_CONFIG{'HOME'} = realpath($1); - $etcdir = "$1/etc"; - $ENV{'PATH'} = "$1/bin:$ENV{'PATH'}" - if (-d "$1/bin"); - } - - # Get options - {Getopt::Long::Configure("auto_abbrev", "bundling");} - GetOptions( - "a|abbreviate!" => \$abbreviate, - "c|config=s" => \@configs, - "d|dump" => \$dump, - "e|etcdir=s" => \$etcdir, - "h|hostname=s" => \$hostname, - "l|lockfile=s" => \$lockfile, - "n|ncpu=i" => \$ncpu, - ) or usage(); - - # Subsequent arguments are platforms to build - foreach (@ARGV) { - if (m/^(\w+(?:\/\w+)?)$/) { - $platforms{$1} = 1; - } else { - die("invalid platform: $_\n"); - } - } - - # Get / check hostname - if (!$hostname) { - $hostname = slurp(qw(/usr/bin/uname -n)); - } - if ($hostname && - $hostname =~ m/^\s*([a-z][0-9a-z-]+(?:\.[a-z][0-9a-z-]+)*)\s*$/s) { - $hostname = $1; - } else { - $hostname = 'unknown'; - } - $INITIAL_CONFIG{'HOSTNAME'} = $hostname; - - # Get / check number of CPUs - if (!$ncpu) { - $ncpu = slurp(qw(/sbin/sysctl -n hw.ncpu)); - } - if ($ncpu && $ncpu =~ m/^\s*(\d+)\s*$/s) { - $ncpu = int($1); - } else { - $ncpu = 1; - } - $INITIAL_CONFIG{'NCPU'} = $ncpu; - - # Check options - if (@configs) { - @configs = split(/,/, join(',', @configs)); - } else { - $configs[0] = $hostname; - chomp($configs[0]); - $configs[0] =~ s/^(\w+)(\..*)?/$1/; - } - if (defined($etcdir)) { - if ($etcdir !~ m/^([\w\/\.-]+)$/) { - die("invalid etcdir\n"); - } - $etcdir = $1; - chdir($etcdir) - or die("$etcdir: $!\n"); - } - for (my $n = 0; $n < @configs; ++$n) { - $configs[$n] =~ m/^([\w-]+)$/ - or die("invalid config: $configs[$n]\n"); - $configs[$n] = $1; - } - - # Acquire lock - if (defined($lockfile)) { - if ($lockfile !~ m/^([\w\/\.-]+)$/) { - die("invalid lockfile\n"); - } - $lockfile = $1; - $lock = open_locked($lockfile, '>', 0600) - or die("unable to acquire lock on $lockfile\n"); - # Lock will be released upon termination. - } - - # Run all specified or implied configurations - foreach my $config (@configs) { - tbmaster($config); - } - exit(0); -} diff --git a/tools/tools/tinderbox/tinderbox.1 b/tools/tools/tinderbox/tinderbox.1 deleted file mode 100644 index 4e7253a1056..00000000000 --- a/tools/tools/tinderbox/tinderbox.1 +++ /dev/null @@ -1,379 +0,0 @@ -.\"- -.\" Copyright (c) 2003-2014 Dag-Erling Smørgrav -.\" 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: user/des/tinderbox/tinderbox.1 268719 2014-07-15 22:34:54Z des $ -.\" $MidnightBSD$ -.\" -.Dd May 24, 2014 -.Dt TINDERBOX 1 -.Os -.Sh NAME -.Nm tinderbox -.Nd build and release testing -.Sh SYNOPSIS -.Nm -.Op options -.Ar command Op ... -.Op Ar variable Ns = Ns Ar value ... -.Sh DESCRIPTION -The -.Nm -script tests the -.Mx -build and release system by performing a cross-build (and optionally a -cross-release) of an arbitrary branch of the source tree for an -arbitrary target platform. -.Pp -The following options are recognized: -.Bl -tag -width 12n -.It Fl -arch Ns = Ns Ar ARCH -Specifies the target architecture -.Pq Va $arch . -The default value is whatever the host system's -.Xr uname 1 -reports. -.It Fl -branch Ns = Ns Ar BRANCH -The branch to check out from -.Xr svn 1 -when updating the source tree -.Pq Va $branch . -The default is to check out HEAD. -For historical compatibility, -.Xr cvs 1 Ns -style -branch names are translated to -.Xr svn 1 -paths; for instance, -.Dv RELENG_9 -becomes -.Pa stable/9 -and -.Dv RELENG_9_1 -becomes -.Pa releng/9.1 . -.It Fl -destdir Ns = Ns Ar DIR -The directory (aka -.Dv DESTDIR ) -in which the results of the build will be installed if the -.Cm install -command is specified. -The default is -.Pa $SANDBOX/inst . -.It Fl -hostname Ns = Ns Ar NAME -The name of the host running the tinderbox. -This defaults to the name reported by the -.Fl n -option of the -.Xr uname 1 -command, and is only used for cosmetic purposes. -.It Fl -jobs Ns = Ns Ar NUM -The maximum number of paralell jobs -.Pq Va $jobs , -as specified to -.Xr make 1 -using the -.Fl j -option. -The default is 1. -.It Fl -logfile Ns = Ns Ar FILE -The name of a file to which the output and error messages produced by -the build should be written. -Note that this file can grow quite large. -The default is to redirect all output to -.Pa /dev/stdout . -.It Fl -machine Ns = Ns Ar MACHINE -Specifies the target machine -.Pq Va $machine . -The default value is whatever the host system's -.Xr uname 1 -reports, unless a target architecture was specified with the -.Fl -arch -option, in which case the target machine is set to the same value. -.It Fl -objdir Ns = Ns Ar DIR -Specifies the object directory prefix -.Pq Va $objdir . -.It Fl -patch Ns = Ns Ar PATCH -The file name of a patch to apply to the source tree before building -if the -.Cm patch -command is specified. -The patch should be relative to the root of the source tree. -When building a release, the patch is passed to the release process -through the -.Ev LOCAL_PATCHES -environment variable (see -.Xr release 7 -for more information), regardless of whether the -.Cm patch -command was specified. -The default is to not apply any patches. -.It Fl -sandbox Ns = Ns Ar DIR -The location of the sandbox in which the builds are to take place. -This directory should reside on a reasonably fast disk with at least -1.5 GB available (3 GB if building a release). -.It Fl -srcdir Ns = Ns Ar DIR -Specifies the source directory -.Pq Va $srcdir . -Normally, the -.Nm -script creates a separate source directory within the sandbox for each -branch, architecture and platform. -This option allows a single source directory to be shared between -multiple architectures and platforms. -This may simplify the process of build-testing modified sources, and, -depending on the exact setup, speed up the build significantly. -.Pp -Note that it is generally not a good idea to combine this with any of -the -.Dq preclean , -.Dq precleansrc -or -.Dq update -commands. -.It Fl -svnbase Ns = Ns Ar URL -The URL to the base of the Subversion repository. -The default is -.\" There does not seem to be an mdoc macro for URLs; use Pa instead. -.Pa svn://svn.freebsd.org/base . -.It Fl -timeout Ns = Ns Ar NUM -The maximum wall-time duration of the run, in seconds. -The default is to continue until all targets are completed. -.It Fl -verbose -Enable additional debugging output. -.El -.Pp -Following the options on the command line, at least one of the -following commands must be specified: -.Bl -tag -width 12n -.It Cm clean -Alias for -.Cm preclean . -.It Cm cleansrc -Alias for -.Cm precleansrc . -.It Cm cleanobj -Alias for -.Cm precleanobj . -.It Cm cleaninst -Alias for -.Cm precleaninst . -.It Cm cleanroot -Alias for -.Cm precleanroot . -.It Cm preclean -Delete the source, object, installation and release trees at the -start of each job. -See -.Cm precleansrc , -.Cm precleanobj , -.Cm precleaninst -and -.Cm precleanroot -below. -.It Cm precleansrc -Delete the source tree at the start of each job. -This is highly recommended when sources are patched, as successive -builds will fail due to repeated application of the same patch to the -same sources. -.It Cm precleanobj -Delete the object tree at the start of each job. -.It Cm precleaninst -Delete the installation tree at the start of each job. -.It Cm precleanroot -Delete the release chroot tree at the start of each job. -.It Cm revert -Revert the source tree to a clean state. -.It Cm update -Update the source tree using -.Xr svn 1 . -.It Cm patch -Apply the patch specified with the -.Fl -patch -option to the source tree. -If the specified patch file does not exist, the -.Cm patch -command will fail gracefully. -.It Cm version -After updating and patching the source tree but before doing anything -else, log information about the current state of the source tree. -.It Cm world -Build the world. -.It Cm lint -Build LINT kernels if available. -In -.Fx -5 and newer, the -.Pa LINT -configuration files will first be generated from the corresponding -.Pa NOTES -file. -If there are no -.Pa LINT -configurations in the kernel configuration directory and -.Pa NOTES -does not exist, the -.Cm lint -command will fail gracefully. -.It Cm kernel: Ns Ar CONF -Build the -.Ar CONF -kernel. -If a file named -.Ar CONF -does not exist in the kernel configuration directory, this command -will fail gracefully. -.It Cm generic -Equivalent to -.Cm kernel: Ns Ar GENERIC , -for backward compatibility. -.It Cm kernels -Build all available kernel configurations other than -.Pa LINT . -.It Cm install -Install the result of the build into -.Pa ${DESTDIR} . -Each kernel that was built will be installed into a subdirectory of -.Pa ${DESTDIR}/boot -named after the corresponding kernel configuration file. -.It Cm release -Build a release by following the procedure described in -.Xr release 7 . -Note that this is a lengthy process which requires root privileges. -.It Cm postclean -As -.Cm preclean , -but at the end of each job. -.It Cm cleansrc -As -.Cm precleansrc , -but at the end of each job. -.It Cm cleanobj -As -.Cm precleanobj , -but at the end of each job. -.It Cm cleaninst -As -.Cm precleaninst , -but at the end of each job. -.It Cm cleanroot -As -.Cm precleanroot , -but at the end of each job. -.El -.Pp -The commands are executed in the order in which they are listed above, -regardless of the order in which they are listed on the command line. -.Pp -Finally, any arguments of the form -.Ar variable Ns = Ns Ar value -are interpreted as environment variables which are exported into the -build environment. -These variables are not allowed to override those set by the script -itself (see -.Sx ENVIRONMENT -below). -.Sh NOTES -The -.Nm -script was originally written to perform daily build testing of -.Fx -4 and 5. -It is not intended for use with older releases, and probably will not -work with anything older than -.Fx 4.2 . -.Sh ENVIRONMENT -The -.Nm -script clears its environment at startup and provides its child -processes with a tailored environment. -The following variables are set for all builds: -.Bl -tag -width 18n -.It PATH -.Ar /usr/bin:/usr/sbin:/bin:/sbin -.It TZ -.Ar UTC -.It __MAKE_CONF -.Ar /dev/null -.It SRCCONF -.Ar /dev/null -.It MAKEOBJDIRPREFIX -.Ar $objdir -.It TARGET -.Ar $machine -.It TARGET_ARCH -.Ar $arch -.It CROSS_BUILD_TESTING -.Ar YES -.El -.Pp -The following additional variables are set for release builds: -.Bl -tag -width 18n -.It CHROOTDIR -.Ar $SANDBOX/root -.It RELEASETAG -.Ar -r$branch -if specified using the -.Fl -branch -option, or -.Ar -A -otherwise. -.It WORLD_FLAGS , KERNEL_FLAGS -Both of these are set to -.Ar -j$jobs -if specified using the -.Fl -jobs -option, or -.Ar -B -otherwise. -.It LOCAL_PATCHES -Set to the path of the patch that was specified with the -.Fl -patch -option, if any. -.It PATCH_FLAGS -Set to -.Ar -fs -if a patch was specified. -.It NOCDROM -.Ar YES -.It NODOC -.Ar YES -.It NOPORTS -.Ar YES -.El -.Pp -None of these variables may be overridden by command-line arguments. -.Sh SEE ALSO -.Xr make 1 , -.Xr patch 1 , -.Xr svn 1 , -.Xr tbmaster 1 , -.Xr build 7 , -.Xr release 7 -.Sh AUTHORS -The -.Nm -script was written by -.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org . -.Sh BUGS -are crunchy and nutritious. diff --git a/tools/tools/tinderbox/tinderbox.pl b/tools/tools/tinderbox/tinderbox.pl deleted file mode 100644 index 0722a261748..00000000000 --- a/tools/tools/tinderbox/tinderbox.pl +++ /dev/null @@ -1,905 +0,0 @@ -#!/usr/bin/perl -Tw -#- -# Copyright (c) 2003-2014 Dag-Erling Smørgrav -# 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: user/des/tinderbox/tinderbox.pl 268719 2014-07-15 22:34:54Z des $ -# $MidnightBSD$ -# - -use v5.10.1; -use strict; -use Fcntl qw(:DEFAULT :flock); -use POSIX; -use Getopt::Long; -use Scalar::Util qw(tainted); - -my $VERSION = "2.22"; -my $COPYRIGHT = "Copyright (c) 2003-2014 Dag-Erling Smørgrav. " . - "All rights reserved."; - -my $arch; # Target architecture -my $branch; # CVS branch to check out -my $destdir; # Destination directory -my $jobs; # Number of paralell jobs -my $hostname; # Name of the host running the tinderbox -my $logfile; # Path to log file -my $machine; # Target machine -my $objdir; # Location of object tree -my $objpath; # Full path to object tree -my $obj32path; # Full path to 32-bit object tree -my $patch; # Patch to apply before building -my $sandbox; # Location of sandbox -my $srcdir; # Location of source tree -my $svnbase; # Subversion base URL -my $timeout; # Timeout in seconds -my $verbose; # Verbose mode - -my %children; - -my %userenv; - -my %cmds = ( - 'clean' => 0, 'preclean' => 0, 'postclean' => 0, - 'cleansrc' => 0, 'precleansrc' => 0, 'postcleansrc' => 0, - 'cleanobj' => 0, 'precleanobj' => 0, 'postcleanobj' => 0, - 'cleaninst' => 0, 'precleaninst' => 0, 'postcleaninst' => 0, - 'cleanobj' => 0, 'precleanobj' => 0, 'postcleanobj' => 0, - 'revert' => 0, - 'update' => 0, - 'patch' => 0, - 'world' => 0, - 'lint' => 0, - 'kernels' => 0, - 'install' => 0, - 'release' => 0, - 'version' => 0, -); -my %kernels; -my %lint; - -my $starttime; - -my $unamecmd = '/usr/bin/uname'; - -my @svncmds = ( - '/usr/bin/svn', - '/usr/local/bin/svn', -); - -my @svnversioncmds = ( - '/usr/bin/svnversion', - '/usr/local/bin/svnversion', -); - -my $svnattempts = 4; - -BEGIN { - ($starttime) = POSIX::times(); -} - -END { - my ($endtime, $user, $system, $cuser, $csystem) = POSIX::times(); - $user += $cuser; - $system += $csystem; - my $ticks = POSIX::sysconf(&POSIX::_SC_CLK_TCK); - message(sprintf("%.2f user %.2f system %.2f real", - $user / $ticks, $system / $ticks, ($endtime - $starttime) / $ticks)); -} - -# -# Issue a message -# -sub message(@) { - - my $time = strftime("%Y-%m-%d %H:%M:%S", localtime()); - my $msg = join(' ', @_); - chomp($msg); - print(STDERR "TB --- $time - $msg\n"); -} - -# -# Issue a warning message -# -sub warning(@) { - - message("WARNING:", @_); - return undef; -} - -# -# Issue an error message and die -# -sub error(@) { - - message("ERROR:", @_); - exit(1); -} - -# -# Invoked when ::warn() is called -# -sub sigwarn { - - warning(@_); -} - -# -# Invoked when ::die() is called -# -sub sigdie { - - error(@_); -} - -# -# Log that we are entering a new stage -# -sub logstage($) { - my $msg = shift; - - chomp($msg); - $0 = "tinderbox: [$branch $arch/$machine] $msg"; - message($msg); -} - -# -# Log a copy of the environment -# -sub logenv() { - - foreach my $key (sort(keys(%ENV))) { - message("$key=$ENV{$key}"); - } -} - -# -# Expand a path -# -sub realpath($;$); -sub realpath($;$) { - my $path = shift; - my $base = shift || ""; - - my $realpath = ($path =~ m|^/|) ? "" : $base; - foreach my $part (split('/', $path)) { - if ($part eq '' || $part eq '.') { - # nothing - } elsif ($part eq '..') { - $realpath =~ s|/[^/]+$|| - or die("'$path' is not a valid path relative to '$base'\n"); - } elsif (-l "$realpath/$part") { - my $target = readlink("$realpath/$part") - or die("unable to resolve symlink '$realpath/$part': $!\n"); - $realpath = realpath($target, $realpath); - } else { - $part =~ m/^([\w.-]+)$/ - or die("unsafe path '$realpath/$part'\n"); - $realpath .= "/$1"; - } - } - return $realpath; -} - -# -# Open and lock a file reliably -# -sub open_locked($;$$) { - my $fn = shift; # File name - my $mode = shift; # Open mode - my $perm = shift; # File permissions - - my $fh; # File handle - my (@sb1, @sb2); # File status - - for (;; close($fh)) { - open($fh, $mode, $fn) - or last; - if (!(@sb1 = stat($fh))) { - # Huh? shouldn't happen - last; - } - if (!flock($fh, LOCK_EX|LOCK_NB)) { - # A failure here means the file can't be locked, or - # something really weird happened, so just give up. - last; - } - if (!(@sb2 = stat($fn))) { - # File was pulled from under our feet, though it may - # reappear in the next pass - next; - } - if ($sb1[0] != $sb2[0] || $sb1[1] != $sb2[1]) { - # File changed under our feet, try again - next; - } - chmod($fh, $perm) - if defined($perm); - return $fh; - } - close($fh); - return undef; -} - -# -# Remove a directory and all its subdirectories -# -sub remove_dir($); -sub remove_dir($) { - my $dir = shift; - - if (-l $dir || !-d $dir) { - print("rm $dir\n") - if ($verbose); - if (!unlink($dir) && $! != ENOENT) { - return warning("$dir: $!"); - } - return 1; - } - - opendir(my $dh, $dir) - or return warning("$dir: $!"); - my @entries = readdir($dh); - closedir($dh) - or return warning("$dir: $!"); - foreach my $ent (@entries) { - next if ($ent eq '.' || $ent eq '..'); - $ent =~ m/(.*)/; - remove_dir("$dir/$1") - or return undef; - } - print("rmdir $dir\n") - if ($verbose); - rmdir($dir) - or return warning("$dir: $!"); - return 1; -} - -# -# Create a directory and the path leading up to it -# -sub make_dir($); -sub make_dir($) { - my $dir = shift; - - if (!-d $dir && $dir =~ m|^(\S*)/([^\s/]+)$|) { - make_dir($1) - or return undef; - message("mkdir $dir"); - if (!mkdir("$dir") && $! != EEXIST) { - return undef; - } - } - return 1; -} - -# -# Change working directory -# -sub cd($) { - my $dir = shift; - - message("cd $dir"); - chdir($dir) - or error("$dir: $!"); -} - -# -# Spawn a child and wait for it to finish -# -sub spawn($@) { - my $cmd = shift; # Command to run - my @args = @_; # Arguments - - message($cmd, @args); - # Check command and arguments for taint. The build will die - # anyway, but at least we'll have a starting point for debugging. - warning("command name is tainted\n") - if tainted($cmd); - for (my $i = 0; $i < @args; ++$i) { - warning("argv\[$i\] is tainted\n") - if tainted($args[$i]); - } - my $pid = fork(); - if (!defined($pid)) { - return warning("fork(): $!"); - } elsif ($pid == 0) { - exec($cmd, @args); - die("exec(): $!\n"); - } - $children{$pid} = $pid; - my $ret = waitpid($pid, 0); - delete $children{$pid}; - if ($ret == -1) { - return warning("waitpid(): $!\n"); - } elsif ($? & 0xff) { - return warning("$cmd caught signal ", $? & 0x7f, "\n"); - } elsif ($? >> 8) { - return warning("$cmd returned exit code ", $? >> 8, "\n"); - } - return 1; -} - -# -# Run make -# -sub make($@) { - my $target = shift; - my %env = @_; - - my @args = map({ "$_=$env{$_}" } keys(%env)); - return spawn('/usr/bin/make', - ($jobs > 1) ? "-j$jobs" : "-B", - $target, @args); -} - -sub timeout() { - kill(15, keys(%children)) - if (%children); - error("timed out after $timeout seconds"); - exit(1); -} - -# -# Handle the various "clean" commands -# -sub do_clean(;$) { - my ($prepost) = @_; - - my $clean = $prepost ? "${prepost}clean" : "clean"; - - if ($cmds{$clean} || $cmds{$clean.'src'}) { - logstage("cleaning the source tree"); - if (-e $srcdir) { - remove_dir($srcdir) - or error("unable to remove old source directory"); - } - } - if ($cmds{$clean} || $cmds{$clean.'obj'}) { - logstage("cleaning the object tree"); - if (-e $objdir) { - remove_dir($objdir) - or error("unable to remove old object directory"); - } - } - if ($cmds{$clean} || $cmds{$clean.'inst'}) { - logstage("cleaning the installation tree"); - if (-e $destdir) { - spawn('/bin/chflags', '-R', '0', $destdir); - remove_dir($destdir) - or error("unable to remove old installation directory"); - } - } - if ($cmds{$clean} || $cmds{$clean.'root'}) { - logstage("cleaning the chroot tree"); - if (-e "$sandbox/root") { - spawn('/bin/chflags', '-R', '0', "$sandbox/root"); - remove_dir("$sandbox/root") - or error("unable to remove old chroot directory"); - } - } -} - -sub usage() { - - print(STDERR "This is the MidnightBSD tinderbox script, version $VERSION. -$COPYRIGHT - -Usage: - $0 [options] [parameters] command [...] - -Options: - --verbose Verbose mode - -Parameters: - --arch=ARCH Target architecture (e.g. i386) - --branch=BRANCH Source branch to check out - --destdir=DIR Destination directory when installing - --jobs=NUM Maximum number of paralell jobs - --hostname=NAME Name of the host running the tinderbox - --logfile=FILE Path to log file - --machine=MACHINE Target machine (e.g. pc98) - --patch=PATCH Patch to apply before building - --sandbox=DIR Location of sandbox - --svnbase=URL Subversion base URL - --timeout=SECONDS Maximum allowed build time - --verbose Increase log detail - -Commands: - clean Clean the sandbox - cleansrc Clean the source tree - cleanobj Clean the object tree - cleaninst Clean the installation tree - cleanroot Clean the release chroot - update Update the source tree - patch Patch the source tree - world Build the world - kernel:KERNCONF Build the KERNCONF kernel - lint Build the LINT kernel - install Install world and all kernels - release Build a full release (run as root!) - -"); - exit(1); -} - -MAIN:{ - # Clear environment and set timezone - %ENV = ( - 'TZ' => "UTC", - 'PATH' => "/usr/bin:/usr/sbin:/bin:/sbin", - ); - tzset(); - - # Set defaults - $hostname = `$unamecmd -n`; - chomp($hostname); - $branch = "HEAD"; - $jobs = 0; - $sandbox = "/tmp/tinderbox"; - $svnbase = "svn://svn.midnightbsd.org/svn/src/"; - $timeout = 0; - - # Get options - GetOptions( - "arch=s" => \$arch, - "branch=s" => \$branch, - "destdir=s" => \$destdir, - "jobs=i" => \$jobs, - "hostname=s" => \$hostname, - "logfile=s" => \$logfile, - "machine=s" => \$machine, - "objdir=s" => \$objdir, - "patch=s" => \$patch, - "sandbox=s" => \$sandbox, - "srcdir=s" => \$srcdir, - "svnbase=s" => \$svnbase, - "timeout=i" => \$timeout, - "verbose+" => \$verbose, - ) or usage(); - - if ($jobs !~ m/^(\d+)$/) { - error("invalid number of jobs"); - } - $jobs = $1; - if ($timeout !~ m/^(\d+)$/) { - error("invalid timeout"); - } - $timeout = $1; - if ($branch !~ m|^(\w+)$|) { - error("invalid source branch"); - } - $branch = ($1 eq 'CURRENT') ? 'trunk' : $1; - if (!defined($arch)) { - $arch = `$unamecmd -p`; - chomp($arch); - if (!defined($machine)) { - $machine = `$unamecmd -m`; - chomp($machine); - } - } - if ($arch !~ m|^(\w+)$|) { - error("invalid target architecture"); - } - $arch = $1; - if (!defined($machine)) { - $machine = $arch; - } - if ($machine !~ m|^(\w+)$|) { - error("invalid target machine"); - } - $machine = $1; - if (!defined($destdir)) { - $destdir = "$sandbox/inst"; - } - if ($svnbase && - $svnbase !~ m@^((?:svn(?:\+ssh)?://(?:[a-z][0-9a-z-]*)(?:\.[a-z][0-9a-z-]*)*(?::\d+)?|file://)/[\w./-]*)@) { - error("invalid SVN base URL"); - } - $svnbase = $1; - - if (!@ARGV) { - usage(); - } - - # Set up a timeout - if ($timeout > 0) { - $SIG{ALRM} = \&timeout; - alarm($timeout); - } - - # Find out what we're expected to do - foreach my $cmd (@ARGV) { - if ($cmd =~ m/^(\w+)=(.*)\s*$/) { - $userenv{$1} = $2; - next; - } - if ($cmd =~ m/^kernel:(\w+)$/) { - $kernels{$1} = 1; - next; - } - # backward compatibility - # note that LINT is special, GENERIC is not - if ($cmd eq 'generic') { - $kernels{'GENERIC'} = 1; - next; - } - if (!exists($cmds{$cmd})) { - error("unrecognized command: '$cmd'"); - } - $cmds{$cmd} = 1; - } - - # Open logfile - open(STDIN, '<', "/dev/null") - or error("/dev/null: $!\n"); - if (defined($logfile)) { - if ($logfile !~ m|([\w./-]+)$|) { - error("invalid log file name"); - } - $logfile = $1; - unlink($logfile); - open(STDOUT, '>', $logfile) - or error("$logfile: $!"); - } - open(STDERR, ">&STDOUT"); - $| = 1; - logstage("tinderbox $VERSION running on $hostname"); - logstage(`$unamecmd -a`); - logstage("starting $branch tinderbox run for $arch/$machine"); - $SIG{__DIE__} = \&sigdie; - $SIG{__WARN__} = \&sigwarn; - - # Take control of our sandbox - if ($sandbox !~ m|^(/[\w./-]+)$|) { - error("invalid sandbox directory"); - } - $sandbox = "$1/$branch/$arch/$machine"; - $ENV{'HOME'} = $sandbox; - make_dir($sandbox) - or error("$sandbox: $!"); - my $lockfile = open_locked("$sandbox/lock", ">", 0600); - if (!defined($lockfile)) { - error("unable to lock sandbox"); - } - truncate($lockfile, 0); - print($lockfile "$$\n"); - - # Validate source directory - if (defined($srcdir)) { - if ($srcdir !~ m|^(/[\w./-]+)$|) { - error("invalid source directory"); - } - $srcdir = $1; - } else { - $srcdir = "$sandbox/src"; - } - $srcdir = realpath($srcdir); - - # Validate object directory - if (defined($objdir)) { - if ($objdir !~ m|^(/[\w./-]+)$|) { - error("invalid object directory"); - } - $objdir = $1; - } else { - $objdir = "$sandbox/obj"; - } - $objdir = realpath($objdir); - - # Construct full path to object directory - $objpath = "$objdir/$machine.$arch$srcdir"; - $obj32path = "$objdir/$machine.$arch/lib32$srcdir"; - - # Clean up remains from old runs - do_clean(); # no prefix for backward compatibility - do_clean('pre'); - - # Locate svn - my $svncmd = '/usr/bin/false'; - if ($cmds{'revert'} || $cmds{'version'} || $cmds{'update'}) { - $svncmd = [grep({ -x } @svncmds)]->[0] - or error("unable to locate svn binary"); - } - - # Upgrade and unlock the working copy - if (($cmds{'revert'} || $cmds{'update'}) && -d "$srcdir/.svn") { - spawn($svncmd, "upgrade", $srcdir); - spawn($svncmd, "cleanup", $srcdir); - } - - # Revert sources - if ($cmds{'revert'} && -d "$srcdir/.svn") { - my @svnargs; - push(@svnargs, "--quiet") - unless ($verbose); - logstage("reverting $srcdir"); - spawn($svncmd, @svnargs, "revert", "-R", $srcdir) - or error("unable to revert the source tree"); - # remove leftovers... ugly! - open(my $pipe, '-|', $svncmd, "stat", "--no-ignore", $srcdir) - or error("unable to stat source tree"); - while (<$pipe>) { - m/^[I?]\s+(\S.*)$/ or next; - if (-d $1) { - remove_dir($1) - or error("unable to remove $1"); - } elsif (-f $1 || -l $1) { - unlink($1) - or error("unable to remove $1"); - } else { - warning("ignoring $1"); - } - } - close($pipe); - } - - # Check out new source tree - if ($cmds{'update'}) { - error("no svn base URL defined") - unless defined($svnbase); - my @svnargs; - push(@svnargs, "--quiet") - unless ($verbose); - # ugly-bugly magic required because CVS to SVN conversion - # smashed branch names - $svnbase =~ s/\/$//; - if ($branch eq 'HEAD') { - $svnbase .= '/head'; - } elsif ($branch =~ m/^RELENG_(\d+)_(\d+)$/) { - $svnbase .= "/releng/$1.$2"; - } elsif ($branch =~ m/^RELENG_(\d+)$/) { - $svnbase .= "/stable/$1"; - } else { - error("unrecognized branch: $branch"); - } - logstage("checking out $srcdir from $svnbase"); - cd("$sandbox"); - for (0..$svnattempts) { - if (-d "$srcdir/.svn") { - last if spawn($svncmd, @svnargs, "update", $srcdir); - } else { - last if spawn($svncmd, @svnargs, "checkout", $svnbase, $srcdir); - } - error("unable to check out the source tree") - if ($_ == $svnattempts); - my $delay = 30 * ($_ + 1); - warning("sleeping $delay s and retrying..."); - sleep($delay); - spawn($svncmd, "cleanup", $srcdir); - } - } - - # Patch sources - if ($cmds{'patch'} && !defined($patch)) { - warning("no patch specified"); - $cmds{'patch'} = 0; - } - if ($cmds{'patch'}) { - $patch = "$sandbox/$patch" - unless ($patch =~ m|^/|); - if ($patch !~ m|^(/[\w./-]+)$|) { - error("invalid patchfile path"); - } - $patch = $1; - if (-f $patch) { - logstage("patching the sources"); - cd($srcdir); - spawn('/usr/bin/patch', "-f", "-E", "-p0", "-s", "-i$patch") - or error("failed to apply patch to source tree"); - } else { - warning("$patch does not exist"); - } - } - - # Print source tree version information - if ($cmds{'version'}) { - if (defined($svnbase)) { - my $svnversioncmd = [grep({ -x } @svnversioncmds)]->[0] - or error("unable to locate svnversion binary"); - if ($verbose) { - spawn($svncmd, "stat", "--no-ignore", $srcdir) - or error("unable to stat source tree"); - } - my $svnversion = `$svnversioncmd $srcdir`; # XXX - message("At svn revision $svnversion"); - } else { - warning("the 'version' target is only supported for svn"); - } - } - - # Prepare environment for make(1); - %ENV = ( - 'TZ' => "UTC", - 'PATH' => "/usr/bin:/usr/sbin:/bin:/sbin", - - '__MAKE_CONF' => "/dev/null", - 'SRCCONF' => "/dev/null", - 'MAKEOBJDIRPREFIX' => $objdir, - - 'TARGET' => $machine, - 'TARGET_ARCH' => $arch, - - # Force cross-build, even when host == target - 'CROSS_BUILD_TESTING' => "YES", - ); - - # Kernel-specific variables - if (%kernels || $cmds{'lint'} || $cmds{'release'}) { - # None at the moment - } - - # User-supplied variables - foreach my $key (keys(%userenv)) { - if (exists($ENV{$key})) { - warning("will not allow override of $key"); - } else { - $ENV{$key} = $userenv{$key}; - } - } - - # Makefile.inc1 makes the idiotic assumption that you could not ever - # start a build less than one second after the source tree was updated. - sleep(1); - - # Build the world, or at least the kernel toolchain - if ($cmds{'world'}) { - logstage("building world"); - logenv(); - cd($srcdir); - make('buildworld') - or error("failed to build world"); - } elsif (%kernels || $cmds{'lint'} || $cmds{'kernels'}) { - logstage("building kernel toolchain"); - logenv(); - cd($srcdir); - make('kernel-toolchain') - or error("failed to build kernel toolchain"); - } - - # Locate LINT configs if requested - if ($cmds{'lint'}) { - if (-f "$srcdir/sys/$machine/conf/NOTES") { - logstage("generating LINT kernel config"); - cd("$srcdir/sys/$machine/conf"); - make('LINT') - or error("failed to generate LINT kernel config"); - my $dir = "$srcdir/sys/$machine/conf/"; - if (opendir(my $dh, $dir)) { - foreach (readdir($dh)) { - if ($_ =~ m|^(LINT(?:-[A-Z0-9][A-Z0-9_.-]*[A-Z0-9])?)$| && -f "$dir/$_") { - $lint{$1} = 1; - } - } - closedir($dh); - } else { - warning("$dir: $!\n"); - } - } - } - - # Locate additional kernel configs - if ($cmds{'kernels'}) { - my $dir = "$srcdir/sys/$machine/conf/"; - if (opendir(my $dh, $dir)) { - foreach (readdir($dh)) { - if ($_ =~ m|^([A-Z0-9][A-Z0-9_.-]*[A-Z0-9])$| && - $_ !~ m|^LINT| && - $_ ne "DEFAULTS" && - $_ ne "NOTES" && - -f "$dir/$_") { - $kernels{$1} = 1; - } - } - closedir($dh); - } else { - warning("$dir: $!\n"); - } - } - - kernel: - foreach my $kernel (sort(keys(%lint)), sort(keys(%kernels))) { - if (! -f "$srcdir/sys/$machine/conf/$kernel") { - warning("no kernel config for $kernel"); - next kernel; - } - # Check that the config is appropriate for this target. - cd("$srcdir/sys/$machine/conf"); - local *PIPE; - # ugh, we really shouldn't need to know that. - my $cmd = "$objpath/tmp/legacy/usr/sbin/config"; - $cmd = "/usr/sbin/config" unless -x $cmd; - my @cmdline = ($cmd, "-m", $kernel); - message(@cmdline); - if (open(PIPE, "-|", @cmdline)) { - local $/; - my $config_m = ; - close(PIPE); - print($config_m) - if ($verbose); - if ($config_m !~ m|^\Q$machine\E\s+\Q$arch\E\s*$|s) { - message("skipping $kernel kernel"); - next kernel; - } - } else { - warning("$kernel: $!"); - next kernel; - } - logstage("building $kernel kernel"); - logenv(); - cd($srcdir); - make('buildkernel', 'KERNCONF' => $kernel) - or error("failed to build $kernel kernel"); - } - - # Install world and kernel if requested - if ($cmds{'install'}) { - make_dir($destdir) - or error("$destdir: $!"); - cd($srcdir); - make('installworld', 'DESTDIR' => $destdir) - or error("failed to install world"); - foreach my $kernel (sort(keys(%kernels))) { - if (! -f "$srcdir/sys/$machine/conf/$kernel") { - warning("no kernel config for $kernel"); - next; - } - make('installkernel', - 'KERNCONF' => $kernel, - 'KODIR' => "/boot/$kernel", - 'DESTDIR' => $destdir); - } - } - - # Build a release if requested - if ($cmds{'release'}) { - $ENV{'CHROOTDIR'} = "$sandbox/root"; - $ENV{'RELEASETAG'} = $branch - if $branch ne 'HEAD'; - $ENV{'WORLD_FLAGS'} = $ENV{'KERNEL_FLAGS'} = - ($jobs > 1) ? "-j$jobs" : "-B"; - if ($patch) { - $ENV{'LOCAL_PATCHES'} = $patch; - $ENV{'PATCH_FLAGS'} = "-fs"; - } - - # Save time and space - $ENV{'NOCDROM'} = "YES"; - $ENV{'NODOC'} = "YES"; - $ENV{'NOPORTS'} = "YES"; - - logstage("building a release"); - logenv(); - cd("$srcdir/release"); - make('release') - or error("failed to build release"); - } - - # Clean up after us - do_clean('post'); - - # Exiting releases the lock file - logstage("tinderbox run completed"); - exit(0); -} diff --git a/tools/tools/tinderbox/www/Makefile b/tools/tools/tinderbox/www/Makefile deleted file mode 100644 index fcb291ea88a..00000000000 --- a/tools/tools/tinderbox/www/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# $MidnightBSD$ -# $FreeBSD: src/tools/tools/tinderbox/www/Makefile,v 1.6 2004/01/25 19:11:43 des Exp $ - -CGI = index.cgi -DATA = tb.css -WWWDIR ?= ${HOME}/public_html -WWWOWN ?= ${USER} -WWWGRP ?= ${USER} - -all: ${IMAGES} - -realinstall: - ${INSTALL} -m0755 -o${WWWOWN} -g${WWWGRP} ${.CURDIR}/${CGI} ${WWWDIR} -.for _data in ${DATA} - ${INSTALL} -m0644 -o${WWWOWN} -g${WWWGRP} ${.CURDIR}/${_data} ${WWWDIR} -.endfor - -.include diff --git a/tools/tools/tinderbox/www/index.cgi b/tools/tools/tinderbox/www/index.cgi deleted file mode 100644 index 106506c2fd5..00000000000 --- a/tools/tools/tinderbox/www/index.cgi +++ /dev/null @@ -1,223 +0,0 @@ -#!/usr/bin/perl -Tw -#- -# Copyright (c) 2003-2013 Dag-Erling Smørgrav -# 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: user/des/tinderbox/www/index.cgi 256311 2013-10-11 08:53:27Z des $ -# - -use v5.10.1; -use strict; -use POSIX qw(strftime); -use Sys::Hostname; - -my %BRANCHES; -my %ARCHES; - -my $DIR = "."; - -sub success($) { - my ($log) = @_; - - local *FILE; - my $result; - - if (open(FILE, "<", $log)) { - $result = grep { m/tinderbox run completed/ } ; - close(FILE); - } - return $result; -} - -sub branch_rank($) { - my ($branch) = @_; - - my $rank; - - if ($branch =~ m/\b(HEAD|CURRENT)$/i) { - $rank = "9999"; - } elsif ($branch =~ m/\bRELENG_(\d{1,2})$/i) { - $rank = sprintf("%02d99", $1); - } elsif ($branch =~ m/\bRELENG_(\d{1,2})_(\d{1,2})$/i) { - $rank = sprintf("%02d%02d", $1, $2); - } else { - $rank = $branch; - } - return $rank; -} - -sub branch_sort($$) { - my ($a, $b) = @_; - - return branch_rank($a) cmp branch_rank($b); -} - -sub inverse_branch_sort($$) { - my ($a, $b) = @_; - - return branch_rank($b) cmp branch_rank($a); -} - -sub do_branch($) { - my ($branch) = @_; - - my $prettybranch = $branch; - $prettybranch =~ s@^HEAD$@head@; - $prettybranch =~ s@^RELENG_(\d+)_(\d+)$@releng/$1.$2@; - $prettybranch =~ s@^RELENG_(\d+)$@stable/$1@; - - print " -   -"; - foreach my $arch (sort(keys(%ARCHES))) { - foreach my $machine (sort(keys(%{$ARCHES{$arch}}))) { - if ($arch eq $machine) { - print " $arch\n"; - } else { - print " $arch
$machine\n"; - } - } - } - print " \n"; - - my $now = time(); - - foreach my $config (sort(keys(%{$BRANCHES{$branch}}))) { - $config =~ m/^(\w+)((?:-\w+)*?)(-build)?$/; - my $variant = $2 =~ s/^-//r; - print " - $prettybranch" . ($variant ? "
($variant)" : "") . " -"; - foreach my $arch (sort(keys(%ARCHES))) { - foreach my $machine (sort(keys(%{$ARCHES{$arch}}))) { - my $log = "tinderbox-$config-$branch-$arch-$machine"; - if (-f "$DIR/$log.brief") { - print " "; - my @stat = stat(_); - my $class = success("$DIR/$log.brief") ? "ok" : "fail"; - my $age = int(($now - $stat[9]) / 1800); - $age = ($age < 0) ? 0 : ($age > 9) ? 9 : $age; - $class .= "-$age"; - print "" . - strftime("%Y-%m-%d
%H:%M UTC", gmtime($stat[9])) . - "

"; - print "" . - "summary"; - if (-f "$DIR/$log.full") { - print " | full log"; - } - print ""; - print "\n"; - } else { - print " n/a\n"; - } - } - } - print " \n"; - } -} - -MAIN:{ - my $date = strftime("%Y-%m-%d %H:%M:%S UTC", gmtime()); - my $realthing; # is this the authentic tinderbox site - my $greeting; - - $| = 1; - if ($ENV{'GATEWAY_INTERFACE'}) { - print "Content-Type: text/html; charset=utf-8\n\n"; - $realthing = ($ENV{'SERVER_NAME'} eq 'tinderbox.freebsd.org'); - } else { - my $host = hostname(); - $realthing = ($host eq 'dma.des.no'); - } - - if ($realthing) { - $greeting = "tinderbox.freebsd.org"; - } else { - $greeting = "For official Tinderbox logs, see here"; - } - - local *DIR; - opendir(DIR, $DIR) - or die("$DIR: $!\n"); - foreach (readdir(DIR)) { - next unless m/^tinderbox-([\w-]+)-(\w+)-(\w+)-(\w+)\.(brief|full)$/; - $BRANCHES{$2}->{$1} = $ARCHES{$3}->{$4} = 1; - } - closedir(DIR); - - print " - - - - FreeBSD tinderbox logs - - - - - - - - - -"; - - # Count columns - my $columns = 1; - print " \n"; - foreach my $arch (sort(keys(%ARCHES))) { - foreach my $machine (sort(keys(%{$ARCHES{$arch}}))) { - print " \n"; - $columns++; - } - } - - # Generate rows - foreach my $branch (sort(inverse_branch_sort keys(%BRANCHES))) { - do_branch($branch); - } - - print " - - - -
- - - -"; - exit(0); -} diff --git a/tools/tools/tinderbox/www/tb.css b/tools/tools/tinderbox/www/tb.css deleted file mode 100644 index 4d20131ee32..00000000000 --- a/tools/tools/tinderbox/www/tb.css +++ /dev/null @@ -1,96 +0,0 @@ -/* - * $MidnightBSD$ - * $FreeBSD: projects/tinderbox/www/tb.css,v 1.7 2007/05/01 10:13:11 des Exp $ - */ - -body { - font-family: sans-serif; - font-style: normal; - background-color: white; - color: navy; -} - -a:link { - color: blue; -} - -a:visited { - color: gray; -} - -a:active { - color: red; -} - -a:hover { - color: blue; -} - -.tiny { - font-size: x-small; -} - -table { - border-collapse: collapse; - border: none; -} - -tr { - border: none; -} - -td, th { - width: 14ex; - text-align: center; - vertical-align: middle; - padding: 3pt; - margin: 0; - border: none; -} - -th { - background-color: #eeeeff; - margin: 0; -} - -td.result { -} - -td.noresult { -} - -.footer { - background-color: #eeeeff; - font-style: italic; - font-size: small; -} - -.footer-left { - float: left; -} - -.footer-right { - float: right; -} - -.ok-0 { background-color: white; color: #007700; } -.ok-1 { background-color: white; color: #117B11; } -.ok-2 { background-color: white; color: #227F22; } -.ok-3 { background-color: white; color: #338333; } -.ok-4 { background-color: white; color: #448744; } -.ok-5 { background-color: white; color: #558B55; } -.ok-6 { background-color: white; color: #668F66; } -.ok-7 { background-color: white; color: #779377; } -.ok-8 { background-color: white; color: #889788; } -.ok-9 { background-color: white; color: #999B99; } - -.fail-0 { background-color: white; color: #ff0000; } -.fail-1 { background-color: white; color: #ff1111; } -.fail-2 { background-color: white; color: #ff2222; } -.fail-3 { background-color: white; color: #ff3333; } -.fail-4 { background-color: white; color: #ff4444; } -.fail-5 { background-color: white; color: #ff5555; } -.fail-6 { background-color: white; color: #ff6666; } -.fail-7 { background-color: white; color: #ff7777; } -.fail-8 { background-color: white; color: #ff8888; } -.fail-9 { background-color: white; color: #ff9999; } diff --git a/usr.bin/dtc/string.hh b/usr.bin/dtc/string.hh deleted file mode 100644 index 0640d397614..00000000000 --- a/usr.bin/dtc/string.hh +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * Copyright (c) 2013 David Chisnall - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * 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: stable/10/usr.bin/dtc/string.hh 245803 2013-01-22 17:49:51Z theraven $ - */ - -#ifndef _STRING_HH_ -#define _STRING_HH_ -#include "input_buffer.hh" - -namespace dtc -{ - -/** - * String, referring to a place in the input file. We don't bother copying - * strings until we write them to the final output. These strings should be - * two words long: a start and a length. They are intended to be cheap to copy - * and store in collections. Copying the string object does not copy the - * underlying storage. - * - * Strings are not nul-terminated. - */ -class string -{ - /** Start address. Contained within the mmap()'d input file and not - * owned by this object. */ - const char *start; - /** length of the string. DTS strings are allowed to contain nuls */ - int length; - /** Generic function for parsing strings matching the character set - * defined by the template argument. */ - template - static string parse(input_buffer &s); - public: - /** - * Constructs a string referring into another buffer. - */ - string(const char *s, int l) : start(s), length(l) {} - /** Constructs a string from a C string. */ - string(const char *s) : start(s), length(strlen(s)) {} - /** Default constructor, returns an empty string. */ - string() : start(0), length(0) {} - /** Construct a from an input buffer, ending with a nul terminator. */ - string(input_buffer &s); - /** - * Returns the longest string in the input buffer starting at the - * current cursor and composed entirely of characters that are valid in - * node names. - */ - static string parse_node_name(input_buffer &s); - /** - * Returns the longest string in the input buffer starting at the - * current cursor and composed entirely of characters that are valid in - * property names. - */ - static string parse_property_name(input_buffer &s); - /** - * Parses either a node or a property name. If is_property is true on - * entry, then only property names are parsed. If it is false, then it - * will be set, on return, to indicate whether the parsed name is only - * valid as a property. - */ - static string parse_node_or_property_name(input_buffer &s, - bool &is_property); - /** - * Compares two strings for equality. Strings are equal if they refer - * to identical byte sequences. - */ - bool operator==(const string& other) const; - /** - * Compares a string against a C string. The trailing nul in the C - * string is ignored for the purpose of comparison, so this will always - * fail if the string contains nul bytes. - */ - bool operator==(const char *other) const; - /** - * Inequality operator, defined as the inverse of the equality - * operator. - */ - template - inline bool operator!=(T other) - { - return !(*this == other); - } - /** - * Comparison operator, defined to allow strings to be used as keys in - * maps. - */ - bool operator<(const string& other) const; - /** - * Returns true if this is the empty string, false otherwise. - */ - inline bool empty() const - { - return length == 0; - } - /** - * Returns the size of the string, in bytes. - */ - inline size_t size() - { - return length; - } - /** - * Writes the string to the specified buffer. - */ - void push_to_buffer(byte_buffer &buffer, bool escapes=false); - /** - * Prints the string to the specified output stream. - */ - void print(FILE *file); - /** - * Dumps the string to the standard error stream. Intended to be used - * for debugging. - */ - void dump(); -}; - -} // namespace dtc - -#endif // !_STRING_HH_ diff --git a/usr.bin/gprof/PSD.doc/abstract.me b/usr.bin/gprof/PSD.doc/abstract.me deleted file mode 100644 index 28e8066fc33..00000000000 --- a/usr.bin/gprof/PSD.doc/abstract.me +++ /dev/null @@ -1,66 +0,0 @@ -.\" Copyright (c) 1982, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)abstract.me 8.1 (Berkeley) 6/8/93 -.\" -.sp 1 -\fB\s+2gprof: a Call Graph Execution Profiler\s-2\fP\** -.(f -\**This work was supported by grant MCS80-05144 -from the National Science Foundation. -.)f -.sp 1 -by -\fISusan L. Graham\fP -\fIPeter B. Kessler\fP -\fIMarshall K. McKusick\fP -.sp 1 -Computer Science Division -Electrical Engineering and Computer Science Department -University of California, Berkeley -Berkeley, California 94720 -.ce 0 -.sp 1 -.sp 0.5i -.sh 0 "Abstract" -.pp -Large complex programs are composed of many small routines -that implement abstractions for the routines that call them. -To be useful, an execution profiler must attribute -execution time in a way that is significant for the -logical structure of a program -as well as for its textual decomposition. -This data must then be displayed to the user -in a convenient and informative way. -The \fBgprof\fP profiler -accounts for the running time of called routines -in the running time of the routines that call them. -The design and use of this profiler is described. diff --git a/usr.bin/gprof/PSD.doc/gathering.me b/usr.bin/gprof/PSD.doc/gathering.me deleted file mode 100644 index 17130c330e6..00000000000 --- a/usr.bin/gprof/PSD.doc/gathering.me +++ /dev/null @@ -1,231 +0,0 @@ -.\" Copyright (c) 1982, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)gathering.me 8.1 (Berkeley) 6/8/93 -.\" -.sh 1 "Gathering Profile Data" -.pp -Routine calls or statement executions can be measured by having a -compiler augment the code at strategic points. -The additions can be inline increments to counters [Knuth71] -[Satterthwaite72] [Joy79] or calls to -monitoring routines [Unix]. -The counter increment overhead is low, and is suitable for -profiling statements. -A call of the monitoring routine has an overhead comparable with a -call of a regular routine, and is therefore only suited -to profiling on a routine by routine basis. -However, the monitoring routine solution has certain advantages. -Whatever counters are needed by the monitoring routine can be -managed by the monitoring routine itself, rather than being -distributed around the code. -In particular, a monitoring routine can easily be called from separately -compiled programs. -In addition, different monitoring routines can be linked into the -program -being measured -to assemble different profiling data without having to -change the compiler or recompile the program. -We have exploited this approach; -our compilers for C, Fortran77, and Pascal can insert calls to a -monitoring routine in the prologue for each routine. -Use of the monitoring routine requires no planning on part of a -programmer other than to request that augmented routine -prologues be produced during compilation. -.pp -We are interested in gathering three pieces of information during -program execution: call counts and execution times for -each profiled routine, and the arcs of the dynamic call graph -traversed by this execution of the program. -By post-processing of this data we can build the dynamic call -graph for this execution of the program and propagate times along -the edges of this graph to attribute times for routines to the -routines that invoke them. -.pp -Gathering of the profiling information should not greatly -interfere with the running of the program. -Thus, the monitoring routine must not produce trace output each -time it is invoked. -The volume of data thus produced would be unmanageably large, -and the time required to record it would overwhelm the running -time of most programs. -Similarly, the monitoring routine can not do the analysis of -the profiling data (e.g. assembling the call graph, propagating -times around it, discovering cycles, etc.) during program -execution. -Our solution is to gather profiling data in memory during program -execution and to condense it to a file as the profiled -program exits. -This file is then processed by a separate program to produce the -listing of the profile data. -An advantage of this approach is that the profile data for -several executions of a program can be combined by the -post-processing to provide a profile of many -executions. -.pp -The execution time monitoring consists of three parts. -The first part allocates and initializes the runtime monitoring data -structures before the program begins execution. -The second part is the monitoring routine invoked from the -prologue of each profiled routine. -The third part condenses the data structures and writes them -to a file as the program terminates. -The monitoring routine is discussed in detail in the following sections. -.sh 2 "Execution Counts" -.pp -The \fBgprof\fP monitoring routine counts the number of times -each profiled routine is called. -The monitoring routine also records the arc in the call graph -that activated the profiled routine. -The count is associated with the arc in the call graph -rather than with the routine. -Call counts for routines can then be determined by summing the counts -on arcs directed into that routine. -In a machine-dependent fashion, the monitoring routine notes its -own return address. -This address is in the prologue of some profiled routine that is -the destination of an arc in the dynamic call graph. -The monitoring routine also discovers the return address for that -routine, thus identifying the call site, or source of the arc. -The source of the arc is in the \fIcaller\fP, and the destination is in -the \fIcallee\fP. -For example, if a routine A calls a routine B, A is the caller, -and B is the callee. -The prologue of B will include a call to the monitoring routine -that will note the arc from A to B and either initialize or -increment a counter for that arc. -.pp -One can not afford to have the monitoring routine output tracing -information as each arc is identified. -Therefore, the monitoring routine maintains a table of all the -arcs discovered, with counts of the numbers of times each is -traversed during execution. -This table is accessed once per routine call. -Access to it -must be as fast as possible so as not to overwhelm the time -required to execute the program. -.pp -Our solution is to access the table through a hash table. -We use the call site as the primary key with the callee -address being the secondary key. -Since each call site typically calls only one callee, we can -reduce (usually to one) the number of minor lookups based on the callee. -Another alternative would use the callee as the primary key and the -call site as the secondary key. -Such an organization has the advantage of associating callers with -callees, at the expense of longer lookups in the monitoring -routine. -We are fortunate to be running in a virtual memory environment, -and (for the sake of speed) were able to allocate enough space -for the primary hash table to allow a one-to-one mapping from -call site addresses to the primary hash table. -Thus our hash function is trivial to calculate and collisions -occur only for call sites that call multiple -destinations (e.g. functional parameters and functional variables). -A one level hash function using both call site and callee would -result in an unreasonably large hash table. -Further, the number of dynamic call sites and callees is not known during -execution of the profiled program. -.pp -Not all callers and callees can be identified by the monitoring -routine. -Routines that were compiled without the profiling augmentations -will not call the monitoring routine as part of their prologue, -and thus no arcs will be recorded whose destinations are in these -routines. -One need not profile all the routines in a program. -Routines that are not profiled run at full speed. -Certain routines, notably exception handlers, are invoked by -non-standard calling sequences. -Thus the monitoring routine may know the destination of an arc -(the callee), -but find it difficult or -impossible to determine the source of the arc (the caller). -Often in these cases the apparent source of the arc is not a call -site at all. -Such anomalous invocations are declared ``spontaneous''. -.sh 2 "Execution Times" -.pp -The execution times for routines can be gathered in at least two -ways. -One method measures the execution time of a routine by measuring -the elapsed time from routine entry to routine exit. -Unfortunately, time measurement is complicated on time-sharing -systems by the time-slicing of the program. -A second method samples the value of the program counter at some -interval, and infers execution time from the distribution of the -samples within the program. -This technique is particularly suited to time-sharing systems, -where the time-slicing can serve as the basis for sampling -the program counter. -Notice that, whereas the first method could provide exact timings, -the second is inherently a statistical approximation. -.pp -The sampling method need not require support from the operating -system: all that is needed is the ability to set and respond to -``alarm clock'' interrupts that run relative to program time. -It is imperative that the intervals be uniform since the -sampling of the program counter rather than the duration of the -interval is the basis of the distribution. -If sampling is done too often, the interruptions to sample the -program counter will overwhelm the running of the profiled program. -On the other hand, the program must run for enough sampled -intervals that the distribution of the samples accurately -represents the distribution of time for the execution of the -program. -As with routine call tracing, the monitoring routine can not -afford to output information for each program counter -sample. -In our computing environment, the operating system can provide a -histogram of the location of the program counter at the end of -each clock tick (1/60th of a second) in which a program runs. -The histogram is assembled in memory as the program runs. -This facility is enabled by our monitoring routine. -We have adjusted the granularity of the histogram so that -program counter values map one-to-one onto the histogram. -We make the simplifying assumption that all calls to a specific -routine require the same amount of time to execute. -This assumption may disguise that some calls -(or worse, some call sites) always invoke a routine -such that its execution is faster (or slower) -than the average time for that routine. -.pp -When the profiled program terminates, -the arc table and the histogram of -program counter samples is written to a file. -The arc table is condensed to consist of the source and destination -addresses of the arc and the count of the number of times the arc -was traversed by this execution of the program. -The recorded histogram consists of counters of the number of -times the program counter was found to be in each of the ranges covered -by the histogram. -The ranges themselves are summarized as a -lower and upper bound and a step size. diff --git a/usr.bin/gprof/PSD.doc/header.me b/usr.bin/gprof/PSD.doc/header.me deleted file mode 100644 index aef606d1fed..00000000000 --- a/usr.bin/gprof/PSD.doc/header.me +++ /dev/null @@ -1,38 +0,0 @@ -.\" Copyright (c) 1982, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)header.me 8.1 (Berkeley) 8/14/93 -.\" -.\"he 'gprof''Graham, Kessler, McKusick' -.\"fo 'Draft of \*(td''%' -.\"ls 2 -.eh 'PSD:18-%''gprof \*- a Call Graph Execution Profiler' -.oh 'gprof \*- A Call Graph Execution Profiler''PSD:18-%' diff --git a/usr.bin/gprof/PSD.doc/intro.me b/usr.bin/gprof/PSD.doc/intro.me deleted file mode 100644 index 3a872b2e2f0..00000000000 --- a/usr.bin/gprof/PSD.doc/intro.me +++ /dev/null @@ -1,81 +0,0 @@ -.\" Copyright (c) 1982, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)intro.me 8.1 (Berkeley) 6/8/93 -.\" -.sh 1 "Programs to be Profiled" -.pp -Software research environments -normally include many large programs -both for production use and for experimental investigation. -These programs are typically modular, -in accordance with generally accepted principles -of good program design. -Often they consist of numerous small routines -that implement various abstractions. -Sometimes such large programs are written -by one programmer -who has understood the requirements for -these abstractions, and has programmed them -appropriately. -More frequently the program has -had multiple authors and has -evolved over time, changing the demands placed -on the implementation of the abstractions without -changing the implementation itself. -Finally, the program may be assembled from a library -of abstraction implementations -unexamined by the programmer. -.pp -Once a large program is executable, -it is often desirable to increase its speed, -especially if small portions of the program -are found to dominate its execution time. -The purpose of the \fBgprof\fP profiling tool is to -help the user evaluate alternative implementations -of abstractions. -We developed this tool in response to our efforts -to improve a code generator we were writing [Graham82]. -.pp -The \fBgprof\fP design takes advantage of the fact that the programs -to be measured are large, structured and hierarchical. -We provide a profile in which the execution time -for a set of routines that implement an -abstraction is collected and charged -to that abstraction. -The profile can be used to compare and assess the costs of -various implementations. -.pp -The profiler can be linked into a program without -special planning by the programmer. -The overhead for using \fBgprof\fP is low; -both in terms of added execution time and in the -volume of profiling information recorded. diff --git a/usr.bin/gprof/PSD.doc/postp.me b/usr.bin/gprof/PSD.doc/postp.me deleted file mode 100644 index d71fefb3e32..00000000000 --- a/usr.bin/gprof/PSD.doc/postp.me +++ /dev/null @@ -1,190 +0,0 @@ -.\" Copyright (c) 1982, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)postp.me 8.1 (Berkeley) 6/8/93 -.\" -.EQ -delim $$ -gsize 11 -.EN -.sh 1 "Post Processing" -.pp -Having gathered the arcs of the call graph and timing information -for an execution of the program, -we are interested in attributing the time for each routine to the -routines that call it. -We build a dynamic call graph with arcs from caller to callee, -and propagate time from descendants to ancestors -by topologically sorting the call graph. -Time propagation is performed from the leaves of the -call graph toward the roots, according to the order -assigned by a topological numbering algorithm. -The topological numbering ensures that -all edges in the graph go from higher numbered nodes to lower -numbered nodes. -An example is given in Figure 1. -If we propagate time from nodes in the -order assigned by the algorithm, -execution time can be propagated from descendants to ancestors -after a single traversal of each arc in the call graph. -Each parent receives some fraction of a child's time. -Thus time is charged to the -caller in addition to being charged to the callee. -.(z -.so postp1.pic -.ce 2 -Topological ordering -Figure 1. -.ce 0 -.)z -.pp -Let $C sub e$ be the number of calls to some routine, -$e$, and $C sub e sup r$ be the number of -calls from a caller $r$ to a callee $e$. -Since we are assuming each call to a routine takes the -average amount of time for all calls to that routine, -the caller is accountable for -$C sub e sup r / C sub e$ -of the time spent by the callee. -Let the $S sub e$ be the $selftime$ of a routine, $e$. -The selftime of a routine can be determined from the -timing information gathered during profiled program execution. -The total time, $T sub r$, we wish to account to a routine -$r$, is then given by the recurrence equation: -.EQ -T sub r ~ = ~ {S sub r} ~ + ~ - sum from {r ~ roman CALLS ~ e} - {T sub e times {{C sub e sup r} over {C sub e}}} -.EN -where $r ~ roman CALLS ~ e$ is a relation showing all routines -$e$ called by a routine $r$. -This relation is easily available from the call graph. -.pp -However, if the execution contains recursive calls, -the call graph has cycles that -cannot be topologically sorted. -In these cases, we discover strongly-connected -components in the call graph, -treat each such component as a single node, -and then sort the resulting graph. -We use a variation of Tarjan's strongly-connected -components algorithm -that discovers strongly-connected components as it is assigning -topological order numbers [Tarjan72]. -.pp -Time propagation within strongly connected -components is a problem. -For example, a self-recursive routine -(a trivial cycle in the call graph) -is accountable for all the time it -uses in all its recursive instantiations. -In our scheme, this time should be -shared among its call graph parents. -The arcs from a routine to itself are of interest, -but do not participate in time propagation. -Thus the simple equation for time propagation -does not work within strongly connected components. -Time is not propagated from one member of a cycle to another, -since, by definition, this involves propagating time from a routine -to itself. -In addition, children of one member of a cycle -must be considered children of all members of the cycle. -Similarly, parents of one member of the cycle must inherit -all members of the cycle as descendants. -It is for these reasons that we collapse connected components. -Our solution collects all members of a cycle together, -summing the time and call counts for all members. -All calls into the cycle are made to share the total -time of the cycle, and all descendants of the cycle -propagate time into the cycle as a whole. -Calls among the members of the cycle -do not propagate any time, -though they are listed in the call graph profile. -.pp -Figure 2 shows a modified version of the call graph of Figure 1, -in which the nodes labelled 3 and 7 in Figure 1 are mutually -recursive. -The topologically sorted graph after the cycle is collapsed is -given in Figure 3. -.(z -.so postp2.pic -.ce 2 -Cycle to be collapsed. -Figure 2. -.ce 0 -.)z -.(z -.so postp3.pic -.ce 2 -Topological numbering after cycle collapsing. -Figure 3. -.ce 0 -.)z -.pp -Since the technique described above only collects the -dynamic call graph, -and the program typically does not call every routine -on each execution, -different executions can introduce different cycles in the -dynamic call graph. -Since cycles often have a significant effect on time propagation, -it is desirable to incorporate the static call graph so that cycles -will have the same members regardless of how the program runs. -.pp -The static call graph can be constructed from the source text -of the program. -However, discovering the static call graph from the source text -would require two moderately difficult steps: -finding the source text for the program -(which may not be available), -and scanning and parsing that text, -which may be in any one of several languages. -.pp -In our programming system, -the static calling information is also contained in the -executable version of the program, -which we already have available, -and which is in language-independent form. -One can examine the instructions -in the object program, -looking for calls to routines, and note which -routines can be called. -This technique allows us to add arcs to those already in the -dynamic call graph. -If a statically discovered arc already exists in the dynamic call -graph, no action is required. -Statically discovered arcs that do not exist in the dynamic call -graph are added to the graph with a traversal count of zero. -Thus they are never responsible for any time propagation. -However, they may affect the structure of the graph. -Since they may complete strongly connected components, -the static call graph construction is -done before topological ordering. diff --git a/usr.bin/gprof/PSD.doc/postp1.pic b/usr.bin/gprof/PSD.doc/postp1.pic deleted file mode 100644 index 1446092e877..00000000000 --- a/usr.bin/gprof/PSD.doc/postp1.pic +++ /dev/null @@ -1,54 +0,0 @@ -.\" Copyright (c) 1986, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)postp1.pic 8.1 (Berkeley) 6/8/93 -.\" -.PS -circle diam .3i "8" -circle diam .3i "9" at 1st circle + (2i,0i) -circle diam .3i "3" at 1st circle + (0.5i,-0.5i) -circle diam .3i "7" at 2nd circle - (0.5i, 0.5i) -circle diam .3i "2" at 1st circle - (0i,1i) -circle diam .3i "5" at 5th circle + (1i,0i) -circle diam .3i "6" at 2nd circle - (0i,1i) -circle diam .3i "1" at 3rd circle - (0i,1i) -circle diam .3i "4" at 4th circle - (0i,1i) -arrow from 1st circle to 3rd circle chop .15i chop .15i -arrow from 1st circle to 4th circle chop .15i chop .15i -arrow from 2nd circle to 4th circle chop .15i chop .15i -arrow from 3rd circle to 5th circle chop .15i chop .15i -arrow from 4th circle to 5th circle chop .15i chop .15i -arrow from 4th circle to 6th circle chop .15i chop .15i -arrow from 4th circle to 7th circle chop .15i chop .15i -arrow from 5th circle to 8th circle chop .15i chop .15i -arrow from 6th circle to 8th circle chop .15i chop .15i -arrow from 6th circle to 9th circle chop .15i chop .15i -.PE diff --git a/usr.bin/gprof/PSD.doc/postp2.pic b/usr.bin/gprof/PSD.doc/postp2.pic deleted file mode 100644 index 3b31736e91a..00000000000 --- a/usr.bin/gprof/PSD.doc/postp2.pic +++ /dev/null @@ -1,56 +0,0 @@ -.\" Copyright (c) 1986, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)postp2.pic 8.1 (Berkeley) 6/8/93 -.\" -.PS -circle diam .3i "\(ci" -circle diam .3i "\(ci" at 1st circle + (2i,0i) -circle diam .3i "\(bu" at 1st circle + (0.5i,-0.5i) -circle diam .3i "\(bu" at 2nd circle - (0.5i, 0.5i) -circle diam .3i "\(ci" at 1st circle - (0i,1i) -circle diam .3i "\(ci" at 5th circle + (1i,0i) -circle diam .3i "\(ci" at 2nd circle - (0i,1i) -circle diam .3i "\(ci" at 3rd circle - (0i,1i) -circle diam .3i "\(ci" at 4th circle - (0i,1i) -arrow from 1st circle to 3rd circle chop .15i chop .15i -arrow from 1st circle to 4th circle chop .15i chop .15i -arrow from 2nd circle to 4th circle chop .15i chop .15i -spline -> from 3rd circle right .5i up .075i then right .5i down .075i chop .15i chop .15i -spline -> from 4th circle left .5i down .075i then left .5i up .075i chop .15i chop .15i -arrow from 3rd circle to 5th circle chop .15i chop .15i -arrow from 4th circle to 5th circle chop .15i chop .15i -arrow from 4th circle to 6th circle chop .15i chop .15i -arrow from 4th circle to 7th circle chop .15i chop .15i -arrow from 5th circle to 8th circle chop .15i chop .15i -arrow from 6th circle to 8th circle chop .15i chop .15i -arrow from 6th circle to 9th circle chop .15i chop .15i -.PE diff --git a/usr.bin/gprof/PSD.doc/postp3.pic b/usr.bin/gprof/PSD.doc/postp3.pic deleted file mode 100644 index 65eb2a78f51..00000000000 --- a/usr.bin/gprof/PSD.doc/postp3.pic +++ /dev/null @@ -1,51 +0,0 @@ -.\" Copyright (c) 1986, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)postp3.pic 8.1 (Berkeley) 6/8/93 -.\" -.PS -circle diam .3i "7" -circle diam .3i "8" at 1st circle + (2i,0i) -EL: ellipse wid 1i ht .3i "\fB6\fR\h'.7i'\fB6\fR" at 1st circle + (1i,-0.5i) -circle diam .3i "2" at 1st circle - (0i,1i) -circle diam .3i "4" at 3th circle + (1i,0i) -circle diam .3i "5" at 2nd circle - (0i,1i) -circle diam .3i "1" at 3rd circle + (0.5i,-0.5i) -circle diam .3i "3" at 5th circle - (0.5i,0.5i) -arrow from 1st circle to EL.nw chop .15i chop 0i -arrow from 2nd circle to EL.ne chop .15i chop 0i -arrow from EL.sw to 3rd circle chop 0i chop .15i -arrow from EL.s to 4th circle chop 0i chop .15i -arrow from EL.se to 5th circle chop 0i chop .15i -arrow from 3rd circle to 6th circle chop .15i chop .15i -arrow from 4th circle to 6th circle chop .15i chop .15i -arrow from 4th circle to 7th circle chop .15i chop .15i -.PE diff --git a/usr.bin/gprof/PSD.doc/pres1.pic b/usr.bin/gprof/PSD.doc/pres1.pic deleted file mode 100644 index 0c311a19e0e..00000000000 --- a/usr.bin/gprof/PSD.doc/pres1.pic +++ /dev/null @@ -1,56 +0,0 @@ -.\" Copyright (c) 1986, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)pres1.pic 8.1 (Berkeley) 6/8/93 -.\" -.PS -ellipse ht .3i wid .75i "\s-1CALLER1\s+1" -ellipse ht .3i wid .75i "\s-1CALLER2\s+1" at 1st ellipse + (2i,0i) -ellipse ht .3i wid .8i "\s-1EXAMPLE\s+1" at 1st ellipse + (1i,-.5i) -ellipse ht .3i wid .5i "\s-1SUB1\s+1" at 1st ellipse - (0i,1i) -ellipse ht .3i wid .5i "\s-1SUB2\s+1" at 3rd ellipse - (0i,.5i) -ellipse ht .3i wid .5i "\s-1SUB3\s+1" at 2nd ellipse - (0i,1i) -line <- from 1st ellipse up .5i left .5i chop .1875i -line <- from 1st ellipse up .5i right .5i chop .1875i -line <- from 2nd ellipse up .5i left .5i chop .1875i -line <- from 2nd ellipse up .5i right .5i chop .1875i -arrow from 1st ellipse to 3rd ellipse chop -arrow from 2nd ellipse to 3rd ellipse chop -arrow from 3rd ellipse to 4th ellipse chop -arrow from 3rd ellipse to 5th ellipse chop .15i chop .15i -arrow from 3rd ellipse to 6th ellipse chop -arrow from 4th ellipse down .5i left .5i chop .1875i -arrow from 4th ellipse down .5i right .5i chop .1875i -arrow from 5th ellipse down .5i left .5i chop .1875i -arrow from 5th ellipse down .5i right .5i chop .1875i -arrow from 6th ellipse down .5i left .5i chop .1875i -arrow from 6th ellipse down .5i right .5i chop .1875i -.PE diff --git a/usr.bin/gprof/PSD.doc/pres2.pic b/usr.bin/gprof/PSD.doc/pres2.pic deleted file mode 100644 index c3a4ea06959..00000000000 --- a/usr.bin/gprof/PSD.doc/pres2.pic +++ /dev/null @@ -1,52 +0,0 @@ -.\" Copyright (c) 1986, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)pres2.pic 8.1 (Berkeley) 6/8/93 -.\" -.PS -ellipse ht .3i wid .6i "\s-1CALC1\s+1" -ellipse ht .3i wid .6i "\s-1CALC2\s+1" at 1st ellipse + (.75i,0i) -ellipse ht .3i wid .6i "\s-1CALC3\s+1" at 1st ellipse + (1.5i,0i) -ellipse ht .3i wid .8i "\s-1FORMAT1\s+1" at 1st ellipse - (0i,.5i) -ellipse ht .3i wid .8i "\s-1FORMAT2\s+1" at 3rd ellipse - (0i,.5i) -ellipse ht .3i wid .75i "\s-1\"WRITE\"\s+1" at 5th ellipse - (.75i,.5i) -line <- from 1st ellipse up .5i left .4i chop .1825i -line <- from 1st ellipse up .5i right .4i chop .1825i -line <- from 2nd ellipse up .5i left .4i chop .1825i -line <- from 2nd ellipse up .5i right .4i chop .1825i -line <- from 3rd ellipse up .5i left .4i chop .1825i -line <- from 3rd ellipse up .5i right .4i chop .1825i -arrow from 1st ellipse to 4th ellipse chop .15i -arrow from 2nd ellipse to 5th ellipse chop -arrow from 3rd ellipse to 5th ellipse chop .15i -arrow from 4th ellipse to 6th ellipse chop -arrow from 5th ellipse to 6th ellipse chop -.PE diff --git a/usr.bin/gprof/PSD.doc/present.me b/usr.bin/gprof/PSD.doc/present.me deleted file mode 100644 index 1dd7f62ad81..00000000000 --- a/usr.bin/gprof/PSD.doc/present.me +++ /dev/null @@ -1,306 +0,0 @@ -.\" Copyright (c) 1982, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)present.me 8.1 (Berkeley) 6/8/93 -.\" -.sh 1 "Data Presentation" -.pp -The data is presented to the user in two different formats. -The first presentation simply lists the routines -without regard to the amount of time their descendants use. -The second presentation incorporates the call graph of the -program. -.sh 2 "The Flat Profile -.pp -The flat profile consists of a list of all the routines -that are called during execution of the program, -with the count of the number of times they are called -and the number of seconds of execution time for which they -are themselves accountable. -The routines are listed in decreasing order of execution time. -A list of the routines that are never called during execution of -the program is also available -to verify that nothing important is omitted by -this execution. -The flat profile gives a quick overview of the routines that are used, -and shows the routines that are themselves responsible -for large fractions of the execution time. -In practice, -this profile usually shows that no single function -is overwhelmingly responsible for -the total time of the program. -Notice that for this profile, -the individual times sum to the total execution time. -.sh 2 "The Call Graph Profile" -.sz 10 -.(z -.TS -box center; -c c c c c l l -c c c c c l l -c c c c c l l -l n n n c l l. - called/total \ \ parents -index %time self descendants called+self name index - called/total \ \ children -_ - 0.20 1.20 4/10 \ \ \s-1CALLER1\s+1 [7] - 0.30 1.80 6/10 \ \ \s-1CALLER2\s+1 [1] -[2] 41.5 0.50 3.00 10+4 \s-1EXAMPLE\s+1 [2] - 1.50 1.00 20/40 \ \ \s-1SUB1\s+1 [4] - 0.00 0.50 1/5 \ \ \s-1SUB2\s+1 [9] - 0.00 0.00 0/5 \ \ \s-1SUB3\s+1 [11] -.TE -.ce 2 -Profile entry for \s-1EXAMPLE\s+1. -Figure 4. -.)z -.pp -Ideally, we would like to print the call graph of the program, -but we are limited by the two-dimensional nature of our output -devices. -We cannot assume that a call graph is planar, -and even if it is, that we can print a planar version of it. -Instead, we choose to list each routine, -together with information about -the routines that are its direct parents and children. -This listing presents a window into the call graph. -Based on our experience, -both parent information and child information -is important, -and should be available without searching -through the output. -.pp -The major entries of the call graph profile are the entries from the -flat profile, augmented by the time propagated to each -routine from its descendants. -This profile is sorted by the sum of the time for the routine -itself plus the time inherited from its descendants. -The profile shows which of the higher level routines -spend large portions of the total execution time -in the routines that they call. -For each routine, we show the amount of time passed by each child -to the routine, which includes time for the child itself -and for the descendants of the child -(and thus the descendants of the routine). -We also show the percentage these times represent of the total time -accounted to the child. -Similarly, the parents of each routine are listed, -along with time, -and percentage of total routine time, -propagated to each one. -.pp -Cycles are handled as single entities. -The cycle as a whole is shown as though it were a single routine, -except that members of the cycle are listed in place of the children. -Although the number of calls of each member -from within the cycle are shown, -they do not affect time propagation. -When a child is a member of a cycle, -the time shown is the appropriate fraction of the time -for the whole cycle. -Self-recursive routines have their calls broken -down into calls from the outside and self-recursive calls. -Only the outside calls affect the propagation of time. -.pp -The following example is a typical fragment of a call graph. -.(b -.so pres1.pic -.)b -The entry in the call graph profile listing for this example is -shown in Figure 4. -.pp -The entry is for routine \s-1EXAMPLE\s+1, which has -the Caller routines as its parents, -and the Sub routines as its children. -The reader should keep in mind that all information -is given \fIwith respect to \s-1EXAMPLE\s+1\fP. -The index in the first column shows that \s-1EXAMPLE\s+1 -is the second entry in the profile listing. -The \s-1EXAMPLE\s+1 routine is called ten times, four times by \s-1CALLER1\s+1, -and six times by \s-1CALLER2\s+1. -Consequently 40% of \s-1EXAMPLE\s+1's time is propagated to \s-1CALLER1\s+1, -and 60% of \s-1EXAMPLE\s+1's time is propagated to \s-1CALLER2\s+1. -The self and descendant fields of the parents -show the amount of self and descendant time \s-1EXAMPLE\s+1 -propagates to them (but not the time used by -the parents directly). -Note that \s-1EXAMPLE\s+1 calls itself recursively four times. -The routine \s-1EXAMPLE\s+1 calls routine \s-1SUB1\s+1 twenty times, \s-1SUB2\s+1 once, -and never calls \s-1SUB3\s+1. -Since \s-1SUB2\s+1 is called a total of five times, -20% of its self and descendant time is propagated to \s-1EXAMPLE\s+1's -descendant time field. -Because \s-1SUB1\s+1 is a member of \fIcycle 1\fR, -the self and descendant times -and call count fraction -are those for the cycle as a whole. -Since cycle 1 is called a total of forty times -(not counting calls among members of the cycle), -it propagates 50% of the cycle's self and descendant -time to \s-1EXAMPLE\s+1's descendant time field. -Finally each name is followed by an index that shows -where on the listing to find the entry for that routine. -.sh 1 "Using the Profiles" -.pp -The profiler is a useful tool for improving -a set of routines that implement an abstraction. -It can be helpful in identifying poorly coded routines, -and in evaluating the new algorithms and code that replace them. -Taking full advantage of the profiler -requires a careful examination of the call graph profile, -and a thorough knowledge of the abstractions underlying -the program. -.pp -The easiest optimization that can be performed -is a small change -to a control construct or data structure that improves the -running time of the program. -An obvious starting point -is a routine that is called many times. -For example, suppose an output -routine is the only parent -of a routine that formats the data. -If this format routine is expanded inline in the -output routine, the overhead of a function call and -return can be saved for each datum that needs to be formatted. -.pp -The drawback to inline expansion is that the data abstractions -in the program may become less parameterized, -hence less clearly defined. -The profiling will also become less useful since the loss of -routines will make its output more granular. -For example, -if the symbol table functions ``lookup'', ``insert'', and ``delete'' -are all merged into a single parameterized routine, -it will be impossible to determine the costs -of any one of these individual functions from the profile. -.pp -Further potential for optimization lies in routines that -implement data abstractions whose total execution -time is long. -For example, a lookup routine might be called only a few -times, but use an inefficient linear search algorithm, -that might be replaced with a binary search. -Alternately, the discovery that a rehashing function is being -called excessively, can lead to a different -hash function or a larger hash table. -If the data abstraction function cannot easily be speeded up, -it may be advantageous to cache its results, -and eliminate the need to rerun -it for identical inputs. -These and other ideas for program improvement are discussed in -[Bentley81]. -.pp -This tool is best used in an iterative approach: -profiling the program, -eliminating one bottleneck, -then finding some other part of the program -that begins to dominate execution time. -For instance, we have used \fBgprof\fR on itself; -eliminating, rewriting, and inline expanding routines, -until reading -data files (hardly a target for optimization!) -represents the dominating factor in its execution time. -.pp -Certain types of programs are not easily analyzed by \fBgprof\fR. -They are typified by programs that exhibit a large degree of -recursion, such as recursive descent compilers. -The problem is that most of the major routines are grouped -into a single monolithic cycle. -As in the symbol table abstraction that is placed -in one routine, -it is impossible to distinguish which members of the cycle are -responsible for the execution time. -Unfortunately there are no easy modifications to these programs that -make them amenable to analysis. -.pp -A completely different use of the profiler is to analyze the control -flow of an unfamiliar program. -If you receive a program from another user that you need to modify -in some small way, -it is often unclear where the changes need to be made. -By running the program on an example and then using \fBgprof\fR, -you can get a view of the structure of the program. -.pp -Consider an example in which you need to change the output format -of the program. -For purposes of this example suppose that the call graph -of the output portion of the program has the following structure: -.(b -.so pres2.pic -.)b -Initially you look through the \fBgprof\fR -output for the system call ``\s-1WRITE\s+1''. -The format routine you will need to change is probably -among the parents of the ``\s-1WRITE\s+1'' procedure. -The next step is to look at the profile entry for each -of parents of ``\s-1WRITE\s+1'', -in this example either ``\s-1FORMAT1\s+1'' or ``\s-1FORMAT2\s+1'', -to determine which one to change. -Each format routine will have one or more parents, -in this example ``\s-1CALC1\s+1'', ``\s-1CALC2\s+1'', and ``\s-1CALC3\s+1''. -By inspecting the source code for each of these routines -you can determine which format routine generates the output that -you wish to modify. -Since the \fBgprof\fR entry shows all the -potential calls to the format routine you intend to change, -you can determine if your modifications will affect output that -should be left alone. -If you desire to change the output of ``\s-1CALC2\s+1'', but not ``\s-1CALC3\s+1'', -then formatting routine ``\s-1FORMAT2\s+1'' needs to be split -into two separate routines, -one of which implements the new format. -You can then retarget just the call by ``\s-1CALC2\s+1'' -that needs the new format. -It should be noted that the static call information is particularly -useful here since the test case you run probably will not -exercise the entire program. -.sh 1 "Conclusions" -.pp -We have created a profiler that aids in the evaluation -of modular programs. -For each routine in the program, -the profile shows the extent to which that routine -helps support various abstractions, -and how that routine uses other abstractions. -The profile accurately assesses the cost of routines -at all levels of the program decomposition. -The profiler is easily used, -and can be compiled into the program without any prior planning by -the programmer. -It adds only five to thirty percent execution overhead to the program -being profiled, -produces no additional output until after the program finishes, -and allows the program to be measured in its actual environment. -Finally, the profiler runs on a time-sharing system -using only the normal services provided by the operating system -and compilers. diff --git a/usr.bin/gprof/PSD.doc/profiling.me b/usr.bin/gprof/PSD.doc/profiling.me deleted file mode 100644 index 227aedf5cf7..00000000000 --- a/usr.bin/gprof/PSD.doc/profiling.me +++ /dev/null @@ -1,115 +0,0 @@ -.\" Copyright (c) 1982, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)profiling.me 8.1 (Berkeley) 6/8/93 -.\" -.sh 1 "Types of Profiling" -.pp -There are several different uses for program profiles, -and each may require different information from the profiles, -or different presentation of the information. -We distinguish two broad categories of profiles: -those that present counts of statement or routine invocations, -and those that display timing information about statements -or routines. -Counts are typically presented in tabular form, -often in parallel with a listing of the source code. -Timing information could be similarly presented; -but more than one measure of time might be associated with each -statement or routine. -For example, -in the framework used by \fBgprof\fP -each profiled segment would display two times: -one for the time used by the segment itself, and another for the -time inherited from code segments it invokes. -.pp -Execution counts are used in many different contexts. -The exact number of times a routine or statement is activated -can be used to determine if an algorithm is performing as -expected. -Cursory inspection of such counters may show algorithms whose -complexity is unsuited to the task at hand. -Careful interpretation of counters can often suggest -improvements to acceptable algorithms. -Precise examination can uncover subtle errors in an -algorithm. -At this level, profiling counters are similar to -debugging statements whose purpose is to show the number of times -a piece of code is executed. -Another view of such counters is as boolean values. -One may be interested that a portion of code has executed at -all, for exhaustive testing, or to check that one implementation -of an abstraction completely replaces a previous one. -.pp -Execution counts are not necessarily proportional to the amount -of time required to execute the routine or statement. -Further, the execution time of a routine will not be the same for -all calls on the routine. -The criteria for establishing execution time -must be decided. -If a routine implements an abstraction by invoking other abstractions, -the time spent in the routine will not accurately reflect the -time required by the abstraction it implements. -Similarly, if an abstraction is implemented by several -routines the time required by the abstraction will be distributed -across those routines. -.pp -Given the execution time of individual routines, -\fBgprof\fP accounts to each routine the time spent -for it by the routines it invokes. -This accounting is done by assembling a \fIcall graph\fP with nodes that -are the routines of the program and directed arcs that represent -calls from call sites to routines. -We distinguish among three different call graphs for a program. -The \fIcomplete call graph\fP incorporates all routines and all -potential arcs, -including arcs that represent calls to functional parameters -or functional variables. -This graph contains the other two graphs as subgraphs. -The \fIstatic call graph\fP includes all routines and all possible arcs -that are not calls to functional parameters or variables. -The \fIdynamic call graph\fP includes only those routines and -arcs traversed by the profiled execution of the program. -This graph need not include all routines, nor need it include all -potential arcs between the routines it covers. -It may, however, include arcs to functional parameters or -variables that the static call graph may omit. -The static call graph can be determined from the (static) program text. -The dynamic call graph is determined only by profiling an -execution of the program. -The complete call graph for a monolithic program could be determined -by data flow analysis techniques. -The complete call graph for programs that change -during execution, by modifying themselves or dynamically loading -or overlaying code, may never be determinable. -Both the static call graph and the dynamic call graph are used -by \fBgprof\fP, but it does not search for the complete call -graph. diff --git a/usr.bin/gprof/PSD.doc/refs.me b/usr.bin/gprof/PSD.doc/refs.me deleted file mode 100644 index 580d08030f5..00000000000 --- a/usr.bin/gprof/PSD.doc/refs.me +++ /dev/null @@ -1,63 +0,0 @@ -.\" Copyright (c) 1982, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)refs.me 8.1 (Berkeley) 6/8/93 -.\" -.sh 1 "References" -.ls 1 -.ip [Bentley81] -Bentley, J. L., -``Writing Efficient Code'', -Department of Computer Science, -Carnegie-Mellon University, -Pittsburgh, Pennsylvania, -CMU-CS-81-116, 1981. -.ip [Graham82] -Graham, S. L., Henry, R. R., Schulman, R. A., -``An Experiment in Table Driven Code Generation'', -SIGPLAN '82 Symposium on Compiler Construction, -June, 1982. -.ip [Joy79] -Joy, W. N., Graham, S. L., Haley, C. B. ``Berkeley Pascal User's Manual'', -Version 1.1, Computer Science Division -University of California, Berkeley, CA. April 1979. -.ip [Knuth71] -Knuth, D. E. ``An empirical study of FORTRAN programs'', -Software - Practice and Experience, 1, 105-133. 1971 -.ip [Satterthwaite72] -Satterthwaite, E. ``Debugging Tools for High Level Languages'', -Software - Practice and Experience, 2, 197-217, 1972 -.ip [Tarjan72] -Tarjan, R. E., ``Depth first search and linear graph algorithm,'' -\fISIAM J. Computing\fP \fB1\fP:2, 146-160, 1972. -.ip [Unix] -Unix Programmer's Manual, ``\fBprof\fR command'', section 1, -Bell Laboratories, Murray Hill, NJ. January 1979. diff --git a/usr.bin/gprof/amd64.h b/usr.bin/gprof/amd64.h deleted file mode 100644 index 91283580a26..00000000000 --- a/usr.bin/gprof/amd64.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1991, 1993 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)i386.h 8.1 (Berkeley) 6/6/93 - */ - - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_OF_CODE 0 - -enum opermodes { dummy }; -typedef enum opermodes operandenum; diff --git a/usr.bin/gprof/aout.c b/usr.bin/gprof/aout.c deleted file mode 100644 index 2219c05b1f4..00000000000 --- a/usr.bin/gprof/aout.c +++ /dev/null @@ -1,230 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1983, 1993 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#if 0 -/* From: */ -#ifndef lint -static char sccsid[] = "@(#)gprof.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ -#endif - -#include - -#include - -#include -#include -#include - -#include "gprof.h" - -static void getstrtab(FILE *, const char *); -static void getsymtab(FILE *, const char *); -static void gettextspace(FILE *); -static bool funcsymbol(struct nlist *); - -static char *strtab; /* string table in core */ -static long ssiz; /* size of the string table */ -static struct exec xbuf; /* exec header of a.out */ - -/* Things which get -E excluded by default. */ -static char *excludes[] = { "mcount", "__mcleanup", NULL }; - - /* - * Set up string and symbol tables from a.out. - * and optionally the text space. - * On return symbol table is sorted by value. - * - * Returns 0 on success, -1 on failure. - */ -int -aout_getnfile(const char *filename, char ***defaultEs) -{ - FILE *nfile; - - nfile = fopen( filename ,"r"); - if (nfile == NULL) - err( 1 , "%s", filename ); - fread(&xbuf, 1, sizeof(xbuf), nfile); - if (N_BADMAG(xbuf)) { - fclose(nfile); - return -1; - } - getstrtab(nfile, filename); - getsymtab(nfile, filename); - gettextspace( nfile ); - fclose(nfile); -# ifdef DEBUG - if ( debug & AOUTDEBUG ) { - register int j; - - for (j = 0; j < nname; j++){ - printf("[getnfile] 0X%08lx\t%s\n", nl[j].value, nl[j].name); - } - } -# endif /* DEBUG */ - *defaultEs = excludes; - return 0; -} - -static void -getstrtab(FILE *nfile, const char *filename) -{ - - fseek(nfile, (long)(N_SYMOFF(xbuf) + xbuf.a_syms), 0); - if (fread(&ssiz, sizeof (ssiz), 1, nfile) == 0) - errx( 1 , "%s: no string table (old format?)" , filename ); - strtab = calloc(ssiz, 1); - if (strtab == NULL) - errx( 1 , "%s: no room for %ld bytes of string table", filename , ssiz); - if (fread(strtab+sizeof(ssiz), ssiz-sizeof(ssiz), 1, nfile) != 1) - errx( 1 , "%s: error reading string table" , filename ); -} - - /* - * Read in symbol table - */ -static void -getsymtab(FILE *nfile, const char *filename) -{ - register long i; - int askfor; - struct nlist nbuf; - - /* pass1 - count symbols */ - fseek(nfile, (long)N_SYMOFF(xbuf), 0); - nname = 0; - for (i = xbuf.a_syms; i > 0; i -= sizeof(struct nlist)) { - fread(&nbuf, sizeof(nbuf), 1, nfile); - if ( ! funcsymbol( &nbuf ) ) { - continue; - } - nname++; - } - if (nname == 0) - errx( 1 , "%s: no symbols" , filename ); - askfor = nname + 1; - nl = (nltype *) calloc( askfor , sizeof(nltype) ); - if (nl == NULL) - errx( 1 , "no room for %zu bytes of symbol table" , - askfor * sizeof(nltype) ); - - /* pass2 - read symbols */ - fseek(nfile, (long)N_SYMOFF(xbuf), 0); - npe = nl; - nname = 0; - for (i = xbuf.a_syms; i > 0; i -= sizeof(struct nlist)) { - fread(&nbuf, sizeof(nbuf), 1, nfile); - if ( ! funcsymbol( &nbuf ) ) { -# ifdef DEBUG - if ( debug & AOUTDEBUG ) { - printf( "[getsymtab] rejecting: 0x%x %s\n" , - nbuf.n_type , strtab + nbuf.n_un.n_strx ); - } -# endif /* DEBUG */ - continue; - } - npe->value = nbuf.n_value; - npe->name = strtab+nbuf.n_un.n_strx; -# ifdef DEBUG - if ( debug & AOUTDEBUG ) { - printf( "[getsymtab] %d %s 0x%08lx\n" , - nname , npe -> name , npe -> value ); - } -# endif /* DEBUG */ - npe++; - nname++; - } - npe->value = -1; -} - - /* - * read in the text space of an a.out file - */ -static void -gettextspace(FILE *nfile) -{ - - textspace = (u_char *) malloc( xbuf.a_text ); - if ( textspace == NULL ) { - warnx("no room for %u bytes of text space: can't do -c" , - xbuf.a_text ); - return; - } - (void) fseek( nfile , N_TXTOFF( xbuf ) , 0 ); - if ( fread( textspace , 1 , xbuf.a_text , nfile ) != xbuf.a_text ) { - warnx("couldn't read text space: can't do -c"); - free( textspace ); - textspace = 0; - return; - } -} - -static bool -funcsymbol(struct nlist *nlistp) -{ - char *name, c; - - /* - * must be a text symbol, - * and static text symbols don't qualify if aflag set. - */ - if ( ! ( ( nlistp -> n_type == ( N_TEXT | N_EXT ) ) - || ( ( nlistp -> n_type == N_TEXT ) && ( aflag == 0 ) ) ) ) { - return FALSE; - } - /* - * name must start with an underscore if uflag is set. - * can't have any `funny' characters in name, - * where `funny' means `.' (.o file names) - * need to make an exception for sparc .mul & co. - * perhaps we should just drop this code entirely... - */ - name = strtab + nlistp -> n_un.n_strx; - if ( uflag && *name != '_' ) - return FALSE; -#ifdef sparc - if ( *name == '.' ) { - char *p = name + 1; - if ( *p == 'u' ) - p++; - if ( strcmp ( p, "mul" ) == 0 || strcmp ( p, "div" ) == 0 || - strcmp ( p, "rem" ) == 0 ) - return TRUE; - } -#endif - while ( (c = *name++) ) { - if ( c == '.' ) { - return FALSE; - } - } - return TRUE; -} diff --git a/usr.bin/gprof/arm.h b/usr.bin/gprof/arm.h deleted file mode 100644 index 91283580a26..00000000000 --- a/usr.bin/gprof/arm.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1991, 1993 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)i386.h 8.1 (Berkeley) 6/6/93 - */ - - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_OF_CODE 0 - -enum opermodes { dummy }; -typedef enum opermodes operandenum; diff --git a/usr.bin/gprof/i386.h b/usr.bin/gprof/i386.h deleted file mode 100644 index 91283580a26..00000000000 --- a/usr.bin/gprof/i386.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1991, 1993 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)i386.h 8.1 (Berkeley) 6/6/93 - */ - - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_OF_CODE 0 - -enum opermodes { dummy }; -typedef enum opermodes operandenum; diff --git a/usr.bin/gprof/ia64.h b/usr.bin/gprof/ia64.h deleted file mode 100644 index 3f87c8d741d..00000000000 --- a/usr.bin/gprof/ia64.h +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)i386.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: stable/10/usr.bin/gprof/ia64.h 216370 2010-12-11 08:32:16Z joel $ - */ - - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_OF_CODE 0 - -enum opermodes { dummy }; -typedef enum opermodes operandenum; diff --git a/usr.bin/gprof/mips.h b/usr.bin/gprof/mips.h deleted file mode 100644 index d969a4520cc..00000000000 --- a/usr.bin/gprof/mips.h +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. Modified by Ralph Campbell for mips. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)mips.h 8.1 (Berkeley) 6/6/93 - * From: @(#)sparc.h 5.1 (Berkeley) 7/8/92 - */ - -/* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_OF_CODE 0 -#define UNITS_TO_CODE (OFFSET_OF_CODE / sizeof(UNIT)) - -enum opermodes { dummy }; -typedef enum opermodes operandenum; diff --git a/usr.bin/gprof/powerpc.h b/usr.bin/gprof/powerpc.h deleted file mode 100644 index 91283580a26..00000000000 --- a/usr.bin/gprof/powerpc.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1991, 1993 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)i386.h 8.1 (Berkeley) 6/6/93 - */ - - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_OF_CODE 0 - -enum opermodes { dummy }; -typedef enum opermodes operandenum; diff --git a/usr.bin/gprof/sparc64.h b/usr.bin/gprof/sparc64.h deleted file mode 100644 index 91283580a26..00000000000 --- a/usr.bin/gprof/sparc64.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1991, 1993 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)i386.h 8.1 (Berkeley) 6/6/93 - */ - - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_OF_CODE 0 - -enum opermodes { dummy }; -typedef enum opermodes operandenum; diff --git a/usr.bin/indent/tests/nsac.0 b/usr.bin/indent/tests/nsac.0 deleted file mode 100644 index 6c26a770a23..00000000000 --- a/usr.bin/indent/tests/nsac.0 +++ /dev/null @@ -1,4 +0,0 @@ -/* $FreeBSD: stable/11/usr.bin/indent/tests/nsac.0 313544 2017-02-10 09:31:39Z pstef $ */ -void t(void) { - int a = (double) 8; -} diff --git a/usr.bin/indent/tests/nsac.0.pro b/usr.bin/indent/tests/nsac.0.pro deleted file mode 100644 index 7369bc83b9e..00000000000 --- a/usr.bin/indent/tests/nsac.0.pro +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD: stable/11/usr.bin/indent/tests/nsac.0.pro 331147 2018-03-18 22:19:52Z eadler $ */ --nsac diff --git a/usr.bin/indent/tests/nsac.0.stdout b/usr.bin/indent/tests/nsac.0.stdout deleted file mode 100644 index d342b158315..00000000000 --- a/usr.bin/indent/tests/nsac.0.stdout +++ /dev/null @@ -1,6 +0,0 @@ -/* $FreeBSD: stable/11/usr.bin/indent/tests/nsac.0.stdout 313544 2017-02-10 09:31:39Z pstef $ */ -void -t(void) -{ - int a = (double)8; -} diff --git a/usr.bin/kdump/linux32_syscalls.conf b/usr.bin/kdump/linux32_syscalls.conf deleted file mode 100644 index a0000ee5a82..00000000000 --- a/usr.bin/kdump/linux32_syscalls.conf +++ /dev/null @@ -1,10 +0,0 @@ -sysnames="linux32_syscalls.c" -sysproto="/dev/null" -sysproto_h=_LINUX32_SYSPROTO_H_ -syshdr="/dev/null" -syssw="/dev/null" -sysmk="/dev/null" -syscallprefix="LINUX32_SYS_" -switchname="/dev/null" -namesname="linux32_syscallnames" -systrace="/dev/null" diff --git a/usr.bin/kdump/linux_syscalls.conf b/usr.bin/kdump/linux_syscalls.conf deleted file mode 100644 index d9690e1fe7e..00000000000 --- a/usr.bin/kdump/linux_syscalls.conf +++ /dev/null @@ -1,10 +0,0 @@ -sysnames="linux_syscalls.c" -sysproto="/dev/null" -sysproto_h=_LINUX_SYSPROTO_H_ -syshdr="/dev/null" -syssw="/dev/null" -sysmk="/dev/null" -syscallprefix="LINUX_SYS_" -switchname="/dev/null" -namesname="linux_syscallnames" -systrace="/dev/null" diff --git a/usr.bin/kdump/mkioctls b/usr.bin/kdump/mkioctls deleted file mode 100644 index 9da906dadfc..00000000000 --- a/usr.bin/kdump/mkioctls +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/sh -# -# $FreeBSD: stable/10/usr.bin/kdump/mkioctls 327847 2018-01-11 21:31:10Z bdrewery $ -# -# When editing this script, keep in mind that truss also uses it. -# - -set -e - -if [ $# -ne 2 -o \( $1 != "print" -a $1 != "return" \) ]; then - echo "usage: sh $0 print|return include-dir" - exit 1 -fi - -style="$1" -includedir="$2" - -LC_ALL=C; export LC_ALL - -# Build a list of headers that have ioctls in them. -# XXX should we use an ANSI cpp? -ioctl_includes=$( - cd $includedir - find -H -s * -name '*.h' | \ - egrep -v '(.*disk.*|net/pfvar|net/if_pfsync)\.h' | \ - xargs egrep -l \ -'^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO[^a-z0-9_]' | - awk '{printf("#include <%s>\\n", $1)}' -) - -: ${MACHINE=$(uname -m)} -case "${MACHINE}" in -*pc98*) - ioctl_includes="$ioctl_includes#include \\n" - ;; -*) - ioctl_includes="$ioctl_includes#include \\n" - ;; -esac - -awk -v x="$ioctl_includes" 'BEGIN {print x}' | - $CPP -nostdinc -I$includedir -dM -DCOMPAT_43TTY - | - awk -v ioctl_includes="$ioctl_includes" -v style="$style" ' -BEGIN { - print "/* XXX obnoxious prerequisites. */" - print "#define COMPAT_43" - print "#define COMPAT_43TTY" - print "#include " - print "#include " - print "#include " - print "#include " - print "#include " - print "#include " - print "#include " - print "#include " - print "#include " - print "#include " - print "#ifdef PF" - print "#include " - print "#include " - print "#endif" - print "#include " - print "#include " - print "#include " - print "#include " - print "#include " - print "#include " - print "#include " - print "#include " - print "#include " - print "#include " - print "" - print ioctl_includes - print "" - if (style == "print") { - print "void ioctlname(unsigned long val, int decimal);" - print "" - print "void" - print "ioctlname(unsigned long val, int decimal)" - } else { - print "const char *ioctlname(unsigned long val);" - print "" - print "const char *" - print "ioctlname(unsigned long val)" - } - print "{" - print "\tconst char *str = NULL;" - print "" -} - -/^#[ ]*define[ ]+[A-Za-z_][A-Za-z0-9_]*[ ]+_IO/ { - - # find where the name starts - for (i = 1; i <= NF; i++) - if ($i ~ /define/) - break; - ++i; - # - printf("\t"); - if (n++ > 0) - printf("else "); - printf("if (val == %s)\n", $i); - printf("\t\tstr = \"%s\";\n", $i); -} -END { - print "" - if (style == "print") { - print "\tif (str != NULL)" - print "\t\tprintf(\"%s\", str);" - print "\telse if (decimal)" - print "\t\tprintf(\"%lu\", val);" - print "\telse" - print "\t\tprintf(\"%#lx\", val);" - } else { - print "\treturn (str);" - } - print "}" -} -' diff --git a/usr.bin/kdump/mksubr b/usr.bin/kdump/mksubr deleted file mode 100644 index a2c21905caf..00000000000 --- a/usr.bin/kdump/mksubr +++ /dev/null @@ -1,761 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2006 "David Kirchner" . 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: stable/10/usr.bin/kdump/mksubr 280250 2015-03-19 12:32:48Z rwatson $ -# -# Generates kdump_subr.c -# mkioctls is a special-purpose script, and works fine as it is -# now, so it remains independent. The idea behind how it generates -# its list was heavily borrowed here. -# -# Some functions here are automatically generated. This can mean -# the user will see unusual kdump output or errors while building -# if the underlying .h files are changed significantly. -# -# Key: -# AUTO: Completely auto-generated with either the "or" or the "switch" -# method. -# AUTO - Special: Generated automatically, but with some extra commands -# that the auto_*_type() functions are inappropriate for. -# MANUAL: Manually entered and must therefore be manually updated. - -set -e - -LC_ALL=C; export LC_ALL - -if [ -z "$1" ] -then - echo "usage: sh $0 include-dir" - exit 1 -fi -include_dir=$1 - -# -# Automatically generates a C function that will print out the -# numeric input as a pipe-delimited string of the appropriate -# #define keys. ex: -# S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH -# The XOR is necessary to prevent including the "0"-value in every -# line. -# -auto_or_type () { - local name grep file - name=$1 - grep=$2 - file=$3 - - cat <<_EOF_ -/* AUTO */ -void -$name(intmax_t arg) -{ - int or = 0; - printf("%#jx<", (uintmax_t)arg); -_EOF_ - egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \ - $include_dir/$file | \ - awk '{ for (i = 1; i <= NF; i++) \ - if ($i ~ /define/) \ - break; \ - ++i; \ - printf "\tif (!((arg > 0) ^ ((%s) > 0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }' -cat <<_EOF_ - printf(">"); - if (or == 0) - printf("%jd", arg); -} - -_EOF_ -} - -# -# Automatically generates a C function used when the argument -# maps to a single, specific #definition -# -auto_switch_type () { - local name grep file - name=$1 - grep=$2 - file=$3 - - cat <<_EOF_ -/* AUTO */ -void -$name(intmax_t arg) -{ - switch (arg) { -_EOF_ - egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \ - $include_dir/$file | \ - awk '{ for (i = 1; i <= NF; i++) \ - if ($i ~ /define/) \ - break; \ - ++i; \ - printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i }' -cat <<_EOF_ - default: /* Should not reach */ - printf("", arg); - } -} - -_EOF_ -} - -# -# Automatically generates a C function used when the argument -# maps to a #definition -# -auto_if_type () { - local name grep file - name=$1 - grep=$2 - file=$3 - - cat <<_EOF_ -/* AUTO */ -void -$name(intmax_t arg) -{ -_EOF_ - egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \ - $include_dir/$file | \ - awk '{ printf "\t"; \ - if (NR > 1) \ - printf "else " ; \ - printf "if (arg == %s) \n\t\tprintf(\"%s\");\n", $2, $2 }' -cat <<_EOF_ - else /* Should not reach */ - printf("", arg); -} - -_EOF_ -} - -# C start - -cat <<_EOF_ -#include -#include -#include -#include -#include -#include -#include -#include -#define _KERNEL -#include -#undef _KERNEL -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define _KERNEL -#include -#undef _KERNEL -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kdump_subr.h" - -/* - * These are simple support macros. print_or utilizes a variable - * defined in the calling function to track whether or not it should - * print a logical-OR character ('|') before a string. if_print_or - * simply handles the necessary "if" statement used in many lines - * of this file. - */ -#define print_or(str,orflag) do { \\ - if (orflag) putchar('|'); else orflag = 1; \\ - printf (str); } \\ - while (0) -#define if_print_or(i,flag,orflag) do { \\ - if ((i & flag) == flag) \\ - print_or(#flag,orflag); } \\ - while (0) - -/* MANUAL */ -void -atfdname(int fd, int decimal) -{ - if (fd == AT_FDCWD) - printf("AT_FDCWD"); - else if (decimal) - printf("%d", fd); - else - printf("%#x", fd); -} - -/* MANUAL */ -extern char *signames[]; /* from kdump.c */ -void -signame(int sig) -{ - if (sig > 0 && sig < NSIG) - printf("SIG%s",signames[sig]); - else - printf("SIG %d", sig); -} - -/* MANUAL */ -void -semctlname(int cmd) -{ - switch (cmd) { - case GETNCNT: - printf("GETNCNT"); - break; - case GETPID: - printf("GETPID"); - break; - case GETVAL: - printf("GETVAL"); - break; - case GETALL: - printf("GETALL"); - break; - case GETZCNT: - printf("GETZCNT"); - break; - case SETVAL: - printf("SETVAL"); - break; - case SETALL: - printf("SETALL"); - break; - case IPC_RMID: - printf("IPC_RMID"); - break; - case IPC_SET: - printf("IPC_SET"); - break; - case IPC_STAT: - printf("IPC_STAT"); - break; - default: /* Should not reach */ - printf("", cmd); - } -} - -/* MANUAL */ -void -shmctlname(int cmd) -{ - switch (cmd) { - case IPC_RMID: - printf("IPC_RMID"); - break; - case IPC_SET: - printf("IPC_SET"); - break; - case IPC_STAT: - printf("IPC_STAT"); - break; - default: /* Should not reach */ - printf("", cmd); - } -} - -/* MANUAL */ -void -semgetname(int flag) -{ - int or = 0; - if_print_or(flag, IPC_CREAT, or); - if_print_or(flag, IPC_EXCL, or); - if_print_or(flag, SEM_R, or); - if_print_or(flag, SEM_A, or); - if_print_or(flag, (SEM_R>>3), or); - if_print_or(flag, (SEM_A>>3), or); - if_print_or(flag, (SEM_R>>6), or); - if_print_or(flag, (SEM_A>>6), or); -} - -/* - * MANUAL - * - * Only used by SYS_open. Unless O_CREAT is set in flags, the - * mode argument is unused (and often bogus and misleading). - */ -void -flagsandmodename(int flags, int mode, int decimal) -{ - flagsname(flags); - putchar(','); - if ((flags & O_CREAT) == O_CREAT) { - modename (mode); - } else { - if (decimal) { - printf("%d", mode); - } else { - printf("%#x", (unsigned int)mode); - } - } -} - -/* MANUAL */ -void -idtypename(idtype_t idtype, int decimal) -{ - switch(idtype) { - case P_PID: - printf("P_PID"); - break; - case P_PPID: - printf("P_PPID"); - break; - case P_PGID: - printf("P_PGID"); - break; - case P_SID: - printf("P_SID"); - break; - case P_CID: - printf("P_CID"); - break; - case P_UID: - printf("P_UID"); - break; - case P_GID: - printf("P_GID"); - break; - case P_ALL: - printf("P_ALL"); - break; - case P_LWPID: - printf("P_LWPID"); - break; - case P_TASKID: - printf("P_TASKID"); - break; - case P_PROJID: - printf("P_PROJID"); - break; - case P_POOLID: - printf("P_POOLID"); - break; - case P_JAILID: - printf("P_JAILID"); - break; - case P_CTID: - printf("P_CTID"); - break; - case P_CPUID: - printf("P_CPUID"); - break; - case P_PSETID: - printf("P_PSETID"); - break; - default: - if (decimal) { - printf("%d", idtype); - } else { - printf("%#x", idtype); - } - } -} - -/* - * MANUAL - * - * [g|s]etsockopt's level argument can either be SOL_SOCKET or a value - * referring to a line in /etc/protocols . It might be appropriate - * to use getprotoent(3) here. - */ -void -sockoptlevelname(int level, int decimal) -{ - if (level == SOL_SOCKET) { - printf("SOL_SOCKET"); - } else { - if (decimal) { - printf("%d", level); - } else { - printf("%#x", (unsigned int)level); - } - } -} - -/* - * MANUAL - * - * Used for page fault type. Cannot use auto_or_type since the macro - * values contain a cast. Also, VM_PROT_NONE has to be handled specially. - */ -void -vmprotname (int type) -{ - int or = 0; - - if (type == VM_PROT_NONE) { - (void)printf("VM_PROT_NONE"); - return; - } - if_print_or(type, VM_PROT_READ, or); - if_print_or(type, VM_PROT_WRITE, or); - if_print_or(type, VM_PROT_EXECUTE, or); - if_print_or(type, VM_PROT_COPY, or); -} - -/* - * MANUAL - */ -void -socktypenamewithflags(int type) -{ - if (type & SOCK_CLOEXEC) - printf("SOCK_CLOEXEC|"), type &= ~SOCK_CLOEXEC; - if (type & SOCK_NONBLOCK) - printf("SOCK_NONBLOCK|"), type &= ~SOCK_NONBLOCK; - socktypename(type); -} -_EOF_ - -auto_or_type "accessmodename" "[A-Z]_OK[[:space:]]+0?x?[0-9A-Fa-f]+" "sys/unistd.h" -auto_switch_type "acltypename" "ACL_TYPE_[A-Z4_]+[[:space:]]+0x[0-9]+" "sys/acl.h" -auto_or_type "capfcntlname" "CAP_FCNTL_[A-Z]+[[:space:]]+\(1" "sys/capsicum.h" -auto_switch_type "extattrctlname" "EXTATTR_NAMESPACE_[A-Z]+[[:space:]]+0x[0-9]+" "sys/extattr.h" -auto_switch_type "fadvisebehavname" "POSIX_FADV_[A-Z]+[[:space:]]+[0-9]+" "sys/fcntl.h" -auto_or_type "flagsname" "O_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h" -auto_or_type "flockname" "LOCK_[A-Z]+[[:space:]]+0x[0-9]+" "sys/fcntl.h" -auto_or_type "getfsstatflagsname" "MNT_[A-Z]+[[:space:]]+[1-9][0-9]*" "sys/mount.h" -auto_switch_type "kldsymcmdname" "KLDSYM_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h" -auto_switch_type "kldunloadfflagsname" "LINKER_UNLOAD_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h" -auto_switch_type "lio_listioname" "LIO_(NO)?WAIT[[:space:]]+[0-9]+" "aio.h" -auto_switch_type "madvisebehavname" "_?MADV_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h" -auto_switch_type "minheritname" "INHERIT_[A-Z]+[[:space:]]+[0-9]+" "sys/mman.h" -auto_or_type "mlockallname" "MCL_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h" -auto_or_type "mmapprotname" "PROT_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h" -auto_or_type "modename" "S_[A-Z]+[[:space:]]+[0-6]{7}" "sys/stat.h" -auto_or_type "mountflagsname" "MNT_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mount.h" -auto_switch_type "msyncflagsname" "MS_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h" -auto_or_type "nfssvcname" "NFSSVC_[A-Z0-9]+[[:space:]]+0x[0-9]+" "nfs/nfssvc.h" -auto_switch_type "prioname" "PRIO_[A-Z]+[[:space:]]+[0-9]" "sys/resource.h" -auto_switch_type "procctlcmdname" "PROC_[A-Z]+[[:space:]]+[0-9]" "sys/procctl.h" -auto_switch_type "ptraceopname" "PT_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/ptrace.h" -auto_switch_type "quotactlname" "Q_[A-Z]+[[:space:]]+0x[0-9]+" "ufs/ufs/quota.h" -auto_or_type "rebootoptname" "RB_[A-Z]+[[:space:]]+0x[0-9]+" "sys/reboot.h" -auto_or_type "rforkname" "RF[A-Z]+[[:space:]]+\([0-9]+<<[0-9]+\)" "sys/unistd.h" -auto_switch_type "rlimitname" "RLIMIT_[A-Z]+[[:space:]]+[0-9]+" "sys/resource.h" -auto_switch_type "schedpolicyname" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sched.h" -auto_switch_type "sendfileflagsname" "SF_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h" -auto_or_type "shmatname" "SHM_[A-Z]+[[:space:]]+[0-9]{6}+" "sys/shm.h" -auto_switch_type "shutdownhowname" "SHUT_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h" -auto_switch_type "sigbuscodename" "BUS_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h" -auto_switch_type "sigchldcodename" "CLD_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h" -auto_switch_type "sigfpecodename" "FPE_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h" -auto_switch_type "sigprocmaskhowname" "SIG_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h" -auto_switch_type "sigillcodename" "ILL_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h" -auto_switch_type "sigsegvcodename" "SEGV_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h" -auto_switch_type "sigtrapcodename" "TRAP_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h" -auto_if_type "sockdomainname" "PF_[[:alnum:]]+[[:space:]]+" "sys/socket.h" -auto_if_type "sockfamilyname" "AF_[[:alnum:]]+[[:space:]]+" "sys/socket.h" -auto_if_type "sockipprotoname" "IPPROTO_[[:alnum:]]+[[:space:]]+" "netinet/in.h" -auto_switch_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h" -auto_switch_type "socktypename" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h" -auto_or_type "thrcreateflagsname" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h" -auto_switch_type "umtxopname" "UMTX_OP_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/umtx.h" -auto_switch_type "vmresultname" "KERN_[A-Z]+[[:space:]]+[0-9]+" "vm/vm_param.h" -auto_or_type "wait6optname" "W[A-Z]+[[:space:]]+[0-9]+" "sys/wait.h" -auto_switch_type "whencename" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "sys/unistd.h" - -cat <<_EOF_ -/* - * AUTO - Special - * F_ is used to specify fcntl commands as well as arguments. Both sets are - * grouped in fcntl.h, and this awk script grabs the first group. - */ -void -fcntlcmdname(int cmd, int arg, int decimal) -{ - switch (cmd) { -_EOF_ -egrep "^#[[:space:]]*define[[:space:]]+F_[A-Z0-9_]+[[:space:]]+[0-9]+[[:space:]]*" \ - $include_dir/sys/fcntl.h | \ - awk 'BEGIN { o=0 } { for (i = 1; i <= NF; i++) \ - if ($i ~ /define/) \ - break; \ - ++i; \ - if (o <= $(i+1)) \ - printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i; \ - else \ - exit; \ - o = $(i+1) }' -cat <<_EOF_ - default: /* Should not reach */ - printf("", cmd); - } - putchar(','); - if (cmd == F_GETFD || cmd == F_SETFD) { - if (arg == FD_CLOEXEC) - printf("FD_CLOEXEC"); - else if (arg == 0) - printf("0"); - else { - if (decimal) - printf("%d", arg); - else - printf("%#x", (unsigned int)arg); - } - } else if (cmd == F_SETFL) { - flagsname(arg); - } else { - if (decimal) - printf("%d", arg); - else - printf("%#x", (unsigned int)arg); - } -} - -/* - * AUTO - Special - * - * The MAP_ALIGNED flag requires special handling. - */ -void -mmapflagsname(int flags) -{ - int align; - int or = 0; - printf("%#x<", flags); -_EOF_ -egrep "^#[[:space:]]*define[[:space:]]+MAP_[A-Z_]+[[:space:]]+0x[0-9A-Fa-f]+[[:space:]]*" \ - $include_dir/sys/mman.h | grep -v MAP_ALIGNED | \ - awk '{ for (i = 1; i <= NF; i++) \ - if ($i ~ /define/) \ - break; \ - ++i; \ - printf "\tif (!((flags > 0) ^ ((%s) > 0)))\n\t\tif_print_or(flags, %s, or);\n", $i, $i }' -cat <<_EOF_ -#ifdef MAP_32BIT - if (!((flags > 0) ^ ((MAP_32BIT) > 0))) - if_print_or(flags, MAP_32BIT, or); -#endif - align = flags & MAP_ALIGNMENT_MASK; - if (align != 0) { - if (align == MAP_ALIGNED_SUPER) - print_or("MAP_ALIGNED_SUPER", or); - else { - print_or("MAP_ALIGNED", or); - printf("(%d)", align >> MAP_ALIGNMENT_SHIFT); - } - } - printf(">"); - if (or == 0) - printf("%d", flags); -} - -/* - * AUTO - Special - * - * The only reason this is not fully automated is due to the - * grep -v RTP_PRIO statement. A better egrep line should - * make this capable of being a auto_switch_type() function. - */ -void -rtprioname(int func) -{ - switch (func) { -_EOF_ -egrep "^#[[:space:]]*define[[:space:]]+RTP_[A-Z]+[[:space:]]+0x[0-9]+[[:space:]]*" \ - $include_dir/sys/rtprio.h | grep -v RTP_PRIO | \ - awk '{ for (i = 1; i <= NF; i++) \ - if ($i ~ /define/) \ - break; \ - ++i; \ - printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i }' -cat <<_EOF_ - default: /* Should not reach */ - printf("", func); - } -} - -/* - * AUTO - Special - * - * The send and recv functions have a flags argument which can be - * set to 0. There is no corresponding #define. The auto_ functions - * detect this as "invalid", which is incorrect here. - */ -void -sendrecvflagsname(int flags) -{ - int or = 0; - - if (flags == 0) { - printf("0"); - return; - } - - printf("%#x<", flags); -_EOF_ -egrep "^#[[:space:]]*define[[:space:]]+MSG_[A-Z]+[[:space:]]+0x[0-9]+[[:space:]]*" $include_dir/sys/socket.h | \ - awk '{ for (i = 1; i <= NF; i++) \ - if ($i ~ /define/) \ - break; \ - ++i; \ - printf "\tif(!((flags>0)^((%s)>0)))\n\t\tif_print_or(flags, %s, or);\n", $i, $i }' -cat <<_EOF_ - printf(">"); -} - -/* - * AUTO - Special - * - * Check general codes first, then defer to signal-specific codes. - */ -void -sigcodename(int sig, int code) -{ - switch (code) { -_EOF_ -egrep "^#[[:space:]]*define[[:space:]]+SI_[A-Z]+[[:space:]]+0(x[0-9abcdef]+)?[[:space:]]*" \ - $include_dir/sys/signal.h | grep -v SI_UNDEFINED | \ - awk '{ for (i = 1; i <= NF; i++) \ - if ($i ~ /define/) \ - break; \ - ++i; \ - printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i }' -cat <<_EOF_ - default: - switch (sig) { - case SIGILL: - sigillcodename(code); - break; - case SIGBUS: - sigbuscodename(code); - break; - case SIGSEGV: - sigsegvcodename(code); - break; - case SIGFPE: - sigfpecodename(code); - break; - case SIGTRAP: - sigtrapcodename(code); - break; - case SIGCHLD: - sigchldcodename(code); - break; - default: - printf("", code); - } - } -} - -/* - * AUTO - Special - * - * Just print 0 as 0. - */ -void -umtxcvwaitflags(intmax_t arg) -{ - int or = 0; - if (arg == 0) { - printf("0"); - return; - } - printf("%#jx<", (uintmax_t)arg); -_EOF_ - egrep "^#[[:space:]]*define[[:space:]]+CVWAIT_[A-Z_]+[[:space:]]+0x[0-9]+[[:space:]]*" \ - $include_dir/sys/umtx.h | \ - awk '{ for (i = 1; i <= NF; i++) \ - if ($i ~ /define/) \ - break; \ - ++i; \ - printf "\tif (!((arg > 0) ^ ((%s) > 0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }' -cat <<_EOF_ - printf(">"); - if (or == 0) - printf("%jd", arg); -} - - -/* - * AUTO - Special - * - * Just print 0 as 0. - */ -void -umtxrwlockflags(intmax_t arg) -{ - int or = 0; - if (arg == 0) { - printf("0"); - return; - } - printf("%#jx<", (uintmax_t)arg); -_EOF_ - egrep "^#[[:space:]]*define[[:space:]]+URWLOCK_PREFER_READER[[:space:]]+0x[0-9]+[[:space:]]*" \ - $include_dir/sys/umtx.h | \ - awk '{ for (i = 1; i <= NF; i++) \ - if ($i ~ /define/) \ - break; \ - ++i; \ - printf "\tif (!((arg > 0) ^ ((%s) > 0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }' -cat <<_EOF_ - printf(">"); - if (or == 0) - printf("%jd", arg); -} -_EOF_ -egrep '#define[[:space:]]+CAP_[A-Z_]+[[:space:]]+CAPRIGHT\([0-9],[[:space:]]+0x[0-9]{16}ULL\)' \ - $include_dir/sys/capsicum.h | \ - sed -E 's/[ ]+/ /g' | \ - awk -F '[ \(,\)]' ' - BEGIN { - printf "void\n" - printf "capname(const cap_rights_t *rightsp)\n" - printf "{\n" - printf "\tint comma = 0;\n\n" - printf "\tprintf(\"<\");\n" - } - { - printf "\tif ((rightsp->cr_rights[%s] & %s) == %s) {\n", $4, $2, $2 - printf "\t\tif (comma) printf(\",\"); else comma = 1;\n" - printf "\t\tprintf(\"%s\");\n", $2 - printf "\t}\n" - } - END { - printf "\tprintf(\">\");\n" - printf "}\n" - }' diff --git a/usr.bin/lastcomm/tests/v1-sparc64-acct.in b/usr.bin/lastcomm/tests/v1-sparc64-acct.in deleted file mode 100644 index 00f05b423fc539ccf8e921fa9172af63e0f76a0e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1568 zcmb`HJx>Bb5Qb;r0u>s+B9-BO8+=GCJPgCjFH?eWWREEZG zFA&Wg9|9Ovu?+KVc)gudGkoQgD}S zP59L;L#mJMKHFSpoGXmyOxc{$4_*W}Cb$cUBYCV&st+Ip3xb;zTuY;p)d%a_P38H8 z72HsLd9zTE{Pti9u!ZPIr8|xvubI`CJW95eenka0IcK0Vmh~TEV!g$9N^J|+A z;ppO0Y&o7-S&cBoA5(EnhoefFrcW#oFHqak2*Dmu0CFhc2}TAC2l@h7P1^Dl~fap6ss$bH@6B z?C|OW=lc#<{C*zJkB4Vjsc=rOE+Y;qwcwRFqrLsvFvmK(08!ixXMR>%DV&!AL-uD` z`a_x+`!kZyW{2>|AM+IX@Ue&1Y$DHA#MvHLhvI5Lsy(I!ABdA1$@CpPksAqA*4Q+} zo%2Xt*simVIBx{sj3dCSTYwVD+PET|@ivIL1F*XeOLK)o#DiMESyu8B;oN!vF?$I1 z-Nh)UnK-2N{aJ_e)i}i0MWi;Ja~VYbP&B?6CZK!&&r#~NI1Rfoj@F+0Q*5o|xyI+w zNO?XU#O2rP7)HY!UTHntMx1{NJXbiatdT;Ts>)sdTypY*Jw2f|gzTS>^2AyCo0ln^ zI^U2+;;4O??HN}3Cw)8KWPiEUP0v@*T0<*r-snd`1TN6P@Y|WvKX8ECym5GOrwdEGWjtl z$oALkXh}Zp@fwBmjI`n*;!ihaC!8NKxd3PL>sOquH>TNuIFtNjF*K@|%QNZEO1&z| z*2`SfAZ{k%?D#p#QR>yEoIl;Yxm?&E=i=V+)Ti-+^HW;mA1nUwCiR8$BmL2j>&0^Q zvg%xjTT65v-jrEYIC}z2G(UOnj?l(1PY~ymKOipnK@jKtz}nay%$V~{OrzIg-xiJi zsoh(b*jL}s*c6vDn63xm{snREMQNmPs-%jCb?a{R)46)}DcEiMqMYZ$9JLSE#$}zn z2a!)e%xF#U_XXSOl^?H<_jl^|;7&m@{-EcSR&tv*I5?6C4#Doj+ z#axuLfw-(@9pbG8s{MCS&IaN#$Hwzx)F1qcNmzU-sCc zaGtGp4>~Jl|FkRTY8T(gp?V@24T--G>TzcdK@W9+1JOqXinluC_!(UWjoYdO41?A!ypnhsc= Shw@|4$*+4-Ejdj-rt}|KtE>qC diff --git a/usr.bin/lastcomm/tests/v2-sparc64.out b/usr.bin/lastcomm/tests/v2-sparc64.out deleted file mode 100644 index f693e8efd9f..00000000000 --- a/usr.bin/lastcomm/tests/v2-sparc64.out +++ /dev/null @@ -1,36 +0,0 @@ -core -FDX root 0.010 secs 0.000 us 0.010 sy 0.042 es Sat May 19 09:17 -core -DX root 0.037 secs 0.001 us 0.036 sy 0.055 es Sat May 19 09:17 -cc - root 0.033 secs 0.002 us 0.031 sy 1.012 es Sat May 19 09:17 -ld - root 0.186 secs 0.115 us 0.071 sy 0.361 es Sat May 19 09:17 -as - root 0.030 secs 0.005 us 0.025 sy 0.126 es Sat May 19 09:17 -cc1 - root 0.105 secs 0.048 us 0.057 sy 0.417 es Sat May 19 09:17 -time - root 0.029 secs 0.001 us 0.028 sy 0.047 es Sat May 19 09:17 -1234567890123456 - root 0.017 secs 0.003 us 0.014 sy 0.019 es Sat May 19 09:17 -ln - root 0.019 secs 0.003 us 0.016 sy 0.020 es Sat May 19 09:17 -time - root 0.029 secs 0.003 us 0.025 sy 0.047 es Sat May 19 09:17 -1234567890123456 - root 0.017 secs 0.002 us 0.015 sy 0.019 es Sat May 19 09:17 -ln - root 0.019 secs 0.004 us 0.015 sy 0.020 es Sat May 19 09:17 -time - root 0.029 secs 0.004 us 0.025 sy 0.053 es Sat May 19 09:17 -123456789012345 - root 0.018 secs 0.001 us 0.016 sy 0.025 es Sat May 19 09:17 -ln - root 0.020 secs 0.001 us 0.019 sy 0.020 es Sat May 19 09:17 -time - root 0.029 secs 0.003 us 0.026 sy 1.702 es Sat May 19 09:17 -diff - root 1.636 secs 1.337 us 0.299 sy 1.674 es Sat May 19 09:17 -time - root 0.027 secs 0.002 us 0.026 sy 0.634 es Sat May 19 09:17 -dd - root 0.588 secs 0.017 us 0.571 sy 0.605 es Sat May 19 09:17 -time - root 0.028 secs 0.001 us 0.027 sy 3.049 es Sat May 19 09:17 -sleep - root 0.018 secs 0.002 us 0.016 sy 3.021 es Sat May 19 09:17 -time - root 0.029 secs 0.002 us 0.027 sy 17.970 es Sat May 19 09:17 -find - root 5.703 secs 0.555 us 5.148 sy 17.942 es Sat May 19 09:17 -time - root 0.029 secs 0.005 us 0.024 sy 27.162 es Sat May 19 09:16 -egrep - root 26.715 secs 26.632 us 0.082 sy 27.133 es Sat May 19 09:16 -logger - root 0.023 secs 0.005 us 0.018 sy 60.808 es Sat May 19 09:15 -sh -F root 0.008 secs 0.000 us 0.008 sy 60.815 es Sat May 19 09:15 -fsck - root 0.055 secs 0.008 us 0.047 sy 60.806 es Sat May 19 09:15 -fsck_ufs - root 0.028 secs 0.005 us 0.022 sy 0.140 es Sat May 19 09:16 -fsck_ufs - root 0.028 secs 0.006 us 0.022 sy 0.123 es Sat May 19 09:16 -fsck_ufs - root 0.028 secs 0.004 us 0.024 sy 0.058 es Sat May 19 09:16 -fsck_ufs - root 0.032 secs 0.004 us 0.028 sy 0.326 es Sat May 19 09:16 -sleep - root 0.019 secs 0.001 us 0.018 sy 60.085 es Sat May 19 09:15 -time - root 0.029 secs 0.005 us 0.025 sy 1.701 es Sat May 19 09:16 -awk - root 1.644 secs 1.617 us 0.028 sy 1.657 es Sat May 19 09:16 -accton - root 0.019 secs 0.003 us 0.016 sy 0.027 es Sat May 19 09:16 diff --git a/usr.bin/ldd/extern.h b/usr.bin/ldd/extern.h deleted file mode 100644 index 24b5f4126f6..00000000000 --- a/usr.bin/ldd/extern.h +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2002 FreeBSD, Inc - * 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. - * - */ - -extern void dump_file(const char *); -extern int error_count; - diff --git a/usr.bin/ldd/sods.c b/usr.bin/ldd/sods.c deleted file mode 100644 index 8e21e963aba..00000000000 --- a/usr.bin/ldd/sods.c +++ /dev/null @@ -1,572 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (C) 1996-1997 John D. Polstra. 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 JOHN D. POLSTRA 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 JOHN D. POLSTRA 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 - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "extern.h" - -#define PAGE_SIZE 4096 /* i386 specific */ - -#ifndef N_SETA -#define N_SETA 0x14 /* Absolute set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETT -#define N_SETT 0x16 /* Text set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETD -#define N_SETD 0x18 /* Data set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETB -#define N_SETB 0x1A /* Bss set element symbol */ -#endif /* This is input to LD, in a .o file. */ - -#ifndef N_SETV -#define N_SETV 0x1C /* Pointer to set vector in data area. */ -#endif /* This is output from LD. */ - -#ifdef STANDALONE -static -#endif - -static void dump_rels(const char *, const struct relocation_info *, - unsigned long, const char *(*)(unsigned long), unsigned char *); -static void dump_segs(void); -static void dump_sods(void); -static void dump_sym(const struct nlist *); -static void dump_syms(void); - -static void dump_rtsyms(void); - -static const char *rtsym_name(unsigned long); -static const char *sym_name(unsigned long); - -#ifdef STANDALONE -static -#endif -int error_count; - -/* - * Variables ending in _base are pointers to things in our address space, - * i.e., in the file itself. - * - * Variables ending in _addr are adjusted according to where things would - * actually appear in memory if the file were loaded. - */ -static const char *file_base; -static const char *text_base; -static const char *data_base; -static const struct relocation_info *rel_base; -static const struct nlist *sym_base; -static const char *str_base; - -static const struct relocation_info *rtrel_base; -static const struct nzlist *rtsym_base; -static const char *rtstr_base; - -static const struct exec *ex; -static const struct _dynamic *dyn; -static const struct section_dispatch_table *sdt; - -static const char *text_addr; -static const char *data_addr; - -static unsigned long rel_count; -static unsigned long sym_count; - -static unsigned long rtrel_count; -static unsigned long rtsym_count; - -/* Dynamically allocated flags, 1 byte per symbol, to record whether each - symbol was referenced by a relocation entry. */ -static unsigned char *sym_used; -static unsigned char *rtsym_used; - -static unsigned long origin; /* What values are relocated relative to */ - -#ifdef STANDALONE -int -main(int argc, char *argv[]) -{ - int i; - - for (i = 1; i < argc; ++i) - dump_file(argv[i]); - - return error_count == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -} -#endif - -static inline const void *align_struct(const void *expr) -{ - assert(!(((int)expr) & 3)); - return expr; -} - -static inline const void *align_long(const void *expr) -{ - assert(!(((int)expr) & 3)); - return expr; -} - -static inline const void *align_short(const void *expr) -{ - assert(!(((int)expr) & 1)); - return expr; -} - -#ifdef STANDALONE -static -#endif -void -dump_file(const char *fname) -{ - int fd; - struct stat sb; - caddr_t objbase; - - if (stat(fname, &sb) == -1) { - warnx("cannot stat \"%s\"", fname); - ++error_count; - return; - } - - if ((sb.st_mode & S_IFMT) != S_IFREG) { - warnx("\"%s\" is not a regular file", fname); - ++error_count; - return; - } - - if ((fd = open(fname, O_RDONLY, 0)) == -1) { - warnx("cannot open \"%s\"", fname); - ++error_count; - return; - } - - objbase = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); - if (objbase == (caddr_t) -1) { - warnx("cannot mmap \"%s\"", fname); - ++error_count; - close(fd); - return; - } - - close(fd); - - file_base = (const char *) objbase; /* Makes address arithmetic easier */ - - if (IS_ELF(*(const Elf32_Ehdr*) align_struct(file_base))) { - warnx("%s: this is an ELF program; use readelf to examine", fname); - ++error_count; - munmap(objbase, sb.st_size); - return; - } - - ex = (const struct exec *) align_struct(file_base); - - printf("%s: a_midmag = 0x%lx\n", fname, (long)ex->a_midmag); - printf(" magic = 0x%lx = 0%lo, netmagic = 0x%lx = 0%lo\n", - (long)N_GETMAGIC(*ex), (long)N_GETMAGIC(*ex), - (long)N_GETMAGIC_NET(*ex), (long)N_GETMAGIC_NET(*ex)); - - if (N_BADMAG(*ex)) { - warnx("%s: bad magic number", fname); - ++error_count; - munmap(objbase, sb.st_size); - return; - } - - printf(" a_text = 0x%lx\n", (long)ex->a_text); - printf(" a_data = 0x%lx\n", (long)ex->a_data); - printf(" a_bss = 0x%lx\n", (long)ex->a_bss); - printf(" a_syms = 0x%lx\n", (long)ex->a_syms); - printf(" a_entry = 0x%lx\n", (long)ex->a_entry); - printf(" a_trsize = 0x%lx\n", (long)ex->a_trsize); - printf(" a_drsize = 0x%lx\n", (long)ex->a_drsize); - - text_base = file_base + N_TXTOFF(*ex); - data_base = file_base + N_DATOFF(*ex); - rel_base = (const struct relocation_info *) - align_struct(file_base + N_RELOFF(*ex)); - sym_base = (const struct nlist *) align_struct(file_base + N_SYMOFF(*ex)); - str_base = file_base + N_STROFF(*ex); - - rel_count = (ex->a_trsize + ex->a_drsize) / sizeof rel_base[0]; - assert(rel_count * sizeof rel_base[0] == ex->a_trsize + ex->a_drsize); - sym_count = ex->a_syms / sizeof sym_base[0]; - assert(sym_count * sizeof sym_base[0] == ex->a_syms); - - if (sym_count != 0) { - sym_used = (unsigned char *) calloc(sym_count, sizeof(unsigned char)); - assert(sym_used != NULL); - } - - printf(" Entry = 0x%lx\n", (long)ex->a_entry); - printf(" Text offset = %x, address = %lx\n", N_TXTOFF(*ex), - (long)N_TXTADDR(*ex)); - printf(" Data offset = %lx, address = %lx\n", (long)N_DATOFF(*ex), - (long)N_DATADDR(*ex)); - - /* - * In an executable program file, everything is relocated relative to - * the assumed run-time load address, i.e., N_TXTADDR(*ex), i.e., 0x1000. - * - * In a shared library file, everything is relocated relative to the - * start of the file, i.e., N_TXTOFF(*ex), i.e., 0. - * - * The way to tell the difference is by looking at ex->a_entry. If it - * is >= 0x1000, then we have an executable program. Otherwise, we - * have a shared library. - * - * When a program is executed, the entire file is mapped into memory, - * including the a.out header and so forth. But it is not mapped at - * address 0; rather it is mapped at address 0x1000. The first page - * of the user's address space is left unmapped in order to catch null - * pointer dereferences. - * - * In this program, when we map in an executable program, we have to - * simulate the empty page by decrementing our assumed base address by - * a pagesize. - */ - - text_addr = text_base; - data_addr = data_base; - origin = 0; - - if (ex->a_entry >= PAGE_SIZE) { /* Executable, not a shared library */ - /* - * The fields in the object have already been relocated on the - * assumption that the object will be loaded at N_TXTADDR(*ex). - * We have to compensate for that. - */ - text_addr -= PAGE_SIZE; - data_addr -= PAGE_SIZE; - origin = PAGE_SIZE; - printf(" Program, origin = %lx\n", origin); - } else if (N_GETFLAG(*ex) & EX_DYNAMIC) - printf(" Shared library, origin = %lx\n", origin); - else - printf(" Object file, origin = %lx\n", origin); - - if (N_GETFLAG(*ex) & EX_DYNAMIC) { - dyn = (const struct _dynamic *) align_struct(data_base); - printf(" Dynamic version = %d\n", dyn->d_version); - - sdt = (const struct section_dispatch_table *) - align_struct(text_addr + (unsigned long) dyn->d_un.d_sdt); - - rtrel_base = (const struct relocation_info *) - align_struct(text_addr + sdt->sdt_rel); - rtrel_count = (sdt->sdt_hash - sdt->sdt_rel) / sizeof rtrel_base[0]; - assert(rtrel_count * sizeof rtrel_base[0] == - (size_t)(sdt->sdt_hash - sdt->sdt_rel)); - - rtsym_base = (const struct nzlist *) - align_struct(text_addr + sdt->sdt_nzlist); - rtsym_count = (sdt->sdt_strings - sdt->sdt_nzlist) / - sizeof rtsym_base[0]; - assert(rtsym_count * sizeof rtsym_base[0] == - (size_t)(sdt->sdt_strings - sdt->sdt_nzlist)); - - if (rtsym_count != 0) { - rtsym_used = (unsigned char *) calloc(rtsym_count, - sizeof(unsigned char)); - assert(rtsym_used != NULL); - } - - rtstr_base = text_addr + sdt->sdt_strings; - } - - dump_segs(); - dump_sods(); - dump_rels("Relocations", rel_base, rel_count, sym_name, sym_used); - dump_syms(); - - dump_rels("Run-time relocations", rtrel_base, rtrel_count, rtsym_name, - rtsym_used); - dump_rtsyms(); - - if (rtsym_used != NULL) { - free(rtsym_used); - rtsym_used = NULL; - } - if (sym_used != NULL) { - free(sym_used); - sym_used = NULL; - } - munmap(objbase, sb.st_size); -} - -static void -dump_rels(const char *label, const struct relocation_info *base, - unsigned long count, const char *(*name)(unsigned long), - unsigned char *sym_used_flags) -{ - unsigned long i; - - printf(" %s:\n", label); - for (i = 0; i < count; ++i) { - const struct relocation_info *r = &base[i]; - unsigned int size; - char contents[16]; - - size = 1u << r->r_length; - - if (origin <= (unsigned long)r->r_address - && (unsigned long)r->r_address < origin + ex->a_text + ex->a_data - && 1 <= size && size <= 4) { - /* - * XXX - This can cause unaligned accesses. OK for the - * i386, not so for other architectures. - */ - switch (size) { - case 1: - snprintf(contents, sizeof contents, " [%02x]", - *(unsigned const char *)(text_addr + r->r_address)); - break; - case 2: - snprintf(contents, sizeof contents, " [%04x]", - *(unsigned const short *) - align_short(text_addr + r->r_address)); - break; - case 4: - snprintf(contents, sizeof contents, "[%08lx]", - *(unsigned const long *) - align_long(text_addr + r->r_address)); - break; - } - } else - snprintf(contents, sizeof contents, " "); - - printf(" %6lu %8x/%u %s %c%c%c%c%c%c", i, - r->r_address, size, - contents, - r->r_extern ? 'e' : '-', - r->r_jmptable ? 'j' : '-', - r->r_relative ? 'r' : '-', - r->r_baserel ? 'b' : '-', - r->r_pcrel ? 'p' : '-', - r->r_copy ? 'c' : '-'); - - if (r->r_extern || r->r_baserel || r->r_jmptable || r->r_copy) { - printf(" %4u %s", r->r_symbolnum, name(r->r_symbolnum)); - sym_used_flags[r->r_symbolnum] = 1; - } - - printf("\n"); - } -} - -static void -dump_rtsyms(void) -{ - unsigned long i; - - printf(" Run-time symbols:\n"); - for (i = 0; i < rtsym_count; ++i) { - printf(" %6lu%c ", i, rtsym_used[i] ? '*' : ' '); - dump_sym(&rtsym_base[i].nlist); - printf("/%-5ld %s\n", rtsym_base[i].nz_size, rtsym_name(i)); - } -} - -static void -dump_segs(void) -{ - printf(" Text segment starts at address %lx\n", origin + N_TXTOFF(*ex)); - if (N_GETFLAG(*ex) & EX_DYNAMIC) { - printf(" rel starts at %lx\n", sdt->sdt_rel); - printf(" hash starts at %lx\n", sdt->sdt_hash); - printf(" nzlist starts at %lx\n", sdt->sdt_nzlist); - printf(" strings starts at %lx\n", sdt->sdt_strings); - } - - printf(" Data segment starts at address %lx\n", origin + N_DATOFF(*ex)); - if (N_GETFLAG(*ex) & EX_DYNAMIC) { - printf(" _dynamic starts at %lx\n", origin + N_DATOFF(*ex)); - printf(" so_debug starts at %lx\n", (unsigned long) dyn->d_debug); - printf(" sdt starts at %lx\n", (unsigned long) dyn->d_un.d_sdt); - printf(" got starts at %lx\n", sdt->sdt_got); - printf(" plt starts at %lx\n", sdt->sdt_plt); - printf(" rest of stuff starts at %lx\n", - sdt->sdt_plt + sdt->sdt_plt_sz); - } -} - -static void -dump_sods(void) -{ - long sod_offset; - long paths_offset; - - if (dyn == NULL) /* Not a shared object */ - return; - - sod_offset = sdt->sdt_sods; - printf(" Shared object dependencies:\n"); - while (sod_offset != 0) { - const struct sod *sodp = (const struct sod *) align_struct((text_addr + sod_offset)); - const char *name = (const char *) (text_addr + sodp->sod_name); - - if (sodp->sod_library) - printf(" -l%-16s version %d.%d\n", name, sodp->sod_major, - sodp->sod_minor); - else - printf(" %s\n", name); - sod_offset = sodp->sod_next; - } - paths_offset = sdt->sdt_paths; - printf(" Shared object additional paths:\n"); - if (paths_offset != 0) { - printf(" %s\n", (const char *)(text_addr + paths_offset)); - } else { - printf(" (none)\n"); - } -} - -static void -dump_sym(const struct nlist *np) -{ - char type[8]; - char aux[8]; - char weak; - char *p; - - switch (np->n_type & ~N_EXT) { - case N_UNDF: strcpy(type, "undf"); break; - case N_ABS: strcpy(type, "abs"); break; - case N_TEXT: strcpy(type, "text"); break; - case N_DATA: strcpy(type, "data"); break; - case N_BSS: strcpy(type, "bss"); break; - case N_INDR: strcpy(type, "indr"); break; - case N_SIZE: strcpy(type, "size"); break; - case N_COMM: strcpy(type, "comm"); break; - case N_SETA: strcpy(type, "seta"); break; - case N_SETT: strcpy(type, "sett"); break; - case N_SETD: strcpy(type, "setd"); break; - case N_SETB: strcpy(type, "setb"); break; - case N_SETV: strcpy(type, "setv"); break; - case N_FN: strcpy(type, np->n_type&N_EXT ? "fn" : "warn"); break; - case N_GSYM: strcpy(type, "gsym"); break; - case N_FNAME: strcpy(type, "fname"); break; - case N_FUN: strcpy(type, "fun"); break; - case N_STSYM: strcpy(type, "stsym"); break; - case N_LCSYM: strcpy(type, "lcsym"); break; - case N_MAIN: strcpy(type, "main"); break; - case N_PC: strcpy(type, "pc"); break; - case N_RSYM: strcpy(type, "rsym"); break; - case N_SLINE: strcpy(type, "sline"); break; - case N_DSLINE: strcpy(type, "dsline"); break; - case N_BSLINE: strcpy(type, "bsline"); break; - case N_SSYM: strcpy(type, "ssym"); break; - case N_SO: strcpy(type, "so"); break; - case N_LSYM: strcpy(type, "lsym"); break; - case N_BINCL: strcpy(type, "bincl"); break; - case N_SOL: strcpy(type, "sol"); break; - case N_PSYM: strcpy(type, "psym"); break; - case N_EINCL: strcpy(type, "eincl"); break; - case N_ENTRY: strcpy(type, "entry"); break; - case N_LBRAC: strcpy(type, "lbrac"); break; - case N_EXCL: strcpy(type, "excl"); break; - case N_RBRAC: strcpy(type, "rbrac"); break; - case N_BCOMM: strcpy(type, "bcomm"); break; - case N_ECOMM: strcpy(type, "ecomm"); break; - case N_ECOML: strcpy(type, "ecoml"); break; - case N_LENG: strcpy(type, "leng"); break; - default: - snprintf(type, sizeof type, "%#02x", np->n_type); - break; - } - - if (np->n_type & N_EXT && type[0] != '0') - for (p = type; *p != '\0'; ++p) - *p = toupper(*p); - - switch (N_AUX(np)) { - case 0: strcpy(aux, ""); break; - case AUX_OBJECT: strcpy(aux, "objt"); break; - case AUX_FUNC: strcpy(aux, "func"); break; - default: snprintf(aux, sizeof aux, "%#01x", N_AUX(np)); break; - } - - weak = N_BIND(np) == BIND_WEAK ? 'w' : ' '; - - printf("%c%-6s %-4s %8lx", weak, type, aux, np->n_value); -} - -static void -dump_syms(void) -{ - unsigned long i; - - printf(" Symbols:\n"); - for (i = 0; i < sym_count; ++i) { - printf(" %6lu%c ", i, sym_used[i] ? '*' : ' '); - dump_sym(&sym_base[i]); - printf(" %s\n", sym_name(i)); - } -} - -static const char * -rtsym_name(unsigned long n) -{ - assert(n < rtsym_count); - if (rtsym_base[n].nz_strx == 0) - return ""; - return rtstr_base + rtsym_base[n].nz_strx; -} - -static const char * -sym_name(unsigned long n) -{ - assert(n < sym_count); - if (sym_base[n].n_un.n_strx == 0) - return ""; - return str_base + sym_base[n].n_un.n_strx; -} diff --git a/usr.bin/mail/USD.doc/mail0.nr b/usr.bin/mail/USD.doc/mail0.nr deleted file mode 100644 index 26b4761c1b6..00000000000 --- a/usr.bin/mail/USD.doc/mail0.nr +++ /dev/null @@ -1,72 +0,0 @@ -.\" Copyright (c) 1980, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)mail0.nr 8.1 (Berkeley) 6/8/93 -.\" -.\" $FreeBSD: src/usr.bin/mail/USD.doc/mail0.nr,v 1.1.1.1.46.1 2005/08/19 02:53:00 cperciva Exp $ -.\" -.eh 'USD:7-%''Mail Reference Manual' -.oh 'Mail Reference Manual''USD:7-%' -.if n \ -.nr fs .5v -.\".he 'Mail Reference Manual'\n(mo/\n(dy/\n(yr'%' -.tp -.sp 1.0i -.sz 12 -.rb -.(l C -MAIL REFERENCE MANUAL -.)l -.sz 10 -.sp 2 -.i -.(l C -Kurt Shoens -.)l -.r -.(l C -Revised by -.)l -.(l C -.i -Craig Leres\ \c -.r -and\ \c -.i -Mark Andrews -.)l -.r -.(l C -Version 5.5 - - -.)l -.pn 2 diff --git a/usr.bin/mail/USD.doc/mail1.nr b/usr.bin/mail/USD.doc/mail1.nr deleted file mode 100644 index 50e7883c745..00000000000 --- a/usr.bin/mail/USD.doc/mail1.nr +++ /dev/null @@ -1,92 +0,0 @@ -.\" Copyright (c) 1980, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)mail1.nr 8.1 (Berkeley) 6/8/93 -.\" -.sh 1 Introduction -.pp -.i Mail -provides a simple and friendly environment for sending and receiving mail. -It divides incoming mail into -its constituent messages and allows the user to deal with them -in any order. In addition, it provides a set of -.i ed -\c -like commands for manipulating messages and sending mail. -.i Mail -offers the user simple editing capabilities to ease the composition -of outgoing messages, as well as providing the ability to define and send -to names which address groups of users. Finally, -.i Mail -is able to send and receive messages across such networks as the -ARPANET, UUCP, and Berkeley network. -.pp -This document describes how to use the -.i Mail -program to send and receive messages. The reader is not assumed to -be familiar with other message handling systems, but should be -familiar with the \s-2UNIX\s0\** -.(f -\** \s-1UNIX\s0 is a trademark of Bell Laboratories. -.)f -shell, the text editor, and some of the common \s-2UNIX\s0 commands. -.q "The \s-2UNIX\s0 Programmer's Manual," -.q "An Introduction to Csh," -and -.q "Text Editing with Ex and Vi" -can be consulted for more information on these topics. -.pp -Here is how messages are handled: -the mail system accepts incoming -.i messages -for you from other people -and collects them in a file, called your -.i "system mailbox" . -When you login, the system notifies you if there are any messages -waiting in your system mailbox. If you are a -.i csh -user, you will be notified when new mail arrives if you inform -the shell of the location of your mailbox. On version 7 systems, -your system mailbox is located in the directory /var/mail -in a file with your login name. If your login name is -.q sam, -then you can make -.i csh -notify you of new mail by including the following line in your .cshrc -file: -.(l -set mail=/var/mail/sam -.)l -When you read your mail using -.i Mail , -it reads your system mailbox and separates that file into the -individual messages that have been sent to you. You can then -read, reply to, delete, or save these messages. -Each message is marked with its author and the date they sent it. diff --git a/usr.bin/mail/USD.doc/mail2.nr b/usr.bin/mail/USD.doc/mail2.nr deleted file mode 100644 index 0419859257b..00000000000 --- a/usr.bin/mail/USD.doc/mail2.nr +++ /dev/null @@ -1,617 +0,0 @@ -.\" Copyright (c) 1980, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)mail2.nr 8.1 (Berkeley) 6/8/93 -.\" -.bp -.sh 1 "Common usage" -.pp -The -.i Mail -command has two distinct usages, according to whether one -wants to send or receive mail. Sending mail is simple: to send a -message to a user whose login name is, say, -\*(lqroot,\*(rq -use the shell -command: -.(l -% Mail root -.)l -then type your message. When you reach the end of the message, type -an EOT (control\-d) at the beginning of a line, which will cause -.i Mail -to echo \*(lqEOT\*(rq and return you to the Shell. When the user you sent mail -to next logs in, he will receive the message: -.(l -You have mail. -.)l -to alert him to the existence of your message. -.pp -If, while you are composing the message -you decide that you do not wish to send it after all, you can -abort the letter with a \s-2RUBOUT\s0. Typing a single \s-2RUBOUT\s0 -causes -.i Mail -to print -.(l -(Interrupt -- one more to kill letter) -.)l -Typing a second -\s-2RUBOUT\s0 causes -.i Mail -to save your partial letter on the file -.q dead.letter -in your home directory and abort the letter. -Once you have -sent mail to someone, there is no way to undo the act, so be -careful. -.pp -The message your recipient reads will consist of the message you -typed, preceded by a line telling who sent the message (your login name) -and the date and time it -was sent. -.pp -If you want to send the same message to several other people, you can list -their login names on the command line. -Thus, -.(l -% Mail sam bob john -Tuition fees are due next Friday. Don't forget!! - -EOT -% -.)l -will send the reminder to sam, bob, and john. -.pp -If, when you log in, you see the message, -.(l -You have mail. -.)l -you can read the mail by typing simply: -.(l -% Mail -.)l -.i Mail -will respond by typing its version number and date and then listing -the messages you have waiting. Then it will type a prompt and await -your command. The messages are assigned numbers starting with 1 \*- you -refer to the messages with these numbers. -.i Mail -keeps track of which messages are -.i new -(have been sent since you last read your mail) and -.i read -(have been read by you). New messages have an -.b N -next to them in the header listing and old, but unread messages have -a -.b U -next to them. -.i Mail -keeps track of new/old and read/unread messages by putting a -header field called -.q Status -into your messages. -.pp -To look at a specific message, use the -.b type -command, which may be abbreviated to simply -.b t . -For example, if you had the following messages: -.(l -N 1 root Wed Sep 21 09:21 "Tuition fees" -N 2 sam Tue Sep 20 22:55 -.)l -you could examine the first message by giving the command: -.(l -type 1 -.)l -which might cause -.i Mail -to respond with, for example: -.(l -Message 1: -From root Wed Sep 21 09:21:45 1978 -Subject: Tuition fees -Status: R - -Tuition fees are due next Wednesday. Don't forget!! - -.)l -Many -.i Mail -commands that operate on messages take a message number as an -argument like the -.b type -command. For these commands, there is a notion of a current -message. When you enter the -.i Mail -program, the current message is initially the first one. Thus, -you can often omit the message number and use, for example, -.(l -t -.)l -to type the current message. As a further shorthand, you can type a message -by simply giving its message number. Hence, -.(l -1 -.)l -would type the first message. -.pp -Frequently, it is useful to read the messages in your mailbox in order, -one after another. You can read the next message in -.i Mail -by simply typing a newline. As a special case, you can type a newline -as your first command to -.i Mail -to type the first message. -.pp -If, after typing a message, you wish to immediately send a reply, -you can do so with the -.b reply -command. -.b Reply , -like -.b type , -takes a message number as an argument. -.i Mail -then begins a message addressed to the user who sent you the message. -You may then type in your letter in reply, followed by a -at the beginning of a line, as before. -.i Mail -will type EOT, then type the ampersand prompt to indicate its readiness -to accept another command. In our example, if, after typing the -first message, you wished to reply to it, you might give the command: -.(l -reply -.)l -.i Mail -responds by typing: -.(l -To: root -Subject: Re: Tuition fees -.)l -and waiting for you to enter your letter. -You are now in the message collection mode described at the beginning -of this section and -.i Mail -will gather up your message up to a control\-d. -Note that it copies the subject -header from the original message. This is useful in that correspondence -about a particular matter will tend to retain the same subject heading, -making it easy to recognize. If there are other header fields in -the message, the information found will also be used. -For example, if the letter had a -.q "To:" -header listing several recipients, -.i Mail -would arrange to send your replay to the same people as well. -Similarly, if the original message contained a -.q "Cc:" -(carbon copies to) field, -.i Mail -would send your reply to -.i those -users, too. -.i Mail -is careful, though, not too send the message to -.i you , -even if you appear in the -.q "To:" -or -.q "Cc:" -field, unless you ask to be included explicitly. See section 4 for more -details. -.pp -After typing in your letter, the dialog with -.i Mail -might look like the following: -.(l -reply -To: root -Subject: Tuition fees - -Thanks for the reminder -EOT -& -.)l -.pp -The -.b reply -command is especially useful for sustaining extended conversations -over the message system, with other -.q listening -users receiving copies of the conversation. The -.b reply -command can be abbreviated to -.b r . -.pp -Sometimes you will receive a message that has been sent to -several people and wish to reply -.i only -to the person who sent it. -.b Reply -with a capital -.b R -replies to a message, but sends a copy to the sender only. -.pp -If you wish, while reading your mail, to send a message to someone, -but not as a reply to one of your messages, you can send the message -directly with the -.b mail -command, which takes as arguments the names of the recipients you wish -to send to. For example, to send a message to -.q frank, -you would do: -.(l -mail frank -This is to confirm our meeting next Friday at 4. -EOT -& -.)l -The -.b mail -command can be abbreviated to -.b m . -.pp -Normally, each message you receive is saved in the file -.i mbox -in your login directory at the time you leave -.i Mail . -Often, -however, you will not want to save a particular message you -have received because it is only of passing interest. To avoid -saving a message in -.i mbox -you can delete it using the -.b delete -command. In our example, -.(l -delete 1 -.)l -will prevent -.i Mail -from saving message 1 (from root) in -.i mbox . -In addition to not saving deleted messages, -.i Mail -will not let -you type them, either. The effect is to make the message disappear -altogether, along with its number. The -.b delete -command can be abbreviated to simply -.b d . -.pp -Many features of -.i Mail -can be tailored to your liking with the -.b set -command. The -.b set -command has two forms, depending on whether you are setting -a -.i binary -option or a -.i valued -option. -Binary options are either on or off. For example, the -.q ask -option informs -.i Mail -that each time you send a message, you want it to prompt you for -a subject header, to be included in the message. -To set the -.q ask -option, you would type -.(l -set ask -.)l -.pp -Another useful -.i Mail -option is -.q hold. -Unless told otherwise, -.i Mail -moves the messages from your system mailbox to the file -.i mbox -in your home directory when you leave -.i Mail . -If you want -.i Mail -to keep your letters in the system mailbox instead, you can set the -.q hold -option. -.pp -Valued options are values which -.i Mail -uses to adapt to your tastes. For example, the -.q SHELL -option tells -.i Mail -which shell you like to use, and is specified by -.(l -set SHELL=/bin/csh -.)l -for example. Note that no spaces are allowed in -.q "SHELL=/bin/csh." -A complete list of the -.i Mail -options appears in section 5. -.pp -Another important valued option is -.q crt. -If you use a fast video terminal, you will find that when you -print long messages, they fly by too quickly for you to read them. -With the -.q crt -option, you can make -.i Mail -print any message larger than a given number of lines by sending -it through a paging program. This program is specified by the -valued option \fBPAGER\fP. -If \fBPAGER\fP is not set, a default paginator is used. -For example, most CRT users with 24-line screens should do: -.(l -set crt=24 -.)l -to paginate messages that will not fit on their screens. -In the default state, \fImore\fP (default paginator) prints a screenful of -information, then types --More--. Type a space to see the next screenful. -.pp -Another adaptation to user needs that -.i Mail -provides is that of -.i aliases . -An alias is simply a name which stands for one or more -real user names. -.i Mail -sent to an alias is really sent to the list of real users -associated with it. For example, an alias can be defined for the -members of a project, so that you can send mail to the whole project -by sending mail to just a single name. The -.b alias -command in -.i Mail -defines an alias. Suppose that the users in a project are -named Sam, Sally, Steve, and Susan. To define an alias called -.q project -for them, you would use the -.i Mail -command: -.(l -alias project sam sally steve susan -.)l -The -.b alias -command can also be used to provide a convenient name for someone -whose user name is inconvenient. For example, if a user named -.q "Bob Anderson" -had the login name -.q anderson," -you might want to use: -.(l -alias bob anderson -.)l -so that you could send mail to the shorter name, -.q bob. -.pp -While the -.b alias -and -.b set -commands allow you to customize -.i Mail , -they have the drawback that they must be retyped each time you enter -.i Mail . -To make them more convenient to use, -.i Mail -always looks for two files when it is invoked. It first reads -a system wide file -.q /etc/mail.rc, -then a user specific file, -.q .mailrc, -which is found in the user's home directory. -The system wide file -is maintained by the system administrator and -contains -.b set -commands that are applicable to all users of the system. -The -.q .mailrc -file is usually used by each user to set options the way he likes -and define individual aliases. -For example, my .mailrc file looks like this: -.(l -set ask nosave SHELL=/bin/csh -.)l -As you can see, it is possible to set many options in the -same -.b set -command. The -.q nosave -option is described in section 5. -.pp -Mail aliasing is implemented -at the system-wide level -by the mail delivery -system -.i sendmail . -These aliases are stored in the file /usr/lib/aliases and are -accessible to all users of the system. -The lines in /usr/lib/aliases are of -the form: -.(l -alias: name\*<1\*>, name\*<2\*>, name\*<3\*> -.)l -where -.i alias -is the mailing list name and the -.i name\* -are the members of the list. Long lists can be continued onto the next -line by starting the next line with a space or tab. Remember that you -must execute the shell command -.i newaliases -after editing /usr/lib/aliases since the delivery system -uses an indexed file created by -.i newaliases . -.pp -We have seen that -.i Mail -can be invoked with command line arguments which are people -to send the message to, or with no arguments to read mail. -Specifying the -.rb \-f -flag on the command line causes -.i Mail -to read messages from a file other than your system mailbox. -For example, if you have a collection of messages in -the file -.q letters -you can use -.i Mail -to read them with: -.(l -% Mail \-f letters -.)l -You can use all -the -.i Mail -commands described in this document to examine, modify, or delete -messages from your -.q letters -file, which will be rewritten when you leave -.i Mail -with the -.b quit -command described below. -.pp -Since mail that you read is saved in the file -.i mbox -in your home directory by default, you can read -.i mbox -in your home directory by using simply -.(l -% Mail \-f -.)l -.pp -Normally, messages that you examine using the -.b type -command are saved in the file -.q mbox -in your home directory if you leave -.i Mail -with the -.b quit -command described below. -If you wish to retain a message in your system mailbox -you can use the -.b preserve -command to tell -.i Mail -to leave it there. -The -.b preserve -command accepts a list of message numbers, just like -.b type -and may be abbreviated to -.b pre . -.pp -Messages in your system mailbox that you do not examine are -normally retained in your system mailbox automatically. -If you wish to have such a message saved in -.i mbox -without reading it, you may use the -.b mbox -command to have them so saved. For example, -.(l -mbox 2 -.)l -in our example would cause the second message (from sam) -to be saved in -.i mbox -when the -.b quit -command is executed. -.b Mbox -is also the way to direct messages to your -.i mbox -file if you have set the -.q hold -option described above. -.b Mbox -can be abbreviated to -.b mb . -.pp -When you have perused all the messages of interest, you can leave -.i Mail -with the -.b quit -command, which saves the messages you have typed but not -deleted in the file -.i mbox -in your login directory. Deleted messages are discarded irretrievably, -and messages left untouched are preserved in your system mailbox so -that you will see them the next time you type: -.(l -% Mail -.)l -The -.b quit -command can be abbreviated to simply -.b q . -.pp -If you wish for some reason to leave -.i Mail -quickly without altering either your system mailbox or -.i mbox , -you can type the -.b x -command (short for -.b exit ), -which will immediately return you to the Shell without changing anything. -.pp -If, instead, you want to execute a Shell command without leaving -.i Mail , -you -can type the command preceded by an exclamation point, just as in the -text editor. Thus, for instance: -.(l -!date -.)l -will print the current date without leaving -.i Mail . -.pp -Finally, the -.b help -command is available to print out a brief summary of the -.i Mail -commands, using only the single character command abbreviations. diff --git a/usr.bin/mail/USD.doc/mail3.nr b/usr.bin/mail/USD.doc/mail3.nr deleted file mode 100644 index 8b133ef39b8..00000000000 --- a/usr.bin/mail/USD.doc/mail3.nr +++ /dev/null @@ -1,133 +0,0 @@ -.\" Copyright (c) 1980, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)mail3.nr 8.1 (Berkeley) 6/8/93 -.\" -.sh 1 "Maintaining folders" -.pp -.i Mail -includes a simple facility for maintaining groups of messages together -in folders. This section describes this facility. -.pp -To use the folder facility, you must tell -.i Mail -where you wish to keep your folders. Each folder of messages will -be a single file. For convenience, all of your folders are kept in -a single directory of your choosing. To tell -.i Mail -where your folder directory is, put a line of the form -.(l -set folder=letters -.)l -in your -.i .mailrc -file. If, as in the example above, your folder directory does not -begin with a `/,' -.i Mail -will assume that your folder directory is to be found starting from -your home directory. Thus, if your home directory is -.b /home/person -the above example told -.i Mail -to find your folder directory in -.b /home/person/letters . -.pp -Anywhere a file name is expected, you can use a folder name, preceded -with `+.' For example, to put a message into a folder with the -.b save -command, you can use: -.(l -save +classwork -.)l -to save the current message in the -.i classwork -folder. If the -.i classwork -folder does not yet exist, it will be created. Note that messages -which are saved with the -.b save -command are automatically removed from your system mailbox. -.pp -In order to make a copy of a message in a folder without causing -that message to be removed from your system mailbox, use the -.b copy -command, which is identical in all other respects to the -.b save -command. For example, -.(l -copy +classwork -.)l -copies the current message into the -.i classwork -folder and leaves a copy in your system mailbox. -.pp -The -.b folder -command -can be used to direct -.i Mail -to the contents of a different folder. -For example, -.(l -folder +classwork -.)l -directs -.i Mail -to read the contents of the -.i classwork -folder. All of the commands that you can use on your system -mailbox are also applicable to folders, including -.b type , -.b delete , -and -.b reply . -To inquire which folder you are currently editing, use simply: -.(l -folder -.)l -.pp -To list your current set of folders, use the -.b folders -command. -.pp -To start -.i Mail -reading one of your folders, you can use the -.b \-f -option described in section 2. For example: -.(l -% Mail \-f +classwork -.)l -will cause -.i Mail -to read your -.i classwork -folder without looking at your system mailbox. diff --git a/usr.bin/mail/USD.doc/mail4.nr b/usr.bin/mail/USD.doc/mail4.nr deleted file mode 100644 index 1a1e0469fab..00000000000 --- a/usr.bin/mail/USD.doc/mail4.nr +++ /dev/null @@ -1,437 +0,0 @@ -.\" Copyright (c) 1980, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)mail4.nr 8.1 (Berkeley) 6/8/93 -.\" -.bp -.sh 1 "More about sending mail" -.sh 2 "Tilde escapes" -.pp -While typing in a message to be sent to others, it is often -useful to be able to invoke the text editor on the partial message, -print the message, execute a shell command, or do some other -auxiliary function. -.i Mail -provides these capabilities through -.i "tilde escapes" , -which consist of a tilde (~) at the beginning of a line, followed by -a single character which indicates the function to be performed. For -example, to print the text of the message so far, use: -.(l -~p -.)l -which will print a line of dashes, the recipients of your message, and -the text of the message so far. -Since -.i Mail -requires two consecutive \s-2RUBOUT\s0's to abort a letter, you -can use a single \s-2RUBOUT\s0 to abort the output of ~p or any other -~ escape without killing your letter. -.pp -If you are dissatisfied with the message as -it stands, you can invoke the text editor on it using the escape -.(l -~e -.)l -which causes the message to be copied into a temporary file and an -instance of the editor to be spawned. After modifying the message to -your satisfaction, write it out and quit the editor. -.i Mail -will respond -by typing -.(l -(continue) -.)l -after which you may continue typing text which will be appended to your -message, or type to end the message. -A standard text editor is provided by -.i Mail . -You can override this default by setting the valued option -.q EDITOR -to something else. For example, you might prefer: -.(l -set EDITOR=/usr/bin/ex -.)l -.pp -Many systems offer a screen editor as an alternative to the standard -text editor, such as the -.i vi -editor from UC Berkeley. -To use the screen, or -.i visual -editor, on your current message, you can use the escape, -.(l -~v -.)l -~v works like ~e, except that the screen editor is invoked instead. -A default screen editor is defined by -.i Mail . -If it does not suit you, you can set the valued option -.q VISUAL -to the path name of a different editor. -.pp -It is often useful to be able to include the contents of some -file in your message; the escape -.(l -~r filename -.)l -is provided for this purpose, and causes the named file to be appended -to your current message. -.i Mail -complains if the file doesn't exist -or can't be read. If the read is successful, the number of lines and -characters appended to your message is printed, after which you may continue -appending text. The filename may contain shell metacharacters like * and ? -which are expanded according to the conventions of your shell. -.pp -As a special case of ~r, the escape -.(l -~d -.)l -reads in the file -.q dead.letter -in your home directory. This is often useful since -.i Mail -copies the text -of your message there when you abort a message with \s-2RUBOUT\s0. -.pp -To save the current text of your message on a file you may use the -.(l -~w filename -.)l -escape. -.i Mail -will print out the number of lines and characters written -to the file, after which you may continue appending text to your message. -Shell metacharacters may be used in the filename, as in ~r and are expanded -with the conventions of your shell. -.pp -If you are sending mail from within -.i Mail's -command mode -you can read a message sent to you into the message -you are constructing with the escape: -.(l -~m 4 -.)l -which will read message 4 into the current message, shifted right by -one tab stop. You can name any non-deleted message, or list of messages. -Messages can also be forwarded without shifting by a tab stop with ~f. -This is the usual way to forward a message. -.pp -If, in the process of composing a message, you decide to add additional -people to the list of message recipients, you can do so with the escape -.(l -~t name1 name2 ... -.)l -You may name as few or many additional recipients as you wish. Note -that the users originally on the recipient list will still receive -the message; you cannot remove someone from the recipient -list with ~t. -.pp -If you wish, you can associate a subject with your message by using the -escape -.(l -~s Arbitrary string of text -.)l -which replaces any previous subject with -.q "Arbitrary string of text." -The subject, if given, is sent near the -top of the message prefixed with -.q "Subject:" -You can see what the message will look like by using ~p. -.pp -For political reasons, one occasionally prefers to list certain -people as recipients of carbon copies of a message rather than -direct recipients. The escape -.(l -~c name1 name2 ... -.)l -adds the named people to the -.q "Cc:" -list, similar to ~t. -Again, you can execute ~p to see what the message will look like. -.pp -The escape -.(l -~b name1 name2 ... -.)l -adds the named people to the -.q "Cc:" -list, but does not make the names visible in the -.q "Cc:" -line ("blind" carbon copy). -.pp -The recipients of the message together constitute the -.q "To:" -field, the subject the -.q "Subject:" -field, and the carbon copies the -.q "Cc:" -field. If you wish to edit these in ways impossible with the ~t, ~s, ~c -and ~b escapes, you can use the escape -.(l -~h -.)l -which prints -.q "To:" -followed by the current list of recipients and leaves the cursor -(or printhead) at the end of the line. If you type in ordinary -characters, they are appended to the end of the current list of -recipients. You can also use your erase character to erase back into -the list of recipients, or your kill character to erase them altogether. -Thus, for example, if your erase and kill characters are the standard -(on printing terminals) # and @ symbols, -.(l -~h -To: root kurt####bill -.)l -would change the initial recipients -.q "root kurt" -to -.q "root bill." -When you type a newline, -.i Mail -advances to the -.q "Subject:" -field, where the same rules apply. Another newline brings you to -the -.q "Cc:" -field, which may be edited in the same fashion. Another newline -brings you to the -.q "Bcc:" -("blind" carbon copy) field, which follows the same rules as the "Cc:" -field. Another newline -leaves you appending text to the end of your message. You can use -~p to print the current text of the header fields and the body -of the message. -.pp -To effect a temporary escape to the shell, the escape -.(l -~!command -.)l -is used, which executes -.i command -and returns you to mailing mode without altering the text of -your message. If you wish, instead, to filter the body of your -message through a shell command, then you can use -.(l -~|command -.)l -which pipes your message through the command and uses the output -as the new text of your message. If the command produces no output, -.i Mail -assumes that something is amiss and retains the old version -of your message. A frequently-used filter is the command -.i fmt , -designed to format outgoing mail. -.pp -To effect a temporary escape to -.i Mail -command mode instead, you can use the -.(l -~:\fIMail command\fP -.)l -escape. This is especially useful for retyping the message you are -replying to, using, for example: -.(l -~:t -.)l -It is also useful for setting options and modifying aliases. -.pp -If you wish abort the current message, you can use the escape -.(l -~q -.)l -This will terminate the current message and return you to the -shell (or \fIMail\fP if you were using the \fBmail\fP command). -If the \fBsave\fP option is set, the message will be copied -to the file -.q dead.letter -in your home directory. -.pp -If you wish (for some reason) to send a message that contains -a line beginning with a tilde, you must double it. Thus, for example, -.(l -~~This line begins with a tilde. -.)l -sends the line -.(l -~This line begins with a tilde. -.)l -.pp -Finally, the escape -.(l -~? -.)l -prints out a brief summary of the available tilde escapes. -.pp -On some terminals (particularly ones with no lower case) -tilde's are difficult to type. -.i Mail -allows you to change the escape character with the -.q escape -option. For example, I set -.(l -set escape=] -.)l -and use a right bracket instead of a tilde. If I ever need to -send a line beginning with right bracket, I double it, just as for ~. -Changing the escape character removes the special meaning of ~. -.sh 2 "Network access" -.pp -This section describes how to send mail to people on other machines. -Recall that sending to a plain login name sends mail to that person -on your machine. If your machine is directly (or sometimes, even, -indirectly) connected to the Arpanet, you can send messages to people -on the Arpanet using a name of the form -.(l -name@host.domain -.)l -where -.i name -is the login name of the person you're trying to reach, -.i host -is the name of the machine on the Arpanet, -and -.i domain -is the higher-level scope within which the hostname is known, e.g. EDU (for educational -institutions), COM (for commercial entities), GOV (for governmental agencies), -ARPA for many other things, BITNET or CSNET for those networks. -.pp -If your recipient logs in on a machine connected to yours by -UUCP (the Bell Laboratories supplied network that communicates -over telephone lines), sending mail can be a bit more complicated. -You must know the list of machines through which your message must -travel to arrive at his site. So, if his machine is directly connected -to yours, you can send mail to him using the syntax: -.(l -host!name -.)l -where, again, -.i host -is the name of the machine and -.i name -is the login name. -If your message must go through an intermediary machine first, you -must use the syntax: -.(l -intermediary!host!name -.)l -and so on. It is actually a feature of UUCP that the map of all -the systems in the network is not known anywhere (except where people -decide to write it down for convenience). Talk to your system administrator -about good ways to get places; the -.i uuname -command will tell you systems whose names are recognized, but not which -ones are frequently called or well-connected. -.pp -When you use the -.b reply -command to respond to a letter, there is a problem of figuring out the -names of the users in the -.q "To:" -and -.q "Cc:" -lists -.i "relative to the current machine" . -If the original letter was sent to you by someone on the local machine, -then this problem does not exist, but if the message came from a remote -machine, the problem must be dealt with. -.i Mail -uses a heuristic to build the correct name for each user relative -to the local machine. So, when you -.b reply -to remote mail, the names in the -.q "To:" -and -.q "Cc:" -lists may change somewhat. -.sh 2 "Special recipients" -.pp -As described previously, you can send mail to either user names or -.b alias -names. It is also possible to send messages directly to files or to -programs, using special conventions. If a recipient name has a -`/' in it or begins with a `+', it is assumed to be the -path name of a file into which -to send the message. If the file already exists, the message is -appended to the end of the file. If you want to name a file in -your current directory (ie, one for which a `/' would not usually -be needed) you can precede the name with `./' -So, to send mail to the file -.q memo -in the current directory, you can give the command: -.(l -% Mail ./memo -.)l -If the name begins with a `+,' it is expanded into the full path name -of the folder name in your folder directory. -This ability to send mail to files can be used for a variety of -purposes, such as maintaining a journal and keeping a record of -mail sent to a certain group of users. The second example can be -done automatically by including the full pathname of the record -file in the -.b alias -command for the group. Using our previous -.b alias -example, you might give the command: -.(l -alias project sam sally steve susan /usr/project/mail_record -.)l -Then, all mail sent to "project" would be saved on the file -.q /usr/project/mail_record -as well as being sent to the members of the project. This file -can be examined using -.i "Mail \-f" . -.pp -It is sometimes useful to send mail directly to a program, for -example one might write a project billboard program and want to access -it using -.i Mail . -To send messages to the billboard program, one can send mail -to the special name `|billboard' for example. -.i Mail -treats recipient names that begin with a `|' as a program to send -the mail to. An -.b alias -can be set up to reference a `|' prefaced name if desired. -.i Caveats : -the shell treats `|' specially, so it must be quoted on the command -line. Also, the `| program' must be presented as a single argument to -mail. The safest course is to surround the entire name with double -quotes. This also applies to usage in the -.b alias -command. For example, if we wanted to alias `rmsgs' to `rmsgs \-s' -we would need to say: -.(l -alias rmsgs "| rmsgs -s" -.)l diff --git a/usr.bin/mail/USD.doc/mail5.nr b/usr.bin/mail/USD.doc/mail5.nr deleted file mode 100644 index 011630308e7..00000000000 --- a/usr.bin/mail/USD.doc/mail5.nr +++ /dev/null @@ -1,1042 +0,0 @@ -.\" Copyright (c) 1980, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)mail5.nr 8.1 (Berkeley) 6/8/93 -.\" $FreeBSD: src/usr.bin/mail/USD.doc/mail5.nr,v 1.4 2000/11/29 10:56:59 ru Exp $ -.\" -.bp -.sh 1 "Additional features" -.pp -This section describes some additional commands useful for -reading your mail, setting options, and handling lists of messages. -.sh 2 "Message lists" -.pp -Several -.i Mail -commands accept a list of messages as an argument. -Along with -.b type -and -.b delete , -described in section 2, -there is the -.b from -command, which prints the message headers associated with the -message list passed to it. -The -.b from -command is particularly useful in conjunction with some of the -message list features described below. -.pp -A -.i "message list" -consists of a list of message numbers, ranges, and names, -separated by spaces or tabs. Message numbers may be either -decimal numbers, which directly specify messages, or one of the -special characters -.q \(ua -.q "." -or -.q "$" -to specify the first relevant, current, or last -relevant message, respectively. -.i Relevant -here means, for most commands -.q "not deleted" -and -.q "deleted" -for the -.b undelete -command. -.pp -A range of messages consists of two message numbers (of the form -described in the previous paragraph) separated by a dash. -Thus, to print the first four messages, use -.(l -type 1\-4 -.)l -and to print all the messages from the current message to the last -message, use -.(l -type .\-$ -.)l -.pp -A -.i name -is a user name. The user names given in the message list are -collected together and each message selected by other means -is checked to make sure it was sent by one of the named users. -If the message consists entirely of user names, then every -message sent by one of those users that is -.i relevant -(in the sense described earlier) -is selected. Thus, to print every message sent to you by -.q root, -do -.(l -type root -.)l -.pp -As a shorthand notation, you can specify simply -.q * -to get every -.i relevant -(same sense) -message. Thus, -.(l -type * -.)l -prints all undeleted messages, -.(l -delete * -.)l -deletes all undeleted messages, and -.(l -undelete * -.)l -undeletes all deleted messages. -.pp -You can search for the presence of a word in subject lines with -.b / . -For example, to print the headers of all messages that contain the -word -.q PASCAL, -do: -.(l -from /pascal -.)l -Note that subject searching ignores upper/lower case differences. -.sh 2 "List of commands" -.pp -This section describes all the -.i Mail -commands available when -receiving mail. -.ip "\fB\-\fP\ \ " -The -.rb \- -command goes to the previous message and prints it. The -.rb \- -command may be given a decimal number -.i n -as an argument, in which case the -.i n th -previous message is gone to and printed. -.ip "\fB?\fP\ \ " -Prints a brief summary of commands. -.ip "\fB!\fP\ \ " -Used to preface a command to be executed by the shell. -.ip "\fBPrint\fP\ \ " -Like -.b print , -but also print out ignored header fields. See also -\fBprint\fP, \fBignore\fP and \fBretain\fP. -\fBPrint\fP can be abbreviated to \fBP\fP. -.ip "\fBReply\fP or \fBRespond\fP\ \ " -Note the capital \fBR\fP in the name. -Frame a reply to a one or more messages. -The reply (or replies if you are using this on multiple messages) -will be sent ONLY to the person who sent you the message -(respectively, the set of people who sent the messages you are -replying to). -You can -add people using the \fB~t\fP, \fB~c\fP and \fB~b\fP -tilde escapes. The subject in your reply is formed by prefacing the -subject in the original message with -.q "Re:" -unless it already began thus. -If the original message included a -.q "reply-to" -header field, the reply will go -.i only -to the recipient named by -.q "reply-to." -You type in your message using the same conventions available to you -through the -.b mail -command. -The -.b Reply -command is especially useful for replying to messages that were sent -to enormous distribution groups when you really just want to -send a message to the originator. Use it often. -\fBReply\fP (and \fBRespond\fP) can be abbreviated to \fBR\fP. -.ip "\fBType\fP\ \ " -Identical to the -.b Print -command. -\fBType\fP can be abbreviated to \fBT\fP. -.ip "\fBalias\fP\ \ " -Define a name to stand for a set of other names. -This is used when you want to send messages to a certain -group of people and want to avoid retyping their names. -For example -.(l -alias project john sue willie kathryn -.)l -creates an alias -.i project -which expands to the four people John, Sue, Willie, and Kathryn. -If no arguments are given, all currently-defined aliases are printed. -If one argument is given, that alias is printed (if it exists). -\fBAlias\fP can be abbreviated to \fBa\fP. -.ip "\fBalternates\fP\ \ " -If you have accounts on several machines, you may find it convenient -to use the /usr/lib/aliases on all the machines except one to direct -your mail to a single account. -The -.b alternates -command is used to inform -.i Mail -that each of these other addresses is really -.i you . -.i Alternates -takes a list of user names and remembers that they are all actually you. -When you -.b reply -to messages that were sent to one of these alternate names, -.i Mail -will not bother to send a copy of the message to this other address (which -would simply be directed back to you by the alias mechanism). -If -.i alternates -is given no argument, it lists the current set of alternate names. -.b Alternates -is usually used in the .mailrc file. -\fBAlternates\fP can be abbreviated to \fBalt\fP. -.ip "\fBchdir\fP\ \ " -The -.b chdir -command allows you to change your current directory. -.b Chdir -takes a single argument, which is taken to be the pathname of -the directory to change to. If no argument is given, -.b chdir -changes to your home directory. -\fBChdir\fP can be abbreviated to \fBc\fP. -.ip "\fBcopy\fP\ \ " -The -.b copy -command does the same thing that -.b save -does, except that it does not mark the messages it is used on -for deletion when you quit. -\fBCopy\fP can be abbreviated to \fBco\fP. -.ip "\fBdelete\fP\ \ " -Deletes a list of messages. Deleted messages can be reclaimed -with the -.b undelete -command. -\fBDelete\fP can be abbreviated to \fBd\fP. -.ip "\fBdp\fP or \fBdt\fP\ \ " -These -commands delete the current message and print the next message. -They are useful for quickly reading and disposing of mail. -If there is no next message, \fImail\fP says ``at EOF.'' -.ip "\fBedit\fP\ \ " -To edit individual messages using the text editor, the -.b edit -command is provided. The -.b edit -command takes a list of messages as described under the -.b type -command and processes each by writing it into the file -Message\c -.i x -where -.i x -is the message number being edited and executing the text editor on it. -When you have edited the message to your satisfaction, write the message -out and quit, upon which -.i Mail -will read the message back and remove the file. -.b Edit -can be abbreviated to -.b e . -.ip "\fBelse\fP\ \ " -Marks the end of the then-part of an -.b if -statement and the beginning of the -part to take effect if the condition of the -.b if -statement is false. -.ip "\fBendif\fP\ \ " -Marks the end of an -.b if -statement. -.ip "\fBexit\fP or \fBxit\fP\ \ " -Leave -.i Mail -without updating the system mailbox or the file your were reading. -Thus, if you accidentally delete several messages, you can use -.b exit -to avoid scrambling your mailbox. -\fBExit\fP can be abbreviated to \fBex\fP or \fBx\fP. -.ip "\fBfile\fP\ \ " -The same as -.b folder . -\fBFile\fP can be abbreviated to \fBfi\fP. -.ip "\fBfolders\fP\ \ " -List the names of the folders in your folder directory. -.ip "\fBfolder\fP\ \ " -The -.b folder -command switches to a new mail file or folder. With no arguments, it -tells you which file you are currently reading. If you give -it an argument, it will write out changes (such as deletions) -you have made in the current file and read the new file. -Some special conventions are recognized for the name: -.(b -.TS -center; -c c -l a. -Name Meaning -_ -# Previous file read -% Your system mailbox -%name \fIName\fP's system mailbox -& Your ~/mbox file -+folder A file in your folder directory -.TE -.)b -\fBFolder\fP can be abbreviated to \fBfo\fP. -.ip "\fBfrom\fP\ \ " -The -.b from -command takes a list of messages and prints out the header lines for each one; -hence -.(l -from joe -.)l -is the easy way to display all the message headers from \*(lqjoe.\*(rq -\fBFrom\fP can be abbreviated to \fBf\fP. -.ip "\fBheaders\fP\ \ " -When you start up -.i Mail -to read your mail, it lists the message headers that you have. -These headers tell you who each message is from, when they were -received, how many lines and characters each message is, and the -.q "Subject:" -header field of each message, if present. In addition, -.i Mail -tags the message header of each message that has been the object -of the -.b preserve -command with a -.q P. -Messages that have been -.b saved -or -.b written -are flagged with a -.q *. -Finally, -.b deleted -messages are not printed at all. If you wish to reprint the current -list of message headers, you can do so with the -.b headers -command. The -.b headers -command (and thus the initial header listing) -only lists the first so many message headers. -The number of headers listed depends on the speed of your -terminal. -This can be overridden by specifying the number of headers you -want with the -.i window -option. -.i Mail -maintains a notion of the current -.q window -into your messages for the purposes of printing headers. -Use the -.b z -command to move forward and back a window. -You can move -.i Mail's -notion of the current window directly to a particular message by -using, for example, -.(l -headers 40 -.)l -to move -.i Mail's -attention to the messages around message 40. -If a ``+'' argument is given, then the next screenful of message headers is -printed, and if a ``\-'' argument is given, the previous screenful of message -headers is printed. -\fBHeaders\fP can be abbreviated to \fBh\fP. -.ip "\fBhelp\fP\ \ " -Print a brief and usually out of date help message about the commands -in -.i Mail . -The -.i man -page for -.i mail -is usually more up-to-date than either the help message or this manual. -It is also a synonym for \fB?\fP. -.ip "\fBhold\fP\ \ " -Arrange to hold a list of messages in the system mailbox, instead -of moving them to the file -.i mbox -in your home directory. If you set the binary option -.i hold , -this will happen by default. -It does not override the \fBdelete\fP command. -\fBHold\fP can be abbreviated to \fBho\fP. -.ip "\fBif\fP\ \ " -Commands in your -.q .mailrc -file can be executed conditionally depending on whether you are -sending or receiving mail with the -.b if -command. For example, you can do: -.(l -if receive - \fIcommands\fP... -endif -.)l -An -.b else -form is also available: -.(l -if send - \fIcommands\fP... -else - \fIcommands\fP... -endif -.)l -Note that the only allowed conditions are -.b receive -and -.b send . -.ip "\fBignore\fP \ \ " -.b N.B.: -.i Ignore -has been superseded by -.i retain. -.br -Add the list of header fields named to the -.i "ignore list" . -Header fields in the ignore list are not printed on your -terminal when you print a message. This allows you to suppress -printing of certain machine-generated header fields, such as -.i Via -which are not usually of interest. The -.b Type -and -.b Print -commands can be used to print a message in its entirety, including -ignored fields. -If -.b ignore -is executed with no arguments, it lists the current set of ignored fields. -.ip "\fBlist\fP\ \ " -List the valid -.i Mail -commands. -\fBList\fP can be abbreviated to \fBl\fP. -.\".ip \fBlocal\fP -.\"Define a list of local names for this host. This command is useful -.\"when the host is known by more than one name. Names in the list -.\"may be qualified be the domain of the host. The first name on the local -.\"list is the -.\".i distinguished -.\"name of the host. -.\"The names on the local list are used by -.\".i Mail -.\"to decide which addresses are local to the host. -.\"For example: -.\".(l -.\"local ucbarpa.BERKELEY.ARPA arpa.BERKELEY.ARPA \\ -.\" arpavax.BERKELEY.ARPA r.BERKELEY.ARPA \\ -.\" ucb-arpa.ARPA -.\".)l -.\"From this list we see that -.\".i "fred@ucbarpa.BERKELEY.ARPA", -.\".i "harold@arpa.BERKELEY", -.\"and -.\".i "larry@r" -.\"are all addresses of users on the local host. -.\"The -.\".b local -.\"command is usually not used be general users since it is designed for -.\"local configuration; it is usually found in the file /etc/mail.rc. -.ip "\fBmail\fP\ \ " -Send mail to one or more people. If you have the -.i ask -option set, -.i Mail -will prompt you for a subject to your message. Then you -can type in your message, using tilde escapes as described in -section 4 to edit, print, or modify your message. To signal your -satisfaction with the message and send it, type control-d at the -beginning of a line, or a . alone on a line if you set the option -.i dot . -To abort the message, type two interrupt characters (\s-2RUBOUT\s0 -by default) in a row or use the -.b ~q -escape. -The \fBmail\fP command can be abbreviated to \fBm\fP. -.ip "\fBmbox\fP\ \ " -Indicate that a list of messages be sent to -.i mbox -in your home directory when you quit. This is the default -action for messages if you do -.i not -have the -.i hold -option set. -.ip "\fBnext\fP or \fB+\fP\ \ " -The -.b next -command goes to the next message and types it. If given a message list, -.b next -goes to the first such message and types it. Thus, -.(l -next root -.)l -goes to the next message sent by -.q root -and types it. The -.b next -command can be abbreviated to simply a newline, which means that one -can go to and type a message by simply giving its message number or -one of the magic characters -.q "^" -.q "." -or -.q "$". -Thus, -.(l -\&. -.)l -prints the current message and -.(l -4 -.)l -prints message 4, as described previously. -\fBNext\fP can be abbreviated to \fBn\fP. -.ip "\fBpreserve\fP\ \ " -Same as -.b hold . -Cause a list of messages to be held in your system mailbox when you quit. -\fBPreserve\fP can be abbreviated to \fBpre\fP. -.ip "\fBprint\fP\ \ " -Print the specified messages. If the -.b crt -variable is set, messages longer than the number of lines it indicates -are paged through the command specified by the \fBPAGER\fP variable. -The \fBprint\fP command can be abbreviated to \fBp\fP. -.ip "\fBquit\fP\ \ " -Terminates the session, saving all undeleted, unsaved and unwritten messages -in the user's \fImbox\fP file in their login directory -(messages marked as having been read), preserving all -messages marked with \fBhold\fP or \fBpreserve\fP or never referenced -in their system mailbox. -Any messages that were deleted, saved, written or saved to \fImbox\fP are -removed from their system mailbox. -If new mail has arrived during the session, the message -``You have new mail'' is given. If given while editing a mailbox file -with the \fB\-f\fP flag, then the edit file is rewritten. -A return to the Shell is effected, unless the rewrite of edit file fails, -in which case the user can escape with the \fBexit\fP command. -\fBQuit\fP can be abbreviated to \fBq\fP. -.ip "\fBreply\fP or \fBrespond\fP\ \ " -Frame a reply to a single message. -The reply will be sent to the -person who sent you the message (to which you are replying), plus all -the people who received the original message, except you. You can -add people using the \fB~t\fP, \fB~c\fP and \fB~b\fP -tilde escapes. The subject in your reply is formed by prefacing the -subject in the original message with -.q "Re:" -unless it already began thus. -If the original message included a -.q "reply-to" -header field, the reply will go -.i only -to the recipient named by -.q "reply-to." -You type in your message using the same conventions available to you -through the -.b mail -command. -The \fBreply\fP (and \fBrespond\fP) command can be abbreviated to \fBr\fP. -.ip "\fBretain\fP\ \ " -Add the list of header fields named to the \fIretained list\fP. -Only the header fields in the retain list -are shown on your terminal when you print a message. -All other header fields are suppressed. -The -.b Type -and -.b Print -commands can be used to print a message in its entirety. -If -.b retain -is executed with no arguments, it lists the current set of -retained fields. -.ip "\fBsave\fP\ \ " -It is often useful to be able to save messages on related topics -in a file. The -.b save -command gives you the ability to do this. The -.b save -command takes as an argument a list of message numbers, followed by -the name of the file in which to save the messages. The messages -are appended to the named file, thus allowing one to keep several -messages in the file, stored in the order they were put there. -The filename in quotes, followed by the line -count and character count is echoed on the user's terminal. -An example of the -.b save -command relative to our running example is: -.(l -s 1 2 tuitionmail -.)l -.b Saved -messages are not automatically saved in -.i mbox -at quit time, nor are they selected by the -.b next -command described above, unless explicitly specified. -\fBSave\fP can be abbreviated to \fBs\fP. -.ip "\fBset\fP\ \ " -Set an option or give an option a value. Used to customize -.i Mail . -Section 5.3 contains a list of the options. Options can be -.i binary , -in which case they are -.i on -or -.i off , -or -.i valued . -To set a binary option -.i option -.i on , -do -.(l -set option -.)l -To give the valued option -.i option -the value -.i value , -do -.(l -set option=value -.)l -There must be no space before or after the ``='' sign. -If no arguments are given, all variable values are printed. -Several options can be specified in a single -.b set -command. -\fBSet\fP can be abbreviated to \fBse\fP. -.ip "\fBshell\fP\ \ " -The -.b shell -command allows you to -escape to the shell. -.b Shell -invokes an interactive shell and allows you to type commands to it. -When you leave the shell, you will return to -.i Mail . -The shell used is a default assumed by -.i Mail ; -you can override this default by setting the valued option -.q SHELL, -eg: -.(l -set SHELL=/bin/csh -.)l -\fBShell\fP can be abbreviated to \fBsh\fP. -.ip "\fBsize\fP\ \ " -Takes a message list and prints out the size in characters of each -message. -.ip "\fBsource\fP\ \ " -The -.b source -command reads -.i mail -commands from a file. It is useful when you are trying to fix your -.q .mailrc -file and you need to re-read it. -\fBSource\fP can be abbreviated to \fBso\fP. -.ip "\fBtop\fP\ \ " -The -.b top -command takes a message list and prints the first five lines -of each addressed message. -If you wish, you can change the number of lines that -.b top -prints out by setting the valued option -.q "toplines." -On a CRT terminal, -.(l -set toplines=10 -.)l -might be preferred. -\fBTop\fP can be abbreviated to \fBto\fP. -.ip "\fBtype\fP\ \ " -Same as \fBprint\fP. -Takes a message list and types out each message on the terminal. -The \fBtype\fP command can be abbreviated to \fBt\fP. -.ip "\fBundelete\fP \ \" -Takes a message list and marks each message as \fInot\fP -being deleted. -\fBUndelete\fP can be abbreviated to \fBu\fP. -.ip "\fBunread\fP\ \ " -Takes a message list and marks each message as -.i not -having been read. -\fBUnread\fP can be abbreviated to \fBU\fP. -.ip "\fBunset\fP\ \ " -Takes a list of option names and discards their remembered values; -the inverse of \fBset\fP . -.ip "\fBvisual\fP\ \ " -It is often useful to be able to invoke one of two editors, -based on the type of terminal one is using. To invoke -a display oriented editor, you can use the -.b visual -command. The operation of the -.b visual -command is otherwise identical to that of the -.b edit -command. -.ne 2v+\n(psu -.sp \n(psu -Both the -.b edit -and -.b visual -commands assume some default text editors. These default editors -can be overridden by the valued options -.q EDITOR -and -.q VISUAL -for the standard and screen editors. You might want to do: -.(l -set EDITOR=/usr/bin/ex VISUAL=/usr/bin/vi -.)l -\fBVisual\fP can be abbreviated to \fBv\fP. -.ip "\fBwrite\fP\ \ " -The -.b save -command always writes the entire message, including the headers, -into the file. If you want to write just the message itself, you -can use the -.b write -command. The -.b write -command has the same syntax as the -.b save -command, and can be abbreviated to simply -.b w . -Thus, we could write the second message by doing: -.(l -w 2 file.c -.)l -As suggested by this example, the -.b write -command is useful for such tasks as sending and receiving -source program text over the message system. -The filename in quotes, followed by the line -count and character count is echoed on the user's terminal. -.ip "\fBz\fP\ \ " -.i Mail -presents message headers in windowfuls as described under -the -.b headers -command. -You can move -.i Mail's -attention forward to the next window by giving the -.(l -z+ -.)l -command. Analogously, you can move to the previous window with: -.(l -z\- -.)l -.sh 2 "Custom options" -.pp -Throughout this manual, we have seen examples of binary and valued options. -This section describes each of the options in alphabetical order, including -some that you have not seen yet. -To avoid confusion, please note that the options are either -all lower case letters or all upper case letters. When I start a sentence -such as: -.q "Ask" -causes -.i Mail -to prompt you for a subject header, -I am only capitalizing -.q ask -as a courtesy to English. -.ip "\fBEDITOR\fP\ \ " -The valued option -.q EDITOR -defines the pathname of the text editor to be used in the -.b edit -command and ~e. If not defined, a standard editor is used. -.ip "\fBPAGER\fP\ \ " -Pathname of the program to use for paginating output when -it exceeds \fIcrt\fP lines. -A default paginator is used if this option is not defined. -.ip "\fBSHELL\fP\ \ " -The valued option -.q SHELL -gives the path name of your shell. This shell is used for the -.b ! -command and ~! escape. In addition, this shell expands -file names with shell metacharacters like * and ? in them. -.ip "\fBVISUAL\fP\ \ " -The valued option -.q VISUAL -defines the pathname of the screen editor to be used in the -.b visual -command -and ~v escape. A standard screen editor is used if you do not define one. -.ip "\fBappend\fP\ \ " -The -.q append -option is binary and -causes messages saved in -.i mbox -to be appended to the end rather than prepended. -Normally, \fIMail\fP will put messages in \fImbox\fP -in the same order that the system puts messages in your system mailbox. -By setting -.q append, -you are requesting that -.i mbox -be appended to regardless. It is in any event quicker to append. -.ip "\fBask\fP\ \ " -.q "Ask" -is a binary option which -causes -.i Mail -to prompt you for the subject of each message you send. -If you respond with simply a newline, no subject field will be sent. -.ip "\fBaskcc\fP\ \ " -.q Askcc -is a binary option which -causes you to be prompted for additional carbon copy recipients at the -end of each message. Responding with a newline shows your -satisfaction with the current list. -.ip "\fBautoprint\fP\ \ " -.q Autoprint -is a binary option which -causes the -.b delete -command to behave like -.b dp -\*- thus, after deleting a message, the next one will be typed -automatically. This is useful when quickly scanning and deleting -messages in your mailbox. -.ip "\fBcrt\fP \ \ " -The valued option -.q crt -is used as a threshold to determine how long a message must -be before -.b PAGER -is used to read it. -.ip "\fBdebug\fP \ \ " -The binary option -.q debug -causes debugging information to be displayed. Use of this -option is the same as using the \fB\-d\fP command line flag. -.ip "\fBdot\fP\ \ " -.q Dot -is a binary option which, if set, causes -.i Mail -to interpret a period alone on a line as the terminator -of the message you are sending. -.ip "\fBescape\fP\ \ " -To allow you to change the escape character used when sending -mail, you can set the valued option -.q escape. -Only the first character of the -.q escape -option is used, and it must be doubled if it is to appear as -the first character of a line of your message. If you change your escape -character, then ~ loses all its special meaning, and need no longer be doubled -at the beginning of a line. -.ip "\fBfolder\fP\ \ " -The name of the directory to use for storing folders of messages. -If this name begins with a `/' -.i Mail -considers it to be an absolute pathname; otherwise, the folder directory -is found relative to your home directory. -.ip "\fBhold\fP\ \ " -The binary option -.q hold -causes messages that have been read but not manually dealt with -to be held in the system mailbox. This prevents such messages from -being automatically swept into your \fImbox\fP file. -.ip "\fBignore\fP\ \ " -The binary option -.q ignore -causes \s-2RUBOUT\s0 characters from your terminal to be ignored and echoed -as @'s while you are sending mail. \s-2RUBOUT\s0 characters retain their -original meaning in -.i Mail -command mode. -Setting the -.q ignore -option is equivalent to supplying the -.b \-i -flag on the command line as described in section 6. -.ip "\fBignoreeof\fP\ \ " -An option related to -.q dot -is -.q ignoreeof -which makes -.i Mail -refuse to accept a control\-d as the end of a message. -.q Ignoreeof -also applies to -.i Mail -command mode. -.ip "\fBkeep\fP\ \ " -The -.q keep -option causes -.i Mail -to truncate your system mailbox instead of deleting it when it -is empty. This is useful if you elect to protect your mailbox, which -you would do with the shell command: -.(l -chmod 600 /var/mail/yourname -.)l -where -.i yourname -is your login name. If you do not do this, anyone can probably read -your mail, although people usually don't. -.ip "\fBkeepsave\fP\ \ " -When you -.b save -a message, -.i Mail -usually discards it when you -.b quit . -To retain all saved messages, set the -.q keepsave -option. -.ip "\fBmetoo\fP\ \ " -When sending mail to an alias, -.i Mail -makes sure that if you are included in the alias, that mail will not -be sent to you. This is useful if a single alias is being used by -all members of the group. If however, you wish to receive a copy of -all the messages you send to the alias, you can set the binary option -.q metoo. -.ip "\fBnoheader\fP\ \ " -The binary option -.q noheader -suppresses the printing of the version and headers when -.i Mail -is first invoked. Setting this option is the same as using -.b \-N -on the command line. -.ip "\fBnosave\fP\ \ " -Normally, -when you abort a message with two \s-2RUBOUTs\s0, -.i Mail -copies the partial letter to the file -.q dead.letter -in your home directory. Setting the binary option -.q nosave -prevents this. -.ip "\fBReplyall\fP\ \ " -Reverses the sense of -.i reply -and -.i Reply -commands. -.ip "\fBquiet\fP\ \ " -The binary option -.q quiet -suppresses the printing of the version when -.i Mail -is first invoked, -as well as printing the for example -.q "Message 4:" -from the -.b type -command. -.ip "\fBrecord\fP\ \ " -If you love to keep records, then the -valued option -.q record -can be set to the name of a file to save your outgoing mail. -Each new message you send is appended to the end of the file. -.ip "\fBscreen\fP\ \ " -When -.i Mail -initially prints the message headers, it determines the number to -print by looking at the speed of your terminal. The faster your -terminal, the more it prints. -The valued option -.q screen -overrides this calculation and -specifies how many message headers you want printed. -This number is also used for scrolling with the -.b z -command. -.ip "\fBsendmail\fP\ \ " -To use an alternate mail delivery system, set the -.q sendmail -option to the full pathname of the program to use. Note: this is not -for everyone! Most people should use the default delivery system. -.ip "\fBtoplines\fP\ \ " -The valued option -.q toplines -defines the number of lines that the -.q top -command will print out instead of the default five lines. -.ip "\fBverbose\fP\ \ " -The binary option "verbose" causes -.i Mail -to invoke sendmail with the -.b \-v -flag, which causes it to go into verbose mode and announce expansion -of aliases, etc. Setting the "verbose" option is equivalent to -invoking -.i Mail -with the -.b \-v -flag as described in section 6. diff --git a/usr.bin/mail/USD.doc/mail6.nr b/usr.bin/mail/USD.doc/mail6.nr deleted file mode 100644 index 0465a94135e..00000000000 --- a/usr.bin/mail/USD.doc/mail6.nr +++ /dev/null @@ -1,125 +0,0 @@ -.\" Copyright (c) 1980, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)mail6.nr 8.1 (Berkeley) 6/8/93 -.\" -.bp -.sh 1 "Command line options" -.pp -This section describes command line options for -.i Mail -and what they are used for. -.ip \-N -Suppress the initial printing of headers. -.ip \-d -Turn on debugging information. Not of general interest. -.ip "\-f file\ \ " -Show the messages in -.i file -instead of your system mailbox. If -.i file -is omitted, -.i Mail -reads -.i mbox -in your home directory. -.ip \-i -Ignore tty interrupt signals. Useful on noisy phone lines, which -generate spurious RUBOUT or DELETE characters. It's usually -more effective to change your interrupt character to control\-c, -for which see the -.i stty -shell command. -.ip \-n -Inhibit reading of /etc/mail.rc. Not generally useful, since -/etc/mail.rc is usually empty. -.ip "\-s string" -Used for sending mail. -.i String -is used as the subject of the message being composed. If -.i string -contains blanks, you must surround it with quote marks. -.ip "\-u name" -Read -.i names's -mail instead of your own. Unwitting others often neglect to protect -their mailboxes, but discretion is advised. Essentially, -.b "\-u user" -is a shorthand way of doing -.b "\-f /var/mail/user". -.ip "\-v" -Use the -.b \-v -flag when invoking sendmail. This feature may also be enabled -by setting the the option "verbose". -.pp -The following command line flags are also recognized, but are -intended for use by programs invoking -.i Mail -and not for people. -.ip "\-T file" -Arrange to print on -.i file -the contents of the -.i article-id -fields of all messages that were either read or deleted. -.b \-T -is for the -.i readnews -program and should NOT be used for reading your mail. -.ip "\-h number" -Pass on hop count information. -.i Mail -will take the number, increment it, and pass it with -.b \-h -to the mail delivery system. -.b \-h -only has effect when sending mail and is used for network mail -forwarding. -.ip "\-r name" -Used for network mail forwarding: interpret -.i name -as the sender of the message. The -.i name -and -.b \-r -are simply sent along to the mail delivery system. Also, -.i Mail -will wait for the message to be sent and return the exit status. -Also restricts formatting of message. -.pp -Note that -.b \-h -and -.b \-r , -which are for network mail forwarding, are not used in practice -since mail forwarding is now handled separately. They may -disappear soon. diff --git a/usr.bin/mail/USD.doc/mail7.nr b/usr.bin/mail/USD.doc/mail7.nr deleted file mode 100644 index 0b2590b19fc..00000000000 --- a/usr.bin/mail/USD.doc/mail7.nr +++ /dev/null @@ -1,107 +0,0 @@ -.\" Copyright (c) 1980, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)mail7.nr 8.1 (Berkeley) 6/8/93 -.\" -.sh 1 "Format of messages" -.pp -This section describes the format of messages. -Messages begin with a -.i from -line, which consists of the word -.q From -followed by a user name, followed by anything, followed by -a date in the format returned by the -.i ctime -library routine described in section 3 of the Unix Programmer's -Manual. A possible -.i ctime -format date is: -.(l -Tue Dec 1 10:58:23 1981 -.)l -The -.i ctime -date may be optionally followed by a single space and a -time zone indication, which -should be three capital letters, such as PDT. -.pp -Following the -.i from -line are zero or more -.i "header field" -lines. -Each header field line is of the form: -.(l -name: information -.)l -.i Name -can be anything, but only certain header fields are recognized as -having any meaning. The recognized header fields are: -.i article-id , -.i bcc , -.i cc , -.i from , -.i reply-to , -.i sender , -.i subject , -and -.i to . -Other header fields are also significant to other systems; see, -for example, the current Arpanet message standard for much more -information on this topic. -A header field can be continued onto following lines by making the -first character on the following line a space or tab character. -.pp -If any headers are present, they must be followed by a blank line. -The part that follows is called the -.i body -of the message, and must be ASCII text, not containing null characters. -Each line in the message body must be no longer than 512 characters and -terminated with an ASCII newline character. -If binary data must be passed through the mail system, it is suggested -that this data be encoded in a system which encodes six bits into -a printable character (i.e.: uuencode). -For example, one could use the upper and lower case letters, the digits, -and the characters comma and period to make up the 64 characters. -Then, one can send a 16-bit binary number -as three characters. These characters should be packed into lines, -preferably lines about 70 characters long as long lines are transmitted -more efficiently. -.pp -The message delivery system always adds a blank line to the end of -each message. This blank line must not be deleted. -.pp -The UUCP message delivery system sometimes adds a blank line to -the end of a message each time it is forwarded through a machine. -.pp -It should be noted that some network transport protocols enforce -limits to the lengths of messages. diff --git a/usr.bin/mail/USD.doc/mail8.nr b/usr.bin/mail/USD.doc/mail8.nr deleted file mode 100644 index b09afbdaf6b..00000000000 --- a/usr.bin/mail/USD.doc/mail8.nr +++ /dev/null @@ -1,75 +0,0 @@ -.\" Copyright (c) 1980, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)mail8.nr 8.1 (Berkeley) 6/8/93 -.\" -.bp -.sh 1 "Glossary" -.pp -This section contains the definitions of a few phrases -peculiar to -.i Mail . -.ip "\fIalias\fP" -An alternative name for a person or list of people. -.ip "\fIflag\fP" -An option, given on the command line of -.i Mail , -prefaced with a \-. For example, -.b \-f -is a flag. -.ip "\fIheader field\fP" -At the beginning of a message, a line which contains information -that is part of the structure of the message. Popular header fields -include -.i to , -.i cc , -and -.i subject . -.ip "\fImail\ \ \fP" -A collection of messages. Often used in the phrase, -.q "Have you read your mail?" -.ip "\fImailbox\fP" -The place where your mail is stored, typically in the directory -/var/mail. -.ip "\fImessage\fP" -A single letter from someone, initially stored in your -.i mailbox . -.ip "\fImessage list\fP" -A string used in -.i Mail -command mode to describe a sequence of messages. -.ip "\fIoption\fP" -A piece of special purpose information used to tailor -.i Mail -to your taste. -Options are specified with the -.b set -command. diff --git a/usr.bin/mail/USD.doc/mail9.nr b/usr.bin/mail/USD.doc/mail9.nr deleted file mode 100644 index 271548e9d07..00000000000 --- a/usr.bin/mail/USD.doc/mail9.nr +++ /dev/null @@ -1,203 +0,0 @@ -.\" Copyright (c) 1980, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)mail9.nr 8.1 (Berkeley) 6/8/93 -.\" -.bp -.sh 1 "Summary of commands, options, and escapes" -.pp -This section gives a quick summary of the -.i Mail -commands, binary and valued options, and tilde escapes. -.pp -The following table describes the commands: -.TS -center ; -c ci -lb l. -Command Description -_ -+ Same as \fBnext\fP -- Back up to previous message -? Print brief summary of \fIMail\fP commands -! Single command escape to shell -Print Type message with ignored fields -Reply Reply to author of message only -Respond Same as \fBReply\fP -Type Type message with ignored fields -alias Define an alias as a set of user names -alternates List other names you are known by -chdir Change working directory, home by default -copy Copy a message to a file or folder -delete Delete a list of messages -dp Same as \fBdt\fP -dt Delete current message, type next message -edit Edit a list of messages -else Start of else part of conditional; see \fBif\fP -endif End of conditional statement; see \fBif\fP -exit Leave mail without changing anything -file Interrogate/change current mail file -folder Same as \fBfile\fP -folders List the folders in your folder directory -from List headers of a list of messages -headers List current window of messages -help Same as \fB?\fP -hold Same as \fBpreserve\fP -if Conditional execution of \fIMail\fP commands -ignore Set/examine list of ignored header fields -list List valid \fIMail\fP commands -local List other names for the local host -mail Send mail to specified names -mbox Arrange to save a list of messages in \fImbox\fP -next Go to next message and type it -preserve Arrange to leave list of messages in system mailbox -print Print messages -quit Leave \fIMail\fP; update system mailbox, \fImbox\fP as appropriate -reply Compose a reply to a message -respond Same as \fBreply\fP -retain Supersedes \fBignore\fP -save Append messages, headers included, on a file -set Set binary or valued options -shell Invoke an interactive shell -size Prints out size of message list -source Read \fImail\fP commands from a file -top Print first so many (5 by default) lines of list of messages -type Same as \fBprint\fP -undelete Undelete list of messages -unread Marks list of messages as not been read -unset Undo the operation of a \fBset\fP -visual Invoke visual editor on a list of messages -write Append messages to a file, don't include headers -xit Same as \fBexit\fP -z Scroll to next/previous screenful of headers -.TE -.bp -.(b -.pp -The following table describes the options. Each option is -shown as being either a binary or valued option. -.TS -center; -c ci ci -l ci l. -Option Type Description -_ -EDITOR valued Pathname of editor for ~e and \fBedit\fP -PAGER valued Pathname of paginator for \fBPrint\fP, \fBprint\fP, \fBType\fP and \fBtype\fP -SHELL valued Pathname of shell for \fBshell\fP, ~! and \fB!\fP -VISUAL valued Pathname of screen editor for ~v, \fBvisual\fP -append binary Always append messages to end of \fImbox\fP -ask binary Prompt user for Subject: field when sending -askcc binary Prompt user for additional Cc's at end of message -autoprint binary Print next message after \fBdelete\fP -crt valued Minimum number of lines before using \fBPAGER\fP -debug binary Print out debugging information -dot binary Accept . alone on line to terminate message input -escape valued Escape character to be used instead of\ \ ~ -folder valued Directory to store folders in -hold binary Hold messages in system mailbox by default -ignore binary Ignore \s-2RUBOUT\s0 while sending mail -ignoreeof binary Don't terminate letters/command input with \fB\(uaD\fP -keep binary Don't unlink system mailbox when empty -keepsave binary Don't delete \fBsave\fPd messages by default -metoo binary Include sending user in aliases -noheader binary Suppress initial printing of version and headers -nosave binary Don't save partial letter in \fIdead.letter\fP -quiet binary Suppress printing of \fIMail\fP version and message numbers -record valued File to save all outgoing mail in -screen valued Size of window of message headers for \fBz\fP, etc. -sendmail valued Choose alternate mail delivery system -toplines valued Number of lines to print in \fBtop\fP -verbose binary Invoke sendmail with the \fB\-v\fP flag -.TE -.)b -.(b -.pp -The following table summarizes the tilde escapes available -while sending mail. -.TS -center; -c ci ci -l li l. -Escape Arguments Description -_ -~! command Execute shell command -~b name ... Add names to "blind" Cc: list -~c name ... Add names to Cc: field -~d Read \fIdead.letter\fP into message -~e Invoke text editor on partial message -~f messages Read named messages -~h Edit the header fields -~m messages Read named messages, right shift by tab -~p Print message entered so far -~q Abort entry of letter; like \s-2RUBOUT\s0 -~r filename Read file into message -~s string Set Subject: field to \fIstring\fP -~t name ... Add names to To: field -~v Invoke screen editor on message -~w filename Write message on file -~| command Pipe message through \fIcommand\fP -~: Mail command Execute a \fIMail\fP command -~~ string Quote a ~ in front of \fIstring\fP -.TE -.)b -.(b -.pp -The following table shows the command line flags that -.i Mail -accepts: -.TS -center; -c c -l a. -Flag Description -_ -\-N Suppress the initial printing of headers -\-T \fIfile\fP Article-id's of read/deleted messages to \fIfile\fP -\-d Turn on debugging -\-f \fIfile\fP Show messages in \fIfile\fP or \fI~/mbox\fP -\-h \fInumber\fP Pass on hop count for mail forwarding -\-i Ignore tty interrupt signals -\-n Inhibit reading of /etc/mail.rc -\-r \fIname\fP Pass on \fIname\fP for mail forwarding -\-s \fIstring\fP Use \fIstring\fP as subject in outgoing mail -\-u \fIname\fP Read \fIname's\fP mail instead of your own -\-v Invoke sendmail with the \fB\-v\fP flag -.TE -.)b -.lp -Notes: -.b \-T , -.b \-d , -.b \-h , -and -.b \-r -are not for human use. diff --git a/usr.bin/mail/USD.doc/maila.nr b/usr.bin/mail/USD.doc/maila.nr deleted file mode 100644 index 84b01fede67..00000000000 --- a/usr.bin/mail/USD.doc/maila.nr +++ /dev/null @@ -1,33 +0,0 @@ -.\" Copyright (c) 1980, 1993 -.\" The Regents of the University of California. 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" @(#)maila.nr 8.1 (Berkeley) 6/8/93 -.\" diff --git a/usr.bin/mail/aux.c b/usr.bin/mail/aux.c deleted file mode 100644 index 6a886adcce9..00000000000 --- a/usr.bin/mail/aux.c +++ /dev/null @@ -1,632 +0,0 @@ -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)aux.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ -#include -__MBSDID("$FreeBSD: src/usr.bin/mail/aux.c,v 1.13 2002/08/25 13:22:47 charnier Exp $"); - -#include - -#include "rcv.h" -#include "extern.h" - -/* - * Mail -- a mail program - * - * Auxiliary functions. - */ - -static char *save2str(char *, char *); - -/* - * Return a pointer to a dynamic copy of the argument. - */ -char * -savestr(str) - char *str; -{ - char *new; - int size = strlen(str) + 1; - - if ((new = salloc(size)) != NULL) - bcopy(str, new, size); - return (new); -} - -/* - * Make a copy of new argument incorporating old one. - */ -char * -save2str(str, old) - char *str, *old; -{ - char *new; - int newsize = strlen(str) + 1; - int oldsize = old ? strlen(old) + 1 : 0; - - if ((new = salloc(newsize + oldsize)) != NULL) { - if (oldsize) { - bcopy(old, new, oldsize); - new[oldsize - 1] = ' '; - } - bcopy(str, new + oldsize, newsize); - } - return (new); -} - -/* - * Touch the named message by setting its MTOUCH flag. - * Touched messages have the effect of not being sent - * back to the system mailbox on exit. - */ -void -touch(mp) - struct message *mp; -{ - - mp->m_flag |= MTOUCH; - if ((mp->m_flag & MREAD) == 0) - mp->m_flag |= MREAD|MSTATUS; -} - -/* - * Test to see if the passed file name is a directory. - * Return true if it is. - */ -int -isdir(name) - char name[]; -{ - struct stat sbuf; - - if (stat(name, &sbuf) < 0) - return (0); - return (S_ISDIR(sbuf.st_mode)); -} - -/* - * Count the number of arguments in the given string raw list. - */ -int -argcount(argv) - char **argv; -{ - char **ap; - - for (ap = argv; *ap++ != NULL;) - ; - return (ap - argv - 1); -} - -/* - * Return the desired header line from the passed message - * pointer (or NULL if the desired header field is not available). - */ -char * -hfield(field, mp) - const char *field; - struct message *mp; -{ - FILE *ibuf; - char linebuf[LINESIZE]; - int lc; - char *hfield; - char *colon, *oldhfield = NULL; - - ibuf = setinput(mp); - if ((lc = mp->m_lines - 1) < 0) - return (NULL); - if (readline(ibuf, linebuf, LINESIZE) < 0) - return (NULL); - while (lc > 0) { - if ((lc = gethfield(ibuf, linebuf, lc, &colon)) < 0) - return (oldhfield); - if ((hfield = ishfield(linebuf, colon, field)) != NULL) - oldhfield = save2str(hfield, oldhfield); - } - return (oldhfield); -} - -/* - * Return the next header field found in the given message. - * Return >= 0 if something found, < 0 elsewise. - * "colon" is set to point to the colon in the header. - * Must deal with \ continuations & other such fraud. - */ -int -gethfield(f, linebuf, rem, colon) - FILE *f; - char linebuf[]; - int rem; - char **colon; -{ - char line2[LINESIZE]; - char *cp, *cp2; - int c; - - for (;;) { - if (--rem < 0) - return (-1); - if ((c = readline(f, linebuf, LINESIZE)) <= 0) - return (-1); - for (cp = linebuf; isprint((unsigned char)*cp) && *cp != ' ' && *cp != ':'; - cp++) - ; - if (*cp != ':' || cp == linebuf) - continue; - /* - * I guess we got a headline. - * Handle wraparounding - */ - *colon = cp; - cp = linebuf + c; - for (;;) { - while (--cp >= linebuf && (*cp == ' ' || *cp == '\t')) - ; - cp++; - if (rem <= 0) - break; - ungetc(c = getc(f), f); - if (c != ' ' && c != '\t') - break; - if ((c = readline(f, line2, LINESIZE)) < 0) - break; - rem--; - for (cp2 = line2; *cp2 == ' ' || *cp2 == '\t'; cp2++) - ; - c -= cp2 - line2; - if (cp + c >= linebuf + LINESIZE - 2) - break; - *cp++ = ' '; - bcopy(cp2, cp, c); - cp += c; - } - *cp = 0; - return (rem); - } - /* NOTREACHED */ -} - -/* - * Check whether the passed line is a header line of - * the desired breed. Return the field body, or 0. - */ - -char* -ishfield(linebuf, colon, field) - char linebuf[]; - char *colon; - const char *field; -{ - char *cp = colon; - - *cp = 0; - if (strcasecmp(linebuf, field) != 0) { - *cp = ':'; - return (0); - } - *cp = ':'; - for (cp++; *cp == ' ' || *cp == '\t'; cp++) - ; - return (cp); -} - -/* - * Copy a string and lowercase the result. - * dsize: space left in buffer (including space for NULL) - */ -void -istrncpy(dest, src, dsize) - char *dest; - const char *src; - size_t dsize; -{ - - strlcpy(dest, src, dsize); - while (*dest) - *dest++ = tolower((unsigned char)*dest); -} - -/* - * The following code deals with input stacking to do source - * commands. All but the current file pointer are saved on - * the stack. - */ - -static int ssp; /* Top of file stack */ -struct sstack { - FILE *s_file; /* File we were in. */ - int s_cond; /* Saved state of conditionals */ - int s_loading; /* Loading .mailrc, etc. */ -}; -#define SSTACK_SIZE 64 /* XXX was NOFILE. */ -static struct sstack sstack[SSTACK_SIZE]; - -/* - * Pushdown current input file and switch to a new one. - * Set the global flag "sourcing" so that others will realize - * that they are no longer reading from a tty (in all probability). - */ -int -source(arglist) - char **arglist; -{ - FILE *fi; - char *cp; - - if ((cp = expand(*arglist)) == NULL) - return (1); - if ((fi = Fopen(cp, "r")) == NULL) { - warn("%s", cp); - return (1); - } - if (ssp >= SSTACK_SIZE - 1) { - printf("Too much \"sourcing\" going on.\n"); - (void)Fclose(fi); - return (1); - } - sstack[ssp].s_file = input; - sstack[ssp].s_cond = cond; - sstack[ssp].s_loading = loading; - ssp++; - loading = 0; - cond = CANY; - input = fi; - sourcing++; - return (0); -} - -/* - * Pop the current input back to the previous level. - * Update the "sourcing" flag as appropriate. - */ -int -unstack() -{ - if (ssp <= 0) { - printf("\"Source\" stack over-pop.\n"); - sourcing = 0; - return (1); - } - (void)Fclose(input); - if (cond != CANY) - printf("Unmatched \"if\"\n"); - ssp--; - cond = sstack[ssp].s_cond; - loading = sstack[ssp].s_loading; - input = sstack[ssp].s_file; - if (ssp == 0) - sourcing = loading; - return (0); -} - -/* - * Touch the indicated file. - * This is nifty for the shell. - */ -void -alter(name) - char *name; -{ - struct stat sb; - struct timeval tv[2]; - - if (stat(name, &sb)) - return; - (void)gettimeofday(&tv[0], (struct timezone *)NULL); - tv[0].tv_sec++; - TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec); - (void)utimes(name, tv); -} - -/* - * Get sender's name from this message. If the message has - * a bunch of arpanet stuff in it, we may have to skin the name - * before returning it. - */ -char * -nameof(mp, reptype) - struct message *mp; - int reptype; -{ - char *cp, *cp2; - - cp = skin(name1(mp, reptype)); - if (reptype != 0 || charcount(cp, '!') < 2) - return (cp); - cp2 = strrchr(cp, '!'); - cp2--; - while (cp2 > cp && *cp2 != '!') - cp2--; - if (*cp2 == '!') - return (cp2 + 1); - return (cp); -} - -/* - * Start of a "comment". - * Ignore it. - */ -char * -skip_comment(cp) - char *cp; -{ - int nesting = 1; - - for (; nesting > 0 && *cp; cp++) { - switch (*cp) { - case '\\': - if (cp[1]) - cp++; - break; - case '(': - nesting++; - break; - case ')': - nesting--; - break; - } - } - return (cp); -} - -/* - * Skin an arpa net address according to the RFC 822 interpretation - * of "host-phrase." - */ -char * -skin(name) - char *name; -{ - char *nbuf, *bufend, *cp, *cp2; - int c, gotlt, lastsp; - - if (name == NULL) - return (NULL); - if (strchr(name, '(') == NULL && strchr(name, '<') == NULL - && strchr(name, ' ') == NULL) - return (name); - - /* We assume that length(input) <= length(output) */ - if ((nbuf = malloc(strlen(name) + 1)) == NULL) - err(1, "Out of memory"); - gotlt = 0; - lastsp = 0; - bufend = nbuf; - for (cp = name, cp2 = bufend; (c = *cp++) != '\0'; ) { - switch (c) { - case '(': - cp = skip_comment(cp); - lastsp = 0; - break; - - case '"': - /* - * Start of a "quoted-string". - * Copy it in its entirety. - */ - while ((c = *cp) != '\0') { - cp++; - if (c == '"') - break; - if (c != '\\') - *cp2++ = c; - else if ((c = *cp) != '\0') { - *cp2++ = c; - cp++; - } - } - lastsp = 0; - break; - - case ' ': - if (cp[0] == 'a' && cp[1] == 't' && cp[2] == ' ') - cp += 3, *cp2++ = '@'; - else - if (cp[0] == '@' && cp[1] == ' ') - cp += 2, *cp2++ = '@'; - else - lastsp = 1; - break; - - case '<': - cp2 = bufend; - gotlt++; - lastsp = 0; - break; - - case '>': - if (gotlt) { - gotlt = 0; - while ((c = *cp) != '\0' && c != ',') { - cp++; - if (c == '(') - cp = skip_comment(cp); - else if (c == '"') - while ((c = *cp) != '\0') { - cp++; - if (c == '"') - break; - if (c == '\\' && *cp != '\0') - cp++; - } - } - lastsp = 0; - break; - } - /* FALLTHROUGH */ - - default: - if (lastsp) { - lastsp = 0; - *cp2++ = ' '; - } - *cp2++ = c; - if (c == ',' && *cp == ' ' && !gotlt) { - *cp2++ = ' '; - while (*++cp == ' ') - ; - lastsp = 0; - bufend = cp2; - } - } - } - *cp2 = '\0'; - - if ((cp = realloc(nbuf, strlen(nbuf) + 1)) != NULL) - nbuf = cp; - return (nbuf); -} - -/* - * Fetch the sender's name from the passed message. - * Reptype can be - * 0 -- get sender's name for display purposes - * 1 -- get sender's name for reply - * 2 -- get sender's name for Reply - */ -char * -name1(mp, reptype) - struct message *mp; - int reptype; -{ - char namebuf[LINESIZE]; - char linebuf[LINESIZE]; - char *cp, *cp2; - FILE *ibuf; - int first = 1; - - if ((cp = hfield("from", mp)) != NULL) - return (cp); - if (reptype == 0 && (cp = hfield("sender", mp)) != NULL) - return (cp); - ibuf = setinput(mp); - namebuf[0] = '\0'; - if (readline(ibuf, linebuf, LINESIZE) < 0) - return (savestr(namebuf)); -newname: - for (cp = linebuf; *cp != '\0' && *cp != ' '; cp++) - ; - for (; *cp == ' ' || *cp == '\t'; cp++) - ; - for (cp2 = &namebuf[strlen(namebuf)]; - *cp != '\0' && *cp != ' ' && *cp != '\t' && - cp2 < namebuf + LINESIZE - 1;) - *cp2++ = *cp++; - *cp2 = '\0'; - if (readline(ibuf, linebuf, LINESIZE) < 0) - return (savestr(namebuf)); - if ((cp = strchr(linebuf, 'F')) == NULL) - return (savestr(namebuf)); - if (strncmp(cp, "From", 4) != 0) - return (savestr(namebuf)); - while ((cp = strchr(cp, 'r')) != NULL) { - if (strncmp(cp, "remote", 6) == 0) { - if ((cp = strchr(cp, 'f')) == NULL) - break; - if (strncmp(cp, "from", 4) != 0) - break; - if ((cp = strchr(cp, ' ')) == NULL) - break; - cp++; - if (first) { - cp2 = namebuf; - first = 0; - } else - cp2 = strrchr(namebuf, '!') + 1; - strlcpy(cp2, cp, sizeof(namebuf) - (cp2 - namebuf) - 1); - strcat(namebuf, "!"); - goto newname; - } - cp++; - } - return (savestr(namebuf)); -} - -/* - * Count the occurances of c in str - */ -int -charcount(str, c) - char *str; - int c; -{ - char *cp; - int i; - - for (i = 0, cp = str; *cp != '\0'; cp++) - if (*cp == c) - i++; - return (i); -} - -/* - * See if the given header field is supposed to be ignored. - */ -int -isign(field, ignore) - const char *field; - struct ignoretab ignore[2]; -{ - char realfld[LINESIZE]; - - if (ignore == ignoreall) - return (1); - /* - * Lower-case the string, so that "Status" and "status" - * will hash to the same place. - */ - istrncpy(realfld, field, sizeof(realfld)); - if (ignore[1].i_count > 0) - return (!member(realfld, ignore + 1)); - else - return (member(realfld, ignore)); -} - -int -member(realfield, table) - char *realfield; - struct ignoretab *table; -{ - struct ignore *igp; - - for (igp = table->i_head[hash(realfield)]; igp != NULL; igp = igp->i_link) - if (*igp->i_field == *realfield && - equal(igp->i_field, realfield)) - return (1); - return (0); -} diff --git a/usr.bin/netstat/flowtable.c b/usr.bin/netstat/flowtable.c deleted file mode 100644 index ab18c67bb41..00000000000 --- a/usr.bin/netstat/flowtable.c +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * Copyright (c) 2014 Gleb Smirnoff - * - * 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 - -#include - -#include - -#include -#include -#include - -#include "netstat.h" - -/* - * Print flowtable statistics. - */ - -static void -print_stats(struct flowtable_stat *stat) -{ - -#define p(f, m) if (stat->f || sflag <= 1) \ - printf(m, (uintmax_t)stat->f, plural(stat->f)) -#define p2(f, m) if (stat->f || sflag <= 1) \ - printf(m, (uintmax_t)stat->f, plurales(stat->f)) - - p(ft_lookups, "\t%ju lookup%s\n"); - p(ft_hits, "\t%ju hit%s\n"); - p2(ft_misses, "\t%ju miss%s\n"); - p(ft_inserts, "\t%ju insert%s\n"); - p(ft_collisions, "\t%ju collision%s\n"); - p(ft_free_checks, "\t%ju free check%s\n"); - p(ft_frees, "\t%ju free%s\n"); - p(ft_fail_lle_invalid, - "\t%ju lookup%s with not resolved Layer 2 address\n"); - -#undef p2 -#undef p -} - -void -flowtable_stats(void) -{ - struct flowtable_stat stat; - - if (!live) - return; - - if (fetch_stats("net.flowtable.ip4.stat", 0, &stat, - sizeof(stat), NULL) == 0) { - printf("flowtable for IPv4:\n"); - print_stats(&stat); - } - - if (fetch_stats("net.flowtable.ip6.stat", 0, &stat, - sizeof(stat), NULL) == 0) { - printf("flowtable for IPv6:\n"); - print_stats(&stat); - } -} diff --git a/usr.bin/truss/aarch64-cloudabi64.c b/usr.bin/truss/aarch64-cloudabi64.c deleted file mode 100644 index e16436ff537..00000000000 --- a/usr.bin/truss/aarch64-cloudabi64.c +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * Copyright (c) 2015 Nuxi, https://nuxi.nl/ - * - * 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 - -#include -#include - -#include - -#include -#include -#include - -#include "truss.h" - -static int -aarch64_cloudabi64_fetch_args(struct trussinfo *trussinfo, unsigned int narg) -{ - struct current_syscall *cs; - struct reg regs; - lwpid_t tid; - unsigned int i; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) == -1) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - cs = &trussinfo->curthread->cs; - for (i = 0; i < narg && i < 8; i++) - cs->args[i] = regs.x[i]; - return (0); -} - -static int -aarch64_cloudabi64_fetch_retval(struct trussinfo *trussinfo, long *retval, - int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) == -1) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - retval[0] = regs.x[0]; - retval[1] = regs.x[1]; - *errorp = (regs.spsr & PSR_C) != 0; - return (0); -} - -static struct procabi aarch64_cloudabi64 = { - "CloudABI ELF64", - SYSDECODE_ABI_CLOUDABI64, - aarch64_cloudabi64_fetch_args, - aarch64_cloudabi64_fetch_retval, - STAILQ_HEAD_INITIALIZER(aarch64_cloudabi64.extra_syscalls), - { NULL } -}; - -PROCABI(aarch64_cloudabi64); diff --git a/usr.bin/truss/aarch64-freebsd.c b/usr.bin/truss/aarch64-freebsd.c deleted file mode 100644 index 313c524d78c..00000000000 --- a/usr.bin/truss/aarch64-freebsd.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2015 The FreeBSD Foundation - * - * Portions of this software were developed by Konstantin Belousov - * under sponsorship from the FreeBSD Foundation. - * - * 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 - -/* FreeBSD/arm64-specific system call handling. */ - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include "truss.h" - -static int -aarch64_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct reg regs; - struct current_syscall *cs; - lwpid_t tid; - u_int i, reg, syscall_num; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* - * FreeBSD has two special kinds of system call redirections -- - * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basically; the latter is for quad-aligned arguments. - * - * The system call argument count and code from ptrace() already - * account for these, but we need to skip over the first argument. - */ - syscall_num = regs.x[8]; - if (syscall_num == SYS_syscall || syscall_num == SYS___syscall) { - reg = 1; - syscall_num = regs.x[0]; - } else { - reg = 0; - } - - for (i = 0; i < narg && reg < 8; i++, reg++) - cs->args[i] = regs.x[reg]; - return (0); -} - -static int -aarch64_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - retval[0] = regs.x[0]; - retval[1] = regs.x[1]; - *errorp = !!(regs.spsr & PSR_C); - return (0); -} - -static struct procabi aarch64_freebsd = { - "FreeBSD ELF64", - SYSDECODE_ABI_FREEBSD, - aarch64_fetch_args, - aarch64_fetch_retval, - STAILQ_HEAD_INITIALIZER(aarch64_freebsd.extra_syscalls), - { NULL } -}; - -PROCABI(aarch64_freebsd); diff --git a/usr.bin/truss/amd64-cloudabi64.c b/usr.bin/truss/amd64-cloudabi64.c deleted file mode 100644 index 459e56dead5..00000000000 --- a/usr.bin/truss/amd64-cloudabi64.c +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * Copyright (c) 2015 Nuxi, https://nuxi.nl/ - * - * 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 - -#include -#include - -#include - -#include -#include -#include - -#include "truss.h" - -static int -amd64_cloudabi64_fetch_args(struct trussinfo *trussinfo, unsigned int narg) -{ - struct current_syscall *cs; - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) == -1) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - cs = &trussinfo->curthread->cs; - if (narg >= 1) - cs->args[0] = regs.r_rdi; - if (narg >= 2) - cs->args[1] = regs.r_rsi; - if (narg >= 3) - cs->args[2] = regs.r_rdx; - if (narg >= 4) - cs->args[3] = regs.r_rcx; - if (narg >= 5) - cs->args[4] = regs.r_r8; - if (narg >= 6) - cs->args[5] = regs.r_r9; - return (0); -} - -static int -amd64_cloudabi64_fetch_retval(struct trussinfo *trussinfo, long *retval, - int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) == -1) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - retval[0] = regs.r_rax; - retval[1] = regs.r_rdx; - *errorp = (regs.r_rflags & PSL_C) != 0; - return (0); -} - -static struct procabi amd64_cloudabi64 = { - "CloudABI ELF64", - SYSDECODE_ABI_CLOUDABI64, - amd64_cloudabi64_fetch_args, - amd64_cloudabi64_fetch_retval, - STAILQ_HEAD_INITIALIZER(amd64_cloudabi64.extra_syscalls), - { NULL } -}; - -PROCABI(amd64_cloudabi64); diff --git a/usr.bin/truss/amd64-freebsd.c b/usr.bin/truss/amd64-freebsd.c deleted file mode 100644 index 8edf7c0e350..00000000000 --- a/usr.bin/truss/amd64-freebsd.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 1997 Sean Eric Fagan - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Sean Eric Fagan - * 4. Neither the name of the author may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * 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 - -/* FreeBSD/amd64-specific system call handling. */ - -#include -#include - -#include -#include - -#include -#include -#include - -#include "truss.h" - -static int -amd64_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct ptrace_io_desc iorequest; - struct reg regs; - struct current_syscall *cs; - lwpid_t tid; - u_int i, reg; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* - * FreeBSD has two special kinds of system call redirections -- - * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basically; the latter is for quad-aligned arguments. - * - * The system call argument count and code from ptrace() already - * account for these, but we need to skip over %rax if it contains - * either of these values. - */ - reg = 0; - switch (regs.r_rax) { - case SYS_syscall: - case SYS___syscall: - reg++; - break; - } - - for (i = 0; i < narg && reg < 6; i++, reg++) { - switch (reg) { - case 0: cs->args[i] = regs.r_rdi; break; - case 1: cs->args[i] = regs.r_rsi; break; - case 2: cs->args[i] = regs.r_rdx; break; - case 3: cs->args[i] = regs.r_rcx; break; - case 4: cs->args[i] = regs.r_r8; break; - case 5: cs->args[i] = regs.r_r9; break; - } - } - if (narg > i) { - iorequest.piod_op = PIOD_READ_D; - iorequest.piod_offs = (void *)(regs.r_rsp + sizeof(register_t)); - iorequest.piod_addr = &cs->args[i]; - iorequest.piod_len = (narg - i) * sizeof(register_t); - ptrace(PT_IO, tid, (caddr_t)&iorequest, 0); - if (iorequest.piod_len == 0) - return (-1); - } - - return (0); -} - -static int -amd64_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - retval[0] = regs.r_rax; - retval[1] = regs.r_rdx; - *errorp = !!(regs.r_rflags & PSL_C); - return (0); -} - -static struct procabi amd64_freebsd = { - "FreeBSD ELF64", - SYSDECODE_ABI_FREEBSD, - amd64_fetch_args, - amd64_fetch_retval, - STAILQ_HEAD_INITIALIZER(amd64_freebsd.extra_syscalls), - { NULL } -}; - -PROCABI(amd64_freebsd); diff --git a/usr.bin/truss/amd64-freebsd32.c b/usr.bin/truss/amd64-freebsd32.c deleted file mode 100644 index 5e26f3f720f..00000000000 --- a/usr.bin/truss/amd64-freebsd32.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 1997 Sean Eric Fagan - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Sean Eric Fagan - * 4. Neither the name of the author may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * 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 - -/* FreeBSD/amd64-freebsd32-specific system call handling. */ - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include "truss.h" - -static int -amd64_freebsd32_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct ptrace_io_desc iorequest; - struct reg regs; - struct current_syscall *cs; - unsigned int args32[narg]; - unsigned long parm_offset; - lwpid_t tid; - u_int i; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - parm_offset = regs.r_rsp + sizeof(int); - - /* - * FreeBSD has two special kinds of system call redirections -- - * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basically; the latter is for quad-aligned arguments. - * - * The system call argument count and code from ptrace() already - * account for these, but we need to skip over the first argument. - */ - switch (regs.r_rax) { - case SYS_syscall: - parm_offset += sizeof(int); - break; - case SYS___syscall: - parm_offset += sizeof(quad_t); - break; - } - - iorequest.piod_op = PIOD_READ_D; - iorequest.piod_offs = (void *)parm_offset; - iorequest.piod_addr = args32; - iorequest.piod_len = sizeof(args32); - ptrace(PT_IO, tid, (caddr_t)&iorequest, 0); - if (iorequest.piod_len == 0) { - return (-1); - } - - for (i = 0; i < narg; i++) - cs->args[i] = args32[i]; - return (0); -} - -static int -amd64_freebsd32_fetch_retval(struct trussinfo *trussinfo, long *retval, - int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - retval[0] = regs.r_rax & 0xffffffff; - retval[1] = regs.r_rdx & 0xffffffff; - *errorp = !!(regs.r_rflags & PSL_C); - return (0); -} - -static struct procabi amd64_freebsd32 = { - "FreeBSD ELF32", - SYSDECODE_ABI_FREEBSD32, - amd64_freebsd32_fetch_args, - amd64_freebsd32_fetch_retval, - STAILQ_HEAD_INITIALIZER(amd64_freebsd32.extra_syscalls), - { NULL } -}; - -PROCABI(amd64_freebsd32); - -static struct procabi amd64_freebsd32_aout = { - "FreeBSD a.out", - SYSDECODE_ABI_FREEBSD32, - amd64_freebsd32_fetch_args, - amd64_freebsd32_fetch_retval, - STAILQ_HEAD_INITIALIZER(amd64_freebsd32.extra_syscalls), - { NULL } -}; - -PROCABI(amd64_freebsd32_aout); diff --git a/usr.bin/truss/amd64-linux.c b/usr.bin/truss/amd64-linux.c deleted file mode 100644 index a996cb9f590..00000000000 --- a/usr.bin/truss/amd64-linux.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 1997 Sean Eric Fagan - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Sean Eric Fagan - * 4. Neither the name of the author may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * 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 - -/* Linux/x86_64-specific system call handling. */ - -#include - -#include -#include - -#include -#include -#include - -#include "truss.h" - -static int -amd64_linux_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct reg regs; - struct current_syscall *cs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - switch (narg) { - default: - cs->args[5] = regs.r_r9; - case 5: - cs->args[4] = regs.r_r8; - case 4: - cs->args[3] = regs.r_rcx; - case 3: - cs->args[2] = regs.r_rdx; - case 2: - cs->args[1] = regs.r_rsi; - case 1: - cs->args[0] = regs.r_rdi; - } - - return (0); -} - -static int -amd64_linux_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - retval[0] = regs.r_rax; - retval[1] = regs.r_rdx; - *errorp = !!(regs.r_rflags & PSL_C); - return (0); -} - -static struct procabi amd64_linux = { - "Linux ELF64", - SYSDECODE_ABI_LINUX, - amd64_linux_fetch_args, - amd64_linux_fetch_retval, - STAILQ_HEAD_INITIALIZER(amd64_linux.extra_syscalls), - { NULL } -}; - -PROCABI(amd64_linux); diff --git a/usr.bin/truss/amd64-linux32.c b/usr.bin/truss/amd64-linux32.c deleted file mode 100644 index 0e1cf54a7cb..00000000000 --- a/usr.bin/truss/amd64-linux32.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 1997 Sean Eric Fagan - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Sean Eric Fagan - * 4. Neither the name of the author may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * 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 - -/* Linux/i386-specific system call handling. */ - -#include - -#include -#include - -#include -#include -#include - -#include "truss.h" - -static int -amd64_linux32_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct reg regs; - struct current_syscall *cs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* - * Linux passes syscall arguments in registers, not - * on the stack. Fortunately, we've got access to the - * register set. Note that we don't bother checking the - * number of arguments. And what does linux do for syscalls - * that have more than five arguments? - */ - switch (narg) { - default: - cs->args[5] = regs.r_rbp; /* Unconfirmed */ - case 5: - cs->args[4] = regs.r_rdi; - case 4: - cs->args[3] = regs.r_rsi; - case 3: - cs->args[2] = regs.r_rdx; - case 2: - cs->args[1] = regs.r_rcx; - case 1: - cs->args[0] = regs.r_rbx; - } - - return (0); -} - -static int -amd64_linux32_fetch_retval(struct trussinfo *trussinfo, long *retval, - int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - retval[0] = regs.r_rax & 0xffffffff; - retval[1] = regs.r_rdx & 0xffffffff; - *errorp = !!(regs.r_rflags & PSL_C); - if (*errorp) - retval[0] = (int)retval[0]; - return (0); -} - -static struct procabi amd64_linux32 = { - "Linux ELF32", - SYSDECODE_ABI_LINUX32, - amd64_linux32_fetch_args, - amd64_linux32_fetch_retval, - STAILQ_HEAD_INITIALIZER(amd64_linux32.extra_syscalls), - { NULL } -}; - -PROCABI(amd64_linux32); diff --git a/usr.bin/truss/arm-freebsd.c b/usr.bin/truss/arm-freebsd.c deleted file mode 100644 index c0a44a751e4..00000000000 --- a/usr.bin/truss/arm-freebsd.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 1997 Sean Eric Fagan - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Sean Eric Fagan - * 4. Neither the name of the author may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * 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 - -/* FreeBSD/arm-specific system call handling. */ - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include "truss.h" - -static int -arm_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct ptrace_io_desc iorequest; - struct reg regs; - struct current_syscall *cs; - lwpid_t tid; - u_int i, reg, syscall_num; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* - * FreeBSD has two special kinds of system call redirections -- - * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basically; the latter is for quad-aligned arguments. - * - * The system call argument count and code from ptrace() already - * account for these, but we need to skip over the first argument. - */ -#ifdef __ARM_EABI__ - syscall_num = regs.r[7]; -#else - if ((syscall_num = ptrace(PT_READ_I, tid, - (caddr_t)(regs.r[_REG_PC] - INSN_SIZE), 0)) == -1) { - fprintf(trussinfo->outfile, "-- CANNOT READ PC --\n"); - return (-1); - } - syscall_num = syscall_num & 0x000fffff; -#endif - - reg = 0; - switch (syscall_num) { - case SYS_syscall: - reg = 1; - break; - case SYS___syscall: - reg = 2; - break; - } - - for (i = 0; i < narg && reg < 4; i++, reg++) - cs->args[i] = regs.r[reg]; - if (narg > i) { - iorequest.piod_op = PIOD_READ_D; - iorequest.piod_offs = (void *)(regs.r_sp + - 4 * sizeof(uint32_t)); - iorequest.piod_addr = &cs->args[i]; - iorequest.piod_len = (narg - i) * sizeof(cs->args[0]); - ptrace(PT_IO, tid, (caddr_t)&iorequest, 0); - if (iorequest.piod_len == 0) - return (-1); - } - - return (0); -} - -static int -arm_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* XXX: Does not have the __ARMEB__ handling for __syscall(). */ - retval[0] = regs.r[0]; - retval[1] = regs.r[1]; - *errorp = !!(regs.r_cpsr & PSR_C); - return (0); -} - -static struct procabi arm_freebsd = { - "FreeBSD ELF32", - SYSDECODE_ABI_FREEBSD, - arm_fetch_args, - arm_fetch_retval, - STAILQ_HEAD_INITIALIZER(arm_freebsd.extra_syscalls), - { NULL } -}; - -PROCABI(arm_freebsd); diff --git a/usr.bin/truss/i386-freebsd.c b/usr.bin/truss/i386-freebsd.c deleted file mode 100644 index c65d11ae8c7..00000000000 --- a/usr.bin/truss/i386-freebsd.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 1997 Sean Eric Fagan - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Sean Eric Fagan - * 4. Neither the name of the author may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * 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 - -/* FreeBSD/i386-specific system call handling. */ - -#include -#include - -#include -#include - -#include -#include -#include - -#include "truss.h" - -static int -i386_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct ptrace_io_desc iorequest; - struct reg regs; - struct current_syscall *cs; - lwpid_t tid; - unsigned int parm_offset; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - parm_offset = regs.r_esp + sizeof(int); - - /* - * FreeBSD has two special kinds of system call redirections -- - * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basically; the latter is for quad-aligned arguments. - * - * The system call argument count and code from ptrace() already - * account for these, but we need to skip over the first argument. - */ - switch (regs.r_eax) { - case SYS_syscall: - parm_offset += sizeof(int); - break; - case SYS___syscall: - parm_offset += sizeof(quad_t); - break; - } - - iorequest.piod_op = PIOD_READ_D; - iorequest.piod_offs = (void *)parm_offset; - iorequest.piod_addr = cs->args; - iorequest.piod_len = narg * sizeof(unsigned long); - ptrace(PT_IO, tid, (caddr_t)&iorequest, 0); - if (iorequest.piod_len == 0) - return (-1); - - return (0); -} - -static int -i386_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - retval[0] = regs.r_eax; - retval[1] = regs.r_edx; - *errorp = !!(regs.r_eflags & PSL_C); - return (0); -} - -static struct procabi i386_freebsd = { - "FreeBSD ELF32", - SYSDECODE_ABI_FREEBSD, - i386_fetch_args, - i386_fetch_retval, - STAILQ_HEAD_INITIALIZER(i386_freebsd.extra_syscalls), - { NULL } -}; - -PROCABI(i386_freebsd); - -static struct procabi i386_freebsd_aout = { - "FreeBSD a.out", - SYSDECODE_ABI_FREEBSD, - i386_fetch_args, - i386_fetch_retval, - STAILQ_HEAD_INITIALIZER(i386_freebsd_aout.extra_syscalls), - { NULL } -}; - -PROCABI(i386_freebsd_aout); - diff --git a/usr.bin/truss/i386-linux.c b/usr.bin/truss/i386-linux.c deleted file mode 100644 index f5b4873901c..00000000000 --- a/usr.bin/truss/i386-linux.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 1997 Sean Eric Fagan - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Sean Eric Fagan - * 4. Neither the name of the author may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * 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 - -/* Linux/i386-specific system call handling. */ - -#include - -#include -#include - -#include -#include -#include - -#include "truss.h" - -static int -i386_linux_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct reg regs; - struct current_syscall *cs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* - * Linux passes syscall arguments in registers, not - * on the stack. Fortunately, we've got access to the - * register set. Note that we don't bother checking the - * number of arguments. And what does linux do for syscalls - * that have more than five arguments? - */ - switch (narg) { - default: - cs->args[5] = regs.r_ebp; /* Unconfirmed */ - case 5: - cs->args[4] = regs.r_edi; - case 4: - cs->args[3] = regs.r_esi; - case 3: - cs->args[2] = regs.r_edx; - case 2: - cs->args[1] = regs.r_ecx; - case 1: - cs->args[0] = regs.r_ebx; - } - - return (0); -} - -static int -i386_linux_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - retval[0] = regs.r_eax; - retval[1] = regs.r_edx; - *errorp = !!(regs.r_eflags & PSL_C); - return (0); -} - -static struct procabi i386_linux = { - "Linux ELF", - SYSDECODE_ABI_LINUX, - i386_linux_fetch_args, - i386_linux_fetch_retval, - STAILQ_HEAD_INITIALIZER(i386_linux.extra_syscalls), - { NULL } -}; - -PROCABI(i386_linux); diff --git a/usr.bin/truss/mips-freebsd.c b/usr.bin/truss/mips-freebsd.c deleted file mode 100644 index 9b0f8f69820..00000000000 --- a/usr.bin/truss/mips-freebsd.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 1998 Sean Eric Fagan - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Sean Eric Fagan - * 4. Neither the name of the author may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * 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 - -/* FreeBSD/mips-specific system call handling. */ - -#define _WANT_MIPS_REGNUM -#include -#include - -#include -#include - -#include -#include -#include - -#include "truss.h" - -static int -mips_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct ptrace_io_desc iorequest; - struct reg regs; - struct current_syscall *cs; - lwpid_t tid; - u_int i, reg; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* - * FreeBSD has two special kinds of system call redirections -- - * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basically; the latter is for quad-aligned arguments. - * - * The system call argument count and code from ptrace() already - * account for these, but we need to skip over the first argument. - */ - reg = A0; - switch (regs.r_regs[V0]) { - case SYS_syscall: - reg = A1; - break; - case SYS___syscall: -#if defined(__mips_n32) || defined(__mips_n64) - reg = A1; -#else - reg = A2; -#endif - break; - } - -#if defined(__mips_n32) || defined(__mips_n64) -#define MAXREG A7 -#else -#define MAXREG A3 -#endif - - for (i = 0; i < narg && reg <= MAXREG; i++, reg++) - cs->args[i] = regs.r_regs[reg]; - if (narg > i) { - iorequest.piod_op = PIOD_READ_D; - iorequest.piod_offs = (void *)((uintptr_t)regs.r_regs[SP] + - 4 * sizeof(cs->args[0])); - iorequest.piod_addr = &cs->args[i]; - iorequest.piod_len = (narg - i) * sizeof(cs->args[0]); - ptrace(PT_IO, tid, (caddr_t)&iorequest, 0); - if (iorequest.piod_len == 0) - return (-1); - } - - return (0); -} - -static int -mips_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* XXX: Does not have special handling for __syscall(). */ - retval[0] = regs.r_regs[V0]; - retval[1] = regs.r_regs[V1]; - *errorp = !!regs.r_regs[A3]; - return (0); -} - - -static struct procabi mips_freebsd = { -#ifdef __mips_n64 - "FreeBSD ELF64", -#else - "FreeBSD ELF32", -#endif - SYSDECODE_ABI_FREEBSD, - mips_fetch_args, - mips_fetch_retval, - STAILQ_HEAD_INITIALIZER(mips_freebsd.extra_syscalls), - { NULL } -}; - -PROCABI(mips_freebsd); diff --git a/usr.bin/truss/powerpc-freebsd.c b/usr.bin/truss/powerpc-freebsd.c deleted file mode 100644 index c593371f954..00000000000 --- a/usr.bin/truss/powerpc-freebsd.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2006 Peter Grehan - * Copyright 2005 Orlando Bassotto - * Copyright 1998 Sean Eric Fagan - * - * 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 - -/* FreeBSD/powerpc-specific system call handling. */ - -#include -#include - -#include -#include - -#include -#include -#include - -#include "truss.h" - -static int -powerpc_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct ptrace_io_desc iorequest; - struct reg regs; - struct current_syscall *cs; - lwpid_t tid; - u_int i, reg; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* - * FreeBSD has two special kinds of system call redirections -- - * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basically; the latter is for quad-aligned arguments. - * - * The system call argument count and code from ptrace() already - * account for these, but we need to skip over the first argument. - */ - reg = 0; - switch (regs.fixreg[0]) { - case SYS_syscall: - reg += 1; - break; - case SYS___syscall: - reg += 2; - break; - } - - for (i = 0; i < narg && reg < NARGREG; i++, reg++) { - cs->args[i] = regs.fixreg[FIRSTARG + reg]; - } - if (narg > i) { - iorequest.piod_op = PIOD_READ_D; - iorequest.piod_offs = (void *)(regs.fixreg[1] + 8); - iorequest.piod_addr = &cs->args[i]; - iorequest.piod_len = (narg - i) * sizeof(cs->args[0]); - ptrace(PT_IO, tid, (caddr_t)&iorequest, 0); - if (iorequest.piod_len == 0) - return (-1); - } - - return (0); -} - -static int -powerpc_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* XXX: Does not have fixup for __syscall(). */ - retval[0] = regs.fixreg[3]; - retval[1] = regs.fixreg[4]; - *errorp = !!(regs.cr & 0x10000000); - return (0); -} - -static struct procabi powerpc_freebsd = { - "FreeBSD ELF32", - SYSDECODE_ABI_FREEBSD, - powerpc_fetch_args, - powerpc_fetch_retval, - STAILQ_HEAD_INITIALIZER(powerpc_freebsd.extra_syscalls), - { NULL } -}; - -PROCABI(powerpc_freebsd); diff --git a/usr.bin/truss/powerpc64-freebsd.c b/usr.bin/truss/powerpc64-freebsd.c deleted file mode 100644 index cd70ee97bcb..00000000000 --- a/usr.bin/truss/powerpc64-freebsd.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2006 Peter Grehan - * Copyright 2005 Orlando Bassotto - * Copyright 1998 Sean Eric Fagan - * - * 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 - -/* FreeBSD/powerpc64-specific system call handling. */ - -#include -#include - -#include -#include - -#include -#include -#include - -#include "truss.h" - -static int -powerpc64_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct ptrace_io_desc iorequest; - struct reg regs; - struct current_syscall *cs; - lwpid_t tid; - u_int i, reg; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* - * FreeBSD has two special kinds of system call redirections -- - * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basically; the latter is for quad-aligned arguments. - * - * The system call argument count and code from ptrace() already - * account for these, but we need to skip over the first argument. - */ - reg = 0; - switch (regs.fixreg[0]) { - case SYS_syscall: - case SYS___syscall: - reg += 1; - break; - } - - for (i = 0; i < narg && reg < NARGREG; i++, reg++) - cs->args[i] = regs.fixreg[FIRSTARG + reg]; - if (narg > i) { - iorequest.piod_op = PIOD_READ_D; - iorequest.piod_offs = (void *)(regs.fixreg[1] + 48); - iorequest.piod_addr = &cs->args[i]; - iorequest.piod_len = (narg - i) * sizeof(cs->args[0]); - ptrace(PT_IO, tid, (caddr_t)&iorequest, 0); - if (iorequest.piod_len == 0) - return (-1); - } - - return (0); -} - -static int -powerpc64_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - retval[0] = regs.fixreg[3]; - retval[1] = regs.fixreg[4]; - *errorp = !!(regs.cr & 0x10000000); - return (0); -} - -static struct procabi powerpc64_freebsd = { - "FreeBSD ELF64", - SYSDECODE_ABI_FREEBSD, - powerpc64_fetch_args, - powerpc64_fetch_retval, - STAILQ_HEAD_INITIALIZER(powerpc64_freebsd.extra_syscalls), - { NULL } -}; - -PROCABI(powerpc64_freebsd); diff --git a/usr.bin/truss/powerpc64-freebsd32.c b/usr.bin/truss/powerpc64-freebsd32.c deleted file mode 100644 index 04254226f04..00000000000 --- a/usr.bin/truss/powerpc64-freebsd32.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2006 Peter Grehan - * Copyright 2005 Orlando Bassotto - * Copyright 1998 Sean Eric Fagan - * - * 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 - -/* FreeBSD/powerpc64-freebsd32-specific system call handling. */ - -#include -#include - -#include -#include - -#include -#include -#include - -#include "truss.h" - -static int -powerpc64_freebsd32_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct ptrace_io_desc iorequest; - struct reg regs; - struct current_syscall *cs; - lwpid_t tid; - u_int i, reg; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* - * FreeBSD has two special kinds of system call redirections -- - * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basically; the latter is for quad-aligned arguments. - * - * The system call argument count and code from ptrace() already - * account for these, but we need to skip over the first argument. - */ - reg = 0; - switch (regs.fixreg[0]) { - case SYS_syscall: - reg += 1; - break; - case SYS___syscall: - reg += 2; - break; - } - - for (i = 0; i < narg && reg < NARGREG; i++, reg++) { - cs->args[i] = regs.fixreg[FIRSTARG + reg] & 0xffffffff; - } - if (narg > i) { - uint32_t args32[narg - i]; - u_int j; - - iorequest.piod_op = PIOD_READ_D; - iorequest.piod_offs = (void *)(regs.fixreg[1] + 8); - iorequest.piod_addr = args32; - iorequest.piod_len = sizeof(args32); - ptrace(PT_IO, tid, (caddr_t)&iorequest, 0); - if (iorequest.piod_len == 0) - return (-1); - for (j = 0; j < narg - i; j++) - cs->args[i + j] = args32[j]; - } - - return (0); -} - -static int -powerpc64_freebsd32_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* XXX: Does not have fixup for __syscall(). */ - retval[0] = regs.fixreg[3] & 0xffffffff; - retval[1] = regs.fixreg[4] & 0xffffffff; - *errorp = !!(regs.cr & 0x10000000); - return (0); -} - -static struct procabi powerpc64_freebsd32 = { - "FreeBSD ELF32", - SYSDECODE_ABI_FREEBSD32, - powerpc64_freebsd32_fetch_args, - powerpc64_freebsd32_fetch_retval, - STAILQ_HEAD_INITIALIZER(powerpc64_freebsd32.extra_syscalls), - { NULL } -}; - -PROCABI(powerpc64_freebsd32); diff --git a/usr.bin/truss/sparc64-freebsd.c b/usr.bin/truss/sparc64-freebsd.c deleted file mode 100644 index 77de641be84..00000000000 --- a/usr.bin/truss/sparc64-freebsd.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 1998 Sean Eric Fagan - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Sean Eric Fagan - * 4. Neither the name of the author may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * 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 - -/* FreeBSD/sparc64-specific system call handling. */ - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include "truss.h" - -static int -sparc64_fetch_args(struct trussinfo *trussinfo, u_int narg) -{ - struct ptrace_io_desc iorequest; - struct reg regs; - struct current_syscall *cs; - lwpid_t tid; - u_int i, reg; - - tid = trussinfo->curthread->tid; - cs = &trussinfo->curthread->cs; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - /* - * FreeBSD has two special kinds of system call redirections -- - * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basically; the latter is for quad-aligned arguments. - * - * The system call argument count and code from ptrace() already - * account for these, but we need to skip over the first argument. - */ - reg = 0; - switch (regs.r_global[1]) { - case SYS_syscall: - case SYS___syscall: - reg = 1; - break; - } - - for (i = 0; i < narg && reg < 6; i++, reg++) - cs->args[i] = regs.r_out[reg]; - if (narg > i) { - iorequest.piod_op = PIOD_READ_D; - iorequest.piod_offs = (void *)(regs.r_out[6] + SPOFF + - offsetof(struct frame, fr_pad[6])); - iorequest.piod_addr = &cs->args[i]; - iorequest.piod_len = (narg - i) * sizeof(cs->args[0]); - ptrace(PT_IO, tid, (caddr_t)&iorequest, 0); - if (iorequest.piod_len == 0) - return (-1); - } - - return (0); -} - -static int -sparc64_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) -{ - struct reg regs; - lwpid_t tid; - - tid = trussinfo->curthread->tid; - if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return (-1); - } - - retval[0] = regs.r_out[0]; - retval[1] = regs.r_out[1]; - *errorp = !!(regs.r_tstate & TSTATE_XCC_C); - return (0); -} - -static struct procabi sparc64_freebsd = { - "FreeBSD ELF64", - SYSDECODE_ABI_FREEBSD, - sparc64_fetch_args, - sparc64_fetch_retval, - STAILQ_HEAD_INITIALIZER(sparc64_freebsd.extra_syscalls), - { NULL } -}; - -PROCABI(sparc64_freebsd); diff --git a/usr.bin/unifdef/unifdef.1 b/usr.bin/unifdef/unifdef.1 deleted file mode 100644 index 4d51366b23f..00000000000 --- a/usr.bin/unifdef/unifdef.1 +++ /dev/null @@ -1,516 +0,0 @@ -.\" Copyright (c) 1985, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" Copyright (c) 2002 - 2015 Tony Finch . All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Dave Yost. It was rewritten to support ANSI C by Tony Finch. -.\" -.\" 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. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" -.Dd December 3, 2015 -.Dt UNIFDEF 1 PRM -.Os " " -.Sh NAME -.Nm unifdef , unifdefall -.Nd remove preprocessor conditionals from code -.Sh SYNOPSIS -.Nm -.Op Fl bBcdehKkmnsStV -.Op Fl I Ns Ar path -.Op Fl [i]D Ns Ar sym Ns Op = Ns Ar val -.Op Fl [i]U Ns Ar sym -.Ar ... -.Op Fl f Ar defile -.Op Fl x Bro Ar 012 Brc -.Op Fl M Ar backext -.Op Fl o Ar outfile -.Op Ar infile ... -.Nm unifdefall -.Op Fl I Ns Ar path -.Ar ... -.Ar file -.Sh DESCRIPTION -The -.Nm -utility selectively processes conditional -.Xr cpp 1 -directives. -It removes from a file -both the directives -and any additional text that they specify should be removed, -while otherwise leaving the file alone. -.Pp -The -.Nm -utility acts on -.Ic #if , #ifdef , #ifndef , -.Ic #elif , #else , -and -.Ic #endif -lines, -using macros specified in -.Fl D -and -.Fl U -command line options or in -.Fl f -definitions files. -A directive is processed -if the macro specifications are sufficient to provide -a definite value for its control expression. -If the result is false, -the directive and the following lines under its control are removed. -If the result is true, -only the directive is removed. -An -.Ic #ifdef -or -.Ic #ifndef -directive is passed through unchanged -if its controlling macro is not specified. -Any -.Ic #if -or -.Ic #elif -control expression that has an unknown value or that -.Nm -cannot parse is passed through unchanged. -By default, -.Nm -ignores -.Ic #if -and -.Ic #elif -lines with constant expressions; -it can be told to process them by specifying the -.Fl k -flag on the command line. -.Pp -It understands a commonly-used subset -of the expression syntax for -.Ic #if -and -.Ic #elif -lines: -integer constants, -integer values of macros defined on the command line, -the -.Fn defined -operator, -the operators -.Ic \&! , ~ , - -(unary), -.Ic * , / , % , + , - , -.Ic < , <= , > , >= , == , != , & , ^ , \&| , -.Ic && , || , -and parenthesized expressions. -Division by zero is treated as an unknown value. -A kind of -.Dq "short circuit" -evaluation is used for the -.Ic && -operator: -if either operand is definitely false then the result is false, -even if the value of the other operand is unknown. -Similarly, -if either operand of -.Ic || -is definitely true then the result is true. -.Pp -When evaluating an expression, -.Nm -does not expand macros first. -The value of a macro must be a simple number, -not an expression. -A limited form of indirection is allowed, -where one macro's value is the name of another. -.Pp -In most cases, -.Nm -does not distinguish between object-like macros -(without arguments) and function-like macros (with arguments). -A function-like macro invocation can appear in -.Ic #if -and -.Ic #elif -control expressions. -If the macro is not explicitly defined, -or is defined with the -.Fl D -flag on the command-line, -or with -.Ic #define -in a -.Fl f -definitions file, -its arguments are ignored. -If a macro is explicitly undefined on the command line with the -.Fl U -flag, -or with -.Ic #undef -in a -.Fl f -definitions file, -it may not have any arguments since this leads to a syntax error. -.Pp -The -.Nm -utility understands just enough about C -to know when one of the directives is inactive -because it is inside -a comment, -or affected by a backslash-continued line. -It spots unusually-formatted preprocessor directives -and knows when the layout is too odd for it to handle. -.Pp -A script called -.Nm unifdefall -can be used to remove all conditional -.Xr cpp 1 -directives from a file. -It uses -.Nm Fl s -and -.Nm cpp Fl dM -to get lists of all the controlling macros -and their definitions (or lack thereof), -then invokes -.Nm -with appropriate arguments to process the file. -.Sh OPTIONS -.Bl -tag -width indent -compact -.It Fl D Ns Ar sym Ns = Ns Ar val -Specify that a macro is defined to a given value. -.Pp -.It Fl D Ns Ar sym -Specify that a macro is defined to the value 1. -.Pp -.It Fl U Ns Ar sym -Specify that a macro is undefined. -.Pp -If the same macro appears in more than one argument, -the last occurrence dominates. -.Pp -.It Fl iD Ns Ar sym Ns Op = Ns Ar val -.It Fl iU Ns Ar sym -C strings, comments, -and line continuations -are ignored within -.Ic #ifdef -and -.Ic #ifndef -blocks -controlled by macros -specified with these options. -.Pp -.It Fl f Ar defile -The file -.Ar defile -contains -.Ic #define -and -.Ic #undef -preprocessor directives, -which have the same effect as the corresponding -.Fl D -and -.Fl U -command-line arguments. -You can have multiple -.Fl f -arguments and mix them with -.Fl D -and -.Fl U -arguments; -later options override earlier ones. -.Pp -Each directive must be on a single line. -Object-like macro definitions (without arguments) -are set to the given value. -Function-like macro definitions (with arguments) -are treated as if they are set to 1. -.Pp -.Em Warning: -string literals and character constants are not parsed correctly in -.Fl f -files. -.Pp -.It Fl b -Replace removed lines with blank lines -instead of deleting them. -Mutually exclusive with the -.Fl B -option. -.Pp -.It Fl B -Compress blank lines around a deleted section. -Mutually exclusive with the -.Fl b -option. -.Pp -.It Fl c -Complement, -i.e., lines that would have been removed or blanked -are retained and vice versa. -.Pp -.It Fl d -Turn on printing of debugging messages. -.Pp -.It Fl e -By default, -.Nm -will report an error if it needs to remove -a preprocessor directive that spans more than one line, -for example, if it has a multi-line -comment hanging off its right hand end. -The -.Fl e -flag makes it ignore the line instead. -.Pp -.It Fl h -Print help. -.Pp -.It Fl I Ns Ar path -Specifies to -.Nm unifdefall -an additional place to look for -.Ic #include -files. -This option is ignored by -.Nm -for compatibility with -.Xr cpp 1 -and to simplify the implementation of -.Nm unifdefall . -.Pp -.It Fl K -Always treat the result of -.Ic && -and -.Ic || -operators as unknown if either operand is unknown, -instead of short-circuiting when unknown operands can't affect the result. -This option is for compatibility with older versions of -.Nm . -.Pp -.It Fl k -Process -.Ic #if -and -.Ic #elif -lines with constant expressions. -By default, sections controlled by such lines are passed through unchanged -because they typically start -.Dq Li "#if 0" -and are used as a kind of comment to sketch out future or past development. -It would be rude to strip them out, just as it would be for normal comments. -.Pp -.It Fl m -Modify one or more input files in place. -If an input file is not modified, -the original is preserved instead of being overwritten with an identical copy. -.Pp -.It Fl M Ar backext -Modify input files in place, and keep backups of the original files by -appending the -.Ar backext -to the input filenames. -A zero length -.Ar backext -behaves the same as the -.Fl m -option. -.Pp -.It Fl n -Add -.Li #line -directives to the output following any deleted lines, -so that errors produced when compiling the output file correspond to -line numbers in the input file. -.Pp -.It Fl o Ar outfile -Write output to the file -.Ar outfile -instead of the standard output when processing a single file. -.Pp -.It Fl s -Instead of processing an input file as usual, -this option causes -.Nm -to produce a list of macros that are used in -preprocessor directive controlling expressions. -.Pp -.It Fl S -Like the -.Fl s -option, but the nesting depth of each macro is also printed. -This is useful for working out the number of possible combinations -of interdependent defined/undefined macros. -.Pp -.It Fl t -Disables parsing for C strings, comments, -and line continuations, -which is useful -for plain text. -This is a blanket version of the -.Fl iD -and -.Fl iU -flags. -.Pp -.It Fl V -Print version details. -.Pp -.It Fl x Bro Ar 012 Brc -Set exit status mode to zero, one, or two. -See the -.Sx EXIT STATUS -section below for details. -.El -.Pp -The -.Nm -utility takes its input from -.Em stdin -if there are no -.Ar file -arguments. -You must use the -.Fl m -or -.Fl M -options if there are multiple input files. -You can specify inut from stdin or output to stdout with -.Ql - . -.Pp -The -.Nm -utility works nicely with the -.Fl D Ns Ar sym -option of -.Xr diff 1 . -.Sh EXIT STATUS -In normal usage the -.Nm -utility's exit status depends on the mode set using the -.Fl x -option. -.Pp -If the exit mode is zero (the default) then -.Nm -exits with status 0 if the output is an exact copy of the input, -or with status 1 if the output differs. -.Pp -If the exit mode is one, -.Nm -exits with status 1 if the output is unmodified -or 0 if it differs. -.Pp -If the exit mode is two, -.Nm -exits with status zero in both cases. -.Pp -In all exit modes, -.Nm -exits with status 2 if there is an error. -.Pp -The exit status is 0 if the -.Fl h -or -.Fl V -command line options are given. -.Sh DIAGNOSTICS -.Bl -item -.It -.Tn EOF -in comment -.It -Inappropriate -.Ic #elif , -.Ic #else -or -.Ic #endif -.It -Missing macro name in #define or #undef -.It -Obfuscated preprocessor control line -.It -Premature -.Tn EOF -(with the line number of the most recent unterminated -.Ic #if ) -.It -Too many levels of nesting -.It -Unrecognized preprocessor directive -.It -Unterminated char or string literal -.El -.Sh SEE ALSO -.Xr cpp 1 , -.Xr diff 1 -.Pp -The unifdef home page is -.Pa https://dotat.at/prog/unifdef -.Sh HISTORY -The -.Nm -command appeared in -.Bx 2.9 . -.Tn ANSI\~C -support was added in -.Fx 4.7 . -.Sh AUTHORS -.An -nosplit -The original implementation was written by -.An Dave Yost Aq Mt Dave@Yost.com . -.An Tony Finch Aq Mt dot@dotat.at -rewrote it to support -.Tn ANSI\~C . -.Sh BUGS -Expression evaluation is very limited. -.Pp -Character constants are not evaluated. -String literals and character constants in -.Fl f -definition files are ignored rather than parsed as -part of a macro's replacement tokens. -.Pp -Handling one line at a time means -preprocessor directives split across more than one physical line -(because of comments or backslash-newline) -cannot be handled in every situation. -.Pp -Trigraphs are not recognized. -.Pp -There is no support for macros with different definitions at -different points in the source file. -.Pp -The text-mode and ignore functionality does not correspond to modern -.Xr cpp 1 -behaviour. diff --git a/usr.bin/unifdef/unifdef.c b/usr.bin/unifdef/unifdef.c deleted file mode 100644 index 8c69e28db9e..00000000000 --- a/usr.bin/unifdef/unifdef.c +++ /dev/null @@ -1,1663 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2002 - 2015 Tony Finch - * - * 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. - */ - -/* - * unifdef - remove ifdef'ed lines - * - * This code was derived from software contributed to Berkeley by Dave Yost. - * It was rewritten to support ANSI C by Tony Finch. The original version - * of unifdef carried the 4-clause BSD copyright licence. None of its code - * remains in this version (though some of the names remain) so it now - * carries a more liberal licence. - * - * Wishlist: - * provide an option which will append the name of the - * appropriate symbol after #else's and #endif's - * provide an option which will check symbols after - * #else's and #endif's to see that they match their - * corresponding #ifdef or #ifndef - * - * These require better buffer handling, which would also make - * it possible to handle all "dodgy" directives correctly. - */ - -#include "unifdef.h" - -static const char copyright[] = - "@(#) $Version: unifdef-2.11 $\n" - "@(#) $Author: Tony Finch (dot@dotat.at) $\n" - "@(#) $URL: https://dotat.at/prog/unifdef $\n" -; - -/* types of input lines: */ -typedef enum { - LT_TRUEI, /* a true #if with ignore flag */ - LT_FALSEI, /* a false #if with ignore flag */ - LT_IF, /* an unknown #if */ - LT_TRUE, /* a true #if */ - LT_FALSE, /* a false #if */ - LT_ELIF, /* an unknown #elif */ - LT_ELTRUE, /* a true #elif */ - LT_ELFALSE, /* a false #elif */ - LT_ELSE, /* #else */ - LT_ENDIF, /* #endif */ - LT_DODGY, /* flag: directive is not on one line */ - LT_DODGY_LAST = LT_DODGY + LT_ENDIF, - LT_PLAIN, /* ordinary line */ - LT_EOF, /* end of file */ - LT_ERROR, /* unevaluable #if */ - LT_COUNT -} Linetype; - -static char const * const linetype_name[] = { - "TRUEI", "FALSEI", "IF", "TRUE", "FALSE", - "ELIF", "ELTRUE", "ELFALSE", "ELSE", "ENDIF", - "DODGY TRUEI", "DODGY FALSEI", - "DODGY IF", "DODGY TRUE", "DODGY FALSE", - "DODGY ELIF", "DODGY ELTRUE", "DODGY ELFALSE", - "DODGY ELSE", "DODGY ENDIF", - "PLAIN", "EOF", "ERROR" -}; - -#define linetype_if2elif(lt) ((Linetype)(lt - LT_IF + LT_ELIF)) -#define linetype_2dodgy(lt) ((Linetype)(lt + LT_DODGY)) - -/* state of #if processing */ -typedef enum { - IS_OUTSIDE, - IS_FALSE_PREFIX, /* false #if followed by false #elifs */ - IS_TRUE_PREFIX, /* first non-false #(el)if is true */ - IS_PASS_MIDDLE, /* first non-false #(el)if is unknown */ - IS_FALSE_MIDDLE, /* a false #elif after a pass state */ - IS_TRUE_MIDDLE, /* a true #elif after a pass state */ - IS_PASS_ELSE, /* an else after a pass state */ - IS_FALSE_ELSE, /* an else after a true state */ - IS_TRUE_ELSE, /* an else after only false states */ - IS_FALSE_TRAILER, /* #elifs after a true are false */ - IS_COUNT -} Ifstate; - -static char const * const ifstate_name[] = { - "OUTSIDE", "FALSE_PREFIX", "TRUE_PREFIX", - "PASS_MIDDLE", "FALSE_MIDDLE", "TRUE_MIDDLE", - "PASS_ELSE", "FALSE_ELSE", "TRUE_ELSE", - "FALSE_TRAILER" -}; - -/* state of comment parser */ -typedef enum { - NO_COMMENT = false, /* outside a comment */ - C_COMMENT, /* in a comment like this one */ - CXX_COMMENT, /* between // and end of line */ - STARTING_COMMENT, /* just after slash-backslash-newline */ - FINISHING_COMMENT, /* star-backslash-newline in a C comment */ - CHAR_LITERAL, /* inside '' */ - STRING_LITERAL /* inside "" */ -} Comment_state; - -static char const * const comment_name[] = { - "NO", "C", "CXX", "STARTING", "FINISHING", "CHAR", "STRING" -}; - -/* state of preprocessor line parser */ -typedef enum { - LS_START, /* only space and comments on this line */ - LS_HASH, /* only space, comments, and a hash */ - LS_DIRTY /* this line can't be a preprocessor line */ -} Line_state; - -static char const * const linestate_name[] = { - "START", "HASH", "DIRTY" -}; - -/* - * Minimum translation limits from ISO/IEC 9899:1999 5.2.4.1 - */ -#define MAXDEPTH 64 /* maximum #if nesting */ -#define MAXLINE 4096 /* maximum length of line */ -#define MAXSYMS 16384 /* maximum number of symbols */ - -/* - * Sometimes when editing a keyword the replacement text is longer, so - * we leave some space at the end of the tline buffer to accommodate this. - */ -#define EDITSLOP 10 - -/* - * Globals. - */ - -static bool compblank; /* -B: compress blank lines */ -static bool lnblank; /* -b: blank deleted lines */ -static bool complement; /* -c: do the complement */ -static bool debugging; /* -d: debugging reports */ -static bool inplace; /* -m: modify in place */ -static bool iocccok; /* -e: fewer IOCCC errors */ -static bool strictlogic; /* -K: keep ambiguous #ifs */ -static bool killconsts; /* -k: eval constant #ifs */ -static bool lnnum; /* -n: add #line directives */ -static bool symlist; /* -s: output symbol list */ -static bool symdepth; /* -S: output symbol depth */ -static bool text; /* -t: this is a text file */ - -static const char *symname[MAXSYMS]; /* symbol name */ -static const char *value[MAXSYMS]; /* -Dsym=value */ -static bool ignore[MAXSYMS]; /* -iDsym or -iUsym */ -static int nsyms; /* number of symbols */ - -static FILE *input; /* input file pointer */ -static const char *filename; /* input file name */ -static int linenum; /* current line number */ -static const char *linefile; /* file name for #line */ -static FILE *output; /* output file pointer */ -static const char *ofilename; /* output file name */ -static const char *backext; /* backup extension */ -static char *tempname; /* avoid splatting input */ - -static char tline[MAXLINE+EDITSLOP];/* input buffer plus space */ -static char *keyword; /* used for editing #elif's */ - -/* - * When processing a file, the output's newline style will match the - * input's, and unifdef correctly handles CRLF or LF endings whatever - * the platform's native style. The stdio streams are opened in binary - * mode to accommodate platforms whose native newline style is CRLF. - * When the output isn't a processed input file (when it is error / - * debug / diagnostic messages) then unifdef uses native line endings. - */ - -static const char *newline; /* input file format */ -static const char newline_unix[] = "\n"; -static const char newline_crlf[] = "\r\n"; - -static Comment_state incomment; /* comment parser state */ -static Line_state linestate; /* #if line parser state */ -static Ifstate ifstate[MAXDEPTH]; /* #if processor state */ -static bool ignoring[MAXDEPTH]; /* ignore comments state */ -static int stifline[MAXDEPTH]; /* start of current #if */ -static int depth; /* current #if nesting */ -static int delcount; /* count of deleted lines */ -static unsigned blankcount; /* count of blank lines */ -static unsigned blankmax; /* maximum recent blankcount */ -static bool constexpr; /* constant #if expression */ -static bool zerosyms; /* to format symdepth output */ -static bool firstsym; /* ditto */ - -static int exitmode; /* exit status mode */ -static int exitstat; /* program exit status */ -static bool altered; /* was this file modified? */ - -static void addsym1(bool, bool, char *); -static void addsym2(bool, const char *, const char *); -static char *astrcat(const char *, const char *); -static void cleantemp(void); -static void closeio(void); -static void debug(const char *, ...); -static void debugsym(const char *, int); -static bool defundef(void); -static void defundefile(const char *); -static void done(void); -static void error(const char *); -static int findsym(const char **); -static void flushline(bool); -static void hashline(void); -static void help(void); -static Linetype ifeval(const char **); -static void ignoreoff(void); -static void ignoreon(void); -static void indirectsym(void); -static void keywordedit(const char *); -static const char *matchsym(const char *, const char *); -static void nest(void); -static Linetype parseline(void); -static void process(void); -static void processinout(const char *, const char *); -static const char *skipargs(const char *); -static const char *skipcomment(const char *); -static const char *skiphash(void); -static const char *skipline(const char *); -static const char *skipsym(const char *); -static void state(Ifstate); -static void unnest(void); -static void usage(void); -static void version(void); -static const char *xstrdup(const char *, const char *); - -#define endsym(c) (!isalnum((unsigned char)c) && c != '_') - -/* - * The main program. - */ -int -main(int argc, char *argv[]) -{ - int opt; - - while ((opt = getopt(argc, argv, "i:D:U:f:I:M:o:x:bBcdehKklmnsStV")) != -1) - switch (opt) { - case 'i': /* treat stuff controlled by these symbols as text */ - /* - * For strict backwards-compatibility the U or D - * should be immediately after the -i but it doesn't - * matter much if we relax that requirement. - */ - opt = *optarg++; - if (opt == 'D') - addsym1(true, true, optarg); - else if (opt == 'U') - addsym1(true, false, optarg); - else - usage(); - break; - case 'D': /* define a symbol */ - addsym1(false, true, optarg); - break; - case 'U': /* undef a symbol */ - addsym1(false, false, optarg); - break; - case 'I': /* no-op for compatibility with cpp */ - break; - case 'b': /* blank deleted lines instead of omitting them */ - case 'l': /* backwards compatibility */ - lnblank = true; - break; - case 'B': /* compress blank lines around removed section */ - compblank = true; - break; - case 'c': /* treat -D as -U and vice versa */ - complement = true; - break; - case 'd': - debugging = true; - break; - case 'e': /* fewer errors from dodgy lines */ - iocccok = true; - break; - case 'f': /* definitions file */ - defundefile(optarg); - break; - case 'h': - help(); - break; - case 'K': /* keep ambiguous #ifs */ - strictlogic = true; - break; - case 'k': /* process constant #ifs */ - killconsts = true; - break; - case 'm': /* modify in place */ - inplace = true; - break; - case 'M': /* modify in place and keep backup */ - inplace = true; - if (strlen(optarg) > 0) - backext = optarg; - break; - case 'n': /* add #line directive after deleted lines */ - lnnum = true; - break; - case 'o': /* output to a file */ - ofilename = optarg; - break; - case 's': /* only output list of symbols that control #ifs */ - symlist = true; - break; - case 'S': /* list symbols with their nesting depth */ - symlist = symdepth = true; - break; - case 't': /* don't parse C comments */ - text = true; - break; - case 'V': - version(); - break; - case 'x': - exitmode = atoi(optarg); - if(exitmode < 0 || exitmode > 2) - usage(); - break; - default: - usage(); - } - argc -= optind; - argv += optind; - if (compblank && lnblank) - errx(2, "-B and -b are mutually exclusive"); - if (symlist && (ofilename != NULL || inplace || argc > 1)) - errx(2, "-s only works with one input file"); - if (argc > 1 && ofilename != NULL) - errx(2, "-o cannot be used with multiple input files"); - if (argc > 1 && !inplace) - errx(2, "multiple input files require -m or -M"); - if (argc == 0 && inplace) - errx(2, "-m requires an input file"); - if (argc == 0) - argc = 1; - if (argc == 1 && !inplace && ofilename == NULL) - ofilename = "-"; - indirectsym(); - - atexit(cleantemp); - if (ofilename != NULL) - processinout(*argv, ofilename); - else while (argc-- > 0) { - processinout(*argv, *argv); - argv++; - } - switch(exitmode) { - case(0): exit(exitstat); - case(1): exit(!exitstat); - case(2): exit(0); - default: abort(); /* bug */ - } -} - -/* - * File logistics. - */ -static void -processinout(const char *ifn, const char *ofn) -{ - struct stat st; - - if (ifn == NULL || strcmp(ifn, "-") == 0) { - filename = "[stdin]"; - linefile = NULL; - input = fbinmode(stdin); - } else { - filename = ifn; - linefile = ifn; - input = fopen(ifn, "rb"); - if (input == NULL) - err(2, "can't open %s", ifn); - } - if (strcmp(ofn, "-") == 0) { - output = fbinmode(stdout); - process(); - return; - } - if (stat(ofn, &st) < 0) { - output = fopen(ofn, "wb"); - if (output == NULL) - err(2, "can't create %s", ofn); - process(); - return; - } - - tempname = astrcat(ofn, ".XXXXXX"); - output = mktempmode(tempname, st.st_mode); - if (output == NULL) - err(2, "can't create %s", tempname); - - process(); - - if (backext != NULL) { - char *backname = astrcat(ofn, backext); - if (rename(ofn, backname) < 0) - err(2, "can't rename \"%s\" to \"%s\"", ofn, backname); - free(backname); - } - /* leave file unmodified if unifdef made no changes */ - if (!altered && backext == NULL) { - if (remove(tempname) < 0) - warn("can't remove \"%s\"", tempname); - } else if (replace(tempname, ofn) < 0) - err(2, "can't rename \"%s\" to \"%s\"", tempname, ofn); - free(tempname); - tempname = NULL; -} - -/* - * For cleaning up if there is an error. - */ -static void -cleantemp(void) -{ - if (tempname != NULL) - remove(tempname); -} - -/* - * Self-identification functions. - */ - -static void -version(void) -{ - const char *c = copyright; - for (;;) { - while (*++c != '$') - if (*c == '\0') - exit(0); - while (*++c != '$') - putc(*c, stderr); - putc('\n', stderr); - } -} - -static void -synopsis(FILE *fp) -{ - fprintf(fp, - "usage: unifdef [-bBcdehKkmnsStV] [-x{012}] [-Mext] [-opath] \\\n" - " [-[i]Dsym[=val]] [-[i]Usym] [-fpath] ... [file] ...\n"); -} - -static void -usage(void) -{ - synopsis(stderr); - exit(2); -} - -static void -help(void) -{ - synopsis(stdout); - printf( - " -Dsym=val define preprocessor symbol with given value\n" - " -Dsym define preprocessor symbol with value 1\n" - " -Usym preprocessor symbol is undefined\n" - " -iDsym=val \\ ignore C strings and comments\n" - " -iDsym ) in sections controlled by these\n" - " -iUsym / preprocessor symbols\n" - " -fpath file containing #define and #undef directives\n" - " -b blank lines instead of deleting them\n" - " -B compress blank lines around deleted section\n" - " -c complement (invert) keep vs. delete\n" - " -d debugging mode\n" - " -e ignore multiline preprocessor directives\n" - " -h print help\n" - " -Ipath extra include file path (ignored)\n" - " -K disable && and || short-circuiting\n" - " -k process constant #if expressions\n" - " -Mext modify in place and keep backups\n" - " -m modify input files in place\n" - " -n add #line directives to output\n" - " -opath output file name\n" - " -S list #if control symbols with nesting\n" - " -s list #if control symbols\n" - " -t ignore C strings and comments\n" - " -V print version\n" - " -x{012} exit status mode\n" - ); - exit(0); -} - -/* - * A state transition function alters the global #if processing state - * in a particular way. The table below is indexed by the current - * processing state and the type of the current line. - * - * Nesting is handled by keeping a stack of states; some transition - * functions increase or decrease the depth. They also maintain the - * ignore state on a stack. In some complicated cases they have to - * alter the preprocessor directive, as follows. - * - * When we have processed a group that starts off with a known-false - * #if/#elif sequence (which has therefore been deleted) followed by a - * #elif that we don't understand and therefore must keep, we edit the - * latter into a #if to keep the nesting correct. We use memcpy() to - * overwrite the 4 byte token "elif" with "if " without a '\0' byte. - * - * When we find a true #elif in a group, the following block will - * always be kept and the rest of the sequence after the next #elif or - * #else will be discarded. We edit the #elif into a #else and the - * following directive to #endif since this has the desired behaviour. - * - * "Dodgy" directives are split across multiple lines, the most common - * example being a multi-line comment hanging off the right of the - * directive. We can handle them correctly only if there is no change - * from printing to dropping (or vice versa) caused by that directive. - * If the directive is the first of a group we have a choice between - * failing with an error, or passing it through unchanged instead of - * evaluating it. The latter is not the default to avoid questions from - * users about unifdef unexpectedly leaving behind preprocessor directives. - */ -typedef void state_fn(void); - -/* report an error */ -static void Eelif (void) { error("Inappropriate #elif"); } -static void Eelse (void) { error("Inappropriate #else"); } -static void Eendif(void) { error("Inappropriate #endif"); } -static void Eeof (void) { error("Premature EOF"); } -static void Eioccc(void) { error("Obfuscated preprocessor control line"); } -/* plain line handling */ -static void print (void) { flushline(true); } -static void drop (void) { flushline(false); } -/* output lacks group's start line */ -static void Strue (void) { drop(); ignoreoff(); state(IS_TRUE_PREFIX); } -static void Sfalse(void) { drop(); ignoreoff(); state(IS_FALSE_PREFIX); } -static void Selse (void) { drop(); state(IS_TRUE_ELSE); } -/* print/pass this block */ -static void Pelif (void) { print(); ignoreoff(); state(IS_PASS_MIDDLE); } -static void Pelse (void) { print(); state(IS_PASS_ELSE); } -static void Pendif(void) { print(); unnest(); } -/* discard this block */ -static void Dfalse(void) { drop(); ignoreoff(); state(IS_FALSE_TRAILER); } -static void Delif (void) { drop(); ignoreoff(); state(IS_FALSE_MIDDLE); } -static void Delse (void) { drop(); state(IS_FALSE_ELSE); } -static void Dendif(void) { drop(); unnest(); } -/* first line of group */ -static void Fdrop (void) { nest(); Dfalse(); } -static void Fpass (void) { nest(); Pelif(); } -static void Ftrue (void) { nest(); Strue(); } -static void Ffalse(void) { nest(); Sfalse(); } -/* variable pedantry for obfuscated lines */ -static void Oiffy (void) { if (!iocccok) Eioccc(); Fpass(); ignoreon(); } -static void Oif (void) { if (!iocccok) Eioccc(); Fpass(); } -static void Oelif (void) { if (!iocccok) Eioccc(); Pelif(); } -/* ignore comments in this block */ -static void Idrop (void) { Fdrop(); ignoreon(); } -static void Itrue (void) { Ftrue(); ignoreon(); } -static void Ifalse(void) { Ffalse(); ignoreon(); } -/* modify this line */ -static void Mpass (void) { memcpy(keyword, "if ", 4); Pelif(); } -static void Mtrue (void) { keywordedit("else"); state(IS_TRUE_MIDDLE); } -static void Melif (void) { keywordedit("endif"); state(IS_FALSE_TRAILER); } -static void Melse (void) { keywordedit("endif"); state(IS_FALSE_ELSE); } - -static state_fn * const trans_table[IS_COUNT][LT_COUNT] = { -/* IS_OUTSIDE */ -{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Eelif, Eelif, Eelif, Eelse, Eendif, - Oiffy, Oiffy, Fpass, Oif, Oif, Eelif, Eelif, Eelif, Eelse, Eendif, - print, done, abort }, -/* IS_FALSE_PREFIX */ -{ Idrop, Idrop, Fdrop, Fdrop, Fdrop, Mpass, Strue, Sfalse,Selse, Dendif, - Idrop, Idrop, Fdrop, Fdrop, Fdrop, Mpass, Eioccc,Eioccc,Eioccc,Eioccc, - drop, Eeof, abort }, -/* IS_TRUE_PREFIX */ -{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Dfalse,Dfalse,Dfalse,Delse, Dendif, - Oiffy, Oiffy, Fpass, Oif, Oif, Eioccc,Eioccc,Eioccc,Eioccc,Eioccc, - print, Eeof, abort }, -/* IS_PASS_MIDDLE */ -{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Pelif, Mtrue, Delif, Pelse, Pendif, - Oiffy, Oiffy, Fpass, Oif, Oif, Pelif, Oelif, Oelif, Pelse, Pendif, - print, Eeof, abort }, -/* IS_FALSE_MIDDLE */ -{ Idrop, Idrop, Fdrop, Fdrop, Fdrop, Pelif, Mtrue, Delif, Pelse, Pendif, - Idrop, Idrop, Fdrop, Fdrop, Fdrop, Eioccc,Eioccc,Eioccc,Eioccc,Eioccc, - drop, Eeof, abort }, -/* IS_TRUE_MIDDLE */ -{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Melif, Melif, Melif, Melse, Pendif, - Oiffy, Oiffy, Fpass, Oif, Oif, Eioccc,Eioccc,Eioccc,Eioccc,Pendif, - print, Eeof, abort }, -/* IS_PASS_ELSE */ -{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Eelif, Eelif, Eelif, Eelse, Pendif, - Oiffy, Oiffy, Fpass, Oif, Oif, Eelif, Eelif, Eelif, Eelse, Pendif, - print, Eeof, abort }, -/* IS_FALSE_ELSE */ -{ Idrop, Idrop, Fdrop, Fdrop, Fdrop, Eelif, Eelif, Eelif, Eelse, Dendif, - Idrop, Idrop, Fdrop, Fdrop, Fdrop, Eelif, Eelif, Eelif, Eelse, Eioccc, - drop, Eeof, abort }, -/* IS_TRUE_ELSE */ -{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Eelif, Eelif, Eelif, Eelse, Dendif, - Oiffy, Oiffy, Fpass, Oif, Oif, Eelif, Eelif, Eelif, Eelse, Eioccc, - print, Eeof, abort }, -/* IS_FALSE_TRAILER */ -{ Idrop, Idrop, Fdrop, Fdrop, Fdrop, Dfalse,Dfalse,Dfalse,Delse, Dendif, - Idrop, Idrop, Fdrop, Fdrop, Fdrop, Dfalse,Dfalse,Dfalse,Delse, Eioccc, - drop, Eeof, abort } -/*TRUEI FALSEI IF TRUE FALSE ELIF ELTRUE ELFALSE ELSE ENDIF - TRUEI FALSEI IF TRUE FALSE ELIF ELTRUE ELFALSE ELSE ENDIF (DODGY) - PLAIN EOF ERROR */ -}; - -/* - * State machine utility functions - */ -static void -ignoreoff(void) -{ - if (depth == 0) - abort(); /* bug */ - ignoring[depth] = ignoring[depth-1]; -} -static void -ignoreon(void) -{ - ignoring[depth] = true; -} -static void -keywordedit(const char *replacement) -{ - snprintf(keyword, tline + sizeof(tline) - keyword, - "%s%s", replacement, newline); - altered = true; - print(); -} -static void -nest(void) -{ - if (depth > MAXDEPTH-1) - abort(); /* bug */ - if (depth == MAXDEPTH-1) - error("Too many levels of nesting"); - depth += 1; - stifline[depth] = linenum; -} -static void -unnest(void) -{ - if (depth == 0) - abort(); /* bug */ - depth -= 1; -} -static void -state(Ifstate is) -{ - ifstate[depth] = is; -} - -/* - * The last state transition function. When this is called, - * lineval == LT_EOF, so the process() loop will terminate. - */ -static void -done(void) -{ - if (incomment) - error("EOF in comment"); - closeio(); -} - -/* - * Write a line to the output or not, according to command line options. - * If writing fails, closeio() will print the error and exit. - */ -static void -flushline(bool keep) -{ - if (symlist) - return; - if (keep ^ complement) { - bool blankline = tline[strspn(tline, " \t\r\n")] == '\0'; - if (blankline && compblank && blankcount != blankmax) { - delcount += 1; - blankcount += 1; - } else { - if (lnnum && delcount > 0) - hashline(); - if (fputs(tline, output) == EOF) - closeio(); - delcount = 0; - blankmax = blankcount = blankline ? blankcount + 1 : 0; - } - } else { - if (lnblank && fputs(newline, output) == EOF) - closeio(); - altered = true; - delcount += 1; - blankcount = 0; - } - if (debugging && fflush(output) == EOF) - closeio(); -} - -/* - * Format of #line directives depends on whether we know the input filename. - */ -static void -hashline(void) -{ - int e; - - if (linefile == NULL) - e = fprintf(output, "#line %d%s", linenum, newline); - else - e = fprintf(output, "#line %d \"%s\"%s", - linenum, linefile, newline); - if (e < 0) - closeio(); -} - -/* - * Flush the output and handle errors. - */ -static void -closeio(void) -{ - /* Tidy up after findsym(). */ - if (symdepth && !zerosyms) - printf("\n"); - if (output != NULL && (ferror(output) || fclose(output) == EOF)) - err(2, "%s: can't write to output", filename); - fclose(input); -} - -/* - * The driver for the state machine. - */ -static void -process(void) -{ - Linetype lineval = LT_PLAIN; - /* When compressing blank lines, act as if the file - is preceded by a large number of blank lines. */ - blankmax = blankcount = 1000; - zerosyms = true; - newline = NULL; - linenum = 0; - altered = false; - while (lineval != LT_EOF) { - lineval = parseline(); - trans_table[ifstate[depth]][lineval](); - debug("process line %d %s -> %s depth %d", - linenum, linetype_name[lineval], - ifstate_name[ifstate[depth]], depth); - } - exitstat |= altered; -} - -/* - * Parse a line and determine its type. We keep the preprocessor line - * parser state between calls in the global variable linestate, with - * help from skipcomment(). - */ -static Linetype -parseline(void) -{ - const char *cp; - int cursym; - Linetype retval; - Comment_state wascomment; - - wascomment = incomment; - cp = skiphash(); - if (cp == NULL) - return (LT_EOF); - if (newline == NULL) { - if (strrchr(tline, '\n') == strrchr(tline, '\r') + 1) - newline = newline_crlf; - else - newline = newline_unix; - } - if (*cp == '\0') { - retval = LT_PLAIN; - goto done; - } - keyword = tline + (cp - tline); - if ((cp = matchsym("ifdef", keyword)) != NULL || - (cp = matchsym("ifndef", keyword)) != NULL) { - cp = skipcomment(cp); - if ((cursym = findsym(&cp)) < 0) - retval = LT_IF; - else { - retval = (keyword[2] == 'n') - ? LT_FALSE : LT_TRUE; - if (value[cursym] == NULL) - retval = (retval == LT_TRUE) - ? LT_FALSE : LT_TRUE; - if (ignore[cursym]) - retval = (retval == LT_TRUE) - ? LT_TRUEI : LT_FALSEI; - } - } else if ((cp = matchsym("if", keyword)) != NULL) - retval = ifeval(&cp); - else if ((cp = matchsym("elif", keyword)) != NULL) - retval = linetype_if2elif(ifeval(&cp)); - else if ((cp = matchsym("else", keyword)) != NULL) - retval = LT_ELSE; - else if ((cp = matchsym("endif", keyword)) != NULL) - retval = LT_ENDIF; - else { - cp = skipsym(keyword); - /* no way can we deal with a continuation inside a keyword */ - if (strncmp(cp, "\\\r\n", 3) == 0 || - strncmp(cp, "\\\n", 2) == 0) - Eioccc(); - cp = skipline(cp); - retval = LT_PLAIN; - goto done; - } - cp = skipcomment(cp); - if (*cp != '\0') { - cp = skipline(cp); - if (retval == LT_TRUE || retval == LT_FALSE || - retval == LT_TRUEI || retval == LT_FALSEI) - retval = LT_IF; - if (retval == LT_ELTRUE || retval == LT_ELFALSE) - retval = LT_ELIF; - } - /* the following can happen if the last line of the file lacks a - newline or if there is too much whitespace in a directive */ - if (linestate == LS_HASH) { - long len = cp - tline; - if (fgets(tline + len, MAXLINE - len, input) == NULL) { - if (ferror(input)) - err(2, "can't read %s", filename); - /* append the missing newline at eof */ - strcpy(tline + len, newline); - cp += strlen(newline); - linestate = LS_START; - } else { - linestate = LS_DIRTY; - } - } - if (retval != LT_PLAIN && (wascomment || linestate != LS_START)) { - retval = linetype_2dodgy(retval); - linestate = LS_DIRTY; - } -done: - debug("parser line %d state %s comment %s line", linenum, - comment_name[incomment], linestate_name[linestate]); - return (retval); -} - -/* - * These are the binary operators that are supported by the expression - * evaluator. - */ -static Linetype op_strict(long *p, long v, Linetype at, Linetype bt) { - if(at == LT_IF || bt == LT_IF) return (LT_IF); - return (*p = v, v ? LT_TRUE : LT_FALSE); -} -static Linetype op_lt(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a < b, at, bt); -} -static Linetype op_gt(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a > b, at, bt); -} -static Linetype op_le(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a <= b, at, bt); -} -static Linetype op_ge(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a >= b, at, bt); -} -static Linetype op_eq(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a == b, at, bt); -} -static Linetype op_ne(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a != b, at, bt); -} -static Linetype op_or(long *p, Linetype at, long a, Linetype bt, long b) { - if (!strictlogic && (at == LT_TRUE || bt == LT_TRUE)) - return (*p = 1, LT_TRUE); - return op_strict(p, a || b, at, bt); -} -static Linetype op_and(long *p, Linetype at, long a, Linetype bt, long b) { - if (!strictlogic && (at == LT_FALSE || bt == LT_FALSE)) - return (*p = 0, LT_FALSE); - return op_strict(p, a && b, at, bt); -} -static Linetype op_blsh(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a << b, at, bt); -} -static Linetype op_brsh(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a >> b, at, bt); -} -static Linetype op_add(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a + b, at, bt); -} -static Linetype op_sub(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a - b, at, bt); -} -static Linetype op_mul(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a * b, at, bt); -} -static Linetype op_div(long *p, Linetype at, long a, Linetype bt, long b) { - if (bt != LT_TRUE) { - debug("eval division by zero"); - return (LT_ERROR); - } - return op_strict(p, a / b, at, bt); -} -static Linetype op_mod(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a % b, at, bt); -} -static Linetype op_bor(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a | b, at, bt); -} -static Linetype op_bxor(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a ^ b, at, bt); -} -static Linetype op_band(long *p, Linetype at, long a, Linetype bt, long b) { - return op_strict(p, a & b, at, bt); -} - -/* - * An evaluation function takes three arguments, as follows: (1) a pointer to - * an element of the precedence table which lists the operators at the current - * level of precedence; (2) a pointer to an integer which will receive the - * value of the expression; and (3) a pointer to a char* that points to the - * expression to be evaluated and that is updated to the end of the expression - * when evaluation is complete. The function returns LT_FALSE if the value of - * the expression is zero, LT_TRUE if it is non-zero, LT_IF if the expression - * depends on an unknown symbol, or LT_ERROR if there is a parse failure. - */ -struct ops; - -typedef Linetype eval_fn(const struct ops *, long *, const char **); - -static eval_fn eval_table, eval_unary; - -/* - * The precedence table. Expressions involving binary operators are evaluated - * in a table-driven way by eval_table. When it evaluates a subexpression it - * calls the inner function with its first argument pointing to the next - * element of the table. Innermost expressions have special non-table-driven - * handling. - * - * The stop characters help with lexical analysis: an operator is not - * recognized if it is followed by one of the stop characters because - * that would make it a different operator. - */ -struct op { - const char *str; - Linetype (*fn)(long *, Linetype, long, Linetype, long); - const char *stop; -}; -struct ops { - eval_fn *inner; - struct op op[5]; -}; -static const struct ops eval_ops[] = { - { eval_table, { { "||", op_or, NULL } } }, - { eval_table, { { "&&", op_and, NULL } } }, - { eval_table, { { "|", op_bor, "|" } } }, - { eval_table, { { "^", op_bxor, NULL } } }, - { eval_table, { { "&", op_band, "&" } } }, - { eval_table, { { "==", op_eq, NULL }, - { "!=", op_ne, NULL } } }, - { eval_table, { { "<=", op_le, NULL }, - { ">=", op_ge, NULL }, - { "<", op_lt, "<=" }, - { ">", op_gt, ">=" } } }, - { eval_table, { { "<<", op_blsh, NULL }, - { ">>", op_brsh, NULL } } }, - { eval_table, { { "+", op_add, NULL }, - { "-", op_sub, NULL } } }, - { eval_unary, { { "*", op_mul, NULL }, - { "/", op_div, NULL }, - { "%", op_mod, NULL } } }, -}; - -/* Current operator precedence level */ -static long prec(const struct ops *ops) -{ - return (ops - eval_ops); -} - -/* - * Function for evaluating the innermost parts of expressions, - * viz. !expr (expr) number defined(symbol) symbol - * We reset the constexpr flag in the last two cases. - */ -static Linetype -eval_unary(const struct ops *ops, long *valp, const char **cpp) -{ - const char *cp; - char *ep; - int sym; - bool defparen; - Linetype lt; - - cp = skipcomment(*cpp); - if (*cp == '!') { - debug("eval%d !", prec(ops)); - cp++; - lt = eval_unary(ops, valp, &cp); - if (lt == LT_ERROR) - return (LT_ERROR); - if (lt != LT_IF) { - *valp = !*valp; - lt = *valp ? LT_TRUE : LT_FALSE; - } - } else if (*cp == '~') { - debug("eval%d ~", prec(ops)); - cp++; - lt = eval_unary(ops, valp, &cp); - if (lt == LT_ERROR) - return (LT_ERROR); - if (lt != LT_IF) { - *valp = ~(*valp); - lt = *valp ? LT_TRUE : LT_FALSE; - } - } else if (*cp == '-') { - debug("eval%d -", prec(ops)); - cp++; - lt = eval_unary(ops, valp, &cp); - if (lt == LT_ERROR) - return (LT_ERROR); - if (lt != LT_IF) { - *valp = -(*valp); - lt = *valp ? LT_TRUE : LT_FALSE; - } - } else if (*cp == '(') { - cp++; - debug("eval%d (", prec(ops)); - lt = eval_table(eval_ops, valp, &cp); - if (lt == LT_ERROR) - return (LT_ERROR); - cp = skipcomment(cp); - if (*cp++ != ')') - return (LT_ERROR); - } else if (isdigit((unsigned char)*cp)) { - debug("eval%d number", prec(ops)); - *valp = strtol(cp, &ep, 0); - if (ep == cp) - return (LT_ERROR); - lt = *valp ? LT_TRUE : LT_FALSE; - cp = ep; - } else if (matchsym("defined", cp) != NULL) { - cp = skipcomment(cp+7); - if (*cp == '(') { - cp = skipcomment(cp+1); - defparen = true; - } else { - defparen = false; - } - sym = findsym(&cp); - cp = skipcomment(cp); - if (defparen && *cp++ != ')') { - debug("eval%d defined missing ')'", prec(ops)); - return (LT_ERROR); - } - if (sym < 0) { - debug("eval%d defined unknown", prec(ops)); - lt = LT_IF; - } else { - debug("eval%d defined %s", prec(ops), symname[sym]); - *valp = (value[sym] != NULL); - lt = *valp ? LT_TRUE : LT_FALSE; - } - constexpr = false; - } else if (!endsym(*cp)) { - debug("eval%d symbol", prec(ops)); - sym = findsym(&cp); - if (sym < 0) { - lt = LT_IF; - cp = skipargs(cp); - } else if (value[sym] == NULL) { - *valp = 0; - lt = LT_FALSE; - } else { - *valp = strtol(value[sym], &ep, 0); - if (*ep != '\0' || ep == value[sym]) - return (LT_ERROR); - lt = *valp ? LT_TRUE : LT_FALSE; - cp = skipargs(cp); - } - constexpr = false; - } else { - debug("eval%d bad expr", prec(ops)); - return (LT_ERROR); - } - - *cpp = cp; - debug("eval%d = %d", prec(ops), *valp); - return (lt); -} - -/* - * Table-driven evaluation of binary operators. - */ -static Linetype -eval_table(const struct ops *ops, long *valp, const char **cpp) -{ - const struct op *op; - const char *cp; - long val = 0; - Linetype lt, rt; - - debug("eval%d", prec(ops)); - cp = *cpp; - lt = ops->inner(ops+1, valp, &cp); - if (lt == LT_ERROR) - return (LT_ERROR); - for (;;) { - cp = skipcomment(cp); - for (op = ops->op; op->str != NULL; op++) { - if (strncmp(cp, op->str, strlen(op->str)) == 0) { - /* assume only one-char operators have stop chars */ - if (op->stop != NULL && cp[1] != '\0' && - strchr(op->stop, cp[1]) != NULL) - continue; - else - break; - } - } - if (op->str == NULL) - break; - cp += strlen(op->str); - debug("eval%d %s", prec(ops), op->str); - rt = ops->inner(ops+1, &val, &cp); - if (rt == LT_ERROR) - return (LT_ERROR); - lt = op->fn(valp, lt, *valp, rt, val); - } - - *cpp = cp; - debug("eval%d = %d", prec(ops), *valp); - debug("eval%d lt = %s", prec(ops), linetype_name[lt]); - return (lt); -} - -/* - * Evaluate the expression on a #if or #elif line. If we can work out - * the result we return LT_TRUE or LT_FALSE accordingly, otherwise we - * return just a generic LT_IF. - */ -static Linetype -ifeval(const char **cpp) -{ - Linetype ret; - long val = 0; - - debug("eval %s", *cpp); - constexpr = killconsts ? false : true; - ret = eval_table(eval_ops, &val, cpp); - debug("eval = %d", val); - return (constexpr ? LT_IF : ret == LT_ERROR ? LT_IF : ret); -} - -/* - * Read a line and examine its initial part to determine if it is a - * preprocessor directive. Returns NULL on EOF, or a pointer to a - * preprocessor directive name, or a pointer to the zero byte at the - * end of the line. - */ -static const char * -skiphash(void) -{ - const char *cp; - - linenum++; - if (fgets(tline, MAXLINE, input) == NULL) { - if (ferror(input)) - err(2, "can't read %s", filename); - else - return (NULL); - } - cp = skipcomment(tline); - if (linestate == LS_START && *cp == '#') { - linestate = LS_HASH; - return (skipcomment(cp + 1)); - } else if (*cp == '\0') { - return (cp); - } else { - return (skipline(cp)); - } -} - -/* - * Mark a line dirty and consume the rest of it, keeping track of the - * lexical state. - */ -static const char * -skipline(const char *cp) -{ - const char *pcp; - if (*cp != '\0') - linestate = LS_DIRTY; - while (*cp != '\0') { - cp = skipcomment(pcp = cp); - if (pcp == cp) - cp++; - } - return (cp); -} - -/* - * Skip over comments, strings, and character literals and stop at the - * next character position that is not whitespace. Between calls we keep - * the comment state in the global variable incomment, and we also adjust - * the global variable linestate when we see a newline. - * XXX: doesn't cope with the buffer splitting inside a state transition. - */ -static const char * -skipcomment(const char *cp) -{ - if (text || ignoring[depth]) { - for (; isspace((unsigned char)*cp); cp++) - if (*cp == '\n') - linestate = LS_START; - return (cp); - } - while (*cp != '\0') - /* don't reset to LS_START after a line continuation */ - if (strncmp(cp, "\\\r\n", 3) == 0) - cp += 3; - else if (strncmp(cp, "\\\n", 2) == 0) - cp += 2; - else switch (incomment) { - case NO_COMMENT: - if (strncmp(cp, "/\\\r\n", 4) == 0) { - incomment = STARTING_COMMENT; - cp += 4; - } else if (strncmp(cp, "/\\\n", 3) == 0) { - incomment = STARTING_COMMENT; - cp += 3; - } else if (strncmp(cp, "/*", 2) == 0) { - incomment = C_COMMENT; - cp += 2; - } else if (strncmp(cp, "//", 2) == 0) { - incomment = CXX_COMMENT; - cp += 2; - } else if (strncmp(cp, "\'", 1) == 0) { - incomment = CHAR_LITERAL; - linestate = LS_DIRTY; - cp += 1; - } else if (strncmp(cp, "\"", 1) == 0) { - incomment = STRING_LITERAL; - linestate = LS_DIRTY; - cp += 1; - } else if (strncmp(cp, "\n", 1) == 0) { - linestate = LS_START; - cp += 1; - } else if (strchr(" \r\t", *cp) != NULL) { - cp += 1; - } else - return (cp); - continue; - case CXX_COMMENT: - if (strncmp(cp, "\n", 1) == 0) { - incomment = NO_COMMENT; - linestate = LS_START; - } - cp += 1; - continue; - case CHAR_LITERAL: - case STRING_LITERAL: - if ((incomment == CHAR_LITERAL && cp[0] == '\'') || - (incomment == STRING_LITERAL && cp[0] == '\"')) { - incomment = NO_COMMENT; - cp += 1; - } else if (cp[0] == '\\') { - if (cp[1] == '\0') - cp += 1; - else - cp += 2; - } else if (strncmp(cp, "\n", 1) == 0) { - if (incomment == CHAR_LITERAL) - error("Unterminated char literal"); - else - error("Unterminated string literal"); - } else - cp += 1; - continue; - case C_COMMENT: - if (strncmp(cp, "*\\\r\n", 4) == 0) { - incomment = FINISHING_COMMENT; - cp += 4; - } else if (strncmp(cp, "*\\\n", 3) == 0) { - incomment = FINISHING_COMMENT; - cp += 3; - } else if (strncmp(cp, "*/", 2) == 0) { - incomment = NO_COMMENT; - cp += 2; - } else - cp += 1; - continue; - case STARTING_COMMENT: - if (*cp == '*') { - incomment = C_COMMENT; - cp += 1; - } else if (*cp == '/') { - incomment = CXX_COMMENT; - cp += 1; - } else { - incomment = NO_COMMENT; - linestate = LS_DIRTY; - } - continue; - case FINISHING_COMMENT: - if (*cp == '/') { - incomment = NO_COMMENT; - cp += 1; - } else - incomment = C_COMMENT; - continue; - default: - abort(); /* bug */ - } - return (cp); -} - -/* - * Skip macro arguments. - */ -static const char * -skipargs(const char *cp) -{ - const char *ocp = cp; - int level = 0; - cp = skipcomment(cp); - if (*cp != '(') - return (cp); - do { - if (*cp == '(') - level++; - if (*cp == ')') - level--; - cp = skipcomment(cp+1); - } while (level != 0 && *cp != '\0'); - if (level == 0) - return (cp); - else - /* Rewind and re-detect the syntax error later. */ - return (ocp); -} - -/* - * Skip over an identifier. - */ -static const char * -skipsym(const char *cp) -{ - while (!endsym(*cp)) - ++cp; - return (cp); -} - -/* - * Skip whitespace and take a copy of any following identifier. - */ -static const char * -getsym(const char **cpp) -{ - const char *cp = *cpp, *sym; - - cp = skipcomment(cp); - cp = skipsym(sym = cp); - if (cp == sym) - return NULL; - *cpp = cp; - return (xstrdup(sym, cp)); -} - -/* - * Check that s (a symbol) matches the start of t, and that the - * following character in t is not a symbol character. Returns a - * pointer to the following character in t if there is a match, - * otherwise NULL. - */ -static const char * -matchsym(const char *s, const char *t) -{ - while (*s != '\0' && *t != '\0') - if (*s != *t) - return (NULL); - else - ++s, ++t; - if (*s == '\0' && endsym(*t)) - return(t); - else - return(NULL); -} - -/* - * Look for the symbol in the symbol table. If it is found, we return - * the symbol table index, else we return -1. - */ -static int -findsym(const char **strp) -{ - const char *str; - int symind; - - str = *strp; - *strp = skipsym(str); - if (symlist) { - if (*strp == str) - return (-1); - if (symdepth && firstsym) - printf("%s%3d", zerosyms ? "" : "\n", depth); - firstsym = zerosyms = false; - printf("%s%.*s%s", - symdepth ? " " : "", - (int)(*strp-str), str, - symdepth ? "" : "\n"); - /* we don't care about the value of the symbol */ - return (0); - } - for (symind = 0; symind < nsyms; ++symind) { - if (matchsym(symname[symind], str) != NULL) { - debugsym("findsym", symind); - return (symind); - } - } - return (-1); -} - -/* - * Resolve indirect symbol values to their final definitions. - */ -static void -indirectsym(void) -{ - const char *cp; - int changed, sym, ind; - - do { - changed = 0; - for (sym = 0; sym < nsyms; ++sym) { - if (value[sym] == NULL) - continue; - cp = value[sym]; - ind = findsym(&cp); - if (ind == -1 || ind == sym || - *cp != '\0' || - value[ind] == NULL || - value[ind] == value[sym]) - continue; - debugsym("indir...", sym); - value[sym] = value[ind]; - debugsym("...ectsym", sym); - changed++; - } - } while (changed); -} - -/* - * Add a symbol to the symbol table, specified with the format sym=val - */ -static void -addsym1(bool ignorethis, bool definethis, char *symval) -{ - const char *sym, *val; - - sym = symval; - val = skipsym(sym); - if (definethis && *val == '=') { - symval[val - sym] = '\0'; - val = val + 1; - } else if (*val == '\0') { - val = definethis ? "1" : NULL; - } else { - usage(); - } - addsym2(ignorethis, sym, val); -} - -/* - * Add a symbol to the symbol table. - */ -static void -addsym2(bool ignorethis, const char *sym, const char *val) -{ - const char *cp = sym; - int symind; - - symind = findsym(&cp); - if (symind < 0) { - if (nsyms >= MAXSYMS) - errx(2, "too many symbols"); - symind = nsyms++; - } - ignore[symind] = ignorethis; - symname[symind] = sym; - value[symind] = val; - debugsym("addsym", symind); -} - -static void -debugsym(const char *why, int symind) -{ - debug("%s %s%c%s", why, symname[symind], - value[symind] ? '=' : ' ', - value[symind] ? value[symind] : "undef"); -} - -/* - * Add symbols to the symbol table from a file containing - * #define and #undef preprocessor directives. - */ -static void -defundefile(const char *fn) -{ - filename = fn; - input = fopen(fn, "rb"); - if (input == NULL) - err(2, "can't open %s", fn); - linenum = 0; - while (defundef()) - ; - if (ferror(input)) - err(2, "can't read %s", filename); - else - fclose(input); - if (incomment) - error("EOF in comment"); -} - -/* - * Read and process one #define or #undef directive - */ -static bool -defundef(void) -{ - const char *cp, *kw, *sym, *val, *end; - - cp = skiphash(); - if (cp == NULL) - return (false); - if (*cp == '\0') - goto done; - /* strip trailing whitespace, and do a fairly rough check to - avoid unsupported multi-line preprocessor directives */ - end = cp + strlen(cp); - while (end > tline && strchr(" \t\n\r", end[-1]) != NULL) - --end; - if (end > tline && end[-1] == '\\') - Eioccc(); - - kw = cp; - if ((cp = matchsym("define", kw)) != NULL) { - sym = getsym(&cp); - if (sym == NULL) - error("Missing macro name in #define"); - if (*cp == '(') { - val = "1"; - } else { - cp = skipcomment(cp); - val = (cp < end) ? xstrdup(cp, end) : ""; - } - debug("#define"); - addsym2(false, sym, val); - } else if ((cp = matchsym("undef", kw)) != NULL) { - sym = getsym(&cp); - if (sym == NULL) - error("Missing macro name in #undef"); - cp = skipcomment(cp); - debug("#undef"); - addsym2(false, sym, NULL); - } else { - error("Unrecognized preprocessor directive"); - } - skipline(cp); -done: - debug("parser line %d state %s comment %s line", linenum, - comment_name[incomment], linestate_name[linestate]); - return (true); -} - -/* - * Concatenate two strings into new memory, checking for failure. - */ -static char * -astrcat(const char *s1, const char *s2) -{ - char *s; - int len; - size_t size; - - len = snprintf(NULL, 0, "%s%s", s1, s2); - if (len < 0) - err(2, "snprintf"); - size = (size_t)len + 1; - s = (char *)malloc(size); - if (s == NULL) - err(2, "malloc"); - snprintf(s, size, "%s%s", s1, s2); - return (s); -} - -/* - * Duplicate a segment of a string, checking for failure. - */ -static const char * -xstrdup(const char *start, const char *end) -{ - size_t n; - char *s; - - if (end < start) abort(); /* bug */ - n = (size_t)(end - start) + 1; - s = malloc(n); - if (s == NULL) - err(2, "malloc"); - snprintf(s, n, "%s", start); - return (s); -} - -/* - * Diagnostics. - */ -static void -debug(const char *msg, ...) -{ - va_list ap; - - if (debugging) { - va_start(ap, msg); - vwarnx(msg, ap); - va_end(ap); - } -} - -static void -error(const char *msg) -{ - if (depth == 0) - warnx("%s: %d: %s", filename, linenum, msg); - else - warnx("%s: %d: %s (#if line %d depth %d)", - filename, linenum, msg, stifline[depth], depth); - closeio(); - errx(2, "Output may be truncated"); -} diff --git a/usr.bin/unifdef/unifdef.h b/usr.bin/unifdef/unifdef.h deleted file mode 100644 index 141061c3dc1..00000000000 --- a/usr.bin/unifdef/unifdef.h +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2012 - 2013 Tony Finch - * - * 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 - -#include -#include -#include -#include -#include -#include -#include -#include - -/* portability stubs */ - -#define fbinmode(fp) (fp) - -#define replace(old,new) rename(old,new) - -static FILE * -mktempmode(char *tmp, int mode) -{ - int fd = mkstemp(tmp); - if (fd < 0) return (NULL); - fchmod(fd, mode & (S_IRWXU|S_IRWXG|S_IRWXO)); - return (fdopen(fd, "wb")); -} diff --git a/usr.bin/unifdef/unifdefall.sh b/usr.bin/unifdef/unifdefall.sh deleted file mode 100644 index c046817d946..00000000000 --- a/usr.bin/unifdef/unifdefall.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# -# unifdefall: remove all the #if's from a source file -# -# SPDX-License-Identifier: BSD-2-Clause-FreeBSD -# -# Copyright (c) 2002 - 2013 Tony Finch -# Copyright (c) 2009 - 2010 Jonathan Nieder -# -# 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 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 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. -# - -set -e - -unifdef="$(dirname "$0")/unifdef" -if [ ! -e "$unifdef" ] -then - unifdef=unifdef -fi - -case "$@" in -"-d "*) echo DEBUGGING 1>&2 - debug=-d - shift -esac - -tmp=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXXXXXX") || exit 2 -trap 'rm -r "$tmp" || exit 2' EXIT - -export LC_ALL=C - -# list of all controlling macros; assume these are undefined -"$unifdef" $debug -s "$@" | sort -u | sed 's/^/#undef /' >"$tmp/undefs" -# list of all macro definitions -cc -E -dM "$@" | sort >"$tmp/defs" - -case $debug in --d) cat "$tmp/undefs" "$tmp/defs" 1>&2 -esac - -# order of -f arguments means definitions override undefs -"$unifdef" $debug -k -f "$tmp/undefs" -f "$tmp/defs" "$@" diff --git a/usr.bin/units/pathnames.h b/usr.bin/units/pathnames.h deleted file mode 100644 index a7aabf8eb0e..00000000000 --- a/usr.bin/units/pathnames.h +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * Copyright (c) 1993 Christopher G. Demetriou - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * 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. - */ - -#define _PATH_UNITSLIB "/usr/share/misc/units.lib" diff --git a/usr.bin/units/units.lib b/usr.bin/units/units.lib deleted file mode 100644 index b9a279cda24..00000000000 --- a/usr.bin/units/units.lib +++ /dev/null @@ -1,731 +0,0 @@ - -/ primitive units - -m !a! -kg !b! -sec !c! -coul !d! -candela !e! -usdollar !f! -euro !g! -bit !h! -erlang !i! -K !j! - -/ prefixes - -yotta- 1e24 -zetta- 1e21 -exa- 1e18 -peta- 1e15 -tera- 1e12 -giga- 1e9 -mega- 1e6 -myria- 1e4 -kilo- 1e3 -hecto- 1e2 -deka- 1e1 -deca- deka -deci- 1e-1 -centi- 1e-2 -milli- 1e-3 -micro- 1e-6 -nano- 1e-9 -pico- 1e-12 -femto- 1e-15 -atto- 1e-18 -zopto- 1e-21 -zepto- zopto -yocto- 1e-24 - -semi- .5 -demi- .5 - -Y- yotta -Z- zetta -E- exa -P- peta -T- tera -G- giga -M- mega -k- kilo -h- hecto -da- deka -d- deci -c- centi -m- milli -n- nano -p- pico -f- femto -a- atto -z- zopto -y- yocto - -/ binary prefixes introduced in 1999 -exbi- 1152921504606846976 -pebi- 1125899906842624 -tebi- 1099511627776 -gibi- 1073741824 -mebi- 1048576 -kibi- 1024 - -Ei- exbi -Pi- pebi -Ti- tebi -Gi- gibi -Mi- mebi -Ki- kibi - -/ constants - -fuzz 1 -pi 3.14159265358979323846 -c 2.99792458e+8 m/sec -g0 9.80665 m/sec2 -g g0 -bigG 6.67428e-11 m3/kg/s2 -AU 1.49597870691e+11 m fuzz -au AU -mole 6.0221417930e+23 fuzz -e 1.6021917e-19 coul fuzz -energy c2 -force g -mercury 1.3332239e+5 kg/m2-sec2 -hg mercury -mmHg 0.001 m hg -#mu 4.e-7 pi-N/A2 -epsilon 1.0 /mu/c2 -alpha 0.5 mu-c-e2/planck -planck 6.6260755e-34 joule-sec -hbar 0.5 planck/pi -electronmass 9.1093821545-31 kg -protonmass 1.6726217129-27 kg -neutronmass 1.6749272928-27 kg - -/ dimensionless - -radian .5 / pi -degree 1|180 pi-radian -circle 2 pi-radian -turn 2 pi-radian -revolution turn -rev turn -grade .9 degree -arcdeg 1 degree -arcmin 1|60 arcdeg -ccs 1|36 erlang -arcsec 1|60 arcmin - -steradian radian2 -sphere 4 pi-steradian -sr steradian - -/ Time - -second sec -s sec -minute 60 sec -min minute -hour 60 min -hr hour -day 24 hr -da day -week 7 day -year 365.24219879 day fuzz -yr year -month 1|12 year -us microsec - -/ Mass - -gram millikg -gm gram -metricton kilokg - -/ Avoirdupois - -lb .45359237 kg -pound lb -lbf lb g -ounce 1|16 lb -oz ounce -dram 1|16 oz -dr dram -grain 1|7000 lb -gr grain -shortton 2000 lb -ton shortton -longton 2240 lb - -/ Apothecary - -scruple 20 grain -apdram 60 grain -apounce 480 grain -appound 5760 grain -troypound appound - -/ Mining - -troyounce apounce -troz apounce -pennyweight 1|20 troz -pwt pennyweight -dwt pennyweight - -/ Length - -meter m -micron micrometer -angstrom decinanometer -ao 0.25 alpha/pi/rydbergconst - -inch 2.54 cm -in inch -foot 12 in -feet foot -ft foot -yard 3 ft -yd yard -rod 5.5 yd -rd rod -mile 5280 ft -mi mile - -british 1200|3937 m/ft -nmile 1852 m - -acre 4840 yd2 - -cc cm3 -liter kilocc -ml milliliter - -/ US Liquid - -gallon 231 in3 -imperial 1.20095 -gal gallon -quart 1|4 gal -qt quart -pint 1|2 qt -pt pint - -floz 1|16 pt -fldr 1|8 floz -shot 3|2 floz - -/ US Dry - -dry 268.8025 in3/gallon fuzz -peck 8 dry-quart -pk peck -bushel 4 peck -bu bushel -chaldron 36 bushel - -/ British - -brgallon 277.420 in3 fuzz -brquart 1|4 brgallon -brpint 1|2 brquart -brfloz 1|20 brpint -brpeck 554.84 in3 fuzz -brbushel 4 brpeck -brhundredweight 112 lb - -/ Bottles - -bottle 750 milliliter -/bottle fifth - -miniature 100 milliliter -split 1|4 bottle -half 1|2 bottle -magnum 2 bottle -jeroboam 4 bottle -rehoboam 6 bottle -methuselah 8 bottle -salmanazar 12 bottle -balthazar 16 bottle -nebuchadnezzar 20 bottle -sovereign 34 bottle - -/ Bottles - alternate names and spellings - -pony split -fillette half -tappit-hen 3 imperial -rheoboam rehoboam -shalmaneser salmanazar - -/ Russian -berkovets 10 pood -pood 40 funt -funt 0.40951 kg -lot 1|32 funt -zolotnik 1|3 lot -dolya 1|96 zolotnik -rumile 7 verst -mezhevayaverst 2 verst -verst 1066.8 m -sazhen 1|500 verst -kosayasazhen 1|430.2 verst -arshin 1|1500 verst -/ is not exactly defined -ruell 16.54 in -liniya 1|10 in -vershok 1.75 in -pyad 7 in -vedro 12.3 liter -shtoff 1|10 vedro -vinebottle 1|16 vedro -vodkabottle 1|20 vedro -charka 1|100 vedro -shkalik 1|200 vedro -desyatina_state 109.3 are -desyatina_farmery 0.75 desyatina_state -sqverst 104.2 desyatina_state -sqarshin 1|21600 desyatina_state -sqfoot 1|117600 desyatina_state - -/ Energy Work - -newton kg-m/sec2 -nt newton -N newton -joule nt-m -J joule -cal 4.1868 joule - -/ Electrical - -coulomb coul -C coul -ampere coul/sec -A ampere -amp ampere -watt joule/sec -W watt -volt watt/amp -ohm volt/amp -mho /ohm -farad coul/volt -F farad -henry sec2/farad -H henry -weber volt-sec -Wb weber - -/ Light - -cd candela -lumen cd sr -lux cd sr/m2 - -/ EMU currencies have constant exchange rate against Euro since 1.1.1999. -/ See http://en.wikipedia.org/wiki/Euro for details. -austriaschilling 1|13.7603 euro -belgiumfranc 1|40.3399 euro -finlandmarkka 1|5.94573 euro -francefranc 1|6.55957 euro -germanymark 1|1.95583 euro -greecedrachma 1|340.750 euro -irelandpunt 1|0.787564 euro -italylira 1|1936.27 euro -luxembourgfranc 1|40.3399 euro -netherlandsguilder 1|2.20371 euro -portugalescudo 1|200.482 euro -spainpeseta 1|166.386 euro -sloveniantolar 1|239.640 euro -cypriotpound 1|0.585274 euro -malteselira 1|0.429300 euro -slovakkoruna 1|30.1260 euro - -/ These ones are pegged to the Euro -/ See http://en.wikipedia.org/wiki/Euro for details. -bosniaherzegovinamark 1|1.95583 euro -bulgarianlev 1|1.95583 euro -capeverdeanescudo 1|110.265 euro -centralafricancfafranc 1|655.957 euro -comorosfranc 1|491.96775 euro -danishkrone 1|7.46038 euro -estoniakroon 1|15.6466 euro -lithuanianlitas 1|3.45280 euro -pacificfrancexchange 1|0.00838 euro -westafricancfafranc 1|655.957 euro - -/ These ones are pegged on the US Dollar -/ See http://en.wikipedia.org/wiki/USD for details. -dollar usdollar -arubanflorin 1|1.75 usdollar -bahamiandollar 1|1 usdollar -bahrainidinar 1|0.376 usdollar -barbadiandollar 1|2 usdollar -belizedollar 1|2 usdollar -belarusianruble 1|2135 usdollar -bermudiandollar 1|1 usdollar -caymanislandsdollar 1.2 usdollar -cubanconvertiblepeso 1.08 usdollar -djiboutianfranc 1|177.721 usdollar -eastcaribbeandollar 1|2.7 usdollar -eritreannakfa 1|15 usdollar -hongkongdollar 1|7.80 usdollar -macanesepatacas 1|1.03 hongkongdollar -jordaniandinar 1|0.709 usdollar -lebanesepound 1|1507.5 usdollar -maldivianrufiyaa 1|12.8 usdollar -netherlandsantilleanguilder 1|1.79 usdollar -omanirial 2.6008 usdollar -qataririyal 1|3.64 usdollar -saudiriyal 1|3.75 usdollar -unitedarabemiratesdirham 1|3.6725 usdollar - -bosniamark bosniaherzegovinamark -cfafranc centralafricancfafranc -cfpfranc pacificfrancexchange -drachma greecedrachma -escudo portugalescudo -franc francefranc -guilder netherlandsguilder -herzegovinamark bosniaherzegovinamark -hollandguilder netherlandsguilder -lira italylira -mark germanymark -markka finlandmarkka -peseta spainpeseta -rand southafricarand - -/ computer - -baud bit/sec -nibble 4 bit -nybble nibble -byte 8 bit -word 2 byte -block 512 byte -kbyte 1024 byte -megabyte 1024 kbyte -gigabyte 1024 megabyte -terabyte 1024 gigabyte -petabyte 1024 terabyte -exabyte 1024 petabyte -zettabyte 1024 exabyte -yottabyte 1024 zettabyte -kilobyte kbyte -meg megabyte - - -/ Trivia - -% 1|100 -abampere 10 ampere -admiraltyknot 6080 ft/hr -apostilb cd/pi-m2 -are 1e+2 m2 -asb apostilb -arpentcan 27.52 mi -arpentlin 191.835 ft -astronomicalunit au -atmosphere 1.01325e+5 nt/m2 -atm atmosphere -atomicmassunit 1.66053878283e-27 kg fuzz -# year 3.15569259747e7 sec fuzz -amu atomicmassunit -bag 94 lb -bakersdozen 13 -bar 1e+5 nt/m2 -barie 1e-1 nt/m2 -barleycorn 1|3 in -barn 1e-28 m2 -oilbarrel 42 gal -barrel oilbarrel -barye 1e-1 nt/m2 -baryl microbar -bev 1e+9 e-volt -biot 10 amp -blondel cd/pi-m2 -boardfoot 144 in3 -bolt 40 yd -bottommeasure 1|40 in -britishthermalunit 1.05506e+3 joule fuzz -btu britishthermalunit -refrigeration 12000 btu/ton-hour -buck usdollar -cable 720 ft -caliber 1e-2 in -calorie cal -carat 205 milligram -caratgold 1|24 -cent centidollar -cental 100 lb -centesimalminute 1e-2 grade -centesimalsecond 1e-4 grade -century 100 year -cfs ft3/sec -chain 66 ft -circularinch 1|4 pi-in2 -circularmil 1e-6|4 pi-in2 -clusec 1e-8 mm-hg m3/s -coomb 4 bu -cord 128 ft3 -cordfoot cord -crith 9.06e-2 gm -cubit 18 in -cup 1|2 pt -curie 3.7e+10 /sec -dalton amu -decade 10 yr -dioptre /m -displacementton 35 ft3 -doppelzentner 100 kg -dozen 12 -drop .03 cm3 -dyne cm-gm/sec2 -electronvolt e-volt -ell 45 in -engineerschain 100 ft -engineerslink 100|100 ft -equivalentfootcandle lumen/pi-ft2 -equivalentlux lumen/pi-m2 -equivalentphot cd/pi-cm2 -erg cm2-gm/sec2 -ev e-volt -faraday 9.6485309e+4 coul -fathom 6 ft -fermi 1e-15 m -fifth 4|5 qt -fin 5 usdollar -finger 7|8 in -firkin 9 gal -footcandle lumen/ft2 -footlambert cd/pi-ft2 -fortnight 14 da -franklin 3.33564e-10 coul -frigorie kilocal -furlong 220 yd -galileo 1e-2 m/sec2 -gamma 1e-9 weber/m2 -gauss 1e-4 weber/m2 -G gauss -geodeticfoot british-ft -geographicalmile 1852 m -gilbert 2.5 amp/pi -gill 1|4 pt -gross 144 -gunterschain 22 yd -hand 4 in -hartree 2 rydberg -head water -hectare 1e+4 m2 -hefnercandle .92 cd -hertz /sec -Hz hertz -hogshead 63 gallon -hd hogshead -homestead 1|4 mi2 -horsepower 735.50 watt -hp horsepower -hubble 1e9 ly -hyl gm force sec2/m -hz /sec -imaginarycubicfoot 1.4 ft3 -jansky 1e-26 W/m2-Hz -Jy jansky -karat 1|24 -kayser /cm -key kg -kilderkin 18 gal -knot nmile/hr -kn knot -lambert cd/pi-cm2 -Lb lambert -langley cal/cm2 -last 80 bu -league 3 mi -lightyear c-yr -ly lightyear -line 1|12 in -link 66|100 ft -longhundredweight 112 lb -longquarter 28 lb -lusec 1e-6 mm-hg m3/s -m_earth 5.97223e24 kg -m_moon 7.34e22 kg -m_sun 1.98843e30 kg -mach 331.46 m/sec -marineleague 3 nmile -maxwell 1e-8 weber -Mx maxwell -metriccarat 200 milligram -mgd megagal/day -mh millihenry -mil 1e-3 in -millennium 1000 year -minersinch 1.5 ft3/min -minim 1|60 fldr -mo month -mpg mile/gal -mph mile/hr -nail 1|16 yd -nauticalmile nmile -nit cd/m2 -noggin 1|8 qt -nox 1e-3 lux -oersted 2.5e+2 amp/m/pi -Oe oersted -pace 36 in -pair 2 -palm 3 in -parasang 3.5 mi -parsec AU-radian/arcsec -pascal nt/m2 -Pa pascal -pc parsec -percent % -perch rd -phot lumen/cm2 -pica 1|6 in -pieze 1e+3 nt/m2 -pipe 4 barrel -point 1|72 in -poise gm/cm-sec -P poise -pole rd -pond 9.80665e-3 nt -poundal ft-lb/sec2 -pdl poundal -proof 1|200 -psi lb-g/in2 -quarter 9 in -quartersection 1|4 mi2 -quintal 100 kg -quire 25 -r_earth 6.378e8 cm -r_moon 1.738e7 cm -r_sun 6.9599e10 cm -rackunit 1.75 in -rad 100 erg/gm -ream 500 -registerton 100 ft3 -rem 0.01 J/kg -rhe 10 m2/nt-sec -rontgen 2.58e-4 curie/kg -roentgen rontgen -rood 1.21e+3 yd -rope 20 ft -RU rackunit -rutherford 1e+6 /sec -rydbergconst 0.5 elctronmass-c-alpha2/planck -rydberg rydbergconst-planck-c -sabin 1 ft2 -sack 3 bu -score 20 -seam 8 bu -section mi2 -shed 1e-24 barn -shippington 40 ft3 -shorthundredweight 100 lb -shortquarter 25 lb -siemens /ohm -sigma microsec -skein 120 yd -skot 1e-3 apostilb -slug lb-g-sec2/ft -smoot 67 in -span 9 in -spat 4 pi sr -spindle 14400 yd -square 100 ft2 -stere m3 -sthene 1e+3 nt -stilb cd/cm2 -sb stilb -stoke 1e-4 m2/sec -stone 14 lb -strike 2 bu -surveyfoot british-ft -surveyyard 3 surveyfoot -surveyorschain 66 ft -surveyorslink 66|100 ft -tablespoon 4 fldr -tbl tablespoon -tbsp tablespoon -teaspoon 4|3 fldr -tesla weber/m2 -T tesla -therm 1e+5 btu -thermie 1e+6 cal -timberfoot ft3 -tnt 4.6e+6 m2/sec2 -tonne 1e+6 gm -torr mm hg -township 36 mi2 -tsp teaspoon -tun 8 barrel -water gram g / cc -wey 40 bu -weymass 252 lb -Xunit 1.00206e-13 m -k 1.38047e-16 erg/degC - - -degC 1&+273.15 K -kelvin K -brewster 1e-12 m2/newton -degF 5|9&255.37222222222222222222 K -degreesrankine 5|9 K -degrankine degreesrankine -degreerankine degreesrankine -degreaumur 10|8&+273.15 K -drachm 60 grain -poncelet 100 kg m g / sec -denier .05|450 gram / m -tex .001 gram / m -englishell 45 inch -scottishell 37.2 inch -flemishell 27 inch -V volt -eV e V -bohrradius hbar2-C2/8.988e9 N m2-e2-electronmass -becquerel 1|3.7e10 curie -fresnel 1e12 hertz -statcoul 1|2.99792458e9 coul -statamp 1|2.99792458e9 amp -statvolt 2.99792458e2 volt -statcoulomb statcoul -statampere statamp -debye 3.33564e-30 coul-m -pulsatance 2 pi/sec -rpm rev/minute -rps rev/sec -kilohm kiloohm -megohm megaohm -siderealyear 365.256360417 day -siderealday 23.934469444 hour -siderealhour 1|24 sidereal day -lunarmonth 29.5305555 day -synodicmonth lunarmonth -siderealmonth 27.32152777 day -tropicalyear year -solaryear year -lunaryear 12 lunarmonth -cran 37.5 brgallon -kip 1000 lbf -frenchfoot 16|15 ft -frenchfeet frenchfoot -toise 6 frenchfeet -sievert 8.4 rontgen -candle 1.02 candela -militarypace 2.5 feet -metre meter -litre liter -gramme gram -iudiptheria 62.8 microgram -iupenicillin .6 microgram -iuinsulin 41.67 microgram -cottonyarncount 2520 ft/pound -linenyarncount 900 ft/pound -worstedyarncount 1680 ft/pound -metricyarncount meter/gram -jewlerspoint 2 milligram diff --git a/usr.bin/users/users.c b/usr.bin/users/users.c deleted file mode 100644 index 652d790c51c..00000000000 --- a/usr.bin/users/users.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 1980, 1987, 1993 - * The Regents of the University of California. 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#ifndef lint -static const char copyright[] = -"@(#) Copyright (c) 1980, 1987, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)users.c 8.1 (Berkeley) 6/6/93"; -#endif -#endif /* not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -typedef char namebuf[sizeof(((struct utmpx *)0)->ut_user) + 1]; - -int scmp(const void *, const void *); -static void usage(void); - -int -main(int argc, char **argv) -{ - namebuf *names = NULL; - int ncnt = 0; - int nmax = 0; - int cnt; - struct utmpx *ut; - int ch; - - while ((ch = getopt(argc, argv, "")) != -1) - switch(ch) { - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - setutxent(); - while ((ut = getutxent()) != NULL) { - if (ut->ut_type != USER_PROCESS) - continue; - if (ncnt >= nmax) { - nmax += 32; - names = realloc(names, sizeof(*names) * nmax); - if (!names) { - errx(1, "realloc"); - /* NOTREACHED */ - } - } - (void)strlcpy(names[ncnt], ut->ut_user, sizeof(*names)); - ++ncnt; - } - endutxent(); - if (ncnt > 0) { - qsort(names, ncnt, sizeof(namebuf), scmp); - (void)printf("%s", names[0]); - for (cnt = 1; cnt < ncnt; ++cnt) - if (strcmp(names[cnt], names[cnt - 1]) != 0) - (void)printf(" %s", names[cnt]); - (void)printf("\n"); - } - exit(0); -} - -static void -usage(void) -{ - (void)fprintf(stderr, "usage: users\n"); - exit(1); -} - -int -scmp(const void *p, const void *q) -{ - - return (strcmp(p, q)); -} diff --git a/usr.sbin/bhyve/consport.c b/usr.sbin/bhyve/consport.c deleted file mode 100644 index 6f16a945480..00000000000 --- a/usr.sbin/bhyve/consport.c +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2011 NetApp, Inc. - * 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 NETAPP, INC ``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 NETAPP, INC 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 - -#include -#ifndef WITHOUT_CAPSICUM -#include -#endif -#include - -#ifndef WITHOUT_CAPSICUM -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -#include "inout.h" -#include "pci_lpc.h" -#include "debug.h" - -#define BVM_CONSOLE_PORT 0x220 -#define BVM_CONS_SIG ('b' << 8 | 'v') - -static struct termios tio_orig, tio_new; - -static void -ttyclose(void) -{ - tcsetattr(STDIN_FILENO, TCSANOW, &tio_orig); -} - -static void -ttyopen(void) -{ - tcgetattr(STDIN_FILENO, &tio_orig); - - cfmakeraw(&tio_new); - tcsetattr(STDIN_FILENO, TCSANOW, &tio_new); - raw_stdio = 1; - - atexit(ttyclose); -} - -static bool -tty_char_available(void) -{ - fd_set rfds; - struct timeval tv; - - FD_ZERO(&rfds); - FD_SET(STDIN_FILENO, &rfds); - tv.tv_sec = 0; - tv.tv_usec = 0; - if (select(STDIN_FILENO + 1, &rfds, NULL, NULL, &tv) > 0) { - return (true); - } else { - return (false); - } -} - -static int -ttyread(void) -{ - char rb; - - if (tty_char_available()) { - read(STDIN_FILENO, &rb, 1); - return (rb & 0xff); - } else { - return (-1); - } -} - -static void -ttywrite(unsigned char wb) -{ - (void) write(STDOUT_FILENO, &wb, 1); -} - -static int -console_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, - uint32_t *eax, void *arg) -{ - static int opened; -#ifndef WITHOUT_CAPSICUM - cap_rights_t rights; - cap_ioctl_t cmds[] = { TIOCGETA, TIOCSETA, TIOCGWINSZ }; -#endif - - if (bytes == 2 && in) { - *eax = BVM_CONS_SIG; - return (0); - } - - /* - * Guests might probe this port to look for old ISA devices - * using single-byte reads. Return 0xff for those. - */ - if (bytes == 1 && in) { - *eax = 0xff; - return (0); - } - - if (bytes != 4) - return (-1); - - if (!opened) { -#ifndef WITHOUT_CAPSICUM - cap_rights_init(&rights, CAP_EVENT, CAP_IOCTL, CAP_READ, - CAP_WRITE); - if (caph_rights_limit(STDIN_FILENO, &rights) == -1) - errx(EX_OSERR, "Unable to apply rights for sandbox"); - if (caph_ioctls_limit(STDIN_FILENO, cmds, nitems(cmds)) == -1) - errx(EX_OSERR, "Unable to apply rights for sandbox"); -#endif - ttyopen(); - opened = 1; - } - - if (in) - *eax = ttyread(); - else - ttywrite(*eax); - - return (0); -} - -SYSRES_IO(BVM_CONSOLE_PORT, 4); - -static struct inout_port consport = { - "bvmcons", - BVM_CONSOLE_PORT, - 1, - IOPORT_F_INOUT, - console_handler -}; - -void -init_bvmcons(void) -{ - - register_inout(&consport); -} diff --git a/usr.sbin/bhyve/dbgport.c b/usr.sbin/bhyve/dbgport.c deleted file mode 100644 index 671972ae0ce..00000000000 --- a/usr.sbin/bhyve/dbgport.c +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2011 NetApp, Inc. - * 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 NETAPP, INC ``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 NETAPP, INC 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 - -#include -#ifndef WITHOUT_CAPSICUM -#include -#endif -#include -#include -#include -#include - -#ifndef WITHOUT_CAPSICUM -#include -#endif -#include -#include -#include -#include -#include -#include -#include - -#include "inout.h" -#include "dbgport.h" -#include "pci_lpc.h" - -#define BVM_DBG_PORT 0x224 -#define BVM_DBG_SIG ('B' << 8 | 'V') - -static int listen_fd, conn_fd; - -static struct sockaddr_in sin; - -static int -dbg_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes, - uint32_t *eax, void *arg) -{ - int nwritten, nread, printonce; - int on = 1; - char ch; - - if (bytes == 2 && in) { - *eax = BVM_DBG_SIG; - return (0); - } - - if (bytes != 4) - return (-1); - -again: - printonce = 0; - while (conn_fd < 0) { - if (!printonce) { - printf("Waiting for connection from gdb\r\n"); - printonce = 1; - } - conn_fd = accept4(listen_fd, NULL, NULL, SOCK_NONBLOCK); - if (conn_fd >= 0) { - /* Avoid EPIPE after the client drops off. */ - (void)setsockopt(conn_fd, SOL_SOCKET, SO_NOSIGPIPE, - &on, sizeof(on)); - /* Improve latency for one byte at a time tranfers. */ - (void)setsockopt(conn_fd, IPPROTO_TCP, TCP_NODELAY, - &on, sizeof(on)); - } else if (errno != EINTR) { - perror("accept"); - } - } - - if (in) { - nread = read(conn_fd, &ch, 1); - if (nread == -1 && errno == EAGAIN) - *eax = -1; - else if (nread == 1) - *eax = ch; - else { - close(conn_fd); - conn_fd = -1; - goto again; - } - } else { - ch = *eax; - nwritten = write(conn_fd, &ch, 1); - if (nwritten != 1) { - close(conn_fd); - conn_fd = -1; - goto again; - } - } - return (0); -} - -static struct inout_port dbgport = { - "bvmdbg", - BVM_DBG_PORT, - 1, - IOPORT_F_INOUT, - dbg_handler -}; - -SYSRES_IO(BVM_DBG_PORT, 4); - -void -init_dbgport(int sport) -{ - int reuse; -#ifndef WITHOUT_CAPSICUM - cap_rights_t rights; -#endif - - conn_fd = -1; - - if ((listen_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - perror("cannot create socket"); - exit(4); - } - - sin.sin_len = sizeof(sin); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = htonl(INADDR_ANY); - sin.sin_port = htons(sport); - - reuse = 1; - if (setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &reuse, - sizeof(reuse)) < 0) { - perror("cannot set socket options"); - exit(4); - } - - if (bind(listen_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { - perror("cannot bind socket"); - exit(4); - } - - if (listen(listen_fd, 1) < 0) { - perror("cannot listen socket"); - exit(4); - } - -#ifndef WITHOUT_CAPSICUM - cap_rights_init(&rights, CAP_ACCEPT, CAP_READ, CAP_WRITE); - if (caph_rights_limit(listen_fd, &rights) == -1) - errx(EX_OSERR, "Unable to apply rights for sandbox"); -#endif - - register_inout(&dbgport); -} diff --git a/usr.sbin/bhyve/dbgport.h b/usr.sbin/bhyve/dbgport.h deleted file mode 100644 index c8754b95d02..00000000000 --- a/usr.sbin/bhyve/dbgport.h +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2011 NetApp, Inc. - * 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 NETAPP, INC ``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 NETAPP, INC 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. - * - */ - -#ifndef _DBGPORT_H_ -#define _DBGPORT_H_ - -void init_dbgport(int port); - -#endif diff --git a/usr.sbin/bluetooth/ath3kfw/ath3kfw.c b/usr.sbin/bluetooth/ath3kfw/ath3kfw.c deleted file mode 100644 index 1fb1460a23d..00000000000 --- a/usr.sbin/bluetooth/ath3kfw/ath3kfw.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * ath3kfw.c - */ - -/*- - * Copyright (c) 2010 Maksim Yevmenkin - * 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: stable/10/usr.sbin/bluetooth/ath3kfw/ath3kfw.c 249179 2013-04-05 23:42:22Z adrian $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define ATH3KFW "ath3kfw" -#define ATH3KFW_VENDOR_ID 0x0cf3 -#define ATH3KFW_PRODUCT_ID 0x3000 -#define ATH3KFW_FW "/usr/local/etc/ath3k-1.fw" -#define ATH3KFW_BULK_EP 0x02 -#define ATH3KFW_REQ_DFU_DNLOAD 1 -#define ATH3KFW_MAX_BSIZE 4096 - -static int parse_ugen_name (char const *ugen, uint8_t *bus, - uint8_t *addr); -static int find_device (struct libusb20_backend *be, - uint8_t bus, uint8_t addr, - struct libusb20_device **dev); -static int download_firmware (struct libusb20_device *dev, - char const *firmware); -static void usage (void); - -static int vendor_id = ATH3KFW_VENDOR_ID; -static int product_id = ATH3KFW_PRODUCT_ID; - -/* - * Firmware downloader for Atheros AR3011 based USB Bluetooth devices - */ - -int -main(int argc, char **argv) -{ - uint8_t bus, addr; - char const *firmware; - struct libusb20_backend *be; - struct libusb20_device *dev; - int n; - - openlog(ATH3KFW, LOG_NDELAY|LOG_PERROR|LOG_PID, LOG_USER); - - bus = 0; - addr = 0; - firmware = ATH3KFW_FW; - - while ((n = getopt(argc, argv, "d:f:hp:v:")) != -1) { - switch (n) { - case 'd': /* ugen device name */ - if (parse_ugen_name(optarg, &bus, &addr) < 0) - usage(); - break; - - case 'f': /* firmware file */ - firmware = optarg; - break; - case 'p': /* product id */ - product_id = strtol(optarg, NULL, 0); - break; - case 'v': /* vendor id */ - vendor_id = strtol(optarg, NULL, 0); - break; - case 'h': - default: - usage(); - break; - /* NOT REACHED */ - } - } - - be = libusb20_be_alloc_default(); - if (be == NULL) { - syslog(LOG_ERR, "libusb20_be_alloc_default() failed"); - return (-1); - } - - if (find_device(be, bus, addr, &dev) < 0) { - syslog(LOG_ERR, "ugen%d.%d is not recognized as " \ - "Atheros AR3011 based device " \ - "(possibly caused by lack of permissions)", bus, addr); - return (-1); - } - - if (download_firmware(dev, firmware) < 0) { - syslog(LOG_ERR, "could not download %s firmare to ugen%d.%d", - firmware, bus, addr); - return (-1); - } - - libusb20_be_free(be); - closelog(); - - return (0); -} - -/* - * Parse ugen name and extract device's bus and address - */ - -static int -parse_ugen_name(char const *ugen, uint8_t *bus, uint8_t *addr) -{ - char *ep; - - if (strncmp(ugen, "ugen", 4) != 0) - return (-1); - - *bus = (uint8_t) strtoul(ugen + 4, &ep, 10); - if (*ep != '.') - return (-1); - - *addr = (uint8_t) strtoul(ep + 1, &ep, 10); - if (*ep != '\0') - return (-1); - - return (0); -} - -/* - * Find USB device - */ - -static int -find_device(struct libusb20_backend *be, uint8_t bus, uint8_t addr, - struct libusb20_device **dev) -{ - struct LIBUSB20_DEVICE_DESC_DECODED *desc; - - *dev = NULL; - - while ((*dev = libusb20_be_device_foreach(be, *dev)) != NULL) { - if (libusb20_dev_get_bus_number(*dev) != bus || - libusb20_dev_get_address(*dev) != addr) - continue; - - desc = libusb20_dev_get_device_desc(*dev); - if (desc == NULL) - continue; - - if (desc->idVendor != vendor_id || - desc->idProduct != product_id) - continue; - - break; - } - - return ((*dev == NULL)? -1 : 0); -} - -/* - * Download firmware - */ - -static int -download_firmware(struct libusb20_device *dev, char const *firmware) -{ - struct libusb20_transfer *bulk; - struct LIBUSB20_CONTROL_SETUP_DECODED req; - int fd, n, error; - uint8_t buf[ATH3KFW_MAX_BSIZE]; - - error = -1; - - if (libusb20_dev_open(dev, 1) != 0) { - syslog(LOG_ERR, "libusb20_dev_open() failed"); - return (error); - } - - if ((bulk = libusb20_tr_get_pointer(dev, 0)) == NULL) { - syslog(LOG_ERR, "libusb20_tr_get_pointer() failed"); - goto out; - } - - if (libusb20_tr_open(bulk, ATH3KFW_MAX_BSIZE, 1, ATH3KFW_BULK_EP) != 0) { - syslog(LOG_ERR, "libusb20_tr_open(%d, 1, %d) failed", - ATH3KFW_MAX_BSIZE, ATH3KFW_BULK_EP); - goto out; - } - - if ((fd = open(firmware, O_RDONLY)) < 0) { - syslog(LOG_ERR, "open(%s) failed. %s", - firmware, strerror(errno)); - goto out1; - } - - n = read(fd, buf, 20); - if (n != 20) { - syslog(LOG_ERR, "read(%s, 20) failed. %s", - firmware, strerror(errno)); - goto out2; - } - - LIBUSB20_INIT(LIBUSB20_CONTROL_SETUP, &req); - req.bmRequestType = LIBUSB20_REQUEST_TYPE_VENDOR; - req.bRequest = ATH3KFW_REQ_DFU_DNLOAD; - req.wLength = 20; - - if (libusb20_dev_request_sync(dev, &req, buf, NULL, 5000, 0) != 0) { - syslog(LOG_ERR, "libusb20_dev_request_sync() failed"); - goto out2; - } - - for (;;) { - n = read(fd, buf, sizeof(buf)); - if (n < 0) { - syslog(LOG_ERR, "read(%s, %d) failed. %s", - firmware, (int) sizeof(buf), strerror(errno)); - goto out2; - } - if (n == 0) - break; - - libusb20_tr_setup_bulk(bulk, buf, n, 3000); - libusb20_tr_start(bulk); - - while (libusb20_dev_process(dev) == 0) { - if (libusb20_tr_pending(bulk) == 0) - break; - - libusb20_dev_wait_process(dev, -1); - } - - if (libusb20_tr_get_status(bulk) != 0) { - syslog(LOG_ERR, "bulk transfer failed with status %d", - libusb20_tr_get_status(bulk)); - goto out2; - } - } - - error = 0; -out2: - close(fd); -out1: - libusb20_tr_close(bulk); -out: - libusb20_dev_close(dev); - - return (error); -} - -/* - * Display usage and exit - */ - -static void -usage(void) -{ - printf( -"Usage: %s -d ugenX.Y -f firmware_file\n" -"Usage: %s -h\n" \ -"Where:\n" \ -"\t-d ugenX.Y ugen device name\n" \ -"\t-f firmware image firmware image file name for download\n" \ -"\t-v vendor_id vendor id\n" \ -"\t-p vendor_id product id\n" \ -"\t-h display this message\n", ATH3KFW, ATH3KFW); - - exit(255); -} - diff --git a/usr.sbin/bluetooth/bt3cfw/Makefile b/usr.sbin/bluetooth/bt3cfw/Makefile deleted file mode 100644 index 2eaca309325..00000000000 --- a/usr.sbin/bluetooth/bt3cfw/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $Id: Makefile,v 1.5 2003/08/14 20:06:00 max Exp $ - -PROG= bt3cfw -MAN= bt3cfw.8 -WARNS?= 2 - -LIBADD+= netgraph - -.include diff --git a/usr.sbin/bluetooth/bt3cfw/Makefile.depend b/usr.sbin/bluetooth/bt3cfw/Makefile.depend deleted file mode 100644 index 7bdc10ae0f8..00000000000 --- a/usr.sbin/bluetooth/bt3cfw/Makefile.depend +++ /dev/null @@ -1,17 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - lib/libnetgraph \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/bluetooth/bt3cfw/bt3cfw.8 b/usr.sbin/bluetooth/bt3cfw/bt3cfw.8 deleted file mode 100644 index 62f2d26347d..00000000000 --- a/usr.sbin/bluetooth/bt3cfw/bt3cfw.8 +++ /dev/null @@ -1,72 +0,0 @@ -.\" Copyright (c) 2001-2002 Maksim Yevmenkin -.\" 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. -.\" -.\" $Id: bt3cfw.8,v 1.4 2003/05/21 00:34:51 max Exp $ -.\" -.Dd November 11, 2002 -.Dt BT3CFW 8 -.Os -.Sh NAME -.Nm bt3cfw -.Nd firmware download utility for 3Com Bluetooth PC card driver -.Sh SYNOPSIS -.Nm -.Op Fl h -.Fl f Ar Firmware_file_name -.Fl n Ar Netgraph_node_name -.Sh DESCRIPTION -The -.Nm -utility connects to the specified Netgraph driver node of type -.Dv BTCCC -and downloads the specified firmware file. -.Pp -Due to copyright issues, I will no longer provide firmware with the card -driver. -The firmware can be obtained from the Windows driver package that -can be downloaded from the 3COM web site at no charge. -The firmware name is -.Pa BT3CPCC.BIN . -I am using the original firmware that came with the card on CD-ROM. -.Pp -.Dl "MD5 (BT3CPCC.BIN) = 36170fda56ea9fdbf1702c966f8a97f1" -.Pp -The options are as follows: -.Bl -tag -width indent -.It Fl f Ar Firmware_file_name -Specify firmware file name for download. -.It Fl h -Display usage message and exit. -.It Fl n Ar Netgraph_node_name -Connect to the specified Netgraph driver node of type -.Dv BTCCC . -.El -.Sh EXIT STATUS -.Ex -std -.Sh SEE ALSO -.Xr ng_bt3c 4 -.Sh AUTHORS -.An Maksim Yevmenkin Aq Mt m_evmenkin@yahoo.com -.Sh BUGS -Please report if found. diff --git a/usr.sbin/bluetooth/bt3cfw/bt3cfw.c b/usr.sbin/bluetooth/bt3cfw/bt3cfw.c deleted file mode 100644 index 52ab1fc33dc..00000000000 --- a/usr.sbin/bluetooth/bt3cfw/bt3cfw.c +++ /dev/null @@ -1,229 +0,0 @@ -/*- - * bt3cfw.c - * - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Maksim Yevmenkin - * 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. - * - * $Id: bt3cfw.c,v 1.2 2003/05/21 22:40:29 max Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define BT3CFW_IDENT "bt3cfw" -#define BT3CFW_MAX_FIRMWARE_SIZE 0xffff - -/* Convert hex ASCII to int4 */ -static int -hexa2int4(const char *a) -{ - if ('0' <= *a && *a <= '9') - return (*a - '0'); - - if ('A' <= *a && *a <= 'F') - return (*a - 'A' + 0xa); - - if ('a' <= *a && *a <= 'f') - return (*a - 'a' + 0xa); - - syslog(LOG_ERR, "Invalid hex character: '%c' (%#x)", *a, *a); - exit(255); -} - -/* Convert hex ASCII to int8 */ -static int -hexa2int8(const char *a) -{ - return ((hexa2int4(a) << 4) | hexa2int4(a + 1)); -} - -/* Convert hex ASCII to int16 */ -static int -hexa2int16(const char *a) -{ - return ((hexa2int8(a) << 8) | hexa2int8(a + 2)); -} - -/* Convert hex ASCII to int32 */ -static int -hexa2int32(const char *a) -{ - return ((hexa2int16(a) << 16) | hexa2int16(a + 4)); -} - -/* Display usage() and exit */ -static void -usage(void) -{ - syslog(LOG_ERR, "Usage: %s -f FirmwareFile -n NodeName", BT3CFW_IDENT); - exit(255); -} - -/* Main */ -int -main(int argc, char *argv[]) -{ - FILE *firmware_file = NULL; - char buffer[80], path[NG_PATHSIZ], - *firmware_filename = NULL; - uint8_t *firmware = NULL; - int firmware_size, opt, cs, ds; - - memset(path, 0, sizeof(path)); - openlog(BT3CFW_IDENT, LOG_NDELAY|LOG_PID|LOG_PERROR, LOG_USER); - - while ((opt = getopt(argc, argv, "f:hn:")) != -1) { - switch (opt) { - case 'f': - firmware_filename = optarg; - break; - - case 'n': - snprintf(path, sizeof(path), "%s:", optarg); - break; - - case 'h': - default: - usage(); - /* NOT REACHED */ - } - } - - if (firmware_filename == NULL || path[0] == 0) - usage(); - /* NOT REACHED */ - - firmware = (uint8_t *) calloc(BT3CFW_MAX_FIRMWARE_SIZE, - sizeof(uint8_t)); - if (firmware == NULL) { - syslog(LOG_ERR, "Could not allocate firmware buffer"); - exit(255); - } - - if ((firmware_file = fopen(firmware_filename, "r")) == NULL) { - syslog(LOG_ERR, "Could not open BT3C firmware file %s. %s (%d)", - firmware_filename, strerror(errno), errno); - exit(255); - } - - firmware_size = 0; - - while (fgets(buffer, sizeof(buffer), firmware_file)) { - int i, size, address, cs, fcs; - - size = hexa2int8(buffer + 2); - address = hexa2int32(buffer + 4); - fcs = hexa2int8(buffer + 2 + size * 2); - - if (buffer[1] == '3') { - ng_bt3c_firmware_block_ep *block = NULL; - uint16_t *data = NULL; - - block = (ng_bt3c_firmware_block_ep *) - (firmware + firmware_size); - - firmware_size += sizeof(*block); - if (firmware_size >= BT3CFW_MAX_FIRMWARE_SIZE) { - syslog(LOG_ERR, "Could not add new firmware " \ - "block. Firmware file %s is " \ - "too big, firmware_size=%d", - firmware_filename, - firmware_size); - exit(255); - } - - block->block_address = address; - block->block_size = (size - 4) / 2; - block->block_alignment = (block->block_size * 2) % 3; - if (block->block_alignment != 0) - block->block_alignment = 3 - block->block_alignment; - - firmware_size += (block->block_size * 2); - firmware_size += block->block_alignment; - if (firmware_size >= BT3CFW_MAX_FIRMWARE_SIZE) { - syslog(LOG_ERR, "Could not add new firmware " \ - "data. Firmware file %s is " \ - "too big, firmware_size=%d", - firmware_filename, - firmware_size); - exit(255); - } - - /* First part of the cheksum: size and address */ - cs = 0; - for (i = 0; i < 5; i++) - cs += hexa2int8(buffer + 2 + i * 2); - - /* Data + second part of the cheksum: data */ - data = (uint16_t *)(block + 1); - for (i = 0; i < block->block_size; i++) { - data[i] = hexa2int16(buffer + (i * 4) + 12); - cs += (((data[i] & 0xff00) >> 8) & 0xff); - cs += (data[i] & 0x00ff); - } - } else - for (cs = 0, i = 0; i < size; i++) - cs += hexa2int8(buffer + 2 + i * 2); - - if (((cs + fcs) & 0xff) != 0xff) { - syslog(LOG_ERR, "Invalid firmware file %s. Checksum " \ - "error, cs=%#x, fcs=%#x, checksum=%#x", - firmware_filename, (cs & 0xff), fcs, - ((cs + fcs) & 0xff)); - exit(255); - } - } - - /* Send firmware to the card */ - if (NgMkSockNode(NULL, &cs, &ds) < 0) { - syslog(LOG_ERR, "Could not create Netgraph socket. %s (%d)", - strerror(errno), errno); - exit(255); - } - - if (NgSendMsg(cs, path, NGM_BT3C_COOKIE, - NGM_BT3C_NODE_DOWNLOAD_FIRMWARE, - (void const *) firmware, firmware_size) < 0) { - syslog(LOG_ERR, "Could not send Netgraph message. %s (%d)", - strerror(errno), errno); - exit(255); - } - - free(firmware); - firmware = NULL; - fclose(firmware_file); - - return (0); -} - diff --git a/usr.sbin/bsdinstall/partedit/partedit_arm64.c b/usr.sbin/bsdinstall/partedit/partedit_arm64.c deleted file mode 100644 index 9fce78b7052..00000000000 --- a/usr.sbin/bsdinstall/partedit/partedit_arm64.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2016 Cavium Inc. - * All rights reserved. - * - * Developed by Semihalf. - * Based on work by Nathan Whitehorn. - * - * 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 -#include - -#include "partedit.h" - -/* EFI partition size in bytes */ -#define EFI_BOOTPART_SIZE (200 * 1024 * 1024) -#define EFI_BOOTPART_PATH "/boot/boot1.efifat" - -const char * -default_scheme(void) -{ - - return ("GPT"); -} - -int -is_scheme_bootable(const char *part_type) -{ - - if (strcmp(part_type, "GPT") == 0) - return (1); - - return (0); -} - -int -is_fs_bootable(const char *part_type, const char *fs) -{ - - if (strcmp(fs, "freebsd-ufs") == 0) - return (1); - - return (0); -} - -size_t -bootpart_size(const char *scheme) -{ - - /* We only support GPT with EFI */ - if (strcmp(scheme, "GPT") != 0) - return (0); - - return (EFI_BOOTPART_SIZE); -} - -const char * -bootpart_type(const char *scheme, const char **mountpoint) -{ - - /* Only EFI is supported as boot partition */ - return ("efi"); -} - -const char * -bootcode_path(const char *part_type) -{ - - return (NULL); -} - -const char * -partcode_path(const char *part_type, const char *fs_type) -{ - - if (strcmp(part_type, "GPT") == 0) - return (EFI_BOOTPART_PATH); - - /* No boot partition data for non-GPT */ - return (NULL); -} - diff --git a/usr.sbin/bsdinstall/partedit/partedit_pc98.c b/usr.sbin/bsdinstall/partedit/partedit_pc98.c deleted file mode 100644 index 88bac85457a..00000000000 --- a/usr.sbin/bsdinstall/partedit/partedit_pc98.c +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * Copyright (c) 2011 Nathan Whitehorn - * 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: stable/10/usr.sbin/bsdinstall/partedit/partedit_pc98.c 273831 2014-10-29 16:48:18Z nwhitehorn $ - */ - -#include - -#include "partedit.h" - -const char * -default_scheme(void) { - return ("PC98"); -} - -int -is_scheme_bootable(const char *part_type) { - if (strcmp(part_type, "BSD") == 0) - return (1); - if (strcmp(part_type, "PC98") == 0) - return (1); - - return (0); -} - -int -is_fs_bootable(const char *part_type, const char *fs) -{ - if (strcmp(fs, "mnbsd-ufs") == 0) - return (1); - - return (0); -} - -size_t -bootpart_size(const char *part_type) { - /* No boot partition */ - return (0); -} - -const char * -bootpart_type(const char *scheme) { - return ("mnbsd-boot"); -} - -const char * -bootcode_path(const char *part_type) { - if (strcmp(part_type, "PC98") == 0) - return ("/boot/pc98boot"); - if (strcmp(part_type, "BSD") == 0) - return ("/boot/boot"); - - return (NULL); -} - -const char * -partcode_path(const char *part_type, const char *fs_type) { - /* No partcode */ - return (NULL); -} - diff --git a/usr.sbin/bsdinstall/partedit/partedit_sparc64.c b/usr.sbin/bsdinstall/partedit/partedit_sparc64.c deleted file mode 100644 index 9a16795026b..00000000000 --- a/usr.sbin/bsdinstall/partedit/partedit_sparc64.c +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2011 Nathan Whitehorn - * 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: stable/10/usr.sbin/bsdinstall/partedit/partedit_sparc64.c 273831 2014-10-29 16:48:18Z nwhitehorn $ - */ - -#include - -#include "partedit.h" - -const char * -default_scheme(void) { - return ("VTOC8"); -} - -int -is_scheme_bootable(const char *part_type) { - if (strcmp(part_type, "VTOC8") == 0) - return (1); - return (0); -} - -int -is_fs_bootable(const char *part_type, const char *fs) -{ - if (strcmp(fs, "mnbsd-ufs") == 0 || strcmp(fs, "mnbsd-zfs") == 0) - return (1); - return (0); -} - - -size_t -bootpart_size(const char *part_type) { - /* No standalone boot partition */ - - return (0); -} - -const char * -bootpart_type(const char *scheme, const char **mountpoint) { - return ("mnbsd-boot"); -} - -const char * -bootcode_path(const char *part_type) { - return (NULL); -} - -const char * -partcode_path(const char *part_type, const char *fs_type) { - if (strcmp(part_type, "VTOC8") == 0) { - if (strcmp(fs_type, "ufs") == 0) { - return ("/boot/boot1"); - } else if (strcmp(fs_type, "zfs") == 0) { - return ("/boot/zfsboot"); - } - } - return (NULL); -} - diff --git a/usr.sbin/bsnmpd/modules/snmp_atm/BEGEMOT-ATM-FREEBSD-MIB.txt b/usr.sbin/bsnmpd/modules/snmp_atm/BEGEMOT-ATM-FREEBSD-MIB.txt deleted file mode 100644 index a153eb3575e..00000000000 --- a/usr.sbin/bsnmpd/modules/snmp_atm/BEGEMOT-ATM-FREEBSD-MIB.txt +++ /dev/null @@ -1,101 +0,0 @@ --- --- Copyright (c) 2004 --- Hartmut Brandt. --- All rights reserved. --- --- Author: Hartmut Brandt --- --- 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 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 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: stable/11/usr.sbin/bsnmpd/modules/snmp_atm/BEGEMOT-ATM-FREEBSD-MIB.txt 312258 2017-01-16 06:55:11Z ngie $ --- --- Private Begemot MIB for ATM interfaces on FreeBSD --- -BEGEMOT-ATM-FREEBSD-MIB DEFINITIONS ::= BEGIN - -IMPORTS - MODULE-IDENTITY, OBJECT-TYPE - FROM SNMPv2-SMI - NgNodeIdOrZero - FROM BEGEMOT-NETGRAPH-MIB - begemotAtmSysGroup, begemotAtmIfEntry - FROM BEGEMOT-ATM-MIB; - -begemotAtmFreeBSDGroup MODULE-IDENTITY - LAST-UPDATED "200408060000Z" - ORGANIZATION "German Aerospace Centre" - CONTACT-INFO - " Hartmut Brandt - - Postal: German Aerospace Centre (DLR) - Institute of Communications and Navigation - 82234 Wessling - Germany - - Fax: +49 8153 28 2844 - - E-mail: harti@freebsd.org" - DESCRIPTION - "The FreeBSD specific Begemot MIB for ATM interfaces." - REVISION "200408060000Z" - DESCRIPTION - "Initial revision." - ::= { begemotAtmSysGroup 1 } - --- Netgraph -begemotAtmNgGroup OBJECT IDENTIFIER ::= { begemotAtmFreeBSDGroup 1 } - --- --- Interfaces table --- -begemotAtmNgIfTable OBJECT-TYPE - SYNTAX SEQUENCE OF BegemotAtmNgIfEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "This table contains an entry for each hardware ATM - interface. The table is indexed by the interface index." - ::= { begemotAtmNgGroup 1 } - -begemotAtmNgIfEntry OBJECT-TYPE - SYNTAX BegemotAtmNgIfEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "This is a table entry describing one ATM hardware interface." - AUGMENTS { begemotAtmIfEntry } - ::= { begemotAtmNgIfTable 1 } - -BegemotAtmNgIfEntry ::= SEQUENCE { - begemotAtmNgIfNodeId NgNodeIdOrZero -} - -begemotAtmNgIfNodeId OBJECT-TYPE - SYNTAX NgNodeIdOrZero - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The netgraph node id of the interface. If there is no - node corresponding to the interface, this is 0." - ::= { begemotAtmNgIfEntry 1 } - -END diff --git a/usr.sbin/bsnmpd/modules/snmp_atm/Makefile b/usr.sbin/bsnmpd/modules/snmp_atm/Makefile deleted file mode 100644 index 125199a4028..00000000000 --- a/usr.sbin/bsnmpd/modules/snmp_atm/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/bsnmpd/modules/snmp_atm/Makefile 312056 2017-01-13 09:07:29Z ngie $ -# -# Author: Harti Brandt - -CONTRIB= ${SRCTOP}/contrib/ngatm -.PATH: ${CONTRIB}/snmp_atm - -MOD= atm -SRCS= snmp_atm.c atm_sys.c -XSYM= begemotAtm -MAN= snmp_atm.3 - -BMIBS= BEGEMOT-ATM.txt BEGEMOT-ATM-FREEBSD-MIB.txt -DEFS= ${MOD}_tree.def atm_freebsd.def -INCS= snmp_${MOD}.h - -EXTRAMIBDEFS= atm_freebsd.def - -CFLAGS+= -I${CONTRIB}/snmp_atm - -.include diff --git a/usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend b/usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend deleted file mode 100644 index 4045c08fc67..00000000000 --- a/usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend +++ /dev/null @@ -1,22 +0,0 @@ -# $FreeBSD: stable/11/usr.sbin/bsnmpd/modules/snmp_atm/Makefile.depend 295989 2016-02-24 17:20:11Z bdrewery $ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - gnu/lib/libgcc \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libbsnmp/libbsnmp \ - lib/libc \ - lib/libcompiler_rt \ - usr.sbin/bsnmpd/modules \ - usr.sbin/bsnmpd/modules/snmp_mibII \ - usr.sbin/bsnmpd/modules/snmp_netgraph \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/bsnmpd/modules/snmp_atm/atm_freebsd.def b/usr.sbin/bsnmpd/modules/snmp_atm/atm_freebsd.def deleted file mode 100644 index e286f4cb1be..00000000000 --- a/usr.sbin/bsnmpd/modules/snmp_atm/atm_freebsd.def +++ /dev/null @@ -1,56 +0,0 @@ -# -# Copyright (c) 2004 -# Hartmut Brandt. -# All rights reserved. -# -# Author: Hartmut Brandt -# -# 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 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 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: stable/11/usr.sbin/bsnmpd/modules/snmp_atm/atm_freebsd.def 133391 2004-08-09 16:36:04Z harti $ -# -# SNMP module for ATM hardware interfaces. -# -# $Begemot: libunimsg/snmp_atm/atm_tree.def,v 1.2 2004/08/05 07:14:22 brandt Exp $ -# -(1 internet - (4 private - (1 enterprises - (12325 fokus - (1 begemot - (101 begemotAtm - (1 begemotAtmObjects - (4 begemotAtmSysGroup - (1 begemotAtmFreeBSDGroup - (1 begemotAtmNgGroup - (1 begemotAtmNgIfTable - (1 begemotAtmNgIfEntry : INTEGER op_atmif_ng - (1 begemotAtmIfNodeId UNSIGNED32 GET) - )) - ) - ) - ) - ) - )) - ) - ) -)) diff --git a/usr.sbin/bsnmpd/modules/snmp_atm/atm_sys.c b/usr.sbin/bsnmpd/modules/snmp_atm/atm_sys.c deleted file mode 100644 index d27b0cbae11..00000000000 --- a/usr.sbin/bsnmpd/modules/snmp_atm/atm_sys.c +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Copyright (c) 2001-2002 - * Fraunhofer Institute for Open Communication Systems (FhG Fokus). - * All rights reserved. - * Copyright (c) 2003-2004 - * Hartmut Brandt. - * All rights reserved. - * - * Author: Hartmut Brandt - * - * 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 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 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: stable/11/usr.sbin/bsnmpd/modules/snmp_atm/atm_sys.c 310901 2016-12-31 10:32:49Z ngie $ - * - * SNMP module for ATM hardware interfaces - FreeBSD/Ng specific part. - */ - -#include "atm.h" -#include "atm_tree.h" -#include "atm_oid.h" - -#include -#include -#include - -#include - -#include -#include -#include - -static const struct hwinfo { - const char *device; - const char *vendor; -} hwinfo[] = { - ATM_DEVICE_NAMES -}; - -struct atmif_sys { - ng_ID_t atm_node; - void *regc; /* cookie registration */ -}; - -/* - * Find the interface for a given node - */ -struct atmif * -atm_node2if(u_int node) -{ - struct atmif_priv *aif; - - if (node != 0) - TAILQ_FOREACH(aif, &atmif_list, link) - if (aif->sys->atm_node == node) - return (&aif->pub); - return (NULL); -} - -u_int -atm_if2node(struct atmif *pub) -{ - struct atmif_priv *aif = (struct atmif_priv *)pub; - - return (aif->sys->atm_node); -} - -/* - * Destroy system dependend stuff. - */ -void -atmif_sys_destroy(struct atmif_priv *aif) -{ - - ng_unregister_cookie(aif->sys->regc); - free(aif->sys); - free(aif->pub.mib); -} - -/* - * Handle a message from the ATM node - */ -static void -handle_atm_message(const struct ng_mesg *mesg, const char *path __unused, - ng_ID_t node, void *uarg) -{ - struct atmif_priv *aif = uarg; - enum atmif_carrier_state ost; - - switch (mesg->header.cmd) { - - case NGM_ATM_IF_CHANGE: - { - const struct ngm_atm_if_change *arg; - - ost = aif->pub.carrier; - if (mesg->header.arglen != sizeof(*arg)) { - syslog(LOG_ERR, "ATM_IF_CHANGE: wrong size"); - atmif_check_carrier(aif); - return; - } - arg = (const struct ngm_atm_if_change *) - (const void *)mesg->data; - - if (arg->carrier) - aif->pub.carrier = ATMIF_CARRIER_ON; - else - aif->pub.carrier = ATMIF_CARRIER_OFF; - - if (ost != aif->pub.carrier) - atmif_send_notification(aif, ATMIF_NOTIFY_CARRIER, - (uintptr_t)ost); - return; - } - - case NGM_ATM_VCC_CHANGE: - { - const struct ngm_atm_vcc_change *arg; - - if (mesg->header.arglen != sizeof(*arg)) { - syslog(LOG_ERR, "ATM_VCC_CHANGE: wrong size"); - return; - } - arg = (const struct ngm_atm_vcc_change *) - (const void *)mesg->data; - atmif_send_notification(aif, ATMIF_NOTIFY_VCC, - (uintptr_t)(((arg->vpi & 0xff) << 24) | - ((arg->vci & 0xffff) << 8) | (arg->state & 1))); - return; - } - } - syslog(LOG_WARNING, "spurious message %u from node [%x]", - mesg->header.cmd, node); -} - -/* - * Attach to an ATM interface - */ -int -atmif_sys_attach_if(struct atmif_priv *aif) -{ - struct ng_mesg *resp, *resp1; - struct namelist *list; - u_int i; - - if ((aif->sys = malloc(sizeof(*aif->sys))) == NULL) { - syslog(LOG_CRIT, "out of memory"); - return (-1); - } - memset(aif->sys, 0, sizeof(*aif->sys)); - - if ((aif->pub.mib = malloc(sizeof(*aif->pub.mib))) == NULL) { - free(aif->sys); - syslog(LOG_CRIT, "out of memory"); - return (-1); - } - - atmif_sys_fill_mib(aif); - - /* - * Get ATM node Id. Must do it the hard way by scanning all nodes - * because the name may be wrong. - */ - if ((resp = ng_dialog_id(snmp_node, NGM_GENERIC_COOKIE, NGM_LISTNODES, - NULL, 0)) == NULL) { - syslog(LOG_ERR, "cannot fetch node list: %m"); - free(aif->sys); - return (-1); - } - list = (struct namelist *)(void *)resp->data; - - for (i = 0; i < list->numnames; i++) { - if (strcmp(list->nodeinfo[i].type, NG_ATM_NODE_TYPE) != 0) - continue; - if ((resp1 = ng_dialog_id(list->nodeinfo[i].id, - NGM_ATM_COOKIE, NGM_ATM_GET_IFNAME, NULL, 0)) == NULL) - continue; - if (strcmp(resp1->data, aif->pub.ifp->name) == 0) { - free(resp1); - break; - } - free(resp1); - } - if (i == list->numnames) - aif->sys->atm_node = 0; - else - aif->sys->atm_node = list->nodeinfo[i].id; - - free(resp); - - if ((aif->sys->regc = ng_register_cookie(module, NGM_ATM_COOKIE, - aif->sys->atm_node, handle_atm_message, aif)) == NULL) { - syslog(LOG_ERR, "cannot register cookie: %m"); - free(aif->sys); - return (-1); - } - return (0); -} - -/* - * Table of all ATM interfaces - Ng part - */ -int -op_atmif_ng(struct snmp_context *ctx __unused, struct snmp_value *value, - u_int sub, u_int vindex __unused, enum snmp_op op) -{ - struct atmif_priv *aif; - int err; - - if ((err = atmif_get_aif(value, sub, op, &aif)) != SNMP_ERR_NOERROR) - return (err); - - if (op == SNMP_OP_SET) { - switch (value->var.subs[sub - 1]) { - - default: - return (SNMP_ERR_NOT_WRITEABLE); - } - } - - switch (value->var.subs[sub - 1]) { - - case LEAF_begemotAtmIfNodeId: - value->v.uint32 = aif->sys->atm_node; - return (SNMP_ERR_NOERROR); - } - abort(); -} - -/* - * Get vendor string - */ -int -atm_sys_get_hw_vendor(struct atmif_priv *aif, struct snmp_value *value) -{ - - if (aif->pub.mib->device >= sizeof(hwinfo) / sizeof(hwinfo[0])) - return (string_get(value, "unknown", -1)); - return (string_get(value, hwinfo[aif->pub.mib->device].vendor, -1)); -} - -/* - * Get device string - */ -int -atm_sys_get_hw_device(struct atmif_priv *aif, struct snmp_value *value) -{ - - if (aif->pub.mib->device >= sizeof(hwinfo) / sizeof(hwinfo[0])) - return (string_get(value, "unknown", -1)); - return (string_get(value, hwinfo[aif->pub.mib->device].device, -1)); -} - -/* - * Extract the ATM MIB from the interface's private MIB - */ -void -atmif_sys_fill_mib(struct atmif_priv *aif) -{ - struct ifatm_mib *mib; - - if (aif->pub.ifp->specmiblen != sizeof(struct ifatm_mib)) { - syslog(LOG_ERR, "atmif MIB has wrong size %zu", - aif->pub.ifp->specmiblen); - memset(aif->pub.mib, 0, sizeof(*aif->pub.mib)); - aif->pub.mib->version = 0; - return; - } - mib = (struct ifatm_mib *)aif->pub.ifp->specmib; - - aif->pub.mib->device = mib->device; - aif->pub.mib->serial = mib->serial; - aif->pub.mib->hw_version = mib->hw_version; - aif->pub.mib->sw_version = mib->sw_version; - aif->pub.mib->media = mib->media; - - memcpy(aif->pub.mib->esi, mib->esi, 6); - aif->pub.mib->pcr = mib->pcr; - aif->pub.mib->vpi_bits = mib->vpi_bits; - aif->pub.mib->vci_bits = mib->vci_bits; - aif->pub.mib->max_vpcs = mib->max_vpcs; - aif->pub.mib->max_vccs = mib->max_vccs; -} diff --git a/usr.sbin/crunch/crunchide/exec_aout.c b/usr.sbin/crunch/crunchide/exec_aout.c deleted file mode 100644 index e769e79e284..00000000000 --- a/usr.sbin/crunch/crunchide/exec_aout.c +++ /dev/null @@ -1,197 +0,0 @@ -/* $NetBSD: exec_aout.c,v 1.6 1997/08/02 21:30:17 perry Exp $ */ -/* - * Copyright (c) 1997 Christopher G. Demetriou. All rights reserved. - * Copyright (c) 1994 University of Maryland - * All Rights Reserved. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of U.M. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. U.M. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M. - * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: James da Silva, Systems Design and Analysis Group - * Computer Science Department - * University of Maryland at College Park - */ -#include -#ifndef lint -__RCSID("$NetBSD: exec_aout.c,v 1.6 1997/08/02 21:30:17 perry Exp $"); -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "extern.h" - -#if defined(NLIST_AOUT) - -int nsyms, ntextrel, ndatarel; -struct exec *hdrp; -char *aoutdata, *strbase; -struct relocation_info *textrel, *datarel; -struct nlist *symbase; - - -#define SYMSTR(sp) (&strbase[(sp)->n_un.n_strx]) - -/* is the symbol a global symbol defined in the current file? */ -#define IS_GLOBAL_DEFINED(sp) \ - (((sp)->n_type & N_EXT) && ((sp)->n_type & N_TYPE) != N_UNDF) - -/* is the relocation entry dependent on a symbol? */ -#define IS_SYMBOL_RELOC(rp) \ - ((rp)->r_extern||(rp)->r_baserel||(rp)->r_jmptable) - -static void check_reloc(const char *filename, struct relocation_info *relp); - -int check_aout(int inf, const char *filename) -{ - struct stat infstat; - struct exec eh; - - /* - * check the header to make sure it's an a.out-format file. - */ - - if(fstat(inf, &infstat) == -1) - return 0; - if(infstat.st_size < sizeof eh) - return 0; - if(read(inf, &eh, sizeof eh) != sizeof eh) - return 0; - - if(N_BADMAG(eh)) - return 0; - - return 1; -} - -int hide_aout(int inf, const char *filename) -{ - struct stat infstat; - struct relocation_info *relp; - struct nlist *symp; - int rc; - - /* - * do some error checking. - */ - - if(fstat(inf, &infstat) == -1) { - perror(filename); - return 1; - } - - /* - * Read the entire file into memory. XXX - Really, we only need to - * read the header and from TRELOFF to the end of the file. - */ - - if((aoutdata = (char *) malloc(infstat.st_size)) == NULL) { - fprintf(stderr, "%s: too big to read into memory\n", filename); - return 1; - } - - if((rc = read(inf, aoutdata, infstat.st_size)) < infstat.st_size) { - fprintf(stderr, "%s: read error: %s\n", filename, - rc == -1? strerror(errno) : "short read"); - return 1; - } - - /* - * Calculate offsets and sizes from the header. - */ - - hdrp = (struct exec *) aoutdata; - -#ifdef __FreeBSD__ - textrel = (struct relocation_info *) (aoutdata + N_RELOFF(*hdrp)); - datarel = (struct relocation_info *) (aoutdata + N_RELOFF(*hdrp) + - hdrp->a_trsize); -#else - textrel = (struct relocation_info *) (aoutdata + N_TRELOFF(*hdrp)); - datarel = (struct relocation_info *) (aoutdata + N_DRELOFF(*hdrp)); -#endif - symbase = (struct nlist *) (aoutdata + N_SYMOFF(*hdrp)); - strbase = (char *) (aoutdata + N_STROFF(*hdrp)); - - ntextrel = hdrp->a_trsize / sizeof(struct relocation_info); - ndatarel = hdrp->a_drsize / sizeof(struct relocation_info); - nsyms = hdrp->a_syms / sizeof(struct nlist); - - /* - * Zap the type field of all globally-defined symbols. The linker will - * subsequently ignore these entries. Don't zap any symbols in the - * keep list. - */ - - for(symp = symbase; symp < symbase + nsyms; symp++) { - if(!IS_GLOBAL_DEFINED(symp)) /* keep undefined syms */ - continue; - - /* keep (C) symbols which are on the keep list */ - if(SYMSTR(symp)[0] == '_' && in_keep_list(SYMSTR(symp) + 1)) - continue; - - symp->n_type = 0; - } - - /* - * Check whether the relocation entries reference any symbols that we - * just zapped. I don't know whether ld can handle this case, but I - * haven't encountered it yet. These checks are here so that the program - * doesn't fail silently should such symbols be encountered. - */ - - for(relp = textrel; relp < textrel + ntextrel; relp++) - check_reloc(filename, relp); - for(relp = datarel; relp < datarel + ndatarel; relp++) - check_reloc(filename, relp); - - /* - * Write the .o file back out to disk. XXX - Really, we only need to - * write the symbol table entries back out. - */ - lseek(inf, 0, SEEK_SET); - if((rc = write(inf, aoutdata, infstat.st_size)) < infstat.st_size) { - fprintf(stderr, "%s: write error: %s\n", filename, - rc == -1? strerror(errno) : "short write"); - return 1; - } - - return 0; -} - - -static void check_reloc(const char *filename, struct relocation_info *relp) -{ - /* bail out if we zapped a symbol that is needed */ - if(IS_SYMBOL_RELOC(relp) && symbase[relp->r_symbolnum].n_type == 0) { - fprintf(stderr, - "%s: oops, have hanging relocation for %s: bailing out!\n", - filename, SYMSTR(&symbase[relp->r_symbolnum])); - exit(1); - } -} - -#endif /* defined(NLIST_AOUT) */ diff --git a/usr.sbin/fdformat/fdformat.1 b/usr.sbin/fdformat/fdformat.1 deleted file mode 100644 index eb3828a99d0..00000000000 --- a/usr.sbin/fdformat/fdformat.1 +++ /dev/null @@ -1,180 +0,0 @@ -.\" Copyright (C) 1993, 1994, 1995, 2001 by Joerg Wunsch, Dresden -.\" 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(S) ``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(S) 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: src/usr.sbin/fdformat/fdformat.1,v 1.31 2007/02/28 10:24:34 ru Exp $ -.\" -.Dd December 25, 2001 -.Os -.Dt FDFORMAT 1 -.Sh NAME -.Nm fdformat -.Nd format floppy disks -.Sh SYNOPSIS -.Nm -.Op Fl F Ar fill -.Op Fl f Ar fmt -.Op Fl s Ar fmtstr -.Op Fl nqvy -.Ar device -.Sh DESCRIPTION -The -.Nm -utility formats a floppy disk at -.Ar device , -where -.Ar device -may either be given as a full path -name of a device node for a floppy disk drive -(e.g.\& -.Pa /dev/fd0 ) , -or using an abbreviated name that will be looked up -under -.Pa /dev -(e.g.\& -.Dq Li fd0 ) . -.Pp -The options are as follows: -.Bl -tag -width ".Fl s Ar fmtstr" -.It Fl F Ar fill -Use -.Ar fill -as the fill byte for newly formatted sectors. -The -.Ar fill -argument -must be a number in the range 0 through 255 using common C -language notation. -The default value is -.Dq Li 0xf6 . -.It Fl f Ar fmt -Specify the density settings for a -.Ar fmt -kilobyte format, as described in -.Xr fdcontrol 8 . -.It Fl s Ar fmtstr -Specify the density settings using explicit parameters, as -described in -.Xr fdcontrol 8 . -.It Fl n -Do not verify floppy after formatting. -.It Fl q -Suppress any normal output from the command, and do not ask the -user for a confirmation whether to format the floppy disk at -.Ar device . -.It Fl v -Do not format, verify only. -.It Fl y -Do not ask for confirmation whether to format the floppy disk but -still report formatting status. -.El -.Pp -For non-autoselecting subdevices, neither -.Fl f Ar fmt -nor -.Fl s Ar fmtstr -may be specified, since the preconfigured media density settings -from the kernel driver will always be used. -However, if -.Ar device -is a device with automatic media density selection (see -.Xr fdc 4 ) , -both methods can be used to override the density settings for the -newly formatted medium (without permanently changing the density -settings of -.Ar device ) . -.Pp -If the -.Fl q -flag has not been specified, the user is asked for a confirmation -of the intended formatting process. -In order to continue, an answer -of -.Ql y -must be given. -.Pp -Note that -.Nm -does only perform low-level formatting. -In order to create -a file system on the medium, see the commands -.Xr newfs 8 -for a -.Tn UFS -file system, or -.Xr newfs_msdos 8 -for an -.Tn MS-DOS -(FAT) -file system. -.Sh EXIT STATUS -An exit status of 0 is returned upon successful operation. -Exit status -1 is returned on any errors during floppy formatting, and an exit status -of 2 reflects invalid arguments given to the program (along with an -appropriate information written to diagnostic output). -.Sh DIAGNOSTICS -Unless -.Fl q -has been specified, a single letter is printed to standard output -to inform the user about the progress of work. -First, an -.Ql F -is printed when the track is being formatted, then a -.Ql V -while it is being verified, and if an error has been detected, it -will finally change to -.Ql E . -Detailed status information (cylinder, head and sector number, and the -exact cause of the error) will be printed for up to 10 errors after the -entire formatting process has completed. -.Sh SEE ALSO -.Xr fdc 4 , -.Xr fdcontrol 8 , -.Xr newfs 8 , -.Xr newfs_msdos 8 -.Sh HISTORY -The -.Nm -utility -has been developed for -.Bx 386 0.1 -and upgraded to the new -.Xr fdc 4 -floppy disk driver. -It later became part of the -.Fx 1.1 -system. -Starting with -.Fx 5.0 , -it uses the unified density specifications as described in -.Xr fdcontrol 8 . -.Sh AUTHORS -.An -nosplit -The program has been contributed by -.An J\(:org Wunsch , -Dresden, with changes by -.An Serge Vakulenko -and -.An Andrey A. Chernov , -Moscow. diff --git a/usr.sbin/iscsid/chap.c b/usr.sbin/iscsid/chap.c deleted file mode 100644 index 77fb9dac477..00000000000 --- a/usr.sbin/iscsid/chap.c +++ /dev/null @@ -1,423 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2014 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Edward Tomasz Napierala under sponsorship - * from the FreeBSD Foundation. - * - * 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 - -#include -#include -#include -#include -#include -#include - -#include "iscsid.h" - -static void -chap_compute_md5(const char id, const char *secret, - const void *challenge, size_t challenge_len, void *response, - size_t response_len) -{ - MD5_CTX ctx; - - assert(response_len == CHAP_DIGEST_LEN); - - MD5Init(&ctx); - MD5Update(&ctx, &id, sizeof(id)); - MD5Update(&ctx, secret, strlen(secret)); - MD5Update(&ctx, challenge, challenge_len); - MD5Final(response, &ctx); -} - -static int -chap_hex2int(const char hex) -{ - switch (hex) { - case '0': - return (0x00); - case '1': - return (0x01); - case '2': - return (0x02); - case '3': - return (0x03); - case '4': - return (0x04); - case '5': - return (0x05); - case '6': - return (0x06); - case '7': - return (0x07); - case '8': - return (0x08); - case '9': - return (0x09); - case 'a': - case 'A': - return (0x0a); - case 'b': - case 'B': - return (0x0b); - case 'c': - case 'C': - return (0x0c); - case 'd': - case 'D': - return (0x0d); - case 'e': - case 'E': - return (0x0e); - case 'f': - case 'F': - return (0x0f); - default: - return (-1); - } -} - -static int -chap_b642bin(const char *b64, void **binp, size_t *bin_lenp) -{ - char *bin; - int b64_len, bin_len; - - b64_len = strlen(b64); - bin_len = (b64_len + 3) / 4 * 3; - bin = calloc(bin_len, 1); - if (bin == NULL) - log_err(1, "calloc"); - - bin_len = b64_pton(b64, bin, bin_len); - if (bin_len < 0) { - log_warnx("malformed base64 variable"); - free(bin); - return (-1); - } - *binp = bin; - *bin_lenp = bin_len; - return (0); -} - -/* - * XXX: Review this _carefully_. - */ -static int -chap_hex2bin(const char *hex, void **binp, size_t *bin_lenp) -{ - int i, hex_len, nibble; - bool lo = true; /* As opposed to 'hi'. */ - char *bin; - size_t bin_off, bin_len; - - if (strncasecmp(hex, "0b", strlen("0b")) == 0) - return (chap_b642bin(hex + 2, binp, bin_lenp)); - - if (strncasecmp(hex, "0x", strlen("0x")) != 0) { - log_warnx("malformed variable, should start with \"0x\"" - " or \"0b\""); - return (-1); - } - - hex += strlen("0x"); - hex_len = strlen(hex); - if (hex_len < 1) { - log_warnx("malformed variable; doesn't contain anything " - "but \"0x\""); - return (-1); - } - - bin_len = hex_len / 2 + hex_len % 2; - bin = calloc(bin_len, 1); - if (bin == NULL) - log_err(1, "calloc"); - - bin_off = bin_len - 1; - for (i = hex_len - 1; i >= 0; i--) { - nibble = chap_hex2int(hex[i]); - if (nibble < 0) { - log_warnx("malformed variable, invalid char \"%c\"", - hex[i]); - free(bin); - return (-1); - } - - assert(bin_off < bin_len); - if (lo) { - bin[bin_off] = nibble; - lo = false; - } else { - bin[bin_off] |= nibble << 4; - bin_off--; - lo = true; - } - } - - *binp = bin; - *bin_lenp = bin_len; - return (0); -} - -#ifdef USE_BASE64 -static char * -chap_bin2hex(const char *bin, size_t bin_len) -{ - unsigned char *b64, *tmp; - size_t b64_len; - - b64_len = (bin_len + 2) / 3 * 4 + 3; /* +2 for "0b", +1 for '\0'. */ - b64 = malloc(b64_len); - if (b64 == NULL) - log_err(1, "malloc"); - - tmp = b64; - tmp += sprintf(tmp, "0b"); - b64_ntop(bin, bin_len, tmp, b64_len - 2); - - return (b64); -} -#else -static char * -chap_bin2hex(const char *bin, size_t bin_len) -{ - unsigned char *hex, *tmp, ch; - size_t hex_len; - size_t i; - - hex_len = bin_len * 2 + 3; /* +2 for "0x", +1 for '\0'. */ - hex = malloc(hex_len); - if (hex == NULL) - log_err(1, "malloc"); - - tmp = hex; - tmp += sprintf(tmp, "0x"); - for (i = 0; i < bin_len; i++) { - ch = bin[i]; - tmp += sprintf(tmp, "%02x", ch); - } - - return (hex); -} -#endif /* !USE_BASE64 */ - -struct chap * -chap_new(void) -{ - struct chap *chap; - - chap = calloc(1, sizeof(*chap)); - if (chap == NULL) - log_err(1, "calloc"); - - /* - * Generate the challenge. - */ - arc4random_buf(chap->chap_challenge, sizeof(chap->chap_challenge)); - arc4random_buf(&chap->chap_id, sizeof(chap->chap_id)); - - return (chap); -} - -char * -chap_get_id(const struct chap *chap) -{ - char *chap_i; - int ret; - - ret = asprintf(&chap_i, "%d", chap->chap_id); - if (ret < 0) - log_err(1, "asprintf"); - - return (chap_i); -} - -char * -chap_get_challenge(const struct chap *chap) -{ - char *chap_c; - - chap_c = chap_bin2hex(chap->chap_challenge, - sizeof(chap->chap_challenge)); - - return (chap_c); -} - -static int -chap_receive_bin(struct chap *chap, void *response, size_t response_len) -{ - - if (response_len != sizeof(chap->chap_response)) { - log_debugx("got CHAP response with invalid length; " - "got %zd, should be %zd", - response_len, sizeof(chap->chap_response)); - return (1); - } - - memcpy(chap->chap_response, response, response_len); - return (0); -} - -int -chap_receive(struct chap *chap, const char *response) -{ - void *response_bin; - size_t response_bin_len; - int error; - - error = chap_hex2bin(response, &response_bin, &response_bin_len); - if (error != 0) { - log_debugx("got incorrectly encoded CHAP response \"%s\"", - response); - return (1); - } - - error = chap_receive_bin(chap, response_bin, response_bin_len); - free(response_bin); - - return (error); -} - -int -chap_authenticate(struct chap *chap, const char *secret) -{ - char expected_response[CHAP_DIGEST_LEN]; - - chap_compute_md5(chap->chap_id, secret, - chap->chap_challenge, sizeof(chap->chap_challenge), - expected_response, sizeof(expected_response)); - - if (memcmp(chap->chap_response, - expected_response, sizeof(expected_response)) != 0) { - return (-1); - } - - return (0); -} - -void -chap_delete(struct chap *chap) -{ - - free(chap); -} - -struct rchap * -rchap_new(const char *secret) -{ - struct rchap *rchap; - - rchap = calloc(1, sizeof(*rchap)); - if (rchap == NULL) - log_err(1, "calloc"); - - rchap->rchap_secret = checked_strdup(secret); - - return (rchap); -} - -static void -rchap_receive_bin(struct rchap *rchap, const unsigned char id, - const void *challenge, size_t challenge_len) -{ - - rchap->rchap_id = id; - rchap->rchap_challenge = calloc(challenge_len, 1); - if (rchap->rchap_challenge == NULL) - log_err(1, "calloc"); - memcpy(rchap->rchap_challenge, challenge, challenge_len); - rchap->rchap_challenge_len = challenge_len; -} - -int -rchap_receive(struct rchap *rchap, const char *id, const char *challenge) -{ - unsigned char id_bin; - void *challenge_bin; - size_t challenge_bin_len; - - int error; - - id_bin = strtoul(id, NULL, 10); - - error = chap_hex2bin(challenge, &challenge_bin, &challenge_bin_len); - if (error != 0) { - log_debugx("got incorrectly encoded CHAP challenge \"%s\"", - challenge); - return (1); - } - - rchap_receive_bin(rchap, id_bin, challenge_bin, challenge_bin_len); - free(challenge_bin); - - return (0); -} - -static void -rchap_get_response_bin(struct rchap *rchap, - void **responsep, size_t *response_lenp) -{ - void *response_bin; - size_t response_bin_len = CHAP_DIGEST_LEN; - - response_bin = calloc(response_bin_len, 1); - if (response_bin == NULL) - log_err(1, "calloc"); - - chap_compute_md5(rchap->rchap_id, rchap->rchap_secret, - rchap->rchap_challenge, rchap->rchap_challenge_len, - response_bin, response_bin_len); - - *responsep = response_bin; - *response_lenp = response_bin_len; -} - -char * -rchap_get_response(struct rchap *rchap) -{ - void *response; - size_t response_len; - char *chap_r; - - rchap_get_response_bin(rchap, &response, &response_len); - chap_r = chap_bin2hex(response, response_len); - free(response); - - return (chap_r); -} - -void -rchap_delete(struct rchap *rchap) -{ - - free(rchap->rchap_secret); - free(rchap->rchap_challenge); - free(rchap); -} diff --git a/usr.sbin/iscsid/keys.c b/usr.sbin/iscsid/keys.c deleted file mode 100644 index a6d17574500..00000000000 --- a/usr.sbin/iscsid/keys.c +++ /dev/null @@ -1,199 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2012 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Edward Tomasz Napierala under sponsorship - * from the FreeBSD Foundation. - * - * 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 - -#include -#include -#include -#include - -#include "iscsid.h" - -struct keys * -keys_new(void) -{ - struct keys *keys; - - keys = calloc(1, sizeof(*keys)); - if (keys == NULL) - log_err(1, "calloc"); - - return (keys); -} - -void -keys_delete(struct keys *keys) -{ - - free(keys->keys_data); - free(keys); -} - -void -keys_load(struct keys *keys, const struct pdu *pdu) -{ - int i; - char *pair; - size_t pair_len; - - if (pdu->pdu_data_len == 0) - return; - - if (pdu->pdu_data[pdu->pdu_data_len - 1] != '\0') - log_errx(1, "protocol error: key not NULL-terminated\n"); - - assert(keys->keys_data == NULL); - keys->keys_data_len = pdu->pdu_data_len; - keys->keys_data = malloc(keys->keys_data_len); - if (keys->keys_data == NULL) - log_err(1, "malloc"); - memcpy(keys->keys_data, pdu->pdu_data, keys->keys_data_len); - - /* - * XXX: Review this carefully. - */ - pair = keys->keys_data; - for (i = 0;; i++) { - if (i >= KEYS_MAX) - log_errx(1, "too many keys received"); - - pair_len = strlen(pair); - - keys->keys_values[i] = pair; - keys->keys_names[i] = strsep(&keys->keys_values[i], "="); - if (keys->keys_names[i] == NULL || keys->keys_values[i] == NULL) - log_errx(1, "malformed keys"); - log_debugx("key received: \"%s=%s\"", - keys->keys_names[i], keys->keys_values[i]); - - pair += pair_len + 1; /* +1 to skip the terminating '\0'. */ - if (pair == keys->keys_data + keys->keys_data_len) - break; - assert(pair < keys->keys_data + keys->keys_data_len); - } -} - -void -keys_save(struct keys *keys, struct pdu *pdu) -{ - char *data; - size_t len; - int i; - - /* - * XXX: Not particularly efficient. - */ - len = 0; - for (i = 0; i < KEYS_MAX; i++) { - if (keys->keys_names[i] == NULL) - break; - /* - * +1 for '=', +1 for '\0'. - */ - len += strlen(keys->keys_names[i]) + - strlen(keys->keys_values[i]) + 2; - } - - if (len == 0) - return; - - data = malloc(len); - if (data == NULL) - log_err(1, "malloc"); - - pdu->pdu_data = data; - pdu->pdu_data_len = len; - - for (i = 0; i < KEYS_MAX; i++) { - if (keys->keys_names[i] == NULL) - break; - data += sprintf(data, "%s=%s", - keys->keys_names[i], keys->keys_values[i]); - data += 1; /* for '\0'. */ - } -} - -const char * -keys_find(struct keys *keys, const char *name) -{ - int i; - - /* - * Note that we don't handle duplicated key names here, - * as they are not supposed to happen in requests, and if they do, - * it's an initiator error. - */ - for (i = 0; i < KEYS_MAX; i++) { - if (keys->keys_names[i] == NULL) - return (NULL); - if (strcmp(keys->keys_names[i], name) == 0) - return (keys->keys_values[i]); - } - return (NULL); -} - -void -keys_add(struct keys *keys, const char *name, const char *value) -{ - int i; - - log_debugx("key to send: \"%s=%s\"", name, value); - - /* - * Note that we don't check for duplicates here, as they are perfectly - * fine in responses, e.g. the "TargetName" keys in discovery sesion - * response. - */ - for (i = 0; i < KEYS_MAX; i++) { - if (keys->keys_names[i] == NULL) { - keys->keys_names[i] = checked_strdup(name); - keys->keys_values[i] = checked_strdup(value); - return; - } - } - log_errx(1, "too many keys"); -} - -void -keys_add_int(struct keys *keys, const char *name, int value) -{ - char *str; - int ret; - - ret = asprintf(&str, "%d", value); - if (ret <= 0) - log_err(1, "asprintf"); - - keys_add(keys, name, str); - free(str); -} diff --git a/usr.sbin/iscsid/log.c b/usr.sbin/iscsid/log.c deleted file mode 100644 index ff643fce306..00000000000 --- a/usr.sbin/iscsid/log.c +++ /dev/null @@ -1,202 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2012 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Edward Tomasz Napierala under sponsorship - * from the FreeBSD Foundation. - * - * 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 - -#include -#include -#include -#include -#include -#include -#include - -#include "iscsid.h" - -static int log_level = 0; -static char *peer_name = NULL; -static char *peer_addr = NULL; - -#define MSGBUF_LEN 1024 - -void -log_init(int level) -{ - - log_level = level; - openlog(getprogname(), LOG_NDELAY | LOG_PID, LOG_DAEMON); -} - -void -log_set_peer_name(const char *name) -{ - - /* - * XXX: Turn it into assertion? - */ - if (peer_name != NULL) - log_errx(1, "%s called twice", __func__); - if (peer_addr == NULL) - log_errx(1, "%s called before log_set_peer_addr", __func__); - - peer_name = checked_strdup(name); -} - -void -log_set_peer_addr(const char *addr) -{ - - /* - * XXX: Turn it into assertion? - */ - if (peer_addr != NULL) - log_errx(1, "%s called twice", __func__); - - peer_addr = checked_strdup(addr); -} - -static void -log_common(int priority, int log_errno, const char *fmt, va_list ap) -{ - static char msgbuf[MSGBUF_LEN]; - static char msgbuf_strvised[MSGBUF_LEN * 4 + 1]; - char *errstr; - int ret; - - ret = vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap); - if (ret < 0) { - fprintf(stderr, "%s: snprintf failed", getprogname()); - syslog(LOG_CRIT, "snprintf failed"); - exit(1); - } - - ret = strnvis(msgbuf_strvised, sizeof(msgbuf_strvised), msgbuf, VIS_NL); - if (ret < 0) { - fprintf(stderr, "%s: strnvis failed", getprogname()); - syslog(LOG_CRIT, "strnvis failed"); - exit(1); - } - - if (log_errno == -1) { - if (peer_name != NULL) { - fprintf(stderr, "%s: %s (%s): %s\n", getprogname(), - peer_addr, peer_name, msgbuf_strvised); - syslog(priority, "%s (%s): %s", - peer_addr, peer_name, msgbuf_strvised); - } else if (peer_addr != NULL) { - fprintf(stderr, "%s: %s: %s\n", getprogname(), - peer_addr, msgbuf_strvised); - syslog(priority, "%s: %s", - peer_addr, msgbuf_strvised); - } else { - fprintf(stderr, "%s: %s\n", getprogname(), msgbuf_strvised); - syslog(priority, "%s", msgbuf_strvised); - } - - } else { - errstr = strerror(log_errno); - - if (peer_name != NULL) { - fprintf(stderr, "%s: %s (%s): %s: %s\n", getprogname(), - peer_addr, peer_name, msgbuf_strvised, errstr); - syslog(priority, "%s (%s): %s: %s", - peer_addr, peer_name, msgbuf_strvised, errstr); - } else if (peer_addr != NULL) { - fprintf(stderr, "%s: %s: %s: %s\n", getprogname(), - peer_addr, msgbuf_strvised, errstr); - syslog(priority, "%s: %s: %s", - peer_addr, msgbuf_strvised, errstr); - } else { - fprintf(stderr, "%s: %s: %s\n", getprogname(), - msgbuf_strvised, errstr); - syslog(priority, "%s: %s", - msgbuf_strvised, errstr); - } - } -} - -void -log_err(int eval, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - log_common(LOG_CRIT, errno, fmt, ap); - va_end(ap); - - exit(eval); -} - -void -log_errx(int eval, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - log_common(LOG_CRIT, -1, fmt, ap); - va_end(ap); - - exit(eval); -} - -void -log_warn(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - log_common(LOG_WARNING, errno, fmt, ap); - va_end(ap); -} - -void -log_warnx(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - log_common(LOG_WARNING, -1, fmt, ap); - va_end(ap); -} - -void -log_debugx(const char *fmt, ...) -{ - va_list ap; - - if (log_level == 0) - return; - - va_start(ap, fmt); - log_common(LOG_DEBUG, -1, fmt, ap); - va_end(ap); -} diff --git a/usr.sbin/iscsid/pdu.c b/usr.sbin/iscsid/pdu.c deleted file mode 100644 index 34b040aa751..00000000000 --- a/usr.sbin/iscsid/pdu.c +++ /dev/null @@ -1,309 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2012 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Edward Tomasz Napierala under sponsorship - * from the FreeBSD Foundation. - * - * 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 - -#include -#include -#include -#include -#include -#include -#include - -#include "iscsid.h" -#include "iscsi_proto.h" - -#ifdef ICL_KERNEL_PROXY -#include -#endif - -static int -pdu_ahs_length(const struct pdu *pdu) -{ - - return (pdu->pdu_bhs->bhs_total_ahs_len * 4); -} - -static int -pdu_data_segment_length(const struct pdu *pdu) -{ - uint32_t len = 0; - - len += pdu->pdu_bhs->bhs_data_segment_len[0]; - len <<= 8; - len += pdu->pdu_bhs->bhs_data_segment_len[1]; - len <<= 8; - len += pdu->pdu_bhs->bhs_data_segment_len[2]; - - return (len); -} - -static void -pdu_set_data_segment_length(struct pdu *pdu, uint32_t len) -{ - - pdu->pdu_bhs->bhs_data_segment_len[2] = len; - pdu->pdu_bhs->bhs_data_segment_len[1] = len >> 8; - pdu->pdu_bhs->bhs_data_segment_len[0] = len >> 16; -} - -struct pdu * -pdu_new(struct connection *conn) -{ - struct pdu *pdu; - - pdu = calloc(1, sizeof(*pdu)); - if (pdu == NULL) - log_err(1, "calloc"); - - pdu->pdu_bhs = calloc(1, sizeof(*pdu->pdu_bhs)); - if (pdu->pdu_bhs == NULL) - log_err(1, "calloc"); - - pdu->pdu_connection = conn; - - return (pdu); -} - -struct pdu * -pdu_new_response(struct pdu *request) -{ - - return (pdu_new(request->pdu_connection)); -} - -#ifdef ICL_KERNEL_PROXY - -static void -pdu_receive_proxy(struct pdu *pdu) -{ - struct connection *conn; - struct iscsi_daemon_receive *idr; - size_t len; - int error; - - conn = pdu->pdu_connection; - assert(conn->conn_conf.isc_iser != 0); - - pdu->pdu_data = malloc(conn->conn_max_recv_data_segment_length); - if (pdu->pdu_data == NULL) - log_err(1, "malloc"); - - idr = calloc(1, sizeof(*idr)); - if (idr == NULL) - log_err(1, "calloc"); - - idr->idr_session_id = conn->conn_session_id; - idr->idr_bhs = pdu->pdu_bhs; - idr->idr_data_segment_len = conn->conn_max_recv_data_segment_length; - idr->idr_data_segment = pdu->pdu_data; - - error = ioctl(conn->conn_iscsi_fd, ISCSIDRECEIVE, idr); - if (error != 0) - log_err(1, "ISCSIDRECEIVE"); - - len = pdu_ahs_length(pdu); - if (len > 0) - log_errx(1, "protocol error: non-empty AHS"); - - len = pdu_data_segment_length(pdu); - assert(len <= (size_t)conn->conn_max_recv_data_segment_length); - pdu->pdu_data_len = len; - - free(idr); -} - -static void -pdu_send_proxy(struct pdu *pdu) -{ - struct connection *conn; - struct iscsi_daemon_send *ids; - int error; - - conn = pdu->pdu_connection; - assert(conn->conn_conf.isc_iser != 0); - - pdu_set_data_segment_length(pdu, pdu->pdu_data_len); - - ids = calloc(1, sizeof(*ids)); - if (ids == NULL) - log_err(1, "calloc"); - - ids->ids_session_id = conn->conn_session_id; - ids->ids_bhs = pdu->pdu_bhs; - ids->ids_data_segment_len = pdu->pdu_data_len; - ids->ids_data_segment = pdu->pdu_data; - - error = ioctl(conn->conn_iscsi_fd, ISCSIDSEND, ids); - if (error != 0) - log_err(1, "ISCSIDSEND"); - - free(ids); -} - -#endif /* ICL_KERNEL_PROXY */ - -static size_t -pdu_padding(const struct pdu *pdu) -{ - - if ((pdu->pdu_data_len % 4) != 0) - return (4 - (pdu->pdu_data_len % 4)); - - return (0); -} - -static void -pdu_read(const struct connection *conn, char *data, size_t len) -{ - ssize_t ret; - - while (len > 0) { - ret = read(conn->conn_socket, data, len); - if (ret < 0) { - if (timed_out()) { - fail(conn, "Login Phase timeout"); - log_errx(1, "exiting due to timeout"); - } - fail(conn, strerror(errno)); - log_err(1, "read"); - } else if (ret == 0) { - fail(conn, "connection lost"); - log_errx(1, "read: connection lost"); - } - len -= ret; - data += ret; - } -} - -void -pdu_receive(struct pdu *pdu) -{ - struct connection *conn; - size_t len, padding; - char dummy[4]; - - conn = pdu->pdu_connection; -#ifdef ICL_KERNEL_PROXY - if (conn->conn_conf.isc_iser != 0) - return (pdu_receive_proxy(pdu)); -#endif - assert(conn->conn_conf.isc_iser == 0); - - pdu_read(conn, (char *)pdu->pdu_bhs, sizeof(*pdu->pdu_bhs)); - - len = pdu_ahs_length(pdu); - if (len > 0) - log_errx(1, "protocol error: non-empty AHS"); - - len = pdu_data_segment_length(pdu); - if (len > 0) { - if (len > (size_t)conn->conn_max_recv_data_segment_length) { - log_errx(1, "protocol error: received PDU " - "with DataSegmentLength exceeding %d", - conn->conn_max_recv_data_segment_length); - } - - pdu->pdu_data_len = len; - pdu->pdu_data = malloc(len); - if (pdu->pdu_data == NULL) - log_err(1, "malloc"); - - pdu_read(conn, (char *)pdu->pdu_data, pdu->pdu_data_len); - - padding = pdu_padding(pdu); - if (padding != 0) { - assert(padding < sizeof(dummy)); - pdu_read(conn, (char *)dummy, padding); - } - } -} - -void -pdu_send(struct pdu *pdu) -{ - struct connection *conn; - ssize_t ret, total_len; - size_t padding; - uint32_t zero = 0; - struct iovec iov[3]; - int iovcnt; - - conn = pdu->pdu_connection; -#ifdef ICL_KERNEL_PROXY - if (conn->conn_conf.isc_iser != 0) - return (pdu_send_proxy(pdu)); -#endif - - assert(conn->conn_conf.isc_iser == 0); - - pdu_set_data_segment_length(pdu, pdu->pdu_data_len); - iov[0].iov_base = pdu->pdu_bhs; - iov[0].iov_len = sizeof(*pdu->pdu_bhs); - total_len = iov[0].iov_len; - iovcnt = 1; - - if (pdu->pdu_data_len > 0) { - iov[1].iov_base = pdu->pdu_data; - iov[1].iov_len = pdu->pdu_data_len; - total_len += iov[1].iov_len; - iovcnt = 2; - - padding = pdu_padding(pdu); - if (padding > 0) { - assert(padding < sizeof(zero)); - iov[2].iov_base = &zero; - iov[2].iov_len = padding; - total_len += iov[2].iov_len; - iovcnt = 3; - } - } - - ret = writev(conn->conn_socket, iov, iovcnt); - if (ret < 0) { - if (timed_out()) - log_errx(1, "exiting due to timeout"); - log_err(1, "writev"); - } - if (ret != total_len) - log_errx(1, "short write"); -} - -void -pdu_delete(struct pdu *pdu) -{ - - free(pdu->pdu_data); - free(pdu->pdu_bhs); - free(pdu); -} diff --git a/usr.sbin/kldxref/ef_nop.c b/usr.sbin/kldxref/ef_nop.c deleted file mode 100644 index 40d43c975c3..00000000000 --- a/usr.sbin/kldxref/ef_nop.c +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2003 Jake Burkholder. - * 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 -#include - -#include "ef.h" - -int -ef_reloc(struct elf_file *ef, const void *reldata, int reltype, Elf_Off relbase, - Elf_Off dataoff, size_t len, void *dest) -{ - - return (0); -} diff --git a/usr.sbin/makefs/msdos/denode.h b/usr.sbin/makefs/msdos/denode.h deleted file mode 100644 index e1e59c8b9ae..00000000000 --- a/usr.sbin/makefs/msdos/denode.h +++ /dev/null @@ -1,236 +0,0 @@ -/* $NetBSD: denode.h,v 1.25 1997/11/17 15:36:28 ws Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. - * Copyright (C) 1994, 1995, 1997 TooLs GmbH. - * All rights reserved. - * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. - */ -/*- - * Written by Paul Popelka (paulp@uts.amdahl.com) - * - * You can do anything you want with this software, just don't say you wrote - * it, and don't remove this notice. - * - * This software is provided "as is". - * - * The author supplies this software to be publicly redistributed on the - * understanding that the author is not responsible for the correct - * functioning of this software in any circumstances and is not liable for - * any damages caused by this software. - * - * October 1992 - */ -#ifndef _FS_MSDOSFS_DENODE_H_ -#define _FS_MSDOSFS_DENODE_H_ - -/* - * This is the pc filesystem specific portion of the vnode structure. - * - * To describe a file uniquely the de_dirclust, de_diroffset, and - * de_StartCluster fields are used. - * - * de_dirclust contains the cluster number of the directory cluster - * containing the entry for a file or directory. - * de_diroffset is the index into the cluster for the entry describing - * a file or directory. - * de_StartCluster is the number of the first cluster of the file or directory. - * - * Now to describe the quirks of the pc filesystem. - * - Clusters 0 and 1 are reserved. - * - The first allocatable cluster is 2. - * - The root directory is of fixed size and all blocks that make it up - * are contiguous. - * - Cluster 0 refers to the root directory when it is found in the - * startcluster field of a directory entry that points to another directory. - * - Cluster 0 implies a 0 length file when found in the start cluster field - * of a directory entry that points to a file. - * - You can't use the cluster number 0 to derive the address of the root - * directory. - * - Multiple directory entries can point to a directory. The entry in the - * parent directory points to a child directory. Any directories in the - * child directory contain a ".." entry that points back to the parent. - * The child directory itself contains a "." entry that points to itself. - * - The root directory does not contain a "." or ".." entry. - * - Directory entries for directories are never changed once they are created - * (except when removed). The size stays 0, and the last modification time - * is never changed. This is because so many directory entries can point to - * the physical clusters that make up a directory. It would lead to an - * update nightmare. - * - The length field in a directory entry pointing to a directory contains 0 - * (always). The only way to find the end of a directory is to follow the - * cluster chain until the "last cluster" marker is found. - * - * My extensions to make this house of cards work. These apply only to the in - * memory copy of the directory entry. - * - A reference count for each denode will be kept since dos doesn't keep such - * things. - */ - -/* - * Internal pseudo-offset for (nonexistent) directory entry for the root - * dir in the root dir - */ -#define MSDOSFSROOT_OFS 0x1fffffff - -/* - * The FAT cache structure. fc_fsrcn is the filesystem relative cluster - * number that corresponds to the file relative cluster number in this - * structure (fc_frcn). - */ -struct fatcache { - u_long fc_frcn; /* file relative cluster number */ - u_long fc_fsrcn; /* filesystem relative cluster number */ -}; - -/* - * The FAT entry cache as it stands helps make extending files a "quick" - * operation by avoiding having to scan the FAT to discover the last - * cluster of the file. The cache also helps sequential reads by - * remembering the last cluster read from the file. This also prevents us - * from having to rescan the FAT to find the next cluster to read. This - * cache is probably pretty worthless if a file is opened by multiple - * processes. - */ -#define FC_SIZE 3 /* number of entries in the cache */ -#define FC_LASTMAP 0 /* entry the last call to pcbmap() resolved - * to */ -#define FC_LASTFC 1 /* entry for the last cluster in the file */ -#define FC_NEXTTOLASTFC 2 /* entry for a close to the last cluster in - * the file */ - -#define FCE_EMPTY 0xffffffff /* doesn't represent an actual cluster # */ - -/* - * Set a slot in the FAT cache. - */ -#define fc_setcache(dep, slot, frcn, fsrcn) \ - (dep)->de_fc[(slot)].fc_frcn = (frcn); \ - (dep)->de_fc[(slot)].fc_fsrcn = (fsrcn); - -/* - * This is the in memory variant of a dos directory entry. It is usually - * contained within a vnode. - */ -struct denode { - struct vnode *de_vnode; /* addr of vnode we are part of */ - u_long de_flag; /* flag bits */ - u_long de_dirclust; /* cluster of the directory file containing this entry */ - u_long de_diroffset; /* offset of this entry in the directory cluster */ - u_long de_fndoffset; /* offset of found dir entry */ - int de_fndcnt; /* number of slots before de_fndoffset */ - long de_refcnt; /* reference count */ - struct msdosfsmount *de_pmp; /* addr of our mount struct */ - u_char de_Name[12]; /* name, from DOS directory entry */ - u_char de_Attributes; /* attributes, from directory entry */ - u_char de_LowerCase; /* NT VFAT lower case flags */ - u_char de_CHun; /* Hundredth of second of CTime*/ - u_short de_CTime; /* creation time */ - u_short de_CDate; /* creation date */ - u_short de_ADate; /* access date */ - u_short de_MTime; /* modification time */ - u_short de_MDate; /* modification date */ - u_long de_StartCluster; /* starting cluster of file */ - u_long de_FileSize; /* size of file in bytes */ - struct fatcache de_fc[FC_SIZE]; /* FAT cache */ - uint64_t de_inode; /* Inode number (really byte offset of direntry) */ -}; - -/* - * Values for the de_flag field of the denode. - */ -#define DE_UPDATE 0x0004 /* Modification time update request */ -#define DE_CREATE 0x0008 /* Creation time update */ -#define DE_ACCESS 0x0010 /* Access time update */ -#define DE_MODIFIED 0x0020 /* Denode has been modified */ -#define DE_RENAME 0x0040 /* Denode is in the process of being renamed */ - -/* Maximum size of a file on a FAT filesystem */ -#define MSDOSFS_FILESIZE_MAX 0xFFFFFFFFLL - -/* - * Transfer directory entries between internal and external form. - * dep is a struct denode * (internal form), - * dp is a struct direntry * (external form). - */ -#define DE_INTERNALIZE32(dep, dp) \ - ((dep)->de_StartCluster |= getushort((dp)->deHighClust) << 16) -#define DE_INTERNALIZE(dep, dp) \ - (memcpy((dep)->de_Name, (dp)->deName, 11), \ - (dep)->de_Attributes = (dp)->deAttributes, \ - (dep)->de_LowerCase = (dp)->deLowerCase, \ - (dep)->de_CHun = (dp)->deCHundredth, \ - (dep)->de_CTime = getushort((dp)->deCTime), \ - (dep)->de_CDate = getushort((dp)->deCDate), \ - (dep)->de_ADate = getushort((dp)->deADate), \ - (dep)->de_MTime = getushort((dp)->deMTime), \ - (dep)->de_MDate = getushort((dp)->deMDate), \ - (dep)->de_StartCluster = getushort((dp)->deStartCluster), \ - (dep)->de_FileSize = getulong((dp)->deFileSize), \ - (FAT32((dep)->de_pmp) ? DE_INTERNALIZE32((dep), (dp)) : 0)) - -#define DE_EXTERNALIZE(dp, dep) \ - (memcpy((dp)->deName, (dep)->de_Name, 11), \ - (dp)->deAttributes = (dep)->de_Attributes, \ - (dp)->deLowerCase = (dep)->de_LowerCase, \ - (dp)->deCHundredth = (dep)->de_CHun, \ - putushort((dp)->deCTime, (dep)->de_CTime), \ - putushort((dp)->deCDate, (dep)->de_CDate), \ - putushort((dp)->deADate, (dep)->de_ADate), \ - putushort((dp)->deMTime, (dep)->de_MTime), \ - putushort((dp)->deMDate, (dep)->de_MDate), \ - putushort((dp)->deStartCluster, (dep)->de_StartCluster), \ - putulong((dp)->deFileSize, \ - ((dep)->de_Attributes & ATTR_DIRECTORY) ? 0 : (dep)->de_FileSize), \ - putushort((dp)->deHighClust, (dep)->de_StartCluster >> 16)) - -#define VTODE(vp) ((struct denode *)(vp)->v_data) -#define DETOV(de) ((de)->de_vnode) - -struct buf; -struct msdosfsmount; -struct direntry; -struct componentname; -struct denode; - -/* - * Internal service routine prototypes. - */ -int deget(struct msdosfsmount *, u_long, u_long, struct denode **); -int uniqdosname(struct denode *, struct componentname *, u_char *); - -int readep(struct msdosfsmount *pmp, u_long dirclu, u_long dirofs, struct buf **bpp, struct direntry **epp); -int readde(struct denode *dep, struct buf **bpp, struct direntry **epp); -int deextend(struct denode *dep, u_long length); -int fillinusemap(struct msdosfsmount *pmp); -int createde(struct denode *dep, struct denode *ddep, struct denode **depp, struct componentname *cnp); -int removede(struct denode *pdep, struct denode *dep); -int detrunc(struct denode *dep, u_long length, int flags); -#endif /* !_FS_MSDOSFS_DENODE_H_ */ diff --git a/usr.sbin/makefs/msdos/fat.h b/usr.sbin/makefs/msdos/fat.h deleted file mode 100644 index d85cac9d8cb..00000000000 --- a/usr.sbin/makefs/msdos/fat.h +++ /dev/null @@ -1,109 +0,0 @@ -/* $NetBSD: fat.h,v 1.12 1997/11/17 15:36:36 ws Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1994, 1997 Wolfgang Solfrank. - * Copyright (C) 1994, 1997 TooLs GmbH. - * All rights reserved. - * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. - */ -/*- - * Written by Paul Popelka (paulp@uts.amdahl.com) - * - * You can do anything you want with this software, just don't say you wrote - * it, and don't remove this notice. - * - * This software is provided "as is". - * - * The author supplies this software to be publicly redistributed on the - * understanding that the author is not responsible for the correct - * functioning of this software in any circumstances and is not liable for - * any damages caused by this software. - * - * October 1992 - */ - -#ifndef _FS_MSDOSFS_FAT_H_ -#define _FS_MSDOSFS_FAT_H_ -/* - * Some useful cluster numbers. - */ -#define MSDOSFSROOT 0 /* cluster 0 means the root dir */ -#define CLUST_FREE 0 /* cluster 0 also means a free cluster */ -#define MSDOSFSFREE CLUST_FREE -#define CLUST_FIRST 2 /* first legal cluster number */ -#define CLUST_RSRVD 0xfffffff6 /* reserved cluster range */ -#define CLUST_BAD 0xfffffff7 /* a cluster with a defect */ -#define CLUST_EOFS 0xfffffff8 /* start of eof cluster range */ -#define CLUST_EOFE 0xffffffff /* end of eof cluster range */ - -#define FAT12_MASK 0x00000fff /* mask for 12 bit cluster numbers */ -#define FAT16_MASK 0x0000ffff /* mask for 16 bit cluster numbers */ -#define FAT32_MASK 0x0fffffff /* mask for FAT32 cluster numbers */ - -/* - * MSDOSFS: - * Return true if filesystem uses 12 bit FATs. Microsoft Programmer's - * Reference says if the maximum cluster number in a filesystem is greater - * than 4084 ((CLUST_RSRVD - CLUST_FIRST) & FAT12_MASK) then we've got a - * 16 bit FAT filesystem. While mounting, the result of this test is stored - * in pm_fatentrysize. - */ -#define FAT12(pmp) (pmp->pm_fatmask == FAT12_MASK) -#define FAT16(pmp) (pmp->pm_fatmask == FAT16_MASK) -#define FAT32(pmp) (pmp->pm_fatmask == FAT32_MASK) - -#define MSDOSFSEOF(pmp, cn) ((((cn) | ~(pmp)->pm_fatmask) & CLUST_EOFS) == CLUST_EOFS) - -/* - * These are the values for the function argument to the function - * fatentry(). - */ -#define FAT_GET 0x0001 /* get a FAT entry */ -#define FAT_SET 0x0002 /* set a FAT entry */ -#define FAT_GET_AND_SET (FAT_GET | FAT_SET) - -/* - * Flags to extendfile: - */ -#define DE_CLEAR 1 /* Zero out the blocks allocated */ - -struct buf; -struct denode; -struct msdosfsmount; - -int pcbmap(struct denode *dep, u_long findcn, daddr_t *bnp, u_long *cnp, int* sp); -int clusterfree(struct msdosfsmount *pmp, u_long cn, u_long *oldcnp); -int clusteralloc(struct msdosfsmount *pmp, u_long start, u_long count, u_long fillwith, u_long *retcluster, u_long *got); -int fatentry(int function, struct msdosfsmount *pmp, u_long cluster, u_long *oldcontents, u_long newcontents); -int freeclusterchain(struct msdosfsmount *pmp, u_long startchain); -int extendfile(struct denode *dep, u_long count, struct buf **bpp, u_long *ncp, int flags); -void fc_purge(struct denode *dep, u_int frcn); - -#endif /* !_FS_MSDOSFS_FAT_H_ */ diff --git a/usr.sbin/makefs/msdos/msdosfs_fat.c b/usr.sbin/makefs/msdos/msdosfs_fat.c index bb5eea45751..e09ba075539 100644 --- a/usr.sbin/makefs/msdos/msdosfs_fat.c +++ b/usr.sbin/makefs/msdos/msdosfs_fat.c @@ -247,7 +247,7 @@ pcbmap(struct denode *dep, u_long findcn, daddr_t *bnp, u_long *cnp, int *sp) return (0); } -hiteof:; +hiteof: if (cnp) *cnp = i; if (bp) diff --git a/usr.sbin/makefs/msdos/msdosfsmount.h b/usr.sbin/makefs/msdos/msdosfsmount.h deleted file mode 100644 index 802c8ffc687..00000000000 --- a/usr.sbin/makefs/msdos/msdosfsmount.h +++ /dev/null @@ -1,198 +0,0 @@ -/* $NetBSD: msdosfsmount.h,v 1.17 1997/11/17 15:37:07 ws Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. - * Copyright (C) 1994, 1995, 1997 TooLs GmbH. - * All rights reserved. - * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below). - * - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. - */ -/*- - * Written by Paul Popelka (paulp@uts.amdahl.com) - * - * You can do anything you want with this software, just don't say you wrote - * it, and don't remove this notice. - * - * This software is provided "as is". - * - * The author supplies this software to be publicly redistributed on the - * understanding that the author is not responsible for the correct - * functioning of this software in any circumstances and is not liable for - * any damages caused by this software. - * - * October 1992 - */ - -#ifndef _MSDOSFS_MSDOSFSMOUNT_H_ -#define _MSDOSFS_MSDOSFSMOUNT_H_ - -#include - -struct vnode; -struct cdev; -struct bpb50; - -/* - * Layout of the mount control block for a MSDOSFS filesystem. - */ -struct msdosfsmount { - struct vnode *pm_devvp; /* vnode for character device mounted */ - struct cdev *pm_dev; /* character device mounted */ - struct bpb50 pm_bpb; /* BIOS parameter blk for this fs */ - u_long pm_FATsecs; /* actual number of FAT sectors */ - u_long pm_fatblk; /* block # of first FAT */ - u_long pm_rootdirblk; /* block # (cluster # for FAT32) of root directory number */ - u_long pm_rootdirsize; /* size in blocks (not clusters) */ - u_long pm_firstcluster; /* block number of first cluster */ - u_long pm_maxcluster; /* maximum cluster number */ - u_long pm_freeclustercount; /* number of free clusters */ - u_long pm_cnshift; /* shift file offset right this amount to get a cluster number */ - u_long pm_crbomask; /* and a file offset with this mask to get cluster rel offset */ - u_long pm_bnshift; /* shift file offset right this amount to get a block number */ - u_long pm_bpcluster; /* bytes per cluster */ - u_long pm_fmod; /* ~0 if fs is modified, this can rollover to 0 */ - u_long pm_fatblocksize; /* size of FAT blocks in bytes */ - u_long pm_fatblocksec; /* size of FAT blocks in sectors */ - u_long pm_fatsize; /* size of FAT in bytes */ - uint32_t pm_fatmask; /* mask to use for FAT numbers */ - u_long pm_fsinfo; /* fsinfo block number */ - u_long pm_nxtfree; /* next place to search for a free cluster */ - u_int pm_fatmult; /* these 2 values are used in FAT */ - u_int pm_fatdiv; /* offset computation */ - u_int pm_curfat; /* current FAT for FAT32 (0 otherwise) */ - u_int *pm_inusemap; /* ptr to bitmap of in-use clusters */ - uint64_t pm_flags; /* see below */ -}; - -/* Byte offset in FAT on filesystem pmp, cluster cn */ -#define FATOFS(pmp, cn) ((cn) * (pmp)->pm_fatmult / (pmp)->pm_fatdiv) - -/* Number of bits in one pm_inusemap item: */ -#define N_INUSEBITS (8 * sizeof(u_int)) - -/* - * Shorthand for fields in the bpb contained in the msdosfsmount structure. - */ -#define pm_BytesPerSec pm_bpb.bpbBytesPerSec -#define pm_ResSectors pm_bpb.bpbResSectors -#define pm_FATs pm_bpb.bpbFATs -#define pm_RootDirEnts pm_bpb.bpbRootDirEnts -#define pm_Sectors pm_bpb.bpbSectors -#define pm_Media pm_bpb.bpbMedia -#define pm_SecPerTrack pm_bpb.bpbSecPerTrack -#define pm_Heads pm_bpb.bpbHeads -#define pm_HiddenSects pm_bpb.bpbHiddenSecs -#define pm_HugeSectors pm_bpb.bpbHugeSectors - -/* - * Convert pointer to buffer -> pointer to direntry - */ -#define bptoep(pmp, bp, dirofs) \ - ((struct direntry *)(((bp)->b_data) \ - + ((dirofs) & (pmp)->pm_crbomask))) - -/* - * Convert block number to cluster number - */ -#define de_bn2cn(pmp, bn) \ - ((bn) >> ((pmp)->pm_cnshift - (pmp)->pm_bnshift)) - -/* - * Convert cluster number to block number - */ -#define de_cn2bn(pmp, cn) \ - ((cn) << ((pmp)->pm_cnshift - (pmp)->pm_bnshift)) - -/* - * Convert file offset to cluster number - */ -#define de_cluster(pmp, off) \ - ((off) >> (pmp)->pm_cnshift) - -/* - * Clusters required to hold size bytes - */ -#define de_clcount(pmp, size) \ - (((size) + (pmp)->pm_bpcluster - 1) >> (pmp)->pm_cnshift) - -/* - * Convert file offset to block number - */ -#define de_blk(pmp, off) \ - (de_cn2bn(pmp, de_cluster((pmp), (off)))) - -/* - * Convert cluster number to file offset - */ -#define de_cn2off(pmp, cn) \ - ((cn) << (pmp)->pm_cnshift) - -/* - * Convert block number to file offset - */ -#define de_bn2off(pmp, bn) \ - ((bn) << (pmp)->pm_bnshift) -/* - * Map a cluster number into a filesystem relative block number. - */ -#define cntobn(pmp, cn) \ - (de_cn2bn((pmp), (cn)-CLUST_FIRST) + (pmp)->pm_firstcluster) - -/* - * Calculate block number for directory entry in root dir, offset dirofs - */ -#define roottobn(pmp, dirofs) \ - (de_blk((pmp), (dirofs)) + (pmp)->pm_rootdirblk) - -/* - * Calculate block number for directory entry at cluster dirclu, offset - * dirofs - */ -#define detobn(pmp, dirclu, dirofs) \ - ((dirclu) == MSDOSFSROOT \ - ? roottobn((pmp), (dirofs)) \ - : cntobn((pmp), (dirclu))) - -/* - * Msdosfs mount options: - */ -#define MSDOSFSMNT_SHORTNAME 1 /* Force old DOS short names only */ -#define MSDOSFSMNT_LONGNAME 2 /* Force Win'95 long names */ -#define MSDOSFSMNT_NOWIN95 4 /* Completely ignore Win95 entries */ -#define MSDOSFSMNT_KICONV 0x10 /* Use libiconv to convert chars */ -/* All flags above: */ -#define MSDOSFSMNT_MNTOPT \ - (MSDOSFSMNT_SHORTNAME|MSDOSFSMNT_LONGNAME|MSDOSFSMNT_NOWIN95 \ - |MSDOSFSMNT_KICONV) -#define MSDOSFSMNT_RONLY 0x80000000 /* mounted read-only */ -#define MSDOSFSMNT_WAITONFAT 0x40000000 /* mounted synchronous */ -#define MSDOSFS_FATMIRROR 0x20000000 /* FAT is mirrored */ -#define MSDOSFS_FSIMOD 0x01000000 - -#endif /* !_MSDOSFS_MSDOSFSMOUNT_H_ */ diff --git a/usr.sbin/mpsutil/mpr_ioctl.h b/usr.sbin/mpsutil/mpr_ioctl.h deleted file mode 100644 index c2746ea4df4..00000000000 --- a/usr.sbin/mpsutil/mpr_ioctl.h +++ /dev/null @@ -1,386 +0,0 @@ -/*- - * Copyright (c) 2008 Yahoo!, Inc. - * All rights reserved. - * Written by: John Baldwin - * - * 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. - * 3. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * 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. - * - * LSI MPT-Fusion Host Adapter FreeBSD userland interface - * - */ -/*- - * Copyright (c) 2011-2014 LSI Corp. - * 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. - * - * LSI MPT-Fusion Host Adapter FreeBSD - * - */ - -#ifndef _MPR_IOCTL_H_ -#define _MPR_IOCTL_H_ - -#include -#include -#include -#include - -/* - * For the read header requests, the header should include the page - * type or extended page type, page number, and page version. The - * buffer and length are unused. The completed header is returned in - * the 'header' member. - * - * For the read page and write page requests, 'buf' should point to a - * buffer of 'len' bytes which holds the entire page (including the - * header). - * - * All requests specify the page address in 'page_address'. - */ -struct mpr_cfg_page_req { - MPI2_CONFIG_PAGE_HEADER header; - uint32_t page_address; - void *buf; - int len; - uint16_t ioc_status; -}; - -struct mpr_ext_cfg_page_req { - MPI2_CONFIG_EXTENDED_PAGE_HEADER header; - uint32_t page_address; - void *buf; - int len; - uint16_t ioc_status; -}; - -struct mpr_raid_action { - uint8_t action; - uint8_t volume_bus; - uint8_t volume_id; - uint8_t phys_disk_num; - uint32_t action_data_word; - void *buf; - int len; - uint32_t volume_status; - uint32_t action_data[4]; - uint16_t action_status; - uint16_t ioc_status; - uint8_t write; -}; - -struct mpr_usr_command { - void *req; - uint32_t req_len; - void *rpl; - uint32_t rpl_len; - void *buf; - int len; - uint32_t flags; -}; - -typedef struct mpr_pci_bits -{ - union { - struct { - uint32_t DeviceNumber :5; - uint32_t FunctionNumber :3; - uint32_t BusNumber :24; - } bits; - uint32_t AsDWORD; - } u; - uint32_t PciSegmentId; -} mpr_pci_bits_t; - -/* - * The following is the MPRIOCTL_GET_ADAPTER_DATA data structure. This data - * structure is setup so that we hopefully are properly aligned for both - * 32-bit and 64-bit mode applications. - * - * Adapter Type - Value = 6 = SCSI Protocol through SAS-3 adapter - * - * MPI Port Number - The PCI Function number for this device - * - * PCI Device HW Id - The PCI device number for this device - * - */ -#define MPRIOCTL_ADAPTER_TYPE_SAS3 6 -typedef struct mpr_adapter_data -{ - uint32_t StructureLength; - uint32_t AdapterType; - uint32_t MpiPortNumber; - uint32_t PCIDeviceHwId; - uint32_t PCIDeviceHwRev; - uint32_t SubSystemId; - uint32_t SubsystemVendorId; - uint32_t Reserved1; - uint32_t MpiFirmwareVersion; - uint32_t BiosVersion; - uint8_t DriverVersion[32]; - uint8_t Reserved2; - uint8_t ScsiId; - uint16_t Reserved3; - mpr_pci_bits_t PciInformation; -} mpr_adapter_data_t; - - -typedef struct mpr_update_flash -{ - uint64_t PtrBuffer; - uint32_t ImageChecksum; - uint32_t ImageOffset; - uint32_t ImageSize; - uint32_t ImageType; -} mpr_update_flash_t; - - -#define MPR_PASS_THRU_DIRECTION_NONE 0 -#define MPR_PASS_THRU_DIRECTION_READ 1 -#define MPR_PASS_THRU_DIRECTION_WRITE 2 -#define MPR_PASS_THRU_DIRECTION_BOTH 3 - -typedef struct mpr_pass_thru -{ - uint64_t PtrRequest; - uint64_t PtrReply; - uint64_t PtrData; - uint32_t RequestSize; - uint32_t ReplySize; - uint32_t DataSize; - uint32_t DataDirection; - uint64_t PtrDataOut; - uint32_t DataOutSize; - uint32_t Timeout; -} mpr_pass_thru_t; - - -/* - * Event queue defines - */ -#define MPR_EVENT_QUEUE_SIZE (50) /* Max Events stored in driver */ -#define MPR_MAX_EVENT_DATA_LENGTH (48) /* Size of each event in Dwords */ - -typedef struct mpr_event_query -{ - uint16_t Entries; - uint16_t Reserved; - uint32_t Types[4]; -} mpr_event_query_t; - -typedef struct mpr_event_enable -{ - uint32_t Types[4]; -} mpr_event_enable_t; - -/* - * Event record entry for ioctl. - */ -typedef struct mpr_event_entry -{ - uint32_t Type; - uint32_t Number; - uint32_t Data[MPR_MAX_EVENT_DATA_LENGTH]; -} mpr_event_entry_t; - -typedef struct mpr_event_report -{ - uint32_t Size; - uint64_t PtrEvents; -} mpr_event_report_t; - - -typedef struct mpr_pci_info -{ - uint32_t BusNumber; - uint8_t DeviceNumber; - uint8_t FunctionNumber; - uint16_t InterruptVector; - uint8_t PciHeader[256]; -} mpr_pci_info_t; - - -typedef struct mpr_diag_action -{ - uint32_t Action; - uint32_t Length; - uint64_t PtrDiagAction; - uint32_t ReturnCode; -} mpr_diag_action_t; - -#define MPR_FW_DIAGNOSTIC_UID_NOT_FOUND (0xFF) - -#define MPR_FW_DIAG_NEW (0x806E6577) - -#define MPR_FW_DIAG_TYPE_REGISTER (0x00000001) -#define MPR_FW_DIAG_TYPE_UNREGISTER (0x00000002) -#define MPR_FW_DIAG_TYPE_QUERY (0x00000003) -#define MPR_FW_DIAG_TYPE_READ_BUFFER (0x00000004) -#define MPR_FW_DIAG_TYPE_RELEASE (0x00000005) - -#define MPR_FW_DIAG_INVALID_UID (0x00000000) - -#define MPR_DIAG_SUCCESS 0 -#define MPR_DIAG_FAILURE 1 - -#define MPR_FW_DIAG_ERROR_SUCCESS (0x00000000) -#define MPR_FW_DIAG_ERROR_FAILURE (0x00000001) -#define MPR_FW_DIAG_ERROR_INVALID_PARAMETER (0x00000002) -#define MPR_FW_DIAG_ERROR_POST_FAILED (0x00000010) -#define MPR_FW_DIAG_ERROR_INVALID_UID (0x00000011) -#define MPR_FW_DIAG_ERROR_RELEASE_FAILED (0x00000012) -#define MPR_FW_DIAG_ERROR_NO_BUFFER (0x00000013) -#define MPR_FW_DIAG_ERROR_ALREADY_RELEASED (0x00000014) - - -typedef struct mpr_fw_diag_register -{ - uint8_t ExtendedType; - uint8_t BufferType; - uint16_t ApplicationFlags; - uint32_t DiagnosticFlags; - uint32_t ProductSpecific[23]; - uint32_t RequestedBufferSize; - uint32_t UniqueId; -} mpr_fw_diag_register_t; - -typedef struct mpr_fw_diag_unregister -{ - uint32_t UniqueId; -} mpr_fw_diag_unregister_t; - -#define MPR_FW_DIAG_FLAG_APP_OWNED (0x0001) -#define MPR_FW_DIAG_FLAG_BUFFER_VALID (0x0002) -#define MPR_FW_DIAG_FLAG_FW_BUFFER_ACCESS (0x0004) - -typedef struct mpr_fw_diag_query -{ - uint8_t ExtendedType; - uint8_t BufferType; - uint16_t ApplicationFlags; - uint32_t DiagnosticFlags; - uint32_t ProductSpecific[23]; - uint32_t TotalBufferSize; - uint32_t DriverAddedBufferSize; - uint32_t UniqueId; -} mpr_fw_diag_query_t; - -typedef struct mpr_fw_diag_release -{ - uint32_t UniqueId; -} mpr_fw_diag_release_t; - -#define MPR_FW_DIAG_FLAG_REREGISTER (0x0001) -#define MPR_FW_DIAG_FLAG_FORCE_RELEASE (0x0002) - -typedef struct mpr_diag_read_buffer -{ - uint8_t Status; - uint8_t Reserved; - uint16_t Flags; - uint32_t StartingOffset; - uint32_t BytesToRead; - uint32_t UniqueId; - uint64_t PtrDataBuffer; -} mpr_diag_read_buffer_t; - -/* - * Register Access - */ -#define REG_IO_READ 1 -#define REG_IO_WRITE 2 -#define REG_MEM_READ 3 -#define REG_MEM_WRITE 4 - -typedef struct mpr_reg_access -{ - uint32_t Command; - uint32_t RegOffset; - uint32_t RegData; -} mpr_reg_access_t; - -typedef struct mpr_btdh_mapping -{ - uint16_t TargetID; - uint16_t Bus; - uint16_t DevHandle; - uint16_t Reserved; -} mpr_btdh_mapping_t; - -#define MPRIO_MPR_COMMAND_FLAG_VERBOSE 0x01 -#define MPRIO_MPR_COMMAND_FLAG_DEBUG 0x02 -#define MPRIO_READ_CFG_HEADER _IOWR('M', 200, struct mpr_cfg_page_req) -#define MPRIO_READ_CFG_PAGE _IOWR('M', 201, struct mpr_cfg_page_req) -#define MPRIO_READ_EXT_CFG_HEADER _IOWR('M', 202, struct mpr_ext_cfg_page_req) -#define MPRIO_READ_EXT_CFG_PAGE _IOWR('M', 203, struct mpr_ext_cfg_page_req) -#define MPRIO_WRITE_CFG_PAGE _IOWR('M', 204, struct mpr_cfg_page_req) -#define MPRIO_RAID_ACTION _IOWR('M', 205, struct mpr_raid_action) -#define MPRIO_MPR_COMMAND _IOWR('M', 210, struct mpr_usr_command) - -#ifndef MPTIOCTL -#define MPTIOCTL ('I') -#define MPTIOCTL_GET_ADAPTER_DATA _IOWR(MPTIOCTL, 1,\ - struct mpr_adapter_data) -#define MPTIOCTL_UPDATE_FLASH _IOWR(MPTIOCTL, 2,\ - struct mpr_update_flash) -#define MPTIOCTL_RESET_ADAPTER _IO(MPTIOCTL, 3) -#define MPTIOCTL_PASS_THRU _IOWR(MPTIOCTL, 4,\ - struct mpr_pass_thru) -#define MPTIOCTL_EVENT_QUERY _IOWR(MPTIOCTL, 5,\ - struct mpr_event_query) -#define MPTIOCTL_EVENT_ENABLE _IOWR(MPTIOCTL, 6,\ - struct mpr_event_enable) -#define MPTIOCTL_EVENT_REPORT _IOWR(MPTIOCTL, 7,\ - struct mpr_event_report) -#define MPTIOCTL_GET_PCI_INFO _IOWR(MPTIOCTL, 8,\ - struct mpr_pci_info) -#define MPTIOCTL_DIAG_ACTION _IOWR(MPTIOCTL, 9,\ - struct mpr_diag_action) -#define MPTIOCTL_REG_ACCESS _IOWR(MPTIOCTL, 10,\ - struct mpr_reg_access) -#define MPTIOCTL_BTDH_MAPPING _IOWR(MPTIOCTL, 11,\ - struct mpr_btdh_mapping) -#endif - -#endif /* !_MPR_IOCTL_H_ */ diff --git a/usr.sbin/mpsutil/mps_ioctl.h b/usr.sbin/mpsutil/mps_ioctl.h deleted file mode 100644 index cb1ad459544..00000000000 --- a/usr.sbin/mpsutil/mps_ioctl.h +++ /dev/null @@ -1,385 +0,0 @@ -/*- - * Copyright (c) 2008 Yahoo!, Inc. - * All rights reserved. - * Written by: John Baldwin - * - * 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. - * 3. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * 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. - * - * LSI MPT-Fusion Host Adapter FreeBSD userland interface - * - */ -/*- - * Copyright (c) 2011, 2012 LSI Corp. - * 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. - * - * LSI MPT-Fusion Host Adapter FreeBSD - * - */ - -#ifndef _MPS_IOCTL_H_ -#define _MPS_IOCTL_H_ - -#include -#include -#include -#include - -/* - * For the read header requests, the header should include the page - * type or extended page type, page number, and page version. The - * buffer and length are unused. The completed header is returned in - * the 'header' member. - * - * For the read page and write page requests, 'buf' should point to a - * buffer of 'len' bytes which holds the entire page (including the - * header). - * - * All requests specify the page address in 'page_address'. - */ -struct mps_cfg_page_req { - MPI2_CONFIG_PAGE_HEADER header; - uint32_t page_address; - void *buf; - int len; - uint16_t ioc_status; -}; - -struct mps_ext_cfg_page_req { - MPI2_CONFIG_EXTENDED_PAGE_HEADER header; - uint32_t page_address; - void *buf; - int len; - uint16_t ioc_status; -}; - -struct mps_raid_action { - uint8_t action; - uint8_t volume_bus; - uint8_t volume_id; - uint8_t phys_disk_num; - uint32_t action_data_word; - void *buf; - int len; - uint32_t volume_status; - uint32_t action_data[4]; - uint16_t action_status; - uint16_t ioc_status; - uint8_t write; -}; - -struct mps_usr_command { - void *req; - uint32_t req_len; - void *rpl; - uint32_t rpl_len; - void *buf; - int len; - uint32_t flags; -}; - -typedef struct mps_pci_bits -{ - union { - struct { - uint32_t DeviceNumber :5; - uint32_t FunctionNumber :3; - uint32_t BusNumber :24; - } bits; - uint32_t AsDWORD; - } u; - uint32_t PciSegmentId; -} mps_pci_bits_t; - -/* - * The following is the MPSIOCTL_GET_ADAPTER_DATA data structure. This data - * structure is setup so that we hopefully are properly aligned for both - * 32-bit and 64-bit mode applications. - * - * Adapter Type - Value = 4 = SCSI Protocol through SAS-2 adapter - * - * MPI Port Number - The PCI Function number for this device - * - * PCI Device HW Id - The PCI device number for this device - * - */ -#define MPSIOCTL_ADAPTER_TYPE_SAS2 4 -#define MPSIOCTL_ADAPTER_TYPE_SAS2_SSS6200 5 -typedef struct mps_adapter_data -{ - uint32_t StructureLength; - uint32_t AdapterType; - uint32_t MpiPortNumber; - uint32_t PCIDeviceHwId; - uint32_t PCIDeviceHwRev; - uint32_t SubSystemId; - uint32_t SubsystemVendorId; - uint32_t Reserved1; - uint32_t MpiFirmwareVersion; - uint32_t BiosVersion; - uint8_t DriverVersion[32]; - uint8_t Reserved2; - uint8_t ScsiId; - uint16_t Reserved3; - mps_pci_bits_t PciInformation; -} mps_adapter_data_t; - - -typedef struct mps_update_flash -{ - uint64_t PtrBuffer; - uint32_t ImageChecksum; - uint32_t ImageOffset; - uint32_t ImageSize; - uint32_t ImageType; -} mps_update_flash_t; - - -#define MPS_PASS_THRU_DIRECTION_NONE 0 -#define MPS_PASS_THRU_DIRECTION_READ 1 -#define MPS_PASS_THRU_DIRECTION_WRITE 2 -#define MPS_PASS_THRU_DIRECTION_BOTH 3 - -typedef struct mps_pass_thru -{ - uint64_t PtrRequest; - uint64_t PtrReply; - uint64_t PtrData; - uint32_t RequestSize; - uint32_t ReplySize; - uint32_t DataSize; - uint32_t DataDirection; - uint64_t PtrDataOut; - uint32_t DataOutSize; - uint32_t Timeout; -} mps_pass_thru_t; - - -/* - * Event queue defines - */ -#define MPS_EVENT_QUEUE_SIZE (50) /* Max Events stored in driver */ -#define MPS_MAX_EVENT_DATA_LENGTH (48) /* Size of each event in Dwords */ - -typedef struct mps_event_query -{ - uint16_t Entries; - uint16_t Reserved; - uint32_t Types[4]; -} mps_event_query_t; - -typedef struct mps_event_enable -{ - uint32_t Types[4]; -} mps_event_enable_t; - -/* - * Event record entry for ioctl. - */ -typedef struct mps_event_entry -{ - uint32_t Type; - uint32_t Number; - uint32_t Data[MPS_MAX_EVENT_DATA_LENGTH]; -} mps_event_entry_t; - -typedef struct mps_event_report -{ - uint32_t Size; - uint64_t PtrEvents; -} mps_event_report_t; - - -typedef struct mps_pci_info -{ - uint32_t BusNumber; - uint8_t DeviceNumber; - uint8_t FunctionNumber; - uint16_t InterruptVector; - uint8_t PciHeader[256]; -} mps_pci_info_t; - - -typedef struct mps_diag_action -{ - uint32_t Action; - uint32_t Length; - uint64_t PtrDiagAction; - uint32_t ReturnCode; -} mps_diag_action_t; - -#define MPS_FW_DIAGNOSTIC_UID_NOT_FOUND (0xFF) - -#define MPS_FW_DIAG_NEW (0x806E6577) - -#define MPS_FW_DIAG_TYPE_REGISTER (0x00000001) -#define MPS_FW_DIAG_TYPE_UNREGISTER (0x00000002) -#define MPS_FW_DIAG_TYPE_QUERY (0x00000003) -#define MPS_FW_DIAG_TYPE_READ_BUFFER (0x00000004) -#define MPS_FW_DIAG_TYPE_RELEASE (0x00000005) - -#define MPS_FW_DIAG_INVALID_UID (0x00000000) - -#define MPS_DIAG_SUCCESS 0 -#define MPS_DIAG_FAILURE 1 - -#define MPS_FW_DIAG_ERROR_SUCCESS (0x00000000) -#define MPS_FW_DIAG_ERROR_FAILURE (0x00000001) -#define MPS_FW_DIAG_ERROR_INVALID_PARAMETER (0x00000002) -#define MPS_FW_DIAG_ERROR_POST_FAILED (0x00000010) -#define MPS_FW_DIAG_ERROR_INVALID_UID (0x00000011) -#define MPS_FW_DIAG_ERROR_RELEASE_FAILED (0x00000012) -#define MPS_FW_DIAG_ERROR_NO_BUFFER (0x00000013) -#define MPS_FW_DIAG_ERROR_ALREADY_RELEASED (0x00000014) - - -typedef struct mps_fw_diag_register -{ - uint8_t ExtendedType; - uint8_t BufferType; - uint16_t ApplicationFlags; - uint32_t DiagnosticFlags; - uint32_t ProductSpecific[23]; - uint32_t RequestedBufferSize; - uint32_t UniqueId; -} mps_fw_diag_register_t; - -typedef struct mps_fw_diag_unregister -{ - uint32_t UniqueId; -} mps_fw_diag_unregister_t; - -#define MPS_FW_DIAG_FLAG_APP_OWNED (0x0001) -#define MPS_FW_DIAG_FLAG_BUFFER_VALID (0x0002) -#define MPS_FW_DIAG_FLAG_FW_BUFFER_ACCESS (0x0004) - -typedef struct mps_fw_diag_query -{ - uint8_t ExtendedType; - uint8_t BufferType; - uint16_t ApplicationFlags; - uint32_t DiagnosticFlags; - uint32_t ProductSpecific[23]; - uint32_t TotalBufferSize; - uint32_t DriverAddedBufferSize; - uint32_t UniqueId; -} mps_fw_diag_query_t; - -typedef struct mps_fw_diag_release -{ - uint32_t UniqueId; -} mps_fw_diag_release_t; - -#define MPS_FW_DIAG_FLAG_REREGISTER (0x0001) -#define MPS_FW_DIAG_FLAG_FORCE_RELEASE (0x0002) - -typedef struct mps_diag_read_buffer -{ - uint8_t Status; - uint8_t Reserved; - uint16_t Flags; - uint32_t StartingOffset; - uint32_t BytesToRead; - uint32_t UniqueId; - uint64_t PtrDataBuffer; -} mps_diag_read_buffer_t; - -/* - * Register Access - */ -#define REG_IO_READ 1 -#define REG_IO_WRITE 2 -#define REG_MEM_READ 3 -#define REG_MEM_WRITE 4 - -typedef struct mps_reg_access -{ - uint32_t Command; - uint32_t RegOffset; - uint32_t RegData; -} mps_reg_access_t; - -typedef struct mps_btdh_mapping -{ - uint16_t TargetID; - uint16_t Bus; - uint16_t DevHandle; - uint16_t Reserved; -} mps_btdh_mapping_t; - -#define MPSIO_MPS_COMMAND_FLAG_VERBOSE 0x01 -#define MPSIO_MPS_COMMAND_FLAG_DEBUG 0x02 -#define MPSIO_READ_CFG_HEADER _IOWR('M', 200, struct mps_cfg_page_req) -#define MPSIO_READ_CFG_PAGE _IOWR('M', 201, struct mps_cfg_page_req) -#define MPSIO_READ_EXT_CFG_HEADER _IOWR('M', 202, struct mps_ext_cfg_page_req) -#define MPSIO_READ_EXT_CFG_PAGE _IOWR('M', 203, struct mps_ext_cfg_page_req) -#define MPSIO_WRITE_CFG_PAGE _IOWR('M', 204, struct mps_cfg_page_req) -#define MPSIO_RAID_ACTION _IOWR('M', 205, struct mps_raid_action) -#define MPSIO_MPS_COMMAND _IOWR('M', 210, struct mps_usr_command) - -#define MPTIOCTL ('I') -#define MPTIOCTL_GET_ADAPTER_DATA _IOWR(MPTIOCTL, 1,\ - struct mps_adapter_data) -#define MPTIOCTL_UPDATE_FLASH _IOWR(MPTIOCTL, 2,\ - struct mps_update_flash) -#define MPTIOCTL_RESET_ADAPTER _IO(MPTIOCTL, 3) -#define MPTIOCTL_PASS_THRU _IOWR(MPTIOCTL, 4,\ - struct mps_pass_thru) -#define MPTIOCTL_EVENT_QUERY _IOWR(MPTIOCTL, 5,\ - struct mps_event_query) -#define MPTIOCTL_EVENT_ENABLE _IOWR(MPTIOCTL, 6,\ - struct mps_event_enable) -#define MPTIOCTL_EVENT_REPORT _IOWR(MPTIOCTL, 7,\ - struct mps_event_report) -#define MPTIOCTL_GET_PCI_INFO _IOWR(MPTIOCTL, 8,\ - struct mps_pci_info) -#define MPTIOCTL_DIAG_ACTION _IOWR(MPTIOCTL, 9,\ - struct mps_diag_action) -#define MPTIOCTL_REG_ACCESS _IOWR(MPTIOCTL, 10,\ - struct mps_reg_access) -#define MPTIOCTL_BTDH_MAPPING _IOWR(MPTIOCTL, 11,\ - struct mps_btdh_mapping) - -#endif /* !_MPS_IOCTL_H_ */ diff --git a/usr.sbin/ndp/gnuc.h b/usr.sbin/ndp/gnuc.h deleted file mode 100644 index 5c6b29e3a30..00000000000 --- a/usr.sbin/ndp/gnuc.h +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD: src/usr.sbin/ndp/gnuc.h,v 1.1 2000/01/06 12:40:40 shin Exp $ */ -/* this is dummy to pacify gmt2local.c. */ diff --git a/usr.sbin/ppp/atm.c b/usr.sbin/ppp/atm.c deleted file mode 100644 index 4350eb01ea9..00000000000 --- a/usr.sbin/ppp/atm.c +++ /dev/null @@ -1,237 +0,0 @@ -/*- - * Copyright (c) 2000 Jakob Stoklund Olesen - * 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: stable/11/usr.sbin/ppp/atm.c 134789 2004-09-05 01:46:52Z brian $ - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "layer.h" -#include "defs.h" -#include "mbuf.h" -#include "log.h" -#include "timer.h" -#include "lqr.h" -#include "hdlc.h" -#include "throughput.h" -#include "fsm.h" -#include "lcp.h" -#include "ccp.h" -#include "link.h" -#include "async.h" -#include "descriptor.h" -#include "physical.h" -#include "main.h" -#include "atm.h" - -/* String identifying PPPoA */ -#define PPPOA "PPPoA" -#define PPPOA_LEN (sizeof(PPPOA) - 1) - -struct atmdevice { - struct device dev; /* What struct physical knows about */ -}; - -#define device2atm(d) ((d)->type == ATM_DEVICE ? (struct atmdevice *)d : NULL) - -unsigned -atm_DeviceSize(void) -{ - return sizeof(struct atmdevice); -} - -static ssize_t -atm_Sendto(struct physical *p, const void *v, size_t n) -{ - ssize_t ret = write(p->fd, v, n); - if (ret < 0) { - log_Printf(LogDEBUG, "atm_Sendto(%ld): %s\n", (long)n, strerror(errno)); - return ret; - } - return ret; -} - -static ssize_t -atm_Recvfrom(struct physical *p, void *v, size_t n) -{ - ssize_t ret = read(p->fd, (char*)v, n); - if (ret < 0) { - log_Printf(LogDEBUG, "atm_Recvfrom(%ld): %s\n", (long)n, strerror(errno)); - return ret; - } - return ret; -} - -static void -atm_Free(struct physical *p) -{ - struct atmdevice *dev = device2atm(p->handler); - - free(dev); -} - -static void -atm_device2iov(struct device *d, struct iovec *iov, int *niov, - int maxiov __unused, int *auxfd __unused, int *nauxfd __unused) -{ - int sz = physical_MaxDeviceSize(); - - iov[*niov].iov_base = realloc(d, sz); - if (iov[*niov].iov_base == NULL) { - log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); - AbortProgram(EX_OSERR); - } - iov[*niov].iov_len = sz; - (*niov)++; -} - -static const struct device baseatmdevice = { - ATM_DEVICE, - "atm", - 0, - { CD_NOTREQUIRED, 0 }, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - atm_Free, - atm_Recvfrom, - atm_Sendto, - atm_device2iov, - NULL, - NULL, - NULL -}; - -struct device * -atm_iov2device(int type, struct physical *p, struct iovec *iov, int *niov, - int maxiov __unused, int *auxfd __unused, int *nauxfd __unused) -{ - if (type == ATM_DEVICE) { - struct atmdevice *dev = (struct atmdevice *)iov[(*niov)++].iov_base; - - dev = realloc(dev, sizeof *dev); /* Reduce to the correct size */ - if (dev == NULL) { - log_Printf(LogALERT, "Failed to allocate memory: %d\n", - (int)(sizeof *dev)); - AbortProgram(EX_OSERR); - } - - /* Refresh function pointers etc */ - memcpy(&dev->dev, &baseatmdevice, sizeof dev->dev); - - physical_SetupStack(p, dev->dev.name, PHYSICAL_FORCE_SYNCNOACF); - return &dev->dev; - } - - return NULL; -} - -static struct atmdevice * -atm_CreateDevice(struct physical *p, const char *iface, unsigned vpi, - unsigned vci) -{ - struct atmdevice *dev; - struct sockaddr_natm sock; - - if ((dev = calloc(1, sizeof *dev)) == NULL) { - log_Printf(LogWARN, "%s: Cannot allocate an atm device: %s\n", - p->link.name, strerror(errno)); - return NULL; - } - - sock.snatm_len = sizeof sock; - sock.snatm_family = AF_NATM; - strncpy(sock.snatm_if, iface, IFNAMSIZ); - sock.snatm_vpi = vpi; - sock.snatm_vci = vci; - - log_Printf(LogPHASE, "%s: Connecting to %s:%u.%u\n", p->link.name, - iface, vpi, vci); - - p->fd = socket(PF_NATM, SOCK_DGRAM, PROTO_NATMAAL5); - if (p->fd >= 0) { - log_Printf(LogDEBUG, "%s: Opened atm socket %s\n", p->link.name, - p->name.full); - if (connect(p->fd, (struct sockaddr *)&sock, sizeof sock) == 0) - return dev; - else - log_Printf(LogWARN, "%s: connect: %s\n", p->name.full, strerror(errno)); - } else - log_Printf(LogWARN, "%s: socket: %s\n", p->name.full, strerror(errno)); - - close(p->fd); - p->fd = -1; - free(dev); - - return NULL; -} - -struct device * -atm_Create(struct physical *p) -{ - struct atmdevice *dev; - - dev = NULL; - if (p->fd < 0 && !strncasecmp(p->name.full, PPPOA, PPPOA_LEN) - && p->name.full[PPPOA_LEN] == ':') { - char iface[25]; - unsigned vci, vpi; - - if (sscanf(p->name.full + PPPOA_LEN + 1, "%25[A-Za-z0-9]:%u.%u", iface, - &vpi, &vci) != 3) { - log_Printf(LogWARN, "Malformed ATM device name \'%s\', " - "PPPoA:if:vpi.vci expected\n", p->name.full); - return NULL; - } - - dev = atm_CreateDevice(p, iface, vpi, vci); - } - - if (dev) { - memcpy(&dev->dev, &baseatmdevice, sizeof dev->dev); - physical_SetupStack(p, dev->dev.name, PHYSICAL_FORCE_SYNCNOACF); - if (p->cfg.cd.necessity != CD_DEFAULT) - log_Printf(LogWARN, "Carrier settings ignored\n"); - return &dev->dev; - } - - return NULL; -} diff --git a/usr.sbin/ppp/atm.h b/usr.sbin/ppp/atm.h deleted file mode 100644 index 67710244ac8..00000000000 --- a/usr.sbin/ppp/atm.h +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright (c) 2000 Jakob Stoklund Olesen - * 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: stable/11/usr.sbin/ppp/atm.h 134789 2004-09-05 01:46:52Z brian $ - */ - -struct physical; -struct device; - -extern struct device *atm_Create(struct physical *); -extern struct device *atm_iov2device(int, struct physical *, - struct iovec *, int *, int, int *, int *); -extern unsigned atm_DeviceSize(void); diff --git a/usr.sbin/rtadvd/dump.c b/usr.sbin/rtadvd/dump.c deleted file mode 100644 index 4c67ff884c0..00000000000 --- a/usr.sbin/rtadvd/dump.c +++ /dev/null @@ -1,252 +0,0 @@ -/* $FreeBSD: src/usr.sbin/rtadvd/dump.c,v 1.12 2003/08/15 19:13:53 ume Exp $ */ -/* $KAME: dump.c,v 1.32 2003/05/19 09:46:50 keiichi Exp $ */ - -/* - * Copyright (C) 2000 WIDE 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. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 PROJECT 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 -#include -#include - -#include -#include -#include - -#include - -/* XXX: the following two are non-standard include files */ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include "rtadvd.h" -#include "timer.h" -#include "if.h" -#include "dump.h" - -static FILE *fp; - -extern struct rainfo *ralist; - -static char *ether_str __P((struct sockaddr_dl *)); -static void if_dump __P((void)); - -static char *rtpref_str[] = { - "medium", /* 00 */ - "high", /* 01 */ - "rsv", /* 10 */ - "low" /* 11 */ -}; - -static char * -ether_str(sdl) - struct sockaddr_dl *sdl; -{ - static char hbuf[32]; - u_char *cp; - - if (sdl->sdl_alen && sdl->sdl_alen > 5) { - cp = (u_char *)LLADDR(sdl); - snprintf(hbuf, sizeof(hbuf), "%x:%x:%x:%x:%x:%x", - cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]); - } else - snprintf(hbuf, sizeof(hbuf), "NONE"); - - return(hbuf); -} - -static void -if_dump() -{ - struct rainfo *rai; - struct prefix *pfx; -#ifdef ROUTEINFO - struct rtinfo *rti; -#endif - char prefixbuf[INET6_ADDRSTRLEN]; - int first; - struct timeval now; - - gettimeofday(&now, NULL); /* XXX: unused in most cases */ - for (rai = ralist; rai; rai = rai->next) { - fprintf(fp, "%s:\n", rai->ifname); - - fprintf(fp, " Status: %s\n", - (iflist[rai->ifindex]->ifm_flags & IFF_UP) ? "UP" : - "DOWN"); - - /* control information */ - if (rai->lastsent.tv_sec) { - /* note that ctime() appends CR by itself */ - fprintf(fp, " Last RA sent: %s", - ctime((time_t *)&rai->lastsent.tv_sec)); - } - if (rai->timer) { - fprintf(fp, " Next RA will be sent: %s", - ctime((time_t *)&rai->timer->tm.tv_sec)); - } - else - fprintf(fp, " RA timer is stopped"); - fprintf(fp, " waits: %d, initcount: %d\n", - rai->waiting, rai->initcounter); - - /* statistics */ - fprintf(fp, " statistics: RA(out/in/inconsistent): " - "%llu/%llu/%llu, ", - (unsigned long long)rai->raoutput, - (unsigned long long)rai->rainput, - (unsigned long long)rai->rainconsistent); - fprintf(fp, "RS(input): %llu\n", - (unsigned long long)rai->rsinput); - - /* interface information */ - if (rai->advlinkopt) - fprintf(fp, " Link-layer address: %s\n", - ether_str(rai->sdl)); - fprintf(fp, " MTU: %d\n", rai->phymtu); - - /* Router configuration variables */ - fprintf(fp, " DefaultLifetime: %d, MaxAdvInterval: %d, " - "MinAdvInterval: %d\n", rai->lifetime, rai->maxinterval, - rai->mininterval); - fprintf(fp, " Flags: %s%s%s, ", - rai->managedflg ? "M" : "", rai->otherflg ? "O" : "", ""); - fprintf(fp, "Preference: %s, ", - rtpref_str[(rai->rtpref >> 3) & 0xff]); - fprintf(fp, "MTU: %d\n", rai->linkmtu); - fprintf(fp, " ReachableTime: %d, RetransTimer: %d, " - "CurHopLimit: %d\n", rai->reachabletime, - rai->retranstimer, rai->hoplimit); - if (rai->clockskew) - fprintf(fp, " Clock skew: %ldsec\n", - rai->clockskew); - for (first = 1, pfx = rai->prefix.next; pfx != &rai->prefix; - pfx = pfx->next) { - if (first) { - fprintf(fp, " Prefixes:\n"); - first = 0; - } - fprintf(fp, " %s/%d(", - inet_ntop(AF_INET6, &pfx->prefix, prefixbuf, - sizeof(prefixbuf)), pfx->prefixlen); - switch (pfx->origin) { - case PREFIX_FROM_KERNEL: - fprintf(fp, "KERNEL, "); - break; - case PREFIX_FROM_CONFIG: - fprintf(fp, "CONFIG, "); - break; - case PREFIX_FROM_DYNAMIC: - fprintf(fp, "DYNAMIC, "); - break; - } - if (pfx->validlifetime == ND6_INFINITE_LIFETIME) - fprintf(fp, "vltime: infinity"); - else - fprintf(fp, "vltime: %ld", - (long)pfx->validlifetime); - if (pfx->vltimeexpire != 0) - fprintf(fp, "(decr,expire %ld), ", (long) - pfx->vltimeexpire > now.tv_sec ? - pfx->vltimeexpire - now.tv_sec : 0); - else - fprintf(fp, ", "); - if (pfx->preflifetime == ND6_INFINITE_LIFETIME) - fprintf(fp, "pltime: infinity"); - else - fprintf(fp, "pltime: %ld", - (long)pfx->preflifetime); - if (pfx->pltimeexpire != 0) - fprintf(fp, "(decr,expire %ld), ", (long) - pfx->pltimeexpire > now.tv_sec ? - pfx->pltimeexpire - now.tv_sec : 0); - else - fprintf(fp, ", "); - fprintf(fp, "flags: %s%s%s", - pfx->onlinkflg ? "L" : "", - pfx->autoconfflg ? "A" : "", - ""); - if (pfx->timer) { - struct timeval *rest; - - rest = rtadvd_timer_rest(pfx->timer); - if (rest) { /* XXX: what if not? */ - fprintf(fp, ", expire in: %ld", - (long)rest->tv_sec); - } - } - fprintf(fp, ")\n"); - } -#ifdef ROUTEINFO - for (first = 1, rti = rai->route.next; rti != &rai->route; - rti = rti->next) { - if (first) { - fprintf(fp, " Route Information:\n"); - first = 0; - } - fprintf(fp, " %s/%d (", - inet_ntop(AF_INET6, &rti->prefix, - prefixbuf, sizeof(prefixbuf)), - rti->prefixlen); - fprintf(fp, "preference: %s, ", - rtpref_str[0xff & (rti->rtpref >> 3)]); - if (rti->ltime == ND6_INFINITE_LIFETIME) - fprintf(fp, "lifetime: infinity"); - else - fprintf(fp, "lifetime: %ld", (long)rti->ltime); - fprintf(fp, ")\n"); - } -#endif - } -} - -void -rtadvd_dump_file(dumpfile) - char *dumpfile; -{ - syslog(LOG_DEBUG, "<%s> dump current status to %s", __func__, - dumpfile); - - if ((fp = fopen(dumpfile, "w")) == NULL) { - syslog(LOG_WARNING, "<%s> open a dump file(%s)", - __func__, dumpfile); - return; - } - - if_dump(); - - fclose(fp); -} diff --git a/usr.sbin/rtadvd/dump.h b/usr.sbin/rtadvd/dump.h deleted file mode 100644 index 8defe604199..00000000000 --- a/usr.sbin/rtadvd/dump.h +++ /dev/null @@ -1,33 +0,0 @@ -/* $FreeBSD: src/usr.sbin/rtadvd/dump.h,v 1.3 2001/06/11 12:39:22 ume Exp $ */ -/* $KAME: dump.h,v 1.1 2000/05/23 11:31:26 itojun Exp $ */ - -/* - * Copyright (C) 1998 WIDE 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. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 PROJECT 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. - */ - -extern void rtadvd_dump_file __P((char *)); diff --git a/usr.sbin/rtsold/probe.c b/usr.sbin/rtsold/probe.c deleted file mode 100644 index 1144fd6722e..00000000000 --- a/usr.sbin/rtsold/probe.c +++ /dev/null @@ -1,189 +0,0 @@ -/* $KAME: probe.c,v 1.17 2003/10/05 00:09:36 itojun Exp $ */ - -/* - * Copyright (C) 1998 WIDE 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. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 PROJECT 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: stable/11/usr.sbin/rtsold/probe.c 331722 2018-03-29 02:50:57Z eadler $ - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include "rtsold.h" - -static struct msghdr sndmhdr; -static struct iovec sndiov[2]; -static int probesock; -static void sendprobe(struct in6_addr *, struct ifinfo *); - -int -probe_init(void) -{ - int scmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + - CMSG_SPACE(sizeof(int)); - static u_char *sndcmsgbuf = NULL; - - if (sndcmsgbuf == NULL && - (sndcmsgbuf = (u_char *)malloc(scmsglen)) == NULL) { - warnmsg(LOG_ERR, __func__, "malloc failed"); - return (-1); - } - - if ((probesock = socket(AF_INET6, SOCK_RAW, IPPROTO_NONE)) < 0) { - warnmsg(LOG_ERR, __func__, "socket: %s", strerror(errno)); - return (-1); - } - - /* initialize msghdr for sending packets */ - sndmhdr.msg_namelen = sizeof(struct sockaddr_in6); - sndmhdr.msg_iov = sndiov; - sndmhdr.msg_iovlen = 1; - sndmhdr.msg_control = (caddr_t)sndcmsgbuf; - sndmhdr.msg_controllen = scmsglen; - - return (0); -} - -/* - * Probe if each router in the default router list is still alive. - */ -void -defrouter_probe(struct ifinfo *ifinfo) -{ - struct in6_defrouter *p, *ep; - int ifindex, mib[4]; - char *buf, ntopbuf[INET6_ADDRSTRLEN]; - size_t l; - - ifindex = ifinfo->sdl->sdl_index; - if (ifindex == 0) - return; - mib[0] = CTL_NET; - mib[1] = PF_INET6; - mib[2] = IPPROTO_ICMPV6; - mib[3] = ICMPV6CTL_ND6_DRLIST; - if (sysctl(mib, nitems(mib), NULL, &l, NULL, 0) < 0) { - warnmsg(LOG_ERR, __func__, "sysctl(ICMPV6CTL_ND6_DRLIST): %s", - strerror(errno)); - return; - } - if (l == 0) - return; - buf = malloc(l); - if (buf == NULL) { - warnmsg(LOG_ERR, __func__, "malloc(): %s", strerror(errno)); - return; - } - if (sysctl(mib, nitems(mib), buf, &l, NULL, 0) < 0) { - warnmsg(LOG_ERR, __func__, "sysctl(ICMPV6CTL_ND6_DRLIST): %s", - strerror(errno)); - free(buf); - return; - } - ep = (struct in6_defrouter *)(void *)(buf + l); - for (p = (struct in6_defrouter *)(void *)buf; p < ep; p++) { - if (ifindex != p->if_index) - continue; - if (!IN6_IS_ADDR_LINKLOCAL(&p->rtaddr.sin6_addr)) { - warnmsg(LOG_ERR, __func__, - "default router list contains a " - "non-link-local address(%s)", - inet_ntop(AF_INET6, &p->rtaddr.sin6_addr, ntopbuf, - INET6_ADDRSTRLEN)); - continue; /* ignore the address */ - } - sendprobe(&p->rtaddr.sin6_addr, ifinfo); - } - free(buf); -} - -static void -sendprobe(struct in6_addr *addr, struct ifinfo *ifinfo) -{ - u_char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; - struct sockaddr_in6 sa6_probe; - struct in6_pktinfo *pi; - struct cmsghdr *cm; - u_int32_t ifindex = ifinfo->sdl->sdl_index; - int hoplimit = 1; - - memset(&sa6_probe, 0, sizeof(sa6_probe)); - sa6_probe.sin6_family = AF_INET6; - sa6_probe.sin6_len = sizeof(sa6_probe); - sa6_probe.sin6_addr = *addr; - sa6_probe.sin6_scope_id = ifinfo->linkid; - - sndmhdr.msg_name = (caddr_t)&sa6_probe; - sndmhdr.msg_iov[0].iov_base = NULL; - sndmhdr.msg_iov[0].iov_len = 0; - - cm = CMSG_FIRSTHDR(&sndmhdr); - /* specify the outgoing interface */ - cm->cmsg_level = IPPROTO_IPV6; - cm->cmsg_type = IPV6_PKTINFO; - cm->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); - pi = (struct in6_pktinfo *)(void *)CMSG_DATA(cm); - memset(&pi->ipi6_addr, 0, sizeof(pi->ipi6_addr)); /*XXX*/ - pi->ipi6_ifindex = ifindex; - - /* specify the hop limit of the packet for safety */ - cm = CMSG_NXTHDR(&sndmhdr, cm); - cm->cmsg_level = IPPROTO_IPV6; - cm->cmsg_type = IPV6_HOPLIMIT; - cm->cmsg_len = CMSG_LEN(sizeof(int)); - memcpy(CMSG_DATA(cm), &hoplimit, sizeof(int)); - - warnmsg(LOG_DEBUG, __func__, "probe a router %s on %s", - inet_ntop(AF_INET6, addr, ntopbuf, INET6_ADDRSTRLEN), - if_indextoname(ifindex, ifnamebuf)); - - if (sendmsg(probesock, &sndmhdr, 0)) - warnmsg(LOG_ERR, __func__, "sendmsg on %s: %s", - if_indextoname(ifindex, ifnamebuf), strerror(errno)); -} diff --git a/usr.sbin/sa/tests/v1-sparc64-sav.in b/usr.sbin/sa/tests/v1-sparc64-sav.in deleted file mode 100644 index d6911cf946bdca91215593b8d83d94c8a4e5342d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI3zityj5XSd{jRjH!5e4{Paz#Wzh53^}!5dIegyeG}w)|I={3p*@vTS zR$LHWZB?lCIi$35O_e8>_9qzEQR{{LDAbcq#$)LS)mTtF(42j>_tc)*wc(tFy-9tu z@hj(0d1#_a&wW?_UBso9rtgUx9Uf(miVI?^EoAgqRT5|F0mCvgk&s?lRCPcGCkz>o zm4}zs3dZRfkaSqz>X78b4M(Hn!)dsh z)zvB1myt^r{6Fjx(UC))xWSXB&z|q>zIgdKjO^U5)H#%3OYr^itI{pJX+P~> diff --git a/usr.sbin/sa/tests/v1-sparc64-usr.out b/usr.sbin/sa/tests/v1-sparc64-usr.out deleted file mode 100644 index 87b9af33847..00000000000 --- a/usr.sbin/sa/tests/v1-sparc64-usr.out +++ /dev/null @@ -1 +0,0 @@ -root 28 0.66cpu 4508tio 9971k*sec diff --git a/usr.sbin/sa/tests/v2-sparc64-sav.in b/usr.sbin/sa/tests/v2-sparc64-sav.in deleted file mode 100644 index b6d836a59e06d190484074b5fe4e6f00b984ff60..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI3zfV*_5XX1wD=awf9Y{Qm<44qj#M4lm z9X3=JHdNY>SXfw)*!w5YpjO0CY3t4|`*`o&f~_Xs&F#$2eCOTVes*)s12*}*Bczuiyd|?gZFaSBdYp0oP9>Bo-tGD zdd2?Db5l!0=|{Lnhn}IBov%ea)4Dg3svZ?~w4^TB^H7uDyGh41rw#k<2X=92ljl;I zTdvfNNtJj5sn*^WSy5{f`#ajx&-I3Of))aHg034Eo5Vef=4WSl#@g`~%!|Ixgk@`!$=b$=w)`MqhD zT)Wu6Kh0@D#-@xtm$DwI^l^byh4I~_NMF|*9MjVcc7o0s7aKkoyN}YdC;Al&CoJ?8 z>)K{r74L1bkDDxIj)O%z>^@2>r4^Ss(M$TZH=V4ATWr{qzj2UM^_Q3q`MQUqR4%VB z)~rp}c%qgI7WawBQ*Qh4CPOiD`O4_kv1`TgVY|x4-pBQqpu1aHotEm^l!@(KJEPYv UJu@x6kL#p#o5~i@Og3ZVKa5_rU;qFB diff --git a/usr.sbin/sa/tests/v2-sparc64-u.out b/usr.sbin/sa/tests/v2-sparc64-u.out deleted file mode 100644 index c4c04f9b7cb..00000000000 --- a/usr.sbin/sa/tests/v2-sparc64-u.out +++ /dev/null @@ -1,36 +0,0 @@ - 0 0.019 cpu 163k mem 0 io accton - 0 1.644 cpu 272k mem 0 io awk - 0 0.029 cpu 175k mem 0 io time - 0 0.019 cpu 163k mem 0 io sleep - 0 0.032 cpu 214k mem 35 io fsck_ufs - 0 0.028 cpu 213k mem 10 io fsck_ufs - 0 0.028 cpu 189k mem 8 io fsck_ufs - 0 0.028 cpu 196k mem 7 io fsck_ufs - 0 0.055 cpu 168k mem 0 io fsck - 0 0.008 cpu 204k mem 0 io sh* - 0 0.023 cpu 179k mem 0 io logger - 0 26.715 cpu 233k mem 25 io egrep - 0 0.029 cpu 162k mem 0 io time - 0 5.703 cpu 184k mem 4444 io find - 0 0.029 cpu 166k mem 0 io time - 0 0.018 cpu 136k mem 0 io sleep - 0 0.028 cpu 157k mem 0 io time - 0 0.588 cpu 160k mem 16 io dd - 0 0.027 cpu 162k mem 0 io time - 0 1.636 cpu 193k mem 0 io diff - 0 0.029 cpu 172k mem 0 io time - 0 0.020 cpu 170k mem 0 io ln - 0 0.018 cpu 135k mem 0 io 123456789012345 - 0 0.029 cpu 167k mem 0 io time - 0 0.019 cpu 163k mem 0 io ln - 0 0.017 cpu 135k mem 0 io 1234567890123456 - 0 0.029 cpu 157k mem 0 io time - 0 0.019 cpu 163k mem 0 io ln - 0 0.017 cpu 135k mem 0 io 1234567890123456 - 0 0.029 cpu 162k mem 0 io time - 0 0.105 cpu 3358k mem 2 io cc1 - 0 0.030 cpu 996k mem 1 io as - 0 0.186 cpu 1114k mem 11 io ld - 0 0.033 cpu 386k mem 6 io cc - 0 0.037 cpu 158k mem 12 io core - 0 0.010 cpu 129k mem 7 io core* diff --git a/usr.sbin/sa/tests/v2-sparc64-usr.in b/usr.sbin/sa/tests/v2-sparc64-usr.in deleted file mode 100644 index 01a1bdc04333beb451c0ba31d8a32d50164dec0f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI%Jqp4=5C+ikukZ#ILUIJXK~h-QL{QM)TUhBqYy)XMfDo|pSZ)x4SlbA1VEJaJ z8eTgwSso)|6p^RsEAKlE0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAn*?Y zgO4SLG0U2)&6-*fAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0zVf>H~MLM u-Q`c-S@lZ<@sLaX<8nhWt*~ioGvM%xLv!5wB-xu)@kzq