Compare commits

..
Author SHA1 Message Date
cvs2svn 148a348454 This commit was manufactured by cvs2svn to create tag
'RELENG_4_6_0_RELEASE'.
2002-07-03 13:01:43 +00:00
cvs2svn db0a3b0996 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-07-03 13:01:42 +00:00
cvs2svn b8fd368d37 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-07-01 01:08:03 +00:00
Jacques Vidrine 4ffec030cc MFC: oflow fixes. 2002-06-26 08:44:24 +00:00
Warner Losh b6b197f3ec MFC: oflow fixes. 2002-06-26 08:36:02 +00:00
Bruce A. Mah 94bc73d703 Note the 4.6 release date.
Approved by:	re (implicitly)
2002-06-16 00:26:45 +00:00
John Baldwin 8b16a3e13f MFS: Don't build a 'de' module which doesn't exist.
Approved by:	re (murray)
2002-06-15 02:12:32 +00:00
John Baldwin 0530043136 MFS: Revert previous revision. 2002-06-14 18:57:19 +00:00
John Baldwin 23f4913235 MFS: Actually dike txp(4) out of the floppy kernel. 2002-06-14 18:44:05 +00:00
Murray Stokely 1972241807 MFC: Fix Alpha overflow woes.
Approved by:   re (murray)
2002-06-14 18:09:24 +00:00
David E. O'Brien 77897c7469 MFC: make room for new home of XF86Config.
Approved by:	murray
2002-06-10 15:34:22 +00:00
David E. O'Brien 1c9e602cfc MFRELENG4: /etc/XF86Config -> /etc/X11/XF86Config 2002-06-10 04:39:51 +00:00
Udo Erdelhoff db7425715e MFen 1.1.2.5.2.2: drop pointer to freebsd-stable, use 4.6-RELEASE manpages
Approved by: re@
2002-06-08 08:54:50 +00:00
Bruce A. Mah c5da444134 Add a note for an ata(4) MFC, which required remaking device nodes.
Suggested by:	Larry Rosenman <[email protected]>
Approved by:	re (bmah)
2002-06-08 05:37:00 +00:00
David E. O'Brien bc3f1177e9 MFC: rev 1.51.2.13 (reduce windows size to 57k).
Requested by:	murray
2002-06-07 20:54:02 +00:00
Udo Erdelhoff ccb3cc5657 MFen: Update release documentation entities for 4.6-RELEASE 2002-06-07 15:45:12 +00:00
Bruce A. Mah 5ce1ad7a0c standard-supfile should track its own branch.
Approved by:	re (implicitly)
2002-06-06 22:11:58 +00:00
Bruce A. Mah cea81f798b Update manual page hyperlinks to use 4.6-RELEASE manpages.
Approved by:	re (implicitly)
2002-06-06 17:16:10 +00:00
Bruce A. Mah e386cb2e50 Remove footer reference to freebsd-stable@ from the 4.6-RELEASE release
documentation.

Approved by:	re (implicitly)
2002-06-06 17:14:10 +00:00
Bruce A. Mah 0c4ed717bc Update for 4.6-RELEASE release documentation snapshot area.
Approved by:	re (implicitly)
2002-06-06 16:41:28 +00:00
Bruce A. Mah 42a7770592 Update release documentation entities for 4.6-RELEASE.
Approved by:	re (implicitly)
2002-06-06 16:39:34 +00:00
Sheldon Hearn b7c917e9fa MFC rev 1.3: correct release of first mention in HISTORY section
Approved by:	re
2002-06-06 10:55:28 +00:00
Murray Stokely 806fe6d23c Update for FreeBSD 4.6.
Approved by:	re (implicit)
2002-06-06 10:25:57 +00:00
Murray Stokely fc9e8f4340 Update for 4.6-RELEASE.
Approved by:	re (implicit)
2002-06-06 10:23:25 +00:00
Murray Stokely 7fde5307de Update the default version number for manual pages.
Approved by:	re (implicit)
2002-06-06 10:20:07 +00:00
Murray Stokely 87e637e2df Update BASE for 4.6.
Approved by:	re (implicit)
2002-06-06 10:14:09 +00:00
cvs2svn 43b09ad426 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-06-02 16:35:30 +00:00
cvs2svn 0bc95402c8 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-05-20 18:51:00 +00:00
cvs2svn 212d3e48d9 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-05-18 16:50:10 +00:00
cvs2svn 99b47403d8 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-05-16 17:21:02 +00:00
cvs2svn 2a92ef7ded This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-05-15 16:06:27 +00:00
cvs2svn 4a08d5ba45 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-05-15 16:03:59 +00:00
cvs2svn e8e9a92bbd This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-05-01 04:11:31 +00:00
cvs2svn 775326df3d This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-04-23 20:35:10 +00:00
cvs2svn d6ff0fd311 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-04-15 12:52:30 +00:00
cvs2svn ad65ee2a34 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-04-08 11:22:24 +00:00
cvs2svn d155565e32 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-04-07 09:54:13 +00:00
cvs2svn 4804a5ef45 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-03-25 21:26:24 +00:00
cvs2svn 9851eed6f3 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-03-12 21:27:06 +00:00
cvs2svn eeaeb5b79a This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-03-12 21:27:05 +00:00
cvs2svn c52ce4bcc2 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-03-10 07:23:29 +00:00
cvs2svn 151e79b844 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-02-25 10:54:08 +00:00
cvs2svn 21eca5f815 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-01-28 17:48:44 +00:00
cvs2svn 5205c1aaa2 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-01-26 15:12:09 +00:00
cvs2svn 1ed30f6426 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2002-01-18 16:42:29 +00:00
cvs2svn 0a379c9386 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2001-11-01 12:33:13 +00:00
cvs2svn 5ebecde547 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2001-10-24 19:14:52 +00:00
cvs2svn e4de098331 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2001-09-28 17:50:17 +00:00
cvs2svn 423c6ff15d This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2001-07-26 22:30:18 +00:00
cvs2svn 26859bad80 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2001-03-05 10:47:12 +00:00
cvs2svn b7a5a03069 This commit was manufactured by cvs2svn to create branch 'RELENG_4_6'. 2000-07-19 06:22:02 +00:00
9986 changed files with 538632 additions and 1577074 deletions

No files matched your search

-26
View File
@@ -1,32 +1,6 @@
# $FreeBSD$
# @(#)COPYRIGHT 8.2 (Berkeley) 3/21/94
The compilation of software known as FreeBSD is distributed under the
following terms:
Copyright (C) 1992-2007 The FreeBSD Project. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY 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.
All of the documentation and software included in the 4.4BSD and 4.4BSD-Lite
Releases is copyrighted by The Regents of the University of California.
+13 -43
View File
@@ -30,7 +30,9 @@
# tree. This makefile executes a child make process, forcing it to use
# the mk files from the source tree which are supposed to DTRT.
#
# The user-driven targets (as listed above) are implemented in Makefile.inc1.
# The user-driven targets (as listed above) are implemented in Makefile.inc0
# and the private targets are in Makefile.inc1. These are kept separate
# to help the bootstrap build from aout to elf format.
#
# If you want to build your system from source be sure that /usr/obj has
# at least 400MB of diskspace available.
@@ -63,11 +65,6 @@
# release of 4.0. You have exactly one major release to move entirely
# to elf.
#
# If TARGET_ARCH=arch (e.g. alpha) is specified you can
# cross build world for other architectures using the buildworld target,
# and once the world is built you can cross build a kernel using the
# buildkernel target.
#
# ----------------------------------------------------------------------------
#
# Upgrading an i386 system from a.out to elf format
@@ -96,20 +93,11 @@
# Define the user-driven targets. These are listed here in alphabetical
# order, but that's not important.
#
TGTS= all all-man buildkernel buildworld checkdpadd clean \
cleandepend cleandir depend distribute distributeworld everything \
hierarchy install installcheck installkernel \
reinstallkernel installmost installworld libraries lint maninstall \
mk most obj objlink regress rerelease tags update
BITGTS= files includes
BITGTS:=${BITGTS} ${BITGTS:S/^/build/} ${BITGTS:S/^/install/}
.ORDER: buildworld installworld
.ORDER: buildworld distributeworld
.ORDER: buildworld buildkernel
.ORDER: buildkernel installkernel
.ORDER: buildkernel reinstallkernel
TGTS= afterdistribute all all-man buildkernel buildworld checkdpadd clean \
cleandepend cleandir depend distribute everything hierarchy includes \
install installcheck installkernel installmost installworld kernel \
libraries lint maninstall mk most obj objlink regress \
reinstallkernel rerelease tags update
PATH= /sbin:/bin:/usr/sbin:/usr/bin
MAKE= PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
@@ -117,7 +105,7 @@ MAKE= PATH=${PATH} make -m ${.CURDIR}/share/mk -f Makefile.inc1
#
# Handle the user-driven targets, using the source relative mk files.
#
${TGTS} ${BITGTS}: upgrade_checks
${TGTS}: upgrade_checks
@cd ${.CURDIR}; \
${MAKE} ${.TARGET}
@@ -156,13 +144,6 @@ world: upgrade_checks
@printf ">>> ${OBJFORMAT} make world completed on `LC_ALL=C date`\n (started ${STARTTIME})\n"
@echo "--------------------------------------------------------------"
#
# kernel
#
# Short hand for `make buildkernel installkernel'
#
kernel: buildkernel installkernel
#
# Perform a few tests to determine if the installed tools are adequate
# for building the world. These are for older systems (prior to 2.2.5).
@@ -173,26 +154,15 @@ kernel: buildkernel installkernel
#
upgrade_checks:
@cd ${.CURDIR}; \
if ! make -m ${.CURDIR}/share/mk -Dnotdef test >/dev/null 2>&1; then \
make make; \
fi
@cd ${.CURDIR}; \
if make -V .CURDIR:C/.// 2>&1 >/dev/null | \
grep -q "Unknown modifier 'C'"; then \
make make; \
fi
if ! make -m ${.CURDIR}/share/mk test > /dev/null 2>&1; then \
make make; \
fi
#
# A simple test target used as part of the test to see if make supports
# the -m argument. Also test that make will only evaluate a conditional
# as far as is necessary to determine its value.
# the -m argument.
#
test:
.if defined(notdef)
.undef notdef
.if defined(notdef) && ${notdef:U}
.endif
.endif
#
# Upgrade the installed make to the current version using the installed
+230 -210
View File
@@ -7,8 +7,8 @@
# -DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
# -DNOCLEAN do not clean at all
# -DNOCRYPT will prevent building of crypt versions
# -DNOMAN do not build the manual pages
# -DNOPROFILE do not build profiled libraries
# -DNOSECURE do not go into secure subdir
# -DNOGAMES do not go into games subdir
# -DNOSHARE do not go into share subdir
# -DNOINFO do not make or install info files
@@ -76,9 +76,6 @@ SUBDIR+= libexec
.if exists(${.CURDIR}/sbin)
SUBDIR+= sbin
.endif
.if exists(${.CURDIR}/secure) && !defined(NOCRYPT)
SUBDIR+= secure
.endif
.if exists(${.CURDIR}/share) && !defined(NOSHARE)
SUBDIR+= share
.endif
@@ -91,6 +88,9 @@ SUBDIR+= usr.bin
.if exists(${.CURDIR}/usr.sbin)
SUBDIR+= usr.sbin
.endif
.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
SUBDIR+= secure
.endif
# etc must be last for "distribute" to work
.if exists(${.CURDIR}/etc)
@@ -107,10 +107,6 @@ SUBDIR+= ${_DIR}
.endfor
.endif
.if defined(SUBDIR_OVERRIDE)
SUBDIR= ${SUBDIR_OVERRIDE}
.endif
.if defined(NOCLEANDIR)
CLEANDIR= clean cleandepend
.else
@@ -125,21 +121,17 @@ SUPFLAGS+= -h ${SUPHOST}
MAKEOBJDIRPREFIX?= /usr/obj
TARGET_ARCH?= ${MACHINE_ARCH}
.if ${TARGET_ARCH} == ${MACHINE_ARCH}
TARGET?= ${MACHINE}
.else
TARGET?= ${TARGET_ARCH}
.endif
.if make(buildworld)
BUILD_ARCH!= sysctl -n hw.machine_arch
.if ${MACHINE_ARCH} != ${BUILD_ARCH}
.error To cross-build, set TARGET_ARCH.
.endif
.endif
.if ${MACHINE} == ${TARGET}
.if ${MACHINE_ARCH} == ${TARGET_ARCH}
OBJTREE= ${MAKEOBJDIRPREFIX}
.else
OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET_ARCH}
.endif
WORLDTMP= ${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
# /usr/games added for fortune which depend on strfile
@@ -177,21 +169,17 @@ CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
MACHINE_ARCH=${TARGET_ARCH} \
MACHINE=${TARGET} \
OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
PERL5LIB=${WORLDTMP}/usr/libdata/perl/5.00503 \
GROFF_BIN_PATH=${WORLDTMP}/usr/bin \
GROFF_FONT_PATH=${WORLDTMP}/usr/share/groff_font \
GROFF_TMAC_PATH=${WORLDTMP}/usr/share/tmac
.if !defined(NOPERL)
CROSSENV+= PERL5LIB=${WORLDTMP}/usr/libdata/perl/5.00503
.endif
# bootstrap-tool stage
BMAKEENV= MAKEOBJDIRPREFIX=${WORLDTMP} \
DESTDIR= \
INSTALL="sh ${.CURDIR}/tools/install.sh"
BMAKE= ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING \
-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED \
-DNO_WERROR
-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
# build-tool stage
TMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE} \
@@ -237,8 +225,8 @@ USRDIRS= usr/bin usr/lib/compat/aout usr/games usr/libdata/ldscripts \
usr/share/groff_font/devutf8 \
usr/share/tmac/mdoc usr/share/tmac/mm
INCDIRS= arpa dev fs g++/std isc isofs libmilter objc openssl \
protocols readline rpc rpcsvc security ufs
INCDIRS= arpa g++/std isc objc protocols readline rpc rpcsvc openssl \
security ss
#
# buildworld
@@ -246,17 +234,13 @@ INCDIRS= arpa dev fs g++/std isc isofs libmilter objc openssl \
# Attempt to rebuild the entire system, with reasonable chance of
# success, regardless of how old your existing system is.
#
_worldtmp:
buildworld:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> Rebuilding the temporary build tree"
@echo "--------------------------------------------------------------"
.if !defined(NOCLEAN)
rm -rf ${WORLDTMP}
.else
# XXX - These two can depend on any header file.
rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c
rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c
.endif
.for _dir in ${USRDIRS}
mkdir -p ${WORLDTMP}/${_dir}
@@ -265,13 +249,11 @@ _worldtmp:
mkdir -p ${WORLDTMP}/usr/include/${_dir}
.endfor
ln -sf ${.CURDIR}/sys ${WORLDTMP}
_bootstrap-tools:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 1: bootstrap tools"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${BMAKE} bootstrap-tools
_cleanobj:
.if !defined(NOCLEAN)
@echo
@echo "--------------------------------------------------------------"
@@ -279,106 +261,78 @@ _cleanobj:
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
.endif
_obj:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 2: rebuilding the object tree"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} par-obj
_build-tools:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 2: build tools"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${TMAKE} build-tools
_cross-tools:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 3: cross tools"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${XMAKE} cross-tools
_includes:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 4: populating ${WORLDTMP}/usr/include"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes
_libraries:
cd ${.CURDIR}; ${WMAKE} SHARED=copies includes
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 4: building libraries"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries
_depend:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 4: make dependencies"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} par-depend
everything:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 4: building everything.."
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} all
WMAKE_TGTS=
.if !defined(SUBDIR_OVERRIDE)
WMAKE_TGTS+= _worldtmp _bootstrap-tools
.endif
WMAKE_TGTS+= _cleanobj _obj _build-tools
.if !defined(SUBDIR_OVERRIDE)
WMAKE_TGTS+= _cross-tools
.endif
WMAKE_TGTS+= _includes _libraries _depend everything
buildworld: ${WMAKE_TGTS}
.ORDER: ${WMAKE_TGTS}
everything:
@echo "--------------------------------------------------------------"
@echo ">>> Building everything.."
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${WMAKE} all
#
# installcheck
#
# Checks to be sure system is ready for installworld
#
CHECK_UIDS=
CHECK_GIDS=
.if !defined(NO_SENDMAIL)
CHECK_UIDS+= smmsp
CHECK_GIDS+= smmsp
.endif
installcheck:
.for uid in ${CHECK_UIDS}
@if ! `id -u ${uid} >/dev/null 2>&1`; then \
echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \
.if !defined(NO_SENDMAIL)
@if ! `grep -q '^smmsp:' /etc/passwd`; then \
echo "ERROR: Required smmsp user is missing, see /usr/src/UPDATING."; \
false; \
fi
.endfor
.for gid in ${CHECK_GIDS}
@if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \
echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \
@if ! `grep -q '^smmsp:' /etc/group`; then \
echo "ERROR: Required smmsp group is missing, see /usr/src/UPDATING."; \
false; \
fi
.endfor
.endif
#
# distributeworld
#
# Distributes everything compiled by a `buildworld'.
#
# installworld
#
# Installs everything compiled by a 'buildworld'.
#
distributeworld installworld: installcheck
installworld: installcheck
mkdir -p ${INSTALLTMP}
for prog in [ awk cap_mkdb cat chflags chmod chown \
date echo egrep find grep \
ln make makewhatis mkdir mtree mv pwd_mkdb rm sed sh sysctl \
for prog in [ awk cat chflags chmod chown date echo egrep find grep \
ln make makewhatis mtree mv perl rm sed sh sysctl \
test true uname wc zic; do \
cp `which $$prog` ${INSTALLTMP}; \
done
cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
cd ${.CURDIR}; ${IMAKE} reinstall
rm -rf ${INSTALLTMP}
#
@@ -398,7 +352,7 @@ reinstall:
@echo ">>> Installing everything.."
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install
.if !defined(NOMAN) && !defined(NO_MAKEDB_RUN)
.if !defined(NOMAN)
@echo
@echo "--------------------------------------------------------------"
@echo ">>> Rebuilding man page indices"
@@ -406,11 +360,14 @@ reinstall:
cd ${.CURDIR}/share/man; ${MAKE} makedb
.endif
redistribute:
@echo "--------------------------------------------------------------"
@echo ">>> Distributing everything.."
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute
#
# distribworld
#
# Front-end to distribute to make sure the search path contains
# the object directory. Needed for miniperl.
#
distribworld:
cd ${.CURDIR}; PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 distribute
#
# buildkernel and installkernel
@@ -434,15 +391,21 @@ KERNCONF?= GENERIC
.endif
INSTKERNNAME?= kernel
# The only exotic TARGET_ARCH/TARGET combination valid at this
# time is i386/pc98. In all other cases set TARGET equal to
# TARGET_ARCH.
.if ${TARGET_ARCH} != "i386" || ${TARGET} != "pc98"
TARGET= ${TARGET_ARCH}
.endif
KRNLSRCDIR= ${.CURDIR}/sys
KRNLCONFDIR= ${KRNLSRCDIR}/${TARGET}/conf
KRNLOBJDIR= ${OBJTREE}${KRNLSRCDIR}
KERNCONFDIR?= ${KRNLCONFDIR}
BUILDKERNELS=
INSTALLKERNEL=
.for _kernel in ${KERNCONF}
.if exists(${KERNCONFDIR}/${_kernel})
.if exists(${KRNLCONFDIR}/${_kernel})
BUILDKERNELS+= ${_kernel}
.if empty(INSTALLKERNEL)
INSTALLKERNEL= ${_kernel}
@@ -476,20 +439,20 @@ buildkernel:
.if !defined(NO_KERNELCONFIG)
cd ${KRNLCONFDIR}; \
PATH=${TMPPATH} \
config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
${KERNCONFDIR}/${_kernel}
config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} ${_kernel}
.endif
.if !defined(NOCLEAN) && !defined(NO_KERNELCLEAN)
.if defined(MODULES_WITH_WORLD) || defined(NO_MODULES) || !exists(${KRNLSRCDIR}/modules)
cd ${KRNLOBJDIR}/${_kernel}; \
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} -DNO_MODULES clean
.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} clean
.else
cd ${KRNLOBJDIR}/${_kernel}; \
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} cleandir
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} clean cleandir
.endif
.endif
cd ${KRNLOBJDIR}/${_kernel}; \
MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
${MAKE} -DBOOTSTRAPPING -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx/aicasm \
${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/aicasm/Makefile
.if !defined(NO_KERNELDEPEND)
cd ${KRNLOBJDIR}/${_kernel}; \
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} depend
@@ -506,22 +469,19 @@ buildkernel:
#
# Install the kernel defined by INSTALLKERNEL
#
installkernel reinstallkernel:
.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
@echo
@echo "--------------------------------------------------------------"
@echo ">>> Making hierarchy"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; \
${CROSSENV} PATH=${TMPPATH} ${MAKE} -f Makefile.inc1 hierarchy
.endif
@echo
@echo "--------------------------------------------------------------"
@echo ">>> Installing kernel"
@echo "--------------------------------------------------------------"
installkernel:
cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
${CROSSENV} PATH=${TMPPATH} \
${MAKE} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel$//}
${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} install
reinstallkernel:
cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
${CROSSENV} ${MAKE} KERNEL=${INSTKERNNAME} reinstall
#
# kernel
#
# Short hand for `make buildkernel installkernel'
#
kernel: buildkernel installkernel
#
# update
@@ -554,7 +514,7 @@ update:
@echo "--------------------------------------------------------------"
@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; cvs -R -q update -rRELENG_4 -P -d
cd ${.CURDIR}; cvs -q update -rRELENG_4 -P -d
.endif
#
@@ -566,9 +526,14 @@ most:
@echo "--------------------------------------------------------------"
@echo ">>> Building programs only"
@echo "--------------------------------------------------------------"
.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ all
.endfor
cd ${.CURDIR}/bin; ${MAKE} all
cd ${.CURDIR}/sbin; ${MAKE} all
cd ${.CURDIR}/libexec; ${MAKE} all
cd ${.CURDIR}/usr.bin; ${MAKE} all
cd ${.CURDIR}/usr.sbin; ${MAKE} all
cd ${.CURDIR}/gnu/libexec; ${MAKE} all
cd ${.CURDIR}/gnu/usr.bin; ${MAKE} all
cd ${.CURDIR}/gnu/usr.sbin; ${MAKE} all
#
# installmost
@@ -580,9 +545,14 @@ installmost:
@echo "--------------------------------------------------------------"
@echo ">>> Installing programs only"
@echo "--------------------------------------------------------------"
.for _dir in bin sbin libexec usr.bin usr.sbin gnu/libexec gnu/usr.bin gnu/usr.sbin
cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ install
.endfor
cd ${.CURDIR}/bin; ${MAKE} install
cd ${.CURDIR}/sbin; ${MAKE} install
cd ${.CURDIR}/libexec; ${MAKE} install
cd ${.CURDIR}/usr.bin; ${MAKE} install
cd ${.CURDIR}/usr.sbin; ${MAKE} install
cd ${.CURDIR}/gnu/libexec; ${MAKE} install
cd ${.CURDIR}/gnu/usr.bin; ${MAKE} install
cd ${.CURDIR}/gnu/usr.sbin; ${MAKE} install
#
# ------------------------------------------------------------------------
@@ -603,16 +573,14 @@ _strfile= games/fortune/strfile
.endif
bootstrap-tools:
.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef \
usr.bin/makewhatis usr.bin/uudecode usr.bin/xinstall \
.for _tool in ${_strfile} usr.bin/yacc usr.bin/colldef usr.bin/xinstall \
usr.sbin/config \
gnu/usr.bin/gperf gnu/usr.bin/groff gnu/usr.bin/texinfo
${ECHODIR} "===> ${_tool}"; \
cd ${.CURDIR}/${_tool}; \
${MAKE} DIRPRFX=${_tool}/ obj; \
${MAKE} DIRPRFX=${_tool}/ depend; \
${MAKE} DIRPRFX=${_tool}/ all; \
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
cd ${.CURDIR}/${_tool}; \
${MAKE} obj; \
${MAKE} depend; \
${MAKE} all; \
${MAKE} DESTDIR=${MAKEOBJDIRPREFIX} install
.endfor
#
@@ -635,28 +603,19 @@ _perl= gnu/usr.bin/perl/miniperl
.endif
.if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
!defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS4)
!defined(NOCRYPT) && defined(MAKE_KERBEROS4)
_libroken4= kerberosIV/lib/libroken
.endif
.if exists(${.CURDIR}/kerberos5) && exists(${.CURDIR}/crypto) && \
!defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
_libkrb5= kerberos5/lib/libroken kerberos5/lib/libvers \
kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
.endif
.if defined(RELEASEDIR)
_sysinstall= release/sysinstall
!defined(NOCRYPT) && defined(MAKE_KERBEROS5)
_libkrb5= kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
.endif
build-tools:
.for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
${_perl} ${_libroken4} ${_libkrb5} lib/libncurses ${_share} \
usr.bin/awk usr.bin/file ${_sysinstall}
${ECHODIR} "===> ${_tool}"; \
cd ${.CURDIR}/${_tool}; \
${MAKE} DIRPRFX=${_tool}/ obj; \
${MAKE} DIRPRFX=${_tool}/ build-tools
${_perl} ${_libroken4} ${_libkrb5} lib/libncurses ${_share} usr.bin/file
cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
.endfor
#
@@ -671,15 +630,13 @@ _btxld= usr.sbin/btxld
.endif
cross-tools:
.for _tool in ${_btxld} ${_elf2exe} usr.bin/genassym usr.bin/gensetdefs \
gnu/usr.bin/binutils usr.bin/objformat usr.sbin/crunch/crunchide \
gnu/usr.bin/cc
${ECHODIR} "===> ${_tool}"; \
cd ${.CURDIR}/${_tool}; \
${MAKE} DIRPRFX=${_tool}/ obj; \
${MAKE} DIRPRFX=${_tool}/ depend; \
${MAKE} DIRPRFX=${_tool}/ all; \
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
.for _tool in ${_btxld} ${_elf2exe} usr.bin/genassym \
usr.bin/gensetdefs gnu/usr.bin/binutils usr.bin/objformat gnu/usr.bin/cc
cd ${.CURDIR}/${_tool}; \
${MAKE} obj; \
${MAKE} depend; \
${MAKE} all; \
${MAKE} DESTDIR=${MAKEOBJDIRPREFIX} install
.endfor
#
@@ -688,96 +645,159 @@ cross-tools:
hierarchy:
cd ${.CURDIR}/etc; ${MAKE} distrib-dirs
#
# includes - possibly generate and install the include files.
#
includes:
cd ${.CURDIR}/include; ${MAKE} -B all install
cd ${.CURDIR}/gnu/include; ${MAKE} install
cd ${.CURDIR}/gnu/lib/libmp; ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/lib/libobjc; ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/lib/libreadline/readline; ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/lib/libregex; ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/lib/libstdc++; ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/lib/libdialog; ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/lib/libgmp; ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/usr.bin/cc/cc1plus; ${MAKE} beforeinstall
.if exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
.if exists(${.CURDIR}/secure/lib/libcrypto)
cd ${.CURDIR}/secure/lib/libcrypto; ${MAKE} beforeinstall
.endif
.if exists(${.CURDIR}/secure/lib/libssl)
cd ${.CURDIR}/secure/lib/libssl; ${MAKE} beforeinstall
.endif
.endif
.if exists(${.CURDIR}/kerberosIV) && !defined(NOCRYPT) && \
defined(MAKE_KERBEROS4)
cd ${.CURDIR}/kerberosIV/lib/libacl; ${MAKE} beforeinstall
cd ${.CURDIR}/kerberosIV/lib/libkadm; ${MAKE} beforeinstall
cd ${.CURDIR}/kerberosIV/lib/libkafs; ${MAKE} beforeinstall
cd ${.CURDIR}/kerberosIV/lib/libkdb; ${MAKE} beforeinstall
cd ${.CURDIR}/kerberosIV/lib/libkrb; ${MAKE} beforeinstall
cd ${.CURDIR}/kerberosIV/lib/libtelnet; ${MAKE} beforeinstall
.elif exists(${.CURDIR}/secure) && !defined(NOCRYPT) && !defined(NOSECURE)
cd ${.CURDIR}/secure/lib/libtelnet; ${MAKE} beforeinstall
.else
cd ${.CURDIR}/lib/libtelnet; ${MAKE} beforeinstall
.endif
.if exists(${.CURDIR}/kerberos5) && !defined(NOCRYPT) && \
defined(MAKE_KERBEROS5)
cd ${.CURDIR}/kerberos5/lib/libasn1; ${MAKE} beforeinstall
cd ${.CURDIR}/kerberos5/lib/libhdb; ${MAKE} beforeinstall
cd ${.CURDIR}/kerberos5/lib/libkadm5clnt; ${MAKE} beforeinstall
cd ${.CURDIR}/kerberos5/lib/libkadm5srv; ${MAKE} beforeinstall
cd ${.CURDIR}/kerberos5/lib/libkafs5; ${MAKE} beforeinstall
cd ${.CURDIR}/kerberos5/lib/libkrb5; ${MAKE} beforeinstall
cd ${.CURDIR}/kerberos5/lib/libsl; ${MAKE} beforeinstall
.endif
.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
cd ${.CURDIR}/lib/csu/${MACHINE_ARCH}; ${MAKE} beforeinstall
.endif
cd ${.CURDIR}/gnu/lib/csu; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libalias; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libatm; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libdevstat; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libc; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libcalendar; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libcam; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libdisk; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libedit; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libfetch; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libftpio; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libkvm; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libmd; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/msun; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libncp; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libncurses; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libnetgraph; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libopie; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libpam/libpam; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libpcap; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libradius; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/librpcsvc; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libskey; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libstand; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libtacplus; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libcom_err; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libusbhid; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libutil; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libvgl; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libwrap; ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libz; ${MAKE} beforeinstall
cd ${.CURDIR}/usr.bin/lex; ${MAKE} beforeinstall
#
# libraries - build all libraries, and install them under ${DESTDIR}.
#
# The list of libraries with dependents (${_prebuild_libs}) and their
# interdependencies (__L) are built automatically by the
# ${.CURDIR}/tools/make_libdeps.sh script.
# The following dependencies exist between the libraries:
#
libraries:
cd ${.CURDIR}; \
${MAKE} -f Makefile.inc1 _startup_libs; \
${MAKE} -f Makefile.inc1 _prebuild_libs; \
${MAKE} -f Makefile.inc1 _generic_libs;
# These dependencies are not automatically generated:
# lib*: csu libgcc_pic
# libatm: libmd
# libcrypt: libmd
# libdialog: libncurses
# libedit: libncurses
# libg++: msun
# libkrb: libcrypt
# libopie: libmd
# libpam: libcom_err libcrypt libcrypto libkrb libopie libradius \
# libskey libtacplus libutil libz libssh
# libradius: libmd
# libreadline: libncurses
# libskey: libcrypt libmd
# libstc++: msun
# libtacplus: libmd
#
# gnu/lib/csu, gnu/lib/libgcc and lib/csu must be built before all
# shared libraries for ELF.
# Across directories this comes down to (rougly):
#
_startup_libs= gnu/lib/csu gnu/lib/libgcc
.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-${OBJFORMAT})
_startup_libs+= lib/csu/${MACHINE_ARCH}-${OBJFORMAT}
# gnu/lib: lib/msun lib/libncurses
# kerberosIV/lib kerberos5/lib: lib/libcrypt
# lib/libpam: secure/lib/libcrypto kerberosIV/lib/libkrb \
# secure/lib/libssh lib/libz
# secure/lib: lib/libmd
#
.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}.pcc)
_csu= lib/csu/${MACHINE_ARCH}.pcc
.elif ${MACHINE_ARCH} == "i386" && ${OBJFORMAT} == "elf"
_csu= lib/csu/i386-elf
.else
_startup_libs+= lib/csu/${MACHINE_ARCH}
_csu= lib/csu/${MACHINE_ARCH}
.endif
_prebuild_libs=
.if !defined(NOSECURE) && !defined(NOCRYPT)
_secure_lib= secure/lib
.endif
_generic_libs= gnu/lib
.if !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
_kerberosIV_lib= kerberosIV/lib
.endif
.if !defined(NOCRYPT) && defined(MAKE_KERBEROS5)
_kerberos5_lib= kerberos5/lib
.endif
.if !defined(NOPERL)
_generic_libs+= gnu/usr.bin/perl/libperl
_libperl= gnu/usr.bin/perl/libperl
.endif
.if !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS5)
_prebuild_libs+= kerberos5/lib/libasn1
_prebuild_libs+= kerberos5/lib/libgssapi
_prebuild_libs+= kerberos5/lib/libkrb5
_prebuild_libs+= kerberos5/lib/libroken
_generic_libs+= kerberos5/lib
.endif
.if !defined(NOCRYPT) && !defined(NO_OPENSSL) && defined(MAKE_KERBEROS4)
_prebuild_libs+= kerberosIV/lib/libkrb
kerberosIV/lib/libkrb__L: lib/libcrypt__L
_generic_libs+= kerberosIV/lib
.endif
_prebuild_libs+= lib/libcom_err lib/libcrypt lib/libmd \
lib/libncurses lib/libopie lib/libradius lib/libskey \
lib/libtacplus lib/libutil \
lib/libz lib/msun
lib/libopie__L lib/libradius__L lib/libtacplus__L: lib/libmd__L
lib/libskey__L: lib/libcrypt__L lib/libmd__L
_generic_libs+= lib
.if !defined(NOCRYPT)
.if !defined(NO_OPENSSL)
_prebuild_libs+= secure/lib/libcrypto secure/lib/libssl
.if !defined(NO_OPENSSH)
_prebuild_libs+= secure/lib/libssh
secure/lib/libssh__L: secure/lib/libcrypto__L lib/libz__L
.endif
.endif
_generic_libs+= secure/lib
.endif
_generic_libs+= usr.bin/lex/lib
.if ${MACHINE_ARCH} == "i386"
_generic_libs+= usr.sbin/pcvt/keycap
_libkeycap= usr.sbin/pcvt/keycap
.endif
.for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
${_lib}__L: .PHONY
libraries:
.for _lib in ${_csu} gnu/lib/csu gnu/lib/libgcc lib/libmd lib/libcrypt \
${_secure_lib} ${_kerberosIV_lib} \
${_kerberos5_lib} lib/libcom_err lib/msun lib/libncurses \
lib/libopie lib/libradius lib/libskey lib/libtacplus lib/libutil \
lib/libz lib gnu/lib ${_libperl} usr.bin/lex/lib ${_libkeycap}
.if exists(${.CURDIR}/${_lib})
${ECHODIR} "===> ${_lib}"; \
cd ${.CURDIR}/${_lib}; \
${MAKE} DIRPRFX=${_lib}/ depend; \
${MAKE} DIRPRFX=${_lib}/ all; \
${MAKE} DIRPRFX=${_lib}/ install
cd ${.CURDIR}/${_lib}; \
${MAKE} depend; \
${MAKE} all; \
${MAKE} install
.endif
.endfor
_startup_libs: ${_startup_libs:S/$/__L/}
_prebuild_libs: ${_prebuild_libs:S/$/__L/}
_generic_libs: ${_generic_libs:S/$/__L/}
.for __target in clean cleandepend cleandir depend includes obj
.for __target in clean cleandepend cleandir depend obj
.for entry in ${SUBDIR}
${entry}.${__target}__D: .PHONY
@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
+3 -111
View File
@@ -8,112 +8,6 @@ A reverse chronology since 4.0 was released is included, followed by
the common items quick how-tos, followed by entries for versions of
-current prior to 4.0 Release.
20070426:
The ABI breakage in sendmail(8)'s libmilter has been repaired
so it is no longer necessary to recompile mail filters (aka,
milters). If you recompiled mail filters after the 20070411
note, it is not necessary to recompile them again.
20070411:
sendmail(8) has been updated to version 8.14.1. Mail filters
(aka, milters) compiled against the libmilter included in the
base operating system should be recompiled.
20050513:
Intel Hyper-Threading is now disabled by default due to a
security issue, but can be re-enabled by setting the
machdep.hyperthreading_allowed tunable in /boot/loader.conf.
20050124:
FreeBSD 4.11-RELEASE.
20040527:
FreeBSD 4.10-RELEASE.
20031028:
FreeBSD 4.9-RELEASE.
20031022:
Support for HyperThread logical CPUs has now been enabled by
default. As a result, the HTT kernel option no longer exists.
Instead, the logical CPUs are always started so that they can
handle interrupts. However, the extra logical CPUs are prevented
from executing user processes by default. To enable the logical
CPUs, change the value of the machdep.hlt_logical_cpus from 1 to
0. This value can also be set from the loader as a tunable of
the same name.
20030923:
Fix a bug in arplookup(), whereby a hostile party on a locally
attached network could exhaust kernel memory, and cause a system
panic, by sending a flood of spoofed ARP requests. See
FreeBSD-SA-03:14.arp.
20030904:
If you get errors regarding sendmail.cf files while trying
to run mergemaster, you should either install the new version,
or run /usr/src/usr.sbin/mergemaster/mergemaster.sh. This is
a one-time issue to fix a Makefile compatibility problem.
20030904:
Between August 9th and August 30th, a bug existed in the i386
virtual memory system which could cause panics under load.
Anyone running a kernel built between those dates is advised
to update at the earliest possible convenience.
20030806:
All current USB quirks in da(4) have been deprecated and will be
removed for 4.9. If this causes failure for your umass(4) devices,
enable "options DA_OLD_QUIRKS" in your kernel and send the output of
"camcontrol inquiry da0" to [email protected] so the quirk can be
re-enabled.
20030403:
FreeBSD 4.8-RELEASE.
20030214:
OpenSSL 0.97 has been imported, and the libcrypto/libssl
library versions have been bumped.
20030213:
sendmail 8.12.7 has been imported. It has one important
change for IPv6 users. The default submit.mc now uses
'[127.0.0.1]' instead of 'localhost' meaning only IPv4 is
used to connect to the MTA. Users on IPv6-only machines
will need to edit /etc/mail/submit.mc appropriately.
20021110:
The definitions of the standard file streams (stdin, stdout, and
stderr) have changed so that they are no longer compile-time
constants. Some older binaries may require updated 3.X
compatability libraries (for example, by setting COMPAT3X=yes
for a buildworld/installworld).
20021010:
FreeBSD 4.7-RELEASE.
20020807:
COPY is being deprecated. The 20020703 change was reverted, as
it causes far more pain than was expected, and to always compare
before installing, please use INSTALL="install -C" again. The
-C option is now silently ignored when used with the -d option.
20020704:
OpenSSH has been upgraded to 3.4p1 and fully PAMified. Note
that the protocol version now defaults to 2 rather than 1,
which means clients might get warnings about unknown host keys
their hostfiles only list the ssh1 RSA key. See ssh_config(5)
and sshd_config(5) for more information on configuring ssh and
sshd.
20020703:
The install(1) utility no longer allows the -d and -C options
to be specified together. "INSTALL=install -C" in make.conf
should be replaced with "COPY=-C".
20020615:
FreeBSD 4.6-RELEASE.
20020515:
The k5su utility installed as part of Kerberos 5 is no longer
installed with the set-user-ID bit set by default. Add
@@ -143,9 +37,7 @@ the common items quick how-tos, followed by entries for versions of
are very benign, some of them have created a bit of a stir.
Use the new version of mergemaster to update /etc, either by
updating /etc after installworld, or by doing:
cd /usr/src/usr.sbin/mergemaster; make -m /usr/src/share/mk all install
before you run installworld.
cd /usr/src/usr.sbin/mergemaster; make all install [clean]
Then use the new -C option to double-check your rc.conf settings.
You should also double-check settings in [defaults/]rc.conf,
syslog.conf, newsyslog.conf, and anything else important
@@ -181,7 +73,7 @@ the common items quick how-tos, followed by entries for versions of
'mergemaster -p' will do this. You may need to install
mergemaster before this will work if you are updating from a
very old version of stable. This can be done with:
cd /usr/src/usr.sbin/mergemaster; make -m /usr/src/share/mk all install
cd /usr/src/usr.sbin/mergemaster; make all install [clean]
20020325:
sendmail 8.12.2 has been imported. The sendmail binary is no
@@ -870,7 +762,7 @@ versions of -stable/-current.
Changes to the pccardd kernel interface require that you recompile
pccardd for new kernel.
19990725:
19980725:
The ipfw interface to the kernel has changed. You will need to
recompile ipfw programs for the new kernel.
+5 -15
View File
@@ -135,14 +135,13 @@ scanfiles(argv, cooked)
{
int i = 0;
char *path;
FILE *fp;
while ((path = argv[i]) != NULL || i == 0) {
int fd;
if (path == NULL || strcmp(path, "-") == 0) {
filename = "stdin";
fd = STDIN_FILENO;
fd = 0;
} else {
filename = path;
fd = open(path, O_RDONLY);
@@ -155,17 +154,12 @@ scanfiles(argv, cooked)
warn("%s", path);
rval = 1;
} else if (cooked) {
if (fd == STDIN_FILENO)
cook_cat(stdin);
else {
fp = fdopen(fd, "r");
cook_cat(fp);
fclose(fp);
}
FILE *fp = fdopen(fd, "r");
cook_cat(fp);
fclose(fp);
} else {
raw_cat(fd);
if (fd != STDIN_FILENO)
close(fd);
close(fd);
}
if (path == NULL)
break;
@@ -179,10 +173,6 @@ cook_cat(fp)
{
register int ch, gobble, line, prev;
/* Reset EOF condition on stdin. */
if (fp == stdin && feof(stdin))
clearerr(stdin);
line = gobble = 0;
for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
if (prev == '\n') {
+3 -4
View File
@@ -47,10 +47,9 @@
.Ar arg2
.Op Ar arg3 Op ...
.Sh DESCRIPTION
The
.Nm
utility is used to control the operation of medium changers, such as those
found in tape and optical disk jukeboxes.
is used to control the operation of medium changers, such as those found
in tape and optical disk jukeboxes.
.Pp
The options are as follows:
.Bl -tag -width indent
@@ -191,7 +190,7 @@ because of buggy firmware or the like.
.Xc
Change volume tag for an element in the media changer. This command
is only supported by few media changers. If it is not supported by a
device, using this command will usually result in an "Invalid Field in
device, using this command will usually result in a "Invalid Field in
CDB" error message on the console.
.Pp
If the
+34 -30
View File
@@ -43,8 +43,11 @@
.Nd change file modes
.Sh SYNOPSIS
.Nm
.Op Fl fhv
.Op Fl R Op Fl H | L | P
.Oo
.Fl fv
.Fl R
.Op Fl H | Fl L | Fl P
.Oc
.Ar mode
.Ar
.Sh DESCRIPTION
@@ -56,22 +59,13 @@ as specified by the
operand.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl f
Do not display a diagnostic message if
.Nm
could not modify the mode for
.Va file ,
nor modify the exit status to reflect such failures.
.Bl -tag -width Ds
.It Fl H
If the
.Fl R
option is specified, symbolic links on the command line are followed.
(Symbolic links encountered in the tree traversal are not followed by
default.)
.It Fl h
If the file is a symbolic link, change the mode of the link itself
rather than the file that the link points to.
.It Fl L
If the
.Fl R
@@ -84,12 +78,24 @@ This is the default.
.It Fl R
Change the modes of the file hierarchies rooted in the files
instead of just the files themselves.
.It Fl f
Do not display a diagnostic message if
.Nm
could not modify the mode for
.Va file .
.It Fl v
Cause
.Nm
to be verbose, showing filenames as the mode is modified.
to be verbose, showing files as the mode is modified.
.El
.Pp
Symbolic links do not have modes, so unless the
.Fl H
or
.Fl L
option is set,
.Nm
on a symbolic link always succeeds and has no effect.
The
.Fl H ,
.Fl L
@@ -112,51 +118,49 @@ one or more of the following values:
.Pp
.Bl -tag -width 6n -compact -offset indent
.It Li 4000
(the setuid bit).
Executable files with this bit set
(the set-user-ID-on-execution bit) Executable files with this bit set
will run with effective uid set to the uid of the file owner.
Directories with this bit set will force all files and
Directories with the set-user-id bit set will force all files and
sub-directories created in them to be owned by the directory owner
and not by the uid of the creating process, if the underlying file
system supports this feature: see
.Xr chmod 2
and the
.Cm suiddir
.Ar suiddir
option to
.Xr mount 8 .
.It Li 2000
(the setgid bit).
Executable files with this bit set
(the set-group-ID-on-execution bit) Executable files with this bit set
will run with effective gid set to the gid of the file owner.
.It Li 1000
(the sticky bit).
See
.Xr chmod 2
and
.Xr sticky 8 .
(the sticky bit)
When set on a directory, unprivileged users can delete and rename
only those files in the directory that are owned by them, regardless of
the permissions on the directory. Under
.Fx ,
the sticky bit is
ignored for executable files and may only be set for directories (see
.Xr sticky 8 ) .
.It Li 0400
Allow read by owner.
.It Li 0200
Allow write by owner.
.It Li 0100
For files, allow execution by owner.
For directories, allow the owner to
For files, allow execution by owner. For directories, allow the owner to
search in the directory.
.It Li 0040
Allow read by group members.
.It Li 0020
Allow write by group members.
.It Li 0010
For files, allow execution by group members.
For directories, allow
For files, allow execution by group members. For directories, allow
group members to search in the directory.
.It Li 0004
Allow read by others.
.It Li 0002
Allow write by others.
.It Li 0001
For files, allow execution by others.
For directories allow others to
For files, allow execution by others. For directories allow others to
search in the directory.
.El
.Pp
+28 -21
View File
@@ -68,15 +68,17 @@ main(argc, argv)
FTS *ftsp;
FTSENT *p;
mode_t *set;
long val;
int oct, omode;
int Hflag, Lflag, Pflag, Rflag, ch, fflag, fts_options, hflag, rval;
int vflag;
char *mode;
char *ep, *mode;
int newmode;
int (*change_mode) __P((const char *, mode_t));
set = NULL;
omode = 0;
Hflag = Lflag = Pflag = Rflag = fflag = hflag = vflag = 0;
while ((ch = getopt(argc, argv, "HLPRXfghorstuvwx")) != -1)
while ((ch = getopt(argc, argv, "HLPRXfgorstuvwx")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
@@ -100,10 +102,9 @@ main(argc, argv)
/*
* In System V (and probably POSIX.2) the -h option
* causes chmod to change the mode of the symbolic
* link. 4.4BSD's symbolic links didn't have modes,
* so it was an undocumented noop. In FreeBSD 3.0,
* lchmod(2) is introduced and this option does real
* work.
* link. 4.4BSD's symbolic links don't have modes,
* so it's an undocumented noop. Do syntax checking,
* though.
*/
hflag = 1;
break;
@@ -146,14 +147,23 @@ done: argv += optind;
}
}
if (hflag)
change_mode = lchmod;
else
change_mode = chmod;
mode = *argv;
if ((set = setmode(mode)) == NULL)
errx(1, "invalid file mode: %s", mode);
if (*mode >= '0' && *mode <= '7') {
errno = 0;
val = strtol(mode, &ep, 8);
if (val > INT_MAX || val < 0)
errno = ERANGE;
if (errno)
err(1, "invalid file mode: %s", mode);
if (*ep)
errx(1, "invalid file mode: %s", mode);
omode = val;
oct = 1;
} else {
if ((set = setmode(mode)) == NULL)
errx(1, "invalid file mode: %s", mode);
oct = 0;
}
if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL)
err(1, NULL);
@@ -179,17 +189,14 @@ done: argv += optind;
* don't point to anything and ones that we found
* doing a physical walk.
*/
if (!hflag)
continue;
/* else */
/* FALLTHROUGH */
continue;
default:
break;
}
newmode = getmode(set, p->fts_statp->st_mode);
newmode = oct ? omode : getmode(set, p->fts_statp->st_mode);
if ((newmode & ALLPERMS) == (p->fts_statp->st_mode & ALLPERMS))
continue;
if ((*change_mode)(p->fts_accpath, newmode) && !fflag) {
if (chmod(p->fts_accpath, newmode) && !fflag) {
warn("%s", p->fts_path);
rval = 1;
} else {
@@ -207,6 +214,6 @@ void
usage()
{
(void)fprintf(stderr,
"usage: chmod [-fhv] [-R [-H | -L | -P]] mode file ...\n");
"usage: chmod [-fv] [-R [-H | -L | -P]] mode file ...\n");
exit(1);
}
+4 -19
View File
@@ -35,7 +35,7 @@
.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
.Dd August 10, 2002
.Dd April 18, 1994
.Dt CP 1
.Os
.Sh NAME
@@ -47,7 +47,7 @@
.Fl R
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f | i | n
.Op Fl f | i
.Op Fl pv
.Ar source_file target_file
.Nm
@@ -55,7 +55,7 @@
.Fl R
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f | i | n
.Op Fl f | i
.Op Fl pv
.Ar source_file ... target_directory
.Sh DESCRIPTION
@@ -121,8 +121,6 @@ regardless of its permissions.
.Fl f
option overrides any previous
.Fl i
or
.Fl n
options.)
.It Fl i
Cause
@@ -138,17 +136,6 @@ the file copy is attempted.
.Fl i
option overrides any previous
.Fl f
or
.Fl n
options.)
.It Fl n
Do not overwrite an existing file.
(The
.Fl n
option overrides any previous
.Fl f
or
.Fl i
options.)
.It Fl p
Cause
@@ -239,9 +226,7 @@ or fifo's.
.Pp
The
.Fl v
and
.Fl n
options are non-standard and their use in scripts is not recommended.
option is non-standard and its use in scripts is not recommended.
.Sh SEE ALSO
.Xr mv 1 ,
.Xr rcp 1 ,
+7 -12
View File
@@ -84,7 +84,7 @@ static const char rcsid[] =
PATH_T to = { to.p_path, "", "" };
int Rflag, fflag, iflag, nflag, pflag, rflag, vflag;
int Rflag, iflag, pflag, rflag, fflag, vflag;
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
@@ -102,7 +102,7 @@ main(argc, argv)
char *target;
Hflag = Lflag = Pflag = 0;
while ((ch = getopt(argc, argv, "HLPRfinprv")) != -1)
while ((ch = getopt(argc, argv, "HLPRfiprv")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
@@ -121,15 +121,11 @@ main(argc, argv)
break;
case 'f':
fflag = 1;
iflag = nflag = 0;
iflag = 0;
break;
case 'i':
iflag = 1;
fflag = nflag = 0;
break;
case 'n':
nflag = 1;
fflag = iflag = 0;
fflag = 0;
break;
case 'p':
pflag = 1;
@@ -350,10 +346,9 @@ copy(argv, type, fts_options)
* honour setuid, setgid and sticky bits, but we
* normally want to preserve them on directories.
*/
if (pflag) {
if (setfile(curr->fts_statp, -1))
rval = 1;
} else {
if (pflag)
rval = setfile(curr->fts_statp, 0);
else {
mode = curr->fts_statp->st_mode;
if ((mode & (S_ISUID | S_ISGID | S_ISTXT)) ||
((mode | S_IRWXU) & mask) != (mode & mask))
+1 -1
View File
@@ -41,7 +41,7 @@ typedef struct {
} PATH_T;
extern PATH_T to;
extern int fflag, iflag, nflag, pflag, vflag;
extern int iflag, pflag, fflag, vflag;
#include <sys/cdefs.h>
+17 -29
View File
@@ -88,11 +88,7 @@ copy_file(entp, dne)
*/
if (!dne) {
#define YESNO "(y/n [n]) "
if (nflag) {
if (vflag)
printf("%s not overwritten\n", to.p_path);
return (0);
} else if (iflag) {
if (iflag) {
(void)fprintf(stderr, "overwrite %s? %s",
to.p_path, YESNO);
checkch = ch = getchar();
@@ -132,8 +128,7 @@ copy_file(entp, dne)
* wins some CPU back.
*/
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
if (S_ISREG(fs->st_mode) && fs->st_size > 0 &&
fs->st_size <= 8 * 1048576) {
if (S_ISREG(fs->st_mode) && fs->st_size <= 8 * 1048576) {
if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ,
MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) {
warn("%s", entp->fts_path);
@@ -215,7 +210,7 @@ copy_link(p, exists)
warn("symlink: %s", link);
return (1);
}
return (pflag ? setfile(p->fts_statp, -1) : 0);
return (0);
}
int
@@ -231,7 +226,7 @@ copy_fifo(from_stat, exists)
warn("mkfifo: %s", to.p_path);
return (1);
}
return (pflag ? setfile(from_stat, -1) : 0);
return (pflag ? setfile(from_stat, 0) : 0);
}
int
@@ -247,7 +242,7 @@ copy_special(from_stat, exists)
warn("mknod: %s", to.p_path);
return (1);
}
return (pflag ? setfile(from_stat, -1) : 0);
return (pflag ? setfile(from_stat, 0) : 0);
}
#define RETAINBITS \
@@ -260,22 +255,20 @@ setfile(fs, fd)
{
static struct timeval tv[2];
struct stat ts;
int rval, gotstat, islink, fdval;
int rval;
int gotstat;
rval = 0;
fdval = fd != -1;
islink = !fdval && S_ISLNK(fs->st_mode);
fs->st_mode &= S_ISUID | S_ISGID | S_ISVTX |
S_IRWXU | S_IRWXG | S_IRWXO;
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec);
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec);
if (islink ? lutimes(to.p_path, tv) : utimes(to.p_path, tv)) {
warn("%sutimes: %s", islink ? "l" : "", to.p_path);
if (utimes(to.p_path, tv)) {
warn("utimes: %s", to.p_path);
rval = 1;
}
if (fdval ? fstat(fd, &ts) :
(islink ? lstat(to.p_path, &ts) : stat(to.p_path, &ts)))
if (fd ? fstat(fd, &ts) : stat(to.p_path, &ts))
gotstat = 0;
else {
gotstat = 1;
@@ -289,9 +282,8 @@ setfile(fs, fd)
* chown. If chown fails, lose setuid/setgid bits.
*/
if (!gotstat || fs->st_uid != ts.st_uid || fs->st_gid != ts.st_gid)
if (fdval ? fchown(fd, fs->st_uid, fs->st_gid) :
(islink ? lchown(to.p_path, fs->st_uid, fs->st_gid) :
chown(to.p_path, fs->st_uid, fs->st_gid))) {
if (fd ? fchown(fd, fs->st_uid, fs->st_gid) :
chown(to.p_path, fs->st_uid, fs->st_gid)) {
if (errno != EPERM) {
warn("chown: %s", to.p_path);
rval = 1;
@@ -300,18 +292,14 @@ setfile(fs, fd)
}
if (!gotstat || fs->st_mode != ts.st_mode)
if (fdval ? fchmod(fd, fs->st_mode) :
(islink ? lchmod(to.p_path, fs->st_mode) :
chmod(to.p_path, fs->st_mode))) {
if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode)) {
warn("chmod: %s", to.p_path);
rval = 1;
}
if (!gotstat || fs->st_flags != ts.st_flags)
if (fdval ?
fchflags(fd, fs->st_flags) :
(islink ? (errno = ENOSYS) :
chflags(to.p_path, fs->st_flags))) {
if (fd ?
fchflags(fd, fs->st_flags) : chflags(to.p_path, fs->st_flags)) {
warn("chflags: %s", to.p_path);
rval = 1;
}
@@ -324,7 +312,7 @@ usage()
{
(void)fprintf(stderr, "%s\n%s\n",
"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src target",
" cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src1 ... srcN directory");
"usage: cp [-R [-H | -L | -P]] [-f | -i] [-pv] src target",
" cp [-R [-H | -L | -P]] [-f | -i] [-pv] src1 ... srcN directory");
exit(EX_USAGE);
}
+8
View File
@@ -0,0 +1,8 @@
# @(#)Makefile 8.1 (Berkeley) 8/14/93
# $FreeBSD$
DIR= usd/04.csh
SRCS= tabs csh.1 csh.2 csh.3 csh.4 csh.a csh.g
MACROS= -ms
.include <bsd.doc.mk>
+1 -1
View File
@@ -739,7 +739,7 @@ Thus the command
echo *
.DE
will not echo the character `*'.
It will either echo a sorted list of filenames in the
It will either echo an sorted list of filenames in the
current
.I "working directory,"
or print the message `No match' if there are
+240 -240
View File
File diff suppressed because it is too large. Load diff
-2
View File
@@ -130,8 +130,6 @@
/* we want to use the system malloc when we install as /bin/csh */
#define SYSMALLOC
#define BSD_STYLE_COLORLS
/* Use LC_MESSAGES locale category to open the message catalog */
#define MCLoadBySet NL_CAT_LOCALE
#endif
#if defined(__bsdi__)
+2
View File
@@ -13,3 +13,5 @@ CLEANFILES+= tcsh.cat tcsh.msg
all: tcsh.cat
tcsh.cat: tcsh.msg
distribute:
+1 -1
View File
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
install:
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
.include <bsd.prog.mk>
+1 -1
View File
@@ -11,7 +11,7 @@ tcsh.msg: set[0-9]*
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
install:
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
.for i in ${LL}
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
+1 -1
View File
@@ -13,7 +13,7 @@ tcsh.msg: set[0-9]*
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
install:
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
.for i in ${LL}
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
+1 -1
View File
@@ -12,7 +12,7 @@ tcsh.msg: set[0-9]*
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
install:
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
.for i in ${LL}
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
+1 -1
View File
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
install:
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
.include <bsd.prog.mk>
+1 -1
View File
@@ -11,7 +11,7 @@ tcsh.msg: set[0-9]*
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
install:
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
.for i in ${LL}
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
+1 -1
View File
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
install:
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
.include <bsd.prog.mk>
+1 -1
View File
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
install:
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
.include <bsd.prog.mk>
+1 -1
View File
@@ -11,7 +11,7 @@ tcsh.msg: set[0-9]*
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
install:
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
.for i in ${LL}
ln -fs ../${DL}/tcsh.cat ${DESTDIR}${NLSDIR}/$i/tcsh.cat
+1 -1
View File
@@ -10,7 +10,7 @@ tcsh.msg: set[0-9]*
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
install:
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
.include <bsd.prog.mk>
+29 -47
View File
@@ -35,7 +35,7 @@
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
.\" $FreeBSD$
.\"
.Dd August 9, 2004
.Dd November 17, 1993
.Dt DATE 1
.Os
.Sh NAME
@@ -168,7 +168,7 @@ Flags are processed in the order given.
When setting values
(rather than adjusting them),
seconds are in the range 0-59, minutes are in the range 0-59, hours are
in the range 0-23, month days are in the range 1-31, week days are in the
in the range 1-12, month days are in the range 1-31, week days are in the
range 0-6 (Sun-Sat),
months are in the range 1-12 (Jan-Dec)
and years are in the range 80-38 or 1980-2038.
@@ -219,22 +219,6 @@ When the date is adjusted to a specific value that occurs twice
the resulting timezone will be set so that the date matches the earlier of
the two times.
.Pp
Adjusting the date by months is inherently ambiguous because
a month is a unit of variable length depending on the current date.
This kind of date adjustment is applied in the most intuitive way.
First of all,
.Nm
tries to preserve the day of the month.
If it is impossible because the target month is shorter than the present one,
the last day of the target month will be the result.
For example, using
.Fl v No +1m
on May 31 will adjust the date to June 30, while using the same option
on January 30 will result in the date adjusted to the last day of February.
This approach is also believed to make the most sense for shell scripting.
Nevertheless, be aware that going forth and back by the same number of
months may take you to a different date.
.Pp
Refer to the examples below for further details.
.El
.Pp
@@ -284,8 +268,9 @@ Time changes for Daylight Saving Time, standard time, leap seconds,
and leap years are handled automatically.
.Sh EXAMPLES
The command:
.Pp
.Dl "date ""+DATE: %Y-%m-%d%nTIME: %H:%M:%S"""
.Bd -literal -offset indent
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S"
.Ed
.Pp
will display:
.Bd -literal -offset indent
@@ -294,54 +279,51 @@ TIME: 13:36:16
.Ed
.Pp
In the Europe/London timezone, the command:
.Pp
.Dl "date -v1m -v+1y"
.Bd -literal -offset indent
date -v1m -v+1y
.Ed
.Pp
will display:
.Pp
.Dl "Sun Jan 4 04:15:24 GMT 1998"
.Bd -literal -offset indent
Sun Jan 4 04:15:24 GMT 1998
.Ed
.Pp
where it is currently Mon Aug 4 04:15:24 BST 1997.
.Pp
The command:
.Pp
.Dl "date -v1d -v3m -v0y -v-1d"
.Bd -literal -offset indent
date -v1d -v3m -v0y -v-1d
.Ed
.Pp
will display the last day of February in the year 2000:
.Pp
.Dl "Tue Feb 29 03:18:00 GMT 2000"
.Pp
So will do the command:
.Pp
.Dl "date -v30d -v3m -v0y -v-1m"
.Pp
because there is no such date as the 30th of February.
.Bd -literal -offset indent
Tue Feb 29 03:18:00 GMT 2000
.Ed
.Pp
The command:
.Pp
.Dl "date -v1d -v+1m -v-1d -v-fri"
.Bd -literal -offset indent
date -v1d -v+1m -v-1d -v-fri
.Ed
.Pp
will display the last Friday of the month:
.Pp
.Dl "Fri Aug 29 04:31:11 BST 1997"
.Bd -literal -offset indent
Fri Aug 29 04:31:11 BST 1997
.Ed
.Pp
where it is currently Mon Aug 4 04:31:11 BST 1997.
.Pp
The command:
.Pp
.Dl "date 8506131627"
.Bd -literal -offset indent
date 8506131627
.Ed
.Pp
sets the date to
.Dq Li "June 13, 1985, 4:27 PM" .
.Pp
.Dl "date ""+%Y%m%d%H%M.%S"""
.Pp
may be used on one machine to print out the date
suitable for setting on another.
.Pp
The command:
.Pp
.Dl "date 1432"
.Bd -literal -offset indent
date 1432
.Ed
.Pp
sets the time to
.Li "2:32 PM" ,
-7
View File
@@ -150,8 +150,6 @@ adjyear(struct tm *t, char type, int val, int mk)
static int
adjmon(struct tm *t, char type, int val, int istext, int mk)
{
int lmdays;
if (val < 0)
return 0;
@@ -199,11 +197,6 @@ adjmon(struct tm *t, char type, int val, int istext, int mk)
t->tm_mon = --val;
}
/* e.g., -v-1m on March, 31 is the last day of February in common sense */
lmdays = daysinmonth(t);
if (t->tm_mday > lmdays)
t->tm_mday = lmdays;
return !mk || domktime(t, type) != -1;
}
+3 -2
View File
@@ -57,7 +57,8 @@ displays the number of complete and partial input and output blocks
and truncated input records to the standard error output.
.Pp
The following operands are available:
.Bl -tag -width ".Cm of Ns = Ns Ar file"
.\" XXX
.Bl -tag -width of=file
.It Cm bs Ns = Ns Ar n
Set both input and output block size to
.Ar n
@@ -378,5 +379,5 @@ operand and the
and
.Cm oldibm
values are extensions to the
.Tn POSIX
\*[Px]
standard.
+19 -19
View File
@@ -41,7 +41,7 @@
.Sh SYNOPSIS
.Nm
.Oo
.Fl b | g | h | H | k |
.Fl b | h | H | k |
.Fl m | P
.Oc
.Op Fl ailn
@@ -52,13 +52,13 @@ The
.Nm
utility
displays statistics about the amount of free disk space on the specified
.Ar file system
or on the file system of which
.Ar filesystem
or on the filesystem of which
.Ar file
is a part.
Values are displayed in 512-byte per block counts.
If neither a file or a file system operand is specified,
statistics for all mounted file systems are displayed
If neither a file or a filesystem operand is specified,
statistics for all mounted filesystems are displayed
(subject to the
.Fl t
option below).
@@ -81,11 +81,11 @@ specification from the environment.
.It Fl H
"Human-readable" output. Use unit suffixes: Byte, Kilobyte, Megabyte,
Gigabyte, Terabyte and Petabyte in order to reduce the number of
digits to four or fewer using base 10 for sizes.
digits to three or less using base 10 for sizes.
.It Fl h
"Human-readable" output. Use unit suffixes: Byte, Kilobyte, Megabyte,
Gigabyte, Terabyte and Petabyte in order to reduce the number of
digits to four or fewer using base 2 for sizes.
digits to three or less using base 2 for sizes.
.It Fl i
Include statistics on the number of free inodes.
.It Fl k
@@ -94,20 +94,20 @@ this overrides the
.Ev BLOCKSIZE
specification from the environment.
.It Fl l
Only display information about locally-mounted file systems.
Only display information about locally-mounted filesystems.
.It Fl m
Use 1048576-byte (1-Mbyte) blocks rather than the default. Note that
this overrides the
.Ev BLOCKSIZE
specification from the environment.
.It Fl n
Print out the previously obtained statistics from the file systems.
Print out the previously obtained statistics from the filesystems.
This option should be used if it is possible that one or more
file systems are in a state such that they will not be able to provide
filesystems are in a state such that they will not be able to provide
statistics without a long delay.
When this option is specified,
.Nm
will not request new statistics from the file systems, but will respond
will not request new statistics from the filesystems, but will respond
with the possibly stale statistics that were previously obtained.
.It Fl P
Use POSIX compliant output of 512-byte blocks rather than the default.
@@ -115,27 +115,27 @@ Note that this overrides the
.Ev BLOCKSIZE
specification from the environment.
.It Fl t
Only print out statistics for file systems of the specified types.
Only print out statistics for filesystems of the specified types.
More than one type may be specified in a comma separated list.
The list of file system types can be prefixed with
The list of filesystem types can be prefixed with
.Dq no
to specify the file system types for which action should
to specify the filesystem types for which action should
.Em not
be taken.
For example, the
.Nm
command:
.Bd -literal -offset indent
df -t nonfs,nullfs
df -t nonfs,mfs
.Ed
.Pp
lists all file systems except those of type
lists all filesystems except those of type
.Tn NFS
and
.Tn NULLFS .
.Tn MFS .
The
.Xr lsvfs 1
command can be used to find out the types of file systems
command can be used to find out the types of filesystems
that are available on the system.
.El
.Sh ENVIRONMENT
@@ -150,7 +150,7 @@ The
.Fl n
and
.Fl t
flags are ignored if a file or file system is specified.
flags are ignored if a file or filesystem is specified.
.Sh SEE ALSO
.Xr lsvfs 1 ,
.Xr quota 1 ,
+21 -26
View File
@@ -112,7 +112,7 @@ unit_t unitp [] = { NONE, KILO, MEGA, GIGA, TERA, PETA };
int bread(off_t, void *, int);
int checkvfsname(const char *, char **);
char *getmntpt(char *);
int int64width(int64_t);
int longwidth(long);
char *makenetvfslist(void);
char **makevfslist(char *);
void prthuman(struct statfs *, long);
@@ -209,9 +209,11 @@ main(int argc, char *argv[])
rv = 0;
if (!*argv) {
mntsize = regetmntinfo(&mntbuf, mntsize, vfslist);
bzero(&maxwidths, sizeof(maxwidths));
for (i = 0; i < mntsize; i++)
update_maxwidths(&maxwidths, &mntbuf[i]);
if (vfslist != NULL) {
bzero(&maxwidths, sizeof(maxwidths));
for (i = 0; i < mntsize; i++)
update_maxwidths(&maxwidths, &mntbuf[i]);
}
for (i = 0; i < mntsize; i++) {
if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0)
prtstat(&mntbuf[i], &maxwidths);
@@ -376,15 +378,9 @@ prthumanval(double bytes)
* Convert statfs returned filesystem size into BLOCKSIZE units.
* Attempts to avoid overflow for large filesystems.
*/
static int64_t
fsbtoblk(int64_t num, uint64_t fsbs, u_long bs)
{
if (fsbs != 0 && fsbs < bs)
return (num / (int64_t)(bs / fsbs));
else
return (num * (int64_t)(fsbs / bs));
}
#define fsbtoblk(num, fsbs, bs) \
(((fsbs) != 0 && (fsbs) < (bs)) ? \
(num) / ((bs) / (fsbs)) : (num) * ((fsbs) / (bs)))
/*
* Print out status about a filesystem.
@@ -426,12 +422,11 @@ prtstat(struct statfs *sfsp, struct maxwidths *mwp)
if (hflag) {
prthuman(sfsp, used);
} else {
(void)printf(" %*lld %*lld %*lld", mwp->total,
(long long)fsbtoblk(sfsp->f_blocks, sfsp->f_bsize,
blocksize), mwp->used,
(long long)fsbtoblk(used, sfsp->f_bsize, blocksize),
mwp->avail, (long long)fsbtoblk(sfsp->f_bavail,
sfsp->f_bsize, blocksize));
(void)printf(" %*ld %*ld %*ld", mwp->total,
fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize),
mwp->used, fsbtoblk(used, sfsp->f_bsize, blocksize),
mwp->avail, fsbtoblk(sfsp->f_bavail, sfsp->f_bsize,
blocksize));
}
(void)printf(" %5.0f%%",
availblks == 0 ? 100.0 : (double)used / (double)availblks * 100.0);
@@ -460,20 +455,20 @@ update_maxwidths(struct maxwidths *mwp, struct statfs *sfsp)
getbsize(&dummy, &blocksize);
mwp->mntfrom = imax(mwp->mntfrom, strlen(sfsp->f_mntfromname));
mwp->total = imax(mwp->total, int64width(fsbtoblk(sfsp->f_blocks,
mwp->total = imax(mwp->total, longwidth(fsbtoblk(sfsp->f_blocks,
sfsp->f_bsize, blocksize)));
mwp->used = imax(mwp->used, int64width(fsbtoblk(sfsp->f_blocks -
mwp->used = imax(mwp->used, longwidth(fsbtoblk(sfsp->f_blocks -
sfsp->f_bfree, sfsp->f_bsize, blocksize)));
mwp->avail = imax(mwp->avail, int64width(fsbtoblk(sfsp->f_bavail,
mwp->avail = imax(mwp->avail, longwidth(fsbtoblk(sfsp->f_bavail,
sfsp->f_bsize, blocksize)));
mwp->iused = imax(mwp->iused, int64width(sfsp->f_files -
mwp->iused = imax(mwp->iused, longwidth(sfsp->f_files -
sfsp->f_ffree));
mwp->ifree = imax(mwp->ifree, int64width(sfsp->f_ffree));
mwp->ifree = imax(mwp->ifree, longwidth(sfsp->f_ffree));
}
/* Return the width in characters of the specified long. */
int
int64width(int64_t val)
longwidth(long val)
{
int len;
@@ -567,7 +562,7 @@ usage(void)
{
(void)fprintf(stderr,
"usage: df [-b | -g | -H | -h | -k | -m | -P] [-ailn] [-t type] [file | filesystem ...]\n");
"usage: df [-b | -H | -h | -k | -m | -P] [-ailn] [-t type] [file | filesystem ...]\n");
exit(EX_USAGE);
}
+6 -15
View File
@@ -35,7 +35,7 @@
.\" @(#)echo.1 8.1 (Berkeley) 7/22/93
.\" $FreeBSD$
.\"
.Dd April 12, 2003
.Dd July 22, 1993
.Dt ECHO 1
.Os
.Sh NAME
@@ -58,20 +58,11 @@ output.
The following option is available:
.Bl -tag -width flag
.It Fl n
Do not print the trailing newline character.
This may also be achieved by appending
Do not print the trailing newline character. This may also be
achieved by appending
.Ql \ec
to the end of the string, as is done
by iBCS2 compatible systems.
Note that this option as well as the effect of
.Ql \ec
are implementation-defined in
.St -p1003.1-2001
as amended by Cor. 1-2002.
Applications aiming for maximum
portability are strongly encouraged to use
.Xr printf 1
to suppress the newline character.
.El
.Pp
Some shells may provide a builtin
@@ -90,6 +81,6 @@ manual page.
.Sh STANDARDS
The
.Nm
utility conforms to
.St -p1003.1-2001
as amended by Cor. 1-2002.
utility is expected to be
.St -p1003.2
compatible.
+1 -1
View File
@@ -5,7 +5,7 @@ SRCS= buf.c cbc.c glbl.c io.c main.c re.c sub.c undo.c
LINKS= ${BINDIR}/ed ${BINDIR}/red
MLINKS= ed.1 red.1
.if exists(${.CURDIR}/../../secure) && !defined(NOCRYPT)
.if exists(${.CURDIR}/../../secure) && !defined(NOCRYPT) && !defined(NOSECURE)
DISTRIBUTION=crypto
CFLAGS+=-DDES
DPADD= ${LIBCIPHER}
+62 -151
View File
@@ -12,35 +12,19 @@
.Op Fl sx
.Op Fl p Ar string
.Op Ar file
.Nm red
.Op Fl
.Op Fl sx
.Op Fl p Ar string
.Op Ar file
.\" .LP
.\" red [-] [-sx] [-p \fIstring\fR] [\fIfile\fR]
.Sh DESCRIPTION
The
.Nm
utility is a line-oriented text editor.
It is used to create, display, modify and otherwise manipulate text
files.
When invoked as
.Nm red ,
the editor runs in
.Qq restricted
mode, in which the only difference is that the editor restricts the
use of filenames which start with
.Ql \&!
(interpreted as shell commands by
.Nm )
or contain a
.Ql \&/ .
Note that editing outside of the current directory is only prohibited
if the user does not have write access to the current directory.
If a user has write access to the current directory, then symbolic
links can be created in the current directory, in which case
.Nm red
will not stop the user from editing the file that the symbolic link
points to.
.\" .B red
.\" is a restricted
.\" .BR ed :
.\" it can only edit files in the current
.\" directory and cannot execute shell commands.
.Pp
If invoked with a
.Ar file
@@ -52,7 +36,7 @@ Changes are made to this copy and not directly to
itself.
Upon quitting
.Nm ,
any changes not explicitly saved with a
any changes not explicitly saved with a
.Em w
command are lost.
.Pp
@@ -87,13 +71,11 @@ When an input command, such as
.Em c
(change), is given,
.Nm
enters input mode.
This is the primary means
enters input mode. This is the primary means
of adding text to a file.
In this mode, no commands are available;
instead, the standard input is written
directly to the editor buffer.
Lines consist of text up to and
directly to the editor buffer. Lines consist of text up to and
including a
.Em newline
character.
@@ -111,8 +93,7 @@ command deletes lines; the
.Em m
command moves lines, and so on.
It is possible to modify only a portion of a line by means of replacement,
as in the example above.
However even here, the
as in the example above. However even here, the
.Em s
command is applied to whole lines at a time.
.Pp
@@ -130,8 +111,7 @@ commands have the structure:
.Sm on
.Pp
The address(es) indicate the line or range of lines to be affected by the
command.
If fewer addresses are given than the command accepts, then
command. If fewer addresses are given than the command accepts, then
default addresses are supplied.
.Sh OPTIONS
The following options are available:
@@ -147,17 +127,14 @@ Prompt for an encryption key to be used in subsequent reads and writes
.Em x
command).
.It Fl p Ar string
Specify a command prompt.
This may be toggled on and off with the
Specify a command prompt. This may be toggled on and off with the
.Em P
command.
.It Ar file
Specify the name of a file to read.
If
Specify the name of a file to read. If
.Ar file
is prefixed with a
bang (!), then it is interpreted as a shell command.
In this case,
bang (!), then it is interpreted as a shell command. In this case,
what is read is
the standard output of
.Ar file
@@ -177,15 +154,13 @@ utility maintains a
.Em current address
which is
typically supplied to commands as the default address when none is specified.
When a file is first read, the current address is set to the last line
of the file.
In general, the current address is set to the last line
When a file is first read, the current address is set to the last line
of the file. In general, the current address is set to the last line
affected by a command.
.Pp
A line address is
constructed from one of the bases in the list below, optionally followed
by a numeric offset.
The offset may include any combination
by a numeric offset. The offset may include any combination
of digits, operators (i.e.,
.Em + ,
.Em -
@@ -205,10 +180,8 @@ and is legal wherever it makes sense.
An address range is two addresses separated either by a comma or
semi-colon.
The value of the first address in a range cannot exceed the
value of the second.
If only one address is given in a range, then
the second address is set to the given address.
If an
value of the second. If only one address is given in a range, then
the second address is set to the given address. If an
.Em n Ns -tuple
of addresses is given where
.Em "n\ >\ 2" ,
@@ -218,8 +191,7 @@ the
If only one address is expected, then the last address is used.
.Pp
Each address in a comma-delimited range is interpreted relative to the
current address.
In a semi-colon-delimited range, the first address is
current address. In a semi-colon-delimited range, the first address is
used to set the current address, and the second address is interpreted
relative to the first.
.Pp
@@ -260,13 +232,11 @@ next line, where
.Em n
is a non-negative number.
.It , or %
The first through last lines in the buffer.
This is equivalent to
The first through last lines in the buffer. This is equivalent to
the address range
.Em 1,$ .
.It ;
The current through last lines in the buffer.
This is equivalent to
The current through last lines in the buffer. This is equivalent to
the address range
.Em .,$ .
.It /re/
@@ -309,8 +279,7 @@ command for selecting old text to be replaced with new.
.Pp
In addition to a specifying string literals, regular expressions can
represent
classes of strings.
Strings thus represented are said to be matched
classes of strings. Strings thus represented are said to be matched
by the corresponding regular expression.
If it is possible for a regular expression
to match several strings in a line, then the left-most longest match is
@@ -321,43 +290,24 @@ The following symbols are used in constructing regular expressions:
.It c
Any character
.Em c
not listed below, including
.Ql \&{ ,
.Ql \&} ,
.Ql \&( ,
.Ql \&) ,
.Ql <
and
.Ql > ,
not listed below, including `{', '}', `(', `)', `<' and `>',
matches itself.
.It Pf \e c
Any backslash-escaped character
.Em c ,
except for
.Ql \&{ ,
.Ql \&} ,
.Ql \&( ,
.Ql \&) ,
.Ql <
and
.Ql > ,
except for `{', '}', `(', `)', `<' and `>',
matches itself.
.It .
Match any single character.
.It Op char-class
Match any single character in
.Em char-class .
To include a
.Ql \&]
To include a `]'
in
.Em char-class ,
it must be the first character.
A range of characters may be specified by separating the end characters
of the range with a
.Ql - ,
e.g.,
.Ql a-z
specifies the lower case characters.
of the range with a `-', e.g., `a-z' specifies the lower case characters.
The following literal expressions can also be used in
.Em char-class
to specify sets of characters:
@@ -368,9 +318,7 @@ to specify sets of characters:
.It [:blank:] Ta [:graph:] Ta [:punct:] Ta [:xdigit:]
.El
.Pp
If
.Ql -
appears as the first or last
If `-' appears as the first or last
character of
.Em char-class ,
then it matches itself.
@@ -394,12 +342,11 @@ where
.Ar col-elm
is a
.Em collating element
are interpreted according to the current locale settings
are interpreted according to
.Xr locale 5
(not currently supported).
See
.Xr regex 3
and
.Xr re_format 7
for an explanation of these constructs.
.It Op ^char-class
Match any single character, other than newline, not in
@@ -438,31 +385,21 @@ where
is a number in the range [1,9], expands to the text matched by the
.Em n Ns th
subexpression.
For example, the regular expression
.Ql \e(.*\e)\e1
matches any string
For example, the regular expression `\e(.*\e)\e1' matches any string
consisting of identical adjacent substrings.
Subexpressions are ordered relative to
their left delimiter.
.It *
Match the single character regular expression or subexpression
immediately preceding it zero or more times.
If
immediately preceding it zero or more times. If
.Em *
is the first
character of a regular expression or subexpression, then it matches
itself.
The
itself. The
.Em *
operator sometimes yields unexpected results.
For example, the regular expression
.Ql b*
matches the beginning of
the string
.Ql abbb
(as opposed to the substring
.Ql bbb ) ,
since a null match
For example, the regular expression `b*' matches the beginning of
the string `abbb' (as opposed to the substring `bbb'), since a null match
is the only left-most match.
.It \e{n,m\e} or \e{n,\e} or \e{n\e}
Match the single character regular expression or subexpression
@@ -510,8 +447,7 @@ and returning the editor to command mode.
The
.Nm
utility
recognizes the following commands.
The commands are shown together with
recognizes the following commands. The commands are shown together with
the default address or address range supplied if none is
specified (in parenthesis).
.Bl -tag -width indent
@@ -520,8 +456,7 @@ Append text to the buffer after the addressed line.
Text is entered in input mode.
The current address is set to last line entered.
.It (.,.)c
Change lines in the buffer.
The addressed lines are deleted
Change lines in the buffer. The addressed lines are deleted
from the buffer, and text is appended in their place.
Text is entered in input mode.
The current address is set to last line entered.
@@ -537,7 +472,7 @@ Edit
and sets the default filename.
If
.Ar file
is not specified, then the default filename is used.
is not specified, then the default filename is used.
Any lines in the buffer are deleted before
the new file is read.
The current address is set to the last line read.
@@ -615,11 +550,8 @@ The format of
.Ar command-list
is the same as that of the
.Em g
command.
A newline alone acts as a null command list.
A single
.Ql &
repeats the last non-null command list.
command. A newline alone acts as a null command list.
A single `&' repeats the last non-null command list.
.It H
Toggle the printing of error explanations.
By default, explanations are not printed.
@@ -632,26 +564,23 @@ Insert text in the buffer before the current line.
Text is entered in input mode.
The current address is set to the last line entered.
.It (.,.+1)j
Join the addressed lines.
The addressed lines are
Join the addressed lines. The addressed lines are
deleted from the buffer and replaced by a single
line containing their joined text.
The current address is set to the resultant line.
.It (.)klc
Mark a line with a lower case letter
.Em lc .
The line can then be addressed as
The line can then be addressed as
.Em 'lc
(i.e., a single quote followed by
.Em lc )
in subsequent commands.
The mark is not cleared until the line is
in subsequent commands. The mark is not cleared until the line is
deleted or otherwise modified.
.It (.,.)l
Print the addressed lines unambiguously.
If a single line fills for than one screen (as might be the case
when viewing a binary file, for instance), a
.Dq Li --More--
when viewing a binary file, for instance), a `--More--'
prompt is printed on the last line.
The
.Nm
@@ -660,8 +589,7 @@ before displaying the next screen.
The current address is set to the last line
printed.
.It (.,.)m(.)
Move lines in the buffer.
The addressed lines are moved to after the
Move lines in the buffer. The addressed lines are moved to after the
right-hand destination address, which may be the address
.Em 0
(zero).
@@ -669,8 +597,7 @@ The current address is set to the
last line moved.
.It (.,.)n
Print the addressed lines along with
their line numbers.
The current address is set to the last line
their line numbers. The current address is set to the last line
printed.
.It (.,.)p
Print the addressed lines.
@@ -695,12 +622,10 @@ except that unwritten changes are discarded without warning.
.It ($)r Ar file
Read
.Ar file
to after the addressed line.
If
to after the addressed line. If
.Ar file
is not specified, then the default
filename is used.
If there was no default filename prior to the command,
filename is used. If there was no default filename prior to the command,
then the default filename is set to
.Ar file .
Otherwise, the default filename is unchanged.
@@ -750,9 +675,7 @@ affected is printed as though the print suffix
.Em p
were specified.
.Pp
An unescaped
.Ql &
in
An unescaped `&' in
.Ar replacement
is replaced by the currently matched text.
The character sequence
@@ -764,9 +687,7 @@ is a number in the range [1,9], is replaced by the
backreference expression of the matched text.
If
.Ar replacement
consists of a single
.Ql % ,
then
consists of a single `%', then
.Ar replacement
from the last substitution is used.
Newlines may be embedded in
@@ -841,8 +762,7 @@ Any previous contents of
is lost without warning.
If there is no default filename, then the default filename is set to
.Ar file ,
otherwise it is unchanged.
If no filename is specified, then the default
otherwise it is unchanged. If no filename is specified, then the default
filename is used.
The current address is unchanged.
.It (1,$)wq Ar file
@@ -867,18 +787,15 @@ command, expect that the previous contents of file is not clobbered.
The current address is unchanged.
.It x
Prompt for an encryption key which is used in subsequent reads and
writes.
If a newline alone is entered as the key, then encryption is
turned off.
Otherwise, echoing is disabled while a key is read.
writes. If a newline alone is entered as the key, then encryption is
turned off. Otherwise, echoing is disabled while a key is read.
Encryption/decryption is done using the
.Xr bdes 1
algorithm.
.It Pf (.+1)z n
Scroll
.Ar n
lines at a time starting at addressed line.
If
lines at a time starting at addressed line. If
.Ar n
is not specified, then the current window size is used.
The current address is set to the last line printed.
@@ -889,9 +806,7 @@ via
.Xr sh 1 .
If the first character of
.Ar command
is
.Ql \&! ,
then it is replaced by text of the
is `!', then it is replaced by text of the
previous
.Ar !command .
The
@@ -902,8 +817,7 @@ for backslash (\\) escapes.
However, an unescaped
.Em %
is replaced by the default filename.
When the shell returns from execution, a
.Ql \&!
When the shell returns from execution, a `!'
is printed to the standard output.
The current line is unchanged.
.It ($)=
@@ -919,7 +833,7 @@ buffer file
.It ed.hup
the file to which
.Nm
attempts to write the buffer if the terminal hangs up
attempts to write the buffer if the terminal hangs up
.El
.Sh SEE ALSO
.Xr bdes 1 ,
@@ -941,15 +855,14 @@ The
.Nm
utility processes
.Ar file
arguments for backslash escapes, i.e., in a filename,
arguments for backslash escapes, i.e., in a filename,
any characters preceded by a backslash (\\) are
interpreted literally.
.Pp
If a text (non-binary) file is not terminated by a newline character,
then
.Nm
appends one on reading/writing it.
In the case of a binary file,
appends one on reading/writing it. In the case of a binary file,
.Nm
does not append a newline on reading/writing.
.Pp
@@ -957,9 +870,7 @@ per line overhead: 4 ints
.Sh DIAGNOSTICS
When an error occurs,
.Nm
prints a
.Ql \&?
and either returns to command mode
prints a `?' and either returns to command mode
or exits if its input is from a script.
An explanation of the last error can be
printed with the
@@ -968,7 +879,7 @@ printed with the
.Pp
Since the
.Em g
(global) command masks any errors from failed searches and substitutions,
(global) command masks any errors from failed searches and substitutions,
it can be used to perform conditional operations in scripts; e.g.,
.Pp
.Sm off
+6 -9
View File
@@ -30,7 +30,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd May 10, 2002
.Dd July 3, 1993
.Dt EXPR 1
.Os
.Sh NAME
@@ -46,15 +46,12 @@ utility evaluates
.Ar expression
and writes the result on standard output.
.Pp
All operators and operands must be passed as separate arguments.
Several of the operators have special meaning to command interpreters
and must therefore be quoted appropriately.
All integer operands are interpreted in base 10.
All operators are separate arguments to the
.Nm
utility.
Characters special to the command interpreter must be escaped.
.Pp
Arithmetic operations are performed using signed integer math.
.Pp
Operators are listed below in order of increasing precedence; all
are left-associative.
Operators are listed below in order of increasing precedence.
Operators with equal precedence are grouped within { } symbols.
.Bl -tag -width indent
.It Ar expr1 Li | Ar expr2
+6 -25
View File
@@ -50,19 +50,17 @@
.Fl l
.Op Ar exit_status
.Nm
.Fl Ar signal_name
.Fl signal_name
.Ar pid
\&...
.Nm
.Fl Ar signal_number
.Fl signal_number
.Ar pid
\&...
.Sh DESCRIPTION
The
.Nm
utility sends a signal to the processes specified by the
.Ar pid
operand(s).
utility sends a signal to the processes specified by the pid operand(s).
.Pp
Only the super-user may send signals to other users' processes.
.Pp
@@ -77,11 +75,11 @@ default
If no operand is given, list the signal names; otherwise, write
the signal name corresponding to
.Ar exit_status .
.It Fl Ar signal_name
.It Fl signal_name
A symbolic signal name specifying the signal to be sent instead of the
default
.Dv TERM .
.It Fl Ar signal_number
.It Fl signal_number
A non-negative decimal integer, specifying the signal to be sent instead
of the default
.Dv TERM .
@@ -118,23 +116,6 @@ command which is similar or identical to this utility.
Consult the
.Xr builtin 1
manual page.
.Sh EXAMPLES
Terminate
the processes with pids 142 and 157:
.Pp
.Dl "kill 142 157"
.Pp
Send the hangup signal
.Pq Dv SIGHUP
to the process with pid 507:
.Pp
.Dl "kill -s HUP 507"
.Pp
Terminate the process group with pgid 117:
.Pp
.Dl "kill -- -117"
.Sh DIAGNOSTICS
.Ex -std
.Sh SEE ALSO
.Xr builtin 1 ,
.Xr csh 1 ,
@@ -152,7 +133,7 @@ compatible.
A
.Nm
command appeared in
.At v3 .
.At v6 .
.Sh BUGS
A replacement for the command
.Dq Li kill 0
+18 -15
View File
@@ -41,9 +41,9 @@ static char const copyright[] =
#if 0
static char sccsid[] = "@(#)kill.c 8.4 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <ctype.h>
#include <err.h>
@@ -53,13 +53,16 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
void nosig(char *);
void printsignals(FILE *);
int signame_to_signum(char *);
void usage(void);
int main __P((int, char *[]));
void nosig __P((char *));
void printsignals __P((FILE *));
int signame_to_signum __P((char *));
void usage __P((void));
int
main(int argc, char *argv[])
main(argc, argv)
int argc;
char *argv[];
{
int errors, numsig, pid;
char *ep;
@@ -103,7 +106,7 @@ main(int argc, char *argv[])
} else
numsig = 0;
argc--, argv++;
} else if (**argv == '-' && *(*argv + 1) != '-') {
} else if (**argv == '-') {
++*argv;
if (isalpha(**argv)) {
if ((numsig = signame_to_signum(*argv)) < 0)
@@ -119,9 +122,6 @@ main(int argc, char *argv[])
argc--, argv++;
}
if (argc > 0 && strncmp(*argv, "--", 2) == 0)
argc--, argv++;
if (argc == 0)
usage();
@@ -140,7 +140,8 @@ main(int argc, char *argv[])
}
int
signame_to_signum(char *sig)
signame_to_signum(sig)
char *sig;
{
int n;
@@ -154,7 +155,8 @@ signame_to_signum(char *sig)
}
void
nosig(char *name)
nosig(name)
char *name;
{
warnx("unknown signal %s; valid signals:", name);
@@ -163,7 +165,8 @@ nosig(char *name)
}
void
printsignals(FILE *fp)
printsignals(fp)
FILE *fp;
{
int n;
@@ -177,7 +180,7 @@ printsignals(FILE *fp)
}
void
usage(void)
usage()
{
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
+2 -2
View File
@@ -46,11 +46,11 @@
.Nm
.Op Fl fhinsv
.Ar source_file
.Op Ar target_file
.Op target_file
.Nm
.Op Fl fhinsv
.Ar source_file ...
.Ar target_dir
.Op target_dir
.Nm link
.Ar source_file Ar target_file
.Sh DESCRIPTION
+18 -23
View File
@@ -41,9 +41,9 @@ static char const copyright[] =
#if 0
static char sccsid[] = "@(#)ln.c 8.2 (Berkeley) 3/31/94";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/stat.h>
@@ -62,14 +62,17 @@ int iflag; /* Interactive mode. */
int sflag; /* Symbolic, not hard, link. */
int vflag; /* Verbose output. */
/* System link call. */
int (*linkf)(const char *, const char *);
int (*linkf) __P((const char *, const char *));
char linkch;
int linkit(const char *, const char *, int);
void usage(void);
int linkit __P((const char *, const char *, int));
int main __P((int, char *[]));
void usage __P((void));
int
main(int argc, char *argv[])
main(argc, argv)
int argc;
char *argv[];
{
struct stat sb;
char *p, *sourcedir;
@@ -85,14 +88,11 @@ main(int argc, char *argv[])
else
++p;
if (strcmp(p, "link") == 0) {
while (getopt(argc, argv, "") != -1)
if (argc == 3) {
linkf = link;
exit(linkit(argv[1], argv[2], 0));
} else
usage();
argc -= optind;
argv += optind;
if (argc != 2)
usage();
linkf = link;
exit(linkit(argv[0], argv[1], 0));
}
while ((ch = getopt(argc, argv, "fhinsv")) != -1)
@@ -134,8 +134,6 @@ main(int argc, char *argv[])
exit(linkit(argv[0], ".", 1));
case 2: /* ln target source */
exit(linkit(argv[0], argv[1], 0));
default:
;
}
/* ln target1 target2 directory */
sourcedir = argv[argc - 1];
@@ -157,7 +155,9 @@ main(int argc, char *argv[])
}
int
linkit(const char *target, const char *source, int isdir)
linkit(target, source, isdir)
const char *target, *source;
int isdir;
{
struct stat sb;
const char *p;
@@ -189,12 +189,7 @@ linkit(const char *target, const char *source, int isdir)
p = target;
else
++p;
if (snprintf(path, sizeof(path), "%s/%s", source, p) >=
sizeof(path)) {
errno = ENAMETOOLONG;
warn("%s", target);
return (1);
}
(void)snprintf(path, sizeof(path), "%s/%s", source, p);
source = path;
}
@@ -237,7 +232,7 @@ linkit(const char *target, const char *source, int isdir)
}
void
usage(void)
usage()
{
(void)fprintf(stderr, "%s\n%s\n%s\n",
"usage: ln [-fhinsv] file1 file2",
+14 -17
View File
@@ -53,7 +53,7 @@ i.e. it is a pointer to another name, and not to an underlying object.
For this reason, symbolic links may reference directories and may span
file systems.
.Pp
Because a symbolic link and its referenced object coexist in the file system
Because a symbolic link and its referenced object coexist in the filesystem
name space, confusion can arise in distinguishing between the link itself
and the referenced object.
Historically, commands and system calls have adopted their own link
@@ -106,13 +106,11 @@ the system call
would return a file descriptor to the file
.Dq afile .
.Pp
There are eight system calls that do not follow links, and which operate
There are six system calls that do not follow links, and which operate
on the symbolic link itself.
They are:
.Xr lchmod 2 ,
.Xr lchown 2 ,
.Xr lstat 2 ,
.Xr lutimes 2 ,
.Xr readlink 2 ,
.Xr rename 2 ,
.Xr rmdir 2 ,
@@ -132,16 +130,8 @@ The owner and group of an existing symbolic link can be changed by
means of the
.Xr lchown 2
system call.
The access permissions, owner/group and modification time of
an existing symbolic link can be changed by means of the
.Xr lchmod 2 ,
.Xr lchown 2 ,
and
.Xr lutimes 2
system calls, respectively.
The flags cannot be changed.
Of these, only the flags are used by the system;
the access permissions and ownership are ignored.
The other file attributes, such as the modification time and access
permissions, are not used by the system and cannot be changed.
.Pp
The
.Bx 4.4
@@ -281,6 +271,13 @@ not of type directory.
Operations that apply to symbolic links are performed on the links
themselves, but otherwise the links are ignored.
.Pp
For example, the command
.Dq Li "chown -R user slink directory"
will ignore
.Dq Li slink ,
because symbolic links in this system do not have owners.
Any symbolic links encountered during the tree traversal will also be
ignored.
The command
.Dq Li "rm -r slink directory"
will remove
@@ -288,7 +285,9 @@ will remove
as well as any symbolic links encountered in the tree traversal of
.Dq Li directory ,
because symbolic links may be removed.
In no case will
In no case will either
.Nm chown
or
.Nm rm
affect the file which
.Dq Li slink
@@ -442,10 +441,8 @@ whether specified on the command line or encountered in the tree walk.
.Xr pax 1 ,
.Xr rm 1 ,
.Xr tar 1 ,
.Xr lchmod 2 ,
.Xr lchown 2 ,
.Xr lstat 2 ,
.Xr lutimes 2 ,
.Xr readlink 2 ,
.Xr rename 2 ,
.Xr symlink 2 ,
+15 -55
View File
@@ -13,6 +13,10 @@
* 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.
@@ -30,14 +34,14 @@
* SUCH DAMAGE.
*/
#if 0
#ifndef lint
#if 0
static char sccsid[] = "@(#)cmp.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
#else
static const char rcsid[] =
"$FreeBSD$";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
@@ -51,91 +55,47 @@ __FBSDID("$FreeBSD$");
int
namecmp(const FTSENT *a, const FTSENT *b)
{
return (strcoll(a->fts_name, b->fts_name));
}
int
revnamecmp(const FTSENT *a, const FTSENT *b)
{
return (strcoll(b->fts_name, a->fts_name));
}
int
modcmp(const FTSENT *a, const FTSENT *b)
{
if (b->fts_statp->st_mtimespec.tv_sec >
a->fts_statp->st_mtimespec.tv_sec)
return (1);
if (b->fts_statp->st_mtimespec.tv_sec <
a->fts_statp->st_mtimespec.tv_sec)
return (-1);
if (b->fts_statp->st_mtimespec.tv_nsec >
a->fts_statp->st_mtimespec.tv_nsec)
return (1);
if (b->fts_statp->st_mtimespec.tv_nsec <
a->fts_statp->st_mtimespec.tv_nsec)
return (-1);
return (strcoll(a->fts_name, b->fts_name));
return (b->fts_statp->st_mtime - a->fts_statp->st_mtime);
}
int
revmodcmp(const FTSENT *a, const FTSENT *b)
{
return (modcmp(b, a));
return (a->fts_statp->st_mtime - b->fts_statp->st_mtime);
}
int
acccmp(const FTSENT *a, const FTSENT *b)
{
if (b->fts_statp->st_atimespec.tv_sec >
a->fts_statp->st_atimespec.tv_sec)
return (1);
if (b->fts_statp->st_atimespec.tv_sec <
a->fts_statp->st_atimespec.tv_sec)
return (-1);
if (b->fts_statp->st_atimespec.tv_nsec >
a->fts_statp->st_atimespec.tv_nsec)
return (1);
if (b->fts_statp->st_atimespec.tv_nsec <
a->fts_statp->st_atimespec.tv_nsec)
return (-1);
return (strcoll(a->fts_name, b->fts_name));
return (b->fts_statp->st_atime - a->fts_statp->st_atime);
}
int
revacccmp(const FTSENT *a, const FTSENT *b)
{
return (acccmp(b, a));
return (a->fts_statp->st_atime - b->fts_statp->st_atime);
}
int
statcmp(const FTSENT *a, const FTSENT *b)
{
if (b->fts_statp->st_ctimespec.tv_sec >
a->fts_statp->st_ctimespec.tv_sec)
return (1);
if (b->fts_statp->st_ctimespec.tv_sec <
a->fts_statp->st_ctimespec.tv_sec)
return (-1);
if (b->fts_statp->st_ctimespec.tv_nsec >
a->fts_statp->st_ctimespec.tv_nsec)
return (1);
if (b->fts_statp->st_ctimespec.tv_nsec <
a->fts_statp->st_ctimespec.tv_nsec)
return (-1);
return (strcoll(a->fts_name, b->fts_name));
return (b->fts_statp->st_ctime - a->fts_statp->st_ctime);
}
int
revstatcmp(const FTSENT *a, const FTSENT *b)
{
return (statcmp(b, a));
return (a->fts_statp->st_ctime - b->fts_statp->st_ctime);
}
-2
View File
@@ -45,9 +45,7 @@ int revstatcmp(const FTSENT *, const FTSENT *);
void printcol(DISPLAY *);
void printlong(DISPLAY *);
int printname(const char *);
void printscol(DISPLAY *);
void printstream(DISPLAY *);
void usage(void);
size_t len_octal(const char *, int);
int prn_octal(const char *);
+17 -38
View File
@@ -35,7 +35,7 @@
.\" @(#)ls.1 8.7 (Berkeley) 7/29/94
.\" $FreeBSD$
.\"
.Dd January 11, 2005
.Dd December 29, 2002
.Dt LS 1
.Os
.Sh NAME
@@ -43,7 +43,7 @@
.Nd list directory contents
.Sh SYNOPSIS
.Nm
.Op Fl ABCFGHLPRTWabcdfghiklmnopqrstuwx1
.Op Fl ABCFGHLPRTWabcdfghiklnoqrstuw1
.Op Ar
.Sh DESCRIPTION
For each operand that names a
@@ -172,7 +172,7 @@ format output.
When used with the
.Fl l
option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte
and Petabyte in order to reduce the number of digits to four or fewer
and Petabyte in order to reduce the number of digits to three or less
using base 2 for sizes.
.It Fl i
For each file, print the file's file serial number (inode number).
@@ -188,12 +188,8 @@ This option overrides the environment variable
.Dq ell . )
List in long format.
(See below.)
A total sum (in blocks, see the
.Fl s
option for the block size unit) for all the file
If the output is to a terminal, a total sum for all the file
sizes is output on a line before the long listing.
.It Fl m
Stream output format; list files across the page, separated by commas.
.It Fl n
Display user and group IDs numerically rather than converting to a user
or group name in a long
@@ -203,10 +199,6 @@ output.
Include the file flags in a long
.Pq Fl l
output.
.It Fl p
Write a slash
.Pq Ql /
after each filename if that file is a directory.
.It Fl q
Force printing of non-graphic characters in file names as
the character
@@ -218,7 +210,7 @@ lexicographical order or the oldest entries first.
.It Fl s
Display the number of file system blocks actually used by each file, in units
of 512 bytes, where partial units are rounded up to the next integer value.
A total sum for all the file
If the output is to a terminal, a total sum for all the file
sizes is output on a line before the listing.
The environment variable
.Ev BLOCKSIZE
@@ -238,11 +230,6 @@ or printing
Force raw printing of non-printable characters.
This is the default
when output is not to a terminal.
.It Fl x
The same as
.Fl C ,
except that the multi-column output is produced with entries sorted
across, rather than down, the columns.
.It Fl 1
(The numeric digit
.Dq one . )
@@ -253,7 +240,7 @@ output is not to a terminal.
.El
.Pp
The
.Fl 1 , C , x ,
.Fl 1 , C ,
and
.Fl l
options all override each other; the last one specified determines
@@ -285,9 +272,7 @@ By default,
lists one entry per line to standard
output; the exceptions are to terminals or when the
.Fl C
or
.Fl x
options are specified.
option is specified.
.Pp
File information is displayed with one or more
.Ao blank Ac Ns s
@@ -332,7 +317,7 @@ linked-to file is preceded by
The file mode printed under the
.Fl l
option consists of the
entry type and the permissions.
entry type, owner permissions, and group permissions.
The entry type character describes the type of file, as
follows:
.Pp
@@ -446,7 +431,7 @@ is set, the block counts
will be displayed in units of that size block.
.It Ev CLICOLOR
Use
.Tn ANSI
\*[Ai]
color sequences to distinguish file types.
See
.Ev LSCOLORS
@@ -493,9 +478,7 @@ utility calculates how
many pathname text columns to display
based on the width provided.
(See
.Fl C
and
.Fl x . )
.Fl C . )
.It Ev LANG
The locale to use when determining the order of day and month in the long
.Fl l
@@ -555,7 +538,7 @@ default foreground or background
.El
.Pp
Note that the above are standard
.Tn ANSI
\*[Ai]
colors.
The actual display may differ
depending on the color capabilities of the terminal in use.
@@ -625,21 +608,17 @@ specification.
.Xr termcap 5 ,
.Xr symlink 7 ,
.Xr sticky 8
.Sh STANDARDS
With the exception of options
.Fl g ,
.Fl n
and
.Fl o ,
the
.Nm
utility conforms to
.St -p1003.1-2001 .
.Sh HISTORY
An
.Nm
command appeared in
.At v1 .
.Sh STANDARDS
The
.Nm
utility is expected to be a superset of the
.St -p1003.2
specification.
.Sh BUGS
To maintain backward compatibility, the relationships between the many
options are quite complex.
+19 -48
View File
@@ -40,13 +40,14 @@ static const char copyright[] =
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#if 0
#ifndef lint
#if 0
static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94";
#endif /* not lint */
#else
static const char rcsid[] =
"$FreeBSD$";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
@@ -110,10 +111,7 @@ static int f_reversesort; /* reverse whatever sort is used */
int f_sectime; /* print the real time for all files */
static int f_singlecol; /* use single column output */
int f_size; /* list size in short listing */
int f_slash; /* similar to f_type, but only for dirs */
int f_sortacross; /* sort across rows, not down columns */
int f_statustime; /* use time of last mode change */
int f_stream; /* stream the output, separate with commas */
static int f_timesort; /* sort by time vice name */
int f_type; /* add type character for non-regular files */
static int f_whiteout; /* show whiteout entries */
@@ -146,11 +144,11 @@ main(int argc, char *argv[])
/* Terminal defaults to -Cq, non-terminal defaults to -1. */
if (isatty(STDOUT_FILENO)) {
termwidth = 80;
if ((p = getenv("COLUMNS")) != NULL && *p != '\0')
termwidth = atoi(p);
else if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) != -1 &&
win.ws_col > 0)
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == -1 ||
!win.ws_col) {
if ((p = getenv("COLUMNS")) != NULL)
termwidth = atoi(p);
} else
termwidth = win.ws_col;
f_nonprint = 1;
} else {
@@ -166,17 +164,15 @@ main(int argc, char *argv[])
f_listdot = 1;
fts_options = FTS_PHYSICAL;
while ((ch = getopt(argc, argv, "1ABCFGHLPRTWabcdfghiklmnopqrstuwx"))
!= -1) {
while ((ch = getopt(argc, argv, "1ABCFGHLPRTWabcdfghiklnoqrstuw")) != -1) {
switch (ch) {
/*
* The -1, -C, -x and -l options all override each other so
* shell aliasing works right.
* The -1, -C and -l options all override each other so shell
* aliasing works right.
*/
case '1':
f_singlecol = 1;
f_longform = 0;
f_stream = 0;
break;
case 'B':
f_nonprint = 0;
@@ -184,17 +180,11 @@ main(int argc, char *argv[])
f_octal_escape = 0;
break;
case 'C':
f_sortacross = f_longform = f_singlecol = 0;
f_longform = f_singlecol = 0;
break;
case 'l':
f_longform = 1;
f_singlecol = 0;
f_stream = 0;
break;
case 'x':
f_sortacross = 1;
f_longform = 0;
f_singlecol = 0;
break;
/* The -c and -u options override each other. */
case 'c':
@@ -207,7 +197,6 @@ main(int argc, char *argv[])
break;
case 'F':
f_type = 1;
f_slash = 0;
break;
case 'H':
fts_options |= FTS_COMFOLLOW;
@@ -252,21 +241,12 @@ main(int argc, char *argv[])
case 'k':
f_kblocks = 1;
break;
case 'm':
f_stream = 1;
f_singlecol = 0;
f_longform = 0;
break;
case 'n':
f_numericonly = 1;
break;
case 'o':
f_flags = 1;
break;
case 'p':
f_slash = 1;
f_type = 1;
break;
case 'q':
f_nonprint = 1;
f_octal = 0;
@@ -404,8 +384,6 @@ main(int argc, char *argv[])
printfcn = printscol;
else if (f_longform)
printfcn = printlong;
else if (f_stream)
printfcn = printstream;
else
printfcn = printcol;
@@ -465,13 +443,10 @@ traverse(int argc, char *argv[], int options)
* a separator. If multiple arguments, precede each
* directory with its name.
*/
if (output) {
putchar('\n');
printname(p->fts_path);
puts(":");
} else if (argc > 1) {
printname(p->fts_path);
puts(":");
if (output)
(void)printf("\n%s:\n", p->fts_path);
else if (argc > 1) {
(void)printf("%s:\n", p->fts_path);
output = 1;
}
chp = fts_children(ftsp, ch_options);
@@ -481,7 +456,6 @@ traverse(int argc, char *argv[], int options)
(void)fts_set(ftsp, p, FTS_SKIP);
break;
default:
break;
}
if (errno)
err(1, "fts_read");
@@ -507,8 +481,7 @@ display(FTSENT *p, FTSENT *list)
size_t flen, ulen, glen;
char *initmax;
int entries, needstats;
const char *user, *group;
char *flags;
char *user, *group, *flags;
char buf[STRBUF_SIZEOF(u_quad_t) + 1];
char ngroup[STRBUF_SIZEOF(uid_t) + 1];
char nuser[STRBUF_SIZEOF(gid_t) + 1];
@@ -591,13 +564,11 @@ display(FTSENT *p, FTSENT *list)
f_notabs = 0;
/* fall through */
default:
break;
}
maxinode = makenines(maxinode);
maxblock = makenines(maxblock);
maxnlink = makenines(maxnlink);
maxsize = makenines(maxsize);
free(jinitmax);
}
bcfile = 0;
flags = NULL;
-2
View File
@@ -52,8 +52,6 @@ extern int f_octal_escape; /* like f_octal but use C escapes if possible */
extern int f_nonprint; /* show unprintables as ? */
extern int f_sectime; /* print the real time for all files */
extern int f_size; /* list size in short listing */
extern int f_slash; /* append a '/' if the file is a directory */
extern int f_sortacross; /* sort across rows, not down columns */
extern int f_statustime; /* use time of last mode change */
extern int f_notabs; /* don't use tab-separated multi-col output */
extern int f_type; /* add type character for non-regular files */
+8 -53
View File
@@ -34,13 +34,14 @@
* SUCH DAMAGE.
*/
#if 0
#ifndef lint
#if 0
static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94";
#endif /* not lint */
#else
static const char rcsid[] =
"$FreeBSD$";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
@@ -141,7 +142,7 @@ printscol(DISPLAY *dp)
/*
* print name in current style
*/
int
static int
printname(const char *name)
{
if (f_octal || f_octal_escape)
@@ -218,31 +219,6 @@ printlong(DISPLAY *dp)
}
}
void
printstream(DISPLAY *dp)
{
FTSENT *p;
extern int termwidth;
int chcnt;
for (p = dp->list, chcnt = 0; p; p = p->fts_link) {
if (p->fts_number == NO_PRINT)
continue;
if (strlen(p->fts_name) + chcnt +
(p->fts_link ? 2 : 0) >= (unsigned)termwidth) {
putchar('\n');
chcnt = 0;
}
chcnt += printaname(p, dp->s_inode, dp->s_block);
if (p->fts_link) {
printf(", ");
chcnt += 2;
}
}
if (chcnt)
putchar('\n');
}
void
printcol(DISPLAY *dp)
{
@@ -303,26 +279,15 @@ printcol(DISPLAY *dp)
if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
(void)printf("total %lu\n", howmany(dp->btotal, blocksize));
if (f_sortacross)
base = 0;
for (row = 0; row < numrows; ++row) {
endcol = colwidth;
if (!f_sortacross)
base = row;
for (col = 0, chcnt = 0; col < numcols; ++col) {
for (base = row, chcnt = col = 0; col < numcols; ++col) {
chcnt += printaname(array[base], dp->s_inode,
dp->s_block);
if (f_sortacross)
base++;
else
base += numrows;
if (base >= num)
if ((base += numrows) >= num)
break;
while ((cnt = ((chcnt + tabwidth) & ~(tabwidth - 1)))
<= endcol) {
if (f_sortacross && col + 1 >= numcols)
break;
(void)putchar(f_notabs ? ' ' : '\t');
chcnt = cnt;
}
@@ -396,15 +361,6 @@ printtime(time_t ftime)
static int
printtype(u_int mode)
{
if (f_slash) {
if ((mode & S_IFMT) == S_IFDIR) {
(void)putchar('/');
return (1);
}
return (0);
}
switch (mode & S_IFMT) {
case S_IFDIR:
(void)putchar('/');
@@ -422,7 +378,6 @@ printtype(u_int mode)
(void)putchar('%');
return (1);
default:
break;
}
if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
(void)putchar('*');
+7 -6
View File
@@ -34,13 +34,14 @@
* SUCH DAMAGE.
*/
#if 0
#ifndef lint
#if 0
static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */
#else
static const char rcsid[] =
"$FreeBSD$";
#endif
#include <sys/types.h>
__FBSDID("$FreeBSD$");
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
@@ -156,9 +157,9 @@ usage(void)
{
(void)fprintf(stderr,
#ifdef COLORLS
"usage: ls [-ABCFGHLPRTWabcdfghiklmnoqrstuwx1]"
"usage: ls [-ABCFGHLPRTWabcdfghiklnoqrstu1]"
#else
"usage: ls [-ABCFHLPRTWabcdfghiklmnoqrstuwx1]"
"usage: ls [-ABCFHLPRTWabcdfghiklnoqrstu1]"
#endif
" [file ...]\n");
exit(1);
+2 -4
View File
@@ -58,12 +58,10 @@ as modified by the current
The options are as follows:
.Pp
.Bl -tag -width indent
.It Fl m Ar mode
.It Fl m
Set the file permission bits of the final created directory to
the specified mode.
The
.Ar mode
argument can be in any of the formats specified to the
The mode argument can be in any of the formats specified to the
.Xr chmod 1
command.
If a symbolic mode is specified, the operation characters
+10 -25
View File
@@ -35,7 +35,7 @@
.\" @(#)mv.1 8.1 (Berkeley) 5/31/93
.\" $FreeBSD$
.\"
.Dd July 9, 2002
.Dd May 31, 1993
.Dt MV 1
.Os
.Sh NAME
@@ -43,11 +43,11 @@
.Nd move files
.Sh SYNOPSIS
.Nm
.Op Fl f | i | n
.Op Fl f | Fl i
.Op Fl v
.Ar source target
.Nm
.Op Fl f | i | n
.Op Fl f | Fl i
.Op Fl v
.Ar source ... directory
.Sh DESCRIPTION
@@ -73,7 +73,7 @@ concatenation of the last operand, a slash, and the final pathname
component of the named file.
.Pp
The following options are available:
.Bl -tag -width indent
.Bl -tag -width flag
.It Fl f
Do not prompt for confirmation before overwriting the destination
path.
@@ -81,8 +81,6 @@ path.
.Fl f
option overrides any previous
.Fl i
or
.Fl n
options.)
.It Fl i
Cause
@@ -90,25 +88,14 @@ Cause
to write a prompt to standard error before moving a file that would
overwrite an existing file.
If the response from the standard input begins with the character
.Ql y
.Sq Li y
or
.Ql Y ,
.Sq Li Y ,
the move is attempted.
(The
.Fl i
option overrides any previous
.Fl f
or
.Fl n
options.)
.It Fl n
Do not overwrite an existing file.
(The
.Fl n
option overrides any previous
.Fl f
or
.Fl i
options.)
.It Fl v
Cause
@@ -127,7 +114,7 @@ prompts the user for confirmation as specified for the
option.
.Pp
As the
.Xr rename 2
.Xr rename 2
call does not work across file systems,
.Nm
uses
@@ -138,8 +125,8 @@ to accomplish the move.
The effect is equivalent to:
.Bd -literal -offset indent
rm -f destination_path && \e
cp -pRP source_file destination && \e
rm -rf source_file
\tcp -pRP source_file destination && \e
\trm -rf source_file
.Ed
.Sh DIAGNOSTICS
.Ex -std
@@ -149,10 +136,8 @@ rm -rf source_file
.Xr symlink 7
.Sh COMPATIBILITY
The
.Fl n
and
.Fl v
options are non-standard and their use in scripts is not recommended.
option is non-standard and its use in scripts is not recommended.
.Sh STANDARDS
The
.Nm
+15 -34
View File
@@ -66,7 +66,7 @@ static const char rcsid[] =
#include "pathnames.h"
int fflg, iflg, nflg, vflg;
int fflg, iflg, vflg;
int copy __P((char *, char *));
int do_move __P((char *, char *));
@@ -85,19 +85,15 @@ main(argc, argv)
int ch;
char path[PATH_MAX];
while ((ch = getopt(argc, argv, "finv")) != -1)
while ((ch = getopt(argc, argv, "fiv")) != -1)
switch (ch) {
case 'i':
iflg = 1;
fflg = nflg = 0;
fflg = 0;
break;
case 'f':
fflg = 1;
iflg = nflg = 0;
break;
case 'n':
nflg = 1;
fflg = iflg = 0;
iflg = 0;
break;
case 'v':
vflg = 1;
@@ -177,11 +173,7 @@ do_move(from, to)
#define YESNO "(y/n [n]) "
ask = 0;
if (nflg) {
if (vflg)
printf("%s not overwritten\n", to);
return (0);
} else if (iflg) {
if (iflg) {
(void)fprintf(stderr, "overwrite %s? %s", to, YESNO);
ask = 1;
} else if (access(to, W_OK) && !stat(to, &sb)) {
@@ -212,25 +204,14 @@ do_move(from, to)
struct statfs sfs;
char path[PATH_MAX];
/*
* If the source is a symbolic link and is on another
* filesystem, it can be recreated at the destination.
*/
if (lstat(from, &sb) == -1) {
warn("%s", from);
/* Can't mv(1) a mount point. */
if (realpath(from, path) == NULL) {
warnx("cannot resolve %s: %s", from, path);
return (1);
}
if (!S_ISLNK(sb.st_mode)) {
/* Can't mv(1) a mount point. */
if (realpath(from, path) == NULL) {
warnx("cannot resolve %s: %s", from, path);
return (1);
}
if (!statfs(path, &sfs) &&
!strcmp(path, sfs.f_mntonname)) {
warnx("cannot rename a mount point");
return (1);
}
if (!statfs(path, &sfs) && !strcmp(path, sfs.f_mntonname)) {
warnx("cannot rename a mount point");
return (1);
}
} else {
warn("rename %s to %s", from, to);
@@ -350,7 +331,7 @@ copy(from, to)
int pid, status;
if ((pid = fork()) == 0) {
execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", "--", from, to,
execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", from, to,
(char *)NULL);
warn("%s", _PATH_CP);
_exit(1);
@@ -369,7 +350,7 @@ copy(from, to)
return (1);
}
if (!(pid = vfork())) {
execl(_PATH_RM, "mv", "-rf", "--", from, (char *)NULL);
execl(_PATH_RM, "mv", "-rf", from, (char *)NULL);
warn("%s", _PATH_RM);
_exit(1);
}
@@ -394,7 +375,7 @@ usage()
{
(void)fprintf(stderr, "%s\n%s\n",
"usage: mv [-f | -i | -n] [-v] source target",
" mv [-f | -i | -n] [-v] source ... directory");
"usage: mv [-f | -i] [-v] source target",
" mv [-f | -i] [-v] source ... directory");
exit(EX_USAGE);
}
+2 -2
View File
@@ -230,7 +230,7 @@ name_uid(uid, frc)
++pwopn;
}
if (ptr == NULL)
ptr = uidtb[uid % UID_SZ] = (UIDC *)malloc(sizeof(UIDC));
ptr = (UIDC *)malloc(sizeof(UIDC));
if ((pw = getpwuid(uid)) == NULL) {
/*
@@ -308,7 +308,7 @@ name_gid(gid, frc)
++gropn;
}
if (ptr == NULL)
ptr = gidtb[gid % GID_SZ] = (GIDC *)malloc(sizeof(GIDC));
ptr = (GIDC *)malloc(sizeof(GIDC));
if ((gr = getgrgid(gid)) == NULL) {
/*
+28 -29
View File
@@ -179,12 +179,12 @@
.Op Ar
.Ar directory
.Sh DESCRIPTION
The
.Nm
utility will read, write, and list the members of an archive file,
.Nm Pax
will read, write, and list the members of an archive file,
and will copy directory hierarchies.
These operations are independent of the specific archive format,
and support a wide variety of different archive formats.
.Nm Pax
operation is independent of the specific archive format,
and supports a wide variety of different archive formats.
A list of supported archive formats can be found under the description of the
.Fl x
option.
@@ -202,7 +202,8 @@ and
.Bl -tag -width 6n
.It <none>
.Em List .
Write to
.Nm Pax
will write to
.Dv standard output
a table of contents of the members of the archive file read from
.Dv standard input ,
@@ -212,7 +213,8 @@ The table of contents contains one filename per line
and is written using single line buffering.
.It Fl r
.Em Read .
Extract the members of the archive file read from the
.Nm Pax
extracts the members of the archive file read from the
.Dv standard input ,
with pathnames matching the specified
.Ar patterns .
@@ -226,7 +228,8 @@ the extracted files are discussed in more detail under the
option.
.It Fl w
.Em Write .
Write an archive containing the
.Nm Pax
writes an archive containing the
.Ar file
operands to
.Dv standard output
@@ -241,7 +244,8 @@ operand is also a directory, the entire file hierarchy rooted
at that directory will be included.
.It Fl r Fl w
.Em Copy .
Copy the
.Nm Pax
copies the
.Ar file
operands to the destination
.Ar directory .
@@ -461,17 +465,15 @@ operand,
will prompt to
.Pa /dev/tty
giving the name of the file, its file mode and its modification time.
The
.Nm
utility will then read a line from
.Nm Pax
will then read a line from
.Pa /dev/tty .
If this line is blank, the file or archive member is skipped.
If this line consists of a single period, the
file or archive member is processed with no modification to its name.
Otherwise, its name is replaced with the contents of the line.
The
.Nm
utility will immediately exit with a non-zero exit status if
.Nm Pax
will immediately exit with a non-zero exit status if
.Dv <EOF>
is encountered when reading a response or if
.Pa /dev/tty
@@ -689,9 +691,8 @@ is not buffered, and is written only after the file has been read or written.
.It Fl x Ar format
Specify the output archive format, with the default format being
.Ar ustar .
The
.Nm
utility currently supports the following formats:
.Nm Pax
currently supports the following formats:
.Bl -tag -width "sv4cpio"
.It Ar cpio
The extended cpio interchange format specified in the
@@ -752,9 +753,8 @@ The default blocksize for this format is 10240 bytes.
Pathnames stored by this format must be 250 characters or less in length.
.El
.Pp
The
.Nm
utility will detect and report any file that it is unable to store or extract
.Nm Pax
will detect and report any file that it is unable to store or extract
as the result of any specific archive format restrictions.
The individual archive formats may impose additional restrictions on use.
Typical archive format restrictions include (but are not limited to):
@@ -1064,13 +1064,13 @@ gives the verbose table of contents for an archive stored in
.Pa filename .
.Pp
The following commands:
.Dl mkdir /tmp/to
.Dl cd /tmp/from
.Dl pax -rw .\ /tmp/to
.Dl mkdir /tmp/foo
.Dl cd /tmp/bar
.Dl pax -rw .\ /tmp/foo
will copy the entire
.Pa /tmp/from
.Pa /tmp/bar
directory hierarchy to
.Pa /tmp/to .
.Pa /tmp/foo .
.Pp
The command:
.Dl pax -r -s ',^//*usr//*,,' -f a.pax
@@ -1145,9 +1145,8 @@ utility appeared in
.An Keith Muller
at the University of California, San Diego
.Sh DIAGNOSTICS
The
.Nm
utility will exit with one of the following values:
.Nm Pax
will exit with one of the following values:
.Bl -tag -width 2n
.It 0
All files were processed successfully.
+1 -2
View File
@@ -104,7 +104,7 @@ int docrc; /* check/create file crc */
char *dirptr; /* destination dir in a copy */
char *argv0; /* root of argv[0] */
sigset_t s_mask; /* signal mask for cleanup critical sect */
FILE *listf; /* file pointer to print file list to */
FILE *listf = stderr; /* file pointer to print file list to */
char *tempfile; /* tempfile to use for mkstemp(3) */
char *tempbase; /* basename of tempfile to use for mkstemp(3) */
@@ -242,7 +242,6 @@ main(argc, argv)
size_t tdlen;
(void) setlocale(LC_ALL, "");
listf = stderr;
/*
* Keep a reference to cwd, so we can always come back home.
*/
+18 -30
View File
@@ -453,13 +453,7 @@ tar_rd(arcn, buf)
* copy out the name and values in the stat buffer
*/
hd = (HD_TAR *)buf;
/*
* old tar format specifies the name always be null-terminated,
* but let's be robust to broken archives.
* the same applies to handling links below.
*/
arcn->nlen = l_strncpy(arcn->name, hd->name,
MIN(sizeof(hd->name), sizeof(arcn->name)) - 1);
arcn->nlen = l_strncpy(arcn->name, hd->name, sizeof(arcn->name) - 1);
arcn->name[arcn->nlen] = '\0';
arcn->sb.st_mode = (mode_t)(asc_ul(hd->mode,sizeof(hd->mode),OCT) &
0xfff);
@@ -488,7 +482,7 @@ tar_rd(arcn, buf)
*/
arcn->type = PAX_SLK;
arcn->ln_nlen = l_strncpy(arcn->ln_name, hd->linkname,
MIN(sizeof(hd->linkname), sizeof(arcn->ln_name)) - 1);
sizeof(arcn->ln_name) - 1);
arcn->ln_name[arcn->ln_nlen] = '\0';
arcn->sb.st_mode |= S_IFLNK;
break;
@@ -500,7 +494,7 @@ tar_rd(arcn, buf)
arcn->type = PAX_HLK;
arcn->sb.st_nlink = 2;
arcn->ln_nlen = l_strncpy(arcn->ln_name, hd->linkname,
MIN(sizeof(hd->linkname), sizeof(arcn->ln_name)) - 1);
sizeof(arcn->ln_name) - 1);
arcn->ln_name[arcn->ln_nlen] = '\0';
/*
@@ -610,7 +604,7 @@ tar_wr(arcn)
case PAX_SLK:
case PAX_HLK:
case PAX_HRG:
if (arcn->ln_nlen >= sizeof(hd->linkname)) {
if (arcn->ln_nlen > sizeof(hd->linkname)) {
paxwarn(1,"Link name too long for tar %s", arcn->ln_name);
return(1);
}
@@ -850,19 +844,12 @@ ustar_rd(arcn, buf)
*/
dest = arcn->name;
if (*(hd->prefix) != '\0') {
cnt = l_strncpy(dest, hd->prefix,
MIN(sizeof(hd->prefix), sizeof(arcn->name) - 2));
cnt = l_strncpy(dest, hd->prefix, sizeof(arcn->name) - 2);
dest += cnt;
*dest++ = '/';
cnt++;
}
/*
* ustar format specifies the name may be unterminated
* if it fills the entire field. this also applies to
* the prefix and the linkname.
*/
arcn->nlen = cnt + l_strncpy(dest, hd->name,
MIN(sizeof(hd->name), sizeof(arcn->name) - cnt - 1));
arcn->nlen = cnt + l_strncpy(dest, hd->name, sizeof(arcn->name) - cnt);
arcn->name[arcn->nlen] = '\0';
/*
@@ -955,7 +942,7 @@ ustar_rd(arcn, buf)
* copy the link name
*/
arcn->ln_nlen = l_strncpy(arcn->ln_name, hd->linkname,
MIN(sizeof(hd->linkname), sizeof(arcn->ln_name) - 1));
sizeof(arcn->ln_name) - 1);
arcn->ln_name[arcn->ln_nlen] = '\0';
break;
case CONTTYPE:
@@ -1012,7 +999,7 @@ ustar_wr(arcn)
* check the length of the linkname
*/
if (((arcn->type == PAX_SLK) || (arcn->type == PAX_HLK) ||
(arcn->type == PAX_HRG)) && (arcn->ln_nlen > sizeof(hd->linkname))){
(arcn->type == PAX_HRG)) && (arcn->ln_nlen >= sizeof(hd->linkname))){
paxwarn(1, "Link name too long for ustar %s", arcn->ln_name);
return(1);
}
@@ -1037,16 +1024,17 @@ ustar_wr(arcn)
* occur, we remove the / and copy the first part to the prefix
*/
*pt = '\0';
l_strncpy(hd->prefix, arcn->name, sizeof(hd->prefix));
l_strncpy(hd->prefix, arcn->name, sizeof(hd->prefix) - 1);
*pt++ = '/';
} else
memset(hd->prefix, 0, sizeof(hd->prefix));
/*
* copy the name part. this may be the whole path or the part after
* the prefix. both the name and prefix may fill the entire field.
* the prefix
*/
l_strncpy(hd->name, pt, sizeof(hd->name));
l_strncpy(hd->name, pt, sizeof(hd->name) - 1);
hd->name[sizeof(hd->name) - 1] = '\0';
/*
* set the fields in the header that are type dependent
@@ -1089,8 +1077,8 @@ ustar_wr(arcn)
hd->typeflag = SYMTYPE;
else
hd->typeflag = LNKTYPE;
/* the link name may occupy the entire field in ustar */
l_strncpy(hd->linkname,arcn->ln_name, sizeof(hd->linkname));
l_strncpy(hd->linkname,arcn->ln_name, sizeof(hd->linkname) - 1);
hd->linkname[sizeof(hd->linkname) - 1] = '\0';
memset(hd->devmajor, 0, sizeof(hd->devmajor));
memset(hd->devminor, 0, sizeof(hd->devminor));
if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3))
@@ -1190,9 +1178,9 @@ name_split(name, len)
* check to see if the file name is small enough to fit in the name
* field. if so just return a pointer to the name.
*/
if (len <= TNMSZ)
if (len < TNMSZ)
return(name);
if (len > (TPFSZ + TNMSZ + 1))
if (len > (TPFSZ + TNMSZ))
return(NULL);
/*
@@ -1201,7 +1189,7 @@ name_split(name, len)
* to find the biggest piece to fit in the name field (or the smallest
* prefix we can find)
*/
start = name + len - TNMSZ - 1;
start = name + len - TNMSZ;
while ((*start != '\0') && (*start != '/'))
++start;
@@ -1219,7 +1207,7 @@ name_split(name, len)
* the file would then expand on extract to //str. The len == 0 below
* makes this special case follow the spec to the letter.
*/
if ((len > TPFSZ) || (len == 0))
if ((len >= TPFSZ) || (len == 0))
return(NULL);
/*
+38 -38
View File
@@ -41,46 +41,46 @@ struct varent;
extern fixpt_t ccpu;
extern int eval, fscale, mempages, nlistread, rawcpu, cflag;
extern time_t now;
extern int sumrusage, termwidth, totwidth;
extern VAR var[];
extern VARENT *vhead;
__BEGIN_DECLS
void command(KINFO *, VARENT *);
void cputime(KINFO *, VARENT *);
int donlist(void);
void evar(KINFO *, VARENT *);
VARENT *find_varentry(VAR *);
const char *fmt_argv(char **, char *, size_t);
double getpcpu(const KINFO *);
void logname(KINFO *, VARENT *);
void longtname(KINFO *, VARENT *);
void lstarted(KINFO *, VARENT *);
void maxrss(KINFO *, VARENT *);
void nlisterr(struct nlist *);
void p_rssize(KINFO *, VARENT *);
void pagein(KINFO *, VARENT *);
void parsefmt(const char *, int);
void pcpu(KINFO *, VARENT *);
void pmem(KINFO *, VARENT *);
void pri(KINFO *, VARENT *);
void rtprior(KINFO *, VARENT *);
void printheader(void);
void pvar(KINFO *, VARENT *);
void rssize(KINFO *, VARENT *);
void runame(KINFO *, VARENT *);
void rvar(KINFO *, VARENT *);
int s_runame(KINFO *);
int s_uname(KINFO *);
void showkey(void);
void started(KINFO *, VARENT *);
void state(KINFO *, VARENT *);
void tdev(KINFO *, VARENT *);
void tname(KINFO *, VARENT *);
void tsize(KINFO *, VARENT *);
void ucomm(KINFO *, VARENT *);
void uname(KINFO *, VARENT *);
void uvar(KINFO *, VARENT *);
void vsize(KINFO *, VARENT *);
void wchan(KINFO *, VARENT *);
void command __P((KINFO *, VARENT *));
void cputime __P((KINFO *, VARENT *));
int donlist __P((void));
void evar __P((KINFO *, VARENT *));
char *fmt_argv __P((char **, char *, int));
double getpcpu __P((KINFO *));
double getpmem __P((KINFO *));
void logname __P((KINFO *, VARENT *));
void longtname __P((KINFO *, VARENT *));
void lstarted __P((KINFO *, VARENT *));
void maxrss __P((KINFO *, VARENT *));
void nlisterr __P((struct nlist *));
void p_rssize __P((KINFO *, VARENT *));
void pagein __P((KINFO *, VARENT *));
void parsefmt __P((char *));
void pcpu __P((KINFO *, VARENT *));
void pmem __P((KINFO *, VARENT *));
void pri __P((KINFO *, VARENT *));
void rtprior __P((KINFO *, VARENT *));
void printheader __P((void));
void pvar __P((KINFO *, VARENT *));
void rssize __P((KINFO *, VARENT *));
void runame __P((KINFO *, VARENT *));
int s_runame __P((KINFO *));
void rvar __P((KINFO *, VARENT *));
void showkey __P((void));
void started __P((KINFO *, VARENT *));
void state __P((KINFO *, VARENT *));
void tdev __P((KINFO *, VARENT *));
void tname __P((KINFO *, VARENT *));
void tsize __P((KINFO *, VARENT *));
void ucomm __P((KINFO *, VARENT *));
void uname __P((KINFO *, VARENT *));
int s_uname __P((KINFO *));
void uvar __P((KINFO *, VARENT *));
void vsize __P((KINFO *, VARENT *));
void wchan __P((KINFO *, VARENT *));
__END_DECLS
+27 -26
View File
@@ -31,40 +31,38 @@
* SUCH DAMAGE.
*/
#if 0
#ifndef lint
#if 0
static char sccsid[] = "@(#)fmt.c 8.4 (Berkeley) 4/15/94";
#endif
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <vis.h>
#include "ps.h"
static char *cmdpart(char *);
static char *shquote(char **);
static char *cmdpart __P((char *));
static char *shquote __P((char **));
/*
* XXX
* This is a stub until marc does the real one.
*/
static char *
shquote(char **argv)
shquote(argv)
char **argv;
{
static long arg_max = -1;
size_t len;
long len;
char **p, *dst, *src;
static char *buf = NULL;
@@ -75,18 +73,18 @@ shquote(char **argv)
errx(1, "malloc failed");
}
if (*argv == NULL) {
buf[0] = '\0';
if (*argv == 0) {
buf[0] = 0;
return (buf);
}
dst = buf;
for (p = argv; (src = *p++) != NULL; ) {
if (*src == '\0')
for (p = argv; (src = *p++) != 0; ) {
if (*src == 0)
continue;
len = (4 * arg_max - (dst - buf)) / 4;
strvisx(dst, src, strlen(src) < len ? strlen(src) : len,
VIS_NL | VIS_CSTYLE);
while (*dst != '\0')
while (*dst)
dst++;
if ((4 * arg_max - (dst - buf)) / 4 > 0)
*dst++ = ' ';
@@ -99,20 +97,24 @@ shquote(char **argv)
}
static char *
cmdpart(char *arg0)
cmdpart(arg0)
char *arg0;
{
char *cp;
return ((cp = strrchr(arg0, '/')) != NULL ? cp + 1 : arg0);
}
const char *
fmt_argv(char **argv, char *cmd, size_t maxlen)
char *
fmt_argv(argv, cmd, maxlen)
char **argv;
char *cmd;
int maxlen;
{
size_t len;
int len;
char *ap, *cp;
if (argv == NULL || argv[0] == NULL) {
if (argv == 0 || argv[0] == 0) {
if (cmd == NULL)
return ("");
ap = NULL;
@@ -121,13 +123,12 @@ fmt_argv(char **argv, char *cmd, size_t maxlen)
ap = shquote(argv);
len = strlen(ap) + maxlen + 4;
}
cp = malloc(len);
if (cp == NULL)
errx(1, "malloc failed");
if ((cp = malloc(len)) == NULL)
return (NULL);
if (ap == NULL)
sprintf(cp, " (%.*s)", (int)maxlen, cmd);
sprintf(cp, " (%.*s)", maxlen, cmd);
else if (strncmp(cmdpart(argv[0]), cmd, maxlen) != 0)
sprintf(cp, "%s (%.*s)", ap, (int)maxlen, cmd);
sprintf(cp, "%s (%.*s)", ap, maxlen, cmd);
else
(void) strcpy(cp, ap);
return (cp);
+31 -51
View File
@@ -31,13 +31,14 @@
* SUCH DAMAGE.
*/
#if 0
#ifndef lint
#if 0
static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94";
#endif /* not lint */
#else
static const char rcsid[] =
"$FreeBSD$";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
@@ -48,15 +49,17 @@ __FBSDID("$FreeBSD$");
#include <sys/user.h>
#include <err.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <utmp.h>
#include "ps.h"
static VAR *findvar(char *, int, char **header);
static int vcmp(const void *, const void *);
static VAR *findvar __P((char *));
static int vcmp __P((const void *, const void *));
#ifdef NOTINUSE
int utime(), stime(), ixrss(), idrss(), isrss();
@@ -77,9 +80,9 @@ int utime(), stime(), ixrss(), idrss(), isrss();
#define UIDLEN 5
#define PIDFMT "d"
#define PIDLEN 5
#define USERLEN (MAXLOGNAME - 1)
#define USERLEN UT_NAMESIZE
static VAR var[] = {
VAR var[] = {
{"%cpu", "%CPU", NULL, 0, pcpu, NULL, 4},
{"%mem", "%MEM", NULL, 0, pmem, NULL, 4},
{"acflag", "ACFLG",
@@ -190,11 +193,11 @@ static VAR var[] = {
};
void
showkey(void)
showkey()
{
VAR *v;
int i;
const char *p, *sep;
char *p, *sep;
i = 0;
sep = "";
@@ -211,45 +214,23 @@ showkey(void)
}
void
parsefmt(const char *p, int user)
parsefmt(p)
char *p;
{
static struct varent *vtail;
char *tempstr, *tempstr1;
#define SKIP_5x_USERCHGS 1
#if SKIP_5x_USERCHGS
/*
* XXX - For now in 4.x-stable, always act as if the user
* explicitly requested this format string. This is
* done to reduce the code-differences with 5.x,
* without making any user-visible changes.
*/
user = 1;
#endif
#define FMTSEP " \t,\n"
tempstr1 = tempstr = strdup(p);
while (tempstr && *tempstr) {
char *cp, *hp;
#define FMTSEP " \t,\n"
while (p && *p) {
char *cp;
VAR *v;
struct varent *vent;
while ((cp = strsep(&tempstr, FMTSEP)) != NULL && *cp == '\0')
while ((cp = strsep(&p, FMTSEP)) != NULL && *cp == '\0')
/* void */;
if (cp == NULL || !(v = findvar(cp, user, &hp)))
if (cp == NULL || !(v = findvar(cp)))
continue;
if (!user) {
/*
* If the user is NOT adding this field manually,
* get on with our lives if this VAR is already
* represented in the list.
*/
vent = find_varentry(v);
if (vent != NULL)
continue;
}
if ((vent = malloc(sizeof(struct varent))) == NULL)
errx(1, "malloc failed");
err(1, NULL);
vent->var = v;
vent->next = NULL;
if (vhead == NULL)
@@ -259,19 +240,17 @@ parsefmt(const char *p, int user)
vtail = vent;
}
}
free(tempstr1);
if (!vhead) {
warnx("no valid keywords; valid keywords:");
showkey();
exit(1);
}
if (!vhead)
errx(1, "no valid keywords");
}
static VAR *
findvar(char *p, int user, char **header __unused)
findvar(p)
char *p;
{
VAR *v, key;
char *hp;
int vcmp();
hp = strchr(p, '=');
if (hp)
@@ -285,19 +264,20 @@ findvar(char *p, int user, char **header __unused)
warnx("%s: illegal keyword specification", p);
eval = 1;
}
parsefmt(v->alias, user);
parsefmt(v->alias);
return ((VAR *)NULL);
}
if (!v) {
warnx("%s: keyword not found", p);
eval = 1;
} else if (hp)
v->header = strdup(hp);
v->header = hp;
return (v);
}
static int
vcmp(const void *a, const void *b)
vcmp(a, b)
const void *a, *b;
{
return (strcmp(((const VAR *)a)->name, ((const VAR *)b)->name));
return (strcmp(((VAR *)a)->name, ((VAR *)b)->name));
}
+5 -8
View File
@@ -31,29 +31,26 @@
* SUCH DAMAGE.
*/
#if 0
#ifndef lint
#if 0
static char sccsid[] = "@(#)nlist.c 8.4 (Berkeley) 4/2/94";
#endif /* not lint */
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/types.h>
#include <sys/sysctl.h>
#include <stddef.h>
int donlist(void); /* should come from extern.h via ps.h */
fixpt_t ccpu; /* kernel _ccpu variable */
int nlistread; /* if nlist already read. */
int mempages; /* number of pages of phys. memory */
int fscale; /* kernel _fscale variable */
int
donlist(void)
donlist()
{
size_t oldlen;
+28 -27
View File
@@ -31,14 +31,13 @@
* SUCH DAMAGE.
*/
#if 0
#ifndef lint
#if 0
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#endif /* not lint */
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
@@ -59,8 +58,8 @@ __FBSDID("$FreeBSD$");
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <string.h>
#include <vis.h>
#include "ps.h"
@@ -70,16 +69,7 @@ printheader()
{
VAR *v;
struct varent *vent;
int allempty;
allempty = 1;
for (vent = vhead; vent; vent = vent->next)
if (*vent->var->header != '\0') {
allempty = 0;
break;
}
if (allempty)
return;
for (vent = vhead; vent; vent = vent->next) {
v = vent->var;
if (v->flag & LJUST) {
@@ -349,29 +339,36 @@ longtname(k, ve)
}
void
started(KINFO *k, VARENT *ve)
started(k, ve)
KINFO *k;
VARENT *ve;
{
VAR *v;
static time_t now;
time_t then;
struct tm *tp;
static int use_ampm = -1;
char buf[100];
static int use_ampm = -1;
v = ve->var;
if (!k->ki_u.u_valid) {
(void)printf("%-*s", v->width, "-");
return;
}
if (use_ampm < 0)
use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0');
then = k->ki_u.u_start.tv_sec;
tp = localtime(&then);
if (!now)
(void)time(&now);
if (now - k->ki_u.u_start.tv_sec < 24 * 3600) {
(void)strftime(buf, sizeof(buf) - 1,
use_ampm ? "%l:%M%p" : "%k:%M ", tp);
use_ampm ? "%l:%M%p" : "%k:%M ", tp);
} else if (now - k->ki_u.u_start.tv_sec < 7 * 86400) {
(void)strftime(buf, sizeof(buf) - 1,
use_ampm ? "%a%I%p" : "%a%H ", tp);
use_ampm ? "%a%I%p" : "%a%H ", tp);
} else
(void)strftime(buf, sizeof(buf) - 1, "%e%b%y", tp);
(void)printf("%-*s", v->width, buf);
@@ -499,7 +496,8 @@ cputime(k, ve)
}
double
getpcpu(const KINFO *k)
getpcpu(k)
KINFO *k;
{
struct proc *p;
static int failure;
@@ -532,8 +530,9 @@ pcpu(k, ve)
(void)printf("%*.1f", v->width, getpcpu(k));
}
static double
getpmem(KINFO *k)
double
getpmem(k)
KINFO *k;
{
static int failure;
struct proc *p;
@@ -580,9 +579,10 @@ pagein(k, ve)
k->ki_u.u_valid ? k->ki_u.u_ru.ru_majflt : 0);
}
/* ARGSUSED */
void
maxrss(KINFO *k __unused, VARENT *ve)
maxrss(k, ve)
KINFO *k;
VARENT *ve;
{
VAR *v;
@@ -639,11 +639,12 @@ rtprior(k, ve)
* structures.
*/
static void
printval(void *bp, VAR *v)
printval(bp, v)
char *bp;
VAR *v;
{
static char ofmt[32] = "%";
const char *fcp;
char *cp;
char *fcp, *cp;
cp = ofmt + 1;
fcp = v->fmt;
+52 -127
View File
@@ -32,7 +32,7 @@
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
.Dd March 27, 2004
.Dd April 18, 1994
.Dt PS 1
.Os
.Sh NAME
@@ -40,64 +40,24 @@
.Nd process status
.Sh SYNOPSIS
.Nm
.Op Fl aCcefhjlmrSTuvwXx
.Oo Fl G Ar gid Ns Xo
.Op , Ns Ar gid Ns No ...
.Xc
.Oc
.Op Fl aCcefhjlmrSTuvwx
.Op Fl M Ar core
.Op Fl N Ar system
.Op Fl O Ar fmt
.Op Fl o Ar fmt
.Oo Fl p Ar pid Ns Xo
.Op , Ns Ar pid Ns No ...
.Xc
.Oc
.Oo Fl t Ar tty Ns Xo
.Op , Ns Ar tty Ns No ...
.Xc
.Oc
.Oo Fl U Ar username Ns Xo
.Op , Ns Ar username Ns No ...
.Xc
.Oc
.Op Fl p Ar pid
.Op Fl t Ar tty
.Op Fl U Ar username
.Nm
.Op Fl L
.Sh DESCRIPTION
The
.Nm
utility
displays a header line, followed by lines containing information about
all of your
.Nm Ps
displays a header line followed by lines containing information about your
processes that have controlling terminals.
.Pp
A different set of processes can be selected for display by using any
combination of the
.Fl a , G , p , T , t
and
.Fl U
options.
If more than one of these options are given, then
.Nm
will select all processes which are matched by at least one of the
given options.
.Pp
For the processes which have been selected for display,
.Nm
will display one line per process.
By default all of these output lines are sorted first by controlling
terminal, then by process
This information is sorted by controlling terminal, then by process
.Tn ID .
The
.Fl m , r , u ,
and
.Fl v
options will change the sort order.
If more than one sorting option was given, then the selected processes
will be sorted by the last sorting option which was specified.
.Pp
For the processes which have been selected for display, the information
to display is selected based on a set of keywords (see the
The information displayed is selected based on a set of keywords (see the
.Fl L
.Fl O
and
@@ -118,10 +78,6 @@ The options are as follows:
.Bl -tag -width indent
.It Fl a
Display information about other users' processes as well as your own.
This will skip any processes which do not have a controlling teminal,
unless the
.Fl x
option is also specified.
This can be disabled by setting the
.Va kern.ps_showallprocs
sysctl to zero.
@@ -137,10 +93,6 @@ Display the environment as well.
.It Fl f
Show commandline and environment information about swapped out processes.
This option is honored only if the uid of the user is 0.
.It Fl G
Display information about processes which are running with the specified
real group
.Tn ID(s) .
.It Fl h
Repeat the information header as often as necessary to guarantee one
header per page of information.
@@ -148,21 +100,17 @@ header per page of information.
Print information associated with the following keywords:
user, pid, ppid, pgid, sess, jobc, state, tt, time and command.
.It Fl L
List the set of keywords available for the
.Fl O
and
.Fl o
options.
List the set of available keywords.
.It Fl l
Display information associated with the following keywords:
uid, pid, ppid, cpu, pri, nice, vsz, rss, wchan, state, tt, time
and command.
.It Fl M
Extract values associated with the name list from the specified core
instead of the currently running system.
instead of the default
.Pa /dev/kmem .
.It Fl m
Sort by memory usage, instead of the combination of controlling
terminal and process
Sort by memory usage, instead of by process
.Tn ID .
.It Fl N
Extract the name list from the specified system instead of the default
@@ -177,20 +125,16 @@ Keywords may be appended with an equals (``='') sign and a string.
This causes the printed header to use the specified string instead of
the standard header.
.It Fl o
Display information associated with the space or comma separated
list of keywords specified.
Multiple keywords may also be given in the form of more than one
.Fl o
option.
Display information associated with the space or comma separated list
of keywords specified.
Keywords may be appended with an equals (``='') sign and a string.
This causes the printed header to use the specified string instead of
the standard header.
.It Fl p
Display information about processes which match the specified process
.Tn ID(s) .
Display information associated with the specified process
.Tn ID .
.It Fl r
Sort by current cpu usage, instead of the combination of controlling
terminal and process
Sort by current cpu usage, instead of by process
.Tn ID .
.It Fl S
Change the way the process time is calculated by summing all exited
@@ -200,10 +144,10 @@ Display information about processes attached to the device associated
with the standard input.
.It Fl t
Display information about processes attached to the specified terminal
device(s).
device.
.It Fl U
Display the processes belonging to the specified
.Ar username Ns (s) .
.Ar username .
.It Fl u
Display information associated with the following keywords:
user, pid, %cpu, %mem, vsz, rss, tt, state, start, time and command.
@@ -229,22 +173,8 @@ If the
option is specified more than once,
.Nm
will use as many columns as necessary without regard for your window size.
.It Fl X
When displaying processes matched by other options, skip any processes
which do not have a controlling terminal.
.It Fl x
When displaying processes matched by other options, include processes
which do not have a controlling terminal.
This is the opposite of the
.Fl X
option.
If both
.Fl X
and
.Fl x
are specified in the same command, then
.Nm
will use the one which was specified last.
Display information about processes without controlling terminals.
.El
.Pp
A complete list of the available keywords are listed below.
@@ -267,6 +197,7 @@ the include file
.It Dv "P_ADVLOCK" Ta No "0x00001 Process may hold a POSIX advisory lock"
.It Dv "P_CONTROLT" Ta No "0x00002 Has a controlling terminal"
.It Dv "P_INMEM" Ta No "0x00004 Loaded into memory"
.It Dv "P_NOCLDSTOP" Ta No "0x00008 No SIGCHLD when children stop"
.It Dv "P_PPWAIT" Ta No "0x00010 Parent is waiting for child to exec/exit"
.It Dv "P_PROFIL" Ta No "0x00020 Has started profiling"
.It Dv "P_SELECT" Ta No "0x00040 Selecting; wakeup/waiting danger"
@@ -280,13 +211,6 @@ the include file
.It Dv "P_EXEC" Ta No "0x04000 Process called exec"
.It Dv "P_OWEUPC" Ta No "0x20000 Owe process an addupc() call at next ast"
.It Dv "P_SWAPPING" Ta No "0x40000 Process is being swapped"
.It Dv "P_SWAPINREQ" Ta No "0x80000 Swapin request due to wakeup"
.It Dv "P_KTHREADP" Ta No "0x200000 Process is really a kernel thread"
.It Dv "P_DEADLKTREAT" Ta No "0x800000 Lock acquisition - deadlock treatment"
.It Dv "P_JAILED" Ta No "0x1000000 Process is in jail"
.It Dv "P_OLDMASK" Ta No "0x2000000 Need to restore mask before pause"
.It Dv "P_ALTSTACK" Ta No "0x4000000 Have alternate signal stack"
.It Dv "P_INEXEC" Ta No "0x8000000 Process is in execve()"
.El
.It lim
The soft limit on memory used, specified via a call to
@@ -308,15 +232,20 @@ If the command started less than 7 days ago, the start time is
displayed using the ``%a6.15p'' format.
Otherwise, the start time is displayed using the ``%e%b%y'' format.
.It state
The state is given by a sequence of characters, for example,
The state is given by a sequence of letters, for example,
.Dq Tn RWNA .
The first character indicates the run state of the process:
The first letter indicates the run state of the process:
.Pp
.Bl -tag -width indent -compact
.It D
Marks a process in disk (or other short term, uninterruptible) wait.
.It I
Marks a process that is idle (sleeping for longer than about 20 seconds).
.It J
Marks a process which is in
.Xr jail 2 .
The hostname of the prison can be found in
.Ql Li /proc/<pid>/status .
.It R
Marks a runnable process.
.It S
@@ -337,13 +266,20 @@ The process is in the foreground process group of its control terminal.
The process has raised
.Tn CPU
scheduling priority.
.It >
The process has specified a soft limit on memory requirements and is
currently exceeding that limit; such a process is (necessarily) not
swapped.
.It A
the process has asked for random page replacement
.Pf ( Dv MADV_RANDOM ,
from
.Xr madvise 2 ,
for example,
.Xr lisp 1
in a garbage collect).
.It E
The process is trying to exit.
.It J
Marks a process which is in
.Xr jail 2 .
The hostname of the prison can be found in
.Ql Li /proc/<pid>/status .
.It L
The process has pages locked in core (for example, for raw
.Tn I/O ) .
@@ -352,11 +288,20 @@ The process has reduced
.Tn CPU
scheduling priority (see
.Xr setpriority 2 ) .
.It S
The process has asked for
.Tn FIFO
page replacement
.Pf ( Dv MADV_SEQUENTIAL ,
from
.Xr madvise 2 ,
for example, a large image processing program using virtual memory to
sequentially address voluminous data).
.It s
The process is a session leader.
.It V
The process is suspended during a
.Xr vfork 2 .
.Xr vfork .
.It W
The process is swapped out.
.It X
@@ -380,9 +325,7 @@ When printing using the command keyword, a process that has exited and
has a parent that has not yet waited for the process (in other words, a zombie)
is listed as ``<defunct>'', and a process which is blocked while trying
to exit is listed as ``<exiting>''.
The
.Nm
utility
.Nm Ps
makes an educated guess as to the file name and arguments given when the
process was created by examining memory or the swap area.
The method is inherently somewhat unreliable and in any event a process
@@ -556,26 +499,8 @@ the mount point of
.Xr procfs 5 ,
.Xr pstat 8 ,
.Xr sysctl 8
.Sh STANDARDS
For historical reasons,
.Nm
utility under
.Fx
supports a different set of options from what is described by
.St -p1003.2 ,
and what is supported on non-BSD operating systems.
.Sh HISTORY
The
.Nm
command appeared in
.At v4 .
.Sh BUGS
Since
.Nm
cannot run faster than the system and is run as any other scheduled
process, the information it displays can never be exact.
.Pp
The
.Nm
utility does not correctly display argument lists containing multibyte
characters.
+251 -770
View File
File diff suppressed because it is too large. Load diff
+7 -11
View File
@@ -48,10 +48,6 @@ struct usave {
#define KI_PROC(ki) (&(ki)->ki_p->kp_proc)
#define KI_EPROC(ki) (&(ki)->ki_p->kp_eproc)
/* These two make it easier to MFC some changes from 5.x. */
#define KI_PROC2(ki) (&(ki)->kp_proc)
#define KI_EPROC2(ki) (&(ki)->kp_eproc)
typedef struct kinfo {
struct kinfo_proc *ki_p; /* proc structure */
struct usave ki_u; /* interesting parts of user */
@@ -66,27 +62,27 @@ typedef struct varent {
} VARENT;
typedef struct var {
const char *name; /* name(s) of variable */
const char *header; /* default header */
const char *alias; /* aliases */
char *name; /* name(s) of variable */
char *header; /* default header */
char *alias; /* aliases */
#define COMM 0x01 /* needs exec arguments and environment (XXX) */
#define LJUST 0x02 /* left adjust on output (trailing blanks) */
#define USER 0x04 /* needs user structure */
#define DSIZ 0x08 /* field size is dynamic*/
u_int flag;
/* output routine */
void (*oproc)(struct kinfo *, struct varent *);
void (*oproc) __P((struct kinfo *, struct varent *));
/* sizing routine*/
int (*sproc)(struct kinfo *);
int (*sproc) __P((struct kinfo *));
short width; /* printing width */
/*
* The following (optional) elements are hooks for passing information
* to the generic output routines: pvar, evar, uvar (those which print
* simple elements from well known structures: proc, eproc, usave)
*/
size_t off; /* offset in structure */
int off; /* offset in structure */
enum type type; /* type of element */
const char *fmt; /* printf format */
char *fmt; /* printf format */
char *time; /* time format */
short dwidth; /* dynamic printing width */
/*
+9 -32
View File
@@ -35,7 +35,7 @@
.\" @(#)pwd.1 8.2 (Berkeley) 4/28/95
.\" $FreeBSD$
.\"
.Dd February 4, 2002
.Dd April 28, 1995
.Dt PWD 1
.Os
.Sh NAME
@@ -43,11 +43,9 @@
.Nd return working directory name
.Sh SYNOPSIS
.Nm
.Op Fl LP
.Sh DESCRIPTION
The
.Nm
utility writes the absolute pathname of the current working directory to
.Nm Pwd
writes the absolute pathname of the current working directory to
the standard output.
.Pp
Some shells may provide a builtin
@@ -56,32 +54,17 @@ command which is similar or identical to this utility.
Consult the
.Xr builtin 1
manual page.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl L
Display the logical current working directory.
.It Fl P
Display the physical current working directory (all symbolic links resolved).
.El
.Pp
If no options are specified, the
.Fl P
option is assumed.
.Sh ENVIRONMENT
Environment variables used by
.Nm :
.Bl -tag -width ".Ev PWD"
.It Ev PWD
Logical current working directory.
.El
.Sh DIAGNOSTICS
.Ex -std
.Sh STANDARDS
The
.Nm
utility conforms to
.St -p1003.1-2001 .
utility is expected to be
.St -p1003.2
compatible.
The
.Fl L
flag is not supported.
.Sh SEE ALSO
.Xr builtin 1 ,
.Xr cd 1 ,
@@ -97,9 +80,3 @@ is always faster because it is built into that shell.
However, it can give a different answer in the rare case
that the current directory or a containing directory was moved after
the shell descended into it.
.Pp
The
.Fl L
option does not work unless the
.Ev PWD
environment variable is exported by the shell.
+27 -61
View File
@@ -45,45 +45,34 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/param.h>
static char *getcwd_logical(void);
void usage(void);
int main __P((int, char *[]));
void usage __P((void));
int
main(int argc, char *argv[])
main(argc, argv)
int argc;
char *argv[];
{
int physical;
int ch;
char *p;
char buf[PATH_MAX];
if (strcmp(getprogname(), "realpath") == 0) {
if (argc != 2)
usage();
if ((p = realpath(argv[1], buf)) == NULL)
err(1, "%s", argv[1]);
(void)printf("%s\n", p);
exit(0);
}
physical = 1;
while ((ch = getopt(argc, argv, "LP")) != -1)
/*
* Flags for pwd are a bit strange. The POSIX 1003.2B/D9 document
* has an optional -P flag for physical, which is what this program
* will produce by default. The logical flag, -L, should fail, as
* there's no way to display a logical path after forking.
*/
while ((ch = getopt(argc, argv, "P")) != -1)
switch (ch) {
case 'L':
physical = 0;
break;
case 'P':
physical = 1;
break;
case '?':
default:
@@ -92,50 +81,27 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
if (argc != 0)
if (argc == 1) {
p = realpath(argv[0], buf);
if (p == NULL)
err(1, "%s", argv[0]);
(void)printf("%s\n", p);
} else if (argc == 0) {
p = getcwd(NULL, (size_t)0);
if (p == NULL)
err(1, ".");
(void)printf("%s\n", p);
} else {
usage();
/*
* If we're trying to find the logical current directory and that
* fails, behave as if -P was specified.
*/
if ((!physical && (p = getcwd_logical()) != NULL) ||
(p = getcwd(NULL, 0)) != NULL)
printf("%s\n", p);
else
err(1, ".");
}
exit(0);
}
void
usage(void)
usage()
{
if (strcmp(getprogname(), "realpath") == 0)
(void)fprintf(stderr, "usage: realpath [path]\n");
else
(void)fprintf(stderr, "usage: pwd [-LP]\n");
exit(1);
}
static char *
getcwd_logical(void)
{
struct stat log, phy;
char *pwd;
/*
* Check that $PWD is an absolute logical pathname referring to
* the current working directory.
*/
if ((pwd = getenv("PWD")) != NULL && *pwd == '/') {
if (stat(pwd, &log) == -1 || stat(".", &phy) == -1)
return (NULL);
if (log.st_dev == phy.st_dev && log.st_ino == phy.st_ino)
return (pwd);
}
errno = ENOENT;
return (NULL);
(void)fprintf(stderr, "usage: pwd\n");
exit(1);
}
+2 -4
View File
@@ -4,13 +4,11 @@
PROG= rcp
SRCS= rcp.c util.c
CFLAGS+=-DBINDIR=${BINDIR}
WARNS= 0
WFORMAT=0
.if defined(MAKE_KERBEROS4) && !defined(NO_OPENSSL) && !defined(NOCRYPT)
.if exists(${DESTDIR}${LIBDIR}/libkrb.a) && defined(MAKE_KERBEROS4)
SRCS+= krcmd.c kcmd.c rcmd_util.c
DPADD= ${LIBUTIL} ${LIBKRB} ${LIBCRYPTO}
CFLAGS+=-DCRYPT -DHAVE_CONFIG_H \
CFLAGS+=-DKERBEROS -DCRYPT -DHAVE_CONFIG_H \
-I${.CURDIR}/../../kerberosIV/include \
-I${.CURDIR}/../../crypto/kerberosIV/include \
-I${.CURDIR}/../../crypto/kerberosIV/lib/roken \
+9 -9
View File
@@ -35,17 +35,17 @@
*/
typedef struct {
size_t cnt;
int cnt;
char *buf;
} BUF;
extern int iamremote;
BUF *allocbuf(BUF *, int, int);
char *colon(char *);
void lostconn(int);
void nospace(void);
int okname(char *);
void run_err(const char *, ...) __printflike(1, 2);
int susystem(char *, int);
void verifydir(char *);
BUF *allocbuf __P((BUF *, int, int));
char *colon __P((char *));
void lostconn __P((int));
void nospace __P((void));
int okname __P((char *));
void run_err __P((const char *, ...)) __printflike(1, 2);
int susystem __P((char *, int));
void verifydir __P((char *));
+42
View File
@@ -0,0 +1,42 @@
/*
* Copyright (c) 1989, 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.
*
* @(#)pathnames.h 8.1 (Berkeley) 5/31/93
* $FreeBSD$
*/
#include <paths.h>
#define _PATH_CP "/bin/cp"
#define _PATH_RCP "/bin/rcp"
#define _PATH_RLOGIN "/usr/bin/rlogin"
#define _PATH_RSH "/usr/bin/rsh"
+2 -6
View File
@@ -40,11 +40,11 @@
.Nd remote file copy
.Sh SYNOPSIS
.Nm
.Op Fl 46Kpx
.Op Fl Kpx
.Op Fl k Ar realm
.Ar file1 file2
.Nm
.Op Fl 46Kprx
.Op Fl Kprx
.Op Fl k Ar realm
.Ar
.Ar directory
@@ -63,10 +63,6 @@ or a `/' before any `:'s).
.Pp
The following options are available:
.Bl -tag -width indent
.It Fl 4
Use IPv4 addresses only.
.It Fl 6
Use IPv6 addresses only.
.It Fl K
Turn off all Kerberos authentication.
.It Fl k
+98 -82
View File
@@ -1,13 +1,6 @@
/*
* Copyright (c) 1983, 1990, 1992, 1993
* The Regents of the University of California. All rights reserved.
* Copyright (c) 2002 Networks Associates Technology, Inc.
* All rights reserved.
*
* Portions of this software were developed for the FreeBSD Project by
* ThinkSec AS and NAI Labs, the Security Research Division of Network
* Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
* ("CBOSS"), as part of the DARPA CHATS research program.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -44,14 +37,13 @@ static char const copyright[] =
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#if 0
#ifndef lint
#if 0
static char sccsid[] = "@(#)rcp.c 8.2 (Berkeley) 4/2/94";
#endif /* not lint */
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
@@ -69,7 +61,6 @@ __FBSDID("$FreeBSD$");
#include <libutil.h>
#include <limits.h>
#include <netdb.h>
#include <paths.h>
#include <pwd.h>
#include <signal.h>
#include <stdio.h>
@@ -78,6 +69,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
#include "pathnames.h"
#include "extern.h"
#ifdef KERBEROS
@@ -88,17 +80,17 @@ __FBSDID("$FreeBSD$");
char dst_realm_buf[REALM_SZ];
char *dest_realm = NULL;
int use_kerberos = 1;
CREDENTIALS cred;
CREDENTIALS cred;
Key_schedule schedule;
extern char *krb_realmofhost();
#ifdef CRYPT
int doencrypt = 0;
#define OPTIONS "46dfKk:prtx"
#define OPTIONS "dfKk:prtx"
#else
#define OPTIONS "46dfKk:prt"
#define OPTIONS "dfKk:prt"
#endif
#else
#define OPTIONS "46dfprt"
#define OPTIONS "dfprt"
#endif
struct passwd *pwd;
@@ -106,7 +98,6 @@ u_short port;
uid_t userid;
int errs, rem;
int pflag, iamremote, iamrecursive, targetshouldbedirectory;
int family = PF_UNSPEC;
static int argc_copy;
static char **argv_copy;
@@ -115,20 +106,22 @@ static char **argv_copy;
char cmd[CMDNEEDS]; /* must hold "rcp -r -p -d\0" */
#ifdef KERBEROS
int kerberos(char **, char *, char *, char *);
void oldw(const char *, ...) __printflike(1, 2);
int kerberos __P((char **, char *, char *, char *));
void oldw __P((const char *, ...)) __printflike(1, 2);
#endif
int response(void);
void rsource(char *, struct stat *);
void run_err(const char *, ...) __printflike(1, 2);
void sink(int, char *[]);
void source(int, char *[]);
void tolocal(int, char *[]);
void toremote(char *, int, char *[]);
void usage(void);
int response __P((void));
void rsource __P((char *, struct stat *));
void run_err __P((const char *, ...)) __printflike(1, 2);
void sink __P((int, char *[]));
void source __P((int, char *[]));
void tolocal __P((int, char *[]));
void toremote __P((char *, int, char *[]));
void usage __P((void));
int
main(int argc, char *argv[])
main(argc, argv)
int argc;
char *argv[];
{
struct servent *sp;
int ch, fflag, i, tflag;
@@ -156,14 +149,6 @@ main(int argc, char *argv[])
fflag = tflag = 0;
while ((ch = getopt(argc, argv, OPTIONS)) != -1)
switch(ch) { /* User-visible flags. */
case '4':
family = PF_INET;
break;
case '6':
family = PF_INET6;
break;
case 'K':
#ifdef KERBEROS
use_kerberos = 0;
@@ -284,7 +269,9 @@ main(int argc, char *argv[])
}
void
toremote(char *targ, int argc, char *argv[])
toremote(targ, argc, argv)
char *targ, *argv[];
int argc;
{
int i, len, tos;
char *bp, *host, *src, *suser, *thost, *tuser;
@@ -317,7 +304,7 @@ toremote(char *targ, int argc, char *argv[])
strlen(src) + (tuser ? strlen(tuser) : 0) +
strlen(thost) + strlen(targ) + CMDNEEDS + 20;
if (!(bp = malloc(len)))
err(1, "malloc");
err(1, NULL);
if (host) {
*host++ = 0;
suser = argv[i];
@@ -344,7 +331,7 @@ toremote(char *targ, int argc, char *argv[])
if (rem == -1) {
len = strlen(targ) + CMDNEEDS + 20;
if (!(bp = malloc(len)))
err(1, "malloc");
err(1, NULL);
(void)snprintf(bp, len, "%s -t %s", cmd, targ);
host = thost;
#ifdef KERBEROS
@@ -354,18 +341,15 @@ toremote(char *targ, int argc, char *argv[])
tuser ? tuser : pwd->pw_name);
else
#endif
rem = rcmd_af(&host, port,
pwd->pw_name,
rem = rcmd(&host, port, pwd->pw_name,
tuser ? tuser : pwd->pw_name,
bp, 0, family);
bp, 0);
if (rem < 0)
exit(1);
if (family == PF_INET) {
tos = IPTOS_THROUGHPUT;
if (setsockopt(rem, IPPROTO_IP, IP_TOS,
&tos, sizeof(int)) < 0)
warn("TOS (ignored)");
}
tos = IPTOS_THROUGHPUT;
if (setsockopt(rem, IPPROTO_IP, IP_TOS,
&tos, sizeof(int)) < 0)
warn("TOS (ignored)");
if (response() < 0)
exit(1);
(void)free(bp);
@@ -377,7 +361,9 @@ toremote(char *targ, int argc, char *argv[])
}
void
tolocal(int argc, char *argv[])
tolocal(argc, argv)
int argc;
char *argv[];
{
int i, len, tos;
char *bp, *host, *src, *suser;
@@ -387,7 +373,7 @@ tolocal(int argc, char *argv[])
len = strlen(_PATH_CP) + strlen(argv[i]) +
strlen(argv[argc - 1]) + 20;
if (!(bp = malloc(len)))
err(1, "malloc");
err(1, NULL);
(void)snprintf(bp, len, "exec %s%s%s %s %s", _PATH_CP,
iamrecursive ? " -PR" : "", pflag ? " -p" : "",
argv[i], argv[argc - 1]);
@@ -414,27 +400,23 @@ tolocal(int argc, char *argv[])
}
len = strlen(src) + CMDNEEDS + 20;
if ((bp = malloc(len)) == NULL)
err(1, "malloc");
err(1, NULL);
(void)snprintf(bp, len, "%s -f %s", cmd, src);
rem =
#ifdef KERBEROS
use_kerberos ?
kerberos(&host, bp, pwd->pw_name, suser) :
#endif
rcmd_af(&host, port, pwd->pw_name, suser, bp, 0,
family);
rcmd(&host, port, pwd->pw_name, suser, bp, 0);
(void)free(bp);
if (rem < 0) {
++errs;
continue;
}
(void)seteuid(userid);
if (family == PF_INET) {
tos = IPTOS_THROUGHPUT;
if (setsockopt(rem, IPPROTO_IP, IP_TOS, &tos,
sizeof(int)) < 0)
warn("TOS (ignored)");
}
tos = IPTOS_THROUGHPUT;
if (setsockopt(rem, IPPROTO_IP, IP_TOS, &tos, sizeof(int)) < 0)
warn("TOS (ignored)");
sink(1, argv + argc - 1);
(void)seteuid(0);
(void)close(rem);
@@ -443,7 +425,9 @@ tolocal(int argc, char *argv[])
}
void
source(int argc, char *argv[])
source(argc, argv)
int argc;
char *argv[];
{
struct stat stb;
static BUF buffer;
@@ -453,7 +437,7 @@ source(int argc, char *argv[])
char *last, *name, buf[BUFSIZ];
for (indx = 0; indx < argc; ++indx) {
name = argv[indx];
name = argv[indx];
if ((fd = open(name, O_RDONLY, 0)) < 0)
goto syserr;
if (fstat(fd, &stb)) {
@@ -529,7 +513,9 @@ next: (void)close(fd);
}
void
rsource(char *name, struct stat *statp)
rsource(name, statp)
char *name;
struct stat *statp;
{
DIR *dirp;
struct dirent *dp;
@@ -580,7 +566,9 @@ rsource(char *name, struct stat *statp)
}
void
sink(int argc, char *argv[])
sink(argc, argv)
int argc;
char *argv[];
{
static BUF buffer;
struct stat stb;
@@ -590,7 +578,7 @@ sink(int argc, char *argv[])
off_t i, j, size;
int amt, count, exists, first, mask, mode, ofd, omode;
int setimes, targisdir, wrerrno = 0;
char ch, *cp, *np, *targ, *why, *vect[1], buf[BUFSIZ], path[PATH_MAX];
char ch, *cp, *np, *targ, *why, *vect[1], buf[BUFSIZ];
#define atime tv[0]
#define mtime tv[1]
@@ -687,15 +675,18 @@ sink(int argc, char *argv[])
if (*cp++ != ' ')
SCREWUP("size not delimited");
if (targisdir) {
if (strlen(targ) + (*targ ? 1 : 0) + strlen(cp)
>= sizeof(path)) {
run_err("%s%s%s: name too long", targ,
*targ ? "/" : "", cp);
exit(1);
static char *namebuf;
static int cursize;
size_t need;
need = strlen(targ) + strlen(cp) + 250;
if (need > cursize) {
if (!(namebuf = malloc(need)))
run_err("%s", strerror(errno));
}
(void)snprintf(path, sizeof(path), "%s%s%s", targ,
(void)snprintf(namebuf, need, "%s%s%s", targ,
*targ ? "/" : "", cp);
np = path;
np = namebuf;
} else
np = targ;
exists = stat(np, &stb) == 0;
@@ -815,7 +806,8 @@ screwup:
#ifdef KERBEROS
int
kerberos(char **host, char *bp, char *locuser, char *user)
kerberos(host, bp, locuser, user)
char **host, *bp, *locuser, *user;
{
if (use_kerberos) {
setuid(getuid());
@@ -845,14 +837,14 @@ kerberos(char **host, char *bp, char *locuser, char *user)
errx(1,
"the -x option requires Kerberos authentication");
#endif
rem = rcmd_af(host, port, locuser, user, bp, 0, family);
rem = rcmd(host, port, locuser, user, bp, 0);
}
return (rem);
}
#endif /* KERBEROS */
int
response(void)
response()
{
char ch, *cp, resp, rbuf[BUFSIZ];
@@ -885,34 +877,48 @@ response(void)
}
void
usage(void)
usage()
{
#ifdef KERBEROS
#ifdef CRYPT
(void)fprintf(stderr, "%s\n%s\n",
"usage: rcp [-46Kpx] [-k realm] f1 f2",
" rcp [-46Kprx] [-k realm] f1 ... fn directory");
"usage: rcp [-Kpx] [-k realm] f1 f2",
" rcp [-Kprx] [-k realm] f1 ... fn directory");
#else
(void)fprintf(stderr, "%s\n%s\n",
"usage: rcp [-46Kp] [-k realm] f1 f2",
" rcp [-46Kpr] [-k realm] f1 ... fn directory");
"usage: rcp [-Kp] [-k realm] f1 f2",
" rcp [-Kpr] [-k realm] f1 ... fn directory");
#endif
#else
(void)fprintf(stderr, "%s\n%s\n",
"usage: rcp [-46p] f1 f2",
" rcp [-46pr] f1 ... fn directory");
"usage: rcp [-p] f1 f2",
" rcp [-pr] f1 ... fn directory");
#endif
exit(1);
}
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#ifdef KERBEROS
void
#if __STDC__
oldw(const char *fmt, ...)
#else
oldw(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)fprintf(stderr, "rcp: ");
(void)vfprintf(stderr, fmt, ap);
(void)fprintf(stderr, ", using standard rcp\n");
@@ -921,11 +927,21 @@ oldw(const char *fmt, ...)
#endif
void
#if __STDC__
run_err(const char *fmt, ...)
#else
run_err(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
static FILE *fp;
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
++errs;
if (fp == NULL && !(fp = fdopen(rem, "w")))
+16 -8
View File
@@ -35,9 +35,9 @@
#if 0
static char sccsid[] = "@(#)util.c 8.2 (Berkeley) 4/2/94";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/stat.h>
@@ -56,7 +56,8 @@ __FBSDID("$FreeBSD$");
#include "extern.h"
char *
colon(char *cp)
colon(cp)
char *cp;
{
if (*cp == ':') /* Leading colon is part of file name. */
return (0);
@@ -71,7 +72,8 @@ colon(char *cp)
}
void
verifydir(char *cp)
verifydir(cp)
char *cp;
{
struct stat stb;
@@ -85,7 +87,8 @@ verifydir(char *cp)
}
int
okname(char *cp0)
okname(cp0)
char *cp0;
{
int c;
char *cp;
@@ -105,7 +108,9 @@ bad: warnx("%s: invalid user name", cp0);
}
int
susystem(char *s, int userid)
susystem(s, userid)
int userid;
char *s;
{
sig_t istat, qstat;
int status;
@@ -131,7 +136,9 @@ susystem(char *s, int userid)
}
BUF *
allocbuf(BUF *bp, int fd, int blksize)
allocbuf(bp, fd, blksize)
BUF *bp;
int fd, blksize;
{
struct stat stb;
size_t size;
@@ -155,7 +162,8 @@ allocbuf(BUF *bp, int fd, int blksize)
}
void
lostconn(int signo)
lostconn(signo)
int signo;
{
if (!iamremote)
warnx("lost connection");
+2
View File
@@ -2,6 +2,8 @@
# $FreeBSD$
PROG= rm
WARNS?= 2
SRCS= rm.c
LINKS= ${BINDIR}/rm ${BINDIR}/unlink
MLINKS= rm.1 unlink.1
+25 -37
View File
@@ -1,4 +1,3 @@
.\"-
.\" Copyright (c) 1990, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -13,6 +12,10 @@
.\" 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.
@@ -32,7 +35,7 @@
.\" @(#)rm.1 8.5 (Berkeley) 12/5/94
.\" $FreeBSD$
.\"
.Dd September 29, 2005
.Dd January 28, 1999
.Dt RM 1
.Os
.Sh NAME
@@ -41,8 +44,7 @@
.Nd remove directory entries
.Sh SYNOPSIS
.Nm
.Op Fl f | i
.Op Fl dIPRrvW
.Op Fl dfiPRrvW
.Ar
.Nm unlink
.Ar file
@@ -78,20 +80,10 @@ The
option overrides any previous
.Fl f
options.
.It Fl I
Request confirmation once if more than three files are being removed or if a
directory is being recursively removed.
This is a far less intrusive option than
.Fl i
yet provides almost the same level of protection against mistakes.
.It Fl P
Overwrite regular files before deleting them.
Files are overwritten three times, first with the byte pattern 0xff,
then 0x00, and then 0xff again, before they are deleted.
Specifying this flag for a read only file will cause
.Nm
to generate an error message and exit.
The file wil not be removed or overwritten.
.It Fl R
Attempt to remove the file hierarchy rooted in each file argument.
The
@@ -123,10 +115,9 @@ The
utility removes symbolic links, not the files referenced by the links.
.Pp
It is an error to attempt to remove the files
.Pa / ,
.Pa .\&
.Dq .\&
or
.Pa .. .
.Dq .. .
.Pp
When the utility is called as
.Nm unlink ,
@@ -157,17 +148,30 @@ to parse its arguments, which allows it to accept
the
.Sq Li --
option which will cause it to stop processing flag options at that
point.
This will allow the removal of file names that begin
point. This will allow the removal of file names that begin
with a dash
.Pq Sq - .
For example:
.Dl rm -- -filename
The same behavior can be obtained by using an absolute or relative
path reference.
For example:
path reference. For example:
.Dl rm /home/user/-filename
.Dl rm ./-filename
.Sh SEE ALSO
.Xr rmdir 1 ,
.Xr undelete 2 ,
.Xr unlink 2 ,
.Xr fts 3 ,
.Xr getopt 3 ,
.Xr symlink 7
.Sh BUGS
The
.Fl P
option assumes that the underlying file system is a fixed-block file
system.
UFS is a fixed-block file system, LFS is not.
In addition, only regular files are overwritten, other types of files
are not.
.Sh COMPATIBILITY
The
.Nm
@@ -183,14 +187,6 @@ Also, historical
.Bx
implementations prompted on the standard output,
not the standard error output.
.Sh SEE ALSO
.Xr chflags 1 ,
.Xr rmdir 1 ,
.Xr undelete 2 ,
.Xr unlink 2 ,
.Xr fts 3 ,
.Xr getopt 3 ,
.Xr symlink 7
.Sh STANDARDS
The
.Nm
@@ -206,11 +202,3 @@ A
.Nm
command appeared in
.At v1 .
.Sh BUGS
The
.Fl P
option assumes that the underlying file system is a fixed-block file
system.
UFS is a fixed-block file system, LFS is not.
In addition, only regular files are overwritten, other types of files
are not.
+54 -148
View File
@@ -10,6 +10,10 @@
* 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.
@@ -27,7 +31,6 @@
* SUCH DAMAGE.
*/
#if 0
#ifndef lint
static const char copyright[] =
"@(#) Copyright (c) 1990, 1993, 1994\n\
@@ -35,11 +38,13 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94";
#endif /* not lint */
#else
static const char rcsid[] =
"$FreeBSD$";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif /* not lint */
#include <sys/stat.h>
#include <sys/param.h>
@@ -49,8 +54,6 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <fcntl.h>
#include <fts.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -58,29 +61,28 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok;
int rflag, Iflag;
uid_t uid;
int check(char *, char *, struct stat *);
int check2(char **);
void checkdot(char **);
void checkslash(char **);
void rm_file(char **);
int rm_overwrite(char *, struct stat *);
void rm_tree(char **);
void usage(void);
int check __P((char *, char *, struct stat *));
void checkdot __P((char **));
void rm_file __P((char **));
void rm_overwrite __P((char *, struct stat *));
void rm_tree __P((char **));
void usage __P((void));
/*
* rm --
* This rm is different from historic rm's, but is expected to match
* POSIX 1003.2 behavior. The most visible difference is that -f
* POSIX 1003.2 behavior. The most visible difference is that -f
* has two specific effects now, ignore non-existent files and force
* file removal.
* file removal.
*/
int
main(int argc, char *argv[])
main(argc, argv)
int argc;
char *argv[];
{
int ch;
int ch, rflag;
char *p;
/*
@@ -93,18 +95,15 @@ main(int argc, char *argv[])
else
++p;
if (strcmp(p, "unlink") == 0) {
while (getopt(argc, argv, "") != -1)
if (argc == 2) {
rm_file(&argv[1]);
exit(eval);
} else
usage();
argc -= optind;
argv += optind;
if (argc != 1)
usage();
rm_file(&argv[0]);
exit(eval);
}
Pflag = rflag = 0;
while ((ch = getopt(argc, argv, "dfiIPRrvW")) != -1)
while ((ch = getopt(argc, argv, "dfiPRrvW")) != -1)
switch(ch) {
case 'd':
dflag = 1;
@@ -117,9 +116,6 @@ main(int argc, char *argv[])
fflag = 0;
iflag = 1;
break;
case 'I':
Iflag = 1;
break;
case 'P':
Pflag = 1;
break;
@@ -141,22 +137,16 @@ main(int argc, char *argv[])
if (argc < 1) {
if (fflag)
return (0);
return 0;
usage();
}
checkdot(argv);
if (getenv("POSIXLY_CORRECT") == NULL)
checkslash(argv);
uid = geteuid();
if (*argv) {
stdin_ok = isatty(STDIN_FILENO);
if (Iflag) {
if (check2(argv) == 0)
exit (1);
}
if (rflag)
rm_tree(argv);
else
@@ -167,7 +157,8 @@ main(int argc, char *argv[])
}
void
rm_tree(char **argv)
rm_tree(argv)
char **argv;
{
FTS *fts;
FTSENT *p;
@@ -192,11 +183,8 @@ rm_tree(char **argv)
flags |= FTS_NOSTAT;
if (Wflag)
flags |= FTS_WHITEOUT;
if (!(fts = fts_open(argv, flags, NULL))) {
if (fflag && errno == ENOENT)
return;
err(1, "fts_open");
}
if (!(fts = fts_open(argv, flags, NULL)))
err(1, NULL);
while ((p = fts_read(fts)) != NULL) {
switch (p->fts_info) {
case FTS_DNR:
@@ -210,8 +198,8 @@ rm_tree(char **argv)
errx(1, "%s: %s", p->fts_path, strerror(p->fts_errno));
case FTS_NS:
/*
* Assume that since fts_read() couldn't stat the
* file, it can't be unlinked.
* FTS_NS: assume that if can't stat the file, it
* can't be unlinked.
*/
if (!needstat)
break;
@@ -280,18 +268,9 @@ rm_tree(char **argv)
}
break;
case FTS_NS:
/*
* Assume that since fts_read() couldn't stat
* the file, it can't be unlinked.
*/
if (fflag)
continue;
/* FALLTHROUGH */
default:
if (Pflag)
if (!rm_overwrite(p->fts_accpath, NULL))
continue;
rm_overwrite(p->fts_accpath, NULL);
rval = unlink(p->fts_accpath);
if (rval == 0 || (fflag && errno == ENOENT)) {
if (rval == 0 && vflag)
@@ -310,7 +289,8 @@ err:
}
void
rm_file(char **argv)
rm_file(argv)
char **argv;
{
struct stat sb;
int rval;
@@ -357,8 +337,7 @@ rm_file(char **argv)
rval = rmdir(f);
else {
if (Pflag)
if (!rm_overwrite(f, &sb))
continue;
rm_overwrite(f, &sb);
rval = unlink(f);
}
}
@@ -382,8 +361,10 @@ rm_file(char **argv)
* System V file system). In a logging file system, you'll have to have
* kernel support.
*/
int
rm_overwrite(char *file, struct stat *sbp)
void
rm_overwrite(file, sbp)
char *file;
struct stat *sbp;
{
struct stat sb;
struct statfs fsb;
@@ -398,14 +379,14 @@ rm_overwrite(char *file, struct stat *sbp)
sbp = &sb;
}
if (!S_ISREG(sbp->st_mode))
return (1);
return;
if ((fd = open(file, O_WRONLY, 0)) == -1)
goto err;
if (fstatfs(fd, &fsb) == -1)
goto err;
bsize = MAX(fsb.f_iosize, 1024);
if ((buf = malloc(bsize)) == NULL)
err(1, "%s: malloc", file);
err(1, "malloc");
#define PASS(byte) { \
memset(buf, byte, bsize); \
@@ -424,21 +405,20 @@ rm_overwrite(char *file, struct stat *sbp)
PASS(0xff);
if (!fsync(fd) && !close(fd)) {
free(buf);
return (1);
return;
}
err: eval = 1;
if (buf)
free(buf);
if (fd != -1)
close(fd);
warn("%s", file);
return (0);
}
int
check(char *path, char *name, struct stat *sp)
check(path, name, sp)
char *path, *name;
struct stat *sp;
{
int ch, first;
char modep[15], *flagsp;
@@ -449,7 +429,7 @@ check(char *path, char *name, struct stat *sp)
else {
/*
* If it's not a symbolic link and it's unwritable and we're
* talking to a terminal, ask. Symbolic links are excluded
* talking to a terminal, ask. Symbolic links are excluded
* because their permissions are meaningless. Check stdin_ok
* first because we may not have stat'ed the file.
*/
@@ -460,16 +440,12 @@ check(char *path, char *name, struct stat *sp)
return (1);
strmode(sp->st_mode, modep);
if ((flagsp = fflagstostr(sp->st_flags)) == NULL)
err(1, "fflagstostr");
if (Pflag)
errx(1,
"%s: -P was specified, but file is not writable",
path);
err(1, NULL);
(void)fprintf(stderr, "override %s%s%s/%s %s%sfor %s? ",
modep + 1, modep[9] == ' ' ? "" : " ",
user_from_uid(sp->st_uid, 0),
group_from_gid(sp->st_gid, 0),
*flagsp ? flagsp : "", *flagsp ? " " : "",
*flagsp ? flagsp : "", *flagsp ? " " : "",
path);
free(flagsp);
}
@@ -481,80 +457,10 @@ check(char *path, char *name, struct stat *sp)
return (first == 'y' || first == 'Y');
}
#define ISSLASH(a) ((a)[0] == '/' && (a)[1] == '\0')
void
checkslash(char **argv)
{
char **t, **u;
int complained;
complained = 0;
for (t = argv; *t;) {
if (ISSLASH(*t)) {
if (!complained++)
warnx("\"/\" may not be removed");
eval = 1;
for (u = t; u[0] != NULL; ++u)
u[0] = u[1];
} else {
++t;
}
}
}
int
check2(char **argv)
{
struct stat st;
int first;
int ch;
int fcount = 0;
int dcount = 0;
int i;
const char *dname = NULL;
for (i = 0; argv[i]; ++i) {
if (lstat(argv[i], &st) == 0) {
if (S_ISDIR(st.st_mode)) {
++dcount;
dname = argv[i]; /* only used if 1 dir */
} else {
++fcount;
}
}
}
first = 0;
while (first != 'n' && first != 'N' && first != 'y' && first != 'Y') {
if (dcount && rflag) {
fprintf(stderr, "recursively remove");
if (dcount == 1)
fprintf(stderr, " %s", dname);
else
fprintf(stderr, " %d dirs", dcount);
if (fcount == 1)
fprintf(stderr, " and 1 file");
else if (fcount > 1)
fprintf(stderr, " and %d files", fcount);
} else if (dcount + fcount > 3) {
fprintf(stderr, "remove %d files", dcount + fcount);
} else {
return(1);
}
fprintf(stderr, "? ");
fflush(stderr);
first = ch = getchar();
while (ch != '\n' && ch != EOF)
ch = getchar();
if (ch == EOF)
break;
}
return (first == 'y' || first == 'Y');
}
#define ISDOT(a) ((a)[0] == '.' && (!(a)[1] || ((a)[1] == '.' && !(a)[2])))
void
checkdot(char **argv)
checkdot(argv)
char **argv;
{
char *p, **save, **t;
int complained;
@@ -578,11 +484,11 @@ checkdot(char **argv)
}
void
usage(void)
usage()
{
(void)fprintf(stderr, "%s\n%s\n",
"usage: rm [-f | -i] [-dIPRrvW] file ...",
"usage: rm [-f | -i] [-dPRrvW] file ...",
" unlink file");
exit(EX_USAGE);
}
-1
View File
@@ -2,7 +2,6 @@
# $FreeBSD$
PROG= sh
INSTALLFLAGS= -S
SHSRCS= alias.c arith.y arith_lex.l cd.c echo.c error.c eval.c exec.c expand.c \
histedit.c input.c jobs.c mail.c main.c memalloc.c miscbltin.c \
mystring.c options.c output.c parser.c printf.c redir.c show.c \
+28 -26
View File
@@ -38,9 +38,9 @@
#if 0
static char sccsid[] = "@(#)alias.c 8.3 (Berkeley) 5/4/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <stdlib.h>
#include "shell.h"
@@ -54,15 +54,16 @@ __FBSDID("$FreeBSD$");
#define ATABSIZE 39
STATIC struct alias *atab[ATABSIZE];
struct alias *atab[ATABSIZE];
STATIC void setalias(char *, char *);
STATIC int unalias(char *);
STATIC struct alias **hashalias(char *);
STATIC void setalias __P((char *, char *));
STATIC int unalias __P((char *));
STATIC struct alias **hashalias __P((char *));
STATIC
void
setalias(char *name, char *val)
setalias(name, val)
char *name, *val;
{
struct alias *ap, **app;
@@ -115,8 +116,9 @@ setalias(char *name, char *val)
}
STATIC int
unalias(char *name)
{
unalias(name)
char *name;
{
struct alias *ap, **app;
app = hashalias(name);
@@ -156,8 +158,7 @@ SHELLPROC {
#endif
void
rmaliases(void)
{
rmaliases() {
struct alias *ap, *tmp;
int i;
@@ -177,7 +178,9 @@ rmaliases(void)
}
struct alias *
lookupalias(char *name, int check)
lookupalias(name, check)
char *name;
int check;
{
struct alias *ap = *hashalias(name);
@@ -196,7 +199,9 @@ lookupalias(char *name, int check)
* TODO - sort output
*/
int
aliascmd(int argc, char **argv)
aliascmd(argc, argv)
int argc;
char **argv;
{
char *n, *v;
int ret = 0;
@@ -207,11 +212,8 @@ aliascmd(int argc, char **argv)
for (i = 0; i < ATABSIZE; i++)
for (ap = atab[i]; ap; ap = ap->next) {
if (*ap->name != '\0') {
out1fmt("alias %s=", ap->name);
out1qstr(ap->val);
out1c('\n');
}
if (*ap->name != '\0')
out1fmt("alias %s=%s\n", ap->name, ap->val);
}
return (0);
}
@@ -220,11 +222,8 @@ aliascmd(int argc, char **argv)
if ((ap = lookupalias(n, 0)) == NULL) {
outfmt(out2, "alias: %s not found\n", n);
ret = 1;
} else {
out1fmt("alias %s=", n);
out1qstr(ap->val);
out1c('\n');
}
} else
out1fmt("alias %s=%s\n", n, ap->val);
else {
*v++ = '\0';
setalias(n, v);
@@ -235,7 +234,9 @@ aliascmd(int argc, char **argv)
}
int
unaliascmd(int argc __unused, char **argv __unused)
unaliascmd(argc, argv)
int argc __unused;
char **argv __unused;
{
int i;
@@ -252,8 +253,9 @@ unaliascmd(int argc __unused, char **argv __unused)
}
STATIC struct alias **
hashalias(char *p)
{
hashalias(p)
char *p;
{
unsigned int hashval;
hashval = *p << 4;
+4 -4
View File
@@ -46,7 +46,7 @@ struct alias {
int flag;
};
struct alias *lookupalias(char *, int);
int aliascmd(int, char **);
int unaliascmd(int, char **);
void rmaliases(void);
struct alias *lookupalias __P((char *, int));
int aliascmd __P((int, char **));
int unaliascmd __P((int, char **));
void rmaliases __P((void));
+2 -2
View File
@@ -34,5 +34,5 @@
* $FreeBSD$
*/
int arith(char *);
int expcmd(int , char **);
int arith __P((char *));
int expcmd __P((int , char **));
+15 -8
View File
@@ -87,6 +87,8 @@ expr: ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; }
* 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$
*/
#ifndef lint
@@ -105,11 +107,12 @@ static const char rcsid[] =
char *arith_buf, *arith_startbuf;
extern void arith_lex_reset();
int yylex(void);
int yyparse(void);
int yylex __P((void));
int yyparse __P((void));
int
arith(char *s)
arith(s)
char *s;
{
long result;
@@ -124,7 +127,8 @@ arith(char *s)
}
void
yyerror(char *s)
yyerror(s)
char *s;
{
yyerrok;
@@ -137,7 +141,9 @@ yyerror(char *s)
* The exp(1) builtin.
*/
int
expcmd(int argc, char **argv)
expcmd(argc, argv)
int argc;
char **argv;
{
char *p;
char *concat;
@@ -174,12 +180,13 @@ expcmd(int argc, char **argv)
/*************************/
#ifdef TEST_ARITH
#include <stdio.h>
main(int argc, char *argv[])
main(argc, argv)
char *argv[];
{
printf("%d\n", exp(argv[1]));
}
error(char *s)
error(s)
char *s;
{
fprintf(stderr, "exp: %s\n", s);
exit(1);
+3 -2
View File
@@ -33,6 +33,8 @@
* 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$
*/
#ifndef lint
@@ -83,7 +85,6 @@ extern char *arith_buf, *arith_startbuf;
%%
void
arith_lex_reset()
{
arith_lex_reset() {
YY_NEW_FILE;
}
+5
View File
@@ -83,8 +83,13 @@
#define INITARGS(argv) if ((commandname = argv[0]) == NULL) {fputs("Argc is zero\n", stderr); exit(2);} else
#endif
#ifdef __STDC__
pointer stalloc(int);
void error(const char *, ...) __printf0like(1, 2);
#else
pointer stalloc();
void error();
#endif
extern char *commandname;
+1 -3
View File
@@ -92,9 +92,7 @@ Output a (horizontal) tab character.
Output a vertical tab.
.It Li \e0 Ns Ar digits
Output the character whose value is given by zero to three digits.
If there are zero digits, a
.Dv NUL
character is output.
If there are zero digits, a nul character is output.
.It Li \e\e
Output a backslash.
.El
+4 -2
View File
@@ -48,7 +48,9 @@
/* #define eflag 1 */
int
main(int argc, char *argv[])
main(argc, argv)
int argc;
char **argv;
{
char **ap;
char *p;
@@ -80,7 +82,7 @@ main(int argc, char *argv[])
case 'a': c = '\a'; break;
case 'b': c = '\b'; break;
case 'c': return 0; /* exit */
case 'e': c = '\033'; break;
case 'e': c = '\e'; break;
case 'f': c = '\f'; break;
case 'n': c = '\n'; break;
case 'r': c = '\r'; break;
+1 -3
View File
@@ -49,8 +49,7 @@
#
# NOTE: bltincmd must come first!
bltincmd builtin
commandcmd command
bltincmd command
#alloccmd alloc
bgcmd -j bg
breakcmd break continue
@@ -92,4 +91,3 @@ waitcmd wait
aliascmd alias
ulimitcmd ulimit
testcmd test [
bindcmd bind
+107 -116
View File
@@ -38,9 +38,9 @@
#if 0
static char sccsid[] = "@(#)cd.c 8.2 (Berkeley) 5/4/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <limits.h>
/*
* The cd and pwd commands.
@@ -68,47 +67,27 @@ __FBSDID("$FreeBSD$");
#include "show.h"
#include "cd.h"
STATIC int cdlogical(char *);
STATIC int cdphysical(char *);
STATIC int docd(char *, int, int);
STATIC char *getcomponent(void);
STATIC int updatepwd(char *);
STATIC int docd __P((char *, int));
STATIC char *getcomponent __P((void));
STATIC void updatepwd __P((char *));
STATIC char *curdir = NULL; /* current working directory */
STATIC char *prevdir; /* previous working directory */
char *curdir = NULL; /* current working directory */
char *prevdir; /* previous working directory */
STATIC char *cdcomppath;
int
cdcmd(int argc, char **argv)
cdcmd(argc, argv)
int argc __unused;
char **argv __unused;
{
char *dest;
char *path;
char *p;
struct stat statb;
int ch, phys, print = 0;
int print = 0;
optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
phys = Pflag;
while ((ch = getopt(argc, argv, "LP")) != -1) {
switch (ch) {
case 'L':
phys = 0;
break;
case 'P':
phys = 1;
break;
default:
error("unknown option: -%c", optopt);
break;
}
}
argc -= optind;
argv += optind;
if (argc > 1)
error("too many arguments");
if ((dest = *argv) == NULL && (dest = bltinlookup("HOME", 1)) == NULL)
nextopt(nullstr);
if ((dest = *argptr) == NULL && (dest = bltinlookup("HOME", 1)) == NULL)
error("HOME not set");
if (*dest == '\0')
dest = ".";
@@ -131,8 +110,9 @@ cdcmd(int argc, char **argv)
p += 2;
print = strcmp(p, dest);
}
if (docd(p, print, phys) >= 0)
if (docd(p, print) >= 0)
return 0;
}
}
error("can't cd to %s", dest);
@@ -142,27 +122,13 @@ cdcmd(int argc, char **argv)
/*
* Actually change the directory. In an interactive shell, print the
* Actually do the chdir. In an interactive shell, print the
* directory name if "print" is nonzero.
*/
STATIC int
docd(char *dest, int print, int phys)
{
TRACE(("docd(\"%s\", %d, %d) called\n", dest, print, phys));
/* If logical cd fails, fall back to physical. */
if ((phys || cdlogical(dest) < 0) && cdphysical(dest) < 0)
return (-1);
if (print && iflag && curdir)
out1fmt("%s\n", curdir);
return 0;
}
STATIC int
cdlogical(char *dest)
docd(dest, print)
char *dest;
int print;
{
char *p;
char *q;
@@ -171,6 +137,8 @@ cdlogical(char *dest)
int first;
int badstat;
TRACE(("docd(\"%s\", %d) called\n", dest, print));
/*
* Check each component of the path. If we find a symlink or
* something we can't stat, clear curdir to force a getcwd()
@@ -197,40 +165,33 @@ cdlogical(char *dest)
if (equal(component, ".."))
continue;
STACKSTRNUL(p);
if (lstat(stackblock(), &statb) < 0) {
if ((lstat(stackblock(), &statb) < 0)
|| (S_ISLNK(statb.st_mode))) {
/* print = 1; */
badstat = 1;
break;
}
}
INTOFF;
if (updatepwd(badstat ? NULL : dest) < 0 || chdir(curdir) < 0) {
if (chdir(dest) < 0) {
INTON;
return (-1);
return -1;
}
updatepwd(badstat ? NULL : dest);
INTON;
return (0);
if (print && iflag && curdir)
out1fmt("%s\n", curdir);
return 0;
}
STATIC int
cdphysical(char *dest)
{
INTOFF;
if (chdir(dest) < 0 || updatepwd(NULL) < 0) {
INTON;
return (-1);
}
INTON;
return (0);
}
/*
* Get the next component of the path name pointed to by cdcomppath.
* This routine overwrites the string pointed to by cdcomppath.
*/
STATIC char *
getcomponent(void)
getcomponent()
{
char *p;
char *start;
@@ -255,8 +216,9 @@ getcomponent(void)
* cd command. We also call hashcd to let the routines in exec.c know
* that the current directory has changed.
*/
STATIC int
updatepwd(char *dir)
STATIC void
updatepwd(dir)
char *dir;
{
char *new;
char *p;
@@ -274,14 +236,12 @@ updatepwd(char *dir)
INTOFF;
prevdir = curdir;
curdir = NULL;
if (getpwd() == NULL) {
INTON;
return (-1);
}
if (getpwd() == NULL)
error("getcwd() failed: %s", strerror(errno));
setvar("PWD", curdir, VEXPORT);
setvar("OLDPWD", prevdir, VEXPORT);
INTON;
return (0);
return;
}
cdcomppath = stalloc(strlen(dir) + 1);
scopy(dir, cdcomppath);
@@ -313,61 +273,51 @@ updatepwd(char *dir)
setvar("PWD", curdir, VEXPORT);
setvar("OLDPWD", prevdir, VEXPORT);
INTON;
return (0);
}
int
pwdcmd(int argc, char **argv)
pwdcmd(argc, argv)
int argc __unused;
char **argv __unused;
{
char buf[PATH_MAX];
int ch, phys;
optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
phys = Pflag;
while ((ch = getopt(argc, argv, "LP")) != -1) {
switch (ch) {
case 'L':
phys = 0;
break;
case 'P':
phys = 1;
break;
default:
error("unknown option: -%c", optopt);
break;
}
}
argc -= optind;
argv += optind;
if (argc != 0)
error("too many arguments");
if (!phys && getpwd()) {
out1str(curdir);
out1c('\n');
} else {
if (getcwd(buf, sizeof(buf)) == NULL)
error(".: %s", strerror(errno));
out1str(buf);
out1c('\n');
}
if (!getpwd())
error("getcwd() failed: %s", strerror(errno));
out1str(curdir);
out1c('\n');
return 0;
}
#define MAXPWD 256
/*
* Find out what the current directory is. If we already know the current
* directory, this routine returns immediately.
*/
char *
getpwd(void)
getpwd()
{
char buf[PATH_MAX];
char buf[MAXPWD];
if (curdir)
return curdir;
/*
* Things are a bit complicated here; we could have just used
* getcwd, but traditionally getcwd is implemented using popen
* to /bin/pwd. This creates a problem for us, since we cannot
* keep track of the job if it is being ran behind our backs.
* So we re-implement getcwd(), and we suppress interrupts
* throughout the process. This is not completely safe, since
* the user can still break out of it by killing the pwd program.
* We still try to use getcwd for systems that we know have a
* c implementation of getcwd, that does not open a pipe to
* /bin/pwd.
*/
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__SVR4)
if (getcwd(buf, sizeof(buf)) == NULL) {
char *pwd = getenv("PWD");
struct stat stdot, stpwd;
@@ -382,6 +332,47 @@ getpwd(void)
return NULL;
}
curdir = savestr(buf);
#else
{
char *p;
int i;
int status;
struct job *jp;
int pip[2];
INTOFF;
if (pipe(pip) < 0)
error("Pipe call failed: %s", strerror(errno));
jp = makejob((union node *)NULL, 1);
if (forkshell(jp, (union node *)NULL, FORK_NOJOB) == 0) {
(void) close(pip[0]);
if (pip[1] != 1) {
close(1);
copyfd(pip[1], 1);
close(pip[1]);
}
(void) execl("/bin/pwd", "pwd", (char *)0);
error("Cannot exec /bin/pwd");
}
(void) close(pip[1]);
pip[1] = -1;
p = buf;
while ((i = read(pip[0], p, buf + MAXPWD - p)) > 0
|| (i == -1 && errno == EINTR)) {
if (i > 0)
p += i;
}
(void) close(pip[0]);
pip[0] = -1;
status = waitforjob(jp);
if (status != 0)
error((char *)0);
if (i < 0 || p == buf || p[-1] != '\n')
error("pwd command failed");
p[-1] = '\0';
}
curdir = savestr(buf);
INTON;
#endif
return curdir;
}
+3 -3
View File
@@ -33,6 +33,6 @@
* $FreeBSD$
*/
char *getpwd(void);
int cdcmd (int, char **);
int pwdcmd(int, char **);
char *getpwd __P((void));
int cdcmd __P((int, char **));
int pwdcmd __P((int, char **));
+46 -9
View File
@@ -38,9 +38,9 @@
#if 0
static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* Errors and exceptions.
@@ -71,7 +71,7 @@ volatile sig_atomic_t intpending;
char *commandname;
static void exverror(int, const char *, va_list) __printf0like(2, 0);
static void exverror __P((int, const char *, va_list)) __printf0like(2, 0);
/*
* Called to raise an exception. Since C doesn't include exceptions, we
@@ -80,7 +80,8 @@ static void exverror(int, const char *, va_list) __printf0like(2, 0);
*/
void
exraise(int e)
exraise(e)
int e;
{
if (handler == NULL)
abort();
@@ -100,8 +101,7 @@ exraise(int e)
*/
void
onint(void)
{
onint() {
sigset_t sigset;
/*
@@ -140,7 +140,10 @@ onint(void)
* formatting. It then raises the error exception.
*/
static void
exverror(int cond, const char *msg, va_list ap)
exverror(cond, msg, ap)
int cond;
const char *msg;
va_list ap;
{
CLEAR_PENDING_INT;
INTOFF;
@@ -162,21 +165,51 @@ exverror(int cond, const char *msg, va_list ap)
}
#ifdef __STDC__
void
error(const char *msg, ...)
#else
void
error(va_alist)
va_dcl
#endif
{
#ifndef __STDC__
const char *msg;
#endif
va_list ap;
#ifdef __STDC__
va_start(ap, msg);
#else
va_start(ap);
msg = va_arg(ap, char *);
#endif
exverror(EXERROR, msg, ap);
va_end(ap);
}
#ifdef __STDC__
void
exerror(int cond, const char *msg, ...)
#else
void
exerror(va_alist)
va_dcl
#endif
{
#ifndef __STDC__
int cond;
char *msg;
#endif
va_list ap;
#ifdef __STDC__
va_start(ap, msg);
#else
va_start(ap);
cond = va_arg(ap, int);
msg = va_arg(ap, char *);
#endif
exverror(cond, msg, ap);
va_end(ap);
}
@@ -221,6 +254,9 @@ STATIC const struct errname errormsg[] = {
{ ENXIO, ALL, "no such device or address" },
{ EROFS, ALL, "read-only file system" },
{ ETXTBSY, ALL, "text busy" },
#ifdef SYSV
{ EAGAIN, E_EXEC, "not enough memory" },
#endif
{ ENOMEM, ALL, "not enough memory" },
#ifdef ENOLINK
{ ENOLINK, ALL, "remote access failed" },
@@ -244,7 +280,6 @@ STATIC const struct errname errormsg[] = {
#ifdef ELIBACC
{ ELIBACC, E_EXEC, "shared library missing" },
#endif
{ EEXIST, E_CREAT, "file exists" },
{ 0, 0, NULL },
};
@@ -256,7 +291,9 @@ STATIC const struct errname errormsg[] = {
*/
char *
errmsg(int e, int action)
errmsg(e, action)
int e;
int action;
{
struct errname const *ep;
static char buf[12];
+7 -5
View File
@@ -89,11 +89,11 @@ extern volatile sig_atomic_t intpending;
#define CLEAR_PENDING_INT intpending = 0
#define int_pending() intpending
void exraise(int);
void onint(void);
void error(const char *, ...) __printf0like(1, 2);
void exerror(int, const char *, ...) __printf0like(2, 3);
char *errmsg(int, int);
void exraise __P((int));
void onint __P((void));
void error __P((const char *, ...)) __printf0like(1, 2);
void exerror __P((int, const char *, ...)) __printf0like(2, 3);
char *errmsg __P((int, int));
/*
@@ -101,5 +101,7 @@ char *errmsg(int, int);
* so we use _setjmp instead.
*/
#ifdef BSD
#define setjmp(jmploc) _setjmp(jmploc)
#define longjmp(jmploc, val) _longjmp(jmploc, val)
#endif
+63 -86
View File
@@ -38,11 +38,10 @@
#if 0
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <paths.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h> /* For WIFSIGNALED(status) */
@@ -93,14 +92,14 @@ int exitstatus; /* exit status of last command */
int oexitstatus; /* saved exit status */
STATIC void evalloop(union node *);
STATIC void evalfor(union node *);
STATIC void evalcase(union node *, int);
STATIC void evalsubshell(union node *, int);
STATIC void expredir(union node *);
STATIC void evalpipe(union node *);
STATIC void evalcommand(union node *, int, struct backcmd *);
STATIC void prehash(union node *);
STATIC void evalloop __P((union node *));
STATIC void evalfor __P((union node *));
STATIC void evalcase __P((union node *, int));
STATIC void evalsubshell __P((union node *, int));
STATIC void expredir __P((union node *));
STATIC void evalpipe __P((union node *));
STATIC void evalcommand __P((union node *, int, struct backcmd *));
STATIC void prehash __P((union node *));
/*
@@ -128,7 +127,9 @@ SHELLPROC {
*/
int
evalcmd(int argc, char **argv)
evalcmd(argc, argv)
int argc;
char **argv;
{
char *p;
char *concat;
@@ -160,8 +161,9 @@ evalcmd(int argc, char **argv)
*/
void
evalstring(char *s)
{
evalstring(s)
char *s;
{
union node *n;
struct stackmark smark;
@@ -183,7 +185,9 @@ evalstring(char *s)
*/
void
evaltree(union node *n, int flags)
evaltree(n, flags)
union node *n;
int flags;
{
if (n == NULL) {
TRACE(("evaltree(NULL) called\n"));
@@ -301,7 +305,8 @@ out:
STATIC void
evalloop(union node *n)
evalloop(n)
union node *n;
{
int status;
@@ -337,7 +342,8 @@ skipping: if (evalskip == SKIPCONT && --skipcount <= 0) {
STATIC void
evalfor(union node *n)
evalfor(n)
union node *n;
{
struct arglist arglist;
union node *argp;
@@ -377,7 +383,9 @@ out:
STATIC void
evalcase(union node *n, int flags)
evalcase(n, flags)
union node *n;
int flags;
{
union node *cp;
union node *patp;
@@ -409,7 +417,9 @@ out:
*/
STATIC void
evalsubshell(union node *n, int flags)
evalsubshell(n, flags)
union node *n;
int flags;
{
struct job *jp;
int backgnd = (n->type == NBACKGND);
@@ -436,7 +446,8 @@ evalsubshell(union node *n, int flags)
*/
STATIC void
expredir(union node *n)
expredir(n)
union node *n;
{
union node *redir;
@@ -449,7 +460,6 @@ expredir(union node *n)
case NTO:
case NFROMTO:
case NAPPEND:
case NCLOBBER:
expandarg(redir->nfile.fname, &fn, EXP_TILDE | EXP_REDIR);
redir->nfile.expfname = fn.list->text;
break;
@@ -474,7 +484,8 @@ expredir(union node *n)
*/
STATIC void
evalpipe(union node *n)
evalpipe(n)
union node *n;
{
struct job *jp;
struct nodelist *lp;
@@ -540,7 +551,9 @@ evalpipe(union node *n)
*/
void
evalbackcmd(union node *n, struct backcmd *result)
evalbackcmd(n, result)
union node *n;
struct backcmd *result;
{
int pip[2];
struct job *jp;
@@ -590,7 +603,10 @@ out:
*/
STATIC void
evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
evalcommand(cmd, flags, backcmd)
union node *cmd;
int flags;
struct backcmd *backcmd;
{
struct stackmark smark;
union node *argp;
@@ -710,7 +726,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
* the command runs. Partly deleting like
* changepatch() does doesn't seem worth the
* bookinging effort, since most such runs add
* directories in front of the new PATH.
* diretories in front of the new PATH.
*/
clearcmdentry(0);
do_clearcmdentry = 1;
@@ -748,9 +764,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
&& (cmdentry.cmdtype != CMDBUILTIN
|| cmdentry.u.index == CDCMD
|| cmdentry.u.index == DOTCMD
|| cmdentry.u.index == EVALCMD))
|| (cmdentry.cmdtype == CMDBUILTIN &&
cmdentry.u.index == COMMANDCMD)) {
|| cmdentry.u.index == EVALCMD))) {
jp = makejob(cmd, 1);
mode = cmd->ncmd.backgnd;
if (flags & EV_BACKCMD) {
@@ -872,8 +886,7 @@ cmddone:
#ifndef NO_HISTORY
|| cmdentry.u.index == HISTCMD
#endif
|| cmdentry.u.index == EXECCMD
|| cmdentry.u.index == COMMANDCMD)
|| cmdentry.u.index == EXECCMD)
exraise(e);
FORCEINTON;
}
@@ -931,7 +944,8 @@ out:
*/
STATIC void
prehash(union node *n)
prehash(n)
union node *n;
{
struct cmdentry entry;
@@ -954,7 +968,9 @@ prehash(union node *n)
*/
int
bltincmd(int argc __unused, char **argv __unused)
bltincmd(argc, argv)
int argc __unused;
char **argv __unused;
{
listsetvar(cmdenviron);
/*
@@ -977,7 +993,9 @@ bltincmd(int argc __unused, char **argv __unused)
*/
int
breakcmd(int argc, char **argv)
breakcmd(argc, argv)
int argc;
char **argv;
{
int n = argc > 1 ? number(argv[1]) : 1;
@@ -990,62 +1008,15 @@ breakcmd(int argc, char **argv)
return 0;
}
/*
* The `command' command.
*/
int
commandcmd(int argc, char **argv)
{
static char stdpath[] = _PATH_STDPATH;
struct jmploc loc, *old;
struct strlist *sp;
char *path;
int ch;
for (sp = cmdenviron; sp ; sp = sp->next)
setvareq(sp->text, VEXPORT|VSTACK);
path = pathval();
optind = optreset = 1;
opterr = 0;
while ((ch = getopt(argc, argv, "p")) != -1) {
switch (ch) {
case 'p':
path = stdpath;
break;
case '?':
default:
error("unknown option: -%c", optopt);
}
}
argc -= optind;
argv += optind;
if (argc != 0) {
old = handler;
handler = &loc;
if (setjmp(handler->loc) == 0)
shellexec(argv, environment(), path, 0);
handler = old;
if (exception == EXEXEC)
exit(exerrno);
exraise(exception);
}
/*
* Do nothing successfully if no command was specified;
* ksh also does this.
*/
exit(0);
}
/*
* The return command.
*/
int
returncmd(int argc, char **argv)
returncmd(argc, argv)
int argc;
char **argv;
{
int ret = argc > 1 ? number(argv[1]) : oexitstatus;
@@ -1062,21 +1033,27 @@ returncmd(int argc, char **argv)
int
falsecmd(int argc __unused, char **argv __unused)
falsecmd(argc, argv)
int argc __unused;
char **argv __unused;
{
return 1;
}
int
truecmd(int argc __unused, char **argv __unused)
truecmd(argc, argv)
int argc __unused;
char **argv __unused;
{
return 0;
}
int
execcmd(int argc, char **argv)
execcmd(argc, argv)
int argc;
char **argv;
{
if (argc > 1) {
struct strlist *sp;
+10 -11
View File
@@ -49,18 +49,17 @@ struct backcmd { /* result of evalbackcmd */
struct job *jp; /* job structure for command */
};
int evalcmd(int, char **);
void evalstring(char *);
int evalcmd __P((int, char **));
void evalstring __P((char *));
union node; /* BLETCH for ansi C */
void evaltree(union node *, int);
void evalbackcmd(union node *, struct backcmd *);
int bltincmd(int, char **);
int breakcmd(int, char **);
int returncmd(int, char **);
int falsecmd(int, char **);
int truecmd(int, char **);
int execcmd(int, char **);
int commandcmd(int, char **);
void evaltree __P((union node *, int));
void evalbackcmd __P((union node *, struct backcmd *));
int bltincmd __P((int, char **));
int breakcmd __P((int, char **));
int returncmd __P((int, char **));
int falsecmd __P((int, char **));
int truecmd __P((int, char **));
int execcmd __P((int, char **));
/* in_function returns nonzero if we are currently evaluating a function */
#define in_function() funcnest
+184 -37
View File
@@ -38,9 +38,9 @@
#if 0
static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
@@ -99,10 +99,13 @@ STATIC int builtinloc = -1; /* index in path of %builtin, or -1 */
int exerrno = 0; /* Last exec error */
STATIC void tryexec(char *, char **, char **);
STATIC void printentry(struct tblentry *, int);
STATIC struct tblentry *cmdlookup(char *, int);
STATIC void delete_cmd_entry(void);
STATIC void tryexec __P((char *, char **, char **));
#ifndef BSD
STATIC void execinterp __P((char **, char **));
#endif
STATIC void printentry __P((struct tblentry *, int));
STATIC struct tblentry *cmdlookup __P((char *, int));
STATIC void delete_cmd_entry __P((void));
@@ -112,7 +115,10 @@ STATIC void delete_cmd_entry(void);
*/
void
shellexec(char **argv, char **envp, char *path, int index)
shellexec(argv, envp, path, index)
char **argv, **envp;
char *path;
int index;
{
char *cmdname;
int e;
@@ -149,16 +155,36 @@ shellexec(char **argv, char **envp, char *path, int index)
STATIC void
tryexec(char *cmd, char **argv, char **envp)
{
tryexec(cmd, argv, envp)
char *cmd;
char **argv;
char **envp;
{
int e;
#ifndef BSD
char *p;
#endif
#ifdef SYSV
do {
execve(cmd, argv, envp);
} while (errno == EINTR);
#else
execve(cmd, argv, envp);
#endif
e = errno;
if (e == ENOEXEC) {
initshellproc();
setinputfile(cmd, 0);
commandname = arg0 = savestr(argv[0]);
#ifndef BSD
pgetc(); pungetc(); /* fill up input buffer */
p = parsenextc;
if (parsenleft > 2 && p[0] == '#' && p[1] == '!') {
argv[0] = cmd;
execinterp(argv, envp);
}
#endif
setparam(argv + 1);
exraise(EXSHELLPROC);
/*NOTREACHED*/
@@ -166,6 +192,86 @@ tryexec(char *cmd, char **argv, char **envp)
errno = e;
}
#ifndef BSD
/*
* Execute an interpreter introduced by "#!", for systems where this
* feature has not been built into the kernel. If the interpreter is
* the shell, return (effectively ignoring the "#!"). If the execution
* of the interpreter fails, exit.
*
* This code peeks inside the input buffer in order to avoid actually
* reading any input. It would benefit from a rewrite.
*/
#define NEWARGS 5
STATIC void
execinterp(argv, envp)
char **argv, **envp;
{
int n;
char *inp;
char *outp;
char c;
char *p;
char **ap;
char *newargs[NEWARGS];
int i;
char **ap2;
char **new;
n = parsenleft - 2;
inp = parsenextc + 2;
ap = newargs;
for (;;) {
while (--n >= 0 && (*inp == ' ' || *inp == '\t'))
inp++;
if (n < 0)
goto bad;
if ((c = *inp++) == '\n')
break;
if (ap == &newargs[NEWARGS])
bad: error("Bad #! line");
STARTSTACKSTR(outp);
do {
STPUTC(c, outp);
} while (--n >= 0 && (c = *inp++) != ' ' && c != '\t' && c != '\n');
STPUTC('\0', outp);
n++, inp--;
*ap++ = grabstackstr(outp);
}
if (ap == newargs + 1) { /* if no args, maybe no exec is needed */
p = newargs[0];
for (;;) {
if (equal(p, "sh") || equal(p, "ash")) {
return;
}
while (*p != '/') {
if (*p == '\0')
goto break2;
p++;
}
p++;
}
break2:;
}
i = (char *)ap - (char *)newargs; /* size in bytes */
if (i == 0)
error("Bad #! line");
for (ap2 = argv ; *ap2++ != NULL ; );
new = ckmalloc(i + ((char *)ap2 - (char *)argv));
ap = newargs, ap2 = new;
while ((i -= sizeof (char **)) >= 0)
*ap2++ = *ap++;
ap = argv;
while (*ap2++ = *ap++);
shellexec(new, envp, pathval(), 0);
}
#endif
/*
* Do a path search. The variable path (passed by reference) should be
* set to the start of the path before the first call; padvance will update
@@ -179,8 +285,10 @@ tryexec(char *cmd, char **argv, char **envp)
char *pathopt;
char *
padvance(char **path, char *name)
{
padvance(path, name)
char **path;
char *name;
{
char *p, *q;
char *start;
int len;
@@ -217,7 +325,9 @@ padvance(char **path, char *name)
int
hashcmd(int argc __unused, char **argv __unused)
hashcmd(argc, argv)
int argc __unused;
char **argv __unused;
{
struct tblentry **pp;
struct tblentry *cmdp;
@@ -237,8 +347,7 @@ hashcmd(int argc __unused, char **argv __unused)
if (*argptr == NULL) {
for (pp = cmdtable ; pp < &cmdtable[CMDTABLESIZE] ; pp++) {
for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
if (cmdp->cmdtype == CMDNORMAL)
printentry(cmdp, verbose);
printentry(cmdp, verbose);
}
}
return 0;
@@ -266,8 +375,10 @@ hashcmd(int argc __unused, char **argv __unused)
STATIC void
printentry(struct tblentry *cmdp, int verbose)
{
printentry(cmdp, verbose)
struct tblentry *cmdp;
int verbose;
{
int index;
char *path;
char *name;
@@ -310,7 +421,11 @@ printentry(struct tblentry *cmdp, int verbose)
*/
void
find_command(char *name, struct cmdentry *entry, int printerr, char *path)
find_command(name, entry, printerr, path)
char *name;
struct cmdentry *entry;
int printerr;
char *path;
{
struct tblentry *cmdp;
int index;
@@ -379,7 +494,11 @@ loop:
TRACE(("searchexec \"%s\": no change\n", name));
goto success;
}
if (stat(fullname, &statb) < 0) {
while (stat(fullname, &statb) < 0) {
#ifdef SYSV
if (errno == EINTR)
continue;
#endif
if (errno != ENOENT && errno != ENOTDIR)
e = errno;
goto loop;
@@ -437,7 +556,8 @@ success:
*/
int
find_builtin(char *name)
find_builtin(name)
char *name;
{
const struct builtincmd *bp;
@@ -456,8 +576,7 @@ find_builtin(char *name)
*/
void
hashcd(void)
{
hashcd() {
struct tblentry **pp;
struct tblentry *cmdp;
@@ -479,7 +598,8 @@ hashcd(void)
*/
void
changepath(const char *newval)
changepath(newval)
const char *newval;
{
const char *old, *new;
int index;
@@ -523,7 +643,8 @@ changepath(const char *newval)
*/
void
clearcmdentry(int firstchange)
clearcmdentry(firstchange)
int firstchange;
{
struct tblentry **tblp;
struct tblentry **pp;
@@ -561,8 +682,7 @@ SHELLPROC {
#endif
void
deletefuncs(void)
{
deletefuncs() {
struct tblentry **tblp;
struct tblentry **pp;
struct tblentry *cmdp;
@@ -593,11 +713,13 @@ deletefuncs(void)
* entry.
*/
STATIC struct tblentry **lastcmdentry;
struct tblentry **lastcmdentry;
STATIC struct tblentry *
cmdlookup(char *name, int add)
cmdlookup(name, add)
char *name;
int add;
{
int hashval;
char *p;
@@ -634,8 +756,7 @@ cmdlookup(char *name, int add)
*/
STATIC void
delete_cmd_entry(void)
{
delete_cmd_entry() {
struct tblentry *cmdp;
INTOFF;
@@ -647,14 +768,35 @@ delete_cmd_entry(void)
#ifdef notdef
void
getcmdentry(name, entry)
char *name;
struct cmdentry *entry;
{
struct tblentry *cmdp = cmdlookup(name, 0);
if (cmdp) {
entry->u = cmdp->param;
entry->cmdtype = cmdp->cmdtype;
} else {
entry->cmdtype = CMDUNKNOWN;
entry->u.index = 0;
}
}
#endif
/*
* Add a new command entry, replacing any existing command entry for
* the same name.
*/
void
addcmdentry(char *name, struct cmdentry *entry)
{
addcmdentry(name, entry)
char *name;
struct cmdentry *entry;
{
struct tblentry *cmdp;
INTOFF;
@@ -673,8 +815,10 @@ addcmdentry(char *name, struct cmdentry *entry)
*/
void
defun(char *name, union node *func)
{
defun(name, func)
char *name;
union node *func;
{
struct cmdentry entry;
INTOFF;
@@ -690,8 +834,9 @@ defun(char *name, union node *func)
*/
int
unsetfunc(char *name)
{
unsetfunc(name)
char *name;
{
struct tblentry *cmdp;
if ((cmdp = cmdlookup(name, 0)) != NULL && cmdp->cmdtype == CMDFUNCTION) {
@@ -699,7 +844,7 @@ unsetfunc(char *name)
delete_cmd_entry();
return (0);
}
return (0);
return (1);
}
/*
@@ -707,7 +852,9 @@ unsetfunc(char *name)
*/
int
typecmd(int argc, char **argv)
typecmd(argc, argv)
int argc;
char **argv;
{
struct cmdentry entry;
struct tblentry *cmdp;
+14 -13
View File
@@ -56,16 +56,17 @@ struct cmdentry {
extern char *pathopt; /* set by padvance */
extern int exerrno; /* last exec error */
void shellexec(char **, char **, char *, int);
char *padvance(char **, char *);
int hashcmd(int, char **);
void find_command(char *, struct cmdentry *, int, char *);
int find_builtin(char *);
void hashcd(void);
void changepath(const char *);
void deletefuncs(void);
void addcmdentry(char *, struct cmdentry *);
void defun(char *, union node *);
int unsetfunc(char *);
int typecmd(int, char **);
void clearcmdentry(int);
void shellexec __P((char **, char **, char *, int));
char *padvance __P((char **, char *));
int hashcmd __P((int, char **));
void find_command __P((char *, struct cmdentry *, int, char *));
int find_builtin __P((char *));
void hashcd __P((void));
void changepath __P((const char *));
void deletefuncs __P((void));
void getcmdentry __P((char *, struct cmdentry *));
void addcmdentry __P((char *, struct cmdentry *));
void defun __P((char *, union node *));
int unsetfunc __P((char *));
int typecmd __P((int, char **));
void clearcmdentry __P((int));
+117 -80
View File
@@ -38,9 +38,9 @@
#if 0
static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/time.h>
@@ -89,33 +89,33 @@ struct ifsregion {
};
STATIC char *expdest; /* output of current string */
STATIC struct nodelist *argbackq; /* list of back quote expressions */
STATIC struct ifsregion ifsfirst; /* first struct in list of ifs regions */
STATIC struct ifsregion *ifslastp; /* last struct in list */
STATIC struct arglist exparg; /* holds expanded arg list */
char *expdest; /* output of current string */
struct nodelist *argbackq; /* list of back quote expressions */
struct ifsregion ifsfirst; /* first struct in list of ifs regions */
struct ifsregion *ifslastp; /* last struct in list */
struct arglist exparg; /* holds expanded arg list */
STATIC void argstr(char *, int);
STATIC char *exptilde(char *, int);
STATIC void expbackq(union node *, int, int);
STATIC int subevalvar(char *, char *, int, int, int, int);
STATIC char *evalvar(char *, int);
STATIC int varisset(char *, int);
STATIC void varvalue(char *, int, int);
STATIC void recordregion(int, int, int);
STATIC void removerecordregions(int);
STATIC void ifsbreakup(char *, struct arglist *);
STATIC void expandmeta(struct strlist *, int);
STATIC void expmeta(char *, char *);
STATIC void addfname(char *);
STATIC struct strlist *expsort(struct strlist *);
STATIC struct strlist *msort(struct strlist *, int);
STATIC int pmatch(char *, char *, int);
STATIC char *cvtnum(int, char *);
STATIC int collate_range_cmp(int, int);
STATIC void argstr __P((char *, int));
STATIC char *exptilde __P((char *, int));
STATIC void expbackq __P((union node *, int, int));
STATIC int subevalvar __P((char *, char *, int, int, int, int));
STATIC char *evalvar __P((char *, int));
STATIC int varisset __P((char *, int));
STATIC void varvalue __P((char *, int, int));
STATIC void recordregion __P((int, int, int));
STATIC void removerecordregions __P((int));
STATIC void ifsbreakup __P((char *, struct arglist *));
STATIC void expandmeta __P((struct strlist *, int));
STATIC void expmeta __P((char *, char *));
STATIC void addfname __P((char *));
STATIC struct strlist *expsort __P((struct strlist *));
STATIC struct strlist *msort __P((struct strlist *, int));
STATIC int pmatch __P((char *, char *, int));
STATIC char *cvtnum __P((int, char *));
STATIC int collate_range_cmp __P((int, int));
STATIC int
collate_range_cmp (int c1, int c2)
STATIC int collate_range_cmp (c1, c2)
int c1, c2;
{
static char s1[2], s2[2];
int ret;
@@ -133,13 +133,13 @@ collate_range_cmp (int c1, int c2)
/*
* Expand shell variables and backquotes inside a here document.
* union node *arg the document
* int fd; where to write the expanded version
*/
void
expandhere(union node *arg, int fd)
{
expandhere(arg, fd)
union node *arg; /* the document */
int fd; /* where to write the expanded version */
{
herefd = fd;
expandarg(arg, (struct arglist *)NULL, 0);
xwrite(fd, stackblock(), expdest - stackblock());
@@ -154,7 +154,10 @@ expandhere(union node *arg, int fd)
*/
void
expandarg(union node *arg, struct arglist *arglist, int flag)
expandarg(arg, arglist, flag)
union node *arg;
struct arglist *arglist;
int flag;
{
struct strlist *sp;
char *p;
@@ -210,10 +213,12 @@ expandarg(union node *arg, struct arglist *arglist, int flag)
*/
STATIC void
argstr(char *p, int flag)
argstr(p, flag)
char *p;
int flag;
{
char c;
int quotes = flag & (EXP_FULL | EXP_CASE | EXP_REDIR); /* do CTLESC */
int quotes = flag & (EXP_FULL | EXP_CASE); /* do CTLESC */
int firsteq = 1;
if (*p == '~' && (flag & (EXP_TILDE | EXP_VARTILDE)))
@@ -272,12 +277,14 @@ breakloop:;
}
STATIC char *
exptilde(char *p, int flag)
exptilde(p, flag)
char *p;
int flag;
{
char c, *startp = p;
struct passwd *pw;
char *home;
int quotes = flag & (EXP_FULL | EXP_CASE | EXP_REDIR);
int quotes = flag & (EXP_FULL | EXP_CASE);
while ((c = *p) != '\0') {
switch(c) {
@@ -320,7 +327,8 @@ lose:
STATIC void
removerecordregions(int endoff)
removerecordregions(endoff)
int endoff;
{
if (ifslastp == NULL)
return;
@@ -363,12 +371,13 @@ removerecordregions(int endoff)
* evaluate, place result in (backed up) result, adjust string position.
*/
void
expari(int flag)
expari(flag)
int flag;
{
char *p, *start;
int result;
int begoff;
int quotes = flag & (EXP_FULL | EXP_CASE | EXP_REDIR);
int quotes = flag & (EXP_FULL | EXP_CASE);
int quoted;
@@ -422,7 +431,10 @@ expari(int flag)
*/
STATIC void
expbackq(union node *cmd, int quoted, int flag)
expbackq(cmd, quoted, flag)
union node *cmd;
int quoted;
int flag;
{
struct backcmd in;
int i;
@@ -435,7 +447,7 @@ expbackq(union node *cmd, int quoted, int flag)
int startloc = dest - stackblock();
char const *syntax = quoted? DQSYNTAX : BASESYNTAX;
int saveherefd;
int quotes = flag & (EXP_FULL | EXP_CASE | EXP_REDIR);
int quotes = flag & (EXP_FULL | EXP_CASE);
INTOFF;
saveifs = ifsfirst;
@@ -495,8 +507,13 @@ expbackq(union node *cmd, int quoted, int flag)
STATIC int
subevalvar(char *p, char *str, int strloc, int subtype, int startloc,
int varflags)
subevalvar(p, str, strloc, subtype, startloc, varflags)
char *p;
char *str;
int strloc;
int subtype;
int startloc;
int varflags;
{
char *startp;
char *loc = NULL;
@@ -621,7 +638,9 @@ recordleft:
*/
STATIC char *
evalvar(char *p, int flag)
evalvar(p, flag)
char *p;
int flag;
{
int subtype;
int varflags;
@@ -634,7 +653,7 @@ evalvar(char *p, int flag)
int startloc;
int varlen;
int easy;
int quotes = flag & (EXP_FULL | EXP_CASE | EXP_REDIR);
int quotes = flag & (EXP_FULL | EXP_CASE);
varflags = *p++;
subtype = varflags & VSTYPE;
@@ -657,17 +676,6 @@ again: /* jump here after setting a variable with ${var=text} */
}
varlen = 0;
startloc = expdest - stackblock();
if (!set && uflag) {
switch (subtype) {
case VSNORMAL:
case VSTRIMLEFT:
case VSTRIMLEFTMAX:
case VSTRIMRIGHT:
case VSTRIMRIGHTMAX:
case VSLENGTH:
error("%.*s: parameter not set", p - var - 1, var);
}
}
if (set && subtype != VSPLUS) {
/* insert the value of the variable */
if (special) {
@@ -796,7 +804,9 @@ record:
*/
STATIC int
varisset(char *name, int nulok)
varisset(name, nulok)
char *name;
int nulok;
{
if (*name == '!')
@@ -838,7 +848,10 @@ varisset(char *name, int nulok)
*/
STATIC void
varvalue(char *name, int quoted, int allow_split)
varvalue(name, quoted, allow_split)
char *name;
int quoted;
int allow_split;
{
int num;
char *p;
@@ -929,7 +942,10 @@ numvar:
*/
STATIC void
recordregion(int start, int end, int nulonly)
recordregion(start, end, nulonly)
int start;
int end;
int nulonly;
{
struct ifsregion *ifsp;
@@ -954,8 +970,10 @@ recordregion(int start, int end, int nulonly)
* searched for IFS characters have been stored by recordregion.
*/
STATIC void
ifsbreakup(char *string, struct arglist *arglist)
{
ifsbreakup(string, arglist)
char *string;
struct arglist *arglist;
{
struct ifsregion *ifsp;
struct strlist *sp;
char *start;
@@ -1046,11 +1064,13 @@ ifsbreakup(char *string, struct arglist *arglist)
* should be escapes. The results are stored in the list exparg.
*/
STATIC char *expdir;
char *expdir;
STATIC void
expandmeta(struct strlist *str, int flag __unused)
expandmeta(str, flag)
struct strlist *str;
int flag __unused;
{
char *p;
struct strlist **savelastp;
@@ -1104,8 +1124,10 @@ nometa:
*/
STATIC void
expmeta(char *enddir, char *name)
{
expmeta(enddir, name)
char *enddir;
char *name;
{
char *p;
char *q;
char *start;
@@ -1164,7 +1186,7 @@ expmeta(char *enddir, char *name)
if (*p == '\0')
break;
}
if (metaflag == 0 || lstat(expdir, &statb) >= 0)
if (metaflag == 0 || stat(expdir, &statb) >= 0)
addfname(expdir);
return;
}
@@ -1233,8 +1255,9 @@ expmeta(char *enddir, char *name)
*/
STATIC void
addfname(char *name)
{
addfname(name)
char *name;
{
char *p;
struct strlist *sp;
@@ -1254,8 +1277,9 @@ addfname(char *name)
*/
STATIC struct strlist *
expsort(struct strlist *str)
{
expsort(str)
struct strlist *str;
{
int len;
struct strlist *sp;
@@ -1267,7 +1291,9 @@ expsort(struct strlist *str)
STATIC struct strlist *
msort(struct strlist *list, int len)
msort(list, len)
struct strlist *list;
int len;
{
struct strlist *p, *q = NULL;
struct strlist **lpp;
@@ -1313,8 +1339,11 @@ msort(struct strlist *list, int len)
*/
int
patmatch(char *pattern, char *string, int squoted)
{
patmatch(pattern, string, squoted)
char *pattern;
char *string;
int squoted; /* string might have quote chars */
{
#ifdef notdef
if (pattern[0] == '!' && pattern[1] == '!')
return 1 - pmatch(pattern + 2, string);
@@ -1325,8 +1354,11 @@ patmatch(char *pattern, char *string, int squoted)
STATIC int
pmatch(char *pattern, char *string, int squoted)
{
pmatch(pattern, string, squoted)
char *pattern;
char *string;
int squoted;
{
char *p, *q;
char c;
@@ -1450,7 +1482,8 @@ breakloop:
*/
void
rmescapes(char *str)
rmescapes(str)
char *str;
{
char *p, *q;
@@ -1479,8 +1512,10 @@ rmescapes(char *str)
*/
int
casematch(union node *pattern, char *val)
{
casematch(pattern, val)
union node *pattern;
char *val;
{
struct stackmark smark;
int result;
char *p;
@@ -1502,8 +1537,10 @@ casematch(union node *pattern, char *val)
*/
STATIC char *
cvtnum(int num, char *buf)
{
cvtnum(num, buf)
int num;
char *buf;
{
char temp[32];
int neg = num < 0;
char *p = temp + 31;
+6 -6
View File
@@ -59,9 +59,9 @@ struct arglist {
union node;
void expandhere(union node *, int);
void expandarg(union node *, struct arglist *, int);
void expari(int);
int patmatch(char *, char *, int);
void rmescapes(char *);
int casematch(union node *, char *);
void expandhere __P((union node *, int));
void expandarg __P((union node *, struct arglist *, int));
void expari __P((int));
int patmatch __P((char *, char *, int));
void rmescapes __P((char *));
int casematch __P((union node *, char *));
+19 -31
View File
@@ -38,9 +38,9 @@
#if 0
static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <limits.h>
@@ -72,14 +72,14 @@ EditLine *el; /* editline cookie */
int displayhist;
static FILE *el_in, *el_out;
STATIC char *fc_replace(const char *, char *, char *);
STATIC char *fc_replace __P((const char *, char *, char *));
/*
* Set history and editing status. Called whenever the status may
* have changed (figures out what to do).
*/
void
histedit(void)
histedit()
{
#define editing (Eflag || Vflag)
@@ -130,7 +130,6 @@ bad:
el_set(el, EL_EDITOR, "vi");
else if (Eflag)
el_set(el, EL_EDITOR, "emacs");
el_source(el, NULL);
}
} else {
INTOFF;
@@ -166,7 +165,9 @@ sethistsize(hs)
* the Korn shell fc command. Oh well...
*/
int
histcmd(int argc, char **argv)
histcmd(argc, argv)
int argc;
char **argv;
{
int ch;
char *editor = NULL;
@@ -181,7 +182,6 @@ histcmd(int argc, char **argv)
struct jmploc *volatile savehandler;
char editfile[PATH_MAX];
FILE *efp;
int oldhistnum;
#ifdef __GNUC__
/* Avoid longjmp clobbering */
(void) &editor;
@@ -205,12 +205,11 @@ histcmd(int argc, char **argv)
error("missing history argument");
optreset = 1; optind = 1; /* initialize getopt */
opterr = 0;
while (not_fcnumber(argv[optind]) &&
(ch = getopt(argc, argv, ":e:lnrs")) != -1)
switch ((char)ch) {
case 'e':
editor = optarg;
editor = shoptarg;
break;
case 'l':
lflg = 1;
@@ -393,7 +392,9 @@ histcmd(int argc, char **argv)
}
STATIC char *
fc_replace(const char *s, char *p, char *r)
fc_replace(s, p, r)
const char *s;
char *p, *r;
{
char *dest;
int plen = strlen(p);
@@ -415,7 +416,8 @@ fc_replace(const char *s, char *p, char *r)
}
int
not_fcnumber(char *s)
not_fcnumber(s)
char *s;
{
if (s == NULL)
return (0);
@@ -425,7 +427,9 @@ not_fcnumber(char *s)
}
int
str_to_event(char *str, int last)
str_to_event(str, last)
char *str;
int last;
{
const HistEvent *he;
char *s = str;
@@ -471,33 +475,17 @@ str_to_event(char *str, int last)
}
return (he->num);
}
int
bindcmd(int argc, char **argv)
{
if (el == NULL)
error("line editing is disabled");
return (el_parse(el, argc, argv));
}
#else
#include "error.h"
int
histcmd(int argc, char **argv)
histcmd(argc, argv)
int argc;
char **argv;
{
error("not compiled with history support");
/*NOTREACHED*/
return (0);
}
int
bindcmd(int argc, char **argv)
{
error("not compiled with line editing support");
return (0);
}
#endif
+3 -3
View File
@@ -37,6 +37,6 @@
* $FreeBSD$
*/
void init(void);
void reset(void);
void initshellproc(void);
void init __P((void));
void reset __P((void));
void initshellproc __P((void));
+31 -33
View File
@@ -38,9 +38,9 @@
#if 0
static char sccsid[] = "@(#)input.c 8.3 (Berkeley) 6/9/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <stdio.h> /* defines BUFSIZ */
#include <fcntl.h>
@@ -64,7 +64,6 @@ __FBSDID("$FreeBSD$");
#include "alias.h"
#include "parser.h"
#include "myhistedit.h"
#include "trap.h"
#define EOF_NLEFT -99 /* value of parsenleft when EOF pushed back */
@@ -102,14 +101,14 @@ MKINIT int parselleft; /* copy of parsefile->lleft */
char *parsenextc; /* copy of parsefile->nextc */
MKINIT struct parsefile basepf; /* top level input file */
char basebuf[BUFSIZ]; /* buffer for top level input file */
STATIC struct parsefile *parsefile = &basepf; /* current input file */
struct parsefile *parsefile = &basepf; /* current input file */
int init_editline = 0; /* editline library initialized? */
int whichprompt; /* 1 == PS1, 2 == PS2 */
EditLine *el; /* cookie for editline package */
STATIC void pushfile(void);
static int preadfd(void);
STATIC void pushfile __P((void));
static int preadfd __P((void));
#ifdef mkinit
INCLUDE "input.h"
@@ -138,7 +137,9 @@ SHELLPROC {
*/
char *
pfgets(char *line, int len)
pfgets(line, len)
char *line;
int len;
{
char *p = line;
int nleft = len;
@@ -167,24 +168,18 @@ pfgets(char *line, int len)
*/
int
pgetc(void)
pgetc()
{
return pgetc_macro();
}
static int
preadfd(void)
preadfd()
{
int nr;
parsenextc = parsefile->buf;
#ifndef NO_HISTORY
if (el != NULL && gotwinch) {
gotwinch = 0;
el_resize(el);
}
#endif
retry:
#ifndef NO_HISTORY
if (parsefile->fd == 0 && el) {
@@ -232,7 +227,7 @@ retry:
*/
int
preadbuffer(void)
preadbuffer()
{
char *p, *q;
int more;
@@ -319,8 +314,7 @@ check:
*/
void
pungetc(void)
{
pungetc() {
parsenleft++;
parsenextc--;
}
@@ -330,8 +324,11 @@ pungetc(void)
* We handle aliases this way.
*/
void
pushstring(char *s, int len, void *ap)
{
pushstring(s, len, ap)
char *s;
int len;
void *ap;
{
struct strpush *sp;
INTOFF;
@@ -354,7 +351,7 @@ pushstring(char *s, int len, void *ap)
}
void
popstring(void)
popstring()
{
struct strpush *sp = parsefile->strpush;
@@ -377,7 +374,9 @@ popstring(void)
*/
void
setinputfile(char *fname, int push)
setinputfile(fname, push)
char *fname;
int push;
{
int fd;
int fd2;
@@ -403,7 +402,8 @@ setinputfile(char *fname, int push)
*/
void
setinputfd(int fd, int push)
setinputfd(fd, push)
int fd, push;
{
(void)fcntl(fd, F_SETFD, FD_CLOEXEC);
if (push) {
@@ -425,8 +425,10 @@ setinputfd(int fd, int push)
*/
void
setinputstring(char *string, int push)
{
setinputstring(string, push)
char *string;
int push;
{
INTOFF;
if (push)
pushfile();
@@ -445,8 +447,7 @@ setinputstring(char *string, int push)
*/
STATIC void
pushfile(void)
{
pushfile() {
struct parsefile *pf;
parsefile->nleft = parsenleft;
@@ -463,8 +464,7 @@ pushfile(void)
void
popfile(void)
{
popfile() {
struct parsefile *pf = parsefile;
INTOFF;
@@ -489,8 +489,7 @@ popfile(void)
*/
void
popallfiles(void)
{
popallfiles() {
while (parsefile != &basepf)
popfile();
}
@@ -503,8 +502,7 @@ popallfiles(void)
*/
void
closescript(void)
{
closescript() {
popallfiles();
if (parsefile->fd > 0) {
close(parsefile->fd);
+12 -12
View File
@@ -49,17 +49,17 @@ extern int parsenleft; /* number of characters left in input buffer */
extern char *parsenextc; /* next character in input buffer */
extern int init_editline; /* 0 == not setup, 1 == OK, -1 == failed */
char *pfgets(char *, int);
int pgetc(void);
int preadbuffer(void);
void pungetc(void);
void pushstring(char *, int, void *);
void popstring(void);
void setinputfile(char *, int);
void setinputfd(int, int);
void setinputstring(char *, int);
void popfile(void);
void popallfiles(void);
void closescript(void);
char *pfgets __P((char *, int));
int pgetc __P((void));
int preadbuffer __P((void));
void pungetc __P((void));
void pushstring __P((char *, int, void *));
void popstring __P((void));
void setinputfile __P((char *, int));
void setinputfd __P((int, int));
void setinputstring __P((char *, int));
void popfile __P((void));
void popallfiles __P((void));
void closescript __P((void));
#define pgetc_macro() (--parsenleft >= 0? *parsenextc++ : preadbuffer())
+269 -356
View File
File diff suppressed because it is too large. Load diff
+13 -15
View File
@@ -67,14 +67,12 @@ struct job {
struct procstat ps0; /* status of process */
struct procstat *ps; /* status or processes when more than one */
short nprocs; /* number of processes */
pid_t pgrp; /* process group of this job */
short pgrp; /* process group of this job */
char state; /* true if job is finished */
char used; /* true if this entry is in used */
char changed; /* true if status has changed */
char foreground; /* true if running in the foreground */
#if JOBS
char jobctl; /* job running under job control */
struct job *next; /* job used after this one */
#endif
};
@@ -84,18 +82,18 @@ extern int in_waitcmd; /* are we in waitcmd()? */
extern int in_dowait; /* are we in dowait()? */
extern volatile sig_atomic_t breakwaitcmd; /* break wait to process traps? */
void setjobctl(int);
int fgcmd(int, char **);
int bgcmd(int, char **);
int jobscmd(int, char **);
void showjobs(int, int, int);
int waitcmd(int, char **);
int jobidcmd(int, char **);
struct job *makejob(union node *, int);
pid_t forkshell(struct job *, union node *, int);
int waitforjob(struct job *, int *);
int stoppedjobs(void);
char *commandtext(union node *);
void setjobctl __P((int));
int fgcmd __P((int, char **));
int bgcmd __P((int, char **));
int jobscmd __P((int, char **));
void showjobs __P((int));
int waitcmd __P((int, char **));
int jobidcmd __P((int, char **));
struct job *makejob __P((union node *, int));
int forkshell __P((struct job *, union node *, int));
int waitforjob __P((struct job *, int *));
int stoppedjobs __P((void));
char *commandtext __P((union node *));
#if ! JOBS
#define setjobctl(on) /* do nothing */
Loaded 100 of 9986 files, more files were not shown because too many files have changed in this diff. Show more