mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 19:34:43 +01:00
Compare commits
66
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2429c4972 | ||
|
|
b3ea8abeca | ||
|
|
9164545f1e | ||
|
|
5eae6b2562 | ||
|
|
a7e451a639 | ||
|
|
3308a3ac7d | ||
|
|
c41cb731de | ||
|
|
6a53694e24 | ||
|
|
e4f98b94ab | ||
|
|
5d95e0d37d | ||
|
|
2288c0a175 | ||
|
|
300d4a9e1c | ||
|
|
31c540a7bf | ||
|
|
b1008d49cf | ||
|
|
5b5ef9ff47 | ||
|
|
137f467304 | ||
|
|
db2fa549af | ||
|
|
4e12eb754a | ||
|
|
ed0a425074 | ||
|
|
beee7146bb | ||
|
|
289aac082e | ||
|
|
09e559d6bf | ||
|
|
ae46147b46 | ||
|
|
414cbe64a2 | ||
|
|
e7ca883fb4 | ||
|
|
09e706bdbe | ||
|
|
95e99f0475 | ||
|
|
1ab7d89a29 | ||
|
|
9ec5b03f78 | ||
|
|
26fbaf095b | ||
|
|
326e527006 | ||
|
|
ebf8311d3f | ||
|
|
355a9e77ac | ||
|
|
0d632bf022 | ||
|
|
9278c6c21f | ||
|
|
92728a8982 | ||
|
|
f347313ee1 | ||
|
|
8f2132bbf7 | ||
|
|
6320e089a3 | ||
|
|
9622c88bb6 | ||
|
|
390987ad32 | ||
|
|
2f18471c5b | ||
|
|
a33a14a17e | ||
|
|
671b1ed0c8 | ||
|
|
5b8b8fac00 | ||
|
|
661208396d | ||
|
|
8a3dd877cd | ||
|
|
6637deed20 | ||
|
|
cb4a44d6f2 | ||
|
|
6f324f98fc | ||
|
|
d0dbb4fe68 | ||
|
|
7c0da636a5 | ||
|
|
357bdc2407 | ||
|
|
cdef692bc0 | ||
|
|
3122ea36c8 | ||
|
|
4e2c43952b | ||
|
|
70a72dca6f | ||
|
|
94597b54af | ||
|
|
3bddebe8ad | ||
|
|
4d8fea4200 | ||
|
|
a6d81ef744 | ||
|
|
ac3575e18b | ||
|
|
571b0eac5e | ||
|
|
eea9ea0d6f | ||
|
|
fccf0e18e5 | ||
|
|
dd85ad4dc8 |
No files matched your search
@@ -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.
|
||||
|
||||
|
||||
@@ -30,31 +30,24 @@
|
||||
# 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.
|
||||
# For novices wanting to build from current sources, the simple instructions
|
||||
# are:
|
||||
#
|
||||
# For individuals wanting to build from the sources currently on their
|
||||
# system, the simple instructions are:
|
||||
# 1. Ensure that your /usr/obj directory has at least 260 Mb of free space.
|
||||
# 2. `cd /usr/src' (or to the directory containing your source tree).
|
||||
# 3. `make world'
|
||||
#
|
||||
# 1. `cd /usr/src' (or to the directory containing your source tree).
|
||||
# 2. `make world'
|
||||
# Be warned, this will update your installed system, except for configuration
|
||||
# files in the /etc directory and for the kernel. You have to do those manually.
|
||||
#
|
||||
# For individuals wanting to upgrade their sources (even if only a
|
||||
# delta of a few days):
|
||||
#
|
||||
# 1. `cd /usr/src' (or to the directory containing your source tree).
|
||||
# 2. `make buildworld'
|
||||
# 3. `make buildkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
|
||||
# 4. `make installkernel KERNCONF=YOUR_KERNEL_HERE' (default is GENERIC).
|
||||
# 5. `reboot' (in single user mode: boot -s from the loader prompt).
|
||||
# 6. `mergemaster -p'
|
||||
# 7. `make installworld'
|
||||
# 8. `mergemaster'
|
||||
# 9. `reboot'
|
||||
#
|
||||
# See src/UPDATING `COMMON ITEMS' for more complete information.
|
||||
# If at first you're a little nervous about having a `make world' update
|
||||
# your system, a `make buildworld' will build everything in the /usr/obj
|
||||
# tree without touching your installed system. To be of any further use
|
||||
# though, a `make installworld' is required.
|
||||
#
|
||||
# If -DWANT_AOUT is specified, a `make world' with OBJFORMAT=elf will
|
||||
# update the legacy support for aout. This includes all libraries, ld.so
|
||||
@@ -63,11 +56,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 +84,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 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 +96,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 +135,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 +145,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
|
||||
|
||||
+289
-252
@@ -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
|
||||
@@ -20,7 +20,7 @@
|
||||
# -DNO_PORTSUPDATE do not update ports in ${MAKE} update
|
||||
# -DNO_DOCUPDATE do not update doc in ${MAKE} update
|
||||
# LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
|
||||
# TARGET_ARCH="arch" to crossbuild world to a different arch
|
||||
# MACHINE_ARCH="machine arch" to crossbuild world to a different arch
|
||||
|
||||
#
|
||||
# The intended user-driven targets are:
|
||||
@@ -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,17 +107,13 @@ SUBDIR+= ${_DIR}
|
||||
.endfor
|
||||
.endif
|
||||
|
||||
.if defined(SUBDIR_OVERRIDE)
|
||||
SUBDIR= ${SUBDIR_OVERRIDE}
|
||||
.endif
|
||||
|
||||
.if defined(NOCLEANDIR)
|
||||
CLEANDIR= clean cleandepend
|
||||
.else
|
||||
CLEANDIR= cleandir
|
||||
.endif
|
||||
|
||||
SUP?= /usr/local/bin/cvsup
|
||||
SUP?= cvsup
|
||||
SUPFLAGS?= -g -L 2 -P -
|
||||
.if defined(SUPHOST)
|
||||
SUPFLAGS+= -h ${SUPHOST}
|
||||
@@ -125,23 +121,13 @@ 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 ${BUILD_ARCH} == ${MACHINE_ARCH}
|
||||
OBJTREE= ${MAKEOBJDIRPREFIX}
|
||||
.else
|
||||
OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}
|
||||
OBJTREE= ${MAKEOBJDIRPREFIX}/${MACHINE_ARCH}
|
||||
.endif
|
||||
WORLDTMP= ${OBJTREE}${.CURDIR}/${MACHINE_ARCH}
|
||||
WORLDTMP= ${OBJTREE}${.CURDIR}/${BUILD_ARCH}
|
||||
# /usr/games added for fortune which depend on strfile
|
||||
STRICTTMPPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
|
||||
TMPPATH= ${STRICTTMPPATH}:${PATH}
|
||||
@@ -172,35 +158,42 @@ INSTALLTMP= ${TMPDIR}/install.${TMPPID}
|
||||
# This stage installs a previously built world.
|
||||
#
|
||||
|
||||
# Common environment for bootstrap related stages
|
||||
BOOTSTRAPENV= MAKEOBJDIRPREFIX=${WORLDTMP} \
|
||||
DESTDIR=${WORLDTMP} \
|
||||
INSTALL="sh ${.CURDIR}/tools/install.sh" \
|
||||
MACHINE_ARCH=${BUILD_ARCH} \
|
||||
TOOLS_PREFIX=${WORLDTMP} \
|
||||
PATH=${TMPPATH}
|
||||
|
||||
# Common environment for world related stages
|
||||
CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \
|
||||
MACHINE_ARCH=${TARGET_ARCH} \
|
||||
MACHINE=${TARGET} \
|
||||
COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
|
||||
LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib \
|
||||
OBJFORMAT_PATH=${WORLDTMP}/usr/libexec \
|
||||
CFLAGS="-nostdinc ${CFLAGS}" \
|
||||
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
|
||||
BMAKEENV= ${BOOTSTRAPENV}
|
||||
BMAKE= ${BMAKEENV} ${MAKE} -f Makefile.inc1 -DNOHTML -DNOINFO \
|
||||
-DNOMAN -DNOPIC -DNOPROFILE -DNOSHARED
|
||||
|
||||
# build-tool stage
|
||||
TMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE} \
|
||||
DESTDIR= \
|
||||
INSTALL="sh ${.CURDIR}/tools/install.sh"
|
||||
TMAKE= ${TMAKEENV} ${MAKE} -f Makefile.inc1 -DBOOTSTRAPPING
|
||||
INSTALL="sh ${.CURDIR}/tools/install.sh" \
|
||||
PATH=${TMPPATH}
|
||||
TMAKE= ${TMAKEENV} ${MAKE} -f Makefile.inc1
|
||||
|
||||
# cross-tool stage
|
||||
XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} -DNO_FORTRAN -DNO_GDB
|
||||
XMAKEENV= ${BOOTSTRAPENV} \
|
||||
TARGET_ARCH=${MACHINE_ARCH}
|
||||
XMAKE= ${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
|
||||
-DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE \
|
||||
-DNOSHARED
|
||||
|
||||
# world stage
|
||||
WMAKEENV= ${CROSSENV} \
|
||||
@@ -237,8 +230,12 @@ 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
|
||||
.if ${MACHINE_ARCH} == "i386" && ${MACHINE} == "pc98"
|
||||
USRDIRS+= usr/libexec/aout
|
||||
.endif
|
||||
|
||||
INCDIRS= arpa g++/std isc objc protocols readline rpc rpcsvc openssl \
|
||||
security ss
|
||||
|
||||
#
|
||||
# buildworld
|
||||
@@ -246,7 +243,7 @@ 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"
|
||||
@@ -254,9 +251,12 @@ _worldtmp:
|
||||
.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
|
||||
for dir in bin games include lib sbin share; do \
|
||||
rm -rf ${WORLDTMP}/usr/$$dir; \
|
||||
done
|
||||
# XXX - Work-around for broken cc/cc_tools/Makefile.
|
||||
# This is beyond dirty...
|
||||
rm -f ${OBJTREE}${.CURDIR}/gnu/usr.bin/cc/cc_tools/.depend
|
||||
.endif
|
||||
.for _dir in ${USRDIRS}
|
||||
mkdir -p ${WORLDTMP}/${_dir}
|
||||
@@ -265,120 +265,73 @@ _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 "--------------------------------------------------------------"
|
||||
@echo ">>> stage 2: cleaning up the object tree"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/}
|
||||
cd ${.CURDIR}; ${TMAKE} ${CLEANDIR:S/^/par-/}
|
||||
.endif
|
||||
_obj:
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> stage 2: rebuilding the object tree"
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; ${WMAKE} par-obj
|
||||
_build-tools:
|
||||
cd ${.CURDIR}; ${TMAKE} par-obj
|
||||
@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
|
||||
|
||||
everything:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> 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}
|
||||
|
||||
#
|
||||
# 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."; \
|
||||
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."; \
|
||||
false; \
|
||||
fi
|
||||
.endfor
|
||||
|
||||
#
|
||||
# distributeworld
|
||||
#
|
||||
# Distributes everything compiled by a `buildworld'.
|
||||
#
|
||||
# installworld
|
||||
#
|
||||
# Installs everything compiled by a 'buildworld'.
|
||||
#
|
||||
distributeworld installworld: installcheck
|
||||
installworld:
|
||||
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 +351,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,24 +359,27 @@ 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
|
||||
#
|
||||
# Which kernels to build and/or install is specified by setting
|
||||
# KERNCONF. If not defined a GENERIC kernel is built/installed.
|
||||
# Only the existing (depending TARGET) config files are used
|
||||
# Only the existing (depending MACHINE) config files are used
|
||||
# for building kernels and only the first of these is designated
|
||||
# as the one being installed.
|
||||
#
|
||||
# Note that we have to use TARGET instead of TARGET_ARCH when
|
||||
# we're in kernel-land. Since only TARGET_ARCH is (expected) to
|
||||
# be set to cross-build, we have to make sure TARGET is set
|
||||
# Note that we have to use MACHINE instead of MACHINE_ARCH when
|
||||
# we're in kernel-land. Since only MACHINE_ARCH is (expected) to
|
||||
# be set to cross-build, we have to make sure MACHINE is set
|
||||
# properly.
|
||||
|
||||
.if !defined(KERNCONF) && defined(KERNEL)
|
||||
@@ -434,15 +390,21 @@ KERNCONF?= GENERIC
|
||||
.endif
|
||||
INSTKERNNAME?= kernel
|
||||
|
||||
# The only exotic MACHINE_ARCH/MACHINE combination valid at this
|
||||
# time is i386/pc98. In all other cases set MACHINE equal to
|
||||
# MACHINE_ARCH.
|
||||
.if ${MACHINE_ARCH} != "i386" || ${MACHINE} != "pc98"
|
||||
MACHINE= ${MACHINE_ARCH}
|
||||
.endif
|
||||
|
||||
KRNLSRCDIR= ${.CURDIR}/sys
|
||||
KRNLCONFDIR= ${KRNLSRCDIR}/${TARGET}/conf
|
||||
KRNLCONFDIR= ${KRNLSRCDIR}/${MACHINE}/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,26 +438,21 @@ 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)
|
||||
cd ${KRNLOBJDIR}/${_kernel}; \
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} -DNO_MODULES clean
|
||||
.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KRNLSRCDIR}/modules)
|
||||
cd ${KRNLOBJDIR}/${_kernel}; \
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} cleandir
|
||||
.endif
|
||||
${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} clean
|
||||
.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
|
||||
${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} depend
|
||||
.endif
|
||||
cd ${KRNLOBJDIR}/${_kernel}; \
|
||||
${KMAKEENV} ${MAKE} KERNEL=${INSTKERNNAME} all
|
||||
${KMAKEENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} all
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`"
|
||||
@echo "--------------------------------------------------------------"
|
||||
@@ -506,22 +463,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} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} install
|
||||
reinstallkernel:
|
||||
cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
|
||||
${CROSSENV} MACHINE=${MACHINE} ${MAKE} KERNEL=${INSTKERNNAME} reinstall
|
||||
|
||||
#
|
||||
# kernel
|
||||
#
|
||||
# Short hand for `make buildkernel installkernel'
|
||||
#
|
||||
kernel: buildkernel installkernel
|
||||
|
||||
#
|
||||
# update
|
||||
@@ -554,7 +508,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_4 -P -d
|
||||
.endif
|
||||
|
||||
#
|
||||
@@ -566,9 +520,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 +539,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 +567,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} install
|
||||
.endfor
|
||||
|
||||
#
|
||||
@@ -630,38 +592,40 @@ _share= share/syscons/scrnmaps
|
||||
_fortran= gnu/usr.bin/cc/f771
|
||||
.endif
|
||||
|
||||
.if !defined(NOPERL)
|
||||
_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
|
||||
!defined(NOCRYPT) && defined(MAKE_KERBEROS5)
|
||||
_libkrb5= kerberos5/lib/libasn1 kerberos5/lib/libhdb kerberos5/lib/libsl
|
||||
.endif
|
||||
|
||||
.if defined(RELEASEDIR)
|
||||
_sysinstall= release/sysinstall
|
||||
.if !defined(NOPERL)
|
||||
_perl= gnu/usr.bin/perl
|
||||
.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
|
||||
${_libroken4} ${_libkrb5} lib/libncurses ${_share} ${_perl} usr.bin/file
|
||||
cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
|
||||
.endfor
|
||||
|
||||
#
|
||||
# cross-tools: Build cross-building tools
|
||||
#
|
||||
# WARNING: Because the bootstrap tools are expected to run on the
|
||||
# build-machine, MACHINE_ARCH is *always* set to BUILD_ARCH when this
|
||||
# target is being made. TARGET_ARCH is *always* set to reflect the
|
||||
# target-machine (which you can set by specifying MACHINE_ARCH on
|
||||
# make's command-line, get it?).
|
||||
# The reason is simple: we build these tools not to be run on the
|
||||
# architecture we're cross-building, but on the architecture we're
|
||||
# currently building on (ie the host-machine) and we expect these
|
||||
# tools to produce output for the architecture we're trying to
|
||||
# cross-build.
|
||||
#
|
||||
.if ${TARGET_ARCH} == "alpha" && ${MACHINE_ARCH} != "alpha"
|
||||
_elf2exe= usr.sbin/elf2exe
|
||||
.endif
|
||||
@@ -670,16 +634,19 @@ _elf2exe= usr.sbin/elf2exe
|
||||
_btxld= usr.sbin/btxld
|
||||
.endif
|
||||
|
||||
# XXX - MACHINE should actually be TARGET. But we don't set that...
|
||||
.if ${TARGET_ARCH} == "i386" && ${MACHINE} == "pc98"
|
||||
_aout_tools= usr.bin/size usr.bin/strip gnu/usr.bin/as gnu/usr.bin/ld
|
||||
.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 ${_aout_tools} ${_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} install
|
||||
.endfor
|
||||
|
||||
#
|
||||
@@ -688,96 +655,166 @@ 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)
|
||||
.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
|
||||
.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
|
||||
.if !defined(WANT_CSRG_LIBM)
|
||||
cd ${.CURDIR}/lib/msun; ${MAKE} beforeinstall
|
||||
.endif
|
||||
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/libss; ${MAKE} -B hdrs 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++: libm
|
||||
# libkrb: libcrypt
|
||||
# libopie: libmd
|
||||
# libpam: libcom_err libcrypt libcrypto libkrb libopie libradius \
|
||||
# libskey libtacplus libutil libz libssh
|
||||
# libradius: libmd
|
||||
# libreadline: libncurses
|
||||
# libskey: libcrypt libmd
|
||||
# libss: libcom_err
|
||||
# libstc++: libm
|
||||
# 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/libm 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(WANT_CSRG_LIBM)
|
||||
_libm= lib/libm
|
||||
.else
|
||||
_libm= lib/msun
|
||||
.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 ${_libm} 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 \
|
||||
|
||||
@@ -19,13 +19,13 @@ standard build targets and compile-time flags.
|
||||
|
||||
Building a kernel is a somewhat more involved process, documentation
|
||||
for which can be found at:
|
||||
http://www.FreeBSD.org/handbook/kernelconfig.html
|
||||
http://www.freebsd.org/handbook/kernelconfig.html
|
||||
And in the config(8) man page.
|
||||
Note: If you want to build and install the kernel with the
|
||||
``buildkernel'' and ``installkernel'' targets, you might need to build
|
||||
``buildkernel'' and ``installkernel'' targets, you have to build
|
||||
world before. More information is available in the handbook.
|
||||
|
||||
The sample kernel configuration files reside in the sys/<arch>/conf
|
||||
The sample kernel configuration files reside in the sys/i386/conf
|
||||
sub-directory (assuming that you've installed the kernel sources), the
|
||||
file named GENERIC being the one used to build your initial installation
|
||||
kernel. The file LINT contains entries for all possible devices, not
|
||||
@@ -36,13 +36,13 @@ wouldn't even run).
|
||||
|
||||
Source Roadmap:
|
||||
---------------
|
||||
bin System/user commands.
|
||||
bin System/User commands.
|
||||
|
||||
contrib Packages contributed by 3rd parties.
|
||||
|
||||
crypto Cryptography stuff (see crypto/README).
|
||||
|
||||
etc Template files for /etc.
|
||||
etc Template files for /etc
|
||||
|
||||
games Amusements.
|
||||
|
||||
@@ -51,9 +51,7 @@ gnu Various commands and libraries under the GNU Public License.
|
||||
|
||||
include System include files.
|
||||
|
||||
kerberos5 Kerberos5 (Heimdal) package.
|
||||
|
||||
kerberosIV KerberosIV (eBones) package.
|
||||
kerberosIV Kerberos package.
|
||||
|
||||
lib System libraries.
|
||||
|
||||
@@ -79,4 +77,4 @@ usr.sbin System administration commands.
|
||||
For information on synchronizing your source tree with one or more of
|
||||
the FreeBSD Project's development branches, please see:
|
||||
|
||||
http://www.FreeBSD.org/handbook/synching.html
|
||||
http://www.freebsd.org/handbook/synching.html
|
||||
@@ -1,244 +1,16 @@
|
||||
Updating Information for FreeBSD STABLE users
|
||||
|
||||
This file is maintained and copyrighted by M. Warner Losh
|
||||
<[email protected]>. See end of file for further details. For commonly
|
||||
done items, please see the COMMON ITEMS: section later in the file.
|
||||
<[email protected]>. Please send new entries directly to him. See end
|
||||
of file for further details. For commonly done items, please see the
|
||||
COMMON ITEMS: section later in the file.
|
||||
|
||||
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
|
||||
ENABLE_SUID_K5SU=yes to /etc/make.conf to have it installed
|
||||
with the set-user-ID bit set.
|
||||
|
||||
20020501:
|
||||
The ephemeral port range change that was previously mentioned
|
||||
in this document has been reverted, so any changes it required
|
||||
to your system may be reverted as well. Those who missed the
|
||||
change should ignore this notice.
|
||||
|
||||
20020421:
|
||||
inetd_enable was changed back to YES, to match the defaults
|
||||
earlier in the 4.0-stable branch. This change restores the
|
||||
daemons that were enabled prior to April 15th.
|
||||
|
||||
When exec'ing set[ug]id executables, the kernel now ensures that the
|
||||
stdio file descriptors (0..2) are open. See FreeBSD-SA-02:23.stdio.
|
||||
|
||||
20020420:
|
||||
sendmail_enable was changed back to YES, to match the
|
||||
defaults earlier in the 4.0-stable branch.
|
||||
|
||||
20020415:
|
||||
Many denizens of /etc were MFC'ed. While most of the changes
|
||||
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.
|
||||
|
||||
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
|
||||
to your system.
|
||||
|
||||
The two most important changes to note: sendmail and inetd were
|
||||
turned off by default. If you need them, please turn them back
|
||||
on by adding sendmail_enable=YES and/or inetd_enable=YES to
|
||||
/etc/rc.conf.
|
||||
|
||||
20020411:
|
||||
New sendmail startup scripts have been installed to make it
|
||||
easier to use alternative MTAs with FreeBSD. The rc.conf
|
||||
variable mta_start_script can be set to a script for starting
|
||||
an alternative MTA or to "" to prevent any MTA from being
|
||||
started at boot.
|
||||
|
||||
20020404:
|
||||
The sendmail startup code in /etc/rc has been changed to deal
|
||||
with a non-set-user-ID sendmail binary. Setting the rc.conf
|
||||
variable sendmail_enable to "NO" no longer prevents any sendmail
|
||||
daemons from starting. Instead, set sendmail_enable to "NONE"
|
||||
to prevent any MTA from being started at boot.
|
||||
|
||||
20020404:
|
||||
Due to the import of sendmail 8.12.2 (see 20020325 entry), a new
|
||||
user and group are required in order for sendmail to run as a
|
||||
set-group-ID binary. A 'make installworld' will use the new user
|
||||
and group to set the owner and group of /var/spool/clientmqueue
|
||||
and will fail if the new user and group do not exist. The 'smmsp'
|
||||
user and group must be merged from src/etc/group and
|
||||
src/etc/master.passwd before using 'make installworld'.
|
||||
'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
|
||||
|
||||
20020325:
|
||||
sendmail 8.12.2 has been imported. The sendmail binary is no
|
||||
longer a set-user-ID root binary and the infrastructure to support
|
||||
command line mail submission has changed. Be sure to run
|
||||
mergemaster (especially for updating /etc/rc, /etc/defaults/rc.conf,
|
||||
and /etc/mail) and read /etc/mail/README for more details.
|
||||
|
||||
20020318:
|
||||
The ata(4) driver has been updated from the version in -CURRENT.
|
||||
As a result, some device nodes in /dev have changed; it will be
|
||||
necessary to update MAKEDEV and re-make the device nodes.
|
||||
mergemaster(8) will offer to do this as a part of its upgrade
|
||||
procedure.
|
||||
|
||||
20020129:
|
||||
FreeBSD 4.5-RELEASE.
|
||||
|
||||
20020105:
|
||||
The locale names have been renamed in -stable to match
|
||||
-current:
|
||||
1. ISO_* -> ISO*
|
||||
2. ru_SU* -> ru_RU*
|
||||
3. DIS_* -> ISO*-15
|
||||
4. *.ASCII -> *.US-ASCII
|
||||
|
||||
20011202:
|
||||
A security hole in OpenSSH involving `UseLogin yes' has been
|
||||
patched.
|
||||
|
||||
20011110:
|
||||
Some linux module changes, merged from current, require that you
|
||||
clean out the old compile directory. If you are building with
|
||||
MODULES_WITH_WORLD=yes, then you need to cd to src/sys/modules/linux
|
||||
and run "make cleandir". If not, then you need to cd
|
||||
src/sys/compile/$KERNCONF and do a make modules-clean.
|
||||
|
||||
20011102:
|
||||
ipfw/bridge/dummynet features merged from current.
|
||||
|
||||
20011018:
|
||||
The kernel Makefile was enhanced to pass -g to modules builds
|
||||
when it is used for kernel building (eg, when the config file
|
||||
has DEBUG=-g). People that have enabled debugging kernels
|
||||
will find they need significantly more disk space in their
|
||||
slash (/) partition.
|
||||
|
||||
20010928:
|
||||
The OpenSSH `ChallengeResponseAuthentication' option now
|
||||
defaults to `yes'. This enables S/Key authentication, which
|
||||
can result in users receiving an S/Key challenge when logging
|
||||
in interactively. To disable this behavior, add a line to
|
||||
your /etc/ssh/sshd_config file:
|
||||
`ChallengeResponseAuthentication no'
|
||||
|
||||
20010914:
|
||||
4.4 Released.
|
||||
20010915:
|
||||
FreeBSD 4.4-RELEASE.
|
||||
|
||||
20010814:
|
||||
The pci attachment for pcic device was merged from current. You
|
||||
@@ -534,7 +306,7 @@ COMMON ITEMS:
|
||||
mount -u /
|
||||
mount -a
|
||||
cd /usr/src
|
||||
adjkerntz -i # if CMOS is wall time
|
||||
adjkerntz -i # if COMS is wall time
|
||||
|
||||
To update from 4.0-RELEASE or later to the most current
|
||||
4.x-STABLE
|
||||
@@ -870,7 +642,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.
|
||||
|
||||
@@ -1186,7 +958,7 @@ that the style, formatting, etc of this file can be maintained.
|
||||
|
||||
Copyright information:
|
||||
|
||||
Copyright 1998-2002 M. Warner Losh. All Rights Reserved.
|
||||
Copyright 1998, 2001 M. Warner Losh. All Rights Reserved.
|
||||
|
||||
Redistribution, translation and use, with or without modification, in
|
||||
full or in part, are permitted provided that the above copyright
|
||||
|
||||
@@ -4,3 +4,13 @@
|
||||
BINDIR?= /bin
|
||||
CFLAGS+= -Wall -Wformat
|
||||
NOSHARED?= YES
|
||||
|
||||
.if exists (${.CURDIR}/../../secure)
|
||||
|
||||
.if exists(${.CURDIR}/../../secure/lib/libcipher/obj)
|
||||
CIPHEROBJDIR= ${.CURDIR}/../../secure/lib/libcipher/obj
|
||||
.else
|
||||
CIPHEROBJDIR= ${.CURDIR}/../../secure/lib/libcipher
|
||||
.endif
|
||||
|
||||
.endif
|
||||
+1
-13
@@ -35,7 +35,7 @@
|
||||
.\" @(#)cat.1 8.3 (Berkeley) 5/2/95
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd September 15, 2001
|
||||
.Dd May 2, 1995
|
||||
.Dt CAT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -59,18 +59,6 @@ is a single dash
|
||||
or absent,
|
||||
.Nm
|
||||
reads from the standard input.
|
||||
If
|
||||
.Ar file
|
||||
is a
|
||||
.Ux
|
||||
domain socket,
|
||||
.Nm
|
||||
connects to it and then reads it until
|
||||
.Dv EOF .
|
||||
This complements the
|
||||
.Ux
|
||||
domain binding capability available in
|
||||
.Xr inetd 8 .
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
|
||||
+58
-116
@@ -50,11 +50,6 @@ static const char rcsid[] =
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef NO_UDOM_SUPPORT
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
@@ -64,21 +59,16 @@ static const char rcsid[] =
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stddef.h>
|
||||
|
||||
int bflag, eflag, nflag, sflag, tflag, vflag;
|
||||
int rval;
|
||||
const char *filename;
|
||||
|
||||
void cook_args __P((char *argv[]));
|
||||
void cook_buf __P((FILE *));
|
||||
int main __P((int argc, char *argv[]));
|
||||
|
||||
static void scanfiles __P((char **argv, int cooked));
|
||||
static void cook_cat __P((FILE *));
|
||||
static void raw_cat __P((int));
|
||||
|
||||
#ifndef NO_UDOM_SUPPORT
|
||||
static int udom_open __P((const char *path, int flags));
|
||||
#endif
|
||||
void raw_args __P((char *argv[]));
|
||||
void raw_cat __P((int));
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
@@ -113,76 +103,53 @@ main(argc, argv)
|
||||
vflag = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
(void)fprintf(stderr,
|
||||
"usage: cat [-benstuv] [-] [file ...]\n");
|
||||
exit(1);
|
||||
}
|
||||
argv += optind;
|
||||
|
||||
if (bflag || eflag || nflag || sflag || tflag || vflag)
|
||||
scanfiles(argv, 1);
|
||||
cook_args(argv);
|
||||
else
|
||||
scanfiles(argv, 0);
|
||||
raw_args(argv);
|
||||
if (fclose(stdout))
|
||||
err(1, "stdout");
|
||||
exit(rval);
|
||||
}
|
||||
|
||||
void
|
||||
scanfiles(argv, cooked)
|
||||
char **argv;
|
||||
int cooked;
|
||||
cook_args(argv)
|
||||
char **argv;
|
||||
{
|
||||
int i = 0;
|
||||
char *path;
|
||||
FILE *fp;
|
||||
register FILE *fp;
|
||||
|
||||
while ((path = argv[i]) != NULL || i == 0) {
|
||||
int fd;
|
||||
|
||||
if (path == NULL || strcmp(path, "-") == 0) {
|
||||
filename = "stdin";
|
||||
fd = STDIN_FILENO;
|
||||
} else {
|
||||
filename = path;
|
||||
fd = open(path, O_RDONLY);
|
||||
#ifndef NO_UDOM_SUPPORT
|
||||
if (fd < 0 && errno == EOPNOTSUPP)
|
||||
fd = udom_open(path, O_RDONLY);
|
||||
#endif
|
||||
}
|
||||
if (fd < 0) {
|
||||
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);
|
||||
fp = stdin;
|
||||
filename = "stdin";
|
||||
do {
|
||||
if (*argv) {
|
||||
if (!strcmp(*argv, "-"))
|
||||
fp = stdin;
|
||||
else if ((fp = fopen(*argv, "r")) == NULL) {
|
||||
warn("%s", *argv);
|
||||
rval = 1;
|
||||
++argv;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
raw_cat(fd);
|
||||
if (fd != STDIN_FILENO)
|
||||
close(fd);
|
||||
filename = *argv++;
|
||||
}
|
||||
if (path == NULL)
|
||||
break;
|
||||
++i;
|
||||
}
|
||||
cook_buf(fp);
|
||||
if (fp != stdin)
|
||||
(void)fclose(fp);
|
||||
} while (*argv);
|
||||
}
|
||||
|
||||
static void
|
||||
cook_cat(fp)
|
||||
void
|
||||
cook_buf(fp)
|
||||
register FILE *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') {
|
||||
@@ -194,12 +161,12 @@ cook_cat(fp)
|
||||
continue;
|
||||
}
|
||||
if (nflag && !bflag) {
|
||||
fprintf(stdout, "%6d\t", ++line);
|
||||
(void)fprintf(stdout, "%6d\t", ++line);
|
||||
if (ferror(stdout))
|
||||
break;
|
||||
}
|
||||
} else if (nflag) {
|
||||
fprintf(stdout, "%6d\t", ++line);
|
||||
(void)fprintf(stdout, "%6d\t", ++line);
|
||||
if (ferror(stdout))
|
||||
break;
|
||||
}
|
||||
@@ -241,14 +208,40 @@ cook_cat(fp)
|
||||
err(1, "stdout");
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
raw_args(argv)
|
||||
char **argv;
|
||||
{
|
||||
register int fd;
|
||||
|
||||
fd = fileno(stdin);
|
||||
filename = "stdin";
|
||||
do {
|
||||
if (*argv) {
|
||||
if (!strcmp(*argv, "-"))
|
||||
fd = fileno(stdin);
|
||||
else if ((fd = open(*argv, O_RDONLY, 0)) < 0) {
|
||||
warn("%s", *argv);
|
||||
rval = 1;
|
||||
++argv;
|
||||
continue;
|
||||
}
|
||||
filename = *argv++;
|
||||
}
|
||||
raw_cat(fd);
|
||||
if (fd != fileno(stdin))
|
||||
(void)close(fd);
|
||||
} while (*argv);
|
||||
}
|
||||
|
||||
void
|
||||
raw_cat(rfd)
|
||||
register int rfd;
|
||||
{
|
||||
register int off, wfd;
|
||||
ssize_t nr, nw;
|
||||
static size_t bsize;
|
||||
static char *buf = NULL;
|
||||
static char *buf;
|
||||
struct stat sbuf;
|
||||
|
||||
wfd = fileno(stdout);
|
||||
@@ -268,54 +261,3 @@ raw_cat(rfd)
|
||||
rval = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NO_UDOM_SUPPORT
|
||||
|
||||
static int
|
||||
udom_open(path, flags)
|
||||
const char *path;
|
||||
int flags;
|
||||
{
|
||||
struct sockaddr_un sou;
|
||||
int fd;
|
||||
unsigned int len;
|
||||
|
||||
bzero(&sou, sizeof(sou));
|
||||
|
||||
/*
|
||||
* Construct the unix domain socket address and attempt to connect
|
||||
*/
|
||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd >= 0) {
|
||||
sou.sun_family = AF_UNIX;
|
||||
snprintf(sou.sun_path, sizeof(sou.sun_path), "%s", path);
|
||||
len = strlen(sou.sun_path);
|
||||
len = offsetof(struct sockaddr_un, sun_path[len+1]);
|
||||
|
||||
if (connect(fd, (void *)&sou, len) < 0) {
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* handle the open flags by shutting down appropriate directions
|
||||
*/
|
||||
if (fd >= 0) {
|
||||
switch(flags & O_ACCMODE) {
|
||||
case O_RDONLY:
|
||||
if (shutdown(fd, SHUT_WR) == -1)
|
||||
perror("cat");
|
||||
break;
|
||||
case O_WRONLY:
|
||||
if (shutdown(fd, SHUT_RD) == -1)
|
||||
perror("cat");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(fd);
|
||||
}
|
||||
|
||||
#endif
|
||||
+3
-4
@@ -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
|
||||
|
||||
+37
-33
@@ -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
|
||||
@@ -207,11 +211,11 @@ symbol ``X'' are only meaningful in conjunction with the
|
||||
.Ar op
|
||||
symbol ``+'', and are ignored in all other cases.
|
||||
.It u
|
||||
The user permission bits in the original mode of the file.
|
||||
The user permission bits in the mode of the original file.
|
||||
.It g
|
||||
The group permission bits in the original mode of the file.
|
||||
The group permission bits in the mode of the original file.
|
||||
.It o
|
||||
The other permission bits in the original mode of the file.
|
||||
The other permission bits in the mode of the original file.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
|
||||
+28
-21
@@ -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
@@ -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 ,
|
||||
|
||||
+15
-52
@@ -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;
|
||||
@@ -252,14 +248,6 @@ copy(argv, type, fts_options)
|
||||
FTSENT *curr;
|
||||
int base = 0, dne, badcp, nlen, rval;
|
||||
char *p, *target_mid;
|
||||
mode_t mask, mode;
|
||||
|
||||
/*
|
||||
* Keep an inverted copy of the umask, for use in correcting
|
||||
* permissions on created directories when not using -p.
|
||||
*/
|
||||
mask = ~umask(0777);
|
||||
umask(~mask);
|
||||
|
||||
if ((ftsp = fts_open(argv, fts_options, mastercmp)) == NULL)
|
||||
err(1, NULL);
|
||||
@@ -276,6 +264,8 @@ copy(argv, type, fts_options)
|
||||
warnx("%s: directory causes a cycle", curr->fts_path);
|
||||
badcp = rval = 1;
|
||||
continue;
|
||||
case FTS_DP: /* Ignore, continue. */
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -333,38 +323,6 @@ copy(argv, type, fts_options)
|
||||
STRIP_TRAILING_SLASH(to);
|
||||
}
|
||||
|
||||
if (curr->fts_info == FTS_DP) {
|
||||
/*
|
||||
* We are nearly finished with this directory. If we
|
||||
* didn't actually copy it, or otherwise don't need to
|
||||
* change its attributes, then we are done.
|
||||
*/
|
||||
if (!curr->fts_number)
|
||||
continue;
|
||||
/*
|
||||
* If -p is in effect, set all the attributes.
|
||||
* Otherwise, set the correct permissions, limited
|
||||
* by the umask. Optimise by avoiding a chmod()
|
||||
* if possible (which is usually the case if we
|
||||
* made the directory). Note that mkdir() does not
|
||||
* 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 {
|
||||
mode = curr->fts_statp->st_mode;
|
||||
if ((mode & (S_ISUID | S_ISGID | S_ISTXT)) ||
|
||||
((mode | S_IRWXU) & mask) != (mode & mask))
|
||||
if (chmod(to.p_path, mode & mask) != 0){
|
||||
warn("chmod: %s", to.p_path);
|
||||
rval = 1;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Not an error but need to remember it happened */
|
||||
if (stat(to.p_path, &to_stat) == -1)
|
||||
dne = 1;
|
||||
@@ -418,11 +376,16 @@ copy(argv, type, fts_options)
|
||||
err(1, "%s", to.p_path);
|
||||
}
|
||||
/*
|
||||
* Arrange to correct directory attributes later
|
||||
* (in the post-order phase) if this is a new
|
||||
* directory, or if the -p flag is in effect.
|
||||
* If not -p and directory didn't exist, set it to be
|
||||
* the same as the from directory, umodified by the
|
||||
* umask; arguably wrong, but it's been that way
|
||||
* forever.
|
||||
*/
|
||||
curr->fts_number = pflag || dne;
|
||||
if (pflag && setfile(curr->fts_statp, 0))
|
||||
badcp = rval = 1;
|
||||
else if (dne)
|
||||
(void)chmod(to.p_path,
|
||||
curr->fts_statp->st_mode);
|
||||
break;
|
||||
case S_IFBLK:
|
||||
case S_IFCHR:
|
||||
|
||||
+1
-1
@@ -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>
|
||||
|
||||
|
||||
+18
-30
@@ -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))) {
|
||||
warn("chmod: %s", to.p_path);
|
||||
if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode)) {
|
||||
warn("chown: %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);
|
||||
}
|
||||
@@ -41,9 +41,6 @@ LINKS= ${BINDIR}/csh ${BINDIR}/tcsh
|
||||
|
||||
CLEANFILES= ${GENHDRS} gethost csh.1
|
||||
|
||||
FILESDIR= ${SHAREDIR}/examples/tcsh
|
||||
FILES= complete.tcsh csh-mode.el
|
||||
|
||||
csh.1: tcsh.man
|
||||
ln -sf ${.ALLSRC} ${.TARGET}
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -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
File diff suppressed because it is too large.
Load diff
@@ -129,9 +129,6 @@
|
||||
#define NLS_BUGS
|
||||
/* 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__)
|
||||
|
||||
+4
-12
@@ -1,5 +1,5 @@
|
||||
newcode :
|
||||
/* $Header: /src/pub/tcsh/host.defs,v 1.31 2001/06/10 02:19:11 christos Exp $ */
|
||||
/* $Header: /src/pub/tcsh/host.defs,v 1.28 2000/11/11 23:03:35 christos Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
/*
|
||||
* host.defs: Hosttype/Machtype etc.
|
||||
@@ -38,7 +38,7 @@ newcode :
|
||||
*/
|
||||
#include "sh.h"
|
||||
|
||||
RCSID("$Id: host.defs,v 1.31 2001/06/10 02:19:11 christos Exp $")
|
||||
RCSID("$Id: host.defs,v 1.28 2000/11/11 23:03:35 christos Exp $")
|
||||
|
||||
endcode :
|
||||
|
||||
@@ -478,8 +478,8 @@ vendor : defined(M_intel) : "intel"
|
||||
vendor : defined(m68k) : "motorola"
|
||||
vendor : defined(mac68k) : "apple"
|
||||
vendor : defined(pc532) : "national-semi"
|
||||
vendor : defined(pmax) : "dec"
|
||||
vendor : defined(mips) : "mips"
|
||||
vendor : defined(pmax) || defined(mips) : "dec"
|
||||
vendor : defined(M_mipsel) : "dec"
|
||||
vendor : defined(sparc) : "sun"
|
||||
vendor : defined(sun3) : "sun"
|
||||
vendor : defined(vax) : "digital"
|
||||
@@ -542,14 +542,6 @@ ostype : : "coherent"
|
||||
machtype: defined(_I386) : "i386"
|
||||
enddef :
|
||||
|
||||
newdef : defined(concurrent)
|
||||
comment : Concurrent PowerHawk
|
||||
vendor : : "concurrent"
|
||||
hosttype: : "powerhawk"
|
||||
ostype : : "powermax_os"
|
||||
machtype: : "powerhawk"
|
||||
enddef :
|
||||
|
||||
newdef : defined(SCO)
|
||||
comment : SCO UNIX System V/386 Release 3.2
|
||||
vendor : : "sco"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# $FreeBSD$
|
||||
|
||||
SUBDIR= finnish french german greek italian ja russian spanish ukrainian
|
||||
SUBDIR= finnish french german greek italian ja spanish ukrainian
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
@@ -13,3 +13,5 @@ CLEANFILES+= tcsh.cat tcsh.msg
|
||||
all: tcsh.cat
|
||||
|
||||
tcsh.cat: tcsh.msg
|
||||
|
||||
distribute:
|
||||
@@ -1,16 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
NL= et
|
||||
DL= et_EE.ISO8859-15
|
||||
|
||||
.PATH: ${BASESRC}/${NL}
|
||||
|
||||
tcsh.msg: set[0-9]*
|
||||
cat ${BASESRC}/${NL}/set[0-9] \
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,8 +1,8 @@
|
||||
# $FreeBSD$
|
||||
|
||||
NL= finnish
|
||||
DL= fi_FI.ISO8859-1
|
||||
LL= fi_FI.ISO8859-15
|
||||
DL= fi_FI.ISO_8859-1
|
||||
LL= fi_FI.DIS_8859-15
|
||||
|
||||
.PATH: ${BASESRC}/${NL}
|
||||
|
||||
@@ -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,10 +1,10 @@
|
||||
# $FreeBSD$
|
||||
|
||||
NL= french
|
||||
DL= fr_FR.ISO8859-1
|
||||
LL= fr_BE.ISO8859-1 fr_CA.ISO8859-1 fr_CH.ISO8859-1 \
|
||||
fr_BE.ISO8859-15 fr_CA.ISO8859-15 fr_CH.ISO8859-15 \
|
||||
fr_FR.ISO8859-15
|
||||
DL= fr_FR.ISO_8859-1
|
||||
LL= fr_BE.ISO_8859-1 fr_CA.ISO_8859-1 fr_CH.ISO_8859-1 \
|
||||
fr_BE.DIS_8859-15 fr_CA.DIS_8859-15 fr_CH.DIS_8859-15 \
|
||||
fr_FR.DIS_8859-15
|
||||
|
||||
.PATH: ${BASESRC}/${NL}
|
||||
|
||||
@@ -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,9 +1,9 @@
|
||||
# $FreeBSD$
|
||||
|
||||
NL= german
|
||||
DL= de_DE.ISO8859-1
|
||||
LL= de_AT.ISO8859-1 de_CH.ISO8859-1 de_AT.ISO8859-15 \
|
||||
de_CH.ISO8859-15 de_DE.ISO8859-15
|
||||
DL= de_DE.ISO_8859-1
|
||||
LL= de_AT.ISO_8859-1 de_CH.ISO_8859-1 de_AT.DIS_8859-15 \
|
||||
de_CH.DIS_8859-15 de_DE.DIS_8859-15
|
||||
|
||||
.PATH: ${BASESRC}/${NL}
|
||||
|
||||
@@ -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,7 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
NL= greek
|
||||
DL= el_GR.ISO8859-7
|
||||
DL= el_GR.ISO_8859-7
|
||||
|
||||
.PATH: ${BASESRC}/${NL}
|
||||
|
||||
@@ -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,8 +1,8 @@
|
||||
# $FreeBSD$
|
||||
|
||||
NL= italian
|
||||
DL= it_IT.ISO8859-1
|
||||
LL= it_CH.ISO8859-1 it_IT.ISO8859-15 it_CH.ISO8859-15
|
||||
DL= it_IT.ISO_8859-1
|
||||
LL= it_CH.ISO_8859-1 it_IT.DIS_8859-15 it_CH.DIS_8859-15
|
||||
|
||||
.PATH: ${BASESRC}/${NL}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,16 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
NL= russian
|
||||
DL= ru_RU.KOI8-R
|
||||
|
||||
.PATH: ${BASESRC}/${NL}
|
||||
|
||||
tcsh.msg: set[0-9]*
|
||||
cat ${BASESRC}/${NL}/set[0-9] \
|
||||
${BASESRC}/${NL}/set[0-9][0-9] > ${.TARGET}
|
||||
|
||||
install:
|
||||
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
|
||||
tcsh.cat ${DESTDIR}${NLSDIR}/${DL}/tcsh.cat
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,8 +1,8 @@
|
||||
# $FreeBSD$
|
||||
|
||||
NL= spanish
|
||||
DL= es_ES.ISO8859-1
|
||||
LL= es_ES.ISO8859-15
|
||||
DL= es_ES.ISO_8859-1
|
||||
LL= es_ES.DIS_8859-15
|
||||
|
||||
.PATH: ${BASESRC}/${NL}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
-53
@@ -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
|
||||
@@ -72,12 +72,6 @@ Otherwise, depending on the options specified,
|
||||
.Nm
|
||||
will set the date and time or print it in a user-defined way.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
utility displays the date and time read from the kernel clock.
|
||||
When used to set the date and time,
|
||||
both the kernel clock and the hardware clock are updated.
|
||||
.Pp
|
||||
Only the superuser may set the date,
|
||||
and if the system securelevel (see
|
||||
.Xr securelevel 8 )
|
||||
@@ -168,7 +162,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 +213,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 +262,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 +273,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" ,
|
||||
|
||||
+1
-3
@@ -83,7 +83,6 @@ main(argc, argv)
|
||||
int jflag, nflag;
|
||||
char *format, buf[1024];
|
||||
char *endptr, *fmt;
|
||||
char *tmp;
|
||||
int set_timezone;
|
||||
struct vary *v;
|
||||
const struct vary *badv;
|
||||
@@ -115,8 +114,7 @@ main(argc, argv)
|
||||
break;
|
||||
case 'r': /* user specified seconds */
|
||||
rflag = 1;
|
||||
tval = strtoq(optarg, &tmp, 0);
|
||||
if (*tmp != 0)
|
||||
if (sscanf(optarg,"%li",&tval) != 1)
|
||||
usage();
|
||||
break;
|
||||
case 't': /* minutes west of UTC */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+43
-52
@@ -43,7 +43,7 @@
|
||||
.Nd convert and copy a file
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Ar operands ...
|
||||
.Op operands ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
@@ -57,10 +57,10 @@ 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"
|
||||
.It Cm bs Ns = Ns Ar n
|
||||
.Bl -tag -width of=file
|
||||
.It Cm bs= Ns Ar n
|
||||
Set both input and output block size to
|
||||
.Ar n
|
||||
.Va n
|
||||
bytes, superseding the
|
||||
.Cm ibs
|
||||
and
|
||||
@@ -73,40 +73,40 @@ or
|
||||
.Cm sync
|
||||
are specified, then each input block is copied to the output as a
|
||||
single block without any aggregation of short blocks.
|
||||
.It Cm cbs Ns = Ns Ar n
|
||||
.It Cm cbs= Ns Ar n
|
||||
Set the conversion record size to
|
||||
.Ar n
|
||||
.Va n
|
||||
bytes.
|
||||
The conversion record size is required by the record oriented conversion
|
||||
values.
|
||||
.It Cm count Ns = Ns Ar n
|
||||
.It Cm count= Ns Ar n
|
||||
Copy only
|
||||
.Ar n
|
||||
.Va n
|
||||
input blocks.
|
||||
.It Cm files Ns = Ns Ar n
|
||||
.It Cm files= Ns Ar n
|
||||
Copy
|
||||
.Ar n
|
||||
.Va n
|
||||
input files before terminating.
|
||||
This operand is only applicable when the input device is a tape.
|
||||
.It Cm ibs Ns = Ns Ar n
|
||||
.It Cm ibs= Ns Ar n
|
||||
Set the input block size to
|
||||
.Ar n
|
||||
.Va n
|
||||
bytes instead of the default 512.
|
||||
.It Cm if Ns = Ns Ar file
|
||||
.It Cm if= Ns Ar file
|
||||
Read input from
|
||||
.Ar file
|
||||
instead of the standard input.
|
||||
.It Cm iseek Ns = Ns Ar n
|
||||
.It Cm iseek= Ns Ar n
|
||||
Seek on the input file
|
||||
.Ar n
|
||||
.Va n
|
||||
blocks.
|
||||
This is synonymous with
|
||||
.Cm skip Ns = Ns Ar n .
|
||||
.It Cm obs Ns = Ns Ar n
|
||||
.Cm skip= Ns Ar n .
|
||||
.It Cm obs= Ns Ar n
|
||||
Set the output block size to
|
||||
.Ar n
|
||||
.Va n
|
||||
bytes instead of the default 512.
|
||||
.It Cm of Ns = Ns Ar file
|
||||
.It Cm of= Ns Ar file
|
||||
Write output to
|
||||
.Ar file
|
||||
instead of the standard output.
|
||||
@@ -117,15 +117,15 @@ If an initial portion of the output file is seeked past (see the
|
||||
.Cm oseek
|
||||
operand),
|
||||
the output file is truncated at that point.
|
||||
.It Cm oseek Ns = Ns Ar n
|
||||
.It Cm oseek= Ns Ar n
|
||||
Seek on the output file
|
||||
.Ar n
|
||||
.Va n
|
||||
blocks.
|
||||
This is synonymous with
|
||||
.Cm seek Ns = Ns Ar n .
|
||||
.It Cm seek Ns = Ns Ar n
|
||||
.Cm seek= Ns Ar n .
|
||||
.It Cm seek= Ns Ar n
|
||||
Seek
|
||||
.Ar n
|
||||
.Va n
|
||||
blocks from the beginning of the output before copying.
|
||||
On non-tape devices, an
|
||||
.Xr lseek 2
|
||||
@@ -137,11 +137,11 @@ using the tape
|
||||
function calls.
|
||||
If the seek operation is past the end of file, space from the current
|
||||
end of file to the specified offset is filled with blocks of
|
||||
.Dv NUL
|
||||
.Tn NUL
|
||||
bytes.
|
||||
.It Cm skip Ns = Ns Ar n
|
||||
.It Cm skip= Ns Ar n
|
||||
Skip
|
||||
.Ar n
|
||||
.Va n
|
||||
blocks from the beginning of the input before copying.
|
||||
On input which supports seeks, an
|
||||
.Xr lseek 2
|
||||
@@ -150,11 +150,14 @@ Otherwise, input data is read and discarded.
|
||||
For pipes, the correct number of bytes is read.
|
||||
For all other devices, the correct number of blocks is read without
|
||||
distinguishing between a partial or complete block being read.
|
||||
.It Cm conv Ns = Ns Ar value Ns Op , Ns Ar value ...
|
||||
.It Xo
|
||||
.Cm conv=
|
||||
.Ns Cm value Ns Op \&, Cm value \&...
|
||||
.Xc
|
||||
Where
|
||||
.Cm value
|
||||
is one of the symbols from the following list.
|
||||
.Bl -tag -width ".Cm unblock"
|
||||
.Bl -tag -width unblock
|
||||
.It Cm ascii , oldascii
|
||||
The same as the
|
||||
.Cm unblock
|
||||
@@ -173,12 +176,11 @@ There are two conversion maps for
|
||||
.Tn ASCII .
|
||||
The value
|
||||
.Cm ascii
|
||||
specifies the recommended one which is compatible with
|
||||
.At V .
|
||||
specifies the recommended one which is compatible with System V.
|
||||
The value
|
||||
.Cm oldascii
|
||||
specifies the one used in historic
|
||||
.At
|
||||
.Tn AT&T
|
||||
and
|
||||
.No pre- Ns Bx 4.3 reno
|
||||
systems.
|
||||
@@ -225,7 +227,7 @@ The values
|
||||
and
|
||||
.Cm oldibm
|
||||
are maps used in historic
|
||||
.At
|
||||
.Tn AT&T
|
||||
and
|
||||
.No pre- Ns Bx 4.3 reno
|
||||
systems.
|
||||
@@ -240,7 +242,7 @@ If the
|
||||
.Cm sync
|
||||
conversion is also specified, any missing input data will be replaced
|
||||
with
|
||||
.Dv NUL
|
||||
.Tn NUL
|
||||
bytes (or with spaces if a block oriented conversion value was
|
||||
specified) and processed as a normal input buffer.
|
||||
If the
|
||||
@@ -264,14 +266,14 @@ after conversion, this conversion forces the final output block
|
||||
to be the same size as preceding blocks for use on devices that require
|
||||
regularly sized blocks to be written.
|
||||
This option is incompatible with use of the
|
||||
.Cm bs Ns = Ns Ar n
|
||||
.Cm bs= Ns Ar n
|
||||
block size specification.
|
||||
.It Cm sparse
|
||||
If one or more output blocks would consist solely of
|
||||
.Dv NUL
|
||||
.Tn NUL
|
||||
bytes, try to seek the output file by the required space instead of
|
||||
filling them with
|
||||
.Dv NUL Ns s ,
|
||||
.Tn NULs ,
|
||||
resulting in a sparse file.
|
||||
.It Cm swab
|
||||
Swap every pair of input bytes.
|
||||
@@ -281,7 +283,7 @@ ignored during swapping.
|
||||
Pad every input block to the input buffer size.
|
||||
Spaces are used for pad bytes if a block oriented conversion value is
|
||||
specified, otherwise
|
||||
.Dv NUL
|
||||
.Tn NUL
|
||||
bytes are used.
|
||||
.It Cm ucase
|
||||
Transform lowercase characters into uppercase characters.
|
||||
@@ -298,19 +300,10 @@ appended.
|
||||
.Pp
|
||||
Where sizes are specified, a decimal, octal, or hexadecimal number of
|
||||
bytes is expected.
|
||||
If the number ends with a
|
||||
.Dq Li b ,
|
||||
.Dq Li k ,
|
||||
.Dq Li m ,
|
||||
.Dq Li g ,
|
||||
or
|
||||
.Dq Li w ,
|
||||
the
|
||||
If the number ends with a ``b'', ``k'', ``m'', ``g'', or ``w'', the
|
||||
number is multiplied by 512, 1024 (1K), 1048576 (1M), 1073741824 (1G)
|
||||
or the number of bytes in an integer, respectively.
|
||||
Two or more numbers may be separated by an
|
||||
.Dq Li x
|
||||
to indicate a product.
|
||||
Two or more numbers may be separated by an ``x'' to indicate a product.
|
||||
.Pp
|
||||
When finished,
|
||||
.Nm
|
||||
@@ -339,9 +332,7 @@ If
|
||||
.Nm
|
||||
receives a
|
||||
.Dv SIGINFO
|
||||
(see the
|
||||
.Cm status
|
||||
argument for
|
||||
(see the ``status'' argument for
|
||||
.Xr stty 1 )
|
||||
signal, the current input and output block counts will
|
||||
be written to the standard error output
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
PROG= df
|
||||
SRCS= df.c vfslist.c
|
||||
BINGRP= operator
|
||||
BINMODE=2555
|
||||
|
||||
MOUNT= ${.CURDIR}/../../sbin/mount
|
||||
CFLAGS+= -I${MOUNT}
|
||||
|
||||
+20
-22
@@ -41,24 +41,22 @@
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Oo
|
||||
.Fl b | g | h | H | k |
|
||||
.Fl b | h | H | k |
|
||||
.Fl m | P
|
||||
.Oc
|
||||
.Op Fl ailn
|
||||
.Op Fl t Ar type
|
||||
.Op Ar file | filesystem ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
.Nm Df
|
||||
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 +79,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 +92,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 +113,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 +148,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 ,
|
||||
|
||||
+115
-173
@@ -51,18 +51,15 @@ static const char rcsid[] =
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <ufs/ufs/ufsmount.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <fstab.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -91,59 +88,41 @@ static const char rcsid[] =
|
||||
#define TERA_SI_SZ (TERA_SZ(1000ULL))
|
||||
#define PETA_SI_SZ (PETA_SZ(1000ULL))
|
||||
|
||||
/* Maximum widths of various fields. */
|
||||
struct maxwidths {
|
||||
int mntfrom;
|
||||
int total;
|
||||
int used;
|
||||
int avail;
|
||||
int iused;
|
||||
int ifree;
|
||||
};
|
||||
|
||||
unsigned long long vals_si [] = {1, KILO_SI_SZ, MEGA_SI_SZ, GIGA_SI_SZ, TERA_SI_SZ, PETA_SI_SZ};
|
||||
unsigned long long vals_base2[] = {1, KILO_2_SZ, MEGA_2_SZ, GIGA_2_SZ, TERA_2_SZ, PETA_2_SZ};
|
||||
unsigned long long *valp;
|
||||
|
||||
typedef enum { NONE, KILO, MEGA, GIGA, TERA, PETA, UNIT_MAX } unit_t;
|
||||
|
||||
unit_t unitp [] = { NONE, KILO, MEGA, GIGA, TERA, PETA };
|
||||
int 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);
|
||||
char *makenetvfslist(void);
|
||||
char **makevfslist(char *);
|
||||
void prthuman(struct statfs *, long);
|
||||
void prthumanval(double);
|
||||
void prtstat(struct statfs *, struct maxwidths *);
|
||||
long regetmntinfo(struct statfs **, long, char **);
|
||||
int ufs_df(char *, struct maxwidths *);
|
||||
unit_t unit_adjust(double *);
|
||||
void update_maxwidths(struct maxwidths *, struct statfs *);
|
||||
void usage(void);
|
||||
int main __P((int, char *[]));
|
||||
int bread __P((off_t, void *, int));
|
||||
int checkvfsname __P((const char *, char **));
|
||||
char *makenetvfslist __P((void));
|
||||
char **makevfslist __P((char *));
|
||||
char *getmntpt __P((char *));
|
||||
void prthuman __P((struct statfs *, long));
|
||||
void prthumanval __P((double));
|
||||
void prtstat __P((struct statfs *, int));
|
||||
long regetmntinfo __P((struct statfs **, long, char **));
|
||||
int ufs_df __P((char *, int));
|
||||
unit_t unit_adjust __P((double *));
|
||||
void usage __P((void));
|
||||
|
||||
int aflag = 0, hflag, iflag, nflag;
|
||||
struct ufs_args mdev;
|
||||
|
||||
static __inline int imax(int a, int b)
|
||||
{
|
||||
return (a > b ? a : b);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
struct stat stbuf;
|
||||
struct statfs statfsbuf, *mntbuf;
|
||||
struct maxwidths maxwidths;
|
||||
const char *fstype;
|
||||
char *mntpath, *mntpt, **vfslist;
|
||||
long mntsize;
|
||||
int ch, i, rv;
|
||||
|
||||
fstype = "ufs";
|
||||
int ch, eno, i, maxwidth, rv, width;
|
||||
char *mntpt, *mntpath, **vfslist;
|
||||
|
||||
vfslist = NULL;
|
||||
while ((ch = getopt(argc, argv, "abgHhiklmnPt:")) != -1)
|
||||
@@ -190,8 +169,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
case 't':
|
||||
if (vfslist != NULL)
|
||||
errx(1, "only one -t option may be specified");
|
||||
fstype = optarg;
|
||||
errx(1, "only one -t option may be specified.");
|
||||
vfslist = makevfslist(optarg);
|
||||
break;
|
||||
case '?':
|
||||
@@ -202,31 +180,43 @@ main(int argc, char *argv[])
|
||||
argv += optind;
|
||||
|
||||
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
|
||||
bzero(&maxwidths, sizeof(maxwidths));
|
||||
for (i = 0; i < mntsize; i++)
|
||||
update_maxwidths(&maxwidths, &mntbuf[i]);
|
||||
maxwidth = 0;
|
||||
for (i = 0; i < mntsize; i++) {
|
||||
width = strlen(mntbuf[i].f_mntfromname);
|
||||
if (width > maxwidth)
|
||||
maxwidth = width;
|
||||
}
|
||||
|
||||
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) {
|
||||
maxwidth = 0;
|
||||
for (i = 0; i < mntsize; i++) {
|
||||
width = strlen(mntbuf[i].f_mntfromname);
|
||||
if (width > maxwidth)
|
||||
maxwidth = width;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < mntsize; i++) {
|
||||
if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0)
|
||||
prtstat(&mntbuf[i], &maxwidths);
|
||||
prtstat(&mntbuf[i], maxwidth);
|
||||
}
|
||||
exit(rv);
|
||||
}
|
||||
|
||||
for (; *argv; argv++) {
|
||||
if (stat(*argv, &stbuf) < 0) {
|
||||
eno = errno;
|
||||
if ((mntpt = getmntpt(*argv)) == 0) {
|
||||
warn("%s", *argv);
|
||||
rv = 1;
|
||||
continue;
|
||||
}
|
||||
} else if (S_ISCHR(stbuf.st_mode)) {
|
||||
} else if ((stbuf.st_mode & S_IFMT) == S_IFCHR) {
|
||||
rv = ufs_df(*argv, maxwidth) || rv;
|
||||
continue;
|
||||
} else if ((stbuf.st_mode & S_IFMT) == S_IFBLK) {
|
||||
if ((mntpt = getmntpt(*argv)) == 0) {
|
||||
mdev.fspec = *argv;
|
||||
mntpath = strdup("/tmp/df.XXXXXX");
|
||||
@@ -242,15 +232,15 @@ main(int argc, char *argv[])
|
||||
free(mntpath);
|
||||
continue;
|
||||
}
|
||||
if (mount(fstype, mntpt, MNT_RDONLY,
|
||||
if (mount("ufs", mntpt, MNT_RDONLY,
|
||||
&mdev) != 0) {
|
||||
rv = ufs_df(*argv, &maxwidths) || rv;
|
||||
rv = ufs_df(*argv, maxwidth) || rv;
|
||||
(void)rmdir(mntpt);
|
||||
free(mntpath);
|
||||
continue;
|
||||
} else if (statfs(mntpt, &statfsbuf) == 0) {
|
||||
statfsbuf.f_mntonname[0] = '\0';
|
||||
prtstat(&statfsbuf, &maxwidths);
|
||||
prtstat(&statfsbuf, maxwidth);
|
||||
} else {
|
||||
warn("%s", *argv);
|
||||
rv = 1;
|
||||
@@ -271,17 +261,16 @@ main(int argc, char *argv[])
|
||||
rv = 1;
|
||||
continue;
|
||||
}
|
||||
if (argc == 1) {
|
||||
bzero(&maxwidths, sizeof(maxwidths));
|
||||
update_maxwidths(&maxwidths, &statfsbuf);
|
||||
}
|
||||
prtstat(&statfsbuf, &maxwidths);
|
||||
if (argc == 1)
|
||||
maxwidth = strlen(statfsbuf.f_mntfromname) + 1;
|
||||
prtstat(&statfsbuf, maxwidth);
|
||||
}
|
||||
return (rv);
|
||||
}
|
||||
|
||||
char *
|
||||
getmntpt(char *name)
|
||||
getmntpt(name)
|
||||
char *name;
|
||||
{
|
||||
long mntsize, i;
|
||||
struct statfs *mntbuf;
|
||||
@@ -300,7 +289,10 @@ getmntpt(char *name)
|
||||
* current (not cached) info. Returns the new count of valid statfs bufs.
|
||||
*/
|
||||
long
|
||||
regetmntinfo(struct statfs **mntbufp, long mntsize, char **vfslist)
|
||||
regetmntinfo(mntbufp, mntsize, vfslist)
|
||||
struct statfs **mntbufp;
|
||||
long mntsize;
|
||||
char **vfslist;
|
||||
{
|
||||
int i, j;
|
||||
struct statfs *mntbuf;
|
||||
@@ -328,7 +320,8 @@ regetmntinfo(struct statfs **mntbufp, long mntsize, char **vfslist)
|
||||
*
|
||||
*/
|
||||
unit_t
|
||||
unit_adjust(double *val)
|
||||
unit_adjust(val)
|
||||
double *val;
|
||||
{
|
||||
double abval;
|
||||
unit_t unit;
|
||||
@@ -349,7 +342,9 @@ unit_adjust(double *val)
|
||||
}
|
||||
|
||||
void
|
||||
prthuman(struct statfs *sfsp, long used)
|
||||
prthuman(sfsp, used)
|
||||
struct statfs *sfsp;
|
||||
long used;
|
||||
{
|
||||
|
||||
prthumanval((double)sfsp->f_blocks * (double)sfsp->f_bsize);
|
||||
@@ -358,7 +353,8 @@ prthuman(struct statfs *sfsp, long used)
|
||||
}
|
||||
|
||||
void
|
||||
prthumanval(double bytes)
|
||||
prthumanval(bytes)
|
||||
double bytes;
|
||||
{
|
||||
|
||||
unit_t unit;
|
||||
@@ -376,125 +372,71 @@ 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.
|
||||
*/
|
||||
void
|
||||
prtstat(struct statfs *sfsp, struct maxwidths *mwp)
|
||||
prtstat(sfsp, maxwidth)
|
||||
struct statfs *sfsp;
|
||||
int maxwidth;
|
||||
{
|
||||
static long blocksize;
|
||||
static int headerlen, timesthrough;
|
||||
static const char *header;
|
||||
long used, availblks, inodes;
|
||||
|
||||
if (maxwidth < 11)
|
||||
maxwidth = 11;
|
||||
if (++timesthrough == 1) {
|
||||
mwp->mntfrom = imax(mwp->mntfrom, strlen("Filesystem"));
|
||||
if (hflag) {
|
||||
header = " Size";
|
||||
mwp->total = mwp->used = mwp->avail = strlen(header);
|
||||
headerlen = strlen(header);
|
||||
(void)printf("%-*.*s %-s Used Avail Capacity",
|
||||
maxwidth, maxwidth, "Filesystem", header);
|
||||
} else {
|
||||
header = getbsize(&headerlen, &blocksize);
|
||||
mwp->total = imax(mwp->total, headerlen);
|
||||
}
|
||||
mwp->used = imax(mwp->used, strlen("Used"));
|
||||
mwp->avail = imax(mwp->avail, strlen("Avail"));
|
||||
|
||||
(void)printf("%-*s %-*s %*s %*s Capacity", mwp->mntfrom,
|
||||
"Filesystem", mwp->total, header, mwp->used, "Used",
|
||||
mwp->avail, "Avail");
|
||||
if (iflag) {
|
||||
mwp->iused = imax(mwp->iused, strlen(" iused"));
|
||||
mwp->ifree = imax(mwp->ifree, strlen("ifree"));
|
||||
(void)printf(" %*s %*s %%iused", mwp->iused - 2,
|
||||
"iused", mwp->ifree, "ifree");
|
||||
(void)printf("%-*.*s %-s Used Avail Capacity",
|
||||
maxwidth, maxwidth, "Filesystem", header);
|
||||
}
|
||||
if (iflag)
|
||||
(void)printf(" iused ifree %%iused");
|
||||
(void)printf(" Mounted on\n");
|
||||
}
|
||||
(void)printf("%-*s", mwp->mntfrom, sfsp->f_mntfromname);
|
||||
(void)printf("%-*.*s", maxwidth, maxwidth, sfsp->f_mntfromname);
|
||||
used = sfsp->f_blocks - sfsp->f_bfree;
|
||||
availblks = sfsp->f_bavail + used;
|
||||
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 %8ld %8ld", headerlen,
|
||||
fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize),
|
||||
fsbtoblk(used, sfsp->f_bsize, blocksize),
|
||||
fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize));
|
||||
}
|
||||
(void)printf(" %5.0f%%",
|
||||
availblks == 0 ? 100.0 : (double)used / (double)availblks * 100.0);
|
||||
if (iflag) {
|
||||
inodes = sfsp->f_files;
|
||||
used = inodes - sfsp->f_ffree;
|
||||
(void)printf(" %*ld %*ld %4.0f%% ", mwp->iused, used,
|
||||
mwp->ifree, sfsp->f_ffree, inodes == 0 ? 100.0 :
|
||||
(double)used / (double)inodes * 100.0);
|
||||
(void)printf(" %7ld %7ld %5.0f%% ", used, sfsp->f_ffree,
|
||||
inodes == 0 ? 100.0 : (double)used / (double)inodes * 100.0);
|
||||
} else
|
||||
(void)printf(" ");
|
||||
(void)printf(" %s\n", sfsp->f_mntonname);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the maximum field-width information in `mwp' based on
|
||||
* the filesystem specified by `sfsp'.
|
||||
*/
|
||||
void
|
||||
update_maxwidths(struct maxwidths *mwp, struct statfs *sfsp)
|
||||
{
|
||||
static long blocksize;
|
||||
int dummy;
|
||||
|
||||
if (blocksize == 0)
|
||||
getbsize(&dummy, &blocksize);
|
||||
|
||||
mwp->mntfrom = imax(mwp->mntfrom, strlen(sfsp->f_mntfromname));
|
||||
mwp->total = imax(mwp->total, int64width(fsbtoblk(sfsp->f_blocks,
|
||||
sfsp->f_bsize, blocksize)));
|
||||
mwp->used = imax(mwp->used, int64width(fsbtoblk(sfsp->f_blocks -
|
||||
sfsp->f_bfree, sfsp->f_bsize, blocksize)));
|
||||
mwp->avail = imax(mwp->avail, int64width(fsbtoblk(sfsp->f_bavail,
|
||||
sfsp->f_bsize, blocksize)));
|
||||
mwp->iused = imax(mwp->iused, int64width(sfsp->f_files -
|
||||
sfsp->f_ffree));
|
||||
mwp->ifree = imax(mwp->ifree, int64width(sfsp->f_ffree));
|
||||
}
|
||||
|
||||
/* Return the width in characters of the specified long. */
|
||||
int
|
||||
int64width(int64_t val)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = 0;
|
||||
/* Negative or zero values require one extra digit. */
|
||||
if (val <= 0) {
|
||||
val = -val;
|
||||
len++;
|
||||
}
|
||||
while (val > 0) {
|
||||
len++;
|
||||
val /= 10;
|
||||
}
|
||||
|
||||
return (len);
|
||||
}
|
||||
|
||||
/*
|
||||
* This code constitutes the pre-system call Berkeley df code for extracting
|
||||
* information from filesystem superblocks.
|
||||
*/
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
#include <errno.h>
|
||||
#include <fstab.h>
|
||||
|
||||
union {
|
||||
struct fs iu_fs;
|
||||
@@ -505,7 +447,9 @@ union {
|
||||
int rfd;
|
||||
|
||||
int
|
||||
ufs_df(char *file, struct maxwidths *mwp)
|
||||
ufs_df(file, maxwidth)
|
||||
char *file;
|
||||
int maxwidth;
|
||||
{
|
||||
struct statfs statfsbuf;
|
||||
struct statfs *sfsp;
|
||||
@@ -539,81 +483,79 @@ ufs_df(char *file, struct maxwidths *mwp)
|
||||
sfsp->f_fsid.val[1] = 0;
|
||||
if ((mntpt = getmntpt(file)) == 0)
|
||||
mntpt = "";
|
||||
memmove(&sfsp->f_mntonname[0], mntpt, (size_t)MNAMELEN);
|
||||
memmove(&sfsp->f_mntfromname[0], file, (size_t)MNAMELEN);
|
||||
prtstat(sfsp, mwp);
|
||||
memmove(&sfsp->f_mntonname[0], mntpt, MNAMELEN);
|
||||
memmove(&sfsp->f_mntfromname[0], file, MNAMELEN);
|
||||
prtstat(sfsp, maxwidth);
|
||||
(void)close(rfd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
bread(off_t off, void *buf, int cnt)
|
||||
bread(off, buf, cnt)
|
||||
off_t off;
|
||||
void *buf;
|
||||
int cnt;
|
||||
{
|
||||
ssize_t nr;
|
||||
int nr;
|
||||
|
||||
(void)lseek(rfd, off, SEEK_SET);
|
||||
if ((nr = read(rfd, buf, (size_t)cnt)) != (ssize_t)cnt) {
|
||||
if ((nr = read(rfd, buf, cnt)) != cnt) {
|
||||
/* Probably a dismounted disk if errno == EIO. */
|
||||
if (errno != EIO)
|
||||
(void)fprintf(stderr, "\ndf: %lld: %s\n",
|
||||
(long long)off, strerror(nr > 0 ? EIO : errno));
|
||||
(void)fprintf(stderr, "\ndf: %qd: %s\n",
|
||||
off, strerror(nr > 0 ? EIO : errno));
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
usage()
|
||||
{
|
||||
|
||||
(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);
|
||||
}
|
||||
|
||||
char *
|
||||
makenetvfslist(void)
|
||||
char *makenetvfslist()
|
||||
{
|
||||
char *str, *strptr, **listptr;
|
||||
int mib[3], maxvfsconf, cnt=0, i;
|
||||
size_t miblen;
|
||||
int mib[3], maxvfsconf, miblen, cnt=0, i;
|
||||
struct ovfsconf *ptr;
|
||||
|
||||
mib[0] = CTL_VFS; mib[1] = VFS_GENERIC; mib[2] = VFS_MAXTYPENUM;
|
||||
miblen=sizeof(maxvfsconf);
|
||||
if (sysctl(mib, (unsigned int)(sizeof(mib) / sizeof(mib[0])),
|
||||
&maxvfsconf, &miblen, NULL, 0)) {
|
||||
if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &maxvfsconf, &miblen, NULL, 0)) {
|
||||
warnx("sysctl failed");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if ((listptr = malloc(sizeof(char*) * maxvfsconf)) == NULL) {
|
||||
if ((listptr=malloc(sizeof(char*) * maxvfsconf)) == NULL) {
|
||||
warnx("malloc failed");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
for (ptr = getvfsent(); ptr; ptr = getvfsent())
|
||||
for (ptr=getvfsent();ptr;ptr=getvfsent())
|
||||
if (ptr->vfc_flags & VFCF_NETWORK) {
|
||||
listptr[cnt++] = strdup(ptr->vfc_name);
|
||||
if (listptr[cnt-1] == NULL) {
|
||||
listptr[cnt++] = strdup (ptr->vfc_name);
|
||||
if (! listptr[cnt-1]) {
|
||||
warnx("malloc failed");
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (cnt == 0 ||
|
||||
(str = malloc(sizeof(char) * (32 * cnt + cnt + 2))) == NULL) {
|
||||
if (cnt > 0)
|
||||
warnx("malloc failed");
|
||||
if ((str = malloc(sizeof(char)*(32*cnt+cnt+2))) == NULL) {
|
||||
warnx("malloc failed");
|
||||
free(listptr);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
*str = 'n'; *(str + 1) = 'o';
|
||||
for (i = 0, strptr = str + 2; i < cnt; i++, strptr++) {
|
||||
strncpy(strptr, listptr[i], 32);
|
||||
strptr += strlen(listptr[i]);
|
||||
*strptr = ',';
|
||||
*str = 'n'; *(str+1) = 'o';
|
||||
for (i = 0,strptr=str+2; i < cnt; i++,strptr++) {
|
||||
strncpy (strptr, listptr[i], 32);
|
||||
strptr+=strlen(listptr[i]);
|
||||
*strptr=',';
|
||||
free(listptr[i]);
|
||||
}
|
||||
*(--strptr) = NULL;
|
||||
|
||||
@@ -42,9 +42,8 @@
|
||||
.Nm
|
||||
.Op Ar ypdomain
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility prints the name of the current YP/NIS domain. The super-user can
|
||||
.Nm Domainname
|
||||
prints the name of the current YP/NIS domain. The super-user can
|
||||
set the domain name by supplying an argument; this is usually done in the
|
||||
network initialization script
|
||||
.Pa /etc/rc.network ,
|
||||
@@ -61,6 +60,6 @@ convenience.
|
||||
The
|
||||
.Nm
|
||||
command appeared in
|
||||
.Fx 1.1 ,
|
||||
based on a similar command in
|
||||
.Fx
|
||||
1.1, based on a similar command in
|
||||
.Tn SunOS .
|
||||
+6
-15
@@ -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.
|
||||
+3
-3
@@ -5,11 +5,11 @@ 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}
|
||||
LDADD= -lcipher
|
||||
LDADD+= -L${CIPHEROBJDIR} -lcipher
|
||||
DPADD+= ${CIPHEROBJDIR}/libcipher.a
|
||||
.endif
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
+73
-169
@@ -12,35 +12,18 @@
|
||||
.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.
|
||||
.Nm Ed
|
||||
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 +35,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 +70,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 +92,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 +110,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 +126,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
|
||||
@@ -171,21 +147,18 @@ only if it is not prefixed with a bang.
|
||||
.El
|
||||
.Sh LINE ADDRESSING
|
||||
An address represents the number of a line in the buffer.
|
||||
The
|
||||
.Nm
|
||||
utility maintains a
|
||||
.Nm Ed
|
||||
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 +178,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 +189,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 +230,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 +277,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 +288,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 +316,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 +340,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 +383,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
|
||||
@@ -507,11 +442,8 @@ to print the last line affected by the command.
|
||||
An interrupt (typically ^C) has the effect of aborting the current command
|
||||
and returning the editor to command mode.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
recognizes the following commands.
|
||||
The commands are shown together with
|
||||
.Nm Ed
|
||||
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 +452,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 +468,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 +546,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,36 +560,31 @@ 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
|
||||
utility waits until the RETURN key is pressed
|
||||
.Nm Ed
|
||||
waits until the RETURN key is pressed
|
||||
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 +592,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 +617,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 +670,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 +682,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 +757,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 +782,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,21 +801,17 @@ 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
|
||||
.Nm
|
||||
utility does not process
|
||||
.Nm Ed
|
||||
does not process
|
||||
.Ar command
|
||||
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 +827,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 ,
|
||||
@@ -937,19 +845,17 @@ USD:12-13
|
||||
.%D 1981
|
||||
.Re
|
||||
.Sh LIMITATIONS
|
||||
The
|
||||
.Nm
|
||||
utility processes
|
||||
.Nm Ed
|
||||
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 +863,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 +872,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
@@ -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
|
||||
|
||||
@@ -43,9 +43,8 @@
|
||||
.Op Fl s
|
||||
.Op Ar name-of-host
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility prints the name of the current host. The super-user can
|
||||
.Nm Hostname
|
||||
prints the name of the current host. The super-user can
|
||||
set the hostname by supplying an argument; this is usually done in the
|
||||
network initialization script
|
||||
.Pa /etc/rc.network ,
|
||||
|
||||
+6
-25
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 ,
|
||||
|
||||
+4
-5
@@ -1,15 +1,14 @@
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/2/93
|
||||
# $FreeBSD$
|
||||
|
||||
|
||||
PROG= ls
|
||||
SRCS= cmp.c ls.c print.c util.c
|
||||
DPADD= ${LIBM}
|
||||
LDADD= -lm
|
||||
|
||||
.if !defined(RELEASE_CRUNCH)
|
||||
.if !defined(RELEASE_BUILD_FIXIT)
|
||||
CFLAGS+= -DCOLORLS
|
||||
DPADD+= ${LIBTERMCAP}
|
||||
LDADD+= -ltermcap
|
||||
LDADD+= -ltermcap
|
||||
DPADD+= ${LIBTERMCAP}
|
||||
.endif
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
+31
-63
@@ -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>
|
||||
@@ -49,93 +53,57 @@ __FBSDID("$FreeBSD$");
|
||||
#include "extern.h"
|
||||
|
||||
int
|
||||
namecmp(const FTSENT *a, const FTSENT *b)
|
||||
namecmp(a, b)
|
||||
const FTSENT *a, *b;
|
||||
{
|
||||
|
||||
return (strcoll(a->fts_name, b->fts_name));
|
||||
}
|
||||
|
||||
int
|
||||
revnamecmp(const FTSENT *a, const FTSENT *b)
|
||||
revnamecmp(a, b)
|
||||
const FTSENT *a, *b;
|
||||
{
|
||||
|
||||
return (strcoll(b->fts_name, a->fts_name));
|
||||
}
|
||||
|
||||
int
|
||||
modcmp(const FTSENT *a, const FTSENT *b)
|
||||
modcmp(a, b)
|
||||
const FTSENT *a, *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)
|
||||
revmodcmp(a, b)
|
||||
const FTSENT *a, *b;
|
||||
{
|
||||
|
||||
return (modcmp(b, a));
|
||||
return (a->fts_statp->st_mtime - b->fts_statp->st_mtime);
|
||||
}
|
||||
|
||||
int
|
||||
acccmp(const FTSENT *a, const FTSENT *b)
|
||||
acccmp(a, b)
|
||||
const FTSENT *a, *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)
|
||||
revacccmp(a, b)
|
||||
const FTSENT *a, *b;
|
||||
{
|
||||
|
||||
return (acccmp(b, a));
|
||||
return (a->fts_statp->st_atime - b->fts_statp->st_atime);
|
||||
}
|
||||
|
||||
int
|
||||
statcmp(const FTSENT *a, const FTSENT *b)
|
||||
statcmp(a, b)
|
||||
const FTSENT *a, *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)
|
||||
revstatcmp(a, b)
|
||||
const FTSENT *a, *b;
|
||||
{
|
||||
|
||||
return (statcmp(b, a));
|
||||
return (a->fts_statp->st_ctime - b->fts_statp->st_ctime);
|
||||
}
|
||||
+17
-21
@@ -34,31 +34,27 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
int acccmp(const FTSENT *, const FTSENT *);
|
||||
int revacccmp(const FTSENT *, const FTSENT *);
|
||||
int modcmp(const FTSENT *, const FTSENT *);
|
||||
int revmodcmp(const FTSENT *, const FTSENT *);
|
||||
int namecmp(const FTSENT *, const FTSENT *);
|
||||
int revnamecmp(const FTSENT *, const FTSENT *);
|
||||
int statcmp(const FTSENT *, const FTSENT *);
|
||||
int revstatcmp(const FTSENT *, const FTSENT *);
|
||||
int acccmp __P((const FTSENT *, const FTSENT *));
|
||||
int revacccmp __P((const FTSENT *, const FTSENT *));
|
||||
int modcmp __P((const FTSENT *, const FTSENT *));
|
||||
int revmodcmp __P((const FTSENT *, const FTSENT *));
|
||||
int namecmp __P((const FTSENT *, const FTSENT *));
|
||||
int revnamecmp __P((const FTSENT *, const FTSENT *));
|
||||
int statcmp __P((const FTSENT *, const FTSENT *));
|
||||
int revstatcmp __P((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 *);
|
||||
int prn_printable(const char *);
|
||||
void printcol __P((DISPLAY *));
|
||||
void printlong __P((DISPLAY *));
|
||||
void printscol __P((DISPLAY *));
|
||||
void usage __P((void));
|
||||
int len_octal __P((const char *, int));
|
||||
int prn_octal __P((const char *));
|
||||
int prn_printable __P((const char *));
|
||||
#ifdef COLORLS
|
||||
void parsecolors(const char *cs);
|
||||
void colorquit(int);
|
||||
void parsecolors __P((char *cs));
|
||||
void colorquit __P((int));
|
||||
|
||||
extern char *ansi_fgcol;
|
||||
extern char *ansi_bgcol;
|
||||
extern char *ansi_coloff;
|
||||
extern char *attrs_off;
|
||||
extern char *enter_bold;
|
||||
#endif
|
||||
+70
-156
@@ -35,7 +35,7 @@
|
||||
.\" @(#)ls.1 8.7 (Berkeley) 7/29/94
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd January 11, 2005
|
||||
.Dd July 29, 1994
|
||||
.Dt LS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -43,7 +43,7 @@
|
||||
.Nd list directory contents
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl ABCFGHLPRTWabcdfghiklmnopqrstuwx1
|
||||
.Op Fl ABCFGHLPRTWabcdfgiklnoqrstu1
|
||||
.Op Ar
|
||||
.Sh DESCRIPTION
|
||||
For each operand that names a
|
||||
@@ -72,51 +72,33 @@ The following options are available:
|
||||
.Bl -tag -width indent
|
||||
.It Fl A
|
||||
List all entries except for
|
||||
.Pa \&.
|
||||
.Ql .\&
|
||||
and
|
||||
.Pa .. .
|
||||
.Ql .. .
|
||||
Always set for the super-user.
|
||||
.It Fl B
|
||||
Force printing of non-printable characters (as defined by
|
||||
.Xr ctype 3
|
||||
and current locale settings) in file names as
|
||||
.Li \e Ns Va xxx ,
|
||||
where
|
||||
.Va xxx
|
||||
is the numeric value of the character in octal.
|
||||
Force printing of non-graphic characters in file names as \\xxx,
|
||||
where xxx is the numeric value of the character in octal.
|
||||
.It Fl C
|
||||
Force multi-column output; this is the default when output is to a terminal.
|
||||
.It Fl F
|
||||
Display a slash
|
||||
.Pq Ql /
|
||||
immediately after each pathname that is a directory,
|
||||
an asterisk
|
||||
.Pq Ql *
|
||||
after each that is executable,
|
||||
an at sign
|
||||
.Pq Ql @
|
||||
after each symbolic link,
|
||||
an equals sign
|
||||
.Pq Ql =
|
||||
after each socket,
|
||||
a percent sign
|
||||
.Pq Ql %
|
||||
after each whiteout,
|
||||
and a vertical bar
|
||||
.Pq Ql \&|
|
||||
after each that is a
|
||||
Display a slash (/) immediately after each pathname
|
||||
that is a directory, an asterisk (*) after each that is
|
||||
executable,
|
||||
an at sign (@) after each symbolic link,
|
||||
an equals sign (=) after each socket,
|
||||
a percent sign (%) after each whiteout,
|
||||
and a vertical bar (|) after each that is a
|
||||
.Tn FIFO .
|
||||
.It Fl G
|
||||
Enable colorized output.
|
||||
This option is equivalent to defining
|
||||
Enable colorized output. This option is equivalent to defining
|
||||
.Ev CLICOLOR
|
||||
in the environment.
|
||||
(See below.)
|
||||
in the environment. (See below).
|
||||
.It Fl H
|
||||
Symbolic links on the command line are followed.
|
||||
This option is assumed if
|
||||
Symbolic links on the command line are followed. This option is assumed if
|
||||
none of the
|
||||
.Fl F , d ,
|
||||
.Fl F ,
|
||||
.Fl d ,
|
||||
or
|
||||
.Fl l
|
||||
options are specified.
|
||||
@@ -128,8 +110,7 @@ This option cancels the
|
||||
option.
|
||||
.It Fl P
|
||||
If argument is a symbolic link, list the link itself rather than the
|
||||
object the link references.
|
||||
This option cancels the
|
||||
object the link references. This option cancels the
|
||||
.Fl H
|
||||
and
|
||||
.Fl L
|
||||
@@ -137,24 +118,17 @@ options.
|
||||
.It Fl R
|
||||
Recursively list subdirectories encountered.
|
||||
.It Fl T
|
||||
When used with the
|
||||
.Fl l
|
||||
(lowercase letter
|
||||
.Dq ell )
|
||||
option, display complete time information for the file, including
|
||||
Display complete time information for the file, including
|
||||
month, day, hour, minute, second, and year.
|
||||
.It Fl W
|
||||
Display whiteouts when scanning directories.
|
||||
.It Fl a
|
||||
Include directory entries whose names begin with a
|
||||
dot
|
||||
.Pq Pa \&. .
|
||||
dot (.).
|
||||
.It Fl b
|
||||
As
|
||||
.Fl B ,
|
||||
but use
|
||||
.Tn C
|
||||
escape codes whenever possible.
|
||||
but use C escape codes whenever possible.
|
||||
.It Fl c
|
||||
Use time when file status was last changed for sorting or printing.
|
||||
.It Fl d
|
||||
@@ -168,32 +142,18 @@ with
|
||||
it was used to display the group name in the long
|
||||
.Pq Fl l
|
||||
format output.
|
||||
.It Fl h
|
||||
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
|
||||
using base 2 for sizes.
|
||||
.It Fl i
|
||||
For each file, print the file's file serial number (inode number).
|
||||
.It Fl k
|
||||
If the
|
||||
.Fl s
|
||||
option is specified, print the file size allocation in kilobytes,
|
||||
not blocks.
|
||||
This option overrides the environment variable
|
||||
.Ev BLOCKSIZE .
|
||||
not blocks. This option overrides the environment variable BLOCKSIZE.
|
||||
.It Fl l
|
||||
(The lowercase letter
|
||||
.Dq ell . )
|
||||
List in long format.
|
||||
(The lowercase letter ``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,26 +163,18 @@ 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
|
||||
.Ql \&? ;
|
||||
this is the default when output is to a terminal.
|
||||
the character `?'; this is the default when output is to a terminal.
|
||||
.It Fl r
|
||||
Reverse the order of the sort to get reverse
|
||||
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
|
||||
sizes is output on a line before the listing.
|
||||
The environment variable
|
||||
.Ev BLOCKSIZE
|
||||
overrides the unit size of 512 bytes.
|
||||
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
|
||||
BLOCKSIZE overrides the unit size of 512 bytes.
|
||||
.It Fl t
|
||||
Sort by time modified (most recently modified
|
||||
first) before sorting the operands by lexicographical
|
||||
@@ -234,26 +186,16 @@ of the file for sorting
|
||||
.Pq Fl t
|
||||
or printing
|
||||
.Pq Fl l .
|
||||
.It Fl w
|
||||
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 . )
|
||||
Force output to be
|
||||
.It Fl \&1
|
||||
(The numeric digit ``one.'') Force output to be
|
||||
one entry per line.
|
||||
This is the default when
|
||||
output is not to a terminal.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Fl 1 , C , x ,
|
||||
.Fl 1 ,
|
||||
.Fl C ,
|
||||
and
|
||||
.Fl l
|
||||
options all override each other; the last one specified determines
|
||||
@@ -267,14 +209,16 @@ options override each other; the last one specified determines
|
||||
the file time used.
|
||||
.Pp
|
||||
The
|
||||
.Fl B , b , w ,
|
||||
.Fl B ,
|
||||
.Fl b
|
||||
and
|
||||
.Fl q
|
||||
options all override each other; the last one specified determines
|
||||
the format used for non-printable characters.
|
||||
.Pp
|
||||
The
|
||||
.Fl H , L
|
||||
.Fl H ,
|
||||
.Fl L
|
||||
and
|
||||
.Fl P
|
||||
options all override each other (either partially or fully); they
|
||||
@@ -285,14 +229,12 @@ 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
|
||||
separating the information associated with the
|
||||
.Fl i , s ,
|
||||
<blank>s separating the information associated with the
|
||||
.Fl i ,
|
||||
.Fl s ,
|
||||
and
|
||||
.Fl l
|
||||
options.
|
||||
@@ -327,12 +269,12 @@ the major and minor device numbers for the file are displayed
|
||||
in the size field.
|
||||
If the file is a symbolic link the pathname of the
|
||||
linked-to file is preceded by
|
||||
.Dq Li -> .
|
||||
.Dq \-> .
|
||||
.Pp
|
||||
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
|
||||
@@ -436,7 +378,7 @@ to get the results sorted from largest to smallest (a reverse sort).
|
||||
.Sh ENVIRONMENT
|
||||
The following environment variables affect the execution of
|
||||
.Nm :
|
||||
.Bl -tag -width ".Ev CLICOLOR_FORCE"
|
||||
.Bl -tag -width BLOCKSIZE
|
||||
.It Ev BLOCKSIZE
|
||||
If the environment variable
|
||||
.Ev BLOCKSIZE
|
||||
@@ -458,7 +400,7 @@ The colorization is dependent on a terminal type with the proper
|
||||
.Xr termcap 5
|
||||
capabilities.
|
||||
The default
|
||||
.Dq Li cons25
|
||||
.Dq cons25
|
||||
console has the proper capabilities,
|
||||
but to display the colors in an
|
||||
.Xr xterm 1 ,
|
||||
@@ -466,17 +408,15 @@ for example,
|
||||
the
|
||||
.Ev TERM
|
||||
variable must be set to
|
||||
.Dq Li xterm-color .
|
||||
Other terminal types may require similar adjustments.
|
||||
Colorization
|
||||
.Dq xterm-color .
|
||||
Other terminal types may require similar adjustments. Colorization
|
||||
is silently disabled if the output isn't directed to a terminal
|
||||
unless the
|
||||
.Ev CLICOLOR_FORCE
|
||||
variable is defined.
|
||||
.It Ev CLICOLOR_FORCE
|
||||
Color sequences are normally disabled if the output isn't directed to
|
||||
a terminal.
|
||||
This can be overridden by setting this flag.
|
||||
a terminal. This can be overridden by setting this flag.
|
||||
The
|
||||
.Ev TERM
|
||||
variable still needs to reference a color capable terminal however
|
||||
@@ -493,9 +433,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
|
||||
@@ -508,48 +446,32 @@ The value of this variable describes what color to use for which
|
||||
attribute when colors are enabled with
|
||||
.Ev CLICOLOR .
|
||||
This string is a concatenation of pairs of the format
|
||||
.Ar f Ns Ar b ,
|
||||
.Sy fb ,
|
||||
where
|
||||
.Ar f
|
||||
.Sy f
|
||||
is the foreground color and
|
||||
.Ar b
|
||||
.Sy b
|
||||
is the background color.
|
||||
.Pp
|
||||
The color designators are as follows:
|
||||
.Pp
|
||||
.Bl -tag -width 4n -offset indent -compact
|
||||
.It Sy a
|
||||
.It Sy 0
|
||||
black
|
||||
.It Sy b
|
||||
.It Sy 1
|
||||
red
|
||||
.It Sy c
|
||||
.It Sy 2
|
||||
green
|
||||
.It Sy d
|
||||
.It Sy 3
|
||||
brown
|
||||
.It Sy e
|
||||
.It Sy 4
|
||||
blue
|
||||
.It Sy f
|
||||
.It Sy 5
|
||||
magenta
|
||||
.It Sy g
|
||||
.It Sy 6
|
||||
cyan
|
||||
.It Sy h
|
||||
.It Sy 7
|
||||
light grey
|
||||
.It Sy A
|
||||
bold black, usually shows up as dark grey
|
||||
.It Sy B
|
||||
bold red
|
||||
.It Sy C
|
||||
bold green
|
||||
.It Sy D
|
||||
bold brown, usually shows up as yellow
|
||||
.It Sy E
|
||||
bold blue
|
||||
.It Sy F
|
||||
bold magenta
|
||||
.It Sy G
|
||||
bold cyan
|
||||
.It Sy H
|
||||
bold light grey; looks like bright white
|
||||
.It Sy x
|
||||
default foreground or background
|
||||
.El
|
||||
@@ -587,19 +509,15 @@ directory writable to others, with sticky bit
|
||||
directory writable to others, without sticky bit
|
||||
.El
|
||||
.Pp
|
||||
The default is
|
||||
.Qq "exfxcxdxbxegedabagacad" ,
|
||||
i.e. blue foreground and
|
||||
The default is "4x5x2x3x1x464301060203", i.e. blue foreground and
|
||||
default background for regular directories, black foreground and red
|
||||
background for setuid executables, etc.
|
||||
.It Ev LS_COLWIDTHS
|
||||
If this variable is set, it is considered to be a
|
||||
colon-delimited list of minimum column widths.
|
||||
Unreasonable
|
||||
colon-delimited list of minimum column widths. Unreasonable
|
||||
and insufficient widths are ignored (thus zero signifies
|
||||
a dynamically sized column).
|
||||
Not all columns have changeable widths.
|
||||
The fields are,
|
||||
a dynamically sized column). Not all
|
||||
columns have changeable widths. The fields are,
|
||||
in order: inode, block count, number of links, user name,
|
||||
group name, flags, file size, file name.
|
||||
.It Ev TERM
|
||||
@@ -625,21 +543,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
|
||||
function 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.
|
||||
+110
-166
@@ -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>
|
||||
@@ -56,10 +57,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fts.h>
|
||||
#include <grp.h>
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -79,85 +78,83 @@ __FBSDID("$FreeBSD$");
|
||||
*/
|
||||
#define STRBUF_SIZEOF(t) (1 + CHAR_BIT * sizeof(t) / 3 + 1)
|
||||
|
||||
static void display(FTSENT *, FTSENT *);
|
||||
static u_quad_t makenines(u_long);
|
||||
static int mastercmp(const FTSENT **, const FTSENT **);
|
||||
static void traverse(int, char **, int);
|
||||
static void display __P((FTSENT *, FTSENT *));
|
||||
static u_quad_t makenines __P((u_long));
|
||||
static int mastercmp __P((const FTSENT **, const FTSENT **));
|
||||
static void traverse __P((int, char **, int));
|
||||
|
||||
static void (*printfcn)(DISPLAY *);
|
||||
static int (*sortfcn)(const FTSENT *, const FTSENT *);
|
||||
static void (*printfcn) __P((DISPLAY *));
|
||||
static int (*sortfcn) __P((const FTSENT *, const FTSENT *));
|
||||
|
||||
long blocksize; /* block size units */
|
||||
int termwidth = 80; /* default terminal width */
|
||||
|
||||
/* flags */
|
||||
int f_accesstime; /* use time of last access */
|
||||
int f_flags; /* show flags associated with a file */
|
||||
int f_humanval; /* show human-readable file sizes */
|
||||
int f_inode; /* print inode */
|
||||
static int f_kblocks; /* print size in kilobytes */
|
||||
static int f_listdir; /* list actual directory, not contents */
|
||||
static int f_listdot; /* list files beginning with . */
|
||||
int f_longform; /* long listing format */
|
||||
int f_nonprint; /* show unprintables as ? */
|
||||
static int f_nosort; /* don't sort output */
|
||||
int f_notabs; /* don't use tab-separated multi-col output */
|
||||
static int f_numericonly; /* don't convert uid/gid to name */
|
||||
int f_octal; /* show unprintables as \xxx */
|
||||
int f_octal_escape; /* like f_octal but use C escapes if possible */
|
||||
static int f_recursive; /* ls subdirectories also */
|
||||
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 */
|
||||
int f_accesstime; /* use time of last access */
|
||||
int f_column; /* columnated format */
|
||||
int f_flags; /* show flags associated with a file */
|
||||
int f_inode; /* print inode */
|
||||
int f_kblocks; /* print size in kilobytes */
|
||||
int f_listdir; /* list actual directory, not contents */
|
||||
int f_listdot; /* list files beginning with . */
|
||||
int f_longform; /* long listing format */
|
||||
int f_nonprint; /* show unprintables as ? */
|
||||
int f_nosort; /* don't sort output */
|
||||
int f_notabs; /* don't use tab-separated multi-col output */
|
||||
int f_numericonly; /* don't convert uid/gid to name */
|
||||
int f_octal; /* show unprintables as \xxx */
|
||||
int f_octal_escape; /* like f_octal but use C escapes if possible */
|
||||
int f_recursive; /* ls subdirectories also */
|
||||
int f_reversesort; /* reverse whatever sort is used */
|
||||
int f_sectime; /* print the real time for all files */
|
||||
int f_singlecol; /* use single column output */
|
||||
int f_size; /* list size in short listing */
|
||||
int f_statustime; /* use time of last mode change */
|
||||
int f_timesort; /* sort by time vice name */
|
||||
int f_type; /* add type character for non-regular files */
|
||||
int f_whiteout; /* show whiteout entries */
|
||||
#ifdef COLORLS
|
||||
int f_color; /* add type in color for non-regular files */
|
||||
int f_color; /* add type in color for non-regular files */
|
||||
|
||||
char *ansi_bgcol; /* ANSI sequence to set background colour */
|
||||
char *ansi_fgcol; /* ANSI sequence to set foreground colour */
|
||||
char *ansi_coloff; /* ANSI sequence to reset colours */
|
||||
char *attrs_off; /* ANSI sequence to turn off attributes */
|
||||
char *enter_bold; /* ANSI sequence to set color to bold mode */
|
||||
#endif
|
||||
|
||||
static int rval;
|
||||
int rval;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
static char dot[] = ".", *dotav[] = {dot, NULL};
|
||||
static char dot[] = ".", *dotav[] = { dot, NULL };
|
||||
struct winsize win;
|
||||
int ch, fts_options, notused;
|
||||
char *p;
|
||||
|
||||
#ifdef COLORLS
|
||||
char termcapbuf[1024]; /* termcap definition buffer */
|
||||
char tcapbuf[512]; /* capability buffer */
|
||||
char termcapbuf[1024]; /* termcap definition buffer */
|
||||
char tcapbuf[512]; /* capability buffer */
|
||||
char *bp = tcapbuf;
|
||||
#endif
|
||||
|
||||
(void)setlocale(LC_ALL, "");
|
||||
(void) setlocale(LC_ALL, "");
|
||||
|
||||
/* 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;
|
||||
f_column = f_nonprint = 1;
|
||||
} else {
|
||||
f_singlecol = 1;
|
||||
/* retrieve environment variable, in case of explicit -C */
|
||||
p = getenv("COLUMNS");
|
||||
if (p)
|
||||
if ((p = getenv("COLUMNS")))
|
||||
termwidth = atoi(p);
|
||||
}
|
||||
|
||||
@@ -166,35 +163,28 @@ main(int argc, char *argv[])
|
||||
f_listdot = 1;
|
||||
|
||||
fts_options = FTS_PHYSICAL;
|
||||
while ((ch = getopt(argc, argv, "1ABCFGHLPRTWabcdfghiklmnopqrstuwx"))
|
||||
!= -1) {
|
||||
while ((ch = getopt(argc, argv, "1ABCFGHLPRTWabcdfgiklnoqrstu")) != -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;
|
||||
f_column = f_longform = 0;
|
||||
break;
|
||||
case 'B':
|
||||
f_nonprint = 0;
|
||||
f_octal = 1;
|
||||
f_octal_escape = 0;
|
||||
f_octal_escape = 0;
|
||||
break;
|
||||
case 'C':
|
||||
f_sortacross = f_longform = f_singlecol = 0;
|
||||
f_column = 1;
|
||||
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;
|
||||
f_column = f_singlecol = 0;
|
||||
break;
|
||||
/* The -c and -u options override each other. */
|
||||
case 'c':
|
||||
@@ -207,10 +197,9 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
case 'F':
|
||||
f_type = 1;
|
||||
f_slash = 0;
|
||||
break;
|
||||
case 'H':
|
||||
fts_options |= FTS_COMFOLLOW;
|
||||
fts_options |= FTS_COMFOLLOW;
|
||||
break;
|
||||
case 'G':
|
||||
setenv("CLICOLOR", "", 1);
|
||||
@@ -220,7 +209,7 @@ main(int argc, char *argv[])
|
||||
fts_options |= FTS_LOGICAL;
|
||||
break;
|
||||
case 'P':
|
||||
fts_options &= ~FTS_COMFOLLOW;
|
||||
fts_options &= ~FTS_COMFOLLOW;
|
||||
fts_options &= ~FTS_LOGICAL;
|
||||
fts_options |= FTS_PHYSICAL;
|
||||
break;
|
||||
@@ -241,10 +230,7 @@ main(int argc, char *argv[])
|
||||
case 'f':
|
||||
f_nosort = 1;
|
||||
break;
|
||||
case 'g': /* Compatibility with 4.3BSD. */
|
||||
break;
|
||||
case 'h':
|
||||
f_humanval = 1;
|
||||
case 'g': /* Compatibility with 4.3BSD. */
|
||||
break;
|
||||
case 'i':
|
||||
f_inode = 1;
|
||||
@@ -252,25 +238,16 @@ 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;
|
||||
f_octal_escape = 0;
|
||||
f_octal_escape = 0;
|
||||
break;
|
||||
case 'r':
|
||||
f_reversesort = 1;
|
||||
@@ -289,14 +266,9 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
case 'b':
|
||||
f_nonprint = 0;
|
||||
f_octal = 0;
|
||||
f_octal = 0;
|
||||
f_octal_escape = 1;
|
||||
break;
|
||||
case 'w':
|
||||
f_nonprint = 0;
|
||||
f_octal = 0;
|
||||
f_octal_escape = 0;
|
||||
break;
|
||||
default:
|
||||
case '?':
|
||||
usage();
|
||||
@@ -312,8 +284,6 @@ main(int argc, char *argv[])
|
||||
if (tgetent(termcapbuf, getenv("TERM")) == 1) {
|
||||
ansi_fgcol = tgetstr("AF", &bp);
|
||||
ansi_bgcol = tgetstr("AB", &bp);
|
||||
attrs_off = tgetstr("me", &bp);
|
||||
enter_bold = tgetstr("md", &bp);
|
||||
|
||||
/* To switch colours off use 'op' if
|
||||
* available, otherwise use 'oc', or
|
||||
@@ -336,8 +306,8 @@ main(int argc, char *argv[])
|
||||
* for "stty oxtabs" mode.
|
||||
*/
|
||||
f_notabs = 1;
|
||||
(void)signal(SIGINT, colorquit);
|
||||
(void)signal(SIGQUIT, colorquit);
|
||||
(void) signal(SIGINT, colorquit);
|
||||
(void) signal(SIGQUIT, colorquit);
|
||||
parsecolors(getenv("LSCOLORS"));
|
||||
}
|
||||
#endif
|
||||
@@ -351,7 +321,7 @@ main(int argc, char *argv[])
|
||||
#ifdef COLORLS
|
||||
&& !f_color
|
||||
#endif
|
||||
)
|
||||
)
|
||||
fts_options |= FTS_NOSTAT;
|
||||
|
||||
/*
|
||||
@@ -378,6 +348,7 @@ main(int argc, char *argv[])
|
||||
blocksize /= 512;
|
||||
}
|
||||
}
|
||||
|
||||
/* Select a sort function. */
|
||||
if (f_reversesort) {
|
||||
if (!f_timesort)
|
||||
@@ -386,7 +357,7 @@ main(int argc, char *argv[])
|
||||
sortfcn = revacccmp;
|
||||
else if (f_statustime)
|
||||
sortfcn = revstatcmp;
|
||||
else /* Use modification time. */
|
||||
else /* Use modification time. */
|
||||
sortfcn = revmodcmp;
|
||||
} else {
|
||||
if (!f_timesort)
|
||||
@@ -395,7 +366,7 @@ main(int argc, char *argv[])
|
||||
sortfcn = acccmp;
|
||||
else if (f_statustime)
|
||||
sortfcn = statcmp;
|
||||
else /* Use modification time. */
|
||||
else /* Use modification time. */
|
||||
sortfcn = modcmp;
|
||||
}
|
||||
|
||||
@@ -404,8 +375,6 @@ main(int argc, char *argv[])
|
||||
printfcn = printscol;
|
||||
else if (f_longform)
|
||||
printfcn = printlong;
|
||||
else if (f_stream)
|
||||
printfcn = printstream;
|
||||
else
|
||||
printfcn = printcol;
|
||||
|
||||
@@ -416,7 +385,7 @@ main(int argc, char *argv[])
|
||||
exit(rval);
|
||||
}
|
||||
|
||||
static int output; /* If anything output. */
|
||||
static int output; /* If anything output. */
|
||||
|
||||
/*
|
||||
* Traverse() walks the logical directory structure specified by the argv list
|
||||
@@ -425,7 +394,9 @@ static int output; /* If anything output. */
|
||||
* a superset (may be exact set) of the files to be displayed.
|
||||
*/
|
||||
static void
|
||||
traverse(int argc, char *argv[], int options)
|
||||
traverse(argc, argv, options)
|
||||
int argc, options;
|
||||
char *argv[];
|
||||
{
|
||||
FTS *ftsp;
|
||||
FTSENT *p, *chp;
|
||||
@@ -465,23 +436,19 @@ 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);
|
||||
display(p, chp);
|
||||
|
||||
if (!f_recursive && chp != NULL)
|
||||
(void)fts_set(ftsp, p, FTS_SKIP);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (errno)
|
||||
err(1, "fts_read");
|
||||
@@ -493,22 +460,19 @@ traverse(int argc, char *argv[], int options)
|
||||
* points to the parent directory of the display list.
|
||||
*/
|
||||
static void
|
||||
display(FTSENT *p, FTSENT *list)
|
||||
display(p, list)
|
||||
FTSENT *p, *list;
|
||||
{
|
||||
struct stat *sp;
|
||||
DISPLAY d;
|
||||
FTSENT *cur;
|
||||
NAMES *np;
|
||||
off_t maxsize;
|
||||
u_quad_t maxsize;
|
||||
u_long btotal, maxblock, maxinode, maxlen, maxnlink;
|
||||
int bcfile, maxflags;
|
||||
gid_t maxgroup;
|
||||
uid_t maxuser;
|
||||
size_t flen, ulen, glen;
|
||||
int bcfile, flen, glen, ulen, maxflags, maxgroup, maxuser;
|
||||
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];
|
||||
@@ -528,8 +492,6 @@ display(FTSENT *p, FTSENT *list)
|
||||
btotal = 0;
|
||||
initmax = getenv("LS_COLWIDTHS");
|
||||
/* Fields match -lios order. New ones should be added at the end. */
|
||||
maxblock = maxinode = maxlen = maxnlink =
|
||||
maxuser = maxgroup = maxflags = maxsize = 0;
|
||||
if (initmax != NULL && *initmax != '\0') {
|
||||
char *initmax2, *jinitmax;
|
||||
int ninitmax;
|
||||
@@ -552,53 +514,34 @@ display(FTSENT *p, FTSENT *list)
|
||||
initmax2[1] = '\0';
|
||||
}
|
||||
}
|
||||
if (initmax2[-1] == ':')
|
||||
strcpy(initmax2, "0");
|
||||
if (initmax2[-1] == ':') strcpy(initmax2, "0");
|
||||
|
||||
ninitmax = sscanf(jinitmax,
|
||||
" %lu : %lu : %lu : %i : %i : %i : %llu : %lu ",
|
||||
" %lu : %lu : %lu : %i : %i : %i : %qu : %lu ",
|
||||
&maxinode, &maxblock, &maxnlink, &maxuser,
|
||||
&maxgroup, &maxflags, &maxsize, &maxlen);
|
||||
f_notabs = 1;
|
||||
switch (ninitmax) {
|
||||
case 0:
|
||||
maxinode = 0;
|
||||
/* fall through */
|
||||
case 1:
|
||||
maxblock = 0;
|
||||
/* fall through */
|
||||
case 2:
|
||||
maxnlink = 0;
|
||||
/* fall through */
|
||||
case 3:
|
||||
maxuser = 0;
|
||||
/* fall through */
|
||||
case 4:
|
||||
maxgroup = 0;
|
||||
/* fall through */
|
||||
case 5:
|
||||
maxflags = 0;
|
||||
/* fall through */
|
||||
case 6:
|
||||
maxsize = 0;
|
||||
/* fall through */
|
||||
case 7:
|
||||
maxlen = 0;
|
||||
/* fall through */
|
||||
case 0: maxinode = 0;
|
||||
case 1: maxblock = 0;
|
||||
case 2: maxnlink = 0;
|
||||
case 3: maxuser = 0;
|
||||
case 4: maxgroup = 0;
|
||||
case 5: maxflags = 0;
|
||||
case 6: maxsize = 0;
|
||||
case 7: maxlen = 0;
|
||||
#ifdef COLORLS
|
||||
if (!f_color)
|
||||
if (!f_color)
|
||||
#endif
|
||||
f_notabs = 0;
|
||||
/* fall through */
|
||||
default:
|
||||
break;
|
||||
f_notabs = 0;
|
||||
}
|
||||
maxinode = makenines(maxinode);
|
||||
maxblock = makenines(maxblock);
|
||||
maxnlink = makenines(maxnlink);
|
||||
maxsize = makenines(maxsize);
|
||||
free(jinitmax);
|
||||
}
|
||||
} else if (initmax == NULL || *initmax == '\0')
|
||||
maxblock = maxinode = maxlen = maxnlink =
|
||||
maxuser = maxgroup = maxflags = maxsize = 0;
|
||||
bcfile = 0;
|
||||
flags = NULL;
|
||||
for (cur = list, entries = 0; cur; cur = cur->fts_link) {
|
||||
@@ -609,6 +552,7 @@ display(FTSENT *p, FTSENT *list)
|
||||
rval = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* P is NULL if list is the argv list, to which different rules
|
||||
* apply.
|
||||
@@ -629,10 +573,8 @@ display(FTSENT *p, FTSENT *list)
|
||||
if (cur->fts_namelen > maxlen)
|
||||
maxlen = cur->fts_namelen;
|
||||
if (f_octal || f_octal_escape) {
|
||||
u_long t = len_octal(cur->fts_name, cur->fts_namelen);
|
||||
|
||||
if (t > maxlen)
|
||||
maxlen = t;
|
||||
int t = len_octal(cur->fts_name, cur->fts_namelen);
|
||||
if (t > maxlen) maxlen = t;
|
||||
}
|
||||
if (needstats) {
|
||||
sp = cur->fts_statp;
|
||||
@@ -670,8 +612,7 @@ display(FTSENT *p, FTSENT *list)
|
||||
}
|
||||
if (flags == NULL)
|
||||
err(1, NULL);
|
||||
flen = strlen(flags);
|
||||
if (flen > (size_t)maxflags)
|
||||
if ((flen = strlen(flags)) > maxflags)
|
||||
maxflags = flen;
|
||||
} else
|
||||
flen = 0;
|
||||
@@ -691,7 +632,7 @@ display(FTSENT *p, FTSENT *list)
|
||||
|
||||
if (f_flags) {
|
||||
np->flags = &np->data[ulen + glen + 2];
|
||||
(void)strcpy(np->flags, flags);
|
||||
(void)strcpy(np->flags, flags);
|
||||
free(flags);
|
||||
}
|
||||
cur->fts_pointer = np;
|
||||
@@ -721,6 +662,7 @@ display(FTSENT *p, FTSENT *list)
|
||||
d.s_size = strlen(buf);
|
||||
d.s_user = maxuser;
|
||||
}
|
||||
|
||||
printfcn(&d);
|
||||
output = 1;
|
||||
|
||||
@@ -736,7 +678,8 @@ display(FTSENT *p, FTSENT *list)
|
||||
* All other levels use the sort function. Error entries remain unsorted.
|
||||
*/
|
||||
static int
|
||||
mastercmp(const FTSENT **a, const FTSENT **b)
|
||||
mastercmp(a, b)
|
||||
const FTSENT **a, **b;
|
||||
{
|
||||
int a_info, b_info;
|
||||
|
||||
@@ -765,7 +708,8 @@ mastercmp(const FTSENT **a, const FTSENT **b)
|
||||
* into a number that wide in decimal.
|
||||
*/
|
||||
static u_quad_t
|
||||
makenines(u_long n)
|
||||
makenines(n)
|
||||
u_long n;
|
||||
{
|
||||
u_long i;
|
||||
u_quad_t reg;
|
||||
|
||||
+7
-10
@@ -44,7 +44,6 @@ extern long blocksize; /* block size units */
|
||||
|
||||
extern int f_accesstime; /* use time of last access */
|
||||
extern int f_flags; /* show flags associated with a file */
|
||||
extern int f_humanval; /* show human-readable file sizes */
|
||||
extern int f_inode; /* print inode */
|
||||
extern int f_longform; /* long listing format */
|
||||
extern int f_octal; /* print unprintables in octal */
|
||||
@@ -52,8 +51,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 */
|
||||
@@ -67,13 +64,13 @@ typedef struct {
|
||||
int bcfile;
|
||||
int entries;
|
||||
int maxlen;
|
||||
u_int s_block;
|
||||
u_int s_flags;
|
||||
u_int s_group;
|
||||
u_int s_inode;
|
||||
u_int s_nlink;
|
||||
u_int s_size;
|
||||
u_int s_user;
|
||||
int s_block;
|
||||
int s_flags;
|
||||
int s_group;
|
||||
int s_inode;
|
||||
int s_nlink;
|
||||
int s_size;
|
||||
int s_user;
|
||||
} DISPLAY;
|
||||
|
||||
typedef struct {
|
||||
|
||||
+133
-264
@@ -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>
|
||||
@@ -48,8 +49,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fts.h>
|
||||
#include <math.h>
|
||||
#include <langinfo.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -64,69 +65,42 @@ __FBSDID("$FreeBSD$");
|
||||
#include "ls.h"
|
||||
#include "extern.h"
|
||||
|
||||
static int printaname(FTSENT *, u_long, u_long);
|
||||
static void printlink(FTSENT *);
|
||||
static void printtime(time_t);
|
||||
static int printtype(u_int);
|
||||
static void printsize(size_t, off_t);
|
||||
static int printaname __P((FTSENT *, u_long, u_long));
|
||||
static void printlink __P((FTSENT *));
|
||||
static void printtime __P((time_t));
|
||||
static int printtype __P((u_int));
|
||||
#ifdef COLORLS
|
||||
static void endcolor(int);
|
||||
static int colortype(mode_t);
|
||||
static void endcolor __P((int));
|
||||
static int colortype __P((mode_t));
|
||||
#endif
|
||||
|
||||
#define IS_NOPRINT(p) ((p)->fts_number == NO_PRINT)
|
||||
|
||||
#define KILO_SZ(n) (n)
|
||||
#define MEGA_SZ(n) ((n) * (n))
|
||||
#define GIGA_SZ(n) ((n) * (n) * (n))
|
||||
#define TERA_SZ(n) ((n) * (n) * (n) * (n))
|
||||
#define PETA_SZ(n) ((n) * (n) * (n) * (n) * (n))
|
||||
|
||||
#define KILO_2_SZ (KILO_SZ(1024ULL))
|
||||
#define MEGA_2_SZ (MEGA_SZ(1024ULL))
|
||||
#define GIGA_2_SZ (GIGA_SZ(1024ULL))
|
||||
#define TERA_2_SZ (TERA_SZ(1024ULL))
|
||||
#define PETA_2_SZ (PETA_SZ(1024ULL))
|
||||
|
||||
static unsigned long long vals_base2[] = {1, KILO_2_SZ, MEGA_2_SZ, GIGA_2_SZ, TERA_2_SZ, PETA_2_SZ};
|
||||
|
||||
typedef enum {
|
||||
NONE, KILO, MEGA, GIGA, TERA, PETA, UNIT_MAX
|
||||
} unit_t;
|
||||
static unit_t unit_adjust(off_t *);
|
||||
|
||||
static int unitp[] = {NONE, KILO, MEGA, GIGA, TERA, PETA};
|
||||
|
||||
#ifdef COLORLS
|
||||
/* Most of these are taken from <sys/stat.h> */
|
||||
typedef enum Colors {
|
||||
C_DIR, /* directory */
|
||||
C_LNK, /* symbolic link */
|
||||
C_SOCK, /* socket */
|
||||
C_FIFO, /* pipe */
|
||||
C_EXEC, /* executable */
|
||||
C_BLK, /* block special */
|
||||
C_CHR, /* character special */
|
||||
C_SUID, /* setuid executable */
|
||||
C_SGID, /* setgid executable */
|
||||
C_WSDIR, /* directory writeble to others, with sticky
|
||||
* bit */
|
||||
C_WDIR, /* directory writeble to others, without
|
||||
* sticky bit */
|
||||
C_NUMCOLORS /* just a place-holder */
|
||||
} Colors;
|
||||
C_DIR, /* directory */
|
||||
C_LNK, /* symbolic link */
|
||||
C_SOCK, /* socket */
|
||||
C_FIFO, /* pipe */
|
||||
C_EXEC, /* executable */
|
||||
C_BLK, /* block special */
|
||||
C_CHR, /* character special */
|
||||
C_SUID, /* setuid executable */
|
||||
C_SGID, /* setgid executable */
|
||||
C_WSDIR, /* directory writeble to others, with sticky bit */
|
||||
C_WDIR, /* directory writeble to others, without sticky bit */
|
||||
C_NUMCOLORS /* just a place-holder */
|
||||
} Colors ;
|
||||
|
||||
static const char *defcolors = "exfxcxdxbxegedabagacad";
|
||||
char *defcolors = "4x5x2x3x1x464301060203";
|
||||
|
||||
/* colors for file types */
|
||||
static struct {
|
||||
int num[2];
|
||||
int bold;
|
||||
} colors[C_NUMCOLORS];
|
||||
static int colors[C_NUMCOLORS][2];
|
||||
#endif
|
||||
|
||||
void
|
||||
printscol(DISPLAY *dp)
|
||||
printscol(dp)
|
||||
DISPLAY *dp;
|
||||
{
|
||||
FTSENT *p;
|
||||
|
||||
@@ -141,8 +115,9 @@ printscol(DISPLAY *dp)
|
||||
/*
|
||||
* print name in current style
|
||||
*/
|
||||
int
|
||||
printname(const char *name)
|
||||
static int
|
||||
printname(name)
|
||||
const char *name;
|
||||
{
|
||||
if (f_octal || f_octal_escape)
|
||||
return prn_octal(name);
|
||||
@@ -153,7 +128,8 @@ printname(const char *name)
|
||||
}
|
||||
|
||||
void
|
||||
printlong(DISPLAY *dp)
|
||||
printlong(dp)
|
||||
DISPLAY *dp;
|
||||
{
|
||||
struct stat *sp;
|
||||
FTSENT *p;
|
||||
@@ -173,9 +149,9 @@ printlong(DISPLAY *dp)
|
||||
if (f_inode)
|
||||
(void)printf("%*lu ", dp->s_inode, (u_long)sp->st_ino);
|
||||
if (f_size)
|
||||
(void)printf("%*lld ",
|
||||
(void)printf("%*qd ",
|
||||
dp->s_block, howmany(sp->st_blocks, blocksize));
|
||||
strmode(sp->st_mode, buf);
|
||||
(void)strmode(sp->st_mode, buf);
|
||||
np = p->fts_pointer;
|
||||
(void)printf("%s %*u %-*s %-*s ", buf, dp->s_nlink,
|
||||
sp->st_nlink, dp->s_user, np->user, dp->s_group,
|
||||
@@ -191,10 +167,10 @@ printlong(DISPLAY *dp)
|
||||
(void)printf("%3d, %3d ",
|
||||
major(sp->st_rdev), minor(sp->st_rdev));
|
||||
else if (dp->bcfile)
|
||||
(void)printf("%*s%*lld ",
|
||||
(void)printf("%*s%*qd ",
|
||||
8 - dp->s_size, "", dp->s_size, sp->st_size);
|
||||
else
|
||||
printsize(dp->s_size, sp->st_size);
|
||||
(void)printf("%*qd ", dp->s_size, sp->st_size);
|
||||
if (f_accesstime)
|
||||
printtime(sp->st_atime);
|
||||
else if (f_statustime)
|
||||
@@ -219,47 +195,15 @@ 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)
|
||||
printcol(dp)
|
||||
DISPLAY *dp;
|
||||
{
|
||||
extern int termwidth;
|
||||
static FTSENT **array;
|
||||
static int lastentries = -1;
|
||||
FTSENT *p;
|
||||
int base;
|
||||
int chcnt;
|
||||
int cnt;
|
||||
int col;
|
||||
int colwidth;
|
||||
int endcol;
|
||||
int num;
|
||||
int numcols;
|
||||
int numrows;
|
||||
int row;
|
||||
int base, chcnt, cnt, col, colwidth, num;
|
||||
int endcol, numcols, numrows, row;
|
||||
int tabwidth;
|
||||
|
||||
if (f_notabs)
|
||||
@@ -296,6 +240,7 @@ printcol(DISPLAY *dp)
|
||||
printscol(dp);
|
||||
return;
|
||||
}
|
||||
|
||||
numcols = termwidth / colwidth;
|
||||
numrows = num / numcols;
|
||||
if (num % numcols)
|
||||
@@ -303,26 +248,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;
|
||||
<= endcol){
|
||||
(void)putchar(f_notabs ? ' ' : '\t');
|
||||
chcnt = cnt;
|
||||
}
|
||||
@@ -337,7 +271,9 @@ printcol(DISPLAY *dp)
|
||||
* return # of characters printed, no trailing characters.
|
||||
*/
|
||||
static int
|
||||
printaname(FTSENT *p, u_long inodefield, u_long sizefield)
|
||||
printaname(p, inodefield, sizefield)
|
||||
FTSENT *p;
|
||||
u_long sizefield, inodefield;
|
||||
{
|
||||
struct stat *sp;
|
||||
int chcnt;
|
||||
@@ -350,7 +286,7 @@ printaname(FTSENT *p, u_long inodefield, u_long sizefield)
|
||||
if (f_inode)
|
||||
chcnt += printf("%*lu ", (int)inodefield, (u_long)sp->st_ino);
|
||||
if (f_size)
|
||||
chcnt += printf("%*lld ",
|
||||
chcnt += printf("%*qd ",
|
||||
(int)sizefield, howmany(sp->st_blocks, blocksize));
|
||||
#ifdef COLORLS
|
||||
if (f_color)
|
||||
@@ -367,44 +303,37 @@ printaname(FTSENT *p, u_long inodefield, u_long sizefield)
|
||||
}
|
||||
|
||||
static void
|
||||
printtime(time_t ftime)
|
||||
printtime(ftime)
|
||||
time_t ftime;
|
||||
{
|
||||
char longstring[80];
|
||||
static time_t now;
|
||||
const char *format;
|
||||
static int d_first = -1;
|
||||
|
||||
if (d_first < 0)
|
||||
d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
|
||||
if (now == 0)
|
||||
now = time(NULL);
|
||||
|
||||
#define SIXMONTHS ((365 / 2) * 86400)
|
||||
/* "%Ef" is a FreeBSD strftime definition for "%e %b" or "%b %e".
|
||||
* Actually format is locale sensitive.
|
||||
*/
|
||||
if (f_sectime)
|
||||
/* mmm dd hh:mm:ss yyyy || dd mmm hh:mm:ss yyyy */
|
||||
format = d_first ? "%e %b %T %Y " : "%b %e %T %Y ";
|
||||
format = "%Ef %T %Y ";
|
||||
else if (ftime + SIXMONTHS > now && ftime < now + SIXMONTHS)
|
||||
/* mmm dd hh:mm || dd mmm hh:mm */
|
||||
format = d_first ? "%e %b %R " : "%b %e %R ";
|
||||
format = "%Ef %R ";
|
||||
else
|
||||
/* mmm dd yyyy || dd mmm yyyy */
|
||||
format = d_first ? "%e %b %Y " : "%b %e %Y ";
|
||||
format = "%Ef %Y ";
|
||||
strftime(longstring, sizeof(longstring), format, localtime(&ftime));
|
||||
fputs(longstring, stdout);
|
||||
}
|
||||
|
||||
static int
|
||||
printtype(u_int mode)
|
||||
printtype(mode)
|
||||
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('/');
|
||||
@@ -421,8 +350,6 @@ printtype(u_int mode)
|
||||
case S_IFWHT:
|
||||
(void)putchar('%');
|
||||
return (1);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
|
||||
(void)putchar('*');
|
||||
@@ -433,156 +360,142 @@ printtype(u_int mode)
|
||||
|
||||
#ifdef COLORLS
|
||||
static int
|
||||
putch(int c)
|
||||
putch(c)
|
||||
int c;
|
||||
{
|
||||
(void)putchar(c);
|
||||
(void) putchar(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
writech(int c)
|
||||
writech(c)
|
||||
int c;
|
||||
{
|
||||
char tmp = c;
|
||||
|
||||
(void)write(STDOUT_FILENO, &tmp, 1);
|
||||
(void) write(STDOUT_FILENO, &tmp, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
printcolor(Colors c)
|
||||
printcolor(c)
|
||||
Colors c;
|
||||
{
|
||||
char *ansiseq;
|
||||
|
||||
if (colors[c].bold)
|
||||
tputs(enter_bold, 1, putch);
|
||||
|
||||
if (colors[c].num[0] != -1) {
|
||||
ansiseq = tgoto(ansi_fgcol, 0, colors[c].num[0]);
|
||||
if (colors[c][0] != -1) {
|
||||
ansiseq = tgoto(ansi_fgcol, 0, colors[c][0]);
|
||||
if (ansiseq)
|
||||
tputs(ansiseq, 1, putch);
|
||||
}
|
||||
if (colors[c].num[1] != -1) {
|
||||
ansiseq = tgoto(ansi_bgcol, 0, colors[c].num[1]);
|
||||
|
||||
if (colors[c][1] != -1) {
|
||||
ansiseq = tgoto(ansi_bgcol, 0, colors[c][1]);
|
||||
if (ansiseq)
|
||||
tputs(ansiseq, 1, putch);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
endcolor(int sig)
|
||||
endcolor(sig)
|
||||
int sig;
|
||||
{
|
||||
tputs(ansi_coloff, 1, sig ? writech : putch);
|
||||
tputs(attrs_off, 1, sig ? writech : putch);
|
||||
}
|
||||
|
||||
static int
|
||||
colortype(mode_t mode)
|
||||
colortype(mode)
|
||||
mode_t mode;
|
||||
{
|
||||
switch (mode & S_IFMT) {
|
||||
case S_IFDIR:
|
||||
switch(mode & S_IFMT) {
|
||||
case S_IFDIR:
|
||||
if (mode & S_IWOTH)
|
||||
if (mode & S_ISTXT)
|
||||
printcolor(C_WSDIR);
|
||||
else
|
||||
printcolor(C_WDIR);
|
||||
if (mode & S_ISTXT)
|
||||
printcolor(C_WSDIR);
|
||||
else
|
||||
printcolor(C_WDIR);
|
||||
else
|
||||
printcolor(C_DIR);
|
||||
return (1);
|
||||
case S_IFLNK:
|
||||
printcolor(C_DIR);
|
||||
return(1);
|
||||
case S_IFLNK:
|
||||
printcolor(C_LNK);
|
||||
return (1);
|
||||
case S_IFSOCK:
|
||||
return(1);
|
||||
case S_IFSOCK:
|
||||
printcolor(C_SOCK);
|
||||
return (1);
|
||||
case S_IFIFO:
|
||||
return(1);
|
||||
case S_IFIFO:
|
||||
printcolor(C_FIFO);
|
||||
return (1);
|
||||
case S_IFBLK:
|
||||
return(1);
|
||||
case S_IFBLK:
|
||||
printcolor(C_BLK);
|
||||
return (1);
|
||||
case S_IFCHR:
|
||||
return(1);
|
||||
case S_IFCHR:
|
||||
printcolor(C_CHR);
|
||||
return (1);
|
||||
return(1);
|
||||
}
|
||||
if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
|
||||
if (mode & S_ISUID)
|
||||
printcolor(C_SUID);
|
||||
printcolor(C_SUID);
|
||||
else if (mode & S_ISGID)
|
||||
printcolor(C_SGID);
|
||||
printcolor(C_SGID);
|
||||
else
|
||||
printcolor(C_EXEC);
|
||||
return (1);
|
||||
printcolor(C_EXEC);
|
||||
return(1);
|
||||
}
|
||||
return (0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
parsecolors(const char *cs)
|
||||
parsecolors(cs)
|
||||
char *cs;
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int len;
|
||||
int i, j, len;
|
||||
char c[2];
|
||||
short legacy_warn = 0;
|
||||
|
||||
if (cs == NULL)
|
||||
cs = ""; /* LSCOLORS not set */
|
||||
if (cs == NULL) cs = ""; /* LSCOLORS not set */
|
||||
len = strlen(cs);
|
||||
for (i = 0; i < C_NUMCOLORS; i++) {
|
||||
colors[i].bold = 0;
|
||||
|
||||
if (len <= 2 * i) {
|
||||
c[0] = defcolors[2 * i];
|
||||
c[1] = defcolors[2 * i + 1];
|
||||
} else {
|
||||
c[0] = cs[2 * i];
|
||||
c[1] = cs[2 * i + 1];
|
||||
for (i = 0 ; i < C_NUMCOLORS ; i++) {
|
||||
if (len <= 2*i) {
|
||||
c[0] = defcolors[2*i];
|
||||
c[1] = defcolors[2*i+1];
|
||||
}
|
||||
for (j = 0; j < 2; j++) {
|
||||
/* Legacy colours used 0-7 */
|
||||
if (c[j] >= '0' && c[j] <= '7') {
|
||||
colors[i].num[j] = c[j] - '0';
|
||||
if (!legacy_warn) {
|
||||
fprintf(stderr,
|
||||
"warn: LSCOLORS should use "
|
||||
"characters a-h instead of 0-9 ("
|
||||
"see the manual page)\n");
|
||||
}
|
||||
legacy_warn = 1;
|
||||
} else if (c[j] >= 'a' && c[j] <= 'h')
|
||||
colors[i].num[j] = c[j] - 'a';
|
||||
else if (c[j] >= 'A' && c[j] <= 'H') {
|
||||
colors[i].num[j] = c[j] - 'A';
|
||||
colors[i].bold = 1;
|
||||
} else if (tolower((unsigned char)c[j] == 'x'))
|
||||
colors[i].num[j] = -1;
|
||||
else {
|
||||
else {
|
||||
c[0] = cs[2*i];
|
||||
c[1] = cs[2*i+1];
|
||||
}
|
||||
for (j = 0 ; j < 2 ; j++) {
|
||||
if ((c[j] < '0' || c[j] > '7') &&
|
||||
tolower((unsigned char)c[j]) != 'x') {
|
||||
fprintf(stderr,
|
||||
"error: invalid character '%c' in LSCOLORS"
|
||||
" env var\n", c[j]);
|
||||
colors[i].num[j] = -1;
|
||||
"error: invalid character '%c' in LSCOLORS env var\n",
|
||||
c[j]);
|
||||
c[j] = defcolors[2*i+j];
|
||||
}
|
||||
if (tolower((unsigned char)c[j]) == 'x')
|
||||
colors[i][j] = -1;
|
||||
else
|
||||
colors[i][j] = c[j]-'0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
colorquit(int sig)
|
||||
colorquit(sig)
|
||||
int sig;
|
||||
{
|
||||
endcolor(sig);
|
||||
|
||||
(void)signal(sig, SIG_DFL);
|
||||
(void)kill(getpid(), sig);
|
||||
(void) signal(sig, SIG_DFL);
|
||||
(void) kill(getpid(), sig);
|
||||
}
|
||||
|
||||
#endif /* COLORLS */
|
||||
|
||||
#endif /*COLORLS*/
|
||||
|
||||
static void
|
||||
printlink(FTSENT *p)
|
||||
printlink(p)
|
||||
FTSENT *p;
|
||||
{
|
||||
int lnklen;
|
||||
char name[MAXPATHLEN + 1];
|
||||
char path[MAXPATHLEN + 1];
|
||||
char name[MAXPATHLEN + 1], path[MAXPATHLEN + 1];
|
||||
|
||||
if (p->fts_level == FTS_ROOTLEVEL)
|
||||
(void)snprintf(name, sizeof(name), "%s", p->fts_name);
|
||||
@@ -595,49 +508,5 @@ printlink(FTSENT *p)
|
||||
}
|
||||
path[lnklen] = '\0';
|
||||
(void)printf(" -> ");
|
||||
(void)printname(path);
|
||||
}
|
||||
|
||||
static void
|
||||
printsize(size_t width, off_t bytes)
|
||||
{
|
||||
unit_t unit;
|
||||
|
||||
if (f_humanval) {
|
||||
unit = unit_adjust(&bytes);
|
||||
|
||||
if (bytes == 0)
|
||||
(void)printf("%*s ", width, "0B");
|
||||
else
|
||||
(void)printf("%*lld%c ", width - 1, bytes,
|
||||
"BKMGTPE"[unit]);
|
||||
} else
|
||||
(void)printf("%*lld ", width, bytes);
|
||||
}
|
||||
|
||||
/*
|
||||
* Output in "human-readable" format. Uses 3 digits max and puts
|
||||
* unit suffixes at the end. Makes output compact and easy to read,
|
||||
* especially on huge disks.
|
||||
*
|
||||
*/
|
||||
unit_t
|
||||
unit_adjust(off_t *val)
|
||||
{
|
||||
double abval;
|
||||
unit_t unit;
|
||||
unsigned int unit_sz;
|
||||
|
||||
abval = fabs((double)*val);
|
||||
|
||||
unit_sz = abval ? ilogb(abval) / 10 : 0;
|
||||
|
||||
if (unit_sz >= UNIT_MAX) {
|
||||
unit = NONE;
|
||||
} else {
|
||||
unit = unitp[unit_sz];
|
||||
*val /= (double)vals_base2[unit_sz];
|
||||
}
|
||||
|
||||
return (unit);
|
||||
printname(path);
|
||||
}
|
||||
+22
-16
@@ -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>
|
||||
@@ -56,13 +57,14 @@ __FBSDID("$FreeBSD$");
|
||||
#include "extern.h"
|
||||
|
||||
int
|
||||
prn_printable(const char *s)
|
||||
prn_printable(s)
|
||||
const char *s;
|
||||
{
|
||||
char c;
|
||||
unsigned char c;
|
||||
int n;
|
||||
|
||||
for (n = 0; (c = *s) != '\0'; ++s, ++n)
|
||||
if (isprint((unsigned char)c))
|
||||
if (isprint(c))
|
||||
putchar(c);
|
||||
else
|
||||
putchar('?');
|
||||
@@ -82,23 +84,27 @@ prn_printable(const char *s)
|
||||
* DES 1998/04/23
|
||||
*/
|
||||
|
||||
size_t
|
||||
len_octal(const char *s, int len)
|
||||
int
|
||||
len_octal(s, len)
|
||||
const char *s;
|
||||
int len;
|
||||
{
|
||||
size_t r = 0;
|
||||
int r = 0;
|
||||
|
||||
while (len--)
|
||||
if (isprint((unsigned const char)*s++)) r++; else r += 4;
|
||||
if (isprint((unsigned char)*s++)) r++; else r += 4;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
prn_octal(const char *s)
|
||||
prn_octal(s)
|
||||
const char *s;
|
||||
{
|
||||
unsigned char ch;
|
||||
int len = 0;
|
||||
|
||||
while ((ch = (unsigned char)*s++)) {
|
||||
while ((ch = *s++))
|
||||
{
|
||||
if (isprint(ch) && (ch != '\"') && (ch != '\\'))
|
||||
putchar(ch), len++;
|
||||
else if (f_octal_escape) {
|
||||
@@ -152,13 +158,13 @@ prn_octal(const char *s)
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
#ifdef COLORLS
|
||||
"usage: ls [-ABCFGHLPRTWabcdfghiklmnoqrstuwx1]"
|
||||
"usage: ls [-ABCFGHLPRTWabcdfgiklnoqrstu1]"
|
||||
#else
|
||||
"usage: ls [-ABCFHLPRTWabcdfghiklmnoqrstuwx1]"
|
||||
"usage: ls [-ABCFHLPRTWabcdfgiklnoqrstu1]"
|
||||
#endif
|
||||
" [file ...]\n");
|
||||
exit(1);
|
||||
|
||||
+4
-7
@@ -47,9 +47,8 @@
|
||||
.Op Fl m Ar mode
|
||||
.Ar directory_name ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility creates the directories named as operands, in the order specified,
|
||||
.Nm Mkdir
|
||||
creates the directories named as operands, in the order specified,
|
||||
using mode
|
||||
.Li rwxrwxrwx (\&0777)
|
||||
as modified by the current
|
||||
@@ -58,12 +57,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
@@ -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
@@ -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
@@ -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) {
|
||||
/*
|
||||
|
||||
+6
-16
@@ -46,7 +46,6 @@ static const char rcsid[] =
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <langinfo.h>
|
||||
#include <stdio.h>
|
||||
#include <utmp.h>
|
||||
#include <unistd.h>
|
||||
@@ -65,17 +64,13 @@ static const char rcsid[] =
|
||||
#define MODELEN 20
|
||||
#define DATELEN 64
|
||||
#define SIXMONTHS ((365 / 2) * 86400)
|
||||
#define CURFRMTM "%b %e %H:%M"
|
||||
#define OLDFRMTM "%b %e %Y"
|
||||
#define CURFRMTD "%e %b %H:%M"
|
||||
#define OLDFRMTD "%e %b %Y"
|
||||
#define CURFRMT "%Ef %H:%M"
|
||||
#define OLDFRMT "%Ef %Y"
|
||||
#ifndef UT_NAMESIZE
|
||||
#define UT_NAMESIZE 8
|
||||
#endif
|
||||
#define UT_GRPSIZE 6
|
||||
|
||||
static int d_first = -1;
|
||||
|
||||
/*
|
||||
* ls_list()
|
||||
* list the members of an archive in ls format
|
||||
@@ -106,8 +101,6 @@ ls_list(arcn, now, fp)
|
||||
return;
|
||||
}
|
||||
|
||||
if (d_first < 0)
|
||||
d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
|
||||
/*
|
||||
* user wants long mode
|
||||
*/
|
||||
@@ -118,9 +111,9 @@ ls_list(arcn, now, fp)
|
||||
* time format based on age compared to the time pax was started.
|
||||
*/
|
||||
if ((sbp->st_mtime + SIXMONTHS) <= now)
|
||||
timefrmt = d_first ? OLDFRMTD : OLDFRMTM;
|
||||
timefrmt = OLDFRMT;
|
||||
else
|
||||
timefrmt = d_first ? CURFRMTD : CURFRMTM;
|
||||
timefrmt = CURFRMT;
|
||||
|
||||
/*
|
||||
* print file mode, link count, uid, gid and time
|
||||
@@ -182,13 +175,10 @@ ls_tty(arcn)
|
||||
char f_mode[MODELEN];
|
||||
char *timefrmt;
|
||||
|
||||
if (d_first < 0)
|
||||
d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
|
||||
|
||||
if ((arcn->sb.st_mtime + SIXMONTHS) <= time((time_t *)NULL))
|
||||
timefrmt = d_first ? OLDFRMTD : OLDFRMTM;
|
||||
timefrmt = OLDFRMT;
|
||||
else
|
||||
timefrmt = d_first ? CURFRMTD : CURFRMTM;
|
||||
timefrmt = CURFRMT;
|
||||
|
||||
/*
|
||||
* convert time to string, and print
|
||||
|
||||
+28
-29
@@ -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
@@ -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
@@ -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
@@ -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
|
||||
+30
-33
@@ -31,40 +31,37 @@
|
||||
* 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 arg_max;
|
||||
char **p, *dst, *src;
|
||||
static char *buf = NULL;
|
||||
|
||||
@@ -75,44 +72,45 @@ 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')
|
||||
strvis(dst, src, VIS_NL | VIS_CSTYLE);
|
||||
while (*dst)
|
||||
dst++;
|
||||
if ((4 * arg_max - (dst - buf)) / 4 > 0)
|
||||
*dst++ = ' ';
|
||||
*dst++ = ' ';
|
||||
}
|
||||
/* Chop off trailing space */
|
||||
if (dst != buf && dst[-1] == ' ')
|
||||
if (dst != buf)
|
||||
dst--;
|
||||
*dst = '\0';
|
||||
return (buf);
|
||||
}
|
||||
|
||||
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 +119,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);
|
||||
|
||||
+33
-53
@@ -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",
|
||||
@@ -124,12 +127,12 @@ static VAR var[] = {
|
||||
NULL, USER, rvar, NULL, 4, ROFF(ru_nswap), LONG, "ld"},
|
||||
{"nvcsw", "NVCSW",
|
||||
NULL, USER, rvar, NULL, 5, ROFF(ru_nvcsw), LONG, "ld"},
|
||||
{"nwchan", "WCHAN", NULL, 0, pvar, NULL, 8, POFF(p_wchan), KPTR, "lx"},
|
||||
{"nwchan", "WCHAN", NULL, 0, pvar, NULL, 6, POFF(p_wchan), KPTR, "lx"},
|
||||
{"oublk", "OUBLK",
|
||||
NULL, USER, rvar, NULL, 4, ROFF(ru_oublock), LONG, "ld"},
|
||||
{"oublock", "", "oublk"},
|
||||
{"p_ru", "P_RU", NULL, 0, pvar, NULL, 6, POFF(p_ru), KPTR, "lx"},
|
||||
{"paddr", "PADDR", NULL, 0, evar, NULL, 8, EOFF(e_paddr), KPTR, "lx"},
|
||||
{"paddr", "PADDR", NULL, 0, evar, NULL, 6, EOFF(e_paddr), KPTR, "lx"},
|
||||
{"pagein", "PAGEIN", NULL, USER, pagein, NULL, 6},
|
||||
{"pcpu", "", "%cpu"},
|
||||
{"pending", "", "sig"},
|
||||
@@ -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
@@ -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;
|
||||
|
||||
|
||||
+33
-39
@@ -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>
|
||||
@@ -52,15 +51,13 @@ __FBSDID("$FreeBSD$");
|
||||
#include <vm/vm.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <langinfo.h>
|
||||
#include <locale.h>
|
||||
#include <math.h>
|
||||
#include <nlist.h>
|
||||
#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 +67,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,12 +337,14 @@ 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];
|
||||
|
||||
v = ve->var;
|
||||
@@ -362,16 +352,19 @@ started(KINFO *k, VARENT *ve)
|
||||
(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);
|
||||
/* I *hate* SCCS... */
|
||||
static char fmt[] = __CONCAT("%l:%", "M%p");
|
||||
(void)strftime(buf, sizeof(buf) - 1, fmt, 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);
|
||||
/* I *hate* SCCS... */
|
||||
static char fmt[] = __CONCAT("%a%", "I%p");
|
||||
(void)strftime(buf, sizeof(buf) - 1, fmt, tp);
|
||||
} else
|
||||
(void)strftime(buf, sizeof(buf) - 1, "%e%b%y", tp);
|
||||
(void)printf("%-*s", v->width, buf);
|
||||
@@ -410,7 +403,7 @@ wchan(k, ve)
|
||||
KI_EPROC(k)->e_wmesg);
|
||||
else
|
||||
(void)printf("%-*lx", v->width,
|
||||
(long)KI_PROC(k)->p_wchan);
|
||||
(long)KI_PROC(k)->p_wchan &~ KERNBASE);
|
||||
} else
|
||||
(void)printf("%-*s", v->width, "-");
|
||||
}
|
||||
@@ -464,10 +457,7 @@ cputime(k, ve)
|
||||
long secs;
|
||||
long psecs; /* "parts" of a second. first micro, then centi */
|
||||
char obuff[128];
|
||||
static char decimal_point = 0;
|
||||
|
||||
if (!decimal_point)
|
||||
decimal_point = localeconv()->decimal_point[0];
|
||||
v = ve->var;
|
||||
if (KI_PROC(k)->p_stat == SZOMB || !k->ki_u.u_valid) {
|
||||
secs = 0;
|
||||
@@ -494,12 +484,13 @@ cputime(k, ve)
|
||||
psecs = psecs % 100;
|
||||
}
|
||||
(void)snprintf(obuff, sizeof(obuff),
|
||||
"%3ld:%02ld%c%02ld", secs/60, secs%60, decimal_point, psecs);
|
||||
"%3ld:%02ld.%02ld", secs/60, secs%60, psecs);
|
||||
(void)printf("%*s", v->width, obuff);
|
||||
}
|
||||
|
||||
double
|
||||
getpcpu(const KINFO *k)
|
||||
getpcpu(k)
|
||||
KINFO *k;
|
||||
{
|
||||
struct proc *p;
|
||||
static int failure;
|
||||
@@ -532,8 +523,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 +572,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 +632,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;
|
||||
@@ -678,7 +672,7 @@ printval(void *bp, VAR *v)
|
||||
(void)printf(ofmt, v->width, *(u_long *)bp);
|
||||
break;
|
||||
case KPTR:
|
||||
(void)printf(ofmt, v->width, *(u_long *)bp);
|
||||
(void)printf(ofmt, v->width, *(u_long *)bp &~ KERNBASE);
|
||||
break;
|
||||
default:
|
||||
errx(1, "unknown type %d", v->type);
|
||||
|
||||
+60
-127
@@ -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,25 @@
|
||||
.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
|
||||
.Op Fl W Ar swap
|
||||
.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 +79,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 +94,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 +101,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 +126,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 +145,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.
|
||||
@@ -221,6 +166,9 @@ The
|
||||
option implies the
|
||||
.Fl m
|
||||
option.
|
||||
.It Fl W
|
||||
Extract swap information from the specified file instead of
|
||||
using libkvm.
|
||||
.It Fl w
|
||||
Use 132 columns to display information, instead of the default which
|
||||
is your window size.
|
||||
@@ -229,22 +177,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 +201,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 +215,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 +236,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 +270,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 +292,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 +329,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
|
||||
@@ -536,6 +483,10 @@ exit or stop status (valid only for stopped or zombie process)
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width /var/db/kvm_kernel.db -compact
|
||||
.It Pa /dev
|
||||
special files and device names
|
||||
.It Pa /dev/drum
|
||||
default swap device
|
||||
.It Pa /dev/kmem
|
||||
default kernel memory
|
||||
.It Pa /var/run/dev.db
|
||||
@@ -556,26 +507,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.
|
||||
+257
-774
File diff suppressed because it is too large.
Load diff
+7
-11
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 *));
|
||||
@@ -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"
|
||||
+8
-15
@@ -40,18 +40,17 @@
|
||||
.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
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility copies files between machines. Each
|
||||
.Nm Rcp
|
||||
copies files between machines. Each
|
||||
.Ar file
|
||||
or
|
||||
.Ar directory
|
||||
@@ -63,10 +62,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
|
||||
@@ -118,16 +113,14 @@ A
|
||||
on a remote host may be quoted (using \e, ", or \(aa)
|
||||
so that the metacharacters are interpreted remotely.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
utility does not prompt for passwords; it performs remote execution
|
||||
.Nm Rcp
|
||||
does not prompt for passwords; it performs remote execution
|
||||
via
|
||||
.Xr rsh 1 ,
|
||||
and requires the same authorization.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
utility handles third party copies, where neither source nor target files
|
||||
.Nm Rcp
|
||||
handles third party copies, where neither source nor target files
|
||||
are on the current machine.
|
||||
.Sh FILES
|
||||
.Bl -tag -width /etc/auth.conf -compact
|
||||
|
||||
+98
-82
@@ -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
@@ -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,6 +2,8 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= rm
|
||||
WARNS?= 2
|
||||
SRCS= rm.c
|
||||
|
||||
LINKS= ${BINDIR}/rm ${BINDIR}/unlink
|
||||
MLINKS= rm.1 unlink.1
|
||||
|
||||
+41
-39
@@ -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,19 +187,25 @@ 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
|
||||
command conforms to
|
||||
.St -p1003.2 .
|
||||
command is almost
|
||||
.St -p1003.2
|
||||
compatible, except that
|
||||
.Tn POSIX
|
||||
requires
|
||||
.Nm
|
||||
to act like
|
||||
.Xr rmdir 1
|
||||
when the
|
||||
.Ar file
|
||||
specified is a directory. This implementation requires the
|
||||
.Fl d
|
||||
option if such behavior is desired. This follows the historical
|
||||
behavior of
|
||||
.Nm
|
||||
with respect to directories.
|
||||
.Pp
|
||||
The simplified
|
||||
.Nm unlink
|
||||
@@ -206,11 +216,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
@@ -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);
|
||||
}
|
||||
+7
-13
@@ -9,20 +9,17 @@ SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
|
||||
PROG= rmail
|
||||
SRCS= rmail.c
|
||||
MAN= rmail.8
|
||||
CFLAGS+=-I${SENDMAIL_DIR}/include -I.
|
||||
CFLAGS+=-I${SENDMAIL_DIR}/include
|
||||
|
||||
.if exists(${.OBJDIR}/../../lib/libsm)
|
||||
LIBSMDIR:= ${.OBJDIR}/../../lib/libsm
|
||||
.if exists(${.OBJDIR}/../../lib/libsmutil)
|
||||
LIBSMUTILDIR:= ${.OBJDIR}/../../lib/libsmutil
|
||||
.else
|
||||
LIBSMDIR!= cd ${.CURDIR}/../../lib/libsm; make -V .OBJDIR
|
||||
LIBSMUTILDIR!= cd ${.CURDIR}/../../lib/libsmutil; make -V .OBJDIR
|
||||
.endif
|
||||
LIBSM:= ${LIBSMDIR}/libsm.a
|
||||
LIBSMUTIL:= ${LIBSMUTILDIR}/libsmutil.a
|
||||
|
||||
DPADD= ${LIBSM}
|
||||
LDADD= ${LIBSM}
|
||||
|
||||
SRCS+= sm_os.h
|
||||
CLEANFILES+=sm_os.h
|
||||
DPADD= ${LIBSMUTIL}
|
||||
LDADD= ${LIBSMUTIL}
|
||||
|
||||
# User customizations to the sendmail build environment
|
||||
CFLAGS+=${SENDMAIL_CFLAGS}
|
||||
@@ -37,7 +34,4 @@ LDFLAGS+=${SENDMAIL_LDFLAGS}
|
||||
# Not much point this being static. It calls a shared sendmail...
|
||||
NOSHARED?= NO
|
||||
|
||||
sm_os.h:
|
||||
ln -sf ${SENDMAIL_DIR}/include/sm/os/sm_os_freebsd.h sm_os.h
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
+2
-5
@@ -2,11 +2,10 @@
|
||||
# $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 \
|
||||
test.c trap.c var.c
|
||||
trap.c var.c
|
||||
GENSRCS= builtins.c init.c nodes.c syntax.c
|
||||
GENHDRS= builtins.h nodes.h syntax.h token.h y.tab.h
|
||||
SRCS= ${SHSRCS} ${GENSRCS} ${GENHDRS} y.tab.h
|
||||
@@ -23,9 +22,7 @@ CFLAGS+=-DSHELL -I. -I${.CURDIR}
|
||||
# for debug:
|
||||
# CFLAGS+= -g -DDEBUG=2
|
||||
|
||||
.PATH: ${.CURDIR}/bltin \
|
||||
${.CURDIR}/../../usr.bin/printf \
|
||||
${.CURDIR}/../../bin/test
|
||||
.PATH: ${.CURDIR}/bltin ${.CURDIR}/../../usr.bin/printf
|
||||
|
||||
CLEANFILES+= mkinit mkinit.o mknodes mknodes.o \
|
||||
mksyntax mksyntax.o
|
||||
|
||||
+28
-26
@@ -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
@@ -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
@@ -34,5 +34,5 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
int arith(char *);
|
||||
int expcmd(int , char **);
|
||||
int arith __P((char *));
|
||||
int expcmd __P((int , char **));
|
||||
+15
-8
@@ -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
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
+2
-5
@@ -47,9 +47,8 @@
|
||||
.Op Fl n | Fl e
|
||||
.Ar args...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility prints its arguments on the standard output, separated by spaces.
|
||||
prints its arguments on the standard output, separated by spaces.
|
||||
Unless the
|
||||
.Fl n
|
||||
option is present, a newline is output following the arguments.
|
||||
@@ -92,9 +91,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
@@ -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;
|
||||
|
||||
+2
-5
@@ -49,8 +49,7 @@
|
||||
#
|
||||
# NOTE: bltincmd must come first!
|
||||
|
||||
bltincmd builtin
|
||||
commandcmd command
|
||||
bltincmd command
|
||||
#alloccmd alloc
|
||||
bgcmd -j bg
|
||||
breakcmd break continue
|
||||
@@ -63,7 +62,7 @@ execcmd exec
|
||||
exitcmd exit
|
||||
expcmd exp let
|
||||
exportcmd export readonly
|
||||
#exprcmd expr
|
||||
#exprcmd expr test [
|
||||
falsecmd false
|
||||
histcmd -h fc
|
||||
fgcmd -j fg
|
||||
@@ -91,5 +90,3 @@ waitcmd wait
|
||||
#foocmd foo
|
||||
aliascmd alias
|
||||
ulimitcmd ulimit
|
||||
testcmd test [
|
||||
bindcmd bind
|
||||
+111
-120
@@ -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);
|
||||
}
|
||||
setvar("PWD", curdir, VEXPORT);
|
||||
setvar("OLDPWD", prevdir, VEXPORT);
|
||||
if (getpwd() == NULL)
|
||||
error("getcwd() failed: %s", strerror(errno));
|
||||
setvar("PWD", curdir, VEXPORT | VTEXTFIXED);
|
||||
setvar("OLDPWD", prevdir, VEXPORT | VTEXTFIXED);
|
||||
INTON;
|
||||
return (0);
|
||||
return;
|
||||
}
|
||||
cdcomppath = stalloc(strlen(dir) + 1);
|
||||
scopy(dir, cdcomppath);
|
||||
@@ -310,64 +270,54 @@ updatepwd(char *dir)
|
||||
ckfree(prevdir);
|
||||
prevdir = curdir;
|
||||
curdir = savestr(stackblock());
|
||||
setvar("PWD", curdir, VEXPORT);
|
||||
setvar("OLDPWD", prevdir, VEXPORT);
|
||||
setvar("PWD", curdir, VEXPORT | VTEXTFIXED);
|
||||
setvar("OLDPWD", prevdir, VEXPORT | VTEXTFIXED);
|
||||
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
@@ -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
@@ -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];
|
||||
|
||||
Loaded 100 of 13447 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user