Merge from head

This commit is contained in:
Simon J. Gerraty
2013-09-05 20:18:59 +00:00
11559 changed files with 2455420 additions and 612210 deletions
+5 -2
View File
@@ -28,6 +28,7 @@ MAC Framework rwatson Pre-commit review requested.
MAC Modules rwatson Pre-commit review requested. MAC Modules rwatson Pre-commit review requested.
contrib/openbsm rwatson Pre-commit review requested. contrib/openbsm rwatson Pre-commit review requested.
sys/security/audit rwatson Pre-commit review requested. sys/security/audit rwatson Pre-commit review requested.
ath(4) adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
ahc(4) gibbs Pre-commit review requested. ahc(4) gibbs Pre-commit review requested.
ahd(4) gibbs Pre-commit review requested. ahd(4) gibbs Pre-commit review requested.
PC Card imp Pre-commit review requested. PC Card imp Pre-commit review requested.
@@ -63,8 +64,7 @@ procfs des Pre-commit review requested.
linprocfs des Pre-commit review requested. linprocfs des Pre-commit review requested.
lpr gad Pre-commit review requested, particularly for lpr gad Pre-commit review requested, particularly for
lpd/recvjob.c and lpd/printjob.c. lpd/recvjob.c and lpd/printjob.c.
newsyslog(8) gad Heads-up appreciated. I'm going thru the PR's for it. net80211 adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org
cvs peter Heads-up appreciated, try not to break it.
nvi peter Try not to break it. nvi peter Try not to break it.
libz peter Try not to break it. libz peter Try not to break it.
groff ru Recommends pre-commit review. groff ru Recommends pre-commit review.
@@ -128,3 +128,6 @@ sysdoc trhodes Pre-commit review preferred.
sh(1) jilles Pre-commit review requested. This also applies sh(1) jilles Pre-commit review requested. This also applies
to kill(1), printf(1) and test(1) which are to kill(1), printf(1) and test(1) which are
compiled in as builtins. compiled in as builtins.
nvme(4) jimharris Pre-commit review requested.
nvd(4) jimharris Pre-commit review requested.
nvmecontrol(8) jimharris Pre-commit review requested.
+69 -29
View File
@@ -32,6 +32,12 @@
# targets - Print a list of supported TARGET/TARGET_ARCH pairs # targets - Print a list of supported TARGET/TARGET_ARCH pairs
# for world and kernel targets. # for world and kernel targets.
# toolchains - Build a toolchain for all world and kernel targets. # toolchains - Build a toolchain for all world and kernel targets.
#
# "quick" way to test all kernel builds:
# _jflag=`sysctl -n hw.ncpu`
# _jflag=$(($_jflag * 2))
# [ $_jflag -gt 12 ] && _jflag=12
# make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
# #
# This makefile is simple by design. The FreeBSD make automatically reads # This makefile is simple by design. The FreeBSD make automatically reads
# the /usr/share/mk/sys.mk unless the -m argument is specified on the # the /usr/share/mk/sys.mk unless the -m argument is specified on the
@@ -65,8 +71,8 @@
# 5. `reboot' (in single user mode: boot -s from the loader prompt). # 5. `reboot' (in single user mode: boot -s from the loader prompt).
# 6. `mergemaster -p' # 6. `mergemaster -p'
# 7. `make installworld' # 7. `make installworld'
# 8. `make delete-old' # 8. `mergemaster' (you may wish to use -i, along with -U or -F).
# 9. `mergemaster' (you may wish to use -i, along with -U or -F). # 9. `make delete-old'
# 10. `reboot' # 10. `reboot'
# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) # 11. `make delete-old-libs' (in case no 3rd party program uses them anymore)
# #
@@ -124,11 +130,34 @@ _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\ .error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
(in make.conf(5)) or command-line variable. (in make.conf(5)) or command-line variable.
.endif .endif
MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
BINMAKE= \ # We often need to use the tree's version of make to build it.
`if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \ # Choices add to complexity though.
# We cannot blindly use a make which may not be the one we want
# so be exlicit - until all choice is removed.
.if !defined(WITHOUT_BMAKE)
WANT_MAKE= bmake
.else
WANT_MAKE= fmake
.endif
MYMAKE= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
.if defined(.PARSEDIR)
HAVE_MAKE= bmake
.else
HAVE_MAKE= fmake
.endif
.if exists(${MYMAKE})
SUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
.elif ${WANT_MAKE} != ${HAVE_MAKE} || ${WANT_MAKE} != "bmake"
# It may not exist yet but we may cause it to.
# In the case of fmake, upgrade_checks may cause a newer version to be built.
SUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
-m ${.CURDIR}/share/mk -m ${.CURDIR}/share/mk
_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} .else
SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
.endif
_MAKE= PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
# Guess machine architecture from machine type, and vice versa. # Guess machine architecture from machine type, and vice versa.
.if !defined(TARGET_ARCH) && defined(TARGET) .if !defined(TARGET_ARCH) && defined(TARGET)
@@ -209,6 +238,13 @@ cleanworld:
# Handle the user-driven targets, using the source relative mk files. # Handle the user-driven targets, using the source relative mk files.
# #
.if empty(.MAKEFLAGS:M-n)
# skip this for -n to avoid changing previous behavior of
# 'make -n buildworld' etc.
${TGTS}: .MAKE
tinderbox toolchains kernel-toolchains: .MAKE
.endif
${TGTS}: ${TGTS}:
${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET} ${_+_}@cd ${.CURDIR}; ${_MAKE} ${.TARGET}
@@ -279,11 +315,13 @@ kernel: buildkernel installkernel
# Perform a few tests to determine if the installed tools are adequate # Perform a few tests to determine if the installed tools are adequate
# for building the world. # for building the world.
# #
# Note: if we ever need to care about the version of bmake, simply testing
# MAKE_VERSION against a required version should suffice.
#
upgrade_checks: upgrade_checks:
.if !defined(.PARSEDIR) .if ${HAVE_MAKE} != ${WANT_MAKE}
.if defined(WITH_BMAKE) @(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
(cd ${.CURDIR} && ${MAKE} bmake) .elif ${WANT_MAKE} == "fmake"
.else
@if ! (cd ${.CURDIR}/tools/build/make_check && \ @if ! (cd ${.CURDIR}/tools/build/make_check && \
PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \ PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \ PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
@@ -291,14 +329,13 @@ upgrade_checks:
(cd ${.CURDIR} && ${MAKE} make); \ (cd ${.CURDIR} && ${MAKE} make); \
fi fi
.endif .endif
.endif
# #
# Upgrade make(1) to the current version using the installed # Upgrade make(1) to the current version using the installed
# headers, libraries and tools. Also, allow the location of # headers, libraries and tools. Also, allow the location of
# the system bsdmake-like utility to be overridden. # the system bsdmake-like utility to be overridden.
# #
MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \ MMAKEENV= MAKEOBJDIRPREFIX=${MYMAKE:H} \
DESTDIR= \ DESTDIR= \
INSTALL="sh ${.CURDIR}/tools/install.sh" INSTALL="sh ${.CURDIR}/tools/install.sh"
MMAKE= ${MMAKEENV} ${MAKE} \ MMAKE= ${MMAKEENV} ${MAKE} \
@@ -312,19 +349,21 @@ make bmake: .PHONY
@echo ">>> Building an up-to-date make(1)" @echo ">>> Building an up-to-date make(1)"
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \ ${_+_}@cd ${.CURDIR}/usr.bin/${.TARGET}; \
${MMAKE} obj && \ ${MMAKE} obj DESTDIR= && \
${MMAKE} depend && \ ${MMAKE} depend DESTDIR= && \
${MMAKE} all && \ ${MMAKE} all DESTDIR= && \
${MMAKE} install DESTDIR=${MAKEPATH} BINDIR= ${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR= PROGNAME=${MYMAKE:T}
tinderbox toolchains kernel-toolchains: upgrade_checks
tinderbox: tinderbox:
@cd ${.CURDIR} && ${MAKE} DOING_TINDERBOX=YES universe @cd ${.CURDIR} && ${SUB_MAKE} DOING_TINDERBOX=YES universe
toolchains: toolchains:
@cd ${.CURDIR} && ${MAKE} UNIVERSE_TARGET=toolchain universe @cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=toolchain universe
kernel-toolchains: kernel-toolchains:
@cd ${.CURDIR} && ${MAKE} UNIVERSE_TARGET=kernel-toolchain universe @cd ${.CURDIR} && ${SUB_MAKE} UNIVERSE_TARGET=kernel-toolchain universe
# #
# universe # universe
@@ -365,7 +404,8 @@ MAKEFAIL=tee -a ${FAILFILE}
MAKEFAIL=cat MAKEFAIL=cat
.endif .endif
universe: universe_prologue upgrade_checks universe_prologue: upgrade_checks
universe: universe_prologue
universe_prologue: universe_prologue:
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@echo ">>> make universe started on ${STARTTIME}" @echo ">>> make universe started on ${STARTTIME}"
@@ -375,17 +415,17 @@ universe_prologue:
.endif .endif
.for target in ${TARGETS} .for target in ${TARGETS}
universe: universe_${target} universe: universe_${target}
.ORDER: universe_prologue upgrade_checks universe_${target}_prologue universe_${target} universe_epilogue universe_epilogue: universe_${target}
universe_${target}: universe_${target}_prologue universe_${target}: universe_${target}_prologue
universe_${target}_prologue: universe_${target}_prologue: universe_prologue
@echo ">> ${target} started on `LC_ALL=C date`" @echo ">> ${target} started on `LC_ALL=C date`"
.if !defined(MAKE_JUST_KERNELS) .if !defined(MAKE_JUST_KERNELS)
.for target_arch in ${TARGET_ARCHES_${target}} .for target_arch in ${TARGET_ARCHES_${target}}
universe_${target}: universe_${target}_${target_arch} universe_${target}: universe_${target}_${target_arch}
universe_${target}_${target_arch}: universe_${target}_prologue universe_${target}_${target_arch}: universe_${target}_prologue .MAKE
@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`" @echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
${MAKE} ${JFLAG} ${UNIVERSE_TARGET} \ ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
TARGET=${target} \ TARGET=${target} \
TARGET_ARCH=${target_arch} \ TARGET_ARCH=${target_arch} \
> _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \ > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
@@ -403,14 +443,14 @@ universe_${target}_kernels: universe_${target}_${target_arch}
.endfor .endfor
.endif .endif
universe_${target}: universe_${target}_kernels universe_${target}: universe_${target}_kernels
universe_${target}_kernels: universe_${target}_prologue universe_${target}_kernels: universe_${target}_prologue .MAKE
.if exists(${KERNSRCDIR}/${target}/conf/NOTES) .if exists(${KERNSRCDIR}/${target}/conf/NOTES)
@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \ @(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \ ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
(echo "${target} 'make LINT' failed," \ (echo "${target} 'make LINT' failed," \
"check _.${target}.makeLINT for details"| ${MAKEFAIL})) "check _.${target}.makeLINT for details"| ${MAKEFAIL}))
.endif .endif
@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} TARGET=${target} \ @cd ${.CURDIR} && ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
universe_kernels universe_kernels
.endif .endif
@echo ">> ${target} completed on `LC_ALL=C date`" @echo ">> ${target} completed on `LC_ALL=C date`"
@@ -431,9 +471,9 @@ TARGET_ARCH_${kernel}!= cd ${KERNSRCDIR}/${TARGET}/conf && \
.error "Target architecture for ${TARGET}/conf/${kernel} unknown. config(8) likely too old." .error "Target architecture for ${TARGET}/conf/${kernel} unknown. config(8) likely too old."
.endif .endif
universe_kernconfs: universe_kernconf_${TARGET}_${kernel} universe_kernconfs: universe_kernconf_${TARGET}_${kernel}
universe_kernconf_${TARGET}_${kernel}: universe_kernconf_${TARGET}_${kernel}: .MAKE
@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
${MAKE} ${JFLAG} buildkernel \ ${SUB_MAKE} ${JFLAG} buildkernel \
TARGET=${TARGET} \ TARGET=${TARGET} \
TARGET_ARCH=${TARGET_ARCH_${kernel}} \ TARGET_ARCH=${TARGET_ARCH_${kernel}} \
KERNCONF=${kernel} \ KERNCONF=${kernel} \
+240 -166
View File
@@ -35,19 +35,12 @@
# buildworld - rebuild *everything*, including glue to help do upgrades # buildworld - rebuild *everything*, including glue to help do upgrades
# installworld- install everything built by "buildworld" # installworld- install everything built by "buildworld"
# doxygen - build API documentation of the kernel # doxygen - build API documentation of the kernel
# update - convenient way to update your source tree (eg: cvsup/cvs) # update - convenient way to update your source tree (eg: svn/svnup)
# #
# Standard targets (not defined here) are documented in the makefiles in # Standard targets (not defined here) are documented in the makefiles in
# /usr/share/mk. These include: # /usr/share/mk. These include:
# obj depend all install clean cleandepend cleanobj # obj depend all install clean cleandepend cleanobj
# You are supposed to define both of these when calling Makefile.inc1
# directly. However, some old scripts don't. Cope for the moment, but
# issue a new warning for a transition period.
.if defined(TARGET) && !defined(TARGET_ARCH)
.warning "You must pass both TARGET and TARGET_ARCH to Makefile.inc1. Setting TARGET_ARCH=${TARGET}."
TARGET_ARCH=${TARGET}
.endif
.if !defined(TARGET) || !defined(TARGET_ARCH) .if !defined(TARGET) || !defined(TARGET_ARCH)
.error "Both TARGET and TARGET_ARCH must be defined." .error "Both TARGET and TARGET_ARCH must be defined."
.endif .endif
@@ -65,6 +58,9 @@ TARGET_ARCH=${TARGET}
# use that new version. And the new (dynamically-linked) /bin/sh # use that new version. And the new (dynamically-linked) /bin/sh
# will expect to find appropriate libraries in /lib and /libexec. # will expect to find appropriate libraries in /lib and /libexec.
# #
.if defined(SUBDIR_OVERRIDE)
SUBDIR= ${SUBDIR_OVERRIDE}
.else
SUBDIR= share/info lib libexec SUBDIR= share/info lib libexec
SUBDIR+=bin SUBDIR+=bin
.if ${MK_GAMES} != "no" .if ${MK_GAMES} != "no"
@@ -91,7 +87,6 @@ SUBDIR+=sys usr.bin usr.sbin
.if ${MK_OFED} != "no" .if ${MK_OFED} != "no"
SUBDIR+=contrib/ofed SUBDIR+=contrib/ofed
.endif .endif
# #
# We must do etc/ last for install/distribute to work. # We must do etc/ last for install/distribute to work.
# #
@@ -104,9 +99,6 @@ SUBDIR+=etc
SUBDIR+= ${_DIR} SUBDIR+= ${_DIR}
.endif .endif
.endfor .endfor
.if defined(SUBDIR_OVERRIDE)
SUBDIR= ${SUBDIR_OVERRIDE}
.endif .endif
.if defined(NOCLEAN) .if defined(NOCLEAN)
@@ -122,15 +114,8 @@ LOCAL_TOOL_DIRS?=
BUILDENV_SHELL?=/bin/sh BUILDENV_SHELL?=/bin/sh
CVS?= cvs SVN?= /usr/local/bin/svn
CVSFLAGS?= -A -P -d -I!
SVN?= svn
SVNFLAGS?= -r HEAD SVNFLAGS?= -r HEAD
SUP?= /usr/bin/csup
SUPFLAGS?= -g -L 2
.if defined(SUPHOST)
SUPFLAGS+= -h ${SUPHOST}
.endif
MAKEOBJDIRPREFIX?= /usr/obj MAKEOBJDIRPREFIX?= /usr/obj
.if !defined(OSRELDATE) .if !defined(OSRELDATE)
@@ -252,7 +237,6 @@ BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
DESTDIR= \ DESTDIR= \
BOOTSTRAPPING=${OSRELDATE} \ BOOTSTRAPPING=${OSRELDATE} \
SSP_CFLAGS= \ SSP_CFLAGS= \
-DWITHOUT_META_MODE \
-DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \ -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \
-DNO_PIC -DNO_PROFILE -DNO_SHARED \ -DNO_PIC -DNO_PROFILE -DNO_SHARED \
-DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
@@ -264,14 +248,12 @@ TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
DESTDIR= \ DESTDIR= \
BOOTSTRAPPING=${OSRELDATE} \ BOOTSTRAPPING=${OSRELDATE} \
SSP_CFLAGS= \ SSP_CFLAGS= \
-DWITHOUT_META_MODE \
-DNO_LINT \ -DNO_LINT \
-DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD
# cross-tools stage # cross-tools stage
XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \ XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
-DWITHOUT_META_MODE \
-DWITHOUT_GDB -DWITHOUT_GDB
# world stage # world stage
@@ -281,18 +263,77 @@ WMAKEENV= ${CROSSENV} \
VERSION="${VERSION}" \ VERSION="${VERSION}" \
INSTALL="sh ${.CURDIR}/tools/install.sh" \ INSTALL="sh ${.CURDIR}/tools/install.sh" \
PATH=${TMPPATH} PATH=${TMPPATH}
# make hierarchy
HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
.if defined(NO_ROOT)
HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
.endif
.if ${MK_CDDL} == "no" .if ${MK_CDDL} == "no"
WMAKEENV+= NO_CTF=1 WMAKEENV+= NO_CTF=1
.endif .endif
.if ${CC:T:Mgcc} == "gcc"
.if defined(CROSS_TOOLCHAIN_PREFIX)
CROSS_COMPILER_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
.endif
XCOMPILERS= CC CXX CPP
.for COMPILER in ${XCOMPILERS}
.if defined(CROSS_COMPILER_PREFIX)
X${COMPILER}?= ${CROSS_COMPILER_PREFIX}${${COMPILER}}
.else
X${COMPILER}?= ${${COMPILER}}
.endif
.endfor
XBINUTILS= AS AR LD NM OBJDUMP RANLIB STRINGS
.for BINUTIL in ${XBINUTILS}
.if defined(CROSS_BINUTILS_PREFIX)
X${BINUTIL}?= ${CROSS_BINUTILS_PREFIX}${${BINUTIL}}
.else
X${BINUTIL}?= ${${BINUTIL}}
.endif
.endfor
WMAKEENV+= CC="${XCC} ${XFLAGS}" CXX="${XCXX} ${XFLAGS}" \
CPP="${XCPP} ${XFLAGS}" \
AS="${XAS}" AR="${XAR}" LD="${XLD}" NM=${XNM} \
OBJDUMP=${XOBJDUMP} RANLIB=${XRANLIB} STRINGS=${XSTRINGS}
.if ${XCC:T:Mgcc} == "gcc"
WMAKE_COMPILER_TYPE= gcc WMAKE_COMPILER_TYPE= gcc
.elif ${CC:T:Mclang} == "clang" .elif ${XCC:T:Mclang} == "clang"
WMAKE_COMPILER_TYPE= clang WMAKE_COMPILER_TYPE= clang
.elif ${MK_CLANG_IS_CC} == "no" .elif ${MK_CLANG_IS_CC} == "no"
WMAKE_COMPILER_TYPE= gcc WMAKE_COMPILER_TYPE= gcc
.else .else
WMAKE_COMPILER_TYPE= clang WMAKE_COMPILER_TYPE= clang
.endif .endif
IMAKE_COMPILER_TYPE= COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
.if ${XCC:M/*}
XFLAGS= --sysroot=${WORLDTMP}
.if defined(CROSS_BINUTILS_PREFIX)
# In the case of xdev-build tools, CROSS_BINUTILS_PREFIX won't be a
# directory, but the compiler will look in the right place for it's
# tools so we don't need to tell it where to look.
.if exists(${CROSS_BINUTILS_PREFIX})
XFLAGS+= -B${CROSS_BINUTILS_PREFIX}
.endif
.else
XFLAGS+= -B${WORLDTMP}/usr/bin
.endif
.if ${TARGET_ARCH} != ${MACHINE_ARCH} && ${WMAKE_COMPILER_TYPE} == "clang"
.if (${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "armv6") && \
${MK_ARM_EABI} != "no"
TARGET_ABI= gnueabi
.else
TARGET_ABI= unknown
.endif
TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd10.0
XFLAGS+= -target ${TARGET_TRIPLE}
.endif
.endif
WMAKEENV+= COMPILER_TYPE=${WMAKE_COMPILER_TYPE} WMAKEENV+= COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP} WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
@@ -328,6 +369,9 @@ LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
-isystem ${LIB32TMP}/usr/include/ \ -isystem ${LIB32TMP}/usr/include/ \
-L${LIB32TMP}/usr/lib32 \ -L${LIB32TMP}/usr/lib32 \
-B${LIB32TMP}/usr/lib32 -B${LIB32TMP}/usr/lib32
.if ${XCC:M/*}
LIB32FLAGS+= --sysroot=${WORLDTMP}
.endif
# Yes, the flags are redundant. # Yes, the flags are redundant.
LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \ LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
@@ -340,8 +384,8 @@ LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
SHLIBDIR=/usr/lib32 \ SHLIBDIR=/usr/lib32 \
COMPILER_TYPE=${WMAKE_COMPILER_TYPE} COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
LIB32WMAKEFLAGS+= \ LIB32WMAKEFLAGS+= \
CC="${CC} ${LIB32FLAGS}" \ CC="${XCC} ${LIB32FLAGS}" \
CXX="${CXX} ${LIB32FLAGS}" \ CXX="${XCXX} ${LIB32FLAGS}" \
DESTDIR=${LIB32TMP} \ DESTDIR=${LIB32TMP} \
-DCOMPAT_32BIT \ -DCOMPAT_32BIT \
-DLIBRARIES_ONLY \ -DLIBRARIES_ONLY \
@@ -357,7 +401,7 @@ LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS \
IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*} IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*}
IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \ IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
${IMAKE_INSTALL} ${IMAKE_MTREE} ${IMAKE_INSTALL} ${IMAKE_MTREE} ${IMAKE_COMPILER_TYPE}
.if empty(.MAKEFLAGS:M-n) .if empty(.MAKEFLAGS:M-n)
IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \ IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
LD_LIBRARY_PATH=${INSTALLTMP} \ LD_LIBRARY_PATH=${INSTALLTMP} \
@@ -370,11 +414,12 @@ IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
INSTALLFLAGS+= -N ${.CURDIR}/etc INSTALLFLAGS+= -N ${.CURDIR}/etc
MTREEFLAGS+= -N ${.CURDIR}/etc MTREEFLAGS+= -N ${.CURDIR}/etc
.endif .endif
_INSTALL_DDIR= ${DESTDIR}/${DISTDIR}
INSTALL_DDIR= ${_INSTALL_DDIR:S://:/:g:C:/$::}
.if defined(NO_ROOT) .if defined(NO_ROOT)
METALOG?= ${DESTDIR}/${DISTDIR}/METALOG METALOG?= ${DESTDIR}/${DISTDIR}/METALOG
IMAKE+= -DNO_ROOT METALOG=${METALOG} IMAKE+= -DNO_ROOT METALOG=${METALOG}
INSTALL_DDIR= ${DESTDIR}/${DISTDIR} INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR}
INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR:S://:/:g:C:/$::}
MTREEFLAGS+= -W MTREEFLAGS+= -W
.endif .endif
.if defined(DB_FROM_SRC) || defined(NO_ROOT) .if defined(DB_FROM_SRC) || defined(NO_ROOT)
@@ -384,7 +429,7 @@ IMAKE_MTREE= MTREE_CMD="nmtree ${MTREEFLAGS}"
# kernel stage # kernel stage
KMAKEENV= ${WMAKEENV} KMAKEENV= ${WMAKEENV}
KMAKE= ${KMAKEENV} ${MAKE} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME} KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME}
# #
# buildworld # buildworld
@@ -432,6 +477,13 @@ _worldtmp:
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
-p ${WORLDTMP}/usr/include >/dev/null -p ${WORLDTMP}/usr/include >/dev/null
ln -sf ${.CURDIR}/sys ${WORLDTMP} ln -sf ${.CURDIR}/sys ${WORLDTMP}
.if ${MK_DEBUG_FILES} != "no"
# We could instead disable debug files for these build stages
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
-p ${WORLDTMP}/legacy/usr/lib >/dev/null
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
-p ${WORLDTMP}/usr/lib >/dev/null
.endif
.if ${MK_BIND_LIBS} != "no" .if ${MK_BIND_LIBS} != "no"
mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \ mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
-p ${WORLDTMP}/usr/include >/dev/null -p ${WORLDTMP}/usr/include >/dev/null
@@ -517,6 +569,10 @@ build32:
-p ${LIB32TMP}/usr >/dev/null -p ${LIB32TMP}/usr >/dev/null
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
-p ${LIB32TMP}/usr/include >/dev/null -p ${LIB32TMP}/usr/include >/dev/null
.if ${MK_DEBUG_FILES} != "no"
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
-p ${LIB32TMP}/usr/lib >/dev/null
.endif
mkdir -p ${WORLDTMP} mkdir -p ${WORLDTMP}
ln -sf ${.CURDIR}/sys ${WORLDTMP} ln -sf ${.CURDIR}/sys ${WORLDTMP}
.for _t in obj includes .for _t in obj includes
@@ -620,6 +676,7 @@ kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries}
# Checks to be sure system is ready for installworld/installkernel. # Checks to be sure system is ready for installworld/installkernel.
# #
installcheck: installcheck:
installcheck_UGID:
# #
# Require DESTDIR to be set if installing for a different architecture or # Require DESTDIR to be set if installing for a different architecture or
@@ -651,7 +708,6 @@ CHECK_GIDS+= smmsp
CHECK_UIDS+= proxy CHECK_UIDS+= proxy
CHECK_GIDS+= proxy authpf CHECK_GIDS+= proxy authpf
.endif .endif
installcheck: installcheck_UGID
installcheck_UGID: installcheck_UGID:
.for uid in ${CHECK_UIDS} .for uid in ${CHECK_UIDS}
@if ! `id -u ${uid} >/dev/null 2>&1`; then \ @if ! `id -u ${uid} >/dev/null 2>&1`; then \
@@ -707,7 +763,7 @@ EXTRA_DISTRIBUTIONS+= lib32
MTREE_MAGIC?= mtree 2.0 MTREE_MAGIC?= mtree 2.0
distributeworld installworld: installcheck distributeworld installworld: installcheck installcheck_UGID
mkdir -p ${INSTALLTMP} mkdir -p ${INSTALLTMP}
progs=$$(for prog in ${ITOOLS}; do \ progs=$$(for prog in ${ITOOLS}; do \
if progpath=`which $$prog`; then \ if progpath=`which $$prog`; then \
@@ -741,6 +797,10 @@ distributeworld installworld: installcheck
-p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
-p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
.if ${MK_DEBUG_FILES} != "no"
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
-p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
.endif
.if defined(NO_ROOT) .if defined(NO_ROOT)
${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \ ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \
sed -e 's#^\./#./${dist}/#' >> ${METALOG} sed -e 's#^\./#./${dist}/#' >> ${METALOG}
@@ -754,13 +814,13 @@ distributeworld installworld: installcheck
cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \ METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \ DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
LOCAL_MTREE=${LOCAL_MTREE} distrib-dirs LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
.endif .endif
${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \ ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \
${IMAKEENV} rm -rf ${INSTALLTMP} ${IMAKEENV} rm -rf ${INSTALLTMP}
.if make(distributeworld) .if make(distributeworld)
.for dist in ${EXTRA_DISTRIBUTIONS} .for dist in ${EXTRA_DISTRIBUTIONS}
find ${DESTDIR}/${DISTDIR}/${dist} -empty -delete find ${DESTDIR}/${DISTDIR}/${dist} -mindepth 1 -empty -delete
.endfor .endfor
.if defined(NO_ROOT) .if defined(NO_ROOT)
.for dist in base ${EXTRA_DISTRIBUTIONS} .for dist in base ${EXTRA_DISTRIBUTIONS}
@@ -773,6 +833,18 @@ distributeworld installworld: installcheck
awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \ awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
${DESTDIR}/${DISTDIR}/${dist}.meta ${DESTDIR}/${DISTDIR}/${dist}.meta
.endfor .endfor
.if ${MK_DEBUG_FILES} != "no"
. for dist in base ${EXTRA_DISTRIBUTIONS}
@# For each file that exists in this dist, print the corresponding
@# line from the METALOG. This relies on the fact that
@# a line containing only the filename will sort immediatly before
@# the relevant mtree line.
cd ${DESTDIR}/${DISTDIR}; \
find ./${dist}/usr/lib/debug | sort -u ${METALOG} - | \
awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \
${DESTDIR}/${DISTDIR}/${dist}.debug.meta
. endfor
.endif
.endif .endif
.endif .endif
@@ -781,13 +853,29 @@ packageworld:
.if defined(NO_ROOT) .if defined(NO_ROOT)
${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \ tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
--exclude usr/lib/debug \
@${DESTDIR}/${DISTDIR}/${dist}.meta @${DESTDIR}/${DISTDIR}/${dist}.meta
.else .else
${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz . tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \
--exclude usr/lib/debug .
.endif .endif
.endfor .endfor
.if ${MK_DEBUG_FILES} != "no"
. for dist in base ${EXTRA_DISTRIBUTIONS}
. if defined(NO_ROOT)
${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.debug.txz \
@${DESTDIR}/${DISTDIR}/${dist}.debug.meta
. else
${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \
tar cvJfL ${DESTDIR}/${DISTDIR}/${dist}.debug.txz \
usr/lib/debug
. endif
. endfor
.endif
# #
# reinstall # reinstall
# #
@@ -800,7 +888,7 @@ reinstall:
@echo ">>> Making hierarchy" @echo ">>> Making hierarchy"
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \ ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \
LOCAL_MTREE=${LOCAL_MTREE} hierarchy LOCAL_MTREE=${LOCAL_MTREE:Q} hierarchy
@echo @echo
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@echo ">>> Installing everything" @echo ">>> Installing everything"
@@ -848,16 +936,11 @@ NO_KERNELOBJ= t
KERNCONF=${KERNFAST} KERNCONF=${KERNFAST}
.endif .endif
.endif .endif
.if !defined(KERNCONF) && defined(KERNEL)
KERNCONF= ${KERNEL}
KERNWARN=
.else
.if ${TARGET_ARCH} == "powerpc64" .if ${TARGET_ARCH} == "powerpc64"
KERNCONF?= GENERIC64 KERNCONF?= GENERIC64
.else .else
KERNCONF?= GENERIC KERNCONF?= GENERIC
.endif .endif
.endif
INSTKERNNAME?= kernel INSTKERNNAME?= kernel
KERNSRCDIR?= ${.CURDIR}/sys KERNSRCDIR?= ${.CURDIR}/sys
@@ -885,12 +968,6 @@ buildkernel:
.if empty(BUILDKERNELS) .if empty(BUILDKERNELS)
@echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \ @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \
false false
.endif
.if defined(KERNWARN)
@echo "--------------------------------------------------------------"
@echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF="
@echo "--------------------------------------------------------------"
@sleep 3
.endif .endif
@echo @echo
.for _kernel in ${BUILDKERNELS} .for _kernel in ${BUILDKERNELS}
@@ -980,26 +1057,53 @@ distributekernel distributekernel.debug:
.if empty(INSTALLKERNEL) .if empty(INSTALLKERNEL)
@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \ @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
false false
.endif
mkdir -p ${DESTDIR}/${DISTDIR}
.if defined(NO_ROOT)
echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.premeta
.endif .endif
cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \ cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
${CROSSENV} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \ ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
DESTDIR=${DESTDIR}/${DISTDIR}/kernel \ ${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
DESTDIR=${INSTALL_DDIR}/kernel \
${.TARGET:S/distributekernel/install/} ${.TARGET:S/distributekernel/install/}
.if defined(NO_ROOT)
sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
${DESTDIR}/${DISTDIR}/kernel.meta
.endif
.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//} .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
.if defined(NO_ROOT)
echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
.endif
cd ${KRNLOBJDIR}/${_kernel}; \ cd ${KRNLOBJDIR}/${_kernel}; \
${CROSSENV} PATH=${TMPPATH} ${MAKE} \ ${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
KERNEL=${INSTKERNNAME}.${_kernel} \ KERNEL=${INSTKERNNAME}.${_kernel} \
DESTDIR=${DESTDIR}/${DISTDIR}/kernel.${_kernel} \ DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
${.TARGET:S/distributekernel/install/} ${.TARGET:S/distributekernel/install/}
sed -e 's|^./kernel|.|' \
${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta > \
${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
.endfor .endfor
packagekernel: packagekernel:
.if defined(NO_ROOT)
cd ${DESTDIR}/${DISTDIR}/kernel; \
tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz \
@${DESTDIR}/${DISTDIR}/kernel.meta
.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz \
@${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
.endfor
.else
cd ${DESTDIR}/${DISTDIR}/kernel; \ cd ${DESTDIR}/${DISTDIR}/kernel; \
tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz . tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz .
.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//} .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz . tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz .
.endfor .endfor
.endif
# #
# doxygen # doxygen
@@ -1016,63 +1120,22 @@ doxygen:
# #
# update # update
# #
# Update the source tree(s), by running cvsup/cvs/svn to update to the # Update the source tree(s), by running svn/svnup to update to the
# latest copy. # latest copy.
# #
update: update:
.if defined(SUP_UPDATE) .if (defined(CVS_UPDATE) || defined(SUP_UPDATE)) && !defined(SVN_UPDATE)
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@echo ">>> Running ${SUP}" @echo "CVS_UPDATE and SUP_UPDATE are no longer supported."
@echo "Please see: https://wiki.freebsd.org/CvsIsDeprecated"
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" @exit 1
@echo "!! Update methods with ${SUP} are deprecated."
@echo "!! Please see http://www.freebsd.org/handbook/svn.html"
@echo "!! and convert your update method to SVN_UPDATE or"
@echo "!! freebsd-update(8)."
@echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!"
@sleep 5
.if defined(SUPFILE)
@${SUP} ${SUPFLAGS} ${SUPFILE}
.endif
.if defined(SUPFILE1)
@${SUP} ${SUPFLAGS} ${SUPFILE1}
.endif
.if defined(SUPFILE2)
@${SUP} ${SUPFLAGS} ${SUPFILE2}
.endif
.if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE)
@${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
.endif
.if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE)
@${SUP} ${SUPFLAGS} ${DOCSUPFILE}
.endif
.endif
.if defined(CVS_UPDATE)
@cd ${.CURDIR} ; \
if [ -d CVS ] ; then \
echo "--------------------------------------------------------------" ; \
echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \
echo "--------------------------------------------------------------" ; \
echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" ; \
echo "!! Update methods with CVS are deprecated." ; \
echo "!! Please see http://www.freebsd.org/handbook/svn.html" ; \
echo "!! and convert your update method to SVN_UPDATE or" ; \
echo "!! freebsd-update(8)." ; \
echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" ; \
sleep 5 ; \
echo ${CVS} -R -q update ${CVSFLAGS} ; \
${CVS} -R -q update ${CVSFLAGS} ; \
fi
.endif .endif
.if defined(SVN_UPDATE) .if defined(SVN_UPDATE)
@cd ${.CURDIR} ; \ @echo "--------------------------------------------------------------"
if [ -d .svn ] ; then \ @echo ">>> Updating ${.CURDIR} using Subversion"
echo "--------------------------------------------------------------" ; \ @echo "--------------------------------------------------------------"
echo ">>> Updating ${.CURDIR} using Subversion" ; \ @(cd ${.CURDIR} && ${SVN} update ${SVNFLAGS})
echo "--------------------------------------------------------------" ; \
echo ${SVN} update ${SVNFLAGS} ; \
${SVN} update ${SVNFLAGS} ; \
fi
.endif .endif
# #
@@ -1096,11 +1159,11 @@ legacy:
.endif .endif
.for _tool in tools/build .for _tool in tools/build
${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \ ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
cd ${.CURDIR}/${_tool}; \ cd ${.CURDIR}/${_tool} && \
${MAKE} DIRPRFX=${_tool}/ obj; \ ${MAKE} DIRPRFX=${_tool}/ obj && \
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \ ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes && \
${MAKE} DIRPRFX=${_tool}/ depend; \ ${MAKE} DIRPRFX=${_tool}/ depend && \
${MAKE} DIRPRFX=${_tool}/ all; \ ${MAKE} DIRPRFX=${_tool}/ all && \
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
.endfor .endfor
@@ -1135,11 +1198,19 @@ _sed= usr.bin/sed
_lex= usr.bin/lex _lex= usr.bin/lex
.endif .endif
.if ${BOOTSTRAPPING} < 1000002
_m4= usr.bin/m4
.endif
.if ${BOOTSTRAPPING} < 1000013 .if ${BOOTSTRAPPING} < 1000013
_yacc= lib/liby \ _yacc= lib/liby \
usr.bin/yacc usr.bin/yacc
.endif .endif
.if ${BOOTSTRAPPING} < 1000014
_crunch= usr.sbin/crunch
.endif
.if ${BOOTSTRAPPING} < 1000026 .if ${BOOTSTRAPPING} < 1000026
_nmtree= lib/libnetbsd \ _nmtree= lib/libnetbsd \
usr.sbin/nmtree usr.sbin/nmtree
@@ -1167,8 +1238,8 @@ _clang_tblgen= \
# dtrace tools are required for older bootstrap env and cross-build # dtrace tools are required for older bootstrap env and cross-build
.if ${MK_CDDL} != "no" && \ .if ${MK_CDDL} != "no" && \
((${BOOTSTRAPPING} < 800038 && \ ((${BOOTSTRAPPING} < 1000034 && \
!(${BOOTSTRAPPING} >= 700112 && ${BOOTSTRAPPING} < 799999)) \ !(${BOOTSTRAPPING} >= 901505 && ${BOOTSTRAPPING} < 999999)) \
|| (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH})) || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH}))
_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \ _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
@@ -1187,13 +1258,14 @@ _kerberos5_bootstrap_tools= \
kerberos5/lib/libroken \ kerberos5/lib/libroken \
kerberos5/lib/libvers \ kerberos5/lib/libvers \
kerberos5/tools/asn1_compile \ kerberos5/tools/asn1_compile \
kerberos5/tools/slc kerberos5/tools/slc \
usr.bin/compile_et
.endif .endif
# Please document (add comment) why something is in 'bootstrap-tools'. # Please document (add comment) why something is in 'bootstrap-tools'.
# Try to bound the building of the bootstrap-tool to just the # Try to bound the building of the bootstrap-tool to just the
# FreeBSD versions that need the tool built at this stage of the build. # FreeBSD versions that need the tool built at this stage of the build.
bootstrap-tools: bootstrap-tools: .MAKE
.for _tool in \ .for _tool in \
${_clang_tblgen} \ ${_clang_tblgen} \
${_kerberos5_bootstrap_tools} \ ${_kerberos5_bootstrap_tools} \
@@ -1211,17 +1283,19 @@ bootstrap-tools:
usr.bin/rpcgen \ usr.bin/rpcgen \
${_sed} \ ${_sed} \
${_yacc} \ ${_yacc} \
${_m4} \
${_lex} \ ${_lex} \
lib/libmd \ lib/libmd \
usr.bin/xinstall \ usr.bin/xinstall \
${_gensnmptree} \ ${_gensnmptree} \
usr.sbin/config \ usr.sbin/config \
${_crunch} \
${_nmtree} ${_nmtree}
${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \ ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
cd ${.CURDIR}/${_tool}; \ cd ${.CURDIR}/${_tool} && \
${MAKE} DIRPRFX=${_tool}/ obj; \ ${MAKE} DIRPRFX=${_tool}/ obj && \
${MAKE} DIRPRFX=${_tool}/ depend; \ ${MAKE} DIRPRFX=${_tool}/ depend && \
${MAKE} DIRPRFX=${_tool}/ all; \ ${MAKE} DIRPRFX=${_tool}/ all && \
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
.endfor .endfor
@@ -1244,7 +1318,7 @@ _gcc_tools= gnu/usr.bin/cc/cc_tools
_rescue= rescue/rescue _rescue= rescue/rescue
.endif .endif
build-tools: build-tools: .MAKE
.for _tool in \ .for _tool in \
bin/csh \ bin/csh \
bin/sh \ bin/sh \
@@ -1257,18 +1331,19 @@ build-tools:
usr.bin/awk \ usr.bin/awk \
lib/libmagic \ lib/libmagic \
usr.bin/mkesdb_static \ usr.bin/mkesdb_static \
usr.bin/mkcsmapper_static usr.bin/mkcsmapper_static \
usr.bin/vi/catalog
${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \ ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
cd ${.CURDIR}/${_tool}; \ cd ${.CURDIR}/${_tool} && \
${MAKE} DIRPRFX=${_tool}/ obj; \ ${MAKE} DIRPRFX=${_tool}/ obj && \
${MAKE} DIRPRFX=${_tool}/ build-tools ${MAKE} DIRPRFX=${_tool}/ build-tools
.endfor .endfor
.for _tool in \ .for _tool in \
${_gcc_tools} ${_gcc_tools}
${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \ ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \
cd ${.CURDIR}/${_tool}; \ cd ${.CURDIR}/${_tool} && \
${MAKE} DIRPRFX=${_tool}/ obj; \ ${MAKE} DIRPRFX=${_tool}/ obj && \
${MAKE} DIRPRFX=${_tool}/ depend; \ ${MAKE} DIRPRFX=${_tool}/ depend && \
${MAKE} DIRPRFX=${_tool}/ all ${MAKE} DIRPRFX=${_tool}/ all
.endfor .endfor
@@ -1289,10 +1364,13 @@ _kgzip= usr.sbin/kgzip
.endif .endif
.endif .endif
.if ${MK_BINUTILS} != "no" .if ${XAS:M/*} == "" && ${MK_BINUTILS} != "no"
_binutils= gnu/usr.bin/binutils _binutils= gnu/usr.bin/binutils
.endif .endif
# If an full path to an external cross compiler is given, don't build
# a cross compiler.
.if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no"
.if ${MK_CLANG} != "no" && (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") .if ${MK_CLANG} != "no" && (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang")
_clang= usr.bin/clang _clang= usr.bin/clang
_clang_libs= lib/clang _clang_libs= lib/clang
@@ -1301,8 +1379,9 @@ _clang_libs= lib/clang
.if ${MK_GCC} != "no" && (${MK_CLANG_IS_CC} == "no" || ${TARGET} == "pc98") .if ${MK_GCC} != "no" && (${MK_CLANG_IS_CC} == "no" || ${TARGET} == "pc98")
_cc= gnu/usr.bin/cc _cc= gnu/usr.bin/cc
.endif .endif
.endif
cross-tools: cross-tools: .MAKE
.for _tool in \ .for _tool in \
${_clang_libs} \ ${_clang_libs} \
${_clang} \ ${_clang} \
@@ -1313,10 +1392,10 @@ cross-tools:
${_crunchide} \ ${_crunchide} \
${_kgzip} ${_kgzip}
${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \ ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
cd ${.CURDIR}/${_tool}; \ cd ${.CURDIR}/${_tool} && \
${MAKE} DIRPRFX=${_tool}/ obj; \ ${MAKE} DIRPRFX=${_tool}/ obj && \
${MAKE} DIRPRFX=${_tool}/ depend; \ ${MAKE} DIRPRFX=${_tool}/ depend && \
${MAKE} DIRPRFX=${_tool}/ all; \ ${MAKE} DIRPRFX=${_tool}/ all && \
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
.endfor .endfor
@@ -1324,12 +1403,7 @@ cross-tools:
# hierarchy - ensure that all the needed directories are present # hierarchy - ensure that all the needed directories are present
# #
hierarchy hier: hierarchy hier:
.if defined(NO_ROOT) cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} \
-DNO_ROOT METALOG=${METALOG} distrib-dirs
.else
cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} distrib-dirs
.endif
# #
# libraries - build all libraries, and install them under ${DESTDIR}. # libraries - build all libraries, and install them under ${DESTDIR}.
@@ -1338,12 +1412,12 @@ hierarchy hier:
# interdependencies (__L) are built automatically by the # interdependencies (__L) are built automatically by the
# ${.CURDIR}/tools/make_libdeps.sh script. # ${.CURDIR}/tools/make_libdeps.sh script.
# #
libraries: libraries: .MAKE
cd ${.CURDIR}; \ cd ${.CURDIR} && \
${MAKE} -f Makefile.inc1 _prereq_libs; \ ${MAKE} -f Makefile.inc1 _prereq_libs && \
${MAKE} -f Makefile.inc1 _startup_libs; \ ${MAKE} -f Makefile.inc1 _startup_libs && \
${MAKE} -f Makefile.inc1 _prebuild_libs; \ ${MAKE} -f Makefile.inc1 _prebuild_libs && \
${MAKE} -f Makefile.inc1 _generic_libs; ${MAKE} -f Makefile.inc1 _generic_libs
# #
# static libgcc.a prerequisite for shared libc # static libgcc.a prerequisite for shared libc
@@ -1386,7 +1460,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \
${_kerberos5_lib_libwind} \ ${_kerberos5_lib_libwind} \
${_lib_atf_libatf_c} \ ${_lib_atf_libatf_c} \
lib/libbz2 ${_libcom_err} lib/libcrypt \ lib/libbz2 ${_libcom_err} lib/libcrypt \
lib/libexpat \ lib/libelf lib/libexpat \
${_lib_libgssapi} ${_lib_libipx} \ ${_lib_libgssapi} ${_lib_libipx} \
lib/libkiconv lib/libkvm lib/liblzma lib/libmd \ lib/libkiconv lib/libkvm lib/liblzma lib/libmd \
lib/ncurses/ncurses lib/ncurses/ncursesw \ lib/ncurses/ncurses lib/ncurses/ncursesw \
@@ -1497,25 +1571,25 @@ lib/libradius__L: lib/libmd__L
.endif .endif
.for _lib in ${_prereq_libs} .for _lib in ${_prereq_libs}
${_lib}__PL: .PHONY ${_lib}__PL: .PHONY .MAKE
.if exists(${.CURDIR}/${_lib}) .if exists(${.CURDIR}/${_lib})
${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \ ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
cd ${.CURDIR}/${_lib}; \ cd ${.CURDIR}/${_lib} && \
${MAKE} DIRPRFX=${_lib}/ obj; \ ${MAKE} DIRPRFX=${_lib}/ obj && \
${MAKE} DIRPRFX=${_lib}/ depend; \ ${MAKE} DIRPRFX=${_lib}/ depend && \
${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \ ${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all && \
${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install ${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install
.endif .endif
.endfor .endfor
.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs} .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
${_lib}__L: .PHONY ${_lib}__L: .PHONY .MAKE
.if exists(${.CURDIR}/${_lib}) .if exists(${.CURDIR}/${_lib})
${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \ ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
cd ${.CURDIR}/${_lib}; \ cd ${.CURDIR}/${_lib} && \
${MAKE} DIRPRFX=${_lib}/ obj; \ ${MAKE} DIRPRFX=${_lib}/ obj && \
${MAKE} DIRPRFX=${_lib}/ depend; \ ${MAKE} DIRPRFX=${_lib}/ depend && \
${MAKE} DIRPRFX=${_lib}/ all; \ ${MAKE} DIRPRFX=${_lib}/ all && \
${MAKE} DIRPRFX=${_lib}/ install ${MAKE} DIRPRFX=${_lib}/ install
.endif .endif
.endfor .endfor
@@ -1523,12 +1597,12 @@ ${_lib}__L: .PHONY
# libpam is special: we need to build static PAM modules before # libpam is special: we need to build static PAM modules before
# static PAM library, and dynamic PAM library before dynamic PAM # static PAM library, and dynamic PAM library before dynamic PAM
# modules. # modules.
lib/libpam__L: .PHONY lib/libpam__L: .PHONY .MAKE
${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \ ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
cd ${.CURDIR}/lib/libpam; \ cd ${.CURDIR}/lib/libpam && \
${MAKE} DIRPRFX=lib/libpam/ obj; \ ${MAKE} DIRPRFX=lib/libpam/ obj && \
${MAKE} DIRPRFX=lib/libpam/ depend; \ ${MAKE} DIRPRFX=lib/libpam/ depend && \
${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \ ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all && \
${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
_prereq_libs: ${_prereq_libs:S/$/__PL/} _prereq_libs: ${_prereq_libs:S/$/__PL/}
@@ -1538,8 +1612,8 @@ _generic_libs: ${_generic_libs:S/$/__L/}
.for __target in all clean cleandepend cleandir depend includes obj .for __target in all clean cleandepend cleandir depend includes obj
.for entry in ${SUBDIR} .for entry in ${SUBDIR}
${entry}.${__target}__D: .PHONY ${entry}.${__target}__D: .PHONY .MAKE
${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \ ${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \ ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
edir=${entry}.${MACHINE_ARCH}; \ edir=${entry}.${MACHINE_ARCH}; \
cd ${.CURDIR}/$${edir}; \ cd ${.CURDIR}/$${edir}; \
@@ -1777,10 +1851,10 @@ _xb-bootstrap-tools:
.for _tool in \ .for _tool in \
${_clang_tblgen} ${_clang_tblgen}
${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \ ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
cd ${.CURDIR}/${_tool}; \ cd ${.CURDIR}/${_tool} && \
${CDMAKE} DIRPRFX=${_tool}/ obj; \ ${CDMAKE} DIRPRFX=${_tool}/ obj && \
${CDMAKE} DIRPRFX=${_tool}/ depend; \ ${CDMAKE} DIRPRFX=${_tool}/ depend && \
${CDMAKE} DIRPRFX=${_tool}/ all; \ ${CDMAKE} DIRPRFX=${_tool}/ all && \
${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
.endfor .endfor
@@ -1796,9 +1870,9 @@ _xb-cross-tools:
${_clang_libs} \ ${_clang_libs} \
${_clang} ${_clang}
${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \ ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \
cd ${.CURDIR}/${_tool}; \ cd ${.CURDIR}/${_tool} && \
${CDMAKE} DIRPRFX=${_tool}/ obj; \ ${CDMAKE} DIRPRFX=${_tool}/ obj && \
${CDMAKE} DIRPRFX=${_tool}/ depend; \ ${CDMAKE} DIRPRFX=${_tool}/ depend && \
${CDMAKE} DIRPRFX=${_tool}/ all ${CDMAKE} DIRPRFX=${_tool}/ all
.endfor .endfor
@@ -1848,4 +1922,4 @@ xdev xdev-build xdev-install:
@echo "*** Error: Both XDEV and XDEV_ARCH must be defined for \"${.TARGET}\" target" @echo "*** Error: Both XDEV and XDEV_ARCH must be defined for \"${.TARGET}\" target"
.endif .endif
.MAKE.MODE= normal buildkernel ${WMAKE_TGTS} ${.ALLTARGETS:M_*}: .MAKE
+93 -1
View File
@@ -38,7 +38,98 @@
# xargs -n1 | sort | uniq -d; # xargs -n1 | sort | uniq -d;
# done # done
# 20130903: gnupatch is no more
OLD_FILES+=usr/bin/gnupatch
OLD_FILES+=usr/share/man/man1/gnupatch.1.gz
# 20130829: bsdpatch is patch unconditionally
OLD_FILES+=usr/bin/bsdpatch
OLD_FILES+=usr/share/man/man1/bsdpatch.1.gz
# 20130822: bind 9.9.3-P2 import
OLD_LIBS+=usr/lib/liblwres.so.80
# 20130814: vm_page_busy(9)
OLD_FILES+=usr/share/man/man9/vm_page_flash.9.gz
OLD_FILES+=usr/share/man/man9/vm_page_io.9.gz
OLD_FILES+=usr/share/man/man9/vm_page_io_finish.9.gz
OLD_FILES+=usr/share/man/man9/vm_page_io_start.9.gz
OLD_FILES+=usr/share/man/man9/vm_page_wakeup.9.gz
# 20130710: libkvm version bump
OLD_LIBS+=lib/libkvm.so.5
OLD_LIBS+=usr/lib32/libkvm.so.5
# 20130623: dialog update from 1.1 to 1.2
OLD_LIBS+=usr/lib/libdialog.so.7
OLD_LIBS+=usr/lib32/libdialog.so.7
# 20130616: vfs_mount.9 removed
OLD_FILES+=usr/share/man/man9/vfs_mount.9.gz
# 20130614: remove CVS from base
OLD_FILES+=usr/bin/cvs
OLD_FILES+=usr/bin/cvsbug
OLD_FILES+=usr/share/doc/psd/28.cvs/paper.ascii.gz
OLD_DIRS+=usr/share/doc/psd/28.cvs
OLD_FILES+=usr/share/examples/cvs/contrib/README
OLD_FILES+=usr/share/examples/cvs/contrib/clmerge
OLD_FILES+=usr/share/examples/cvs/contrib/cln_hist
OLD_FILES+=usr/share/examples/cvs/contrib/commit_prep
OLD_FILES+=usr/share/examples/cvs/contrib/cvs2vendor
OLD_FILES+=usr/share/examples/cvs/contrib/cvs_acls
OLD_FILES+=usr/share/examples/cvs/contrib/cvscheck
OLD_FILES+=usr/share/examples/cvs/contrib/cvscheck.man
OLD_FILES+=usr/share/examples/cvs/contrib/cvshelp.man
OLD_FILES+=usr/share/examples/cvs/contrib/descend.man
OLD_FILES+=usr/share/examples/cvs/contrib/easy-import
OLD_FILES+=usr/share/examples/cvs/contrib/intro.doc
OLD_FILES+=usr/share/examples/cvs/contrib/log
OLD_FILES+=usr/share/examples/cvs/contrib/log_accum
OLD_FILES+=usr/share/examples/cvs/contrib/mfpipe
OLD_FILES+=usr/share/examples/cvs/contrib/rcs-to-cvs
OLD_FILES+=usr/share/examples/cvs/contrib/rcs2log
OLD_FILES+=usr/share/examples/cvs/contrib/rcslock
OLD_FILES+=usr/share/examples/cvs/contrib/sccs2rcs
OLD_DIRS+=usr/share/examples/cvs/contrib
OLD_DIRS+=usr/share/examples/cvs
OLD_FILES+=usr/share/info/cvs.info.gz
OLD_FILES+=usr/share/info/cvsclient.info.gz
OLD_FILES+=usr/share/man/man1/cvs.1.gz
OLD_FILES+=usr/share/man/man5/cvs.5.gz
OLD_FILES+=usr/share/man/man8/cvsbug.8.gz
# 20130607: WITH_DEBUG_FILES added
OLD_FILES+=lib/libufs.so.6.symbols
OLD_FILES+=usr/lib32/libufs.so.6.symbols
# 20130417: nfs fha moved from nfsserver to nfs
OLD_FILES+=usr/include/nfsserver/nfs_fha.h
# 20130411: new clang import which bumps version from 3.2 to 3.3.
OLD_FILES+=usr/include/clang/3.2/__wmmintrin_aes.h
OLD_FILES+=usr/include/clang/3.2/__wmmintrin_pclmul.h
OLD_FILES+=usr/include/clang/3.2/altivec.h
OLD_FILES+=usr/include/clang/3.2/ammintrin.h
OLD_FILES+=usr/include/clang/3.2/avx2intrin.h
OLD_FILES+=usr/include/clang/3.2/avxintrin.h
OLD_FILES+=usr/include/clang/3.2/bmi2intrin.h
OLD_FILES+=usr/include/clang/3.2/bmiintrin.h
OLD_FILES+=usr/include/clang/3.2/cpuid.h
OLD_FILES+=usr/include/clang/3.2/emmintrin.h
OLD_FILES+=usr/include/clang/3.2/f16cintrin.h
OLD_FILES+=usr/include/clang/3.2/fma4intrin.h
OLD_FILES+=usr/include/clang/3.2/fmaintrin.h
OLD_FILES+=usr/include/clang/3.2/immintrin.h
OLD_FILES+=usr/include/clang/3.2/lzcntintrin.h
OLD_FILES+=usr/include/clang/3.2/mm3dnow.h
OLD_FILES+=usr/include/clang/3.2/mm_malloc.h
OLD_FILES+=usr/include/clang/3.2/mmintrin.h
OLD_FILES+=usr/include/clang/3.2/module.map
OLD_FILES+=usr/include/clang/3.2/nmmintrin.h
OLD_FILES+=usr/include/clang/3.2/pmmintrin.h
OLD_FILES+=usr/include/clang/3.2/popcntintrin.h
OLD_FILES+=usr/include/clang/3.2/rtmintrin.h
OLD_FILES+=usr/include/clang/3.2/smmintrin.h
OLD_FILES+=usr/include/clang/3.2/tmmintrin.h
OLD_FILES+=usr/include/clang/3.2/wmmintrin.h
OLD_FILES+=usr/include/clang/3.2/x86intrin.h
OLD_FILES+=usr/include/clang/3.2/xmmintrin.h
OLD_FILES+=usr/include/clang/3.2/xopintrin.h
OLD_DIRS+=usr/include/clang/3.2
# 20130404: legacy ATA stack removed # 20130404: legacy ATA stack removed
OLD_FILES+=etc/periodic/daily/405.status-ata-raid
OLD_FILES+=rescue/atacontrol
OLD_FILES+=sbin/atacontrol OLD_FILES+=sbin/atacontrol
OLD_FILES+=usr/share/man/man8/atacontrol.8.gz OLD_FILES+=usr/share/man/man8/atacontrol.8.gz
OLD_FILES+=usr/share/man/man4/atapicam.4.gz OLD_FILES+=usr/share/man/man4/atapicam.4.gz
@@ -223,7 +314,9 @@ OLD_FILES+=usr/share/man/man1/yyfix.1.gz
# 20120505: new clang import installed a redundant internal header # 20120505: new clang import installed a redundant internal header
OLD_FILES+=usr/include/clang/3.1/stdalign.h OLD_FILES+=usr/include/clang/3.1/stdalign.h
# 20120428: MD2 removed from libmd # 20120428: MD2 removed from libmd
OLD_LIBS+=lib/libmd.so.5
OLD_FILES+=usr/include/md2.h OLD_FILES+=usr/include/md2.h
OLD_LIBS+=usr/lib32/libmd.so.5
OLD_FILES+=usr/share/man/man3/MD2Data.3.gz OLD_FILES+=usr/share/man/man3/MD2Data.3.gz
OLD_FILES+=usr/share/man/man3/MD2End.3.gz OLD_FILES+=usr/share/man/man3/MD2End.3.gz
OLD_FILES+=usr/share/man/man3/MD2File.3.gz OLD_FILES+=usr/share/man/man3/MD2File.3.gz
@@ -790,7 +883,6 @@ OLD_LIBS+=lib/libipx.so.4
OLD_LIBS+=lib/libkiconv.so.3 OLD_LIBS+=lib/libkiconv.so.3
OLD_LIBS+=lib/libkvm.so.4 OLD_LIBS+=lib/libkvm.so.4
OLD_LIBS+=lib/libmd.so.4 OLD_LIBS+=lib/libmd.so.4
OLD_LIBS+=lib/libmd.so.5
OLD_LIBS+=lib/libncurses.so.7 OLD_LIBS+=lib/libncurses.so.7
OLD_LIBS+=lib/libncursesw.so.7 OLD_LIBS+=lib/libncursesw.so.7
OLD_LIBS+=lib/libnvpair.so.1 OLD_LIBS+=lib/libnvpair.so.1
+194 -6
View File
@@ -11,6 +11,11 @@ handbook:
Items affecting the ports and packages system can be found in Items affecting the ports and packages system can be found in
/usr/ports/UPDATING. Please read that file before running portupgrade. /usr/ports/UPDATING. Please read that file before running portupgrade.
NOTE: FreeBSD has switched from gcc to clang. If you have trouble bootstrapping
from older versions of FreeBSD, try WITHOUT_CLANG to bootstrap to the tip of
head, and then rebuild without this option. The bootstrap process from
older version of current is a bit fragile.
NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW: NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW:
FreeBSD 10.x has many debugging features turned on, in both the kernel FreeBSD 10.x has many debugging features turned on, in both the kernel
and userland. These features attempt to detect incorrect use of and userland. These features attempt to detect incorrect use of
@@ -26,6 +31,172 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW:
disable the most expensive debugging functionality run disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".) "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
20130905:
The PROCDESC kernel option is now part of the GENERIC kernel
configuration and is required for the rwhod(8) to work.
If you are using custom kernel configuration, you should include
'options PROCDESC'.
20130905:
The API and ABI related to the Capsicum framework was modified
in backward incompatible way. The userland libraries and programs
have to be recompiled to work with the new kernel. This includes the
following libraries and programs, but the whole buildworld is
advised: libc, libprocstat, dhclient, tcpdump, hastd, hastctl,
kdump, procstat, rwho, rwhod, uniq.
20130827:
Thomas Dickey (vendor author thereof) reports that dialog(1) since
2011/10/18 has a bug in handling --hline. Testers and I noticed the
--hline is not ignored but displayed as a NULL string, regardless of
value. This will cause confusion in some bsdconfig dialogs where the
--hline is used to inform users which keybindings to use. This will
likewise affect any other persons relying on --hline. It also looks
rather strange seeing "[]" at the bottom of dialog(1) widgets when
passing --hline "anything". Thomas said he will have a look in a few
weeks. NOTE: The "[]" brackets appear with the left-edge where it
would normally appear given the width of text to display, but the
displayed text is not there (part of the bug).
20130821:
The PADLOCK_RNG and RDRAND_RNG kernel options are now devices.
Thus "device padlock_rng" and "device rdrand_rng" should be
used instead of "options PADLOCK_RNG" & "options RDRAND_RNG".
20130813:
WITH_ICONV has been split into two feature sets. WITH_ICONV now
enables just the iconv* functionality and is now on by default.
WITH_LIBICONV_COMPAT enables the libiconv api and link time
compatability. Set WITHOUT_ICONV to build the old way.
If you have been using WITH_ICONV before, you will very likely
need to turn on WITH_LIBICONV_COMPAT.
20130806:
INVARIANTS option now enables DEBUG for code with OpenSolaris and
Illumos origin, including ZFS. If you have INVARIANTS in your
kernel configuration, then there is no need to set DEBUG or ZFS_DEBUG
explicitly.
DEBUG used to enable witness(9) tracking of OpenSolaris (mostly ZFS)
locks if WITNESS option was set. Because that generated a lot of
witness(9) reports and all of them were believed to be false
positives, this is no longer done. New option OPENSOLARIS_WITNESS
can be used to achieve the previous behavior.
20130806:
Timer values in IPv6 data structures now use time_uptime instead
of time_second. Although this is not a user-visible functional
change, userland utilities which directly use them---ndp(8),
rtadvd(8), and rtsold(8) in the base system---need to be updated
to r253970 or later.
20130802:
find -delete can now delete the pathnames given as arguments,
instead of only files found below them or if the pathname did
not contain any slashes. Formerly, the following error message
would result:
find: -delete: <path>: relative path potentially not safe
Deleting the pathnames given as arguments can be prevented
without error messages using -mindepth 1 or by changing
directory and passing "." as argument to find. This works in the
old as well as the new version of find.
20130726:
Behavior of devfs rules path matching has been changed.
Pattern is now always matched against fully qualified devfs
path and slash characters must be explicitly matched by
slashes in pattern (FNM_PATHNAME). Rulesets involving devfs
subdirectories must be reviewed.
20130716:
The default ARM ABI has changed to the ARM EABI. The old ABI is
incompatible with the ARM EABI and all programs and modules will
need to be rebuilt to work with a new kernel.
To keep using the old ABI ensure the WITHOUT_ARM_EABI knob is set.
NOTE: Support for the old ABI will be removed in the future and
users are advised to upgrade.
20130709:
pkg_install has been disconnected from the build if you really need it
you should add WITH_PKGTOOLS in your src.conf(5).
20130709:
Most of network statistics structures were changed to be able
keep 64-bits counters. Thus all tools, that work with networking
statistics, must be rebuilt (netstat(1), bsnmpd(1), etc.)
20130629:
Fix targets that run multiple make's to use && rather than ;
so that subsequent steps depend on success of previous.
NOTE: if building 'universe' with -j* on stable/8 or stable/9
it would be better to start the build using bmake, to avoid
overloading the machine.
20130618:
Fix a bug that allowed a tracing process (e.g. gdb) to write
to a memory-mapped file in the traced process's address space
even if neither the traced process nor the tracing process had
write access to that file.
20130615:
CVS has been removed from the base system. An exact copy
of the code is available from the devel/cvs port.
20130613:
Some people report the following error after the switch to bmake:
make: illegal option -- J
usage: make [-BPSXeiknpqrstv] [-C directory] [-D variable]
...
*** [buildworld] Error code 2
this likely due to an old instance of make in
${MAKEPATH} (${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE})
which src/Makefile will use that blindly, if it exists, so if
you see the above error:
rm -rf `make -V MAKEPATH`
should resolve it.
20130516:
Use bmake by default.
Whereas before one could choose to build with bmake via
-DWITH_BMAKE one must now use -DWITHOUT_BMAKE to use the old
make. The goal is to remove these knobs for 10-RELEASE.
It is worth noting that bmake (like gmake) treats the command
line as the unit of failure, rather than statements within the
command line. Thus '(cd some/where && dosomething)' is safer
than 'cd some/where; dosomething'. The '()' allows consistent
behavior in parallel build.
20130429:
Fix a bug that allows NFS clients to issue READDIR on files.
20130426:
The WITHOUT_IDEA option has been removed because
the IDEA patent expired.
20130426:
The sysctl which controls TRIM support under ZFS has been renamed
from vfs.zfs.trim_disable -> vfs.zfs.trim.enabled and has been
enabled by default.
20130425:
The mergemaster command now uses the default MAKEOBJDIRPREFIX
rather than creating it's own in the temporary directory in
order allow access to bootstrapped versions of tools such as
install and mtree. When upgrading from version of FreeBSD where
the install command does not support -l, you will need to
install a new mergemaster command if mergemaster -p is required.
This can be accomplished with the command (cd src/usr.sbin/mergemaster
&& make install).
20130404: 20130404:
Legacy ATA stack, disabled and replaced by new CAM-based one since Legacy ATA stack, disabled and replaced by new CAM-based one since
FreeBSD 9.0, completely removed from the sources. Kernel modules FreeBSD 9.0, completely removed from the sources. Kernel modules
@@ -77,6 +248,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW:
while having the GNU version installed as gnupatch, rebuild while having the GNU version installed as gnupatch, rebuild
and install world with the WITH_BSD_PATCH knob set. and install world with the WITH_BSD_PATCH knob set.
20130121:
Due to the use of the new -l option to install(1) during build
and install, you must take care not to directly set the INSTALL
make variable in your /etc/make.conf, /etc/src.conf, or on the
command line. If you wish to use the -C flag for all installs
you may be able to add INSTALL+=-C to /etc/make.conf or
/etc/src.conf.
20130118: 20130118:
The install(1) option -M has changed meaning and now takes an The install(1) option -M has changed meaning and now takes an
argument that is a file or path to append logs to. In the argument that is a file or path to append logs to. In the
@@ -122,7 +301,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW:
This means that the world and kernel will be compiled with clang This means that the world and kernel will be compiled with clang
and that clang will be installed as /usr/bin/cc, /usr/bin/c++, and that clang will be installed as /usr/bin/cc, /usr/bin/c++,
and /usr/bin/cpp. To disable this behavior and revert to building and /usr/bin/cpp. To disable this behavior and revert to building
with gcc, compile with WITHOUT_CLANG_IS_CC. with gcc, compile with WITHOUT_CLANG_IS_CC. Really old versions
of current may need to bootstrap WITHOUT_CLANG first if the clang
build fails (its compatibility window doesn't extend to the 9 stable
branch point).
20121102: 20121102:
The IPFIREWALL_FORWARD kernel option has been removed. Its The IPFIREWALL_FORWARD kernel option has been removed. Its
@@ -190,9 +372,9 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW:
20120913: 20120913:
The random(4) support for the VIA hardware random number The random(4) support for the VIA hardware random number
generator (`PADLOCK') is no longer enabled unconditionally. generator (`PADLOCK') is no longer enabled unconditionally.
Add the PADLOCK_RNG option in the custom kernel config if Add the padlock_rng device in the custom kernel config if
needed. The GENERIC kernels on i386 and amd64 do include the needed. The GENERIC kernels on i386 and amd64 do include the
option, so the change only affects the custom kernel device, so the change only affects the custom kernel
configurations. configurations.
20120908: 20120908:
@@ -253,7 +435,9 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW:
is now spelled mips64. mipsn32eb is now spelled mipsn32. mipseb is is now spelled mips64. mipsn32eb is now spelled mipsn32. mipseb is
now spelled mips. This is to aid compatibility with third-party now spelled mips. This is to aid compatibility with third-party
software that expects this naming scheme in uname(3). Little-endian software that expects this naming scheme in uname(3). Little-endian
settings are unchanged. settings are unchanged. If you are updating a big-endian mips64 machine
from before this change, you may need to set MACHINE_ARCH=mips64 in
your environment before the new build system will recognize your machine.
20120306: 20120306:
Disable by default the option VFS_ALLOW_NONMPSAFE for all supported Disable by default the option VFS_ALLOW_NONMPSAFE for all supported
@@ -1604,6 +1788,11 @@ COMMON ITEMS:
path, and has the highest probability of being successful. Please try path, and has the highest probability of being successful. Please try
this approach before reporting problems with a major version upgrade. this approach before reporting problems with a major version upgrade.
When upgrading a live system, having a root shell around before
installing anything can help undo problems. Not having a root shell
around can lead to problems if pam has changed too much from your
starting point to allow continued authentication after the upgrade.
ZFS notes ZFS notes
--------- ---------
When upgrading the boot ZFS pool to a new version, always follow When upgrading the boot ZFS pool to a new version, always follow
@@ -1669,7 +1858,6 @@ COMMON ITEMS:
make delete-old [6] make delete-old [6]
<reboot> <reboot>
To cross-install current onto a separate partition To cross-install current onto a separate partition
-------------------------------------------------- --------------------------------------------------
# In this approach we use a separate partition to hold # In this approach we use a separate partition to hold
@@ -1745,7 +1933,7 @@ COMMON ITEMS:
step. It never hurts to do it all the time. You may need to step. It never hurts to do it all the time. You may need to
install a new mergemaster (cd src/usr.sbin/mergemaster && make install a new mergemaster (cd src/usr.sbin/mergemaster && make
install) after the buildworld before this step if you last updated install) after the buildworld before this step if you last updated
from current before 20020224 or from -stable before 20020408. from current before 20130425 or from -stable before 20130430.
[6] This only deletes old files and directories. Old libraries [6] This only deletes old files and directories. Old libraries
can be deleted by "make delete-old-libs", but you have to make can be deleted by "make delete-old-libs", but you have to make
+2 -1
View File
@@ -68,7 +68,7 @@ static int bflag, eflag, lflag, nflag, sflag, tflag, vflag;
static int rval; static int rval;
static const char *filename; static const char *filename;
static void usage(void); static void usage(void) __dead2;
static void scanfiles(char *argv[], int cooked); static void scanfiles(char *argv[], int cooked);
static void cook_cat(FILE *); static void cook_cat(FILE *);
static void raw_cat(int); static void raw_cat(int);
@@ -153,6 +153,7 @@ main(int argc, char *argv[])
static void static void
usage(void) usage(void)
{ {
fprintf(stderr, "usage: cat [-belnstuv] [file ...]\n"); fprintf(stderr, "usage: cat [-belnstuv] [file ...]\n");
exit(1); exit(1);
/* NOTREACHED */ /* NOTREACHED */
+19 -3
View File
@@ -32,7 +32,7 @@
.\" @(#)chflags.1 8.4 (Berkeley) 5/2/95 .\" @(#)chflags.1 8.4 (Berkeley) 5/2/95
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd March 3, 2006 .Dd April 8, 2013
.Dt CHFLAGS 1 .Dt CHFLAGS 1
.Os .Os
.Sh NAME .Sh NAME
@@ -101,20 +101,36 @@ The following keywords are currently defined:
.Bl -tag -offset indent -width ".Cm opaque" .Bl -tag -offset indent -width ".Cm opaque"
.It Cm arch , archived .It Cm arch , archived
set the archived flag (super-user only) set the archived flag (super-user only)
.It Cm opaque
set the opaque flag (owner or super-user only)
.It Cm nodump .It Cm nodump
set the nodump flag (owner or super-user only) set the nodump flag (owner or super-user only)
.It Cm opaque
set the opaque flag (owner or super-user only)
.It Cm sappnd , sappend .It Cm sappnd , sappend
set the system append-only flag (super-user only) set the system append-only flag (super-user only)
.It Cm schg , schange , simmutable .It Cm schg , schange , simmutable
set the system immutable flag (super-user only) set the system immutable flag (super-user only)
.It Cm snapshot
set the snapshot flag (filesystems do not allow changing this flag)
.It Cm sunlnk , sunlink .It Cm sunlnk , sunlink
set the system undeletable flag (super-user only) set the system undeletable flag (super-user only)
.It Cm uappnd , uappend .It Cm uappnd , uappend
set the user append-only flag (owner or super-user only) set the user append-only flag (owner or super-user only)
.It Cm uarch , uarchive
set the archive flag (owner or super-user only)
.It Cm uchg , uchange , uimmutable .It Cm uchg , uchange , uimmutable
set the user immutable flag (owner or super-user only) set the user immutable flag (owner or super-user only)
.It Cm uhidden , hidden
set the hidden file attribute (owner or super-user only)
.It Cm uoffline , offline
set the offline file attribute (owner or super-user only)
.It Cm urdonly , rdonly , readonly
set the DOS, Windows and CIFS readonly flag (owner or super-user only)
.It Cm usparse , sparse
set the sparse file attribute (owner or super-user only)
.It Cm usystem , system
set the DOS, Windows and CIFS system flag (owner or super-user only)
.It Cm ureparse , reparse
set the Windows reparse point file attribute (owner or super-user only)
.It Cm uunlnk , uunlink .It Cm uunlnk , uunlink
set the user undeletable flag (owner or super-user only) set the user undeletable flag (owner or super-user only)
.El .El
+70
View File
@@ -54,6 +54,8 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <langinfo.h>
#include <locale.h>
#include "defs.h" #include "defs.h"
#include "pathnames.h" #include "pathnames.h"
@@ -81,6 +83,7 @@ static int do_status(const char *, int, char **);
static int do_ielem(const char *, int, char **); static int do_ielem(const char *, int, char **);
static int do_return(const char *, int, char **); static int do_return(const char *, int, char **);
static int do_voltag(const char *, int, char **); static int do_voltag(const char *, int, char **);
static void print_designator(const char *, u_int8_t, u_int8_t);
#ifndef CHET_VT #ifndef CHET_VT
#define CHET_VT 10 /* Completely Arbitrary */ #define CHET_VT 10 /* Completely Arbitrary */
@@ -723,6 +726,10 @@ do_status(const char *cname, int argc, char **argv)
putchar('?'); putchar('?');
putchar('>'); putchar('>');
} }
if (ces->ces_designator_length > 0)
print_designator(ces->ces_designator,
ces->ces_code_set,
ces->ces_designator_length);
putchar('\n'); putchar('\n');
} }
@@ -1177,3 +1184,66 @@ usage(void)
"arg1 arg2 [arg3 [...]]\n", getprogname()); "arg1 arg2 [arg3 [...]]\n", getprogname());
exit(1); exit(1);
} }
#define UTF8CODESET "UTF-8"
static void
print_designator(const char *designator, u_int8_t code_set,
u_int8_t designator_length)
{
printf(" serial number: <");
switch (code_set) {
case CES_CODE_SET_ASCII: {
/*
* The driver insures that the string is always NUL terminated.
*/
printf("%s", designator);
break;
}
case CES_CODE_SET_UTF_8: {
char *cs_native;
setlocale(LC_ALL, "");
cs_native = nl_langinfo(CODESET);
/* See if we can natively print UTF-8 */
if (strcmp(cs_native, UTF8CODESET) == 0)
cs_native = NULL;
if (cs_native == NULL) {
/* We can natively print UTF-8, so use printf. */
printf("%s", designator);
} else {
int i;
/*
* We can't natively print UTF-8. We should
* convert it to the terminal's codeset, but that
* requires iconv(3) and FreeBSD doesn't have
* iconv(3) in the base system yet. So we use %XX
* notation for non US-ASCII characters instead.
*/
for (i = 0; i < designator_length &&
designator[i] != '\0'; i++) {
if ((unsigned char)designator[i] < 0x80)
printf("%c", designator[i]);
else
printf("%%%02x",
(unsigned char)designator[i]);
}
}
break;
}
case CES_CODE_SET_BINARY: {
int i;
for (i = 0; i < designator_length; i++)
printf("%02X%s", designator[i],
(i == designator_length - 1) ? "" : " ");
break;
}
default:
break;
}
printf(">");
}
+1
View File
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h> #include <errno.h>
#include <inttypes.h> #include <inttypes.h>
#include <limits.h> #include <limits.h>
#include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
+1
View File
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h> #include <sys/types.h>
#include <signal.h>
#include <stdint.h> #include <stdint.h>
#include "dd.h" #include "dd.h"
+6 -2
View File
@@ -81,6 +81,7 @@ size_t cbsz; /* conversion block size */
uintmax_t files_cnt = 1; /* # of files to copy */ uintmax_t files_cnt = 1; /* # of files to copy */
const u_char *ctab; /* conversion table */ const u_char *ctab; /* conversion table */
char fill_char; /* Character to fill with if defined */ char fill_char; /* Character to fill with if defined */
volatile sig_atomic_t need_summary;
int int
main(int argc __unused, char *argv[]) main(int argc __unused, char *argv[])
@@ -89,7 +90,7 @@ main(int argc __unused, char *argv[])
jcl(argv); jcl(argv);
setup(); setup();
(void)signal(SIGINFO, summaryx); (void)signal(SIGINFO, siginfo_handler);
(void)signal(SIGINT, terminate); (void)signal(SIGINT, terminate);
atexit(summary); atexit(summary);
@@ -358,7 +359,7 @@ dd_in(void)
* than noerror, notrunc or sync are specified, the block * than noerror, notrunc or sync are specified, the block
* is output without buffering as it is read. * is output without buffering as it is read.
*/ */
if (ddflags & C_BS) { if ((ddflags & ~(C_NOERROR | C_NOTRUNC | C_SYNC)) == C_BS) {
out.dbcnt = in.dbcnt; out.dbcnt = in.dbcnt;
dd_out(1); dd_out(1);
in.dbcnt = 0; in.dbcnt = 0;
@@ -375,6 +376,9 @@ dd_in(void)
in.dbp += in.dbrcnt; in.dbp += in.dbrcnt;
(*cfunc)(); (*cfunc)();
if (need_summary) {
summary();
}
} }
} }
+2 -1
View File
@@ -43,7 +43,7 @@ void jcl(char **);
void pos_in(void); void pos_in(void);
void pos_out(void); void pos_out(void);
void summary(void); void summary(void);
void summaryx(int); void siginfo_handler(int);
void terminate(int); void terminate(int);
void unblock(void); void unblock(void);
void unblock_close(void); void unblock_close(void);
@@ -61,3 +61,4 @@ extern const u_char e2a_32V[], e2a_POSIX[];
extern const u_char a2ibm_32V[], a2ibm_POSIX[]; extern const u_char a2ibm_32V[], a2ibm_POSIX[];
extern u_char casetab[]; extern u_char casetab[];
extern char fill_char; extern char fill_char;
extern volatile sig_atomic_t need_summary;
+10 -18
View File
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h> #include <errno.h>
#include <inttypes.h> #include <inttypes.h>
#include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -57,41 +58,32 @@ summary(void)
{ {
struct timeval tv; struct timeval tv;
double secs; double secs;
char buf[100];
(void)gettimeofday(&tv, NULL); (void)gettimeofday(&tv, NULL);
secs = tv.tv_sec + tv.tv_usec * 1e-6 - st.start; secs = tv.tv_sec + tv.tv_usec * 1e-6 - st.start;
if (secs < 1e-6) if (secs < 1e-6)
secs = 1e-6; secs = 1e-6;
/* Use snprintf(3) so that we don't reenter stdio(3). */ (void)fprintf(stderr,
(void)snprintf(buf, sizeof(buf),
"%ju+%ju records in\n%ju+%ju records out\n", "%ju+%ju records in\n%ju+%ju records out\n",
st.in_full, st.in_part, st.out_full, st.out_part); st.in_full, st.in_part, st.out_full, st.out_part);
(void)write(STDERR_FILENO, buf, strlen(buf)); if (st.swab)
if (st.swab) { (void)fprintf(stderr, "%ju odd length swab %s\n",
(void)snprintf(buf, sizeof(buf), "%ju odd length swab %s\n",
st.swab, (st.swab == 1) ? "block" : "blocks"); st.swab, (st.swab == 1) ? "block" : "blocks");
(void)write(STDERR_FILENO, buf, strlen(buf)); if (st.trunc)
} (void)fprintf(stderr, "%ju truncated %s\n",
if (st.trunc) {
(void)snprintf(buf, sizeof(buf), "%ju truncated %s\n",
st.trunc, (st.trunc == 1) ? "block" : "blocks"); st.trunc, (st.trunc == 1) ? "block" : "blocks");
(void)write(STDERR_FILENO, buf, strlen(buf)); (void)fprintf(stderr,
}
(void)snprintf(buf, sizeof(buf),
"%ju bytes transferred in %.6f secs (%.0f bytes/sec)\n", "%ju bytes transferred in %.6f secs (%.0f bytes/sec)\n",
st.bytes, secs, st.bytes / secs); st.bytes, secs, st.bytes / secs);
(void)write(STDERR_FILENO, buf, strlen(buf)); need_summary = 0;
} }
/* ARGSUSED */ /* ARGSUSED */
void void
summaryx(int notused __unused) siginfo_handler(int signo __unused)
{ {
int save_errno = errno;
summary(); need_summary = 1;
errno = save_errno;
} }
/* ARGSUSED */ /* ARGSUSED */
+3
View File
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <err.h> #include <err.h>
#include <errno.h> #include <errno.h>
#include <inttypes.h> #include <inttypes.h>
#include <signal.h>
#include <unistd.h> #include <unistd.h>
#include "dd.h" #include "dd.h"
@@ -91,6 +92,8 @@ pos_in(void)
} }
} else } else
--cnt; --cnt;
if (need_summary)
summary();
continue; continue;
} }
+3 -1
View File
@@ -196,7 +196,9 @@ If the value is outside, it will be set to the appropriate limit.
.Xr localeconv 3 , .Xr localeconv 3 ,
.Xr fstab 5 , .Xr fstab 5 ,
.Xr mount 8 , .Xr mount 8 ,
.Xr quot 8 . .Xr pstat 8 ,
.Xr quot 8 ,
.Xr swapinfo 8 .
.Sh STANDARDS .Sh STANDARDS
With the exception of most options, With the exception of most options,
the the
+6 -5
View File
@@ -114,6 +114,7 @@ main(int argc, char *argv[])
fstype = "ufs"; fstype = "ufs";
(void)setlocale(LC_ALL, ""); (void)setlocale(LC_ALL, "");
memset(&maxwidths, 0, sizeof(maxwidths));
memset(&totalbuf, 0, sizeof(totalbuf)); memset(&totalbuf, 0, sizeof(totalbuf));
totalbuf.f_bsize = DEV_BSIZE; totalbuf.f_bsize = DEV_BSIZE;
strlcpy(totalbuf.f_mntfromname, "total", MNAMELEN); strlcpy(totalbuf.f_mntfromname, "total", MNAMELEN);
@@ -200,7 +201,7 @@ main(int argc, char *argv[])
} else { } else {
/* just the filesystems specified on the command line */ /* just the filesystems specified on the command line */
mntbuf = malloc(argc * sizeof(*mntbuf)); mntbuf = malloc(argc * sizeof(*mntbuf));
if (mntbuf == 0) if (mntbuf == NULL)
err(1, "malloc()"); err(1, "malloc()");
mntsize = 0; mntsize = 0;
/* continued in for loop below */ /* continued in for loop below */
@@ -209,13 +210,13 @@ main(int argc, char *argv[])
/* iterate through specified filesystems */ /* iterate through specified filesystems */
for (; *argv; argv++) { for (; *argv; argv++) {
if (stat(*argv, &stbuf) < 0) { if (stat(*argv, &stbuf) < 0) {
if ((mntpt = getmntpt(*argv)) == 0) { if ((mntpt = getmntpt(*argv)) == NULL) {
warn("%s", *argv); warn("%s", *argv);
rv = 1; rv = 1;
continue; continue;
} }
} else if (S_ISCHR(stbuf.st_mode)) { } else if (S_ISCHR(stbuf.st_mode)) {
if ((mntpt = getmntpt(*argv)) == 0) { if ((mntpt = getmntpt(*argv)) == NULL) {
mdev.fspec = *argv; mdev.fspec = *argv;
mntpath = strdup("/tmp/df.XXXXXX"); mntpath = strdup("/tmp/df.XXXXXX");
if (mntpath == NULL) { if (mntpath == NULL) {
@@ -282,7 +283,7 @@ main(int argc, char *argv[])
mntbuf[mntsize++] = statfsbuf; mntbuf[mntsize++] = statfsbuf;
} }
bzero(&maxwidths, sizeof(maxwidths)); memset(&maxwidths, 0, sizeof(maxwidths));
for (i = 0; i < mntsize; i++) { for (i = 0; i < mntsize; i++) {
if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0) { if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0) {
update_maxwidths(&maxwidths, &mntbuf[i]); update_maxwidths(&maxwidths, &mntbuf[i]);
@@ -309,7 +310,7 @@ getmntpt(const char *name)
if (!strcmp(mntbuf[i].f_mntfromname, name)) if (!strcmp(mntbuf[i].f_mntfromname, name))
return (mntbuf[i].f_mntonname); return (mntbuf[i].f_mntonname);
} }
return (0); return (NULL);
} }
/* /*
+8 -6
View File
@@ -29,7 +29,7 @@
.\" From: @(#)hostname.1 8.1 (Berkeley) 5/31/93 .\" From: @(#)hostname.1 8.1 (Berkeley) 5/31/93
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd September 18, 1994 .Dd April 22, 2013
.Dt DOMAINNAME 1 .Dt DOMAINNAME 1
.Os .Os
.Sh NAME .Sh NAME
@@ -43,10 +43,11 @@ The
.Nm .Nm
utility prints the name of the current YP/NIS domain. utility prints the name of the current YP/NIS domain.
The super-user can The super-user can
set the domain name by supplying an argument; this is usually done in the set the domain name by supplying an argument; this is usually done with the
network initialization script .Va nisdomainname
.Pa /etc/rc.network , variable in the
normally run at boot .Pa /etc/rc.conf
file, normally run at boot
time. time.
.Sh NOTES .Sh NOTES
The YP/NIS (formerly ``Yellow Pages'' but renamed for legal reasons) The YP/NIS (formerly ``Yellow Pages'' but renamed for legal reasons)
@@ -54,7 +55,8 @@ domain name does not necessarily have anything to do with the Domain
Name System domain name, although they are often set equal for administrative Name System domain name, although they are often set equal for administrative
convenience. convenience.
.Sh SEE ALSO .Sh SEE ALSO
.Xr getdomainname 3 .Xr getdomainname 3 ,
.Xr rc.conf 5
.Sh HISTORY .Sh HISTORY
The The
.Nm .Nm
+2 -2
View File
@@ -914,9 +914,9 @@ that line.
.El .El
.Sh FILES .Sh FILES
.Bl -tag -width /tmp/ed.* -compact .Bl -tag -width /tmp/ed.* -compact
.It /tmp/ed.* .It Pa /tmp/ed.*
buffer file buffer file
.It ed.hup .It Pa ed.hup
the file to which the file to which
.Nm .Nm
attempts to write the buffer if the terminal hangs up attempts to write the buffer if the terminal hangs up
+1 -1
View File
@@ -89,7 +89,7 @@ extract_pattern(int delimiter)
default: default:
break; break;
case '[': case '[':
if ((nd = parse_char_class(++nd)) == NULL) { if ((nd = parse_char_class(nd + 1)) == NULL) {
errmsg = "unbalanced brackets ([])"; errmsg = "unbalanced brackets ([])";
return NULL; return NULL;
} }
+2
View File
@@ -4,4 +4,6 @@ PROG= expr
SRCS= expr.y SRCS= expr.y
YFLAGS= YFLAGS=
NO_WMISSING_VARIABLE_DECLARATIONS=
.include <bsd.prog.mk> .include <bsd.prog.mk>
+1 -1
View File
@@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$");
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
static void usage(void); static void usage(void) __dead2;
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
+6 -6
View File
@@ -37,9 +37,9 @@ __FBSDID("$FreeBSD$");
static void usage(void); static void usage(void);
static int kdumpenv(void); static int kdumpenv(void);
static int kgetenv(char *); static int kgetenv(const char *);
static int ksetenv(char *, char *); static int ksetenv(const char *, char *);
static int kunsetenv(char *); static int kunsetenv(const char *);
static int hflag = 0; static int hflag = 0;
static int Nflag = 0; static int Nflag = 0;
@@ -170,7 +170,7 @@ kdumpenv(void)
} }
static int static int
kgetenv(char *env) kgetenv(const char *env)
{ {
char buf[1024]; char buf[1024];
int ret; int ret;
@@ -186,7 +186,7 @@ kgetenv(char *env)
} }
static int static int
ksetenv(char *env, char *val) ksetenv(const char *env, char *val)
{ {
int ret; int ret;
@@ -197,7 +197,7 @@ ksetenv(char *env, char *val)
} }
static int static int
kunsetenv(char *env) kunsetenv(const char *env)
{ {
int ret; int ret;
+1 -1
View File
@@ -156,7 +156,7 @@ signame_to_signum(const char *sig)
{ {
int n; int n;
if (!strncasecmp(sig, "SIG", (size_t)3)) if (strncasecmp(sig, "SIG", 3) == 0)
sig += 3; sig += 3;
for (n = 1; n < sys_nsig; n++) { for (n = 1; n < sys_nsig; n++) {
if (!strcasecmp(sys_signame[n], sig)) if (!strcasecmp(sys_signame[n], sig))
+4 -4
View File
@@ -65,8 +65,8 @@ static int wflag; /* Warn if symlink target does not
* exist, and -f is not enabled. */ * exist, and -f is not enabled. */
static char linkch; static char linkch;
int linkit(const char *, const char *, int); static int linkit(const char *, const char *, int);
void usage(void); static void usage(void);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
@@ -219,7 +219,7 @@ samedirent(const char *path1, const char *path2)
return sb1.st_dev == sb2.st_dev && sb1.st_ino == sb2.st_ino; return sb1.st_dev == sb2.st_dev && sb1.st_ino == sb2.st_ino;
} }
int static int
linkit(const char *source, const char *target, int isdir) linkit(const char *source, const char *target, int isdir)
{ {
struct stat sb; struct stat sb;
@@ -347,7 +347,7 @@ linkit(const char *source, const char *target, int isdir)
return (0); return (0);
} }
void static void
usage(void) usage(void)
{ {
(void)fprintf(stderr, "%s\n%s\n%s\n", (void)fprintf(stderr, "%s\n%s\n%s\n",
+3
View File
@@ -232,6 +232,9 @@ output.
Include the file flags in a long Include the file flags in a long
.Pq Fl l .Pq Fl l
output. output.
See
.Xr chflags 1
for a list of file flags and their meanings.
.It Fl p .It Fl p
Write a slash Write a slash
.Pq Ql / .Pq Ql /
+2 -2
View File
@@ -135,7 +135,7 @@ main(int argc, char *argv[])
* Returns 1 if a directory has been created, * Returns 1 if a directory has been created,
* 2 if it already existed, and 0 on failure. * 2 if it already existed, and 0 on failure.
*/ */
int static int
build(char *path, mode_t omode) build(char *path, mode_t omode)
{ {
struct stat sb; struct stat sb;
@@ -208,7 +208,7 @@ build(char *path, mode_t omode)
return (retval); return (retval);
} }
void static void
usage(void) usage(void)
{ {
+6 -1
View File
@@ -29,7 +29,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE. .\" POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd February 11, 2010 .Dd August 9, 2013
.Dt PKILL 1 .Dt PKILL 1
.Os .Os
.Sh NAME .Sh NAME
@@ -44,6 +44,7 @@
.Op Fl N Ar system .Op Fl N Ar system
.Op Fl P Ar ppid .Op Fl P Ar ppid
.Op Fl U Ar uid .Op Fl U Ar uid
.Op Fl c Ar class
.Op Fl d Ar delim .Op Fl d Ar delim
.Op Fl g Ar pgrp .Op Fl g Ar pgrp
.Op Fl j Ar jid .Op Fl j Ar jid
@@ -60,6 +61,7 @@
.Op Fl N Ar system .Op Fl N Ar system
.Op Fl P Ar ppid .Op Fl P Ar ppid
.Op Fl U Ar uid .Op Fl U Ar uid
.Op Fl c Ar class
.Op Fl g Ar pgrp .Op Fl g Ar pgrp
.Op Fl j Ar jid .Op Fl j Ar jid
.Op Fl s Ar sid .Op Fl s Ar sid
@@ -130,6 +132,9 @@ or
process and all of its ancestors are excluded (unless process and all of its ancestors are excluded (unless
.Fl v .Fl v
is used). is used).
.It Fl c Ar class
Restrict matches to processes running with specified login class
.Ar class .
.It Fl f .It Fl f
Match against full argument lists. Match against full argument lists.
The default is to match against process names. The default is to match against process names.
+36 -7
View File
@@ -79,12 +79,14 @@ enum listtype {
LT_TTY, LT_TTY,
LT_PGRP, LT_PGRP,
LT_JID, LT_JID,
LT_SID LT_SID,
LT_CLASS
}; };
struct list { struct list {
SLIST_ENTRY(list) li_chain; SLIST_ENTRY(list) li_chain;
long li_number; long li_number;
char *li_name;
}; };
SLIST_HEAD(listhead, list); SLIST_HEAD(listhead, list);
@@ -116,6 +118,7 @@ static struct listhead ppidlist = SLIST_HEAD_INITIALIZER(ppidlist);
static struct listhead tdevlist = SLIST_HEAD_INITIALIZER(tdevlist); static struct listhead tdevlist = SLIST_HEAD_INITIALIZER(tdevlist);
static struct listhead sidlist = SLIST_HEAD_INITIALIZER(sidlist); static struct listhead sidlist = SLIST_HEAD_INITIALIZER(sidlist);
static struct listhead jidlist = SLIST_HEAD_INITIALIZER(jidlist); static struct listhead jidlist = SLIST_HEAD_INITIALIZER(jidlist);
static struct listhead classlist = SLIST_HEAD_INITIALIZER(classlist);
static void usage(void) __attribute__((__noreturn__)); static void usage(void) __attribute__((__noreturn__));
static int killact(const struct kinfo_proc *); static int killact(const struct kinfo_proc *);
@@ -179,7 +182,7 @@ main(int argc, char **argv)
execf = NULL; execf = NULL;
coref = _PATH_DEVNULL; coref = _PATH_DEVNULL;
while ((ch = getopt(argc, argv, "DF:G:ILM:N:P:SU:ad:fg:ij:lnoqs:t:u:vx")) != -1) while ((ch = getopt(argc, argv, "DF:G:ILM:N:P:SU:ac:d:fg:ij:lnoqs:t:u:vx")) != -1)
switch (ch) { switch (ch) {
case 'D': case 'D':
debug_opt++; debug_opt++;
@@ -222,6 +225,10 @@ main(int argc, char **argv)
case 'a': case 'a':
ancestors++; ancestors++;
break; break;
case 'c':
makelist(&classlist, LT_CLASS, optarg);
criteria = 1;
break;
case 'd': case 'd':
if (!pgrep) if (!pgrep)
usage(); usage();
@@ -469,6 +476,20 @@ main(int argc, char **argv)
continue; continue;
} }
SLIST_FOREACH(li, &classlist, li_chain) {
/*
* We skip P_SYSTEM processes to match ps(1) output.
*/
if ((kp->ki_flag & P_SYSTEM) == 0 &&
kp->ki_loginclass != NULL &&
strcmp(kp->ki_loginclass, li->li_name) == 0)
break;
}
if (SLIST_FIRST(&classlist) != NULL && li == NULL) {
selected[i] = 0;
continue;
}
if (argc == 0) if (argc == 0)
selected[i] = 1; selected[i] = 1;
} }
@@ -562,9 +583,9 @@ usage(void)
fprintf(stderr, fprintf(stderr,
"usage: %s %s [-F pidfile] [-G gid] [-M core] [-N system]\n" "usage: %s %s [-F pidfile] [-G gid] [-M core] [-N system]\n"
" [-P ppid] [-U uid] [-g pgrp] [-j jid] [-s sid]\n" " [-P ppid] [-U uid] [-c class] [-g pgrp] [-j jid]\n"
" [-t tty] [-u euid] pattern ...\n", getprogname(), " [-s sid] [-t tty] [-u euid] pattern ...\n",
ustr); getprogname(), ustr);
exit(STATUS_BADUSAGE); exit(STATUS_BADUSAGE);
} }
@@ -664,8 +685,10 @@ makelist(struct listhead *head, enum listtype type, char *src)
SLIST_INSERT_HEAD(head, li, li_chain); SLIST_INSERT_HEAD(head, li, li_chain);
empty = 0; empty = 0;
li->li_number = (uid_t)strtol(sp, &ep, 0); if (type != LT_CLASS)
if (*ep == '\0') { li->li_number = (uid_t)strtol(sp, &ep, 0);
if (type != LT_CLASS && *ep == '\0') {
switch (type) { switch (type) {
case LT_PGRP: case LT_PGRP:
if (li->li_number == 0) if (li->li_number == 0)
@@ -750,6 +773,12 @@ foundtty: if ((st.st_mode & S_IFCHR) == 0)
errx(STATUS_BADUSAGE, errx(STATUS_BADUSAGE,
"Invalid jail ID `%s'", sp); "Invalid jail ID `%s'", sp);
break; break;
case LT_CLASS:
li->li_number = -1;
li->li_name = strdup(sp);
if (li->li_name == NULL)
err(STATUS_ERROR, "Cannot allocate memory");
break;
default: default:
usage(); usage();
} }
+1
View File
@@ -87,6 +87,7 @@ static VAR var[] = {
{"etimes", "ELAPSED", NULL, USER, elapseds, 0, CHAR, NULL, 0}, {"etimes", "ELAPSED", NULL, USER, elapseds, 0, CHAR, NULL, 0},
{"euid", "", "uid", 0, NULL, 0, CHAR, NULL, 0}, {"euid", "", "uid", 0, NULL, 0, CHAR, NULL, 0},
{"f", "F", NULL, 0, kvar, KOFF(ki_flag), INT, "x", 0}, {"f", "F", NULL, 0, kvar, KOFF(ki_flag), INT, "x", 0},
{"fib", "FIB", NULL, 0, kvar, KOFF(ki_fibnum), INT, "d", 0},
{"flags", "", "f", 0, NULL, 0, CHAR, NULL, 0}, {"flags", "", "f", 0, NULL, 0, CHAR, NULL, 0},
{"gid", "GID", NULL, 0, kvar, KOFF(ki_groups), UINT, UIDFMT, 0}, {"gid", "GID", NULL, 0, kvar, KOFF(ki_groups), UINT, UIDFMT, 0},
{"group", "GROUP", NULL, LJUST, egroupname, 0, CHAR, NULL, 0}, {"group", "GROUP", NULL, LJUST, egroupname, 0, CHAR, NULL, 0},
+3
View File
@@ -512,6 +512,9 @@ elapsed running time, format
minutes:seconds. minutes:seconds.
.It Cm etimes .It Cm etimes
elapsed running time, in decimal integer seconds elapsed running time, in decimal integer seconds
.It Cm fib
default FIB number, see
.Xr setfib 1
.It Cm flags .It Cm flags
the process flags, in hexadecimal (alias the process flags, in hexadecimal (alias
.Cm f ) .Cm f )
+4 -2
View File
@@ -32,7 +32,7 @@
.\" @(#)rm.1 8.5 (Berkeley) 12/5/94 .\" @(#)rm.1 8.5 (Berkeley) 12/5/94
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd March 15, 2013 .Dd April 25, 2013
.Dt RM 1 .Dt RM 1
.Os .Os
.Sh NAME .Sh NAME
@@ -42,7 +42,7 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl f | i .Op Fl f | i
.Op Fl dIPRrvW .Op Fl dIPRrvWx
.Ar .Ar
.Nm unlink .Nm unlink
.Ar file .Ar file
@@ -132,6 +132,8 @@ Attempt to undelete the named files.
Currently, this option can only be used to recover Currently, this option can only be used to recover
files covered by whiteouts in a union file system (see files covered by whiteouts in a union file system (see
.Xr undelete 2 ) . .Xr undelete 2 ) .
.It Fl x
When removing a hierarchy, do not cross mount points.
.El .El
.Pp .Pp
The The
+28 -23
View File
@@ -59,19 +59,19 @@ __FBSDID("$FreeBSD$");
#include <unistd.h> #include <unistd.h>
static int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok; static int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok;
static int rflag, Iflag; static int rflag, Iflag, xflag;
static uid_t uid; static uid_t uid;
static volatile sig_atomic_t info; static volatile sig_atomic_t info;
int check(char *, char *, struct stat *); static int check(const char *, const char *, struct stat *);
int check2(char **); static int check2(char **);
void checkdot(char **); static void checkdot(char **);
void checkslash(char **); static void checkslash(char **);
void rm_file(char **); static void rm_file(char **);
int rm_overwrite(char *, struct stat *); static int rm_overwrite(const char *, struct stat *);
void rm_tree(char **); static void rm_tree(char **);
static void siginfo(int __unused); static void siginfo(int __unused);
void usage(void); static void usage(void);
/* /*
* rm -- * rm --
@@ -106,8 +106,8 @@ main(int argc, char *argv[])
exit(eval); exit(eval);
} }
Pflag = rflag = 0; Pflag = rflag = xflag = 0;
while ((ch = getopt(argc, argv, "dfiIPRrvW")) != -1) while ((ch = getopt(argc, argv, "dfiIPRrvWx")) != -1)
switch(ch) { switch(ch) {
case 'd': case 'd':
dflag = 1; dflag = 1;
@@ -136,6 +136,9 @@ main(int argc, char *argv[])
case 'W': case 'W':
Wflag = 1; Wflag = 1;
break; break;
case 'x':
xflag = 1;
break;
default: default:
usage(); usage();
} }
@@ -170,7 +173,7 @@ main(int argc, char *argv[])
exit (eval); exit (eval);
} }
void static void
rm_tree(char **argv) rm_tree(char **argv)
{ {
FTS *fts; FTS *fts;
@@ -196,6 +199,8 @@ rm_tree(char **argv)
flags |= FTS_NOSTAT; flags |= FTS_NOSTAT;
if (Wflag) if (Wflag)
flags |= FTS_WHITEOUT; flags |= FTS_WHITEOUT;
if (xflag)
flags |= FTS_XDEV;
if (!(fts = fts_open(argv, flags, NULL))) { if (!(fts = fts_open(argv, flags, NULL))) {
if (fflag && errno == ENOENT) if (fflag && errno == ENOENT)
return; return;
@@ -335,7 +340,7 @@ rm_tree(char **argv)
fts_close(fts); fts_close(fts);
} }
void static void
rm_file(char **argv) rm_file(char **argv)
{ {
struct stat sb; struct stat sb;
@@ -412,8 +417,8 @@ rm_file(char **argv)
* System V file system). In a logging or COW file system, you'll have to * System V file system). In a logging or COW file system, you'll have to
* have kernel support. * have kernel support.
*/ */
int static int
rm_overwrite(char *file, struct stat *sbp) rm_overwrite(const char *file, struct stat *sbp)
{ {
struct stat sb, sb2; struct stat sb, sb2;
struct statfs fsb; struct statfs fsb;
@@ -479,8 +484,8 @@ err: eval = 1;
} }
int static int
check(char *path, char *name, struct stat *sp) check(const char *path, const char *name, struct stat *sp)
{ {
int ch, first; int ch, first;
char modep[15], *flagsp; char modep[15], *flagsp;
@@ -491,7 +496,7 @@ check(char *path, char *name, struct stat *sp)
else { else {
/* /*
* If it's not a symbolic link and it's unwritable and we're * 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 * because their permissions are meaningless. Check stdin_ok
* first because we may not have stat'ed the file. * first because we may not have stat'ed the file.
*/ */
@@ -524,7 +529,7 @@ check(char *path, char *name, struct stat *sp)
} }
#define ISSLASH(a) ((a)[0] == '/' && (a)[1] == '\0') #define ISSLASH(a) ((a)[0] == '/' && (a)[1] == '\0')
void static void
checkslash(char **argv) checkslash(char **argv)
{ {
char **t, **u; char **t, **u;
@@ -544,7 +549,7 @@ checkslash(char **argv)
} }
} }
int static int
check2(char **argv) check2(char **argv)
{ {
struct stat st; struct stat st;
@@ -595,7 +600,7 @@ check2(char **argv)
} }
#define ISDOT(a) ((a)[0] == '.' && (!(a)[1] || ((a)[1] == '.' && !(a)[2]))) #define ISDOT(a) ((a)[0] == '.' && (!(a)[1] || ((a)[1] == '.' && !(a)[2])))
void static void
checkdot(char **argv) checkdot(char **argv)
{ {
char *p, **save, **t; char *p, **save, **t;
@@ -619,12 +624,12 @@ checkdot(char **argv)
} }
} }
void static void
usage(void) usage(void)
{ {
(void)fprintf(stderr, "%s\n%s\n", (void)fprintf(stderr, "%s\n%s\n",
"usage: rm [-f | -i] [-dIPRrvW] file ...", "usage: rm [-f | -i] [-dIPRrvWx] file ...",
" unlink file"); " unlink file");
exit(EX_USAGE); exit(EX_USAGE);
} }
+3 -8
View File
@@ -8,7 +8,7 @@ SHSRCS= alias.c arith_yacc.c arith_yylex.c cd.c echo.c error.c eval.c \
histedit.c input.c jobs.c kill.c mail.c main.c memalloc.c miscbltin.c \ histedit.c input.c jobs.c kill.c mail.c main.c memalloc.c miscbltin.c \
mystring.c options.c output.c parser.c printf.c redir.c show.c \ mystring.c options.c output.c parser.c printf.c redir.c show.c \
test.c trap.c var.c test.c trap.c var.c
GENSRCS= builtins.c init.c nodes.c syntax.c GENSRCS= builtins.c nodes.c syntax.c
GENHDRS= builtins.h nodes.h syntax.h token.h GENHDRS= builtins.h nodes.h syntax.h token.h
SRCS= ${SHSRCS} ${GENSRCS} ${GENHDRS} SRCS= ${SHSRCS} ${GENSRCS} ${GENHDRS}
@@ -30,26 +30,21 @@ WFORMAT=0
${.CURDIR}/../test \ ${.CURDIR}/../test \
${.CURDIR}/../../usr.bin/printf ${.CURDIR}/../../usr.bin/printf
CLEANFILES+= mkinit mkinit.o mknodes mknodes.o \ CLEANFILES+= mknodes mknodes.o \
mksyntax mksyntax.o mksyntax mksyntax.o
CLEANFILES+= ${GENSRCS} ${GENHDRS} CLEANFILES+= ${GENSRCS} ${GENHDRS}
build-tools: mkinit mknodes mksyntax build-tools: mknodes mksyntax
.ORDER: builtins.c builtins.h .ORDER: builtins.c builtins.h
builtins.c builtins.h: mkbuiltins builtins.def builtins.c builtins.h: mkbuiltins builtins.def
sh ${.CURDIR}/mkbuiltins ${.CURDIR} sh ${.CURDIR}/mkbuiltins ${.CURDIR}
init.c: mkinit alias.c eval.c exec.c input.c jobs.c options.c parser.c \
redir.c trap.c var.c
./mkinit ${.ALLSRC:S/^mkinit$//}
# XXX this is just to stop the default .c rule being used, so that the # XXX this is just to stop the default .c rule being used, so that the
# intermediate object has a fixed name. # intermediate object has a fixed name.
# XXX we have a default .c rule, but no default .o rule. # XXX we have a default .c rule, but no default .o rule.
.o: .o:
${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
mkinit: mkinit.o
mknodes: mknodes.o mknodes: mknodes.o
mksyntax: mksyntax.o mksyntax: mksyntax.o
+1 -28
View File
@@ -25,38 +25,11 @@ programs is:
program input files generates program input files generates
------- ----------- --------- ------- ----------- ---------
mkbuiltins builtins builtins.h builtins.c mkbuiltins builtins builtins.h builtins.c
mkinit *.c init.c
mknodes nodetypes nodes.h nodes.c mknodes nodetypes nodes.h nodes.c
mksyntax - syntax.h syntax.c mksyntax - syntax.h syntax.c
mktokens - token.h mktokens - token.h
There are undoubtedly too many of these. Mkinit searches all the There are undoubtedly too many of these.
C source files for entries looking like:
RESET {
x = 2; /* executed when the shell does a longjmp
back to the main command loop */
}
It pulls this code out into routines which are when particular
events occur. The intent is to improve modularity by isolating
the information about which modules need to be explicitly
initialized/reset within the modules themselves.
Mkinit recognizes several constructs for placing declarations in
the init.c file.
INCLUDE "file.h"
includes a file. The storage class MKINIT makes a declaration
available in the init.c file, for example:
MKINIT int funcnest; /* depth of function calls */
MKINIT alone on a line introduces a structure or union declara-
tion:
MKINIT
struct redirtab {
short renamed[10];
};
Preprocessor #define statements are copied to init.c without any
special action to request this.
EXCEPTIONS: Code for dealing with exceptions appears in EXCEPTIONS: Code for dealing with exceptions appears in
exceptions.c. The C language doesn't include exception handling, exceptions.c. The C language doesn't include exception handling,
+5 -3
View File
@@ -237,17 +237,19 @@ printaliases(void)
} }
int int
aliascmd(int argc, char **argv) aliascmd(int argc __unused, char **argv __unused)
{ {
char *n, *v; char *n, *v;
int ret = 0; int ret = 0;
struct alias *ap; struct alias *ap;
if (argc == 1) { nextopt("");
if (*argptr == NULL) {
printaliases(); printaliases();
return (0); return (0);
} }
while ((n = *++argv) != NULL) { while ((n = *argptr++) != NULL) {
if ((v = strchr(n+1, '=')) == NULL) /* n+1: funny ksh stuff */ if ((v = strchr(n+1, '=')) == NULL) /* n+1: funny ksh stuff */
if ((ap = lookupalias(n, 0)) == NULL) { if ((ap = lookupalias(n, 0)) == NULL) {
warning("%s: not found", n); warning("%s: not found", n);
+4
View File
@@ -218,9 +218,13 @@ yylex(void)
value += ARITH_REM - '%'; value += ARITH_REM - '%';
goto checkeq; goto checkeq;
case '+': case '+':
if (buf[1] == '+')
return ARITH_BAD;
value += ARITH_ADD - '+'; value += ARITH_ADD - '+';
goto checkeq; goto checkeq;
case '-': case '-':
if (buf[1] == '-')
return ARITH_BAD;
value += ARITH_SUB - '-'; value += ARITH_SUB - '-';
goto checkeq; goto checkeq;
case '~': case '~':
+10 -19
View File
@@ -76,7 +76,7 @@ __FBSDID("$FreeBSD$");
int evalskip; /* set if we are skipping commands */ int evalskip; /* set if we are skipping commands */
int skipcount; /* number of levels to skip */ int skipcount; /* number of levels to skip */
MKINIT int loopnest; /* current loop nesting level */ static int loopnest; /* current loop nesting level */
int funcnest; /* depth of function calls */ int funcnest; /* depth of function calls */
static int builtin_flags; /* evalcommand flags for builtins */ static int builtin_flags; /* evalcommand flags for builtins */
@@ -104,16 +104,12 @@ static void prehash(union node *);
* Called to reset things after an exception. * Called to reset things after an exception.
*/ */
#ifdef mkinit void
INCLUDE "eval.h" reseteval(void)
{
RESET {
evalskip = 0; evalskip = 0;
loopnest = 0; loopnest = 0;
funcnest = 0;
} }
#endif
/* /*
@@ -328,7 +324,7 @@ skipping: if (evalskip == SKIPCONT && --skipcount <= 0) {
} }
if (evalskip == SKIPBREAK && --skipcount <= 0) if (evalskip == SKIPBREAK && --skipcount <= 0)
evalskip = 0; evalskip = 0;
if (evalskip == SKIPFUNC || evalskip == SKIPFILE) if (evalskip == SKIPRETURN)
status = exitstatus; status = exitstatus;
break; break;
} }
@@ -589,7 +585,8 @@ evalpipe(union node *n)
pip[1] = -1; pip[1] = -1;
if (lp->next) { if (lp->next) {
if (pipe(pip) < 0) { if (pipe(pip) < 0) {
close(prevfd); if (prevfd >= 0)
close(prevfd);
error("Pipe call failed: %s", strerror(errno)); error("Pipe call failed: %s", strerror(errno));
} }
} }
@@ -1071,7 +1068,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
funcnest--; funcnest--;
popredir(); popredir();
INTON; INTON;
if (evalskip == SKIPFUNC) { if (evalskip == SKIPRETURN) {
evalskip = 0; evalskip = 0;
skipcount = 0; skipcount = 0;
} }
@@ -1308,14 +1305,8 @@ returncmd(int argc, char **argv)
{ {
int ret = argc > 1 ? number(argv[1]) : oexitstatus; int ret = argc > 1 ? number(argv[1]) : oexitstatus;
if (funcnest) { evalskip = SKIPRETURN;
evalskip = SKIPFUNC; skipcount = 1;
skipcount = 1;
} else {
/* skip the rest of the file */
evalskip = SKIPFILE;
skipcount = 1;
}
return ret; return ret;
} }
+3 -2
View File
@@ -46,6 +46,8 @@ struct backcmd { /* result of evalbackcmd */
struct job *jp; /* job structure for command */ struct job *jp; /* job structure for command */
}; };
void reseteval(void);
/* flags in argument to evaltree/evalstring */ /* flags in argument to evaltree/evalstring */
#define EV_EXIT 01 /* exit after evaluating tree */ #define EV_EXIT 01 /* exit after evaluating tree */
#define EV_TESTED 02 /* exit status is checked; ignore -e flag */ #define EV_TESTED 02 /* exit status is checked; ignore -e flag */
@@ -65,5 +67,4 @@ extern int skipcount;
/* reasons for skipping commands (see comment on breakcmd routine) */ /* reasons for skipping commands (see comment on breakcmd routine) */
#define SKIPBREAK 1 #define SKIPBREAK 1
#define SKIPCONT 2 #define SKIPCONT 2
#define SKIPFUNC 3 #define SKIPRETURN 3
#define SKIPFILE 4
+2 -1
View File
@@ -70,7 +70,6 @@ __FBSDID("$FreeBSD$");
#include "syntax.h" #include "syntax.h"
#include "memalloc.h" #include "memalloc.h"
#include "error.h" #include "error.h"
#include "init.h"
#include "mystring.h" #include "mystring.h"
#include "show.h" #include "show.h"
#include "jobs.h" #include "jobs.h"
@@ -763,5 +762,7 @@ typecmd_impl(int argc, char **argv, int cmd, const char *path)
int int
typecmd(int argc, char **argv) typecmd(int argc, char **argv)
{ {
if (argc > 2 && strcmp(argv[1], "--") == 0)
argc--, argv++;
return typecmd_impl(argc, argv, TYPECMD_TYPE, bltinlookup("PATH", 1)); return typecmd_impl(argc, argv, TYPECMD_TYPE, bltinlookup("PATH", 1));
} }
-36
View File
@@ -1,36 +0,0 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Kenneth Almquist.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)init.h 8.2 (Berkeley) 5/4/95
* $FreeBSD$
*/
void reset(void);
+8 -12
View File
@@ -92,7 +92,7 @@ struct parsefile {
int plinno = 1; /* input line number */ int plinno = 1; /* input line number */
int parsenleft; /* copy of parsefile->nleft */ int parsenleft; /* copy of parsefile->nleft */
MKINIT int parselleft; /* copy of parsefile->lleft */ static int parselleft; /* copy of parsefile->lleft */
const char *parsenextc; /* copy of parsefile->nextc */ const char *parsenextc; /* copy of parsefile->nextc */
static char basebuf[BUFSIZ + 1];/* buffer for top level input file */ static char basebuf[BUFSIZ + 1];/* buffer for top level input file */
static struct parsefile basepf = { /* top level input file */ static struct parsefile basepf = { /* top level input file */
@@ -108,15 +108,12 @@ static void pushfile(void);
static int preadfd(void); static int preadfd(void);
static void popstring(void); static void popstring(void);
#ifdef mkinit void
INCLUDE "input.h" resetinput(void)
INCLUDE "error.h" {
RESET {
popallfiles(); popallfiles();
parselleft = parsenleft = 0; /* clear input buffer */ parselleft = parsenleft = 0; /* clear input buffer */
} }
#endif
/* /*
@@ -397,10 +394,10 @@ setinputfile(const char *fname, int push)
int fd2; int fd2;
INTOFF; INTOFF;
if ((fd = open(fname, O_RDONLY)) < 0) if ((fd = open(fname, O_RDONLY | O_CLOEXEC)) < 0)
error("cannot open %s: %s", fname, strerror(errno)); error("cannot open %s: %s", fname, strerror(errno));
if (fd < 10) { if (fd < 10) {
fd2 = fcntl(fd, F_DUPFD, 10); fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 10);
close(fd); close(fd);
if (fd2 < 0) if (fd2 < 0)
error("Out of file descriptors"); error("Out of file descriptors");
@@ -412,14 +409,13 @@ setinputfile(const char *fname, int push)
/* /*
* Like setinputfile, but takes an open file descriptor. Call this with * Like setinputfile, but takes an open file descriptor (which should have
* interrupts off. * its FD_CLOEXEC flag already set). Call this with interrupts off.
*/ */
void void
setinputfd(int fd, int push) setinputfd(int fd, int push)
{ {
(void)fcntl(fd, F_SETFD, FD_CLOEXEC);
if (push) { if (push) {
pushfile(); pushfile();
parsefile->buf = ckmalloc(BUFSIZ + 1); parsefile->buf = ckmalloc(BUFSIZ + 1);
+1
View File
@@ -47,6 +47,7 @@ extern const char *parsenextc; /* next character in input buffer */
struct alias; struct alias;
struct parsefile; struct parsefile;
void resetinput(void);
char *pfgets(char *, int); char *pfgets(char *, int);
int pgetc(void); int pgetc(void);
int preadbuffer(void); int preadbuffer(void);
+76 -55
View File
@@ -77,24 +77,25 @@ __FBSDID("$FreeBSD$");
static struct job *jobtab; /* array of jobs */ static struct job *jobtab; /* array of jobs */
static int njobs; /* size of array */ static int njobs; /* size of array */
MKINIT pid_t backgndpid = -1; /* pid of last background process */ static pid_t backgndpid = -1; /* pid of last background process */
MKINIT struct job *bgjob = NULL; /* last background process */ static struct job *bgjob = NULL; /* last background process */
#if JOBS #if JOBS
static struct job *jobmru; /* most recently used job list */ static struct job *jobmru; /* most recently used job list */
static pid_t initialpgrp; /* pgrp of shell on invocation */ static pid_t initialpgrp; /* pgrp of shell on invocation */
#endif #endif
int in_waitcmd = 0; /* are we in waitcmd()? */
volatile sig_atomic_t breakwaitcmd = 0; /* should wait be terminated? */
static int ttyfd = -1; static int ttyfd = -1;
/* mode flags for dowait */ /* mode flags for dowait */
#define DOWAIT_BLOCK 0x1 /* wait until a child exits */ #define DOWAIT_BLOCK 0x1 /* wait until a child exits */
#define DOWAIT_SIG 0x2 /* if DOWAIT_BLOCK, abort on signals */ #define DOWAIT_SIG 0x2 /* if DOWAIT_BLOCK, abort on SIGINT/SIGQUIT */
#define DOWAIT_SIG_ANY 0x4 /* if DOWAIT_SIG, abort on any signal */
#if JOBS #if JOBS
static void restartjob(struct job *); static void restartjob(struct job *);
#endif #endif
static void freejob(struct job *); static void freejob(struct job *);
static int waitcmdloop(struct job *);
static struct job *getjob_nonotfound(char *);
static struct job *getjob(char *); static struct job *getjob(char *);
pid_t getjobpgrp(char *); pid_t getjobpgrp(char *);
static pid_t dowait(int, struct job *); static pid_t dowait(int, struct job *);
@@ -114,7 +115,7 @@ static void showjob(struct job *, int);
* Turn job control on and off. * Turn job control on and off.
*/ */
MKINIT int jobctl; static int jobctl;
#if JOBS #if JOBS
void void
@@ -127,11 +128,12 @@ setjobctl(int on)
if (on) { if (on) {
if (ttyfd != -1) if (ttyfd != -1)
close(ttyfd); close(ttyfd);
if ((ttyfd = open(_PATH_TTY, O_RDWR)) < 0) { if ((ttyfd = open(_PATH_TTY, O_RDWR | O_CLOEXEC)) < 0) {
i = 0; i = 0;
while (i <= 2 && !isatty(i)) while (i <= 2 && !isatty(i))
i++; i++;
if (i > 2 || (ttyfd = fcntl(i, F_DUPFD, 10)) < 0) if (i > 2 ||
(ttyfd = fcntl(i, F_DUPFD_CLOEXEC, 10)) < 0)
goto out; goto out;
} }
if (ttyfd < 10) { if (ttyfd < 10) {
@@ -139,7 +141,7 @@ setjobctl(int on)
* Keep our TTY file descriptor out of the way of * Keep our TTY file descriptor out of the way of
* the user's redirections. * the user's redirections.
*/ */
if ((i = fcntl(ttyfd, F_DUPFD, 10)) < 0) { if ((i = fcntl(ttyfd, F_DUPFD_CLOEXEC, 10)) < 0) {
close(ttyfd); close(ttyfd);
ttyfd = -1; ttyfd = -1;
goto out; goto out;
@@ -147,11 +149,6 @@ setjobctl(int on)
close(ttyfd); close(ttyfd);
ttyfd = i; ttyfd = i;
} }
if (fcntl(ttyfd, F_SETFD, FD_CLOEXEC) < 0) {
close(ttyfd);
ttyfd = -1;
goto out;
}
do { /* while we are in the background */ do { /* while we are in the background */
initialpgrp = tcgetpgrp(ttyfd); initialpgrp = tcgetpgrp(ttyfd);
if (initialpgrp < 0) { if (initialpgrp < 0) {
@@ -185,13 +182,14 @@ out: out2fmt_flush("sh: can't access tty; job control turned off\n");
#if JOBS #if JOBS
int int
fgcmd(int argc __unused, char **argv) fgcmd(int argc __unused, char **argv __unused)
{ {
struct job *jp; struct job *jp;
pid_t pgrp; pid_t pgrp;
int status; int status;
jp = getjob(argv[1]); nextopt("");
jp = getjob(*argptr);
if (jp->jobctl == 0) if (jp->jobctl == 0)
error("job not created under job control"); error("job not created under job control");
printjobcmd(jp); printjobcmd(jp);
@@ -212,8 +210,9 @@ bgcmd(int argc, char **argv)
{ {
struct job *jp; struct job *jp;
nextopt("");
do { do {
jp = getjob(*++argv); jp = getjob(*argptr);
if (jp->jobctl == 0) if (jp->jobctl == 0)
error("job not created under job control"); error("job not created under job control");
if (jp->state == JOBDONE) if (jp->state == JOBDONE)
@@ -222,7 +221,7 @@ bgcmd(int argc, char **argv)
jp->foreground = 0; jp->foreground = 0;
out1fmt("[%td] ", jp - jobtab + 1); out1fmt("[%td] ", jp - jobtab + 1);
printjobcmd(jp); printjobcmd(jp);
} while (--argc > 1); } while (*argptr != NULL && *++argptr != NULL);
return 0; return 0;
} }
@@ -417,13 +416,15 @@ showjobs(int change, int mode)
if (change && ! jp->changed) if (change && ! jp->changed)
continue; continue;
showjob(jp, mode); showjob(jp, mode);
jp->changed = 0; if (mode == SHOWJOBS_DEFAULT || mode == SHOWJOBS_VERBOSE) {
/* Hack: discard jobs for which $! has not been referenced jp->changed = 0;
* in interactive mode when they terminate. /* Hack: discard jobs for which $! has not been
*/ * referenced in interactive mode when they terminate.
if (jp->state == JOBDONE && !jp->remembered && */
(iflag || jp != bgjob)) { if (jp->state == JOBDONE && !jp->remembered &&
freejob(jp); (iflag || jp != bgjob)) {
freejob(jp);
}
} }
} }
} }
@@ -461,32 +462,41 @@ int
waitcmd(int argc __unused, char **argv __unused) waitcmd(int argc __unused, char **argv __unused)
{ {
struct job *job; struct job *job;
int status, retval; int retval;
struct job *jp;
nextopt(""); nextopt("");
if (*argptr != NULL) { if (*argptr == NULL)
job = getjob(*argptr); return (waitcmdloop(NULL));
} else {
job = NULL; do {
} job = getjob_nonotfound(*argptr);
if (job == NULL)
retval = 127;
else
retval = waitcmdloop(job);
argptr++;
} while (*argptr != NULL);
return (retval);
}
static int
waitcmdloop(struct job *job)
{
int status, retval, sig;
struct job *jp;
/* /*
* Loop until a process is terminated or stopped, or a SIGINT is * Loop until a process is terminated or stopped, or a SIGINT is
* received. * received.
*/ */
in_waitcmd++;
do { do {
if (job != NULL) { if (job != NULL) {
if (job->state) { if (job->state == JOBDONE) {
status = job->ps[job->nprocs - 1].status; status = job->ps[job->nprocs - 1].status;
if (WIFEXITED(status)) if (WIFEXITED(status))
retval = WEXITSTATUS(status); retval = WEXITSTATUS(status);
#if JOBS
else if (WIFSTOPPED(status))
retval = WSTOPSIG(status) + 128;
#endif
else else
retval = WTERMSIG(status) + 128; retval = WTERMSIG(status) + 128;
if (! iflag || ! job->changed) if (! iflag || ! job->changed)
@@ -496,7 +506,6 @@ waitcmd(int argc __unused, char **argv __unused)
if (job == bgjob) if (job == bgjob)
bgjob = NULL; bgjob = NULL;
} }
in_waitcmd--;
return retval; return retval;
} }
} else { } else {
@@ -512,7 +521,6 @@ waitcmd(int argc __unused, char **argv __unused)
} }
for (jp = jobtab ; ; jp++) { for (jp = jobtab ; ; jp++) {
if (jp >= jobtab + njobs) { /* no running procs */ if (jp >= jobtab + njobs) { /* no running procs */
in_waitcmd--;
return 0; return 0;
} }
if (jp->used && jp->state == 0) if (jp->used && jp->state == 0)
@@ -520,20 +528,22 @@ waitcmd(int argc __unused, char **argv __unused)
} }
} }
} while (dowait(DOWAIT_BLOCK | DOWAIT_SIG, (struct job *)NULL) != -1); } while (dowait(DOWAIT_BLOCK | DOWAIT_SIG, (struct job *)NULL) != -1);
in_waitcmd--;
return pendingsig + 128; sig = pendingsig_waitcmd;
pendingsig_waitcmd = 0;
return sig + 128;
} }
int int
jobidcmd(int argc __unused, char **argv) jobidcmd(int argc __unused, char **argv __unused)
{ {
struct job *jp; struct job *jp;
int i; int i;
jp = getjob(argv[1]); nextopt("");
jp = getjob(*argptr);
for (i = 0 ; i < jp->nprocs ; ) { for (i = 0 ; i < jp->nprocs ; ) {
out1fmt("%d", (int)jp->ps[i].pid); out1fmt("%d", (int)jp->ps[i].pid);
out1c(++i < jp->nprocs? ' ' : '\n'); out1c(++i < jp->nprocs? ' ' : '\n');
@@ -548,7 +558,7 @@ jobidcmd(int argc __unused, char **argv)
*/ */
static struct job * static struct job *
getjob(char *name) getjob_nonotfound(char *name)
{ {
int jobno; int jobno;
struct job *found, *jp; struct job *found, *jp;
@@ -613,12 +623,22 @@ currentjob: if ((jp = getcurjob(NULL)) == NULL)
return jp; return jp;
} }
} }
error("No such job: %s", name);
/*NOTREACHED*/
return NULL; return NULL;
} }
static struct job *
getjob(char *name)
{
struct job *jp;
jp = getjob_nonotfound(name);
if (jp == NULL)
error("No such job: %s", name);
return (jp);
}
pid_t pid_t
getjobpgrp(char *name) getjobpgrp(char *name)
{ {
@@ -967,7 +987,8 @@ waitforjob(struct job *jp, int *origstatus)
INTOFF; INTOFF;
TRACE(("waitforjob(%%%td) called\n", jp - jobtab + 1)); TRACE(("waitforjob(%%%td) called\n", jp - jobtab + 1));
while (jp->state == 0) while (jp->state == 0)
if (dowait(DOWAIT_BLOCK | (Tflag ? DOWAIT_SIG : 0), jp) == -1) if (dowait(DOWAIT_BLOCK | (Tflag ? DOWAIT_SIG |
DOWAIT_SIG_ANY : 0), jp) == -1)
dotrap(); dotrap();
#if JOBS #if JOBS
if (jp->jobctl) { if (jp->jobctl) {
@@ -1058,12 +1079,17 @@ dowait(int mode, struct job *job)
pid = wait3(&status, wflags, (struct rusage *)NULL); pid = wait3(&status, wflags, (struct rusage *)NULL);
TRACE(("wait returns %d, status=%d\n", (int)pid, status)); TRACE(("wait returns %d, status=%d\n", (int)pid, status));
if (pid == 0 && (mode & DOWAIT_SIG) != 0) { if (pid == 0 && (mode & DOWAIT_SIG) != 0) {
sigsuspend(&omask);
pid = -1; pid = -1;
if (((mode & DOWAIT_SIG_ANY) != 0 ?
pendingsig : pendingsig_waitcmd) != 0) {
errno = EINTR;
break;
}
sigsuspend(&omask);
if (int_pending()) if (int_pending())
break; break;
} }
} while (pid == -1 && errno == EINTR && breakwaitcmd == 0); } while (pid == -1 && errno == EINTR);
if (pid == -1 && errno == ECHILD && job != NULL) if (pid == -1 && errno == ECHILD && job != NULL)
job->state = JOBDONE; job->state = JOBDONE;
if ((mode & DOWAIT_SIG) != 0) { if ((mode & DOWAIT_SIG) != 0) {
@@ -1072,11 +1098,6 @@ dowait(int mode, struct job *job)
sigprocmask(SIG_SETMASK, &omask, NULL); sigprocmask(SIG_SETMASK, &omask, NULL);
INTON; INTON;
} }
if (breakwaitcmd != 0) {
breakwaitcmd = 0;
if (pid <= 0)
return -1;
}
if (pid <= 0) if (pid <= 0)
return pid; return pid;
INTOFF; INTOFF;
-2
View File
@@ -83,8 +83,6 @@ enum {
}; };
extern int job_warning; /* user was warned about stopped jobs */ extern int job_warning; /* user was warned about stopped jobs */
extern int in_waitcmd; /* are we in waitcmd()? */
extern volatile sig_atomic_t breakwaitcmd; /* break wait to process traps? */
void setjobctl(int); void setjobctl(int);
void showjobs(int, int); void showjobs(int, int);
+11 -4
View File
@@ -68,10 +68,10 @@ __FBSDID("$FreeBSD$");
#include "show.h" #include "show.h"
#include "memalloc.h" #include "memalloc.h"
#include "error.h" #include "error.h"
#include "init.h"
#include "mystring.h" #include "mystring.h"
#include "exec.h" #include "exec.h"
#include "cd.h" #include "cd.h"
#include "redir.h"
#include "builtins.h" #include "builtins.h"
int rootpid; int rootpid;
@@ -79,6 +79,7 @@ int rootshell;
struct jmploc main_handler; struct jmploc main_handler;
int localeisutf8, initial_localeisutf8; int localeisutf8, initial_localeisutf8;
static void reset(void);
static void cmdloop(int); static void cmdloop(int);
static void read_profile(const char *); static void read_profile(const char *);
static char *find_dot_file(char *); static char *find_dot_file(char *);
@@ -170,8 +171,8 @@ main(int argc, char *argv[])
if (minusc) { if (minusc) {
evalstring(minusc, sflag ? 0 : EV_EXIT); evalstring(minusc, sflag ? 0 : EV_EXIT);
} }
state4:
if (sflag || minusc == NULL) { if (sflag || minusc == NULL) {
state4: /* XXX ??? - why isn't this before the "if" statement */
cmdloop(1); cmdloop(1);
} }
exitshell(exitstatus); exitshell(exitstatus);
@@ -179,6 +180,12 @@ main(int argc, char *argv[])
return 0; return 0;
} }
static void
reset(void)
{
reseteval();
resetinput();
}
/* /*
* Read and execute commands. "Top" is nonzero for the top level command * Read and execute commands. "Top" is nonzero for the top level command
@@ -224,7 +231,7 @@ cmdloop(int top)
popstackmark(&smark); popstackmark(&smark);
setstackmark(&smark); setstackmark(&smark);
if (evalskip != 0) { if (evalskip != 0) {
if (evalskip == SKIPFILE) if (evalskip == SKIPRETURN)
evalskip = 0; evalskip = 0;
break; break;
} }
@@ -248,7 +255,7 @@ read_profile(const char *name)
if (expandedname == NULL) if (expandedname == NULL)
return; return;
INTOFF; INTOFF;
if ((fd = open(expandedname, O_RDONLY)) >= 0) if ((fd = open(expandedname, O_RDONLY | O_CLOEXEC)) >= 0)
setinputfd(fd, 1); setinputfd(fd, 1);
INTON; INTON;
if (fd < 0) if (fd < 0)
+3 -17
View File
@@ -124,7 +124,6 @@ struct stack_block {
#define SPACE(sp) ((char*)(sp) + ALIGN(sizeof(struct stack_block))) #define SPACE(sp) ((char*)(sp) + ALIGN(sizeof(struct stack_block)))
static struct stack_block *stackp; static struct stack_block *stackp;
static struct stackmark *markp;
char *stacknxt; char *stacknxt;
int stacknleft; int stacknleft;
char *sstrend; char *sstrend;
@@ -186,8 +185,9 @@ setstackmark(struct stackmark *mark)
mark->stackp = stackp; mark->stackp = stackp;
mark->stacknxt = stacknxt; mark->stacknxt = stacknxt;
mark->stacknleft = stacknleft; mark->stacknleft = stacknleft;
mark->marknext = markp; /* Ensure this block stays in place. */
markp = mark; if (stackp != NULL && stacknxt == SPACE(stackp))
stalloc(1);
} }
@@ -197,7 +197,6 @@ popstackmark(struct stackmark *mark)
struct stack_block *sp; struct stack_block *sp;
INTOFF; INTOFF;
markp = mark->marknext;
while (stackp != mark->stackp) { while (stackp != mark->stackp) {
sp = stackp; sp = stackp;
stackp = sp->prev; stackp = sp->prev;
@@ -229,7 +228,6 @@ growstackblock(int min)
int oldlen; int oldlen;
struct stack_block *sp; struct stack_block *sp;
struct stack_block *oldstackp; struct stack_block *oldstackp;
struct stackmark *xmark;
if (min < stacknleft) if (min < stacknleft)
min = stacknleft; min = stacknleft;
@@ -254,18 +252,6 @@ growstackblock(int min)
stacknxt = SPACE(sp); stacknxt = SPACE(sp);
stacknleft = newlen - (stacknxt - (char*)sp); stacknleft = newlen - (stacknxt - (char*)sp);
sstrend = stacknxt + stacknleft; sstrend = stacknxt + stacknleft;
/*
* Stack marks pointing to the start of the old block
* must be relocated to point to the new block
*/
xmark = markp;
while (xmark != NULL && xmark->stackp == oldstackp) {
xmark->stackp = stackp;
xmark->stacknxt = stacknxt;
xmark->stacknleft = stacknleft;
xmark = xmark->marknext;
}
INTON; INTON;
} else { } else {
newlen -= ALIGN(sizeof(struct stack_block)); newlen -= ALIGN(sizeof(struct stack_block));
-1
View File
@@ -39,7 +39,6 @@ struct stackmark {
struct stack_block *stackp; struct stack_block *stackp;
char *stacknxt; char *stacknxt;
int stacknleft; int stacknleft;
struct stackmark *marknext;
}; };
+20 -3
View File
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include "error.h" #include "error.h"
#include "mystring.h" #include "mystring.h"
#include "syntax.h" #include "syntax.h"
#include "trap.h"
#undef eflag #undef eflag
@@ -102,6 +103,8 @@ readcmd(int argc __unused, char **argv __unused)
struct timeval tv; struct timeval tv;
char *tvptr; char *tvptr;
fd_set ifds; fd_set ifds;
ssize_t nread;
int sig;
rflag = 0; rflag = 0;
prompt = NULL; prompt = NULL;
@@ -156,8 +159,10 @@ readcmd(int argc __unused, char **argv __unused)
/* /*
* If there's nothing ready, return an error. * If there's nothing ready, return an error.
*/ */
if (status <= 0) if (status <= 0) {
return(1); sig = pendingsig;
return (128 + (sig != 0 ? sig : SIGALRM));
}
} }
status = 0; status = 0;
@@ -165,7 +170,19 @@ readcmd(int argc __unused, char **argv __unused)
backslash = 0; backslash = 0;
STARTSTACKSTR(p); STARTSTACKSTR(p);
for (;;) { for (;;) {
if (read(STDIN_FILENO, &c, 1) != 1) { nread = read(STDIN_FILENO, &c, 1);
if (nread == -1) {
if (errno == EINTR) {
sig = pendingsig;
if (sig == 0)
continue;
status = 128 + sig;
break;
}
warning("read error: %s", strerror(errno));
status = 2;
break;
} else if (nread != 1) {
status = 1; status = 1;
break; break;
} }
-480
View File
@@ -1,480 +0,0 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Kenneth Almquist.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char const copyright[] =
"@(#) Copyright (c) 1991, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)mkinit.c 8.2 (Berkeley) 5/4/95";
#endif
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* This program scans all the source files for code to handle various
* special events and combines this code into one file. This (allegedly)
* improves the structure of the program since there is no need for
* anyone outside of a module to know that that module performs special
* operations on particular events.
*
* Usage: mkinit sourcefile...
*/
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
/*
* OUTFILE is the name of the output file. Output is initially written
* to the file OUTTEMP, which is then moved to OUTFILE.
*/
#define OUTFILE "init.c"
#define OUTTEMP "init.c.new"
/*
* A text structure is basically just a string that grows as more characters
* are added onto the end of it. It is implemented as a linked list of
* blocks of characters. The routines addstr and addchar append a string
* or a single character, respectively, to a text structure. Writetext
* writes the contents of a text structure to a file.
*/
#define BLOCKSIZE 512
struct text {
char *nextc;
int nleft;
struct block *start;
struct block *last;
};
struct block {
struct block *next;
char text[BLOCKSIZE];
};
/*
* There is one event structure for each event that mkinit handles.
*/
struct event {
const char *name; /* name of event (e.g. RESET) */
const char *routine; /* name of routine called on event */
const char *comment; /* comment describing routine */
struct text code; /* code for handling event */
};
char writer[] = "\
/*\n\
* This file was generated by the mkinit program.\n\
*/\n\
\n";
char reset[] = "\
/*\n\
* This routine is called when an error or an interrupt occurs in an\n\
* interactive shell and control is returned to the main command loop.\n\
*/\n";
struct event event[] = {
{ "RESET", "reset", reset, { NULL, 0, NULL, NULL } },
{ NULL, NULL, NULL, { NULL, 0, NULL, NULL } }
};
const char *curfile; /* current file */
int linno; /* current line */
char *header_files[200]; /* list of header files */
struct text defines; /* #define statements */
struct text decls; /* declarations */
int amiddecls; /* for formatting */
void readfile(const char *);
int match(const char *, const char *);
int gooddefine(const char *);
void doevent(struct event *, FILE *, const char *);
void doinclude(char *);
void dodecl(char *, FILE *);
void output(void);
void addstr(const char *, struct text *);
void addchar(int, struct text *);
void writetext(struct text *, FILE *);
FILE *ckfopen(const char *, const char *);
void *ckmalloc(size_t);
char *savestr(const char *);
void error(const char *);
#define equal(s1, s2) (strcmp(s1, s2) == 0)
int
main(int argc __unused, char *argv[])
{
char **ap;
header_files[0] = savestr("\"shell.h\"");
header_files[1] = savestr("\"mystring.h\"");
header_files[2] = savestr("\"init.h\"");
for (ap = argv + 1 ; *ap ; ap++)
readfile(*ap);
output();
rename(OUTTEMP, OUTFILE);
exit(0);
}
/*
* Parse an input file.
*/
void
readfile(const char *fname)
{
FILE *fp;
char line[1024];
struct event *ep;
fp = ckfopen(fname, "r");
curfile = fname;
linno = 0;
amiddecls = 0;
while (fgets(line, sizeof line, fp) != NULL) {
linno++;
for (ep = event ; ep->name ; ep++) {
if (line[0] == ep->name[0] && match(ep->name, line)) {
doevent(ep, fp, fname);
break;
}
}
if (line[0] == 'I' && match("INCLUDE", line))
doinclude(line);
if (line[0] == 'M' && match("MKINIT", line))
dodecl(line, fp);
if (line[0] == '#' && gooddefine(line)) {
char *cp;
char line2[1024];
static const char undef[] = "#undef ";
strcpy(line2, line);
memcpy(line2, undef, sizeof(undef) - 1);
cp = line2 + sizeof(undef) - 1;
while(*cp && (*cp == ' ' || *cp == '\t'))
cp++;
while(*cp && *cp != ' ' && *cp != '\t' && *cp != '\n')
cp++;
*cp++ = '\n'; *cp = '\0';
addstr(line2, &defines);
addstr(line, &defines);
}
}
fclose(fp);
}
int
match(const char *name, const char *line)
{
const char *p, *q;
p = name, q = line;
while (*p) {
if (*p++ != *q++)
return 0;
}
if (*q != '{' && *q != ' ' && *q != '\t' && *q != '\n')
return 0;
return 1;
}
int
gooddefine(const char *line)
{
const char *p;
if (! match("#define", line))
return 0; /* not a define */
p = line + 7;
while (*p == ' ' || *p == '\t')
p++;
while (*p != ' ' && *p != '\t') {
if (*p == '(')
return 0; /* macro definition */
p++;
}
while (*p != '\n' && *p != '\0')
p++;
if (p[-1] == '\\')
return 0; /* multi-line definition */
return 1;
}
void
doevent(struct event *ep, FILE *fp, const char *fname)
{
char line[1024];
int indent;
const char *p;
sprintf(line, "\n /* from %s: */\n", fname);
addstr(line, &ep->code);
addstr(" {\n", &ep->code);
for (;;) {
linno++;
if (fgets(line, sizeof line, fp) == NULL)
error("Unexpected EOF");
if (equal(line, "}\n"))
break;
indent = 6;
for (p = line ; *p == '\t' ; p++)
indent += 8;
for ( ; *p == ' ' ; p++)
indent++;
if (*p == '\n' || *p == '#')
indent = 0;
while (indent >= 8) {
addchar('\t', &ep->code);
indent -= 8;
}
while (indent > 0) {
addchar(' ', &ep->code);
indent--;
}
addstr(p, &ep->code);
}
addstr(" }\n", &ep->code);
}
void
doinclude(char *line)
{
char *p;
char *name;
char **pp;
for (p = line ; *p != '"' && *p != '<' && *p != '\0' ; p++);
if (*p == '\0')
error("Expecting '\"' or '<'");
name = p;
while (*p != ' ' && *p != '\t' && *p != '\n')
p++;
if (p[-1] != '"' && p[-1] != '>')
error("Missing terminator");
*p = '\0';
/* name now contains the name of the include file */
for (pp = header_files ; *pp && ! equal(*pp, name) ; pp++);
if (*pp == NULL)
*pp = savestr(name);
}
void
dodecl(char *line1, FILE *fp)
{
char line[1024];
char *p, *q;
if (strcmp(line1, "MKINIT\n") == 0) { /* start of struct/union decl */
addchar('\n', &decls);
do {
linno++;
if (fgets(line, sizeof line, fp) == NULL)
error("Unterminated structure declaration");
addstr(line, &decls);
} while (line[0] != '}');
amiddecls = 0;
} else {
if (! amiddecls)
addchar('\n', &decls);
q = NULL;
for (p = line1 + 6 ; *p && strchr("=/\n", *p) == NULL; p++)
continue;
if (*p == '=') { /* eliminate initialization */
for (q = p ; *q && *q != ';' ; q++);
if (*q == '\0')
q = NULL;
else {
while (p[-1] == ' ')
p--;
*p = '\0';
}
}
addstr("extern", &decls);
addstr(line1 + 6, &decls);
if (q != NULL)
addstr(q, &decls);
amiddecls = 1;
}
}
/*
* Write the output to the file OUTTEMP.
*/
void
output(void)
{
FILE *fp;
char **pp;
struct event *ep;
fp = ckfopen(OUTTEMP, "w");
fputs(writer, fp);
for (pp = header_files ; *pp ; pp++)
fprintf(fp, "#include %s\n", *pp);
fputs("\n\n\n", fp);
writetext(&defines, fp);
fputs("\n\n", fp);
writetext(&decls, fp);
for (ep = event ; ep->name ; ep++) {
fputs("\n\n\n", fp);
fputs(ep->comment, fp);
fprintf(fp, "\nvoid\n%s(void)\n{\n", ep->routine);
writetext(&ep->code, fp);
fprintf(fp, "}\n");
}
fclose(fp);
}
/*
* A text structure is simply a block of text that is kept in memory.
* Addstr appends a string to the text struct, and addchar appends a single
* character.
*/
void
addstr(const char *s, struct text *text)
{
while (*s) {
if (--text->nleft < 0)
addchar(*s++, text);
else
*text->nextc++ = *s++;
}
}
void
addchar(int c, struct text *text)
{
struct block *bp;
if (--text->nleft < 0) {
bp = ckmalloc(sizeof *bp);
if (text->start == NULL)
text->start = bp;
else
text->last->next = bp;
text->last = bp;
text->nextc = bp->text;
text->nleft = BLOCKSIZE - 1;
}
*text->nextc++ = c;
}
/*
* Write the contents of a text structure to a file.
*/
void
writetext(struct text *text, FILE *fp)
{
struct block *bp;
if (text->start != NULL) {
for (bp = text->start ; bp != text->last ; bp = bp->next)
fwrite(bp->text, sizeof (char), BLOCKSIZE, fp);
fwrite(bp->text, sizeof (char), BLOCKSIZE - text->nleft, fp);
}
}
FILE *
ckfopen(const char *file, const char *mode)
{
FILE *fp;
if ((fp = fopen(file, mode)) == NULL) {
fprintf(stderr, "Can't open %s: %s\n", file, strerror(errno));
exit(2);
}
return fp;
}
void *
ckmalloc(size_t nbytes)
{
char *p;
if ((p = malloc(nbytes)) == NULL)
error("Out of space");
return p;
}
char *
savestr(const char *s)
{
char *p;
p = ckmalloc(strlen(s) + 1);
strcpy(p, s);
return p;
}
void
error(const char *msg)
{
if (curfile != NULL)
fprintf(stderr, "%s:%d: ", curfile, linno);
fprintf(stderr, "%s\n", msg);
exit(2);
}
-19
View File
@@ -75,25 +75,6 @@ struct output memout = {NULL, 0, NULL, 0, MEM_OUT, 0};
struct output *out1 = &output; struct output *out1 = &output;
struct output *out2 = &errout; struct output *out2 = &errout;
#ifdef mkinit
INCLUDE "output.h"
INCLUDE "memalloc.h"
RESET {
out1 = &output;
out2 = &errout;
if (memout.buf != NULL) {
ckfree(memout.buf);
memout.buf = NULL;
}
}
#endif
void void
outcslow(int c, struct output *file) outcslow(int c, struct output *file)
{ {
+79 -110
View File
@@ -96,9 +96,9 @@ static struct heredoc *heredoclist; /* list of here documents to read */
static int doprompt; /* if set, prompt the user */ static int doprompt; /* if set, prompt the user */
static int needprompt; /* true if interactive and at start of line */ static int needprompt; /* true if interactive and at start of line */
static int lasttoken; /* last token read */ static int lasttoken; /* last token read */
MKINIT int tokpushback; /* last token pushed back */ static int tokpushback; /* last token pushed back */
static char *wordtext; /* text of last word returned by readtoken */ static char *wordtext; /* text of last word returned by readtoken */
MKINIT int checkkwd; /* 1 == check for kwds, 2 == also eat newlines */ static int checkkwd;
static struct nodelist *backquotelist; static struct nodelist *backquotelist;
static union node *redirnode; static union node *redirnode;
static struct heredoc *heredoc; static struct heredoc *heredoc;
@@ -108,12 +108,13 @@ static int funclinno; /* line # where the current function started */
static struct parser_temp *parser_temp; static struct parser_temp *parser_temp;
static union node *list(int, int); static union node *list(int);
static union node *andor(void); static union node *andor(void);
static union node *pipeline(void); static union node *pipeline(void);
static union node *command(void); static union node *command(void);
static union node *simplecmd(union node **, union node *); static union node *simplecmd(union node **, union node *);
static union node *makename(void); static union node *makename(void);
static union node *makebinary(int type, union node *n1, union node *n2);
static void parsefname(void); static void parsefname(void);
static void parseheredoc(void); static void parseheredoc(void);
static int peektoken(void); static int peektoken(void);
@@ -121,6 +122,7 @@ static int readtoken(void);
static int xxreadtoken(void); static int xxreadtoken(void);
static int readtoken1(int, const char *, const char *, int); static int readtoken1(int, const char *, const char *, int);
static int noexpand(char *); static int noexpand(char *);
static void consumetoken(int);
static void synexpect(int) __dead2; static void synexpect(int) __dead2;
static void synerror(const char *) __dead2; static void synerror(const char *) __dead2;
static void setprompt(int); static void setprompt(int);
@@ -210,6 +212,7 @@ parsecmd(int interact)
heredoclist = NULL; heredoclist = NULL;
tokpushback = 0; tokpushback = 0;
checkkwd = 0;
doprompt = interact; doprompt = interact;
if (doprompt) if (doprompt)
setprompt(1); setprompt(1);
@@ -222,18 +225,18 @@ parsecmd(int interact)
if (t == TNL) if (t == TNL)
return NULL; return NULL;
tokpushback++; tokpushback++;
return list(1, 1); return list(1);
} }
static union node * static union node *
list(int nlflag, int erflag) list(int nlflag)
{ {
union node *ntop, *n1, *n2, *n3; union node *ntop, *n1, *n2, *n3;
int tok; int tok;
checkkwd = CHKNL | CHKKWD | CHKALIAS; checkkwd = CHKNL | CHKKWD | CHKALIAS;
if (!nlflag && !erflag && tokendlist[peektoken()]) if (!nlflag && tokendlist[peektoken()])
return NULL; return NULL;
ntop = n1 = NULL; ntop = n1 = NULL;
for (;;) { for (;;) {
@@ -255,17 +258,11 @@ list(int nlflag, int erflag)
if (ntop == NULL) if (ntop == NULL)
ntop = n2; ntop = n2;
else if (n1 == NULL) { else if (n1 == NULL) {
n1 = (union node *)stalloc(sizeof (struct nbinary)); n1 = makebinary(NSEMI, ntop, n2);
n1->type = NSEMI;
n1->nbinary.ch1 = ntop;
n1->nbinary.ch2 = n2;
ntop = n1; ntop = n1;
} }
else { else {
n3 = (union node *)stalloc(sizeof (struct nbinary)); n3 = makebinary(NSEMI, n1->nbinary.ch2, n2);
n3->type = NSEMI;
n3->nbinary.ch1 = n1->nbinary.ch2;
n3->nbinary.ch2 = n2;
n1->nbinary.ch2 = n3; n1->nbinary.ch2 = n3;
n1 = n3; n1 = n3;
} }
@@ -286,8 +283,7 @@ list(int nlflag, int erflag)
tokpushback++; tokpushback++;
} }
checkkwd = CHKNL | CHKKWD | CHKALIAS; checkkwd = CHKNL | CHKKWD | CHKALIAS;
if (!nlflag && (erflag ? peektoken() == TEOF : if (!nlflag && tokendlist[peektoken()])
tokendlist[peektoken()]))
return ntop; return ntop;
break; break;
case TEOF: case TEOF:
@@ -297,7 +293,7 @@ list(int nlflag, int erflag)
pungetc(); /* push back EOF on input */ pungetc(); /* push back EOF on input */
return ntop; return ntop;
default: default:
if (nlflag || erflag) if (nlflag)
synexpect(-1); synexpect(-1);
tokpushback++; tokpushback++;
return ntop; return ntop;
@@ -310,10 +306,10 @@ list(int nlflag, int erflag)
static union node * static union node *
andor(void) andor(void)
{ {
union node *n1, *n2, *n3; union node *n;
int t; int t;
n1 = pipeline(); n = pipeline();
for (;;) { for (;;) {
if ((t = readtoken()) == TAND) { if ((t = readtoken()) == TAND) {
t = NAND; t = NAND;
@@ -321,14 +317,9 @@ andor(void)
t = NOR; t = NOR;
} else { } else {
tokpushback++; tokpushback++;
return n1; return n;
} }
n2 = pipeline(); n = makebinary(t, n, pipeline());
n3 = (union node *)stalloc(sizeof (struct nbinary));
n3->type = t;
n3->nbinary.ch1 = n1;
n3->nbinary.ch2 = n2;
n1 = n3;
} }
} }
@@ -410,49 +401,39 @@ command(void)
case TIF: case TIF:
n1 = (union node *)stalloc(sizeof (struct nif)); n1 = (union node *)stalloc(sizeof (struct nif));
n1->type = NIF; n1->type = NIF;
if ((n1->nif.test = list(0, 0)) == NULL) if ((n1->nif.test = list(0)) == NULL)
synexpect(-1); synexpect(-1);
if (readtoken() != TTHEN) consumetoken(TTHEN);
synexpect(TTHEN); n1->nif.ifpart = list(0);
n1->nif.ifpart = list(0, 0);
n2 = n1; n2 = n1;
while (readtoken() == TELIF) { while (readtoken() == TELIF) {
n2->nif.elsepart = (union node *)stalloc(sizeof (struct nif)); n2->nif.elsepart = (union node *)stalloc(sizeof (struct nif));
n2 = n2->nif.elsepart; n2 = n2->nif.elsepart;
n2->type = NIF; n2->type = NIF;
if ((n2->nif.test = list(0, 0)) == NULL) if ((n2->nif.test = list(0)) == NULL)
synexpect(-1); synexpect(-1);
if (readtoken() != TTHEN) consumetoken(TTHEN);
synexpect(TTHEN); n2->nif.ifpart = list(0);
n2->nif.ifpart = list(0, 0);
} }
if (lasttoken == TELSE) if (lasttoken == TELSE)
n2->nif.elsepart = list(0, 0); n2->nif.elsepart = list(0);
else { else {
n2->nif.elsepart = NULL; n2->nif.elsepart = NULL;
tokpushback++; tokpushback++;
} }
if (readtoken() != TFI) consumetoken(TFI);
synexpect(TFI);
checkkwd = CHKKWD | CHKALIAS; checkkwd = CHKKWD | CHKALIAS;
break; break;
case TWHILE: case TWHILE:
case TUNTIL: { case TUNTIL:
int got; t = lasttoken;
n1 = (union node *)stalloc(sizeof (struct nbinary)); if ((n1 = list(0)) == NULL)
n1->type = (lasttoken == TWHILE)? NWHILE : NUNTIL;
if ((n1->nbinary.ch1 = list(0, 0)) == NULL)
synexpect(-1); synexpect(-1);
if ((got=readtoken()) != TDO) { consumetoken(TDO);
TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : "")); n1 = makebinary((t == TWHILE)? NWHILE : NUNTIL, n1, list(0));
synexpect(TDO); consumetoken(TDONE);
}
n1->nbinary.ch2 = list(0, 0);
if (readtoken() != TDONE)
synexpect(TDONE);
checkkwd = CHKKWD | CHKALIAS; checkkwd = CHKKWD | CHKALIAS;
break; break;
}
case TFOR: case TFOR:
if (readtoken() != TWORD || quoteflag || ! goodname(wordtext)) if (readtoken() != TWORD || quoteflag || ! goodname(wordtext))
synerror("Bad for loop variable"); synerror("Bad for loop variable");
@@ -464,10 +445,7 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
if (lasttoken == TWORD && ! quoteflag && equal(wordtext, "in")) { if (lasttoken == TWORD && ! quoteflag && equal(wordtext, "in")) {
app = &ap; app = &ap;
while (readtoken() == TWORD) { while (readtoken() == TWORD) {
n2 = (union node *)stalloc(sizeof (struct narg)); n2 = makename();
n2->type = NARG;
n2->narg.text = wordtext;
n2->narg.backquote = backquotelist;
*app = n2; *app = n2;
app = &n2->narg.next; app = &n2->narg.next;
} }
@@ -499,21 +477,15 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
t = TEND; t = TEND;
else else
synexpect(-1); synexpect(-1);
n1->nfor.body = list(0, 0); n1->nfor.body = list(0);
if (readtoken() != t) consumetoken(t);
synexpect(t);
checkkwd = CHKKWD | CHKALIAS; checkkwd = CHKKWD | CHKALIAS;
break; break;
case TCASE: case TCASE:
n1 = (union node *)stalloc(sizeof (struct ncase)); n1 = (union node *)stalloc(sizeof (struct ncase));
n1->type = NCASE; n1->type = NCASE;
if (readtoken() != TWORD) consumetoken(TWORD);
synexpect(TWORD); n1->ncase.expr = makename();
n1->ncase.expr = n2 = (union node *)stalloc(sizeof (struct narg));
n2->type = NARG;
n2->narg.text = wordtext;
n2->narg.backquote = backquotelist;
n2->narg.next = NULL;
while (readtoken() == TNL); while (readtoken() == TNL);
if (lasttoken != TWORD || ! equal(wordtext, "in")) if (lasttoken != TWORD || ! equal(wordtext, "in"))
synerror("expecting \"in\""); synerror("expecting \"in\"");
@@ -526,10 +498,7 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
if (lasttoken == TLP) if (lasttoken == TLP)
readtoken(); readtoken();
for (;;) { for (;;) {
*app = ap = (union node *)stalloc(sizeof (struct narg)); *app = ap = makename();
ap->type = NARG;
ap->narg.text = wordtext;
ap->narg.backquote = backquotelist;
checkkwd = CHKNL | CHKKWD; checkkwd = CHKNL | CHKKWD;
if (readtoken() != TPIPE) if (readtoken() != TPIPE)
break; break;
@@ -539,7 +508,7 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
ap->narg.next = NULL; ap->narg.next = NULL;
if (lasttoken != TRP) if (lasttoken != TRP)
synexpect(TRP); synexpect(TRP);
cp->nclist.body = list(0, 0); cp->nclist.body = list(0);
checkkwd = CHKNL | CHKKWD | CHKALIAS; checkkwd = CHKNL | CHKKWD | CHKALIAS;
if ((t = readtoken()) != TESAC) { if ((t = readtoken()) != TESAC) {
@@ -559,34 +528,31 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
case TLP: case TLP:
n1 = (union node *)stalloc(sizeof (struct nredir)); n1 = (union node *)stalloc(sizeof (struct nredir));
n1->type = NSUBSHELL; n1->type = NSUBSHELL;
n1->nredir.n = list(0, 0); n1->nredir.n = list(0);
n1->nredir.redirect = NULL; n1->nredir.redirect = NULL;
if (readtoken() != TRP) consumetoken(TRP);
synexpect(TRP);
checkkwd = CHKKWD | CHKALIAS; checkkwd = CHKKWD | CHKALIAS;
is_subshell = 1; is_subshell = 1;
break; break;
case TBEGIN: case TBEGIN:
n1 = list(0, 0); n1 = list(0);
if (readtoken() != TEND) consumetoken(TEND);
synexpect(TEND);
checkkwd = CHKKWD | CHKALIAS; checkkwd = CHKKWD | CHKALIAS;
break; break;
/* Handle an empty command like other simple commands. */ /* A simple command must have at least one redirection or word. */
case TBACKGND: case TBACKGND:
case TSEMI: case TSEMI:
case TAND: case TAND:
case TOR: case TOR:
/* case TPIPE:
* An empty command before a ; doesn't make much sense, and case TENDCASE:
* should certainly be disallowed in the case of `if ;'. case TFALLTHRU:
*/ case TEOF:
case TNL:
case TRP:
if (!redir) if (!redir)
synexpect(-1); synexpect(-1);
case TNL:
case TEOF:
case TWORD: case TWORD:
case TRP:
tokpushback++; tokpushback++;
n1 = simplecmd(rpp, redir); n1 = simplecmd(rpp, redir);
return n1; return n1;
@@ -644,10 +610,7 @@ simplecmd(union node **rpp, union node *redir)
for (;;) { for (;;) {
checkkwd = savecheckkwd; checkkwd = savecheckkwd;
if (readtoken() == TWORD) { if (readtoken() == TWORD) {
n = (union node *)stalloc(sizeof (struct narg)); n = makename();
n->type = NARG;
n->narg.text = wordtext;
n->narg.backquote = backquotelist;
*app = n; *app = n;
app = &n->narg.next; app = &n->narg.next;
if (savecheckkwd != 0 && !isassignment(wordtext)) if (savecheckkwd != 0 && !isassignment(wordtext))
@@ -659,8 +622,7 @@ simplecmd(union node **rpp, union node *redir)
} else if (lasttoken == TLP && app == &args->narg.next } else if (lasttoken == TLP && app == &args->narg.next
&& rpp == orig_rpp) { && rpp == orig_rpp) {
/* We have a function */ /* We have a function */
if (readtoken() != TRP) consumetoken(TRP);
synexpect(TRP);
funclinno = plinno; funclinno = plinno;
/* /*
* - Require plain text. * - Require plain text.
@@ -708,6 +670,18 @@ makename(void)
return n; return n;
} }
static union node *
makebinary(int type, union node *n1, union node *n2)
{
union node *n;
n = (union node *)stalloc(sizeof (struct nbinary));
n->type = type;
n->nbinary.ch1 = n1;
n->nbinary.ch2 = n2;
return (n);
}
void void
fixredir(union node *n, const char *text, int err) fixredir(union node *n, const char *text, int err)
{ {
@@ -734,8 +708,7 @@ parsefname(void)
{ {
union node *n = redirnode; union node *n = redirnode;
if (readtoken() != TWORD) consumetoken(TWORD);
synexpect(-1);
if (n->type == NHERE) { if (n->type == NHERE) {
struct heredoc *here = heredoc; struct heredoc *here = heredoc;
struct heredoc *p; struct heredoc *p;
@@ -786,11 +759,7 @@ parseheredoc(void)
} }
readtoken1(pgetc(), here->here->type == NHERE? SQSYNTAX : DQSYNTAX, readtoken1(pgetc(), here->here->type == NHERE? SQSYNTAX : DQSYNTAX,
here->eofmark, here->striptabs); here->eofmark, here->striptabs);
n = (union node *)stalloc(sizeof (struct narg)); n = makename();
n->narg.type = NARG;
n->narg.next = NULL;
n->narg.text = wordtext;
n->narg.backquote = backquotelist;
here->here->nhere.doc = n; here->here->nhere.doc = n;
} }
} }
@@ -1090,14 +1059,14 @@ parsebackq(char *out, struct nodelist **pbqlist,
doprompt = 0; doprompt = 0;
} }
n = list(0, oldstyle); n = list(0);
if (oldstyle) if (oldstyle) {
if (peektoken() != TEOF)
synexpect(-1);
doprompt = saveprompt; doprompt = saveprompt;
else { } else
if (readtoken() != TRP) consumetoken(TRP);
synexpect(TRP);
}
(*nlpp)->n = n; (*nlpp)->n = n;
if (oldstyle) { if (oldstyle) {
@@ -1819,14 +1788,6 @@ parsearith: {
} /* end of readtoken */ } /* end of readtoken */
#ifdef mkinit
RESET {
tokpushback = 0;
checkkwd = 0;
}
#endif
/* /*
* Returns true if the text contains nothing to expand (no dollar signs * Returns true if the text contains nothing to expand (no dollar signs
* or backquotes). * or backquotes).
@@ -1888,6 +1849,14 @@ isassignment(const char *p)
} }
static void
consumetoken(int token)
{
if (readtoken() != token)
synexpect(token);
}
/* /*
* Called when an unexpected token is read during the parse. The argument * Called when an unexpected token is read during the parse. The argument
* is the token that is expected, or -1 if more than one type of token can * is the token that is expected, or -1 if more than one type of token can
+2 -4
View File
@@ -68,11 +68,9 @@
/* /*
* NEOF is returned by parsecmd when it encounters an end of file. It * NEOF is returned by parsecmd when it encounters an end of file. It
* must be distinct from NULL, so we use the address of a variable that * must be distinct from NULL.
* happens to be handy.
*/ */
extern int tokpushback; #define NEOF ((union node *)-1)
#define NEOF ((union node *)&tokpushback)
extern int whichprompt; /* 1 == PS1, 2 == PS2 */ extern int whichprompt; /* 1 == PS1, 2 == PS2 */
extern const char *const parsekwd[]; extern const char *const parsekwd[];
+3 -20
View File
@@ -66,14 +66,13 @@ __FBSDID("$FreeBSD$");
#define CLOSED -1 /* fd was not open before redir */ #define CLOSED -1 /* fd was not open before redir */
MKINIT
struct redirtab { struct redirtab {
struct redirtab *next; struct redirtab *next;
int renamed[10]; int renamed[10];
}; };
MKINIT struct redirtab *redirlist; static struct redirtab *redirlist;
/* /*
* We keep track of whether or not fd0 has been redirected. This is for * We keep track of whether or not fd0 has been redirected. This is for
@@ -121,7 +120,7 @@ redirect(union node *redir, int flags)
if ((flags & REDIR_PUSH) && sv->renamed[fd] == EMPTY) { if ((flags & REDIR_PUSH) && sv->renamed[fd] == EMPTY) {
INTOFF; INTOFF;
if ((i = fcntl(fd, F_DUPFD, 10)) == -1) { if ((i = fcntl(fd, F_DUPFD_CLOEXEC, 10)) == -1) {
switch (errno) { switch (errno) {
case EBADF: case EBADF:
i = CLOSED; i = CLOSED;
@@ -131,8 +130,7 @@ redirect(union node *redir, int flags)
error("%d: %s", fd, strerror(errno)); error("%d: %s", fd, strerror(errno));
break; break;
} }
} else }
(void)fcntl(i, F_SETFD, FD_CLOEXEC);
sv->renamed[fd] = i; sv->renamed[fd] = i;
INTON; INTON;
} }
@@ -321,21 +319,6 @@ popredir(void)
INTON; INTON;
} }
/*
* Undo all redirections. Called on error or interrupt.
*/
#ifdef mkinit
INCLUDE "redir.h"
RESET {
while (redirlist)
popredir();
}
#endif
/* Return true if fd 0 has already been redirected at least once. */ /* Return true if fd 0 has already been redirected at least once. */
int int
fd0_redirected_p(void) fd0_redirected_p(void)
+48 -7
View File
@@ -32,7 +32,7 @@
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd March 24, 2013 .Dd June 14, 2013
.Dt SH 1 .Dt SH 1
.Os .Os
.Sh NAME .Sh NAME
@@ -1036,6 +1036,9 @@ The current working directory as set by
The file creation mask as set by The file creation mask as set by
.Ic umask . .Ic umask .
.It .It
Resource limits as set by
.Ic ulimit .
.It
References to open files. References to open files.
.It .It
Traps as set by Traps as set by
@@ -1142,8 +1145,10 @@ command is
.Pp .Pp
.D1 Ic return Op Ar exitstatus .D1 Ic return Op Ar exitstatus
.Pp .Pp
It terminates the current executional scope, returning from the previous It terminates the current executional scope, returning from the closest
nested function, sourced script, or shell instance, in that order. nested function or sourced script;
if no function or sourced script is being executed,
it exits the shell instance.
The The
.Ic return .Ic return
command is implemented as a special built-in command. command is implemented as a special built-in command.
@@ -1340,9 +1345,33 @@ The primary prompt string, which defaults to
.Dq Li "$ " , .Dq Li "$ " ,
unless you are the superuser, in which case it defaults to unless you are the superuser, in which case it defaults to
.Dq Li "# " . .Dq Li "# " .
.Va PS1
may include any of the following formatting sequences,
which are replaced by the given information:
.Bl -tag -width indent
.It Li \eH
The local hostname.
.It Li \eh
The fully-qualified hostname.
.It Li \eW
The final component of the current working directory.
.It Li \ew
The entire path of the current working directory.
.It Li \e$
Superuser status.
.Dq Li "$ "
for normal users and
.Dq Li "# "
for superusers.
.It Li \e\e
A literal backslash.
.El
.It Va PS2 .It Va PS2
The secondary prompt string, which defaults to The secondary prompt string, which defaults to
.Dq Li "> " . .Dq Li "> " .
.Va PS2
may include any of the formatting sequences from
.Va PS1 .
.It Va PS4 .It Va PS4
The prefix for the trace output (if The prefix for the trace output (if
.Fl x .Fl x
@@ -2348,7 +2377,9 @@ option is specified and the
elapses before a complete line of input is supplied, elapses before a complete line of input is supplied,
the the
.Ic read .Ic read
command will return an exit status of 1 without assigning any values. command will return an exit status as if terminated by
.Dv SIGALRM
without assigning any values.
The The
.Ar timeout .Ar timeout
value may optionally be followed by one of value may optionally be followed by one of
@@ -2364,6 +2395,11 @@ is assumed.
The The
.Fl e .Fl e
option exists only for backward compatibility with older scripts. option exists only for backward compatibility with older scripts.
.Pp
The exit status is 0 on success, 1 on end of file,
between 2 and 128 if an error occurs
and greater than 128 if a trapped signal interrupts
.Ic read .
.It Ic readonly Oo Fl p Oc Op Ar name ... .It Ic readonly Oo Fl p Oc Op Ar name ...
Each specified Each specified
.Ar name .Ar name
@@ -2611,12 +2647,17 @@ If the
option is specified, the option is specified, the
.Ar name .Ar name
arguments are treated as function names. arguments are treated as function names.
.It Ic wait Op Ar job .It Ic wait Op Ar job ...
Wait for the specified Wait for each specified
.Ar job .Ar job
to complete and return the exit status of the last process in the to complete and return the exit status of the last process in the
last specified
.Ar job . .Ar job .
If the argument is omitted, wait for all jobs to complete If any
.Ar job
specified is unknown to the shell, it is treated as if it
were a known job that exited with exit status 127.
If no operands are given, wait for all jobs to complete
and return an exit status of zero. and return an exit status of zero.
.El .El
.Ss Commandline Editing .Ss Commandline Editing
-1
View File
@@ -63,7 +63,6 @@ typedef intmax_t arith_t;
#define ARITH_MAX INTMAX_MAX #define ARITH_MAX INTMAX_MAX
typedef void *pointer; typedef void *pointer;
#define MKINIT /* empty */
#include <sys/cdefs.h> #include <sys/cdefs.h>
+5 -13
View File
@@ -72,8 +72,9 @@ __FBSDID("$FreeBSD$");
#define S_RESET 5 /* temporary - to reset a hard ignored sig */ #define S_RESET 5 /* temporary - to reset a hard ignored sig */
MKINIT char sigmode[NSIG]; /* current value of signal */ static char sigmode[NSIG]; /* current value of signal */
volatile sig_atomic_t pendingsig; /* indicates some signal received */ volatile sig_atomic_t pendingsig; /* indicates some signal received */
volatile sig_atomic_t pendingsig_waitcmd; /* indicates SIGINT/SIGQUIT received */
int in_dotrap; /* do we execute in a trap handler? */ int in_dotrap; /* do we execute in a trap handler? */
static char *volatile trap[NSIG]; /* trap handler commands */ static char *volatile trap[NSIG]; /* trap handler commands */
static volatile sig_atomic_t gotsig[NSIG]; static volatile sig_atomic_t gotsig[NSIG];
@@ -389,23 +390,13 @@ onsig(int signo)
} }
/* If we are currently in a wait builtin, prepare to break it */ /* If we are currently in a wait builtin, prepare to break it */
if ((signo == SIGINT || signo == SIGQUIT) && in_waitcmd != 0) { if (signo == SIGINT || signo == SIGQUIT)
breakwaitcmd = 1; pendingsig_waitcmd = signo;
pendingsig = signo;
}
if (trap[signo] != NULL && trap[signo][0] != '\0' && if (trap[signo] != NULL && trap[signo][0] != '\0' &&
(signo != SIGCHLD || !ignore_sigchld)) { (signo != SIGCHLD || !ignore_sigchld)) {
gotsig[signo] = 1; gotsig[signo] = 1;
pendingsig = signo; pendingsig = signo;
/*
* If a trap is set, not ignored and not the null command, we
* need to make sure traps are executed even when a child
* blocks signals.
*/
if (Tflag && !(trap[signo][0] == ':' && trap[signo][1] == '\0'))
breakwaitcmd = 1;
} }
#ifndef NO_HISTORY #ifndef NO_HISTORY
@@ -428,6 +419,7 @@ dotrap(void)
in_dotrap++; in_dotrap++;
for (;;) { for (;;) {
pendingsig = 0; pendingsig = 0;
pendingsig_waitcmd = 0;
for (i = 1; i < NSIG; i++) { for (i = 1; i < NSIG; i++) {
if (gotsig[i]) { if (gotsig[i]) {
gotsig[i] = 0; gotsig[i] = 0;
+1
View File
@@ -34,6 +34,7 @@
*/ */
extern volatile sig_atomic_t pendingsig; extern volatile sig_atomic_t pendingsig;
extern volatile sig_atomic_t pendingsig_waitcmd;
extern int in_dotrap; extern int in_dotrap;
extern volatile sig_atomic_t gotwinch; extern volatile sig_atomic_t gotwinch;
+3 -2
View File
@@ -710,6 +710,7 @@ localcmd(int argc __unused, char **argv __unused)
{ {
char *name; char *name;
nextopt("");
if (! in_function()) if (! in_function())
error("Not in a function"); error("Not in a function");
while ((name = *argptr++) != NULL) { while ((name = *argptr++) != NULL) {
@@ -877,7 +878,7 @@ unsetvar(const char *s)
/* /*
* Returns true if the two strings specify the same varable. The first * Returns true if the two strings specify the same variable. The first
* variable name is terminated by '='; the second may be terminated by * variable name is terminated by '='; the second may be terminated by
* either '=' or '\0'. * either '=' or '\0'.
*/ */
@@ -898,7 +899,7 @@ varequal(const char *p, const char *q)
* Search for a variable. * Search for a variable.
* 'name' may be terminated by '=' or a NUL. * 'name' may be terminated by '=' or a NUL.
* vppp is set to the pointer to vp, or the list head if vp isn't found * vppp is set to the pointer to vp, or the list head if vp isn't found
* lenp is set to the number of charactets in 'name' * lenp is set to the number of characters in 'name'
*/ */
static struct var * static struct var *
+9 -2
View File
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h> #include <ctype.h>
#include <err.h> #include <err.h>
#include <errno.h>
#include <limits.h> #include <limits.h>
#include <signal.h> #include <signal.h>
#include <stdint.h> #include <stdint.h>
@@ -81,14 +82,20 @@ main(int argc, char *argv[])
time_to_sleep.tv_nsec = 1e9 * (d - time_to_sleep.tv_sec); time_to_sleep.tv_nsec = 1e9 * (d - time_to_sleep.tv_sec);
signal(SIGINFO, report_request); signal(SIGINFO, report_request);
/*
* Note: [EINTR] is supposed to happen only when a signal was handled
* but the kernel also returns it when a ptrace-based debugger
* attaches. This is a bug but it is hard to fix.
*/
while (nanosleep(&time_to_sleep, &time_to_sleep) != 0) { while (nanosleep(&time_to_sleep, &time_to_sleep) != 0) {
if (report_requested) { if (report_requested) {
/* Reporting does not bother with nanoseconds. */ /* Reporting does not bother with nanoseconds. */
warnx("about %d second(s) left out of the original %d", warnx("about %d second(s) left out of the original %d",
(int)time_to_sleep.tv_sec, (int)original); (int)time_to_sleep.tv_sec, (int)original);
report_requested = 0; report_requested = 0;
} else } else if (errno != EINTR)
break; err(1, "nanosleep");
} }
return (0); return (0);
} }
+32 -55
View File
@@ -32,7 +32,7 @@
.\" @(#)test.1 8.1 (Berkeley) 5/31/93 .\" @(#)test.1 8.1 (Berkeley) 5/31/93
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd December 27, 2012 .Dd June 1, 2013
.Dt TEST 1 .Dt TEST 1
.Os .Os
.Sh NAME .Sh NAME
@@ -169,65 +169,15 @@ True if
.Ar file .Ar file
exists and is a socket. exists and is a socket.
.It Ar file1 Fl nt Ar file2 .It Ar file1 Fl nt Ar file2
True if both True if
.Ar file1 .Ar file1
and exists and is newer than
.Ar file2
exist and
.Ar file1
is newer than
.Ar file2 . .Ar file2 .
.It Ar file1 Fl nt Ns Ar X Ns Ar Y Ar file2
True if both
.Ar file1
and
.Ar file2
exist and
.Ar file1
has a more recent last access time
.Pq Ar X Ns = Ns Cm a ,
inode creation time
.Pq Ar X Ns = Ns Cm b ,
change time
.Pq Ar X Ns = Ns Cm c ,
or modification time
.Pq Ar X Ns = Ns Cm m
than the last access time
.Pq Ar Y Ns = Ns Cm a ,
inode creation time
.Pq Ar Y Ns = Ns Cm b ,
change time
.Pq Ar Y Ns = Ns Cm c ,
or modification time
.Pq Ar Y Ns = Ns Cm m
of
.Ar file2 .
Note that
.Ic -ntmm
is equivalent to
.Ic -nt .
.It Ar file1 Fl ot Ar file2 .It Ar file1 Fl ot Ar file2
True if both True if
.Ar file1 .Ar file1
and exists and is older than
.Ar file2
exist and
.Ar file1
is older than
.Ar file2 . .Ar file2 .
Note that
.Ar file1
.Ic -ot
.Ar file2
is equivalent to
.Ar file2
.Ic -nt
.Ar file1
.It Ar file1 Fl ot Ns Ar X Ns Ar Y Ar file2
Equivalent to
.Ar file2
.Ic -nt Ns Ar Y Ns Ar X
.Ar file1 .
.It Ar file1 Fl ef Ar file2 .It Ar file1 Fl ef Ar file2
True if True if
.Ar file1 .Ar file1
@@ -381,6 +331,20 @@ missing.
.It >1 .It >1
An error occurred. An error occurred.
.El .El
.Sh EXAMPLES
Implement
.Li test FILE1 -nt FILE2
using only
.Tn POSIX
functionality:
.Pp
.Dl test -n \&"$(find -L -- FILE1 -prune -newer FILE2 2>/dev/null)\&"
.Pp
This can be modified using non-standard
.Xr find 1
primaries like
.Cm -newerca
to compare other timestamps.
.Sh COMPATIBILITY .Sh COMPATIBILITY
For compatibility with some other implementations, For compatibility with some other implementations,
the the
@@ -391,7 +355,9 @@ with the same meaning.
.Sh SEE ALSO .Sh SEE ALSO
.Xr builtin 1 , .Xr builtin 1 ,
.Xr expr 1 , .Xr expr 1 ,
.Xr find 1 ,
.Xr sh 1 , .Xr sh 1 ,
.Xr stat 1 ,
.Xr symlink 7 .Xr symlink 7
.Sh STANDARDS .Sh STANDARDS
The The
@@ -399,6 +365,17 @@ The
utility implements a superset of the utility implements a superset of the
.St -p1003.2 .St -p1003.2
specification. specification.
The primaries
.Cm < ,
.Cm == ,
.Cm > ,
.Fl ef ,
.Fl nt ,
.Fl ot ,
.Fl G ,
and
.Fl O
are extensions.
.Sh BUGS .Sh BUGS
Both sides are always evaluated in Both sides are always evaluated in
.Fl a .Fl a
+23 -161
View File
@@ -63,7 +63,7 @@ error(const char *msg, ...)
"-u"|"-g"|"-k"|"-s"|"-t"|"-z"|"-n"|"-o"|"-O"|"-G"|"-L"|"-S"; "-u"|"-g"|"-k"|"-s"|"-t"|"-z"|"-n"|"-o"|"-O"|"-G"|"-L"|"-S";
binary-operator ::= "="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"| binary-operator ::= "="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
"-nt"|"-nt[abcm][abcm]"|"-ot"|"-ot[abcm][abcm])"|"-ef"; "-nt"|"-ot"|"-ef";
operand ::= <any legal UNIX file name> operand ::= <any legal UNIX file name>
*/ */
@@ -85,38 +85,8 @@ enum token {
FILSUID, FILSUID,
FILSGID, FILSGID,
FILSTCK, FILSTCK,
FILNTAA, FILNT,
FILNTAB, FILOT,
FILNTAC,
FILNTAM,
FILNTBA,
FILNTBB,
FILNTBC,
FILNTBM,
FILNTCA,
FILNTCB,
FILNTCC,
FILNTCM,
FILNTMA,
FILNTMB,
FILNTMC,
FILNTMM,
FILOTAA,
FILOTAB,
FILOTAC,
FILOTAM,
FILOTBA,
FILOTBB,
FILOTBC,
FILOTBM,
FILOTCA,
FILOTCB,
FILOTCC,
FILOTCM,
FILOTMA,
FILOTMB,
FILOTMC,
FILOTMM,
FILEQ, FILEQ,
FILUID, FILUID,
FILGID, FILGID,
@@ -148,16 +118,9 @@ enum token_types {
PAREN PAREN
}; };
enum time_types {
ATIME,
BTIME,
CTIME,
MTIME
};
static struct t_op { static struct t_op {
char op_text[6]; char op_text[4];
char op_num, op_type; short op_num, op_type;
} const ops [] = { } const ops [] = {
{"-r", FILRD, UNOP}, {"-r", FILRD, UNOP},
{"-w", FILWR, UNOP}, {"-w", FILWR, UNOP},
@@ -191,40 +154,8 @@ static struct t_op {
{"-gt", INTGT, BINOP}, {"-gt", INTGT, BINOP},
{"-le", INTLE, BINOP}, {"-le", INTLE, BINOP},
{"-lt", INTLT, BINOP}, {"-lt", INTLT, BINOP},
{"-nt", FILNTMM, BINOP}, {"-nt", FILNT, BINOP},
{"-ntaa", FILNTAA, BINOP}, {"-ot", FILOT, BINOP},
{"-ntab", FILNTAB, BINOP},
{"-ntac", FILNTAC, BINOP},
{"-ntam", FILNTAM, BINOP},
{"-ntba", FILNTBA, BINOP},
{"-ntbb", FILNTBB, BINOP},
{"-ntbc", FILNTBC, BINOP},
{"-ntbm", FILNTBM, BINOP},
{"-ntca", FILNTCA, BINOP},
{"-ntcb", FILNTCB, BINOP},
{"-ntcc", FILNTCC, BINOP},
{"-ntcm", FILNTCM, BINOP},
{"-ntma", FILNTMA, BINOP},
{"-ntmb", FILNTMB, BINOP},
{"-ntmc", FILNTMC, BINOP},
{"-ntmm", FILNTMM, BINOP},
{"-ot", FILOTMM, BINOP},
{"-otaa", FILOTAA, BINOP},
{"-otab", FILOTBB, BINOP},
{"-otac", FILOTAC, BINOP},
{"-otam", FILOTAM, BINOP},
{"-otba", FILOTBA, BINOP},
{"-otbb", FILOTBB, BINOP},
{"-otbc", FILOTBC, BINOP},
{"-otbm", FILOTBM, BINOP},
{"-otca", FILOTCA, BINOP},
{"-otcb", FILOTCB, BINOP},
{"-otcc", FILOTCC, BINOP},
{"-otcm", FILOTCM, BINOP},
{"-otma", FILOTMA, BINOP},
{"-otmb", FILOTMB, BINOP},
{"-otmc", FILOTMC, BINOP},
{"-otmm", FILOTMM, BINOP},
{"-ef", FILEQ, BINOP}, {"-ef", FILEQ, BINOP},
{"!", UNOT, BUNOP}, {"!", UNOT, BUNOP},
{"-a", BAND, BBINOP}, {"-a", BAND, BBINOP},
@@ -249,10 +180,10 @@ static int intcmp(const char *, const char *);
static int isunopoperand(void); static int isunopoperand(void);
static int islparenoperand(void); static int islparenoperand(void);
static int isrparenoperand(void); static int isrparenoperand(void);
static int newerf(const char *, const char *, enum time_types, static int newerf(const char *, const char *);
enum time_types);
static int nexpr(enum token); static int nexpr(enum token);
static int oexpr(enum token); static int oexpr(enum token);
static int olderf(const char *, const char *);
static int primary(enum token); static int primary(enum token);
static void syntax(const char *, const char *); static void syntax(const char *, const char *);
static enum token t_lex(char *); static enum token t_lex(char *);
@@ -422,70 +353,10 @@ binop(void)
return intcmp(opnd1, opnd2) <= 0; return intcmp(opnd1, opnd2) <= 0;
case INTLT: case INTLT:
return intcmp(opnd1, opnd2) < 0; return intcmp(opnd1, opnd2) < 0;
case FILNTAA: case FILNT:
return newerf(opnd1, opnd2, ATIME, ATIME); return newerf (opnd1, opnd2);
case FILNTAB: case FILOT:
return newerf(opnd1, opnd2, ATIME, BTIME); return olderf (opnd1, opnd2);
case FILNTAC:
return newerf(opnd1, opnd2, ATIME, CTIME);
case FILNTAM:
return newerf(opnd1, opnd2, ATIME, MTIME);
case FILNTBA:
return newerf(opnd1, opnd2, BTIME, ATIME);
case FILNTBB:
return newerf(opnd1, opnd2, BTIME, BTIME);
case FILNTBC:
return newerf(opnd1, opnd2, BTIME, CTIME);
case FILNTBM:
return newerf(opnd1, opnd2, BTIME, MTIME);
case FILNTCA:
return newerf(opnd1, opnd2, CTIME, ATIME);
case FILNTCB:
return newerf(opnd1, opnd2, CTIME, BTIME);
case FILNTCC:
return newerf(opnd1, opnd2, CTIME, CTIME);
case FILNTCM:
return newerf(opnd1, opnd2, CTIME, MTIME);
case FILNTMA:
return newerf(opnd1, opnd2, MTIME, ATIME);
case FILNTMB:
return newerf(opnd1, opnd2, MTIME, BTIME);
case FILNTMC:
return newerf(opnd1, opnd2, MTIME, CTIME);
case FILNTMM:
return newerf(opnd1, opnd2, MTIME, MTIME);
case FILOTAA:
return newerf(opnd2, opnd1, ATIME, ATIME);
case FILOTAB:
return newerf(opnd2, opnd1, BTIME, ATIME);
case FILOTAC:
return newerf(opnd2, opnd1, CTIME, ATIME);
case FILOTAM:
return newerf(opnd2, opnd1, MTIME, ATIME);
case FILOTBA:
return newerf(opnd2, opnd1, ATIME, BTIME);
case FILOTBB:
return newerf(opnd2, opnd1, BTIME, BTIME);
case FILOTBC:
return newerf(opnd2, opnd1, CTIME, BTIME);
case FILOTBM:
return newerf(opnd2, opnd1, MTIME, BTIME);
case FILOTCA:
return newerf(opnd2, opnd1, ATIME, CTIME);
case FILOTCB:
return newerf(opnd2, opnd1, BTIME, CTIME);
case FILOTCC:
return newerf(opnd2, opnd1, CTIME, CTIME);
case FILOTCM:
return newerf(opnd2, opnd1, MTIME, CTIME);
case FILOTMA:
return newerf(opnd2, opnd1, ATIME, MTIME);
case FILOTMB:
return newerf(opnd2, opnd1, BTIME, MTIME);
case FILOTMC:
return newerf(opnd2, opnd1, CTIME, MTIME);
case FILOTMM:
return newerf(opnd2, opnd1, MTIME, MTIME);
case FILEQ: case FILEQ:
return equalf (opnd1, opnd2); return equalf (opnd1, opnd2);
default: default:
@@ -699,34 +570,25 @@ intcmp (const char *s1, const char *s2)
} }
static int static int
newerf (const char *f1, const char *f2, enum time_types t1, enum time_types t2) newerf (const char *f1, const char *f2)
{ {
struct stat b1, b2; struct stat b1, b2;
struct timespec *ts1, *ts2;
if (stat(f1, &b1) != 0 || stat(f2, &b2) != 0) if (stat(f1, &b1) != 0 || stat(f2, &b2) != 0)
return 0; return 0;
switch (t1) { if (b1.st_mtim.tv_sec > b2.st_mtim.tv_sec)
case ATIME: ts1 = &b1.st_atim; break;
case BTIME: ts1 = &b1.st_birthtim; break;
case CTIME: ts1 = &b1.st_ctim; break;
default: ts1 = &b1.st_mtim; break;
}
switch (t2) {
case ATIME: ts2 = &b2.st_atim; break;
case BTIME: ts2 = &b2.st_birthtim; break;
case CTIME: ts2 = &b2.st_ctim; break;
default: ts2 = &b2.st_mtim; break;
}
if (ts1->tv_sec > ts2->tv_sec)
return 1; return 1;
if (ts1->tv_sec < ts2->tv_sec) if (b1.st_mtim.tv_sec < b2.st_mtim.tv_sec)
return 0; return 0;
return (ts1->tv_nsec > ts2->tv_nsec); return (b1.st_mtim.tv_nsec > b2.st_mtim.tv_nsec);
}
static int
olderf (const char *f1, const char *f2)
{
return (newerf(f2, f1));
} }
static int static int
@@ -23,9 +23,8 @@
* Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms. * Use is subject to license terms.
*/ */
/*
* Copyright (c) 2012 by Delphix. All rights reserved. #pragma ident "%Z%%M% %I% %E% SMI"
*/
/* /*
* ASSERTION: * ASSERTION:
@@ -38,20 +37,19 @@
*/ */
/* /*
* We make some regrettable assumptions about the implementation in this * We make some regrettable assumptions about the implementation in this test.
* test. First, we assume that each entry for the printf() of an int * First, we assume that each entry for the printf() of an int takes _exactly_
* takes _exactly_ 16 bytes (4 bytes for the EPID, 8 bytes for the * eight bytes (four bytes for the EPID, four bytes for the payload). Second,
* timestamp, 4 bytes for the payload). Second, we assume that by * we assume that by allocating storage for n + 1 records, we will get exactly
* allocating storage for n + 1 records, we will get exactly n. Here is * n. Here is why: the final predicate that evaluates to false will reserve
* why: the final predicate that evaluates to false will reserve space * space that it won't use. This act of reservation will advance the wrapped
* that it won't use. This act of reservation will advance the wrapped * offset. That record won't be subsequently used, but the wrapped offset has
* offset. That record won't be subsequently used, but the wrapped * advanced. (And in this case, that old record is clobbered by the exit()
* offset has advanced. (And in this case, that old record is clobbered * anyway.) Thirdly: we rely on t_cpu/cpu_id. Finally: we rely on being
* by the exit() anyway.) Thirdly: we rely on t_cpu/cpu_id. Finally: * able to run on the CPU that we first ran on.
* we rely on being able to run on the CPU that we first ran on.
*/ */
#pragma D option bufpolicy=ring #pragma D option bufpolicy=ring
#pragma D option bufsize=80 #pragma D option bufsize=40
#pragma D option quiet #pragma D option quiet
int n; int n;
@@ -36,12 +36,12 @@
#pragma D option quiet #pragma D option quiet
#pragma D option statusrate=10ms #pragma D option statusrate=10ms
fbt::ioctl:entry fbt::kern_ioctl:entry
{ {
printf("Entering the ioctl function\n"); printf("Entering the ioctl function\n");
} }
fbt::ioctl:return fbt::kern_ioctl:return
{ {
printf("Returning from ioctl function\n"); printf("Returning from ioctl function\n");
exit(0); exit(0);
@@ -36,7 +36,7 @@
#pragma D option quiet #pragma D option quiet
#pragma D option statusrate=10ms #pragma D option statusrate=10ms
fbt::ioctl:return fbt::kern_ioctl:return
{ {
printf("The function return value is stored in %u\n", arg1); printf("The function return value is stored in %u\n", arg1);
exit(0); exit(0);
@@ -36,13 +36,13 @@
#pragma D option quiet #pragma D option quiet
#pragma D option statusrate=10ms #pragma D option statusrate=10ms
fbt::ioctl:entry fbt::kern_ioctl:entry
{ {
printf("Entering the ioctl function\n"); printf("Entering the ioctl function\n");
printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3); printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3);
} }
fbt::ioctl:return fbt::kern_ioctl:return
{ {
printf("Returning from ioctl function\n"); printf("Returning from ioctl function\n");
printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3); printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3);
@@ -41,12 +41,12 @@ BEGIN
self->traceme = 1; self->traceme = 1;
} }
fbt::ioctl:entry fbt::kern_ioctl:entry
{ {
printf("Entering the function\n"); printf("Entering the function\n");
} }
fbt::ioctl:return fbt::kern_ioctl:return
{ {
printf("The offset = %u\n", arg0); printf("The offset = %u\n", arg0);
exit(0); exit(0);
@@ -36,14 +36,14 @@
#pragma D option quiet #pragma D option quiet
#pragma D option statusrate=10ms #pragma D option statusrate=10ms
fbt::ioctl:entry fbt::kern_ioctl:entry
{ {
printf("Entering the ioctl function\n"); printf("Entering the ioctl function\n");
printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3); printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3);
exit(0); exit(0);
} }
fbt::ioctl:return fbt::kern_ioctl:return
{ {
printf("Returning from ioctl function\n"); printf("Returning from ioctl function\n");
printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3); printf("The few arguments are %u %u %u %u\n", arg0, arg1, arg2, arg3);
@@ -36,7 +36,7 @@
#pragma D option quiet #pragma D option quiet
#pragma D option statusrate=10ms #pragma D option statusrate=10ms
fbt::ioctl:return fbt::kern_ioctl:return
/arg1 == 0/ /arg1 == 0/
{ {
printf("%s %x returned 0", probefunc, arg0); printf("%s %x returned 0", probefunc, arg0);
@@ -36,7 +36,7 @@
#pragma D option quiet #pragma D option quiet
#pragma D option statusrate=10ms #pragma D option statusrate=10ms
fbt::ioctl:entry fbt::kern_ioctl:entry
{ {
self->traceme = 1; self->traceme = 1;
} }
@@ -47,7 +47,7 @@ fbt:::entry
printf("called %s\n", probefunc); printf("called %s\n", probefunc);
} }
fbt::ioctl:return fbt::kern_ioctl:return
/self->traceme/ /self->traceme/
{ {
self->traceme = 0; self->traceme = 0;
@@ -24,7 +24,9 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#pragma ident "%Z%%M% %I% %E% SMI" /*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
#pragma D option quiet #pragma D option quiet
@@ -36,3 +38,8 @@ BEGIN
printf("%s\n", strjoin("", "")); printf("%s\n", strjoin("", ""));
exit(0); exit(0);
} }
BEGIN
{
exit(1);
}
@@ -73,7 +73,7 @@ die "Could not determine local IP address" if $local eq "";
# Find the first remote host that responds to an icmp echo, # Find the first remote host that responds to an icmp echo,
# which isn't a local address. # which isn't a local address.
# #
open PING, "/sbin/ping -ns $Broadcast{$local} 56 $MAXHOSTS |" or open PING, "/sbin/ping -n -s 56 -c $MAXHOSTS $Broadcast{$local} |" or
die "Couldn't run ping: $!\n"; die "Couldn't run ping: $!\n";
while (<PING>) { while (<PING>) {
if (/bytes from (.*): / and not defined $Broadcast{$1}) { if (/bytes from (.*): / and not defined $Broadcast{$1}) {
@@ -48,7 +48,9 @@ my $MULTICAST = "FF02::1"; # IPv6 multicast address
# #
my $local = ""; my $local = "";
my $remote = ""; my $remote = "";
my $interf = "";
my %Local; my %Local;
my %Addr;
my $up; my $up;
open IFCONFIG, '/sbin/ifconfig -a inet6 |' open IFCONFIG, '/sbin/ifconfig -a inet6 |'
or die "Couldn't run ifconfig: $!\n"; or die "Couldn't run ifconfig: $!\n";
@@ -59,27 +61,34 @@ while (<IFCONFIG>) {
$up = 1 if /^[a-z].*<UP,/; $up = 1 if /^[a-z].*<UP,/;
$up = 0 if /^[a-z].*<,/; $up = 0 if /^[a-z].*<,/;
if (m:(\S+\d+)\: :) {
$interf = $1;
}
# assume output is "inet6 ...": # assume output is "inet6 ...":
if (m:inet6 (\S+)/:) { if (m:inet6 (\S+) :) {
my $addr = $1; my $addr = $1;
$Local{$addr} = 1; $Local{$addr} = 1;
$local = $addr if $up and $local eq ""; $Addr{$interf} = $addr;
$up = 0; $up = 0;
$interf = "";
} }
} }
close IFCONFIG; close IFCONFIG;
exit 1 if $local eq "";
# #
# Find the first remote host that responds to an icmp echo, # Find the first remote host that responds to an icmp echo,
# which isn't a local address. # which isn't a local address. Try each IPv6-enabled interface.
# #
open PING, "/sbin/ping -ns -A inet6 $MULTICAST 56 $MAXHOSTS |" or foreach $interf (split(' ', `ifconfig -l -u inet6`)) {
die "Couldn't run ping: $!\n"; next if $interf =~ /lo[0-9]+/;
while (<PING>) { open PING, "/sbin/ping6 -n -s 56 -c $MAXHOSTS $MULTICAST\%$interf |" or next;
if (/bytes from (.*): / and not defined $Local{$1}) { while (<PING>) {
$remote = $1; if (/bytes from (.*), / and not defined $Local{$1}) {
last; $remote = $1;
$local = $Addr{$interf};
last;
}
} }
} }
close PING; close PING;
@@ -24,9 +24,7 @@
# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms. # Use is subject to license terms.
# #
# ident "%Z%%M% %I% %E% SMI"
#
# Copyright (c) 2012 by Delphix. All rights reserved.
# #
if [ $# != 1 ]; then if [ $# != 1 ]; then
@@ -51,13 +49,13 @@ tick-1s
tick-1s tick-1s
/(i % 2) == 0/ /(i % 2) == 0/
{ {
system("dtrace -c date -n 'pid\$target::main:entry' >/dev/null"); system("dtrace -c date -ln 'pid\$target::main:entry' >/dev/null");
} }
tick-1s tick-1s
/(i % 2) == 1/ /(i % 2) == 1/
{ {
system("dtrace -c date -n 'pid\$target::main:return' >/dev/null"); system("dtrace -c date -ln 'pid\$target::main:return' >/dev/null");
} }
EOF EOF
@@ -24,7 +24,9 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#pragma ident "%Z%%M% %I% %E% SMI" /*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* /*
* ASSERTION: This test reproduces the alignment error. * ASSERTION: This test reproduces the alignment error.
@@ -39,9 +41,10 @@
BEGIN BEGIN
{ {
x = (int *) 64; x = (int *)64;
y = *x; y = *x;
trace(y); trace(y);
exit(0);
} }
ERROR ERROR
@@ -24,7 +24,9 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#pragma ident "%Z%%M% %I% %E% SMI" /*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* /*
* ASSERTION: D pointers do not allow invalid pointer accesses. * ASSERTION: D pointers do not allow invalid pointer accesses.
@@ -44,6 +46,7 @@ BEGIN
y = (int *) (x - 3300778156056); y = (int *) (x - 3300778156056);
*y = 3; *y = 3;
trace(*y); trace(*y);
exit(0);
} }
ERROR ERROR
@@ -24,7 +24,9 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#pragma ident "%Z%%M% %I% %E% SMI" /*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* /*
* ASSERTION: D pointers do not allow invalid pointer accesses. * ASSERTION: D pointers do not allow invalid pointer accesses.
@@ -39,9 +41,10 @@
BEGIN BEGIN
{ {
y = (int *) (-33007); y = (int *)-33007;
*y = 3; *y = 3;
trace(*y); trace(*y);
exit(0);
} }
ERROR ERROR
@@ -24,7 +24,9 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#pragma ident "%Z%%M% %I% %E% SMI" /*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* /*
* ASSERTION: Demonstrating valid memory access. * ASSERTION: Demonstrating valid memory access.
@@ -40,10 +42,11 @@
BEGIN BEGIN
{ {
x = (int *)alloca(sizeof (int)); x = (int *)alloca(sizeof (int));
printf("Address x: %x\n", (int) x); printf("Address x: %x\n", (int)x);
y = (int *) (x - 2); y = (int *)(x - 2);
*y = 3; *y = 3;
printf("Address y: %x\tValue: %d\n", (int) y, *y); printf("Address y: %x\tValue: %d\n", (int)y, *y);
exit(0);
} }
ERROR ERROR
@@ -1,28 +0,0 @@
/*
* CDDL HEADER START
*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
BEGIN
{
*((int *)alloca(4)) = 1;
}
BEGIN
{
exit(0);
}
@@ -1,29 +0,0 @@
/*
* CDDL HEADER START
*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
BEGIN
{
this->a = alloca(4);
*((int *)this->a) = 1;
}
BEGIN
{
exit(0);
}
@@ -73,8 +73,8 @@ if [ "$status" -ne 0 ]; then
fi fi
# dtrace outputs a blank line at the end, which will sort to the beginning, # dtrace outputs a blank line at the end, which will sort to the beginning,
# so use head to remove the blank line. # so use sed to remove the blank line.
head -n -1 $file > $file.2 sed '$d' $file > $file.2
sort -n $file.2 | diff $file.2 - sort -n $file.2 | diff $file.2 -
status=$? status=$?
@@ -89,8 +89,8 @@ if [ "$status" -ne 0 ]; then
fi fi
# dtrace outputs a blank line at the end, which will sort to the beginning, # dtrace outputs a blank line at the end, which will sort to the beginning,
# so use grep to remove the blank line. # so use sed to remove the blank line.
head -n -1 $file > $file.2 sed '$d' $file > $file.2
sort -n $file.2 | diff $file.2 - sort -n $file.2 | diff $file.2 -
status=$? status=$?
@@ -0,0 +1,197 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
unload()
{
#
# Get the list of services whose processes have USDT probes. Ideally
# it would be possible to unload the fasttrap provider while USDT
# probes exist -- once that fix is integrated, this hack can go away
# We create two lists -- one of regular SMF services and one of legacy
# services -- since each must be enabled and disabled using a specific
# mechanism.
#
pids=$(dtrace -l | \
perl -ne 'print "$1\n" if (/^\s*\S+\s+\S*\D(\d+)\s+/);' | \
sort | uniq | tr '\n' ',')
ctids=$(ps -p $pids -o ctid | tail +2 | sort | uniq)
svcs=
lrcs=
for ct in $ctids
do
line=$(svcs -o fmri,ctid | grep " $ct\$")
svc=$(echo $line | cut -d' ' -f1)
if [[ $(svcs -Ho STA $svc) == "LRC" ]]; then
lrc=$(svcs -Ho SVC $svc | tr _ '?')
lrcs="$lrcs $lrc"
else
svcs="$svcs $svc"
fi
done
for svc in $svcs
do
svcadm disable -ts $svc
done
for lrc in $lrcs
do
#
# Does it seem a little paternalistic that lsvcrun requires
# this environment variable to be set? I'd say so...
#
SMF_RESTARTER=svc:/system/svc/restarter:default \
/lib/svc/bin/lsvcrun $lrc stop
done
modunload -i 0
modunload -i 0
modunload -i 0
modinfo | grep dtrace
success=$?
for svc in $svcs
do
svcadm enable -ts $svc
done
for lrc in $lrcs
do
SMF_RESTARTER=svc:/system/svc/restarter:default \
/lib/svc/bin/lsvcrun $lrc start
done
if [ ! $success ]; then
echo $tst: could not unload dtrace
exit 1
fi
}
script1()
{
$dtrace -s /dev/stdin <<EOF
syscall:::entry
/pid != $ppid/
{
@a[probefunc] = count();
}
tick-1sec
/i++ == 5/
{
exit(0);
}
EOF
}
script2()
{
$dtrace -s /dev/stdin <<EOF
#pragma D option statusrate=1ms
syscall:::entry
/pid == $ppid/
{
ttl++;
}
tick-1sec
/i++ == 5/
{
exit(2);
}
END
/ttl/
{
printf("success; ttl is %d", ttl);
exit(0);
}
END
/ttl == 0/
{
printf("error -- total should be non-zero");
exit(1);
}
EOF
}
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
ppid=$$
dtrace=$1
unload
script1 &
child=$!
let waited=0
while [ "$waited" -lt 5 ]; do
seconds=`date +%S`
if [ "$seconds" -ne "$last" ]; then
last=$seconds
let waited=waited+1
fi
done
wait $child
status=$?
if [ "$status" -ne 0 ]; then
echo $tst: first dtrace failed
exit $status
fi
unload
script2 &
child=$!
let waited=0
while [ "$waited" -lt 10 ]; do
seconds=`date +%S`
if [ "$seconds" -ne "$last" ]; then
last=$seconds
let waited=waited+1
fi
done
wait $child
status=$?
exit $status
@@ -0,0 +1,29 @@
/*
* CDDL HEADER START
*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
BEGIN
{
@ = count();
print(@);
}
BEGIN
{
exit(0);
}
@@ -20,10 +20,15 @@
*/ */
/* /*
* Copyright (c) 2011 by Delphix. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved.
*/ */
BEGIN BEGIN
{ {
print((void)`p0); print((void)`p0);
} }
BEGIN
{
exit(0);
}
@@ -20,10 +20,15 @@
*/ */
/* /*
* Copyright (c) 2011 by Delphix. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved.
*/ */
BEGIN BEGIN
{ {
print(); print();
} }
BEGIN
{
exit(0);
}
@@ -0,0 +1,33 @@
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
#pragma D option quiet
enum simpson {
homer,
marge,
bart,
lisa,
maggie,
snowball_ii,
santas_little_helper
};
BEGIN
{
print(bart);
print((enum simpson)4);
print(snowball_ii);
exit(0);
}
@@ -0,0 +1,4 @@
enum simpson bart
enum simpson maggie
enum simpson snowball_ii
@@ -24,7 +24,9 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#pragma ident "%Z%%M% %I% %E% SMI" /*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* /*
* ASSERTION: * ASSERTION:
@@ -39,7 +41,7 @@
*/ */
#pragma D option bufsize=16 #pragma D option bufsize=32
#pragma D option bufpolicy=ring #pragma D option bufpolicy=ring
#pragma D option statusrate=1nsec #pragma D option statusrate=1nsec
@@ -26,26 +26,24 @@
#pragma ident "%Z%%M% %I% %E% SMI" #pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <sys/sysctl.h>
#include <err.h>
#include <unistd.h> #include <unistd.h>
#ifndef __FreeBSD__
#include <sys/uadmin.h>
#endif
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
#ifdef __FreeBSD__ int val = 1;
return (1);
#else
while (1) { while (1) {
if (uadmin(A_SDTTEST, 0, 0) < 0) { if (sysctlbyname("debug.dtracetest.sdttest", NULL, NULL, &val,
perror("uadmin"); sizeof(val)))
return (1); err(1, "sysctlbyname");
}
sleep(1); sleep(1);
} }
return (0); return (0);
#endif
} }
@@ -43,7 +43,7 @@ ERROR
exit(1); exit(1);
} }
sdt:::test test:::sdttest
/arg0 != 1 || arg1 != 2 || arg2 != 3 || arg3 != 4 || arg4 != 5 || arg5 != 6 || /arg0 != 1 || arg1 != 2 || arg2 != 3 || arg3 != 4 || arg4 != 5 || arg5 != 6 ||
arg6 != 7/ arg6 != 7/
{ {
@@ -54,7 +54,7 @@ sdt:::test
exit(1); exit(1);
} }
sdt:::test test:::sdttest
{ {
exit(0); exit(0);
} }
@@ -24,7 +24,9 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#pragma ident "%Z%%M% %I% %E% SMI" /*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* /*
* ASSERTION: * ASSERTION:
@@ -24,10 +24,7 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
/* #pragma ident "%Z%%M% %I% %E% SMI"
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* /*
* ASSERTION: * ASSERTION:
* Verify the behavior of speculations with changes in specsize. * Verify the behavior of speculations with changes in specsize.
@@ -38,7 +35,7 @@
*/ */
#pragma D option quiet #pragma D option quiet
#pragma D option specsize=48 #pragma D option specsize=40
BEGIN BEGIN
{ {
@@ -24,8 +24,9 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#pragma ident "%Z%%M% %I% %E% SMI" /*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* /*
* ASSERTION: * ASSERTION:
@@ -39,3 +40,8 @@ BEGIN
trace(); trace();
} }
BEGIN
{
exit(0);
}
@@ -0,0 +1,29 @@
/*
* CDDL HEADER START
*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
BEGIN
{
@ = count();
trace(@);
}
BEGIN
{
exit(0);
}
@@ -24,7 +24,9 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#pragma ident "%Z%%M% %I% %E% SMI" /*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* /*
* ASSERTION: * ASSERTION:
@@ -37,3 +39,8 @@ BEGIN
{ {
trace((void)`kmem_flags); trace((void)`kmem_flags);
} }
BEGIN
{
exit(0);
}
@@ -0,0 +1,29 @@
/*
* CDDL HEADER START
*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
* Make sure we can scope types with modifiers.
*/
BEGIN
{
trace((D`int *)0);
trace((const D`int *)0);
exit(0);
}
+22 -11
View File
@@ -28,6 +28,7 @@
* Copyright (c) 2011-2012 Pawel Jakub Dawidek <pawel@dawidek.net>. * Copyright (c) 2011-2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
* All rights reserved. * All rights reserved.
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved. * Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
*/ */
#include <assert.h> #include <assert.h>
@@ -56,6 +57,7 @@
#include <sys/fs/zfs.h> #include <sys/fs/zfs.h>
#include <sys/types.h> #include <sys/types.h>
#include <time.h> #include <time.h>
#include <err.h>
#include <libzfs.h> #include <libzfs.h>
#include <libzfs_core.h> #include <libzfs_core.h>
@@ -3529,6 +3531,12 @@ zfs_snapshot_cb(zfs_handle_t *zhp, void *arg)
int rv = 0; int rv = 0;
int error; int error;
if (sd->sd_recursive &&
zfs_prop_get_int(zhp, ZFS_PROP_INCONSISTENT) != 0) {
zfs_close(zhp);
return (0);
}
error = asprintf(&name, "%s@%s", zfs_get_name(zhp), sd->sd_snapname); error = asprintf(&name, "%s@%s", zfs_get_name(zhp), sd->sd_snapname);
if (error == -1) if (error == -1)
nomem(); nomem();
@@ -5233,8 +5241,7 @@ zfs_do_hold_rele_impl(int argc, char **argv, boolean_t holding)
continue; continue;
} }
if (holding) { if (holding) {
if (zfs_hold(zhp, delim+1, tag, recursive, if (zfs_hold(zhp, delim+1, tag, recursive, -1) != 0)
B_FALSE, -1) != 0)
++errors; ++errors;
} else { } else {
if (zfs_release(zhp, delim+1, tag, recursive) != 0) if (zfs_release(zhp, delim+1, tag, recursive) != 0)
@@ -5601,8 +5608,8 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
(void) fprintf(stderr, gettext("cannot share '%s': " (void) fprintf(stderr, gettext("cannot share '%s': "
"legacy share\n"), zfs_get_name(zhp)); "legacy share\n"), zfs_get_name(zhp));
(void) fprintf(stderr, gettext("use share(1M) to " (void) fprintf(stderr, gettext("to "
"share this filesystem, or set " "share this filesystem set "
"sharenfs property on\n")); "sharenfs property on\n"));
return (1); return (1);
} }
@@ -5618,7 +5625,7 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
(void) fprintf(stderr, gettext("cannot %s '%s': " (void) fprintf(stderr, gettext("cannot %s '%s': "
"legacy mountpoint\n"), cmdname, zfs_get_name(zhp)); "legacy mountpoint\n"), cmdname, zfs_get_name(zhp));
(void) fprintf(stderr, gettext("use %s(1M) to " (void) fprintf(stderr, gettext("use %s(8) to "
"%s this filesystem\n"), cmdname, cmdname); "%s this filesystem\n"), cmdname, cmdname);
return (1); return (1);
} }
@@ -6056,8 +6063,10 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual)
strcmp(smbshare_prop, "off") == 0) { strcmp(smbshare_prop, "off") == 0) {
(void) fprintf(stderr, gettext("cannot unshare " (void) fprintf(stderr, gettext("cannot unshare "
"'%s': legacy share\n"), path); "'%s': legacy share\n"), path);
#ifdef illumos
(void) fprintf(stderr, gettext("use " (void) fprintf(stderr, gettext("use "
"unshare(1M) to unshare this filesystem\n")); "unshare(1M) to unshare this filesystem\n"));
#endif
} else if (!zfs_is_shared(zhp)) { } else if (!zfs_is_shared(zhp)) {
(void) fprintf(stderr, gettext("cannot unshare '%s': " (void) fprintf(stderr, gettext("cannot unshare '%s': "
"not currently shared\n"), path); "not currently shared\n"), path);
@@ -6076,7 +6085,7 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual)
(void) fprintf(stderr, gettext("cannot unmount " (void) fprintf(stderr, gettext("cannot unmount "
"'%s': legacy mountpoint\n"), "'%s': legacy mountpoint\n"),
zfs_get_name(zhp)); zfs_get_name(zhp));
(void) fprintf(stderr, gettext("use umount(1M) " (void) fprintf(stderr, gettext("use umount(8) "
"to unmount this filesystem\n")); "to unmount this filesystem\n"));
} else { } else {
ret = zfs_unmountall(zhp, flags); ret = zfs_unmountall(zhp, flags);
@@ -6298,9 +6307,11 @@ unshare_unmount(int op, int argc, char **argv)
(void) fprintf(stderr, gettext("cannot " (void) fprintf(stderr, gettext("cannot "
"unshare '%s': legacy share\n"), "unshare '%s': legacy share\n"),
zfs_get_name(zhp)); zfs_get_name(zhp));
#ifdef illumos
(void) fprintf(stderr, gettext("use " (void) fprintf(stderr, gettext("use "
"unshare(1M) to unshare this " "unshare(1M) to unshare this "
"filesystem\n")); "filesystem\n"));
#endif
ret = 1; ret = 1;
} else if (!zfs_is_shared(zhp)) { } else if (!zfs_is_shared(zhp)) {
(void) fprintf(stderr, gettext("cannot " (void) fprintf(stderr, gettext("cannot "
@@ -6318,7 +6329,7 @@ unshare_unmount(int op, int argc, char **argv)
"unmount '%s': legacy " "unmount '%s': legacy "
"mountpoint\n"), zfs_get_name(zhp)); "mountpoint\n"), zfs_get_name(zhp));
(void) fprintf(stderr, gettext("use " (void) fprintf(stderr, gettext("use "
"umount(1M) to unmount this " "umount(8) to unmount this "
"filesystem\n")); "filesystem\n"));
ret = 1; ret = 1;
} else if (!zfs_is_mounted(zhp, NULL)) { } else if (!zfs_is_mounted(zhp, NULL)) {
@@ -6504,12 +6515,12 @@ manual_mount(int argc, char **argv)
} }
} else { } else {
(void) fprintf(stderr, gettext("filesystem '%s' cannot be " (void) fprintf(stderr, gettext("filesystem '%s' cannot be "
"mounted using 'mount -F zfs'\n"), dataset); "mounted using 'mount -t zfs'\n"), dataset);
(void) fprintf(stderr, gettext("Use 'zfs set mountpoint=%s' " (void) fprintf(stderr, gettext("Use 'zfs set mountpoint=%s' "
"instead.\n"), path); "instead.\n"), path);
(void) fprintf(stderr, gettext("If you must use 'mount -F zfs' " (void) fprintf(stderr, gettext("If you must use 'mount -t zfs' "
"or /etc/vfstab, use 'zfs set mountpoint=legacy'.\n")); "or /etc/fstab, use 'zfs set mountpoint=legacy'.\n"));
(void) fprintf(stderr, gettext("See zfs(1M) for more " (void) fprintf(stderr, gettext("See zfs(8) for more "
"information.\n")); "information.\n"));
ret = 1; ret = 1;
} }
+2 -1
View File
@@ -21,6 +21,7 @@
/* /*
* Copyright (c) 2012 by Delphix. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
*/ */
/* /*
@@ -153,7 +154,7 @@ import_pool(const char *target, boolean_t readonly)
g_importargs.poolname = g_pool; g_importargs.poolname = g_pool;
pools = zpool_search_import(g_zfs, &g_importargs); pools = zpool_search_import(g_zfs, &g_importargs);
if (pools == NULL || nvlist_next_nvpair(pools, NULL) == NULL) { if (nvlist_empty(pools)) {
if (!g_importargs.can_be_active) { if (!g_importargs.can_be_active) {
g_importargs.can_be_active = B_TRUE; g_importargs.can_be_active = B_TRUE;
if (zpool_search_import(g_zfs, &g_importargs) != NULL || if (zpool_search_import(g_zfs, &g_importargs) != NULL ||
+59 -16
View File
@@ -25,6 +25,7 @@
* Copyright (c) 2012 by Delphix. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2012 by Frederik Wessels. All rights reserved. * Copyright (c) 2012 by Frederik Wessels. All rights reserved.
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved. * Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 by Prasad Joshi (sTec). All rights reserved.
*/ */
#include <solaris.h> #include <solaris.h>
@@ -804,6 +805,7 @@ zpool_do_create(int argc, char **argv)
goto errout; goto errout;
break; break;
case 'm': case 'm':
/* Equivalent to -O mountpoint=optarg */
mountpoint = optarg; mountpoint = optarg;
break; break;
case 'o': case 'o':
@@ -842,8 +844,18 @@ zpool_do_create(int argc, char **argv)
*propval = '\0'; *propval = '\0';
propval++; propval++;
if (add_prop_list(optarg, propval, &fsprops, B_FALSE)) /*
* Mountpoints are checked and then added later.
* Uniquely among properties, they can be specified
* more than once, to avoid conflict with -m.
*/
if (0 == strcmp(optarg,
zfs_prop_to_name(ZFS_PROP_MOUNTPOINT))) {
mountpoint = propval;
} else if (add_prop_list(optarg, propval, &fsprops,
B_FALSE)) {
goto errout; goto errout;
}
break; break;
case ':': case ':':
(void) fprintf(stderr, gettext("missing argument for " (void) fprintf(stderr, gettext("missing argument for "
@@ -961,6 +973,18 @@ zpool_do_create(int argc, char **argv)
} }
} }
/*
* Now that the mountpoint's validity has been checked, ensure that
* the property is set appropriately prior to creating the pool.
*/
if (mountpoint != NULL) {
ret = add_prop_list(zfs_prop_to_name(ZFS_PROP_MOUNTPOINT),
mountpoint, &fsprops, B_FALSE);
if (ret != 0)
goto errout;
}
ret = 1;
if (dryrun) { if (dryrun) {
/* /*
* For a dry run invocation, print out a basic message and run * For a dry run invocation, print out a basic message and run
@@ -995,21 +1019,19 @@ zpool_do_create(int argc, char **argv)
if (nvlist_exists(props, propname)) if (nvlist_exists(props, propname))
continue; continue;
if (add_prop_list(propname, ZFS_FEATURE_ENABLED, ret = add_prop_list(propname,
&props, B_TRUE) != 0) ZFS_FEATURE_ENABLED, &props, B_TRUE);
if (ret != 0)
goto errout; goto errout;
} }
} }
ret = 1;
if (zpool_create(g_zfs, poolname, if (zpool_create(g_zfs, poolname,
nvroot, props, fsprops) == 0) { nvroot, props, fsprops) == 0) {
zfs_handle_t *pool = zfs_open(g_zfs, poolname, zfs_handle_t *pool = zfs_open(g_zfs, poolname,
ZFS_TYPE_FILESYSTEM); ZFS_TYPE_FILESYSTEM);
if (pool != NULL) { if (pool != NULL) {
if (mountpoint != NULL)
verify(zfs_prop_set(pool,
zfs_prop_to_name(
ZFS_PROP_MOUNTPOINT),
mountpoint) == 0);
if (zfs_mount(pool, NULL, 0) == 0) if (zfs_mount(pool, NULL, 0) == 0)
ret = zfs_shareall(pool); ret = zfs_shareall(pool);
zfs_close(pool); zfs_close(pool);
@@ -1274,12 +1296,13 @@ print_status_config(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
int namewidth, int depth, boolean_t isspare) int namewidth, int depth, boolean_t isspare)
{ {
nvlist_t **child; nvlist_t **child;
uint_t c, children; uint_t c, vsc, children;
pool_scan_stat_t *ps = NULL; pool_scan_stat_t *ps = NULL;
vdev_stat_t *vs; vdev_stat_t *vs;
char rbuf[6], wbuf[6], cbuf[6]; char rbuf[6], wbuf[6], cbuf[6];
char *vname; char *vname;
uint64_t notpresent; uint64_t notpresent;
uint64_t ashift;
spare_cbdata_t cb; spare_cbdata_t cb;
const char *state; const char *state;
@@ -1288,7 +1311,7 @@ print_status_config(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
children = 0; children = 0;
verify(nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS, verify(nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS,
(uint64_t **)&vs, &c) == 0); (uint64_t **)&vs, &vsc) == 0);
state = zpool_state_to_name(vs->vs_state, vs->vs_aux); state = zpool_state_to_name(vs->vs_state, vs->vs_aux);
if (isspare) { if (isspare) {
@@ -1342,6 +1365,10 @@ print_status_config(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
(void) printf(gettext("unsupported feature(s)")); (void) printf(gettext("unsupported feature(s)"));
break; break;
case VDEV_AUX_ASHIFT_TOO_BIG:
(void) printf(gettext("unsupported minimum blocksize"));
break;
case VDEV_AUX_SPARED: case VDEV_AUX_SPARED:
verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID,
&cb.cb_guid) == 0); &cb.cb_guid) == 0);
@@ -1384,6 +1411,12 @@ print_status_config(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
(void) printf(gettext("corrupted data")); (void) printf(gettext("corrupted data"));
break; break;
} }
} else if (children == 0 && !isspare &&
VDEV_STAT_VALID(vs_physical_ashift, vsc) &&
vs->vs_configured_ashift < vs->vs_physical_ashift) {
(void) printf(
gettext(" block size: %dB configured, %dB native"),
1 << vs->vs_configured_ashift, 1 << vs->vs_physical_ashift);
} }
(void) nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_SCAN_STATS, (void) nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_SCAN_STATS,
@@ -2096,8 +2129,10 @@ zpool_do_import(int argc, char **argv)
errno = 0; errno = 0;
searchguid = strtoull(argv[0], &endptr, 10); searchguid = strtoull(argv[0], &endptr, 10);
if (errno != 0 || *endptr != '\0') if (errno != 0 || *endptr != '\0') {
searchname = argv[0]; searchname = argv[0];
searchguid = 0;
}
found_config = NULL; found_config = NULL;
/* /*
@@ -3976,7 +4011,7 @@ print_dedup_stats(nvlist_t *config)
/* /*
* If the pool was faulted then we may not have been able to * If the pool was faulted then we may not have been able to
* obtain the config. Otherwise, if have anything in the dedup * obtain the config. Otherwise, if we have anything in the dedup
* table continue processing the stats. * table continue processing the stats.
*/ */
if (nvlist_lookup_uint64_array(config, ZPOOL_CONFIG_DDT_OBJ_STATS, if (nvlist_lookup_uint64_array(config, ZPOOL_CONFIG_DDT_OBJ_STATS,
@@ -4247,6 +4282,15 @@ status_callback(zpool_handle_t *zhp, void *data)
"'zpool clear'.\n")); "'zpool clear'.\n"));
break; break;
case ZPOOL_STATUS_NON_NATIVE_ASHIFT:
(void) printf(gettext("status: One or more devices are "
"configured to use a non-native block size.\n"
"\tExpect reduced performance.\n"));
(void) printf(gettext("action: Replace affected devices with "
"devices that support the\n\tconfigured block size, or "
"migrate data to a properly configured\n\tpool.\n"));
break;
default: default:
/* /*
* The remaining errors can't actually be generated, yet. * The remaining errors can't actually be generated, yet.
@@ -5323,10 +5367,9 @@ main(int argc, char **argv)
* 'freeze' is a vile debugging abomination, so we treat * 'freeze' is a vile debugging abomination, so we treat
* it as such. * it as such.
*/ */
char buf[16384]; zfs_cmd_t zc = { 0 };
int fd = open(ZFS_DEV, O_RDWR); (void) strlcpy(zc.zc_name, argv[2], sizeof (zc.zc_name));
(void) strcpy((void *)buf, argv[2]); return (!!zfs_ioctl(g_zfs, ZFS_IOC_POOL_FREEZE, &zc));
return (!!ioctl(fd, ZFS_IOC_POOL_FREEZE, buf));
} else { } else {
(void) fprintf(stderr, gettext("unrecognized " (void) fprintf(stderr, gettext("unrecognized "
"command '%s'\n"), cmdname); "command '%s'\n"), cmdname);
+65 -14
View File
@@ -20,9 +20,10 @@
*/ */
/* /*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved. * Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
*/ */
/* /*
@@ -185,6 +186,7 @@ static const ztest_shared_opts_t ztest_opts_defaults = {
extern uint64_t metaslab_gang_bang; extern uint64_t metaslab_gang_bang;
extern uint64_t metaslab_df_alloc_threshold; extern uint64_t metaslab_df_alloc_threshold;
extern uint64_t zfs_deadman_synctime;
static ztest_shared_opts_t *ztest_shared_opts; static ztest_shared_opts_t *ztest_shared_opts;
static ztest_shared_opts_t ztest_opts; static ztest_shared_opts_t ztest_opts;
@@ -364,7 +366,7 @@ ztest_info_t ztest_info[] = {
{ ztest_fault_inject, 1, &zopt_sometimes }, { ztest_fault_inject, 1, &zopt_sometimes },
{ ztest_ddt_repair, 1, &zopt_sometimes }, { ztest_ddt_repair, 1, &zopt_sometimes },
{ ztest_dmu_snapshot_hold, 1, &zopt_sometimes }, { ztest_dmu_snapshot_hold, 1, &zopt_sometimes },
{ ztest_reguid, 1, &zopt_sometimes }, { ztest_reguid, 1, &zopt_rarely },
{ ztest_spa_rename, 1, &zopt_rarely }, { ztest_spa_rename, 1, &zopt_rarely },
{ ztest_scrub, 1, &zopt_rarely }, { ztest_scrub, 1, &zopt_rarely },
{ ztest_spa_upgrade, 1, &zopt_rarely }, { ztest_spa_upgrade, 1, &zopt_rarely },
@@ -767,6 +769,16 @@ ztest_kill(ztest_shared_t *zs)
{ {
zs->zs_alloc = metaslab_class_get_alloc(spa_normal_class(ztest_spa)); zs->zs_alloc = metaslab_class_get_alloc(spa_normal_class(ztest_spa));
zs->zs_space = metaslab_class_get_space(spa_normal_class(ztest_spa)); zs->zs_space = metaslab_class_get_space(spa_normal_class(ztest_spa));
/*
* Before we kill off ztest, make sure that the config is updated.
* See comment above spa_config_sync().
*/
mutex_enter(&spa_namespace_lock);
spa_config_sync(ztest_spa, B_FALSE, B_FALSE);
mutex_exit(&spa_namespace_lock);
zfs_dbgmsg_print(FTAG);
(void) kill(getpid(), SIGKILL); (void) kill(getpid(), SIGKILL);
} }
@@ -2731,7 +2743,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
uint64_t leaf, top; uint64_t leaf, top;
uint64_t ashift = ztest_get_ashift(); uint64_t ashift = ztest_get_ashift();
uint64_t oldguid, pguid; uint64_t oldguid, pguid;
size_t oldsize, newsize; uint64_t oldsize, newsize;
char oldpath[MAXPATHLEN], newpath[MAXPATHLEN]; char oldpath[MAXPATHLEN], newpath[MAXPATHLEN];
int replacing; int replacing;
int oldvd_has_siblings = B_FALSE; int oldvd_has_siblings = B_FALSE;
@@ -2890,8 +2902,8 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
if (error != expected_error && expected_error != EBUSY) { if (error != expected_error && expected_error != EBUSY) {
fatal(0, "attach (%s %llu, %s %llu, %d) " fatal(0, "attach (%s %llu, %s %llu, %d) "
"returned %d, expected %d", "returned %d, expected %d",
oldpath, (longlong_t)oldsize, newpath, oldpath, oldsize, newpath,
(longlong_t)newsize, replacing, error, expected_error); newsize, replacing, error, expected_error);
} }
VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); VERIFY(mutex_unlock(&ztest_vdev_lock) == 0);
@@ -3605,6 +3617,9 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
else else
dmu_tx_hold_write(tx, bigobj, bigoff, bigsize); dmu_tx_hold_write(tx, bigobj, bigoff, bigsize);
/* This accounts for setting the checksum/compression. */
dmu_tx_hold_bonus(tx, bigobj);
txg = ztest_tx_assign(tx, TXG_MIGHTWAIT, FTAG); txg = ztest_tx_assign(tx, TXG_MIGHTWAIT, FTAG);
if (txg == 0) { if (txg == 0) {
umem_free(packbuf, packsize); umem_free(packbuf, packsize);
@@ -4509,7 +4524,7 @@ ztest_dmu_commit_callbacks(ztest_ds_t *zd, uint64_t id)
*/ */
tmp_cb = list_head(&zcl.zcl_callbacks); tmp_cb = list_head(&zcl.zcl_callbacks);
if (tmp_cb != NULL && if (tmp_cb != NULL &&
tmp_cb->zcd_txg > txg - ZTEST_COMMIT_CALLBACK_THRESH) { (txg - ZTEST_COMMIT_CALLBACK_THRESH) > tmp_cb->zcd_txg) {
fatal(0, "Commit callback threshold exceeded, oldest txg: %" fatal(0, "Commit callback threshold exceeded, oldest txg: %"
PRIu64 ", open txg: %" PRIu64 "\n", tmp_cb->zcd_txg, txg); PRIu64 ", open txg: %" PRIu64 "\n", tmp_cb->zcd_txg, txg);
} }
@@ -4713,7 +4728,7 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
error = user_release_one(fullname, tag); error = user_release_one(fullname, tag);
if (error) if (error)
fatal(0, "user_release_one(%s)", fullname, tag); fatal(0, "user_release_one(%s, %s) = %d", fullname, tag, error);
VERIFY3U(dmu_objset_hold(fullname, FTAG, &origin), ==, ENOENT); VERIFY3U(dmu_objset_hold(fullname, FTAG, &origin), ==, ENOENT);
@@ -4754,6 +4769,14 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
ASSERT(leaves >= 1); ASSERT(leaves >= 1);
/*
* Grab the name lock as reader. There are some operations
* which don't like to have their vdevs changed while
* they are in progress (i.e. spa_change_guid). Those
* operations will have grabbed the name lock as writer.
*/
(void) rw_rdlock(&ztest_name_lock);
/* /*
* We need SCL_STATE here because we're going to look at vd0->vdev_tsd. * We need SCL_STATE here because we're going to look at vd0->vdev_tsd.
*/ */
@@ -4783,7 +4806,14 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
if (vd0 != NULL && vd0->vdev_top->vdev_islog) if (vd0 != NULL && vd0->vdev_top->vdev_islog)
islog = B_TRUE; islog = B_TRUE;
if (vd0 != NULL && maxfaults != 1) { /*
* If the top-level vdev needs to be resilvered
* then we only allow faults on the device that is
* resilvering.
*/
if (vd0 != NULL && maxfaults != 1 &&
(!vdev_resilver_needed(vd0->vdev_top, NULL, NULL) ||
vd0->vdev_resilver_txg != 0)) {
/* /*
* Make vd0 explicitly claim to be unreadable, * Make vd0 explicitly claim to be unreadable,
* or unwriteable, or reach behind its back * or unwriteable, or reach behind its back
@@ -4814,6 +4844,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
if (sav->sav_count == 0) { if (sav->sav_count == 0) {
spa_config_exit(spa, SCL_STATE, FTAG); spa_config_exit(spa, SCL_STATE, FTAG);
(void) rw_unlock(&ztest_name_lock);
return; return;
} }
vd0 = sav->sav_vdevs[ztest_random(sav->sav_count)]; vd0 = sav->sav_vdevs[ztest_random(sav->sav_count)];
@@ -4827,6 +4858,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
} }
spa_config_exit(spa, SCL_STATE, FTAG); spa_config_exit(spa, SCL_STATE, FTAG);
(void) rw_unlock(&ztest_name_lock);
/* /*
* If we can tolerate two or more faults, or we're dealing * If we can tolerate two or more faults, or we're dealing
@@ -5292,16 +5324,33 @@ static void *
ztest_deadman_thread(void *arg) ztest_deadman_thread(void *arg)
{ {
ztest_shared_t *zs = arg; ztest_shared_t *zs = arg;
int grace = 300; spa_t *spa = ztest_spa;
hrtime_t delta; hrtime_t delta, total = 0;
delta = (zs->zs_thread_stop - zs->zs_thread_start) / NANOSEC + grace; for (;;) {
delta = (zs->zs_thread_stop - zs->zs_thread_start) /
NANOSEC + zfs_deadman_synctime;
(void) poll(NULL, 0, (int)(1000 * delta)); (void) poll(NULL, 0, (int)(1000 * delta));
fatal(0, "failed to complete within %d seconds of deadline", grace); /*
* If the pool is suspended then fail immediately. Otherwise,
* check to see if the pool is making any progress. If
* vdev_deadman() discovers that there hasn't been any recent
* I/Os then it will end up aborting the tests.
*/
if (spa_suspended(spa)) {
fatal(0, "aborting test after %llu seconds because "
"pool has transitioned to a suspended state.",
zfs_deadman_synctime);
return (NULL);
}
vdev_deadman(spa->spa_root_vdev);
return (NULL); total += zfs_deadman_synctime;
(void) printf("ztest has been running for %lld seconds\n",
total);
}
} }
static void static void
@@ -5615,6 +5664,7 @@ ztest_run(ztest_shared_t *zs)
zs->zs_alloc = metaslab_class_get_alloc(spa_normal_class(spa)); zs->zs_alloc = metaslab_class_get_alloc(spa_normal_class(spa));
zs->zs_space = metaslab_class_get_space(spa_normal_class(spa)); zs->zs_space = metaslab_class_get_space(spa_normal_class(spa));
zfs_dbgmsg_print(FTAG);
umem_free(tid, ztest_opts.zo_threads * sizeof (thread_t)); umem_free(tid, ztest_opts.zo_threads * sizeof (thread_t));
@@ -6030,6 +6080,7 @@ main(int argc, char **argv)
(void) setvbuf(stdout, NULL, _IOLBF, 0); (void) setvbuf(stdout, NULL, _IOLBF, 0);
dprintf_setup(&argc, argv); dprintf_setup(&argc, argv);
zfs_deadman_synctime = 300;
ztest_fd_rand = open("/dev/urandom", O_RDONLY); ztest_fd_rand = open("/dev/urandom", O_RDONLY);
ASSERT3S(ztest_fd_rand, >=, 0); ASSERT3S(ztest_fd_rand, >=, 0);

Some files were not shown because too many files have changed in this diff Show More