diff --git Makefile Makefile index bce6edb33e10..6aece21ecdc8 100644 --- Makefile +++ Makefile @@ -34,12 +34,16 @@ # for world and kernel targets. # toolchains - Build a toolchain for all world and kernel targets. # xdev - xdev-build + xdev-install for the architecture -# specified with XDEV and XDEV_ARCH. +# specified with TARGET and TARGET_ARCH. # xdev-build - Build cross-development tools. # xdev-install - Install cross-development tools. # xdev-links - Create traditional links in /usr/bin for cc, etc # native-xtools - Create host binaries that produce target objects -# for use in qemu user-mode jails. +# for use in qemu user-mode jails. TARGET and +# TARGET_ARCH should be defined. +# native-xtools-install +# - Install the files to the given DESTDIR/NXTP where +# NXTP defaults to /nxb-bin. # # "quick" way to test all kernel builds: # _jflag=`sysctl -n hw.ncpu` @@ -118,6 +122,7 @@ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \ check check-old check-old-dirs check-old-files check-old-libs \ checkdpadd checkworld clean cleandepend cleandir cleanworld \ + cleanuniverse \ delete-old delete-old-dirs delete-old-files delete-old-libs \ depend distribute distributekernel distributekernel.debug \ distributeworld distrib-dirs distribution doxygen \ @@ -125,16 +130,21 @@ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \ installkernel.debug packagekernel packageworld \ reinstallkernel reinstallkernel.debug \ installworld kernel-toolchain libraries lint maninstall \ - obj objlink rerelease showconfig tags toolchain update \ + obj objlink showconfig tags toolchain update \ _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ _build-tools _build-metadata _cross-tools _includes _libraries \ build32 distribute32 install32 buildsoft distributesoft installsoft \ builddtb xdev xdev-build xdev-install \ - xdev-links native-xtools stageworld stagekernel stage-packages \ + xdev-links native-xtools native-xtools-install stageworld stagekernel \ + stage-packages \ create-packages-world create-packages-kernel create-packages \ packages installconfig real-packages sign-packages package-pkg \ print-dir test-system-compiler +# These targets require a TARGET and TARGET_ARCH be defined. +XTGTS= native-xtools native-xtools-install xdev xdev-build xdev-install \ + xdev-links + # XXX: r156740: This can't work since bsd.subdir.mk is not included ever. # It will only work for SUBDIR_TARGETS in make.conf. TGTS+= ${SUBDIR_TARGETS} @@ -157,6 +167,18 @@ META_TGT_WHITELIST+= \ tinderbox toolchain \ toolchains universe world worlds xdev xdev-build +# Likewise for AUTO_OBJ. Many targets do not need object directories created +# for each visited directory. Only when things are being built are they +# needed. Having AUTO_OBJ disabled in a build target is fine as it should +# fallback to running 'make obj' as needed. If a target is not in this list +# then it is ran with MK_AUTO_OBJ=no in environment. +# 'showconfig' is in the list to avoid forcing MK_AUTO_OBJ=no for it. +AUTO_OBJ_TGT_WHITELIST+= \ + _* all all-man build* depend everything *toolchain* includes \ + libraries obj objlink showconfig tags xdev xdev-build native-xtools \ + stage* create-packages* real-packages sign-packages package-pkg \ + tinderbox universe* kernel kernels world worlds bmake + .ORDER: buildworld installworld .ORDER: buildworld distrib-dirs .ORDER: buildworld distribution @@ -179,12 +201,13 @@ META_TGT_WHITELIST+= \ PATH= /sbin:/bin:/usr/sbin:/usr/bin MAKEOBJDIRPREFIX?= /usr/obj -_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} MK_AUTO_OBJ=no ${MAKE} \ +_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} MK_AUTO_OBJ=no \ ${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \ + SRCCONF=${SRCCONF} \ -f /dev/null -V MAKEOBJDIRPREFIX dummy .if !empty(_MAKEOBJDIRPREFIX) .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 src.conf(5)) or command-line variable. .endif # We often need to use the tree's version of make to build it. @@ -199,7 +222,7 @@ WANT_MAKE_VERSION= 20160604 # 20160220 - support .dinclude for FAST_DEPEND. WANT_MAKE_VERSION= 20160220 .endif -MYMAKE= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE} +MYMAKE= ${OBJROOT}make.${MACHINE}/${WANT_MAKE} .if defined(.PARSEDIR) HAVE_MAKE= bmake .else @@ -224,8 +247,11 @@ SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk _MAKE= PATH=${PATH} MAKE_CMD="${MAKE}" ${SUB_MAKE} -f Makefile.inc1 \ TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} +.if defined(MK_META_MODE) && ${MK_META_MODE} == "yes" # Only allow meta mode for the whitelisted targets. See META_TGT_WHITELIST -# above. +# above. If overridden as a make argument then don't bother trying to +# disable it. +.if empty(.MAKEOVERRIDES:MMK_META_MODE) .for _tgt in ${META_TGT_WHITELIST} .if make(${_tgt}) _CAN_USE_META_MODE?= yes @@ -233,17 +259,37 @@ _CAN_USE_META_MODE?= yes .endfor .if !defined(_CAN_USE_META_MODE) _MAKE+= MK_META_MODE=no +MK_META_MODE= no .if defined(.PARSEDIR) .unexport META_MODE .endif -.elif defined(MK_META_MODE) && ${MK_META_MODE} == "yes" +.endif # !defined(_CAN_USE_META_MODE) +.endif # empty(.MAKEOVERRIDES:MMK_META_MODE) + +.if ${MK_META_MODE} == "yes" .if !exists(/dev/filemon) && !defined(NO_FILEMON) && !make(showconfig) # Require filemon be loaded to provide a working incremental build .error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded. \ ${.newline}ERROR: WITH_META_MODE is enabled but requires filemon for an incremental build. \ ${.newline}ERROR: 'kldload filemon' or pass -DNO_FILEMON to suppress this error. .endif # !exists(/dev/filemon) && !defined(NO_FILEMON) -.endif # !defined(_CAN_USE_META_MODE) +.endif # ${MK_META_MODE} == yes +.endif # defined(MK_META_MODE) && ${MK_META_MODE} == yes + +# Only allow AUTO_OBJ for the whitelisted targets. See AUTO_OBJ_TGT_WHITELIST +# above. MK_AUTO_OBJ not checked here for "yes" as it may not yet be enabled +# since it is opportunistic. +.if empty(.MAKEOVERRIDES:MMK_AUTO_OBJ) +.for _tgt in ${AUTO_OBJ_TGT_WHITELIST} +.if make(${_tgt}) +_CAN_USE_AUTO_OBJ?= yes +.endif +.endfor +.if !defined(_CAN_USE_AUTO_OBJ) +_MAKE+= MK_AUTO_OBJ=no +MK_AUTO_OBJ= no +.endif +.endif # empty(.MAKEOVERRIDES:MMK_AUTO_OBJ) # Guess target architecture from target type, and vice versa, based on # historic FreeBSD practice of tending to have TARGET == TARGET_ARCH @@ -270,14 +316,36 @@ _TARGET= ${XDEV} .if defined(XDEV_ARCH) _TARGET_ARCH= ${XDEV_ARCH} .endif +# Some targets require a set TARGET/TARGET_ARCH, check before the default +# MACHINE and after the compatibility handling. +.if !defined(_TARGET) || !defined(_TARGET_ARCH) +${XTGTS}: _assert_target +.endif # Otherwise, default to current machine type and architecture. _TARGET?= ${MACHINE} _TARGET_ARCH?= ${MACHINE_ARCH} +.if make(native-xtools*) +NXB_TARGET:= ${_TARGET} +NXB_TARGET_ARCH:= ${_TARGET_ARCH} +_TARGET= ${MACHINE} +_TARGET_ARCH= ${MACHINE_ARCH} +_MAKE+= NXB_TARGET=${NXB_TARGET} \ + NXB_TARGET_ARCH=${NXB_TARGET_ARCH} +.endif + .if make(print-dir) .SILENT: .endif +_assert_target: .PHONY .MAKE +.for _tgt in ${XTGTS} +.if make(${_tgt}) + @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${_tgt}\" target" + @false +.endif +.endfor + # # Make sure we have an up-to-date make(1). Only world and buildworld # should do this as those are the initial targets used for upgrades. @@ -384,10 +452,13 @@ upgrade_checks: .PHONY # headers, libraries and tools. Also, allow the location of # the system bsdmake-like utility to be overridden. # -MMAKEENV= MAKEOBJDIRPREFIX=${MYMAKE:H} \ +MMAKEENV= \ DESTDIR= \ INSTALL="sh ${.CURDIR}/tools/install.sh" MMAKE= ${MMAKEENV} ${MAKE} \ + OBJTOP=${MYMAKE:H}/obj \ + OBJROOT='$${OBJTOP}/' \ + MAKEOBJDIRPREFIX= \ MAN= -DNO_SHARED \ -DNO_CPU_CFLAGS -DNO_WERROR \ -DNO_SUBDIR \ @@ -435,7 +506,7 @@ worlds: .PHONY .if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets) TARGETS?=amd64 arm arm64 i386 mips powerpc riscv sparc64 _UNIVERSE_TARGETS= ${TARGETS} -TARGET_ARCHES_arm?= arm armeb armv6 +TARGET_ARCHES_arm?= arm armeb armv6 armv7 TARGET_ARCHES_arm64?= aarch64 TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32 mipselhf mipshf mips64elhf mips64hf TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpcspe @@ -527,12 +598,13 @@ universe_${target}_kernels: universe_${target}_worlds .PHONY universe_${target}_kernels: universe_${target}_prologue .MAKE .PHONY .if exists(${KERNSRCDIR}/${target}/conf/NOTES) @(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \ - ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \ + ${SUB_MAKE} -DNO_OBJ LINT \ + > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \ (echo "${target} 'make LINT' failed," \ "check _.${target}.makeLINT for details"| ${MAKEFAIL})) .endif @cd ${.CURDIR}; ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \ - universe_kernels + universe_kernels MK_AUTO_OBJ=no .endif # !MAKE_JUST_WORLDS # Tell the user the worlds and kernels have completed diff --git Makefile.inc1 Makefile.inc1 index 0054b67f7909..0c214ea12248 100644 --- Makefile.inc1 +++ Makefile.inc1 @@ -78,18 +78,11 @@ MK_CLANG_BOOTSTRAP= no MK_GCC_BOOTSTRAP= no .endif -MAKEOBJDIRPREFIX?= /usr/obj -.if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING) -OBJTREE= ${MAKEOBJDIRPREFIX} -.else -OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH} -.endif - # Pull in compiler metadata from buildworld/toolchain if possible to avoid # running CC from bsd.compiler.mk. .if make(installworld) || make(install) || make(distributeworld) || \ make(stageworld) -.-include "${OBJTREE}${.CURDIR}/compiler-metadata.mk" +.-include "${OBJTOP}/compiler-metadata.mk" .endif # Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early. @@ -133,7 +126,7 @@ WANT_COMPILER_VERSION!= \ # TARGET_ARCH!=MACHINE_ARCH. .if ${MK_SYSTEM_COMPILER} == "yes" && \ (${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \ - !make(showconfig) && !make(native-xtools) && !make(xdev*) && \ + !make(showconfig) && !make(xdev*) && \ ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE} && \ (${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \ ${COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \ @@ -308,7 +301,7 @@ CLEANDIR= cleandir .if defined(WORLDFAST) NO_CLEAN= t -NO_OBJ= t +NO_OBJWALK= t .endif .if ${MK_META_MODE} == "yes" @@ -319,11 +312,11 @@ NO_OBJ= t NO_CLEAN= t .endif .endif -.if defined(NO_OBJ) || ${MK_AUTO_OBJ} == "yes" -NO_OBJ= t +.if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes" +NO_OBJWALK= t NO_KERNELOBJ= t .endif -.if !defined(NO_OBJ) +.if !defined(NO_OBJWALK) _obj= obj .endif @@ -365,11 +358,11 @@ OSRELDATE= 0 # Set VERSION for CTFMERGE to use via the default CTFFLAGS=-L VERSION. .if !defined(_REVISION) -_REVISION!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V REVISION +_REVISION!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V REVISION .export _REVISION .endif .if !defined(_BRANCH) -_BRANCH!= MK_AUTO_OBJ=no ${MAKE} -C ${SRCDIR}/release -V BRANCH +_BRANCH!= ${MAKE} -C ${SRCDIR}/release MK_AUTO_OBJ=no -V BRANCH .export _BRANCH .endif .if !defined(SRCRELDATE) @@ -398,6 +391,7 @@ KNOWN_ARCHES?= aarch64/arm64 \ arm \ armeb/arm \ armv6/arm \ + armv7/arm \ i386 \ mips \ mipsel/mips \ @@ -438,8 +432,8 @@ _TARGET_CPUTYPE=${TARGET_CPUTYPE} .else _TARGET_CPUTYPE=dummy .endif -_CPUTYPE!= MK_AUTO_OBJ=no MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \ - -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE +_CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} -f /dev/null \ + -m ${.CURDIR}/share/mk MK_AUTO_OBJ=no -V CPUTYPE .if ${_CPUTYPE} != ${_TARGET_CPUTYPE} .error CPUTYPE global should be set with ?=. .endif @@ -449,7 +443,7 @@ BUILD_ARCH!= uname -p .error To cross-build, set TARGET_ARCH. .endif .endif -WORLDTMP= ${OBJTREE}${.CURDIR}/tmp +WORLDTMP?= ${OBJTOP}/tmp BPATH= ${CCACHE_WRAPPER_PATH_PFX}${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/bin XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin STRICTTMPPATH= ${BPATH}:${XPATH} @@ -507,7 +501,7 @@ MINIMUM_SUPPORTED_OSREL?= 900044 MINIMUM_SUPPORTED_REL?= 9.1 # Common environment for world related stages -CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \ +CROSSENV+= \ MACHINE_ARCH=${TARGET_ARCH} \ MACHINE=${TARGET} \ CPUTYPE=${TARGET_CPUTYPE} @@ -527,22 +521,25 @@ BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \ MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" # need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile BSARGS= DESTDIR= \ + OBJTOP='${WORLDTMP}/obj-tools' \ + OBJROOT='$${OBJTOP}/' \ + MAKEOBJDIRPREFIX= \ BOOTSTRAPPING=${OSRELDATE} \ BWPHASE=${.TARGET:C,^_,,} \ SSP_CFLAGS= \ MK_HTML=no NO_LINT=yes MK_MAN=no \ -DNO_PIC MK_PROFILE=no -DNO_SHARED \ -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ - MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \ + MK_CLANG_EXTRAS=yes MK_CLANG_FULL=no \ MK_LLDB=no MK_TESTS=no \ MK_INCLUDES=yes MK_CFI=no -BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \ +BMAKE= \ ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \ ${BSARGS} # build-tools stage -TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \ +TMAKE= \ ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ DESTDIR= \ @@ -551,11 +548,12 @@ TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \ SSP_CFLAGS= \ -DNO_LINT \ -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ - MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \ + MK_CLANG_EXTRAS=yes MK_CLANG_FULL=no \ MK_LLDB=no MK_TESTS=no MK_CFI=no # cross-tools stage -XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \ +# TOOLS_PREFIX set in BMAKE +XMAKE= ${BMAKE} \ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ MK_GDB=no MK_LLD_IS_LD=${MK_LLD_BOOTSTRAP} MK_TESTS=no @@ -563,9 +561,12 @@ XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \ KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \ PATH=${BPATH}:${PATH} \ WORLDTMP=${WORLDTMP} -KTMAKE= TOOLS_PREFIX=${WORLDTMP} MAKEOBJDIRPREFIX=${WORLDTMP} \ +KTMAKE= TOOLS_PREFIX=${WORLDTMP} \ ${KTMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \ DESTDIR= \ + OBJTOP='${WORLDTMP}/obj-kernel-tools' \ + OBJROOT='$${OBJTOP}/' \ + MAKEOBJDIRPREFIX= \ BOOTSTRAPPING=${OSRELDATE} \ SSP_CFLAGS= \ MK_HTML=no -DNO_LINT MK_MAN=no \ @@ -614,7 +615,7 @@ BFLAGS+= -B${CROSS_BINUTILS_PREFIX} BFLAGS+= -B${WORLDTMP}/usr/bin .endif .if ${TARGET} == "arm" -.if ${TARGET_ARCH:Marmv6*} != "" && ${TARGET_CPUTYPE:M*soft*} == "" +.if ${TARGET_ARCH:Marmv[67]*} != "" && ${TARGET_CPUTYPE:M*soft*} == "" TARGET_ABI= gnueabihf .else TARGET_ABI= gnueabi @@ -636,6 +637,8 @@ XCXXFLAGS+= -isystem ${WORLDTMP}/usr/include/c++/v1 -std=c++11 \ .endif .elif ${WANT_COMPILER_TYPE} == clang || \ (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang) +MACHINE_ABI?= unknown +MACHINE_TRIPLE?=${MACHINE_ARCH:C/amd64/x86_64/}-${MACHINE_ABI}-freebsd12.0 TARGET_ABI?= unknown TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd12.0 XCFLAGS+= -target ${TARGET_TRIPLE} @@ -650,7 +653,7 @@ XCFLAGS+= ${BFLAGS} ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH:Mmips64*} != "") LIBCOMPAT= 32 .include "Makefile.libcompat" -.elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH} == "armv6" +.elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH:Marmv[67]*} != "" LIBCOMPAT= SOFT .include "Makefile.libcompat" .endif @@ -666,11 +669,11 @@ LIBCOMPAT= SOFT META_MODE_BAD_ABI_VERS+= 1200031 .if !defined(OBJDIR_HOST_OSRELDATE) -.if exists(${OBJTREE}${.CURDIR}/host-osreldate.h) +.if exists(${OBJTOP}/host-osreldate.h) OBJDIR_HOST_OSRELDATE!= \ awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \ - ${OBJTREE}${.CURDIR}/host-osreldate.h -.else + ${OBJTOP}/host-osreldate.h +.elif exists(${WORLDTMP}/usr/include/osreldate.h) OBJDIR_HOST_OSRELDATE= 0 .endif .export OBJDIR_HOST_OSRELDATE @@ -679,6 +682,7 @@ OBJDIR_HOST_OSRELDATE= 0 # Note that this logic is the opposite of normal BOOTSTRAP handling. We want # to compare the WORLDTMP's OSRELDATE to the host's OSRELDATE. If the WORLDTMP # is older than the ABI-breakage OSRELDATE of the HOST then we rebuild. +.if defined(OBJDIR_HOST_OSRELDATE) .for _ver in ${META_MODE_BAD_ABI_VERS} .if ${OSRELDATE} >= ${_ver} && ${OBJDIR_HOST_OSRELDATE} < ${_ver} _meta_mode_need_rebuild= ${_ver} @@ -688,8 +692,9 @@ _meta_mode_need_rebuild= ${_ver} .info META_MODE: Rebuilding host tools due to ABI breakage in __FreeBSD_version ${_meta_mode_need_rebuild}. NO_META_IGNORE_HOST_HEADERS= 1 .export NO_META_IGNORE_HOST_HEADERS -.endif -.endif +.endif # defined(_meta_mode_need_rebuild) +.endif # defined(OBJDIR_HOST_OSRELDATE) +.endif # ${MK_META_MODE} == "yes" && defined(NO_CLEAN) ... # This is only used for META_MODE+filemon to track what the oldest # __FreeBSD_version is in WORLDTMP. This purposely does NOT have # a make dependency on /usr/include/osreldate.h as the file should @@ -747,88 +752,89 @@ KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME} # Attempt to rebuild the entire system, with reasonable chance of # success, regardless of how old your existing system is. # -_worldtmp: .PHONY +_sanity_check: .PHONY .MAKE .if ${.CURDIR:C/[^,]//g} != "" # The m4 build of sendmail files doesn't like it if ',' is used # anywhere in the path of it's files. @echo @echo "*** Error: path to source tree contains a comma ','" @echo - false -.endif + @false +.elif ${.CURDIR:M*\:*} != "" +# Using ':' leaks into PATH and breaks finding cross-tools. @echo - @echo "--------------------------------------------------------------" - @echo ">>> Rebuilding the temporary build tree" - @echo "--------------------------------------------------------------" -.if !defined(NO_CLEAN) - rm -rf ${WORLDTMP} -.if defined(LIBCOMPAT) - rm -rf ${LIBCOMPATTMP} -.endif -.else -.if exists(${WORLDTMP}) - @echo ">>> Deleting stale files in build tree..." - ${_+_}cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \ - delete-old delete-old-libs >/dev/null -.endif -.if defined(LIBCOMPAT) && exists(${LIBCOMPATTMP}) - ${_+_}cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \ - DESTDIR=${LIBCOMPATTMP} \ - delete-old delete-old-libs >/dev/null + @echo "*** Error: path to source tree contains a colon ':'" + @echo + @false .endif - rm -rf ${WORLDTMP}/legacy/usr/include -.if ${USING_SYSTEM_COMPILER} == "yes" -.for cc in cc c++ - if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \ - inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \ - find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \ - fi -.endfor -.endif # ${USING_SYSTEM_COMPILER} == "yes" # Our current approach to dependency tracking cannot cope with certain source # tree changes, particularly with respect to removing source files and # replacing generated files. Handle these cases here in an ad-hoc fashion. -# +_cleanobj_fast_depend_hack: .PHONY # Syscall stubs rewritten in C # Date SVN Rev Syscalls # 20160829 r305012 ptrace # 20170624 r320278 fstat fstatat fstatfs getdirentries getfsstat statfs .for f in fstat fstatat fstatfs getdirentries getfsstat ptrace statfs -.if exists(${OBJTREE}${.CURDIR}/lib/libc/.depend.${f}.o) +.if exists(${OBJTOP}/lib/libc/.depend.${f}.o) @if egrep -qw '${f}\.[sS]' \ - ${OBJTREE}${.CURDIR}/lib/libc/.depend.${f}.o; then \ + ${OBJTOP}/lib/libc/.depend.${f}.o; then \ echo Removing stale dependencies for ${f} syscall wrappers; \ - rm -f ${OBJTREE}${.CURDIR}/lib/libc/.depend.${f}.* \ - ${OBJTREE}${.CURDIR}/world32/${.CURDIR}/lib/libc/.depend.${f}.*; \ + rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \ + ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \ fi .endif .endfor # 20170607 remove stale dependencies for utimens* wrappers removed in r319663 .for f in futimens utimensat -.if exists(${OBJTREE}${.CURDIR}/lib/libc/.depend.${f}.o) +.if exists(${OBJTOP}/lib/libc/.depend.${f}.o) @if egrep -q '/${f}.c' \ - ${OBJTREE}${.CURDIR}/lib/libc/.depend.${f}.o; then \ + ${OBJTOP}/lib/libc/.depend.${f}.o; then \ echo Removing stale dependencies for ${f} syscall wrappers; \ - rm -f ${OBJTREE}${.CURDIR}/lib/libc/.depend.${f}.* \ - ${OBJTREE}${.CURDIR}/world32/${.CURDIR}/lib/libc/.depend.${f}.*; \ + rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \ + ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \ fi .endif .endfor # 20170523 remove stale generated asm files for functions which are no longer # syscalls after r302092 (pipe) and r318736 (others) .for f in getdents lstat mknod pipe stat -.if exists(${OBJTREE}${.CURDIR}/lib/libc/${f}.s) || \ - exists(${OBJTREE}${.CURDIR}/lib/libc/${f}.S) +.if exists(${OBJTOP}/lib/libc/${f}.s) || \ + exists(${OBJTOP}/lib/libc/${f}.S) @echo Removing stale generated ${f} syscall files - @rm -f ${OBJTREE}${.CURDIR}/lib/libc/${f}.* \ - ${OBJTREE}${.CURDIR}/lib/libc/.depend.${f}.* \ - ${OBJTREE}${.CURDIR}/world32/${.CURDIR}/lib/libc/${f}.* \ - ${OBJTREE}${.CURDIR}/world32/${.CURDIR}/lib/libc/.depend.${f}.* + @rm -f ${OBJTOP}/lib/libc/${f}.* \ + ${OBJTOP}/lib/libc/.depend.${f}.* \ + ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/${f}.*} \ + ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*} .endif .endfor +_worldtmp: .PHONY + @echo + @echo "--------------------------------------------------------------" + @echo ">>> Rebuilding the temporary build tree" + @echo "--------------------------------------------------------------" +.if !defined(NO_CLEAN) + rm -rf ${WORLDTMP} +.else +.if exists(${WORLDTMP}) + @echo ">>> Deleting stale files in build tree..." + ${_+_}cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \ + delete-old delete-old-libs >/dev/null +.endif + rm -rf ${WORLDTMP}/legacy/usr/include +.if ${USING_SYSTEM_COMPILER} == "yes" +.for cc in cc c++ + if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \ + inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \ + find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \ + fi +.endfor +.endif # ${USING_SYSTEM_COMPILER} == "yes" .endif # !defined(NO_CLEAN) + @mkdir -p ${WORLDTMP} + @touch ${WORLDTMP}/${.TARGET} .for _dir in \ lib lib/casper usr legacy/bin legacy/usr @@ -844,32 +850,11 @@ _worldtmp: .PHONY -p ${WORLDTMP}/usr/include >/dev/null 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 defined(LIBCOMPAT) - mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ - -p ${WORLDTMP}/usr >/dev/null -.if ${MK_DEBUG_FILES} != "no" - mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ - -p ${WORLDTMP}/legacy/usr/lib/debug/usr >/dev/null - mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ - -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null -.endif -.endif -.if ${MK_TESTS} != "no" - mkdir -p ${WORLDTMP}${TESTSBASE} - mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \ - -p ${WORLDTMP}${TESTSBASE} >/dev/null -.if ${MK_DEBUG_FILES} != "no" - mkdir -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} - mtree -deU -f ${.CURDIR}/etc/mtree/BSD.tests.dist \ - -p ${WORLDTMP}/usr/lib/debug/${TESTSBASE} >/dev/null -.endif -.endif .for _mtree in ${LOCAL_MTREE} mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null .endfor @@ -895,7 +880,9 @@ _cleanobj: .if defined(LIBCOMPAT) ${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR} .endif -.endif +.else + ${_+_}cd ${.CURDIR}; ${WMAKE} _cleanobj_fast_depend_hack +.endif # !defined(NO_CLEAN) _obj: @echo @echo "--------------------------------------------------------------" @@ -913,7 +900,7 @@ _cross-tools: @echo "--------------------------------------------------------------" @echo ">>> stage 3: cross tools" @echo "--------------------------------------------------------------" - @rm -f ${OBJTREE}${.CURDIR}/compiler-metadata.mk + @rm -f ${OBJTOP}/compiler-metadata.mk ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools ${_+_}cd ${.CURDIR}; ${XMAKE} kernel-tools _build-metadata: @@ -952,12 +939,12 @@ everything: .PHONY WMAKE_TGTS= .if !defined(WORLDFAST) -WMAKE_TGTS+= _worldtmp _legacy +WMAKE_TGTS+= _sanity_check _worldtmp _legacy .if empty(SUBDIR_OVERRIDE) WMAKE_TGTS+= _bootstrap-tools .endif WMAKE_TGTS+= _cleanobj -.if !defined(NO_OBJ) +.if !defined(NO_OBJWALK) WMAKE_TGTS+= _obj .endif WMAKE_TGTS+= _build-tools _cross-tools @@ -1001,17 +988,28 @@ buildenvvars: .PHONY .endif .endif BUILDENV_DIR?= ${.CURDIR} +# +# Note: make will report any errors the shell reports. This can +# be odd if the last command in an interactive shell generates an +# error or is terminated by SIGINT. These reported errors look bad, +# but are harmless. Allowing them also allows BUIDLENV_SHELL to +# be a complex command whose status will be returned to the caller. +# Some scripts in tools rely on this behavior to report build errors. +# buildenv: .PHONY @echo Entering world for ${TARGET_ARCH}:${TARGET} .if ${BUILDENV_SHELL:M*zsh*} @echo For ZSH you must run: export CPUTYPE=${TARGET_CPUTYPE} .endif - @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} \ - || true + @cd ${BUILDENV_DIR} && env ${WMAKEENV} BUILDENV=1 ${BUILDENV_SHELL} TOOLCHAIN_TGTS= ${WMAKE_TGTS:Neverything:Nbuild${libcompat}} toolchain: ${TOOLCHAIN_TGTS} .PHONY -kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} .PHONY +KERNEL_TOOLCHAIN_TGTS= ${TOOLCHAIN_TGTS:N_obj:N_cleanobj:N_includes:N_libraries} +.if make(kernel-toolchain) +.ORDER: ${KERNEL_TOOLCHAIN_TGTS} +.endif +kernel-toolchain: ${KERNEL_TOOLCHAIN_TGTS} .PHONY # # installcheck @@ -1082,7 +1080,7 @@ __installcheck_UGID: .PHONY (empty(DESTDIR) || ${DESTDIR} == "/") && empty(BYPASS_INSTALLCHECK_SH) _installcheck_world: __installcheck_sh_check __installcheck_sh_check: .PHONY - @if [ "`${OBJTREE}${.CURDIR}/rescue/rescue/rescue sh -c 'echo OK'`" != \ + @if [ "`${OBJTOP}/rescue/rescue/rescue sh -c 'echo OK'`" != \ OK ]; then \ echo "rescue/sh check failed, installation aborted" >&2; \ false; \ @@ -1344,7 +1342,7 @@ INSTKERNNAME?= kernel KERNSRCDIR?= ${.CURDIR}/sys KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf -KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR} +KRNLOBJDIR= ${OBJTOP}${KERNSRCDIR:C,^${.CURDIR},,} KERNCONFDIR?= ${KRNLCONFDIR} BUILDKERNELS= @@ -1359,6 +1357,10 @@ BUILDKERNELS+= ${_kernel} .if empty(INSTALLKERNEL) && !defined(NO_INSTALLKERNEL) INSTALLKERNEL= ${_kernel} .endif +.else +.if make(buildkernel) +.error Missing KERNCONF ${KERNCONFDIR}/${_kernel} +.endif .endif .endfor @@ -1548,9 +1550,9 @@ stagekernel: .PHONY ${_+_}${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} distributekernel PORTSDIR?= /usr/ports -WSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/worldstage -KSTAGEDIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/${TARGET}.${TARGET_ARCH}/kernelstage -REPODIR?= ${MAKEOBJDIRPREFIX}${.CURDIR}/repo +WSTAGEDIR?= ${OBJTOP}/worldstage +KSTAGEDIR?= ${OBJTOP}/kernelstage +REPODIR?= ${OBJROOT}repo PKGSIGNKEY?= # empty .ORDER: stage-packages create-packages @@ -1786,7 +1788,8 @@ update: .PHONY # ELF Tool Chain libraries are needed for ELF tools and dtrace tools. # r296685 fix cross-endian objcopy -.if ${BOOTSTRAPPING} < 1100102 +# r310724 fixed PR 215350, a crash in libdwarf with objects built by GCC 6.2. +.if ${BOOTSTRAPPING} < 1200020 _elftoolchain_libs= lib/libelf lib/libdwarf .endif @@ -1811,11 +1814,11 @@ legacy: .PHONY .for _tool in tools/build ${_elftoolchain_libs} ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \ cd ${.CURDIR}/${_tool}; \ - if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ - ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \ + if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ + ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy includes; \ ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \ ${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \ - DESTDIR=${MAKEOBJDIRPREFIX}/legacy install + DESTDIR=${WORLDTMP}/legacy install .endfor # @@ -1839,7 +1842,6 @@ _vtfontcvt= usr.bin/vtfontcvt .endif .if ${BOOTSTRAPPING} < 1000033 -_libopenbsd= lib/libopenbsd _m4= usr.bin/m4 _lex= usr.bin/lex @@ -1925,9 +1927,6 @@ _kerberos5_bootstrap_tools= \ .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g} .endif -# r283777 makewhatis(1) replaced with mandoc version which builds a database. -_libopenbsd?= lib/libopenbsd -_makewhatis= usr.bin/mandoc ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd bootstrap-tools: .PHONY @@ -1944,8 +1943,8 @@ bootstrap-tools: .PHONY ${_cat} \ ${_kbdcontrol} \ usr.bin/lorder \ - ${_libopenbsd} \ - ${_makewhatis} \ + lib/libopenbsd \ + usr.bin/mandoc \ usr.bin/rpcgen \ ${_yacc} \ ${_m4} \ @@ -1961,9 +1960,9 @@ bootstrap-tools: .PHONY ${_bt}-${_tool}: .PHONY .MAKE ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \ cd ${.CURDIR}/${_tool}; \ - if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ + if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ ${MAKE} DIRPRFX=${_tool}/ all; \ - ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install + ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install bootstrap-tools: ${_bt}-${_tool} .endfor @@ -1984,8 +1983,18 @@ _gcc_tools= gnu/usr.bin/cc/cc_tools _rescue=rescue/rescue .endif +.if ${MK_TCSH} != "no" +_tcsh=bin/csh +.endif + +# kernel-toolchain skips _cleanobj, so handle cleaning up previous +# build-tools directories if needed. +.if !defined(NO_CLEAN) && make(kernel-toolchain) +_bt_clean= ${CLEANDIR} +.endif + .for _tool in \ - bin/csh \ + ${_tcsh} \ bin/sh \ ${LOCAL_TOOL_DIRS} \ lib/ncurses/ncurses \ @@ -1996,21 +2005,14 @@ _rescue=rescue/rescue lib/libmagic \ usr.bin/mkesdb_static \ usr.bin/mkcsmapper_static \ - usr.bin/vi/catalog -build-tools_${_tool}: .PHONY - ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \ - cd ${.CURDIR}/${_tool}; \ - if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ - ${MAKE} DIRPRFX=${_tool}/ build-tools -build-tools: build-tools_${_tool} -.endfor -.for _tool in \ + usr.bin/vi/catalog \ ${_gcc_tools} build-tools_${_tool}: .PHONY - ${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \ + ${_+_}@${ECHODIR} "===> ${_tool} (${_bt_clean:D${_bt_clean},}obj,build-tools)"; \ cd ${.CURDIR}/${_tool}; \ - if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ - ${MAKE} DIRPRFX=${_tool}/ all + if [ -n "${_bt_clean}" ]; then ${MAKE} DIRPRFX=${_tool}/ ${_bt_clean}; fi; \ + if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ + ${MAKE} DIRPRFX=${_tool}/ build-tools build-tools: build-tools_${_tool} .endfor @@ -2018,9 +2020,9 @@ build-tools: build-tools_${_tool} # kernel-tools: Build kernel-building tools # kernel-tools: .PHONY - mkdir -p ${MAKEOBJDIRPREFIX}/usr + mkdir -p ${WORLDTMP}/usr mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ - -p ${MAKEOBJDIRPREFIX}/usr >/dev/null + -p ${WORLDTMP}/usr >/dev/null # # cross-tools: All the tools needed to build the rest of the system after @@ -2094,56 +2096,34 @@ cross-tools: .MAKE .PHONY ${_usb_tools} ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \ cd ${.CURDIR}/${_tool}; \ - if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ + if [ -z "${NO_OBJWALK}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \ ${MAKE} DIRPRFX=${_tool}/ all; \ - ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install + ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP} install .endfor -NXBDESTDIR= ${OBJTREE}/nxb-bin -NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \ - TOOLS_PREFIX= \ - INSTALL="sh ${.CURDIR}/tools/install.sh" \ - PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin -NXBMAKE= ${NXBENV} ${MAKE} \ - LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \ - CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \ - MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \ - MK_GDB=no MK_TESTS=no \ - SSP_CFLAGS= \ - MK_HTML=no NO_LINT=yes MK_MAN=no MK_MAN_UTILS=yes \ - -DNO_PIC MK_PROFILE=no -DNO_SHARED \ - -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ - MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \ - MK_LLDB=no MK_DEBUG_FILES=no - +# # native-xtools is the current target for qemu-user cross builds of ports # via poudriere and the imgact_binmisc kernel module. -# For non-clang enabled targets that are still using the in tree gcc -# we must build a gperf binary for one instance of its Makefiles. On -# clang-enabled systems, the gperf binary is obsolete. -native-xtools: .PHONY -.if ${MK_GCC_BOOTSTRAP} != "no" - mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin - ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \ - cd ${.CURDIR}/${_gperf}; \ - if [ -z "${NO_OBJ}" ]; then ${NXBMAKE} DIRPRFX=${_gperf}/ obj; fi; \ - ${NXBMAKE} DIRPRFX=${_gperf}/ all; \ - ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install -.endif - mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr - mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ - -p ${NXBDESTDIR}/usr >/dev/null - mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ - -p ${NXBDESTDIR}/usr/include >/dev/null -.if ${MK_DEBUG_FILES} != "no" - mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ - -p ${NXBDESTDIR}/usr/lib >/dev/null -.endif -.for _tool in \ +# This target merely builds a toolchan/sysroot, then builds the tools it wants +# with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain +# already built. It then installs the static tools to NXBDESTDIR for Poudriere +# to pickup. +# +NXBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/nxb/ +NXBOBJTOP= ${NXBOBJROOT}${NXB_TARGET}.${NXB_TARGET_ARCH} +NXTP?= /nxb-bin +.if ${NXTP:N/*} +.error NXTP variable should be an absolute path +.endif +NXBDESTDIR?= ${DESTDIR}${NXTP} + +# This is the list of tools to be built/installed as static and where +# appropriate to build for the given TARGET.TARGET_ARCH. +NXBDIRS+= \ bin/cat \ bin/chmod \ bin/cp \ - bin/csh \ + ${_tcsh} \ bin/echo \ bin/expr \ bin/hostname \ @@ -2157,24 +2137,18 @@ native-xtools: .PHONY bin/rmdir \ bin/sh \ bin/sleep \ - ${_clang_tblgen} \ - usr.bin/ar \ - ${_binutils} \ - ${_elftctools} \ - ${_gcc} \ - ${_gcc_tools} \ - ${_clang_libs} \ - ${_clang} \ - ${_lld} \ sbin/md5 \ sbin/sysctl \ - usr.bin/diff \ + usr.bin/addr2line \ + usr.bin/ar \ usr.bin/awk \ usr.bin/basename \ usr.bin/bmake \ usr.bin/bzip2 \ usr.bin/cmp \ + usr.bin/diff \ usr.bin/dirname \ + usr.bin/elfcopy \ usr.bin/env \ usr.bin/fetch \ usr.bin/find \ @@ -2184,14 +2158,16 @@ native-xtools: .PHONY usr.bin/lex \ usr.bin/limits \ usr.bin/lorder \ - ${_libopenbsd} \ - ${_makewhatis} \ + usr.bin/mandoc \ usr.bin/mktemp \ usr.bin/mt \ + usr.bin/nm \ usr.bin/patch \ usr.bin/readelf \ usr.bin/sed \ + usr.bin/size \ usr.bin/sort \ + usr.bin/strings \ usr.bin/tar \ usr.bin/touch \ usr.bin/tr \ @@ -2203,12 +2179,111 @@ native-xtools: .PHONY usr.bin/xz \ usr.bin/yacc \ usr.sbin/chown - ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \ - cd ${.CURDIR}/${_tool}; \ - if [ -z "${NO_OBJ}" ]; then ${NXBMAKE} DIRPRFX=${_tool}/ obj; fi; \ - ${NXBMAKE} DIRPRFX=${_tool}/ all; \ - ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install -.endfor + +SUBDIR_DEPEND_usr.bin/clang= lib/clang +.if ${MK_CLANG} != "no" +NXBDIRS+= lib/clang +NXBDIRS+= usr.bin/clang +.endif +.if ${MK_GCC} != "no" +NXBDIRS+= gnu/usr.bin/cc +.endif +.if ${MK_BINUTILS} != "no" +NXBDIRS+= gnu/usr.bin/binutils +.endif +# XXX: native-xtools passes along ${NXBDIRS} in SUBDIR_OVERRIDE that needs +# to be evaluated after NXBDIRS is set. +.if make(install) && !empty(SUBDIR_OVERRIDE) +SUBDIR= ${SUBDIR_OVERRIDE} +.endif + +NXBMAKEARGS+= \ + OBJTOP=${NXBOBJTOP:Q} \ + OBJROOT=${NXBOBJROOT:Q} \ + MAKEOBJDIRPREFIX= \ + -DNO_SHARED \ + -DNO_CPU_CFLAGS \ + -DNO_PIC \ + SSP_CFLAGS= \ + MK_CLANG_EXTRAS=yes \ + MK_CLANG_FULL=no \ + MK_CTF=no \ + MK_DEBUG_FILES=no \ + MK_GDB=no \ + MK_HTML=no \ + MK_LLDB=no \ + MK_MAN=no \ + MK_MAN_UTILS=yes \ + MK_OFED=no \ + MK_OPENSSH=no \ + MK_PROFILE=no \ + MK_SENDMAIL=no \ + MK_SVNLITE=no \ + MK_TESTS=no \ + MK_WARNS=no \ + MK_ZFS=no + +.if make(native-xtools*) && \ + (!defined(NXB_TARGET) || !defined(NXB_TARGET_ARCH)) +.error Missing NXB_TARGET / NXB_TARGET_ARCH +.endif +# For 'toolchain' we want to produce native binaries that themselves generate +# native binaries. +NXBTMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS:N-DNO_PIC:N-DNO_SHARED} \ + TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH} +# For 'everything' we want to produce native binaries (hence -target to +# be MACHINE) that themselves generate TARGET.TARGET_ARCH binaries. +# TARGET/TARGET_ARCH are still passed along from user. +# +# Use the toolchain we create as an external toolchain. +.if ${USING_SYSTEM_COMPILER} == "yes" || ${XCC:N${CCACHE_BIN}:M/*} +NXBMAKE+= XCC="${XCC}" \ + XCXX="${XCXX}" \ + XCPP="${XCPP}" +.else +NXBMAKE+= XCC="${NXBOBJTOP}/tmp/usr/bin/cc" \ + XCXX="${NXBOBJTOP}/tmp/usr/bin/c++" \ + XCPP="${NXBOBJTOP}/tmp/usr/bin/cpp" +.endif +NXBMAKE+= ${NXBMAKEENV} ${MAKE} -f Makefile.inc1 ${NXBMAKEARGS} \ + TARGET=${NXB_TARGET} TARGET_ARCH=${NXB_TARGET_ARCH} \ + TARGET_TRIPLE=${MACHINE_TRIPLE:Q} +# NXBDIRS is improperly based on MACHINE rather than NXB_TARGET. Need to +# invoke a sub-make to reevaluate MK_GCC, etc, for NXBDIRS. +NXBMAKE+= SUBDIR_OVERRIDE='$${NXBDIRS:M*}' +# Need to avoid the -isystem logic when using clang as an external toolchain +# even if the TARGET being built for wants GCC. +NXBMAKE+= WANT_COMPILER_TYPE='$${X_COMPILER_TYPE}' +native-xtools: .PHONY + ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _cleanobj + # Build the bootstrap/host/cross tools that produce native binaries + # Pass along MK_GCC=yes to ensure GCC-needed build tools are built. + # We don't quite know what the NXB_TARGET wants so just build it. + ${_+_}cd ${.CURDIR}; ${NXBTMAKE} kernel-toolchain MK_GCC=yes + # Populate includes/libraries sysroot that produce native binaries. + # This is split out from 'toolchain' above mostly so that target LLVM + # libraries have a proper LLVM_DEFAULT_TARGET_TRIPLE without + # polluting the cross-compiler build. The LLVM/GCC libs are skipped + # here to avoid the problem but are kept in 'toolchain' so that + # needed build tools are built. + ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _includes MK_CLANG=no MK_GCC=no + ${_+_}cd ${.CURDIR}; ${NXBTMAKE} _libraries MK_CLANG=no MK_GCC=no +.if !defined(NO_OBJWALK) + ${_+_}cd ${.CURDIR}; ${NXBMAKE} _obj +.endif + ${_+_}cd ${.CURDIR}; ${NXBMAKE} everything + @echo ">> native-xtools done. Use 'make native-xtools-install' to install to a given DESTDIR" + +native-xtools-install: .PHONY + mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ + -p ${NXBDESTDIR}/usr >/dev/null + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ + -p ${NXBDESTDIR}/usr/include >/dev/null + ${_+_}cd ${.CURDIR}; ${NXBMAKE} \ + DESTDIR=${NXBDESTDIR} \ + -DNO_ROOT \ + install # # hierarchy - ensure that all the needed directories are present @@ -2350,6 +2425,9 @@ lib/libcasper__L: lib/libnv__L lib/liblzma__L: lib/libthr__L _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib} +.if ${MK_IPFILTER} != "no" +_generic_libs+= sbin/ipf/libipf +.endif .for _DIR in ${LOCAL_LIB_DIRS} .if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR}) _generic_libs+= ${_DIR} @@ -2468,7 +2546,7 @@ ${_lib}__PL: .PHONY .MAKE .if exists(${.CURDIR}/${_lib}) ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \ cd ${.CURDIR}/${_lib}; \ - if [ -z "${NO_OBJ}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \ + if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \ ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \ DIRPRFX=${_lib}/ all; \ ${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \ @@ -2481,7 +2559,7 @@ ${_lib}__L: .PHONY .MAKE .if exists(${.CURDIR}/${_lib}) ${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \ cd ${.CURDIR}/${_lib}; \ - if [ -z "${NO_OBJ}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \ + if [ -z "${NO_OBJWALK}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \ ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \ ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install .endif @@ -2554,7 +2632,7 @@ delete-old-files: .PHONY done # Remove catpages without corresponding manpages. @exec 3<&0; \ - find ${DESTDIR}/usr/share/man/cat* ! -type d | \ + find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \ sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \ while read catpage; do \ read manpage; \ @@ -2580,7 +2658,7 @@ check-old-files: .PHONY done; \ done # Check for catpages without corresponding manpages. - @find ${DESTDIR}/usr/share/man/cat* ! -type d | \ + @find ${DESTDIR}/usr/share/man/cat* ! -type d 2>/dev/null | \ sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \ while read catpage; do \ read manpage; \ @@ -2718,21 +2796,31 @@ builddtb: .PHONY # # It is expected that BW_CANONICALOBJDIR == the CANONICALOBJDIR as would be # created by bsd.obj.mk, except that we don't want to .include that file -# in this makefile. +# in this makefile. We don't do a cleandir walk if MK_AUTO_OBJ is yes +# since it is not possible for files to land in the wrong place. # -BW_CANONICALOBJDIR:=${OBJTREE}${.CURDIR} -cleanworld: .PHONY -.if exists(${BW_CANONICALOBJDIR}/) - -rm -rf ${BW_CANONICALOBJDIR}/* +.if make(cleanworld) +BW_CANONICALOBJDIR:=${OBJTOP}/ +.elif make(cleanuniverse) +BW_CANONICALOBJDIR:=${OBJROOT} +.if ${MK_UNIFIED_OBJDIR} == "no" +.error ${.TARGETS} only supported with WITH_UNIFIED_OBJDIR enabled. +.endif +.endif +cleanworld cleanuniverse: .PHONY +.if !empty(BW_CANONICALOBJDIR) && exists(${BW_CANONICALOBJDIR}) && \ + ${.CURDIR:tA} != ${BW_CANONICALOBJDIR:tA} + -rm -rf ${BW_CANONICALOBJDIR}* -chflags -R 0 ${BW_CANONICALOBJDIR} - rm -rf ${BW_CANONICALOBJDIR}/* + rm -rf ${BW_CANONICALOBJDIR}* .endif +.if make(cleanworld) && ${MK_AUTO_OBJ} == "no" && \ + (empty(BW_CANONICALOBJDIR) || ${.CURDIR:tA} == ${BW_CANONICALOBJDIR:tA}) .if ${.CURDIR} == ${.OBJDIR} || ${.CURDIR}/obj == ${.OBJDIR} # To be safe in this case, fall back to a 'make cleandir' ${_+_}@cd ${.CURDIR}; ${MAKE} cleandir .endif - -.if defined(TARGET) && defined(TARGET_ARCH) +.endif .if ${TARGET} == ${MACHINE} && ${TARGET_ARCH} == ${MACHINE_ARCH} XDEV_CPUTYPE?=${CPUTYPE} @@ -2752,10 +2840,16 @@ XDTP?=/usr/${XDDIR} .error XDTP variable should be an absolute path .endif -CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \ +CDBOBJROOT= ${OBJROOT}${MACHINE}.${MACHINE_ARCH}/xdev/ +CDBOBJTOP= ${CDBOBJROOT}${XDDIR} +CDBENV= \ INSTALL="sh ${.CURDIR}/tools/install.sh" CDENV= ${CDBENV} \ TOOLS_PREFIX=${XDTP} +CDMAKEARGS= \ + OBJTOP=${CDBOBJTOP:Q} \ + OBJROOT=${CDBOBJROOT:Q} +CD2MAKEARGS= ${CDMAKEARGS} .if ${WANT_COMPILER_TYPE} == gcc || \ (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) @@ -2777,14 +2871,15 @@ CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}" CPP="${CPP} ${CD2CFLAGS}" \ MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} -CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp -CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN} -CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} ${MAKE} ${NOFUN} +CDTMP= ${OBJTOP}/${XDDIR}/tmp +CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${CDMAKEARGS} ${NOFUN} +CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} \ + ${MAKE} ${CD2MAKEARGS} ${NOFUN} .if ${MK_META_MODE} != "no" # Don't rebuild build-tools targets during normal build. CD2MAKE+= BUILD_TOOLS_META=.NOMETA .endif -XDDESTDIR=${DESTDIR}/${XDTP} +XDDESTDIR=${DESTDIR}${XDTP} .ORDER: xdev-build xdev-install xdev-links xdev: xdev-build xdev-install .PHONY @@ -2804,26 +2899,29 @@ _xb-bootstrap-tools: .PHONY ${_yacc} ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \ cd ${.CURDIR}/${_tool}; \ - if [ -z "${NO_OBJ}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \ + if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \ ${CDMAKE} DIRPRFX=${_tool}/ all; \ ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install .endfor _xb-build-tools: .PHONY ${_+_}@cd ${.CURDIR}; \ - ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools + ${CDBENV} ${MAKE} ${CDMAKEARGS} -f Makefile.inc1 ${NOFUN} build-tools -_xb-cross-tools: .PHONY -.for _tool in \ +XDEVDIRS= \ + ${_clang_libs} \ + ${_lld} \ ${_binutils} \ ${_elftctools} \ usr.bin/ar \ - ${_clang_libs} \ ${_clang} \ ${_gcc} + +_xb-cross-tools: .PHONY +.for _tool in ${XDEVDIRS} ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \ cd ${.CURDIR}/${_tool}; \ - if [ -z "${NO_OBJ}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \ + if [ -z "${NO_OBJWALK}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \ ${CDMAKE} DIRPRFX=${_tool}/ all .endfor @@ -2851,19 +2949,17 @@ xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries .P _xi-cross-tools: .PHONY @echo "_xi-cross-tools" -.for _tool in \ - ${_binutils} \ - ${_elftctools} \ - usr.bin/ar \ - ${_clang_libs} \ - ${_clang} \ - ${_gcc} +.for _tool in ${XDEVDIRS} ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \ cd ${.CURDIR}/${_tool}; \ ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR} .endfor _xi-includes: .PHONY +.if !defined(NO_OBJWALK) + ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 _obj \ + DESTDIR=${XDDESTDIR} +.endif ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 includes \ DESTDIR=${XDDESTDIR} @@ -2880,7 +2976,3 @@ xdev-links: .PHONY ln -sf ../../${XDTP}/usr/bin/$$i \ ../../../../usr/bin/${XDDIR}${_REVISION}-$$i; \ done -.else -xdev xdev-build xdev-install xdev-links: .PHONY - @echo "*** Error: Both TARGET and TARGET_ARCH must be defined for \"${.TARGET}\" target" -.endif diff --git Makefile.libcompat Makefile.libcompat index 67c699eb8ae8..4cae3d6b938c 100644 --- Makefile.libcompat +++ Makefile.libcompat @@ -59,10 +59,10 @@ LIB32WMAKEFLAGS+= -DCOMPAT_32BIT # ------------------------------------------------------------------- # soft-fp world -.if ${TARGET_ARCH} == "armv6" +.if ${TARGET_ARCH:Marmv[67]*} != "" LIBSOFTCFLAGS= -DCOMPAT_SOFTFP LIBSOFTCPUFLAGS= -mfloat-abi=softfp -LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=armv6 +LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=${TARGET_ARCH} LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP .endif @@ -70,7 +70,7 @@ LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP # Generic code for each type. # Set defaults based on type. libcompat= ${LIBCOMPAT:tl} -_LIBCOMPAT_MAKEVARS= _OBJTREE TMP CPUFLAGS CFLAGS CXXFLAGS WMAKEENV \ +_LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS WMAKEENV \ WMAKEFLAGS WMAKE .for _var in ${_LIBCOMPAT_MAKEVARS} .if !empty(LIB${LIBCOMPAT}${_var}) @@ -79,8 +79,8 @@ LIBCOMPAT${_var}?= ${LIB${LIBCOMPAT}${_var}} .endfor # Shared flags -LIBCOMPAT_OBJTREE?= ${OBJTREE}${.CURDIR}/world${libcompat} -LIBCOMPATTMP?= ${OBJTREE}${.CURDIR}/lib${libcompat} +LIBCOMPAT_OBJTOP?= ${OBJTOP}/obj-lib${libcompat} +LIBCOMPATTMP?= ${LIBCOMPAT_OBJTOP}/tmp LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \ -L${LIBCOMPATTMP}/usr/lib${libcompat} \ @@ -107,7 +107,7 @@ LIBCOMPATCXXFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \ .endif # Yes, the flags are redundant. -LIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} \ +LIBCOMPATWMAKEENV+= \ INSTALL="sh ${.CURDIR}/tools/install.sh" \ PATH=${TMPPATH} \ SYSROOT=${LIBCOMPATTMP} \ @@ -128,6 +128,9 @@ LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \ MK_SAFESTACK=no \ MK_TESTS=no LIBCOMPATWMAKE+= ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \ + OBJTOP=${LIBCOMPAT_OBJTOP} \ + OBJROOT='$${OBJTOP}/' \ + MAKEOBJDIRPREFIX= \ MK_MAN=no MK_HTML=no LIBCOMPATIMAKE+= ${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \ MK_TOOLCHAIN=no ${IMAKE_INSTALL} \ @@ -149,6 +152,16 @@ build${libcompat}: .PHONY @echo "--------------------------------------------------------------" @echo ">>> stage 5.1: building lib${libcompat} shim libraries" @echo "--------------------------------------------------------------" +.if !defined(NO_CLEAN) + rm -rf ${LIBCOMPATTMP} +.else +.if exists(${LIBCOMPATTMP}) + ${_+_}cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \ + DESTDIR=${LIBCOMPATTMP} \ + delete-old delete-old-libs >/dev/null +.endif +.endif # !defined(NO_CLEAN) + mkdir -p ${LIBCOMPATTMP}/usr/include mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ -p ${LIBCOMPATTMP}/usr >/dev/null @@ -174,16 +187,21 @@ build${libcompat}: .PHONY ${_+_}cd ${.CURDIR}/${_dir}; \ WORLDTMP=${WORLDTMP} \ MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ - MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \ + ${MAKE} SSP_CFLAGS= DESTDIR= \ + OBJTOP=${LIBCOMPAT_OBJTOP} \ + OBJROOT='$${OBJTOP}/' \ + MAKEOBJDIRPREFIX= \ DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ build-tools .endfor ${_+_}cd ${.CURDIR}; \ ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries -.if ${libcompat} == "32" && !defined(NO_RTLD) +.if ${libcompat} == "32" .for _t in ${_obj} all +.if !defined(NO_RTLD) ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \ -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t} +.endif ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \ DIRPRFX=usr.bin/ldd ${_t} .endfor @@ -193,9 +211,11 @@ distribute${libcompat} install${libcompat}: .PHONY .for _dir in ${_LC_LIBDIRS.yes} ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//} .endfor -.if ${libcompat} == "32" && !defined(NO_RTLD) +.if ${libcompat} == "32" +.if !defined(NO_RTLD) ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \ PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//} +.endif ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \ ${.TARGET:S/32$//} .endif diff --git ObsoleteFiles.inc ObsoleteFiles.inc index 935dc0e57846..fbe901e5cad4 100644 --- ObsoleteFiles.inc +++ ObsoleteFiles.inc @@ -38,9 +38,206 @@ # xargs -n1 | sort | uniq -d; # done +# 20171110: Removal of mailaddr man page +OLD_FILES+=usr/share/man/man7/mailaddr.7.gz +# 20171108: badsect(8) removal +OLD_FILES+=sbin/badsect +OLD_FILES+=rescue/badsect +OLD_FILES+=usr/share/man/man8/badsect.8.gz +# 20171105: fixing lib/libclang_rt CRTARCH for arm:armv[67]. +.if ${MACHINE_ARCH:Marmv[67]*} != "" && \ + (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") +OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.asan-preinit-arm.a +OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.asan-arm.a +OLD_LIBS+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.asan-arm.so +OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.asan_cxx-arm.a +OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.profile-arm.a +OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.safestack-arm.a +OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.stats-arm.a +OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.stats_client-arm.a +OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.ubsan_standalone-arm.a +OLD_FILES+=usr/lib/clang/5.0.0/lib/freebsd/libclang_rt.ubsan_standalone_cxx-arm.a +.endif +# 20171104: libcap_random should be in /lib not in /usr/lib +OLD_LIBS+=usr/lib/libcap_random.so.0 +# 20171104: Casper can work only as shared library +OLD_FILES+=usr/lib/libcasper.a +OLD_FILES+=usr/lib/libcasper_p.a +OLD_FILES+=usr/lib/libcap_dns.a +OLD_FILES+=usr/lib/libcap_dns_p.a +OLD_FILES+=usr/lib/libcap_grp.a +OLD_FILES+=usr/lib/libcap_grp_p.a +OLD_FILES+=usr/lib/libcap_pwd.a +OLD_FILES+=usr/lib/libcap_pwd_p.a +OLD_FILES+=usr/lib/libcap_random.a +OLD_FILES+=usr/lib/libcap_random_p.a +OLD_FILES+=usr/lib/libcap_sysctl.a +OLD_FILES+=usr/lib/libcap_sysctl_p.a +# 20171031: Removal of adding_user man page +OLD_FILES+=usr/share/man/man7/adding_user.7.gz +# 20171031: Disconnected libpathconv tests +OLD_DIRS+=usr/tests/lib/libpathconv +# 20171017: Removal of mbpool(9) +OLD_FILES+=usr/include/sys/mbpool.h +OLD_FILES+=usr/share/man/man9/mbpool.9.gz +OLD_FILES+=usr/share/man/man9/mbp_destroy.9.gz +OLD_FILES+=usr/share/man/man9/mbp_alloc.9.gz +OLD_FILES+=usr/share/man/man9/mbp_ext_free.9.gz +OLD_FILES+=usr/share/man/man9/mbp_count.9.gz +OLD_FILES+=usr/share/man/man9/mbp_card_free.9.gz +OLD_FILES+=usr/share/man/man9/mbp_get_keep.9.gz +OLD_FILES+=usr/share/man/man9/mbp_free.9.gz +OLD_FILES+=usr/share/man/man9/mbp_get.9.gz +OLD_FILES+=usr/share/man/man9/mbp_create.9.gz +OLD_FILES+=usr/share/man/man9/mbp_sync.9.gz +# 20171010: Remove libstand +OLD_FILES+=usr/lib/libstand.a +OLD_FILES+=usr/lib/libstand_p.a +OLD_FILES+=usr/include/stand.h +OLD_FILES+=usr/share/man/man3/libstand.3 +# 20171003: remove RCMDS +OLD_FILES+=bin/rcp +OLD_FILES+=rescue/rcp +OLD_FILES+=usr/bin/rlogin +OLD_FILES+=usr/bin/rsh +OLD_FILES+=usr/libexec/rlogind +OLD_FILES+=usr/libexec/rshd +OLD_FILES+=usr/share/man/man1/rcp.1.gz +OLD_FILES+=usr/share/man/man1/rlogin.1.gz +OLD_FILES+=usr/share/man/man1/rsh.1.gz +OLD_FILES+=usr/share/man/man8/rlogind.8.gz +OLD_FILES+=usr/share/man/man8/rshd.8.gz +# 20170927: crshared +OLD_FILES+=usr/share/man/man9/crshared.9.gz +# 20170927: procctl +OLD_FILES+=usr/share/man/man8/procctl.8.gz +OLD_FILES+=usr/sbin/procctl +# 20170926: remove unneeded man aliases and locales directory +OLD_FILES+=usr/share/man/en.ISO8859-1/man1 +OLD_FILES+=usr/share/man/en.ISO8859-1/man2 +OLD_FILES+=usr/share/man/en.ISO8859-1/man3 +OLD_FILES+=usr/share/man/en.ISO8859-1/man4 +OLD_FILES+=usr/share/man/en.ISO8859-1/man5 +OLD_FILES+=usr/share/man/en.ISO8859-1/man6 +OLD_FILES+=usr/share/man/en.ISO8859-1/man7 +OLD_FILES+=usr/share/man/en.ISO8859-1/man8 +OLD_FILES+=usr/share/man/en.ISO8859-1/man9 +OLD_DIRS+=usr/share/man/en.ISO8859-1 +OLD_FILES+=usr/share/man/en.ISO8859-1/mandoc.db +OLD_FILES+=usr/share/man/en.UTF-8/man1 +OLD_FILES+=usr/share/man/en.UTF-8/man2 +OLD_FILES+=usr/share/man/en.UTF-8/man3 +OLD_FILES+=usr/share/man/en.UTF-8/man4 +OLD_FILES+=usr/share/man/en.UTF-8/man5 +OLD_FILES+=usr/share/man/en.UTF-8/man6 +OLD_FILES+=usr/share/man/en.UTF-8/man7 +OLD_FILES+=usr/share/man/en.UTF-8/man8 +OLD_FILES+=usr/share/man/en.UTF-8/man9 +OLD_FILES+=usr/share/man/en.UTF-8/mandoc.db +OLD_DIRS+=usr/share/man/en.UTF-8 +OLD_FILES+=usr/share/man/en.ISO8859-15 +OLD_FILES+=usr/share/openssl/man/en.ISO8859-1/man1 +OLD_FILES+=usr/share/openssl/man/en.ISO8859-1/man3 +OLD_FILES+=usr/share/openssl/man/en.ISO8859-1/mandoc.db +OLD_DIRS+=usr/share/openssl/man/en.ISO8859-1 +OLD_FILES+=usr/share/openssl/man/en.ISO8859-15 +OLD_DIRS+=usr/share/man/ja/man1 +OLD_DIRS+=usr/share/man/ja/man2 +OLD_DIRS+=usr/share/man/ja/man3 +OLD_DIRS+=usr/share/man/ja/man4 +OLD_DIRS+=usr/share/man/ja/man5 +OLD_DIRS+=usr/share/man/ja/man6 +OLD_DIRS+=usr/share/man/ja/man7 +OLD_DIRS+=usr/share/man/ja/man8 +OLD_DIRS+=usr/share/man/ja/man9 +OLD_DIRS+=usr/share/man/ja +# 20170913: remove unneeded catman utility +OLD_FILES+=etc/periodic/weekly/330.catman +OLD_FILES+=usr/bin/catman +OLD_FILES+=usr/libexec/catman.local +OLD_FILES+=usr/share/man/man1/catman.1.gz +OLD_FILES+=usr/share/man/man8/catman.local.8.gz +OLD_DIRS+=usr/share/man/cat1 +OLD_DIRS+=usr/share/man/cat2 +OLD_DIRS+=usr/share/man/cat3 +OLD_DIRS+=usr/share/man/cat4/amd64 +OLD_DIRS+=usr/share/man/cat4/arm +OLD_DIRS+=usr/share/man/cat4/i386 +OLD_DIRS+=usr/share/man/cat4/powerpc +OLD_DIRS+=usr/share/man/cat4/sparc64 +OLD_DIRS+=usr/share/man/cat4 +OLD_DIRS+=usr/share/man/cat5 +OLD_DIRS+=usr/share/man/cat6 +OLD_DIRS+=usr/share/man/cat7 +OLD_DIRS+=usr/share/man/cat8/amd64 +OLD_DIRS+=usr/share/man/cat8/arm +OLD_DIRS+=usr/share/man/cat8/i386 +OLD_DIRS+=usr/share/man/cat8/powerpc +OLD_DIRS+=usr/share/man/cat8/sparc64 +OLD_DIRS+=usr/share/man/cat8 +OLD_DIRS+=usr/share/man/cat9 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat1 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat2 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat3 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat4/amd64 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat4/arm +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat4/i386 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat4/powerpc +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat4/sparc64 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat4 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat5 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat6 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat7 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat8/amd64 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat8/arm +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat8/i386 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat8/powerpc +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat8/sparc64 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat8 +OLD_DIRS+=usr/share/man/en.ISO8859-1/cat9 +OLD_DIRS+=usr/share/man/en.UTF-8/cat1 +OLD_DIRS+=usr/share/man/en.UTF-8/cat2 +OLD_DIRS+=usr/share/man/en.UTF-8/cat3 +OLD_DIRS+=usr/share/man/en.UTF-8/cat4/amd64 +OLD_DIRS+=usr/share/man/en.UTF-8/cat4/arm +OLD_DIRS+=usr/share/man/en.UTF-8/cat4/i386 +OLD_DIRS+=usr/share/man/en.UTF-8/cat4/powerpc +OLD_DIRS+=usr/share/man/en.UTF-8/cat4/sparc64 +OLD_DIRS+=usr/share/man/en.UTF-8/cat4 +OLD_DIRS+=usr/share/man/en.UTF-8/cat5 +OLD_DIRS+=usr/share/man/en.UTF-8/cat6 +OLD_DIRS+=usr/share/man/en.UTF-8/cat7 +OLD_DIRS+=usr/share/man/en.UTF-8/cat8/amd64 +OLD_DIRS+=usr/share/man/en.UTF-8/cat8/arm +OLD_DIRS+=usr/share/man/en.UTF-8/cat8/i386 +OLD_DIRS+=usr/share/man/en.UTF-8/cat8/powerpc +OLD_DIRS+=usr/share/man/en.UTF-8/cat8/sparc64 +OLD_DIRS+=usr/share/man/en.UTF-8/cat8 +OLD_DIRS+=usr/share/man/en.UTF-8/cat9 +OLD_DIRS+=usr/share/man/ja/cat1 +OLD_DIRS+=usr/share/man/ja/cat2 +OLD_DIRS+=usr/share/man/ja/cat3 +OLD_DIRS+=usr/share/man/ja/cat4/amd64 +OLD_DIRS+=usr/share/man/ja/cat4/arm +OLD_DIRS+=usr/share/man/ja/cat4/i386 +OLD_DIRS+=usr/share/man/ja/cat4/powerpc +OLD_DIRS+=usr/share/man/ja/cat4/sparc64 +OLD_DIRS+=usr/share/man/ja/cat4 +OLD_DIRS+=usr/share/man/ja/cat5 +OLD_DIRS+=usr/share/man/ja/cat6 +OLD_DIRS+=usr/share/man/ja/cat7 +OLD_DIRS+=usr/share/man/ja/cat8/amd64 +OLD_DIRS+=usr/share/man/ja/cat8/arm +OLD_DIRS+=usr/share/man/ja/cat8/powerpc +OLD_DIRS+=usr/share/man/ja/cat8/sparc64 +OLD_DIRS+=usr/share/man/ja/cat8 +OLD_DIRS+=usr/share/man/ja/cat9 +OLD_DIRS+=usr/share/openssl/man/cat1 +OLD_DIRS+=usr/share/openssl/man/cat3 +OLD_DIRS+=usr/share/openssl/man/en.ISO8859-1/cat1 +OLD_DIRS+=usr/share/openssl/man/en.ISO8859-1/cat3 # 20170802: ksyms(4) ioctl interface was removed OLD_FILES+=usr/include/sys/ksyms.h - # 20170722: new clang import which bumps version from 4.0.0 to 5.0.0. OLD_FILES+=usr/lib/clang/4.0.0/include/sanitizer/allocator_interface.h OLD_FILES+=usr/lib/clang/4.0.0/include/sanitizer/asan_interface.h diff --git README README index a097ddfdb108..c9068c34ee10 100644 --- README +++ README @@ -9,7 +9,7 @@ more information). The Makefile in this directory supports a number of targets for building components (or all) of the FreeBSD source tree. See build(7) -and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html +and https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html for more information, including setting make(1) variables. The `buildkernel` and `installkernel` targets build and install @@ -18,7 +18,7 @@ the Makefile in this directory for more information on the standard build targets and compile-time flags. Building a kernel is a somewhat more involved process. See build(7), config(8), -and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html +and https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html for more information. Note: If you want to build and install the kernel with the @@ -81,4 +81,4 @@ usr.sbin System administration commands. For information on synchronizing your source tree with one or more of the FreeBSD Project's development branches, please see: - https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/updating-src.html + https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/current-stable.html diff --git README.md README.md index 9e1181e685b5..6b5e078f738c 100644 --- README.md +++ README.md @@ -11,7 +11,7 @@ more information). The Makefile in this directory supports a number of targets for building components (or all) of the FreeBSD source tree. See build(7) -and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html +and https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html for more information, including setting make(1) variables. The `buildkernel` and `installkernel` targets build and install @@ -20,7 +20,7 @@ the Makefile in this directory for more information on the standard build targets and compile-time flags. Building a kernel is a somewhat more involved process. See build(7), config(8), -and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html +and https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html for more information. Note: If you want to build and install the kernel with the @@ -83,4 +83,4 @@ usr.sbin System administration commands. For information on synchronizing your source tree with one or more of the FreeBSD Project's development branches, please see: - http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/synching.html + https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/current-stable.html diff --git UPDATING UPDATING index b50ab45fa1c5..6f852439bc7d 100644 --- UPDATING +++ UPDATING @@ -6,7 +6,7 @@ COMMON ITEMS: section later in the file. These instructions assume that you basically know what you are doing. If not, then please consult the FreeBSD handbook: - https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/updating-src.html + https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/current-stable.html Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before running portupgrade. @@ -51,6 +51,88 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW: ****************************** SPECIAL WARNING: ****************************** +201711xx: + The LOADER_FIREWIRE_SUPPORT build variable as been renamed to + WITH/OUT_LOADER_FIREWIRE. LOADER_{NO_,}GELI_SUPPORT has been renamed + to WITH/OUT_LOADER_GELI. + +20171106: + The naive and non-compliant support of posix_fallocate(2) in ZFS + has been removed as of r325320. The system call now returns EINVAL + when used on a ZFS file. Although the new behavior complies with the + standard, some consumers are not prepared to cope with it. + One known victim is lld prior to r325420. + +20171102: + Building in a FreeBSD src checkout will automatically create object + directories now rather than store files in the current directory if + 'make obj' was not ran. Calling 'make obj' is no longer necesarry. + This feature can be disabled by setting WITHOUT_AUTO_OBJ=yes in + /etc/src-env.conf (not /etc/src.conf), or passing the option in the + environment. + +20171101: + The default MAKEOBJDIR has changed from /usr/obj/<srcdir> for native + builds, and /usr/obj/<arch>/<srcdir> for cross-builds, to a unified + /usr/obj/<srcdir>/<arch>. This behavior can be changed to the old + format by setting WITHOUT_UNIFIED_OBJDIR=yes in /etc/src-env.conf, + the environment, or with -DWITHOUT_UNIFIED_OBJDIR when building. + The UNIFIED_OBJDIR option is a transitional feature that will be + removed for 12.0 release; please migrate to the new format for any + tools by looking up the OBJDIR used by 'make -V .OBJDIR' means rather + than hardcoding paths. + +20171028: + The native-xtools target no longer installs the files by default to the + OBJDIR. Use the native-xtools-install target with a DESTDIR to install + to ${DESTDIR}/${NXTP} where NXTP defaults to /nxb-bin. + +20171021: + As part of the boot loader infrastructure cleanup, LOADER_*_SUPPORT + options are changing from controlling the build if defined / undefined + to controlling the build with explicit 'yes' or 'no' values. They will + shift to WITH/WITHOUT options to match other options in the system. + +20171010: + libstand has turned into a private library for sys/boot use only. + It is no longer supported as a public interface outside of sys/boot. + +20171005: + The arm port has split armv6 into armv6 and armv7. armv7 is now + a valid TARGET_ARCH/MACHINE_ARCH setting. If you have an armv7 system + and are running a kernel from before r324363, you will need to add + MACHINE_ARCH=armv7 to 'make buildworld' to do a native build. + +20171003: + When building multiple kernels using KERNCONF, non-existent KERNCONF + files will produce an error and buildkernel will fail. Previously + missing KERNCONF files silently failed giving no indication as to + why, only to subsequently discover during installkernel that the + desired kernel was never built in the first place. + +20170912: + The default serial number format for CTL LUNs has changed. This will + affect users who use /dev/diskid/* device nodes, or whose FibreChannel + or iSCSI clients care about their LUNs' serial numbers. Users who + require serial number stability should hardcode serial numbers in + /etc/ctl.conf . + +20170912: + For 32-bit arm compiled for hard-float support, soft-floating point + binaries now always get their shared libraries from + LD_SOFT_LIBRARY_PATH (in the past, this was only used if + /usr/libsoft also existed). Only users with a hard-float ld.so, but + soft-float everything else should be affected. + +20170826: + The geli password typed at boot is now hidden. To restore the previous + behavior, see geli(8) for configuration options. + +20170825: + Move PMTUD blackhole counters to TCPSTATS and remove them from bare + sysctl values. Minor nit, but requires a rebuild of both world/kernel + to complete. + 20170814: "make check" behavior (made in ^/head@r295380) has been changed to execute from a limited sandbox, as opposed to executing from @@ -1792,21 +1874,6 @@ COMMON ITEMS: make installkernel KERNCONF=YOUR_KERNEL_HERE KODIR=/boot/testkernel nextboot -k testkernel - To just build a kernel when you know that it won't mess you up - -------------------------------------------------------------- - This assumes you are already running a CURRENT system. Replace - ${arch} with the architecture of your machine (e.g. "i386", - "arm", "amd64", "ia64", "pc98", "sparc64", "powerpc", "mips", etc). - - cd src/sys/${arch}/conf - config KERNEL_NAME_HERE - cd ../compile/KERNEL_NAME_HERE - make depend - make - make install - - If this fails, go to the "To build a kernel" section. - To rebuild everything and install it on the current system. ----------------------------------------------------------- # Note: sometimes if you are running current you gotta do more than @@ -1814,7 +1881,8 @@ COMMON ITEMS: <make sure you have good level 0 dumps> make buildworld - make kernel KERNCONF=YOUR_KERNEL_HERE + make buildkernel KERNCONF=YOUR_KERNEL_HERE + make installkernel KERNCONF=YOUR_KERNEL_HERE [1] <reboot in single user> [3] mergemaster -Fp [5] @@ -1914,10 +1982,7 @@ COMMON ITEMS: Make sure that you merge any new devices from GENERIC since the last time you updated your kernel config file. - [9] When checking out sources, you must include the -P flag to have - cvs prune empty directories. - - If CPUTYPE is defined in your /etc/make.conf, make sure to use the + [9] If CPUTYPE is defined in your /etc/make.conf, make sure to use the "?=" instead of the "=" assignment operator, so that buildworld can override the CPUTYPE if it needs to. diff --git UPDATING-HardenedBSD UPDATING-HardenedBSD index 104bfe3514ab..be94fd5c602f 100644 --- UPDATING-HardenedBSD +++ UPDATING-HardenedBSD @@ -1,3 +1,131 @@ +[20170914] TOCTOU fix, PAX_CONTROL_{ACL,EXTATTR} +__HardenedBSD_version = 1200055 + + hbsdcontrol + ----------------------------------------------------------------------- + The hbsdcontrol subsystem is an extattr(9) based control pane for + HardenedBSD's security settings. + + Currently only the system namespace supported. (The FreeBSD's extattr + subsystem has two namespace: system and user. The system namespace is + writeable only from non-jail root user, the user namespace is writeable + from all users.) + This means only the root can assign rules to specific file. The other + restriction is similar, only from the host is allowed to set rules to + specific file, and prohibited a such operation from jails, for jail's + root user too prohibited. + + To enable the hbsdcontrol subsystem, you should add the + + options PAX_CONTROL_EXTATTR + + kernel knob to your kernel config. + + The hbsdcontrol subsystem use the following extended attributes: + + hbsd.pax.aslr + hbsd.pax.noaslr + hbsd.pax.segvguard + hbsd.pax.nosegvguard + hbsd.pax.pageexec + hbsd.pax.nopageexec + hbsd.pax.mprotect + hbsd.pax.nomprotect + hbsd.pax.shlibrandom + hbsd.pax.noshlibrandom + hbsd.pax.disallow_map32bit + hbsd.pax.nodisallow_map32bit + + Valid values are only the 0 (= disabled) and 1 (= enabled). + Valid settings are the following in system FS-EA namespace (with the ASLR + example, the same is true for the other settings): + + * no hbsd.pax.aslr, nor hbsd.pax.noaslr assigned to the file -> system default + * hbsd.pax.aslr = 1 and hbsd.pax.noaslr = 0 -> enabled ASLR + * hbsd.pax.aslr = 0 and hbsd.pax.noaslr = 1 -> disabled ASLR + * hbsd.pax.aslr = 0 and hbsd.pax.noaslr = 0 -> invalid, warning message + execution error + * hbsd.pax.aslr = 1 and hbsd.pax.noaslr = 1 -> invalid, warning message + execution error + + Attributes in user namespace are ignored. + + TOCTOU fix, PAX_ACL + ----------------------------------------------------------------------- + As preparation to hbsdcontrol, and to clean up the whole control logic + there is some new kernel knob: + + * PAX_CONTROL_ACL + * PAX_CONTROL_ACL_OVERRIDE_SUPPORT + * PAX_CONTROL_EXTATTR + + If you want to use the external secadm utility to manage hardenedbsd's + security features, then you should add + + options PAX_CONTROL_ACL + + to your kernel config. + + If you want to use the extattr(9) based hbsdcontrol, you should add + the + + options PAX_CONTROL_EXTATTR + + kernel knob. + + If you want to use both hbsdcontrol and secadm, and it's nice to add + + option PAX_CONTROL_ACL_OVERRIDE_SUPPORT + + too. This is nice in very special case, when you set rules both + from hbsdcontrol and from secadm on the _same_ file. By default + always the hbsdcontrol wins this situation, and what was set up + by hbsdcontrol gets applied as policy. To override this behavior + you can add a special flag in you secadm conf to override this + behavior. For more details consult with secadm's source code / + readme / man page. + + +[20170914] Changed auxvector after e5ea82a50dd64a3e47767b132a16281242ff396d +__HardenedBSD_version = 1200054 + + After the following commit: + + > commit e5ea82a50dd64a3e47767b132a16281242ff396d + > Author: jhb <jhb@FreeBSD.org> + > Date: Thu Sep 14 14:26:55 2017 +0000 + + > Add AT_HWCAP and AT_EHDRFLAGS on all platforms. + > + > A new 'u_long *sv_hwcap' field is added to 'struct sysentvec'. A + > process ABI can set this field to point to a value holding a mask of + > architecture-specific CPU feature flags. If an ABI does not wish to + > supply AT_HWCAP to processes the field can be left as NULL. + > + > The support code for AT_EHDRFLAGS was already present on all systems, + > just the #define was not present. This is a step towards unifying the + > AT_* constants across platforms. + > + > Reviewed by: kib + > MFC after: 1 month + > Differential Revision: https://reviews.freebsd.org/D12290 + + > Notes: + > svn path=/head/; revision=323579 + + the AT_PAXFLAGS has been changed from 24 to 26 position in + elf auxvector. This may break some functionality, especially + the SHLIBRAND feature, when you running on a newer kernel + with an older user-space. + + +[20170831] Changed pax_elf API +__HardenedBSD_version = 1200053 + + As preparation to hardenedBSD rationalize + the pax_elf(...) functions signature, to + follow the codes in kern_exec's style. + For the details, see the code. + + [20170709] Enforced KPI __HardenedBSD_version = 1200052 diff --git bin/Makefile bin/Makefile index 3e7571c27e61..3ad97ac8d624 100644 --- bin/Makefile +++ bin/Makefile @@ -40,7 +40,6 @@ SUBDIR= cat \ test \ uuidgen -SUBDIR.${MK_RCMDS}+= rcp SUBDIR.${MK_SENDMAIL}+= rmail SUBDIR.${MK_TCSH}+= csh SUBDIR.${MK_TESTS}+= tests diff --git bin/cat/Makefile.depend bin/cat/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/cat/Makefile.depend +++ bin/cat/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/cat/cat.c bin/cat/cat.c index 770ab61a08a4..57d48028906e 100644 --- bin/cat/cat.c +++ bin/cat/cat.c @@ -226,10 +226,16 @@ cook_cat(FILE *fp) } else gobble = 0; } - if (nflag && (!bflag || ch != '\n')) { - (void)fprintf(stdout, "%6d\t", ++line); - if (ferror(stdout)) - break; + if (nflag) { + if (!bflag || ch != '\n') { + (void)fprintf(stdout, "%6d\t", ++line); + if (ferror(stdout)) + break; + } else if (eflag) { + (void)fprintf(stdout, "%6s\t", ""); + if (ferror(stdout)) + break; + } } } if (ch == '\n') { diff --git bin/cat/tests/Makefile bin/cat/tests/Makefile index 92e16aea1732..ebc313c5a091 100644 --- bin/cat/tests/Makefile +++ bin/cat/tests/Makefile @@ -17,10 +17,4 @@ ${PACKAGE}FILES+= d_vt_output.out .include <netbsd-tests.test.mk> -d_align.out: ${TESTSRC}/d_align.out - sed -E -e 's,^[[:space:]]{7}\$$$$,\$$,' < ${.ALLSRC} > ${.TARGET}.tmp - mv ${.TARGET}.tmp ${.TARGET} - -CLEANFILES+= d_align.out d_align.out.tmp - .include <bsd.test.mk> diff --git bin/chflags/Makefile bin/chflags/Makefile index db9defdcded3..1cee973c5655 100644 --- bin/chflags/Makefile +++ bin/chflags/Makefile @@ -1,7 +1,12 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ +.include <src.opts.mk> + PACKAGE=runtime PROG= chflags +HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests + .include <bsd.prog.mk> diff --git bin/chflags/Makefile.depend bin/chflags/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/chflags/Makefile.depend +++ bin/chflags/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/chflags/tests/Makefile bin/chflags/tests/Makefile new file mode 100644 index 000000000000..e0737b090b95 --- /dev/null +++ bin/chflags/tests/Makefile @@ -0,0 +1,5 @@ +# $FreeBSD$ + +ATF_TESTS_SH+= chflags_test + +.include <bsd.test.mk> diff --git bin/chflags/tests/Makefile.depend bin/chflags/tests/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ bin/chflags/tests/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git bin/chflags/tests/chflags_test.sh bin/chflags/tests/chflags_test.sh new file mode 100644 index 000000000000..5574e370d68d --- /dev/null +++ bin/chflags/tests/chflags_test.sh @@ -0,0 +1,63 @@ +# +# Copyright 2017 Shivansh Rai +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +usage_output='usage: chflags' + +atf_test_case invalid_usage +invalid_usage_head() +{ + atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message" +} + +invalid_usage_body() +{ + atf_check -s not-exit:0 -e match:"$usage_output" chflags -f + atf_check -s not-exit:0 -e match:"$usage_output" chflags -H + atf_check -s not-exit:0 -e match:"$usage_output" chflags -h + atf_check -s not-exit:0 -e match:"$usage_output" chflags -L + atf_check -s not-exit:0 -e match:"$usage_output" chflags -P + atf_check -s not-exit:0 -e match:"$usage_output" chflags -R + atf_check -s not-exit:0 -e match:"$usage_output" chflags -v +} + +atf_test_case no_arguments +no_arguments_head() +{ + atf_set "descr" "Verify that chflags(1) fails and generates a valid usage message when no arguments are supplied" +} + +no_arguments_body() +{ + atf_check -s not-exit:0 -e match:"$usage_output" chflags +} + +atf_init_test_cases() +{ + atf_add_test_case invalid_usage + atf_add_test_case no_arguments +} diff --git bin/chio/Makefile.depend bin/chio/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/chio/Makefile.depend +++ bin/chio/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/chmod/Makefile.depend bin/chmod/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/chmod/Makefile.depend +++ bin/chmod/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/chmod/tests/Makefile.depend bin/chmod/tests/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ bin/chmod/tests/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git bin/cp/Makefile.depend bin/cp/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/cp/Makefile.depend +++ bin/cp/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/csh/Makefile.depend bin/csh/Makefile.depend index c7bb5b0b113c..05f33d1d7799 100644 --- bin/csh/Makefile.depend +++ bin/csh/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git bin/date/Makefile.depend bin/date/Makefile.depend index 26cae4ede976..4bd09984c29d 100644 --- bin/date/Makefile.depend +++ bin/date/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/protocols \ include/xlocale \ diff --git bin/dd/Makefile.depend bin/dd/Makefile.depend index 4def626103ce..1adfc08a54d6 100644 --- bin/dd/Makefile.depend +++ bin/dd/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/dd/args.c bin/dd/args.c index 5c82983beecf..7a39ada74db1 100644 --- bin/dd/args.c +++ bin/dd/args.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> +#include <ctype.h> #include <err.h> #include <errno.h> #include <inttypes.h> @@ -184,7 +185,7 @@ f_bs(char *arg) res = get_num(arg); if (res < 1 || res > SSIZE_MAX) - errx(1, "bs must be between 1 and %jd", (intmax_t)SSIZE_MAX); + errx(1, "bs must be between 1 and %zd", (ssize_t)SSIZE_MAX); in.dbsz = out.dbsz = (size_t)res; } @@ -195,22 +196,22 @@ f_cbs(char *arg) res = get_num(arg); if (res < 1 || res > SSIZE_MAX) - errx(1, "cbs must be between 1 and %jd", (intmax_t)SSIZE_MAX); + errx(1, "cbs must be between 1 and %zd", (ssize_t)SSIZE_MAX); cbsz = (size_t)res; } static void f_count(char *arg) { - intmax_t res; + uintmax_t res; - res = (intmax_t)get_num(arg); - if (res < 0) - errx(1, "count cannot be negative"); + res = get_num(arg); + if (res == UINTMAX_MAX) + errc(1, ERANGE, "%s", oper); if (res == 0) - cpy_cnt = (uintmax_t)-1; + cpy_cnt = UINTMAX_MAX; else - cpy_cnt = (uintmax_t)res; + cpy_cnt = res; } static void @@ -219,7 +220,7 @@ f_files(char *arg) files_cnt = get_num(arg); if (files_cnt < 1) - errx(1, "files must be between 1 and %jd", (uintmax_t)-1); + errx(1, "files must be between 1 and %zu", SIZE_MAX); } static void @@ -240,8 +241,8 @@ f_ibs(char *arg) if (!(ddflags & C_BS)) { res = get_num(arg); if (res < 1 || res > SSIZE_MAX) - errx(1, "ibs must be between 1 and %jd", - (intmax_t)SSIZE_MAX); + errx(1, "ibs must be between 1 and %zd", + (ssize_t)SSIZE_MAX); in.dbsz = (size_t)res; } } @@ -261,8 +262,8 @@ f_obs(char *arg) if (!(ddflags & C_BS)) { res = get_num(arg); if (res < 1 || res > SSIZE_MAX) - errx(1, "obs must be between 1 and %jd", - (intmax_t)SSIZE_MAX); + errx(1, "obs must be between 1 and %zd", + (ssize_t)SSIZE_MAX); out.dbsz = (size_t)res; } } diff --git bin/dd/conv.c bin/dd/conv.c index 89987b3ea9d1..5d8e771e33dc 100644 --- bin/dd/conv.c +++ bin/dd/conv.c @@ -133,7 +133,7 @@ block(void) */ ch = 0; for (inp = in.dbp - in.dbcnt, outp = out.dbp; in.dbcnt;) { - maxlen = MIN(cbsz, in.dbcnt); + maxlen = MIN(cbsz, (size_t)in.dbcnt); if ((t = ctab) != NULL) for (cnt = 0; cnt < maxlen && (ch = *inp++) != '\n'; ++cnt) @@ -146,7 +146,7 @@ block(void) * Check for short record without a newline. Reassemble the * input block. */ - if (ch != '\n' && in.dbcnt < cbsz) { + if (ch != '\n' && (size_t)in.dbcnt < cbsz) { (void)memmove(in.db, in.dbp - in.dbcnt, in.dbcnt); break; } @@ -228,7 +228,7 @@ unblock(void) * translation has to already be done or we might not recognize the * spaces. */ - for (inp = in.db; in.dbcnt >= cbsz; inp += cbsz, in.dbcnt -= cbsz) { + for (inp = in.db; (size_t)in.dbcnt >= cbsz; inp += cbsz, in.dbcnt -= cbsz) { for (t = inp + cbsz - 1; t >= inp && *t == ' '; --t) ; if (t >= inp) { diff --git bin/dd/dd.c bin/dd/dd.c index 22d2bd5d8e34..3ac110355dec 100644 --- bin/dd/dd.c +++ bin/dd/dd.c @@ -204,10 +204,10 @@ setup(void) * record oriented I/O, only need a single buffer. */ if (!(ddflags & (C_BLOCK | C_UNBLOCK))) { - if ((in.db = malloc(out.dbsz + in.dbsz - 1)) == NULL) + if ((in.db = malloc((size_t)out.dbsz + in.dbsz - 1)) == NULL) err(1, "input buffer"); out.db = in.db; - } else if ((in.db = malloc(MAX(in.dbsz, cbsz) + cbsz)) == NULL || + } else if ((in.db = malloc(MAX((size_t)in.dbsz, cbsz) + cbsz)) == NULL || (out.db = malloc(out.dbsz + cbsz)) == NULL) err(1, "output buffer"); @@ -405,7 +405,7 @@ dd_in(void) ++st.in_full; /* Handle full input blocks. */ - } else if ((size_t)n == in.dbsz) { + } else if ((size_t)n == (size_t)in.dbsz) { in.dbcnt += in.dbrcnt = n; ++st.in_full; @@ -562,7 +562,7 @@ dd_out(int force) outp += nw; st.bytes += nw; - if ((size_t)nw == n && n == out.dbsz) + if ((size_t)nw == n && n == (size_t)out.dbsz) ++st.out_full; else ++st.out_part; diff --git bin/dd/dd.h bin/dd/dd.h index 87def085d745..932530262526 100644 --- bin/dd/dd.h +++ bin/dd/dd.h @@ -38,10 +38,9 @@ typedef struct { u_char *db; /* buffer address */ u_char *dbp; /* current buffer I/O address */ - /* XXX ssize_t? */ - size_t dbcnt; /* current buffer byte count */ - size_t dbrcnt; /* last read byte count */ - size_t dbsz; /* block size */ + ssize_t dbcnt; /* current buffer byte count */ + ssize_t dbrcnt; /* last read byte count */ + ssize_t dbsz; /* block size */ #define ISCHR 0x01 /* character device (warn on short) */ #define ISPIPE 0x02 /* pipe-like (see position.c) */ diff --git bin/dd/position.c bin/dd/position.c index d816716456fe..a4f3b46f167e 100644 --- bin/dd/position.c +++ bin/dd/position.c @@ -207,7 +207,7 @@ pos_out(void) n = write(out.fd, out.db, out.dbsz); if (n == -1) err(1, "%s", out.name); - if ((size_t)n != out.dbsz) + if (n != out.dbsz) errx(1, "%s: write failure", out.name); } break; diff --git bin/df/Makefile.depend bin/df/Makefile.depend index 137678c21e46..5770a091f2a6 100644 --- bin/df/Makefile.depend +++ bin/df/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/domainname/Makefile.depend bin/domainname/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/domainname/Makefile.depend +++ bin/domainname/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/echo/Makefile.depend bin/echo/Makefile.depend index 4def626103ce..1adfc08a54d6 100644 --- bin/echo/Makefile.depend +++ bin/echo/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/echo/tests/Makefile.depend bin/echo/tests/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ bin/echo/tests/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git bin/ed/Makefile.depend bin/ed/Makefile.depend index fc0b63320671..cdd96948933d 100644 --- bin/ed/Makefile.depend +++ bin/ed/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/expr/Makefile.depend bin/expr/Makefile.depend index ca0b2f9610f7..d084433f911c 100644 --- bin/expr/Makefile.depend +++ bin/expr/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/getfacl/Makefile.depend bin/getfacl/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/getfacl/Makefile.depend +++ bin/getfacl/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/hostname/Makefile.depend bin/hostname/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/hostname/Makefile.depend +++ bin/hostname/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/kenv/Makefile.depend bin/kenv/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/kenv/Makefile.depend +++ bin/kenv/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/kill/Makefile.depend bin/kill/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/kill/Makefile.depend +++ bin/kill/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/ln/Makefile.depend bin/ln/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/ln/Makefile.depend +++ bin/ln/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/ln/tests/Makefile.depend bin/ln/tests/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ bin/ln/tests/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git bin/ls/Makefile.depend bin/ls/Makefile.depend index 6151c71a3632..6f1067211443 100644 --- bin/ls/Makefile.depend +++ bin/ls/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/mkdir/Makefile bin/mkdir/Makefile index 45876288fc40..79ed25fdc204 100644 --- bin/mkdir/Makefile +++ bin/mkdir/Makefile @@ -1,7 +1,12 @@ # @(#)Makefile 8.1 (Berkeley) 5/31/93 # $FreeBSD$ +.include <src.opts.mk> + PACKAGE=runtime PROG= mkdir +HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests + .include <bsd.prog.mk> diff --git bin/mkdir/Makefile.depend bin/mkdir/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/mkdir/Makefile.depend +++ bin/mkdir/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/mkdir/tests/Makefile bin/mkdir/tests/Makefile new file mode 100644 index 000000000000..3b28a958bea0 --- /dev/null +++ bin/mkdir/tests/Makefile @@ -0,0 +1,5 @@ +# $FreeBSD$ + +ATF_TESTS_SH+= mkdir_test + +.include <bsd.test.mk> diff --git bin/mkdir/tests/Makefile.depend bin/mkdir/tests/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ bin/mkdir/tests/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git bin/mkdir/tests/mkdir_test.sh bin/mkdir/tests/mkdir_test.sh new file mode 100644 index 000000000000..985a486d2075 --- /dev/null +++ bin/mkdir/tests/mkdir_test.sh @@ -0,0 +1,61 @@ +# +# Copyright 2017 Shivansh Rai +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +usage_output='usage: mkdir' + +atf_test_case invalid_usage +invalid_usage_head() +{ + atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message" +} + +invalid_usage_body() +{ + atf_check -s not-exit:0 -e inline:"mkdir: option requires an argument -- m +usage: mkdir [-pv] [-m mode] directory_name ... +" mkdir -m + atf_check -s not-exit:0 -e match:"$usage_output" mkdir -p + atf_check -s not-exit:0 -e match:"$usage_output" mkdir -v +} + +atf_test_case no_arguments +no_arguments_head() +{ + atf_set "descr" "Verify that mkdir(1) fails and generates a valid usage message when no arguments are supplied" +} + +no_arguments_body() +{ + atf_check -s not-exit:0 -e match:"$usage_output" mkdir +} + +atf_init_test_cases() +{ + atf_add_test_case invalid_usage + atf_add_test_case no_arguments +} diff --git bin/mv/Makefile.depend bin/mv/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/mv/Makefile.depend +++ bin/mv/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/pax/Makefile.depend bin/pax/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/pax/Makefile.depend +++ bin/pax/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/pkill/Makefile.depend bin/pkill/Makefile.depend index 35df7dcbf24e..6f5a5f79bf30 100644 --- bin/pkill/Makefile.depend +++ bin/pkill/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/pkill/pkill.c bin/pkill/pkill.c index 380dc29e1f04..8a307a6022ea 100644 --- bin/pkill/pkill.c +++ bin/pkill/pkill.c @@ -568,7 +568,7 @@ main(int argc, char **argv) continue; rv |= (*action)(kp); } - if (rv && pgrep) + if (rv && pgrep && !quiet) putchar('\n'); if (!did_action && !pgrep && longfmt) fprintf(stderr, diff --git bin/ps/Makefile.depend bin/ps/Makefile.depend index 1576eff2f0c6..eefffb37d491 100644 --- bin/ps/Makefile.depend +++ bin/ps/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/ps/keyword.c bin/ps/keyword.c index 55c89a134250..5c873910f33c 100644 --- bin/ps/keyword.c +++ bin/ps/keyword.c @@ -199,7 +199,8 @@ static VAR var[] = { {"tdaddr", "TDADDR", NULL, "thread-address", 0, kvar, KOFF(ki_tdaddr), KPTR, "lx", 0}, {"tdev", "TDEV", NULL, "terminal-device", 0, tdev, 0, CHAR, NULL, 0}, - {"tdnam", "TDNAM", NULL, "terminal-device-name", LJUST, tdnam, 0, CHAR, + {"tdnam", "", "tdname", NULL, 0, NULL, 0, CHAR, NULL, 0}, + {"tdname", "TDNAME", NULL, "thread-name", LJUST, tdnam, 0, CHAR, NULL, 0}, {"time", "TIME", NULL, "cpu-time", USER, cputime, 0, CHAR, NULL, 0}, {"tpgid", "TPGID", NULL, "terminal-process-gid", 0, kvar, diff --git bin/ps/print.c bin/ps/print.c index d84628771ff0..cb63369a3992 100644 --- bin/ps/print.c +++ bin/ps/print.c @@ -262,9 +262,9 @@ state(KINFO *k, VARENT *ve __unused) cp++; if (!(flag & P_INMEM)) *cp++ = 'W'; - if (k->ki_p->ki_nice < NZERO) + if (k->ki_p->ki_nice < NZERO || k->ki_p->ki_pri.pri_class == PRI_REALTIME) *cp++ = '<'; - else if (k->ki_p->ki_nice > NZERO) + else if (k->ki_p->ki_nice > NZERO || k->ki_p->ki_pri.pri_class == PRI_IDLE) *cp++ = 'N'; if (flag & P_TRACED) *cp++ = 'X'; @@ -274,6 +274,8 @@ state(KINFO *k, VARENT *ve __unused) *cp++ = 'V'; if ((flag & P_SYSTEM) || k->ki_p->ki_lock > 0) *cp++ = 'L'; + if ((k->ki_p->ki_cr_flags & CRED_FLAG_CAPMODE) != 0) + *cp++ = 'C'; if (k->ki_p->ki_kiflag & KI_SLEADER) *cp++ = 's'; if ((flag & P_CONTROLT) && k->ki_p->ki_pgid == k->ki_p->ki_tpgid) diff --git bin/ps/ps.1 bin/ps/ps.1 index b5270cfcdecc..67bea88f1a4d 100644 --- bin/ps/ps.1 +++ bin/ps/ps.1 @@ -29,7 +29,7 @@ .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd July 25, 2017 +.Dd October 9, 2017 .Dt PS 1 .Os .Sh NAME @@ -436,6 +436,10 @@ information: The process is in the foreground process group of its control terminal. .It Li < The process has raised CPU scheduling priority. +.It Li C +The process is in +.Xr capsicum 4 +capability mode. .It Li E The process is trying to exit. .It Li J @@ -541,7 +545,7 @@ short-term CPU usage factor (for scheduling) .It Cm dsiz data size (in Kbytes) .It Cm emul -system-call emulation environment +system-call emulation environment (ABI) .It Cm etime elapsed running time, format .Op days- Ns @@ -671,6 +675,8 @@ saved UID from a setuid executable accumulated system CPU time .It Cm tdaddr thread address +.It Cm tdname +thread name .It Cm tdev control terminal device number .It Cm time diff --git bin/ps/ps.c bin/ps/ps.c index cb3e5e64aae5..40dc4f77f6b2 100644 --- bin/ps/ps.c +++ bin/ps/ps.c @@ -523,7 +523,11 @@ main(int argc, char *argv[]) */ nentries = -1; kp = kvm_getprocs(kd, what, flag, &nentries); - if ((kp == NULL && nentries > 0) || (kp != NULL && nentries < 0)) + /* + * Ignore ESRCH to preserve behaviour of "ps -p nonexistent-pid" + * not reporting an error. + */ + if ((kp == NULL && errno != ESRCH) || (kp != NULL && nentries < 0)) xo_errx(1, "%s", kvm_geterr(kd)); nkept = 0; if (nentries > 0) { diff --git bin/pwait/Makefile.depend bin/pwait/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/pwait/Makefile.depend +++ bin/pwait/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/pwait/pwait.c bin/pwait/pwait.c index 76989c919371..85ecc7b7b2b0 100644 --- bin/pwait/pwait.c +++ bin/pwait/pwait.c @@ -71,6 +71,7 @@ main(int argc, char *argv[]) long pid; char *s, *end; double timeout; + pid_t me; tflag = verbose = 0; memset(&itv, 0, sizeof(itv)); @@ -118,6 +119,8 @@ main(int argc, char *argv[]) if (argc == 0) usage(); + me = getpid(); + kq = kqueue(); if (kq == -1) err(1, "kqueue"); @@ -136,6 +139,10 @@ main(int argc, char *argv[]) warnx("%s: bad process id", s); continue; } + if (pid == me) { + warnx("%s: ignoring own process id", s); + continue; + } duplicate = 0; for (i = 0; i < nleft; i++) if (e[i].ident == (uintptr_t)pid) diff --git bin/pwd/Makefile.depend bin/pwd/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/pwd/Makefile.depend +++ bin/pwd/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/rcp/Makefile bin/rcp/Makefile deleted file mode 100644 index 6c1cfb18a8c5..000000000000 --- bin/rcp/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 7/19/93 -# $FreeBSD$ - -PACKAGE=rcmds -PROG= rcp -SRCS= rcp.c util.c -CFLAGS+=-DBINDIR=${BINDIR} - -PACKAGE=rcmds - -BINOWN= root -BINMODE=4555 - -.include <bsd.prog.mk> diff --git bin/rcp/rcp.1 bin/rcp/rcp.1 deleted file mode 100644 index 9d2b8ae35bca..000000000000 --- bin/rcp/rcp.1 +++ /dev/null @@ -1,160 +0,0 @@ -.\"- -.\" Copyright (c) 1983, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)rcp.1 8.1 (Berkeley) 5/31/93 -.\" $FreeBSD$ -.\" -.Dd July 3, 2017 -.Dt RCP 1 -.Os -.Sh NAME -.Nm rcp -.Nd remote file copy -.Sh SYNOPSIS -.Nm -.Op Fl 46p -.Ar file1 file2 -.Nm -.Op Fl 46pr -.Ar -.Ar directory -.Sh DEPRECATION NOTICE -.Nm -is deprecated and will be removed from future versions of the -.Fx -base system. -If -.Nm -is still required, it can be installed from ports or packages -(net/bsdrcmds). -.Sh DESCRIPTION -The -.Nm -utility copies files between machines. -Each -.Ar file -or -.Ar directory -argument is either a remote file name of the -form -.Dq ruser@rhost:path , -or a local file name (containing no -.Ql :\& -characters, -or a -.Ql / -before any -.Ql :\& Ns -s). -.Pp -The following options are available: -.Bl -tag -width indent -.It Fl 4 -Use IPv4 addresses only. -.It Fl 6 -Use IPv6 addresses only. -.It Fl p -Cause -.Nm -to attempt to preserve (duplicate) in its copies the modification -times and modes of the source files, ignoring the -.Xr umask 2 . -By default, the mode and owner of -.Ar file2 -are preserved if it already existed; otherwise the mode of the source file -modified by the -.Xr umask 2 -on the destination host is used. -.It Fl r -If any of the source files are directories, -.Nm -copies each subtree rooted at that name; in this case -the destination must be a directory. -.El -.Pp -If -.Ar path -is not a full path name, it is interpreted relative to -the login directory of the specified user -.Ar ruser -on -.Ar rhost , -or your current user name if no other remote user name is specified. -A -.Ar path -on a remote host may be quoted (using -.Ql \e , -.Ql \&" , -or -.Ql \(aa ) -so that the metacharacters are interpreted remotely. -.Pp -The -.Nm -utility does not prompt for passwords; it performs remote execution -via -.Xr rsh 1 , -and requires the same authorization. -.Pp -The -.Nm -utility handles third party copies, where neither source nor target files -are on the current machine. -.Sh SEE ALSO -.Xr cp 1 , -.Xr ftp 1 , -.Xr rlogin 1 , -.Xr rsh 1 , -.Xr hosts.equiv 5 -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.2 . -The version of -.Nm -described here -has been reimplemented with Kerberos in -.Bx 4.3 Reno . -.Sh BUGS -Does not detect all cases where the target of a copy might -be a file in cases where only a directory should be legal. -.Pp -Is confused by any output generated by commands in a -.Pa .login , -.Pa .profile , -or -.Pa .cshrc -file on the remote host. -.Pp -The destination user and hostname may have to be specified as -.Dq rhost.ruser -when the destination machine is running the -.Bx 4.2 -version of -.Nm . diff --git bin/rcp/rcp.c bin/rcp/rcp.c deleted file mode 100644 index 3c6fdcf5ba41..000000000000 --- bin/rcp/rcp.c +++ /dev/null @@ -1,791 +0,0 @@ -/*- - * Copyright (c) 1983, 1990, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * Copyright (c) 2002 Networks Associates Technology, Inc. - * All rights reserved. - * - * Portions of this software were developed for the FreeBSD Project by - * ThinkSec AS and NAI Labs, the Security Research Division of Network - * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 - * ("CBOSS"), as part of the DARPA CHATS research program. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if 0 -#ifndef lint -static char const copyright[] = -"@(#) Copyright (c) 1983, 1990, 1992, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)rcp.c 8.2 (Berkeley) 4/2/94"; -#endif /* not lint */ -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netinet/in_systm.h> -#include <netinet/ip.h> - -#include <ctype.h> -#include <dirent.h> -#include <err.h> -#include <errno.h> -#include <fcntl.h> -#include <limits.h> -#include <netdb.h> -#include <paths.h> -#include <pwd.h> -#include <signal.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "extern.h" - -#define OPTIONS "46dfprt" - -static struct passwd *pwd; -static u_short port; -static uid_t userid; -static int errs, rem; -int iamremote; -static int pflag, iamrecursive, targetshouldbedirectory; -static int family = PF_UNSPEC; - -static int argc_copy; -static const char **argv_copy; - -static char period[] = "."; - -#define CMDNEEDS 64 -static char cmd[CMDNEEDS]; /* must hold "rcp -r -p -d\0" */ - -int response(void); -void rsource(char *, struct stat *); -void sink(int, char *[]); -void source(int, char *[]); -void tolocal(int, char *[]); -void toremote(char *, int, char *[]); -void usage(void); - -int -main(int argc, char *argv[]) -{ - struct servent *sp; - int ch, fflag, i, tflag; - char *targ; - - /* - * Prepare for execing ourselves. - */ - argc_copy = argc + 1; - argv_copy = malloc((argc_copy + 1) * sizeof(*argv_copy)); - if (argv_copy == NULL) - err(1, "malloc"); - argv_copy[0] = argv[0]; - argv_copy[1] = "-K"; - for (i = 1; i < argc; ++i) { - argv_copy[i + 1] = strdup(argv[i]); - if (argv_copy[i + 1] == NULL) - errx(1, "strdup: out of memory"); - } - argv_copy[argc + 1] = NULL; - - fflag = tflag = 0; - while ((ch = getopt(argc, argv, OPTIONS)) != -1) - switch(ch) { /* User-visible flags. */ - case '4': - family = PF_INET; - break; - - case '6': - family = PF_INET6; - break; - - case 'p': - pflag = 1; - break; - case 'r': - iamrecursive = 1; - break; - /* Server options. */ - case 'd': - targetshouldbedirectory = 1; - break; - case 'f': /* "from" */ - iamremote = 1; - fflag = 1; - break; - case 't': /* "to" */ - iamremote = 1; - tflag = 1; - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - sp = getservbyname("shell", "tcp"); - if (sp == NULL) - errx(1, "shell/tcp: unknown service"); - port = sp->s_port; - - if ((pwd = getpwuid(userid = getuid())) == NULL) - errx(1, "unknown user %d", (int)userid); - - rem = STDIN_FILENO; /* XXX */ - - if (fflag) { /* Follow "protocol", send data. */ - (void)response(); - (void)setuid(userid); - source(argc, argv); - exit(errs); - } - - if (tflag) { /* Receive data. */ - (void)setuid(userid); - sink(argc, argv); - exit(errs); - } - - if (argc < 2) - usage(); - if (argc > 2) - targetshouldbedirectory = 1; - - rem = -1; - /* Command to be executed on remote system using "rsh". */ - (void)snprintf(cmd, sizeof(cmd), "rcp%s%s%s", - iamrecursive ? " -r" : "", pflag ? " -p" : "", - targetshouldbedirectory ? " -d" : ""); - - (void)signal(SIGPIPE, lostconn); - - if ((targ = colon(argv[argc - 1]))) /* Dest is remote host. */ - toremote(targ, argc, argv); - else { - tolocal(argc, argv); /* Dest is local host. */ - if (targetshouldbedirectory) - verifydir(argv[argc - 1]); - } - exit(errs); -} - -void -toremote(char *targ, int argc, char *argv[]) -{ - int i, tos; - char *bp, *host, *src, *suser, *thost, *tuser; - - *targ++ = 0; - if (*targ == 0) - targ = period; - - if ((thost = strchr(argv[argc - 1], '@'))) { - /* user@host */ - *thost++ = 0; - tuser = argv[argc - 1]; - if (*tuser == '\0') - tuser = NULL; - else if (!okname(tuser)) - exit(1); - } else { - thost = argv[argc - 1]; - tuser = NULL; - } - - for (i = 0; i < argc - 1; i++) { - src = colon(argv[i]); - if (src) { /* remote to remote */ - *src++ = 0; - if (*src == 0) - src = period; - host = strchr(argv[i], '@'); - if (host) { - *host++ = 0; - suser = argv[i]; - if (*suser == '\0') - suser = pwd->pw_name; - else if (!okname(suser)) { - ++errs; - continue; - } - if (asprintf(&bp, - "%s %s -l %s -n %s %s '%s%s%s:%s'", - _PATH_RSH, host, suser, cmd, src, - tuser ? tuser : "", tuser ? "@" : "", - thost, targ) == -1) - err(1, "asprintf"); - } else - if (asprintf(&bp, - "exec %s %s -n %s %s '%s%s%s:%s'", - _PATH_RSH, argv[i], cmd, src, - tuser ? tuser : "", tuser ? "@" : "", - thost, targ) == -1) - err(1, "asprintf"); - (void)susystem(bp, userid); - (void)free(bp); - } else { /* local to remote */ - if (rem == -1) { - if (asprintf(&bp, "%s -t %s", cmd, targ) - == -1) - err(1, "asprintf"); - host = thost; - rem = rcmd_af(&host, port, - pwd->pw_name, - tuser ? tuser : pwd->pw_name, - bp, 0, family); - if (rem < 0) - exit(1); - if (family == PF_INET) { - tos = IPTOS_THROUGHPUT; - if (setsockopt(rem, IPPROTO_IP, IP_TOS, - &tos, sizeof(int)) < 0) - warn("TOS (ignored)"); - } - if (response() < 0) - exit(1); - (void)free(bp); - (void)setuid(userid); - } - source(1, argv+i); - } - } -} - -void -tolocal(int argc, char *argv[]) -{ - int i, len, tos; - char *bp, *host, *src, *suser; - - for (i = 0; i < argc - 1; i++) { - if (!(src = colon(argv[i]))) { /* Local to local. */ - len = strlen(_PATH_CP) + strlen(argv[i]) + - strlen(argv[argc - 1]) + 20; - if (!(bp = malloc(len))) - err(1, "malloc"); - (void)snprintf(bp, len, "exec %s%s%s %s %s", _PATH_CP, - iamrecursive ? " -PR" : "", pflag ? " -p" : "", - argv[i], argv[argc - 1]); - if (susystem(bp, userid)) - ++errs; - (void)free(bp); - continue; - } - *src++ = 0; - if (*src == 0) - src = period; - if ((host = strchr(argv[i], '@')) == NULL) { - host = argv[i]; - suser = pwd->pw_name; - } else { - *host++ = 0; - suser = argv[i]; - if (*suser == '\0') - suser = pwd->pw_name; - else if (!okname(suser)) { - ++errs; - continue; - } - } - len = strlen(src) + CMDNEEDS + 20; - if ((bp = malloc(len)) == NULL) - err(1, "malloc"); - (void)snprintf(bp, len, "%s -f %s", cmd, src); - rem = rcmd_af(&host, port, pwd->pw_name, suser, bp, 0, - family); - (void)free(bp); - if (rem < 0) { - ++errs; - continue; - } - (void)seteuid(userid); - if (family == PF_INET) { - tos = IPTOS_THROUGHPUT; - if (setsockopt(rem, IPPROTO_IP, IP_TOS, &tos, - sizeof(int)) < 0) - warn("TOS (ignored)"); - } - sink(1, argv + argc - 1); - (void)seteuid(0); - (void)close(rem); - rem = -1; - } -} - -void -source(int argc, char *argv[]) -{ - struct stat stb; - static BUF buffer; - BUF *bp; - off_t i; - int amt, fd, haderr, indx, result; - char *last, *name, buf[BUFSIZ]; - - for (indx = 0; indx < argc; ++indx) { - name = argv[indx]; - if ((fd = open(name, O_RDONLY, 0)) < 0) - goto syserr; - if (fstat(fd, &stb)) { -syserr: run_err("%s: %s", name, strerror(errno)); - goto next; - } - switch (stb.st_mode & S_IFMT) { - case S_IFREG: - break; - case S_IFDIR: - if (iamrecursive) { - rsource(name, &stb); - goto next; - } - /* FALLTHROUGH */ - default: - run_err("%s: not a regular file", name); - goto next; - } - if ((last = strrchr(name, '/')) == NULL) - last = name; - else - ++last; - if (pflag) { - /* - * Make it compatible with possible future - * versions expecting microseconds. - */ - (void)snprintf(buf, sizeof(buf), "T%ld 0 %ld 0\n", - (long)stb.st_mtim.tv_sec, - (long)stb.st_atim.tv_sec); - (void)write(rem, buf, strlen(buf)); - if (response() < 0) - goto next; - } -#define MODEMASK (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO) - (void)snprintf(buf, sizeof(buf), "C%04o %jd %s\n", - stb.st_mode & MODEMASK, (intmax_t)stb.st_size, last); - (void)write(rem, buf, strlen(buf)); - if (response() < 0) - goto next; - if ((bp = allocbuf(&buffer, fd, BUFSIZ)) == NULL) { -next: if (fd >= 0) - (void)close(fd); - continue; - } - - /* Keep writing after an error so that we stay sync'd up. */ - for (haderr = i = 0; i < stb.st_size; i += bp->cnt) { - amt = bp->cnt; - if (i + amt > stb.st_size) - amt = stb.st_size - i; - if (!haderr) { - result = read(fd, bp->buf, amt); - if (result != amt) - haderr = result >= 0 ? EIO : errno; - } - if (haderr) - (void)write(rem, bp->buf, amt); - else { - result = write(rem, bp->buf, amt); - if (result != amt) - haderr = result >= 0 ? EIO : errno; - } - } - if (close(fd) && !haderr) - haderr = errno; - if (!haderr) - (void)write(rem, "", 1); - else - run_err("%s: %s", name, strerror(haderr)); - (void)response(); - } -} - -void -rsource(char *name, struct stat *statp) -{ - DIR *dirp; - struct dirent *dp; - char *last, *vect[1], path[PATH_MAX]; - - if (!(dirp = opendir(name))) { - run_err("%s: %s", name, strerror(errno)); - return; - } - last = strrchr(name, '/'); - if (last == NULL) - last = name; - else - last++; - if (pflag) { - (void)snprintf(path, sizeof(path), "T%ld 0 %ld 0\n", - (long)statp->st_mtim.tv_sec, - (long)statp->st_atim.tv_sec); - (void)write(rem, path, strlen(path)); - if (response() < 0) { - closedir(dirp); - return; - } - } - (void)snprintf(path, sizeof(path), - "D%04o %d %s\n", statp->st_mode & MODEMASK, 0, last); - (void)write(rem, path, strlen(path)); - if (response() < 0) { - closedir(dirp); - return; - } - while ((dp = readdir(dirp))) { - if (dp->d_ino == 0) - continue; - if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) - continue; - if (strlen(name) + 1 + strlen(dp->d_name) >= sizeof(path)) { - run_err("%s/%s: name too long", name, dp->d_name); - continue; - } - (void)snprintf(path, sizeof(path), "%s/%s", name, dp->d_name); - vect[0] = path; - source(1, vect); - } - (void)closedir(dirp); - (void)write(rem, "E\n", 2); - (void)response(); -} - -void -sink(int argc, char *argv[]) -{ - static BUF buffer; - struct stat stb; - struct timeval tv[2]; - enum { YES, NO, DISPLAYED } wrerr; - BUF *bp; - off_t i, j, size; - int amt, exists, first, mask, mode, ofd, omode; - size_t count; - int setimes, targisdir, wrerrno = 0; - char ch, *cp, *np, *targ, *vect[1], buf[BUFSIZ], path[PATH_MAX]; - const char *why; - -#define atime tv[0] -#define mtime tv[1] -#define SCREWUP(str) { why = str; goto screwup; } - - setimes = targisdir = 0; - mask = umask(0); - if (!pflag) - (void)umask(mask); - if (argc != 1) { - run_err("ambiguous target"); - exit(1); - } - targ = *argv; - if (targetshouldbedirectory) - verifydir(targ); - (void)write(rem, "", 1); - if (stat(targ, &stb) == 0 && S_ISDIR(stb.st_mode)) - targisdir = 1; - for (first = 1;; first = 0) { - cp = buf; - if (read(rem, cp, 1) <= 0) - return; - if (*cp++ == '\n') - SCREWUP("unexpected <newline>"); - do { - if (read(rem, &ch, sizeof(ch)) != sizeof(ch)) - SCREWUP("lost connection"); - *cp++ = ch; - } while (cp < &buf[BUFSIZ - 1] && ch != '\n'); - *cp = 0; - - if (buf[0] == '\01' || buf[0] == '\02') { - if (iamremote == 0) - (void)write(STDERR_FILENO, - buf + 1, strlen(buf + 1)); - if (buf[0] == '\02') - exit(1); - ++errs; - continue; - } - if (buf[0] == 'E') { - (void)write(rem, "", 1); - return; - } - - if (ch == '\n') - *--cp = 0; - - cp = buf; - if (*cp == 'T') { - setimes++; - cp++; - mtime.tv_sec = strtol(cp, &cp, 10); - if (!cp || *cp++ != ' ') - SCREWUP("mtime.sec not delimited"); - mtime.tv_usec = strtol(cp, &cp, 10); - if (!cp || *cp++ != ' ') - SCREWUP("mtime.usec not delimited"); - atime.tv_sec = strtol(cp, &cp, 10); - if (!cp || *cp++ != ' ') - SCREWUP("atime.sec not delimited"); - atime.tv_usec = strtol(cp, &cp, 10); - if (!cp || *cp++ != '\0') - SCREWUP("atime.usec not delimited"); - (void)write(rem, "", 1); - continue; - } - if (*cp != 'C' && *cp != 'D') { - /* - * Check for the case "rcp remote:foo\* local:bar". - * In this case, the line "No match." can be returned - * by the shell before the rcp command on the remote is - * executed so the ^Aerror_message convention isn't - * followed. - */ - if (first) { - run_err("%s", cp); - exit(1); - } - SCREWUP("expected control record"); - } - mode = 0; - for (++cp; cp < buf + 5; cp++) { - if (*cp < '0' || *cp > '7') - SCREWUP("bad mode"); - mode = (mode << 3) | (*cp - '0'); - } - if (*cp++ != ' ') - SCREWUP("mode not delimited"); - - for (size = 0; isdigit(*cp);) - size = size * 10 + (*cp++ - '0'); - if (*cp++ != ' ') - SCREWUP("size not delimited"); - if (targisdir) { - if (strlen(targ) + (*targ ? 1 : 0) + strlen(cp) - >= sizeof(path)) { - run_err("%s%s%s: name too long", targ, - *targ ? "/" : "", cp); - exit(1); - } - (void)snprintf(path, sizeof(path), "%s%s%s", targ, - *targ ? "/" : "", cp); - np = path; - } else - np = targ; - exists = stat(np, &stb) == 0; - if (buf[0] == 'D') { - int mod_flag = pflag; - if (exists) { - if (!S_ISDIR(stb.st_mode)) { - errno = ENOTDIR; - goto bad; - } - if (pflag) - (void)chmod(np, mode); - } else { - /* Handle copying from a read-only directory */ - mod_flag = 1; - if (mkdir(np, mode | S_IRWXU) < 0) - goto bad; - } - vect[0] = np; - sink(1, vect); - if (setimes) { - setimes = 0; - if (utimes(np, tv) < 0) - run_err("%s: set times: %s", - np, strerror(errno)); - } - if (mod_flag) - (void)chmod(np, mode); - continue; - } - omode = mode; - mode |= S_IWRITE; - if ((ofd = open(np, O_WRONLY|O_CREAT, mode)) < 0) { -bad: run_err("%s: %s", np, strerror(errno)); - continue; - } - (void)write(rem, "", 1); - if ((bp = allocbuf(&buffer, ofd, BUFSIZ)) == NULL) { - (void)close(ofd); - continue; - } - cp = bp->buf; - wrerr = NO; - for (count = i = 0; i < size; i += BUFSIZ) { - amt = BUFSIZ; - if (i + amt > size) - amt = size - i; - count += amt; - do { - j = read(rem, cp, amt); - if (j <= 0) { - run_err("%s", j ? strerror(errno) : - "dropped connection"); - exit(1); - } - amt -= j; - cp += j; - } while (amt > 0); - if (count == bp->cnt) { - /* Keep reading so we stay sync'd up. */ - if (wrerr == NO) { - j = write(ofd, bp->buf, count); - if (j != (off_t)count) { - wrerr = YES; - wrerrno = j >= 0 ? EIO : errno; - } - } - count = 0; - cp = bp->buf; - } - } - if (count != 0 && wrerr == NO && - (j = write(ofd, bp->buf, count)) != (off_t)count) { - wrerr = YES; - wrerrno = j >= 0 ? EIO : errno; - } - if (ftruncate(ofd, size)) { - run_err("%s: truncate: %s", np, strerror(errno)); - wrerr = DISPLAYED; - } - if (pflag) { - if (exists || omode != mode) - if (fchmod(ofd, omode)) - run_err("%s: set mode: %s", - np, strerror(errno)); - } else { - if (!exists && omode != mode) - if (fchmod(ofd, omode & ~mask)) - run_err("%s: set mode: %s", - np, strerror(errno)); - } - (void)close(ofd); - (void)response(); - if (setimes && wrerr == NO) { - setimes = 0; - if (utimes(np, tv) < 0) { - run_err("%s: set times: %s", - np, strerror(errno)); - wrerr = DISPLAYED; - } - } - switch(wrerr) { - case YES: - run_err("%s: %s", np, strerror(wrerrno)); - break; - case NO: - (void)write(rem, "", 1); - break; - case DISPLAYED: - break; - } - } -screwup: - run_err("protocol error: %s", why); - exit(1); -} - -int -response(void) -{ - char ch, *cp, resp, rbuf[BUFSIZ]; - - if (read(rem, &resp, sizeof(resp)) != sizeof(resp)) - lostconn(0); - - cp = rbuf; - switch(resp) { - case 0: /* ok */ - return (0); - default: - *cp++ = resp; - /* FALLTHROUGH */ - case 1: /* error, followed by error msg */ - case 2: /* fatal error, "" */ - do { - if (read(rem, &ch, sizeof(ch)) != sizeof(ch)) - lostconn(0); - *cp++ = ch; - } while (cp < &rbuf[BUFSIZ] && ch != '\n'); - - if (!iamremote) - (void)write(STDERR_FILENO, rbuf, cp - rbuf); - ++errs; - if (resp == 1) - return (-1); - exit(1); - } - /* NOTREACHED */ -} - -void -usage(void) -{ - (void)fprintf(stderr, "%s\n%s\n", - "usage: rcp [-46p] file1 file2", - " rcp [-46pr] file ... directory"); - exit(1); -} - -#include <stdarg.h> - -void -run_err(const char *fmt, ...) -{ - static FILE *fp; - va_list ap; - - ++errs; - if (fp == NULL && !(fp = fdopen(rem, "w"))) - return; - (void)fprintf(fp, "%c", 0x01); - (void)fprintf(fp, "rcp: "); - va_start(ap, fmt); - (void)vfprintf(fp, fmt, ap); - va_end(ap); - (void)fprintf(fp, "\n"); - (void)fflush(fp); - - if (!iamremote) { - va_start(ap, fmt); - vwarnx(fmt, ap); - va_end(ap); - } -} diff --git bin/rcp/util.c bin/rcp/util.c deleted file mode 100644 index 501123eb356c..000000000000 --- bin/rcp/util.c +++ /dev/null @@ -1,159 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -#if 0 -static const char sccsid[] = "@(#)util.c 8.2 (Berkeley) 4/2/94"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/stat.h> -#include <sys/wait.h> - -#include <ctype.h> -#include <err.h> -#include <errno.h> -#include <paths.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "extern.h" - -char * -colon(char *cp) -{ - if (*cp == ':') /* Leading colon is part of file name. */ - return (0); - - for (; *cp; ++cp) { - if (*cp == ':') - return (cp); - if (*cp == '/') - return (0); - } - return (0); -} - -void -verifydir(char *cp) -{ - struct stat stb; - - if (!stat(cp, &stb)) { - if (S_ISDIR(stb.st_mode)) - return; - errno = ENOTDIR; - } - run_err("%s: %s", cp, strerror(errno)); - exit(1); -} - -int -okname(char *cp0) -{ - int c; - char *cp; - - cp = cp0; - do { - c = *cp; - if (c & 0200) - goto bad; - if (!isalpha(c) && !isdigit(c) && c != '_' && c != '-' && c != '.') - goto bad; - } while (*++cp); - return (1); - -bad: warnx("%s: invalid user name", cp0); - return (0); -} - -int -susystem(char *s, int userid) -{ - sig_t istat, qstat; - int status; - pid_t pid; - - pid = vfork(); - switch (pid) { - case -1: - return (127); - - case 0: - (void)setuid(userid); - execl(_PATH_BSHELL, "sh", "-c", s, (char *)NULL); - _exit(127); - } - istat = signal(SIGINT, SIG_IGN); - qstat = signal(SIGQUIT, SIG_IGN); - if (waitpid(pid, &status, 0) < 0) - status = -1; - (void)signal(SIGINT, istat); - (void)signal(SIGQUIT, qstat); - return (status); -} - -BUF * -allocbuf(BUF *bp, int fd, int blksize) -{ - struct stat stb; - size_t size; - - if (fstat(fd, &stb) < 0) { - run_err("fstat: %s", strerror(errno)); - return (0); - } - size = roundup(stb.st_blksize, blksize); - if (size == 0) - size = blksize; - if (bp->cnt >= size) - return (bp); - if ((bp->buf = realloc(bp->buf, size)) == NULL) { - bp->cnt = 0; - run_err("%s", strerror(errno)); - return (0); - } - bp->cnt = size; - return (bp); -} - -void -lostconn(int signo __unused) -{ - if (!iamremote) - warnx("lost connection"); - exit(1); -} diff --git bin/realpath/Makefile.depend bin/realpath/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- bin/realpath/Makefile.depend +++ bin/realpath/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git bin/rm/Makefile.depend bin/rm/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/rm/Makefile.depend +++ bin/rm/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/rm/rm.c bin/rm/rm.c index bb05aac6cac9..af3322199408 100644 --- bin/rm/rm.c +++ bin/rm/rm.c @@ -515,7 +515,7 @@ check(const char *path, const char *name, struct stat *sp) "%s: -P was specified, but file is not writable", path); (void)fprintf(stderr, "override %s%s%s/%s %s%sfor %s? ", - modep + 1, modep[9] == ' ' ? "" : " ", + modep + 1, modep[10] == ' ' ? "" : " ", user_from_uid(sp->st_uid, 0), group_from_gid(sp->st_gid, 0), *flagsp ? flagsp : "", *flagsp ? " " : "", diff --git bin/rmail/Makefile.depend bin/rmail/Makefile.depend index 0cb1420f7290..e07330e48118 100644 --- bin/rmail/Makefile.depend +++ bin/rmail/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/rmdir/Makefile bin/rmdir/Makefile index a40686dba51a..9a081323f813 100644 --- bin/rmdir/Makefile +++ bin/rmdir/Makefile @@ -1,7 +1,11 @@ # @(#)Makefile 8.1 (Berkeley) 5/31/93 # $FreeBSD$ +.include <src.opts.mk> + PACKAGE=runtime PROG= rmdir +HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests .include <bsd.prog.mk> diff --git bin/rmdir/Makefile.depend bin/rmdir/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/rmdir/Makefile.depend +++ bin/rmdir/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/rmdir/tests/Makefile bin/rmdir/tests/Makefile new file mode 100644 index 000000000000..abf3a1e02a37 --- /dev/null +++ bin/rmdir/tests/Makefile @@ -0,0 +1,5 @@ +# $FreeBSD$ + +ATF_TESTS_SH+= rmdir_test + +.include <bsd.test.mk> diff --git bin/rmdir/tests/Makefile.depend bin/rmdir/tests/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ bin/rmdir/tests/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git bin/rmdir/tests/rmdir_test.sh bin/rmdir/tests/rmdir_test.sh new file mode 100644 index 000000000000..204039c28311 --- /dev/null +++ bin/rmdir/tests/rmdir_test.sh @@ -0,0 +1,58 @@ +# +# Copyright 2017 Shivansh Rai +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +usage_output='usage: rmdir' + +atf_test_case invalid_usage +invalid_usage_head() +{ + atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message" +} + +invalid_usage_body() +{ + atf_check -s not-exit:0 -e match:"$usage_output" rmdir -p + atf_check -s not-exit:0 -e match:"$usage_output" rmdir -v +} + +atf_test_case no_arguments +no_arguments_head() +{ + atf_set "descr" "Verify that rmdir(1) fails and generates a valid usage message when no arguments are supplied" +} + +no_arguments_body() +{ + atf_check -s not-exit:0 -e match:"$usage_output" rmdir +} + +atf_init_test_cases() +{ + atf_add_test_case invalid_usage + atf_add_test_case no_arguments +} diff --git bin/setfacl/Makefile.depend bin/setfacl/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/setfacl/Makefile.depend +++ bin/setfacl/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/sh/Makefile.depend bin/sh/Makefile.depend index 3d9203935abf..0e0490b10835 100644 --- bin/sh/Makefile.depend +++ bin/sh/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/sh/tests/invocation/Makefile.depend bin/sh/tests/invocation/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ bin/sh/tests/invocation/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git bin/sleep/Makefile.depend bin/sleep/Makefile.depend index 4def626103ce..1adfc08a54d6 100644 --- bin/sleep/Makefile.depend +++ bin/sleep/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/stty/Makefile.depend bin/stty/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/stty/Makefile.depend +++ bin/stty/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/sync/Makefile.depend bin/sync/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- bin/sync/Makefile.depend +++ bin/sync/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git bin/test/Makefile.depend bin/test/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- bin/test/Makefile.depend +++ bin/test/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git bin/uuidgen/Makefile.depend bin/uuidgen/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- bin/uuidgen/Makefile.depend +++ bin/uuidgen/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/compat/opensolaris/misc/zmount.c cddl/compat/opensolaris/misc/zmount.c index d46b378ea92a..3c965b05d8b3 100644 --- cddl/compat/opensolaris/misc/zmount.c +++ cddl/compat/opensolaris/misc/zmount.c @@ -74,7 +74,7 @@ zmount(const char *spec, const char *dir, int mflag, char *fstype, char *dataptr, int datalen, char *optptr, int optlen) { struct iovec *iov; - char *optstr, *os, *p; + char *optstr, *os, *p, *tofree; int iovlen, rv; assert(spec != NULL); @@ -87,7 +87,7 @@ zmount(const char *spec, const char *dir, int mflag, char *fstype, assert(optptr != NULL); assert(optlen > 0); - optstr = strdup(optptr); + tofree = optstr = strdup(optptr); assert(optstr != NULL); iov = NULL; @@ -98,11 +98,9 @@ zmount(const char *spec, const char *dir, int mflag, char *fstype, build_iovec(&iov, &iovlen, "fspath", __DECONST(char *, dir), (size_t)-1); build_iovec(&iov, &iovlen, "from", __DECONST(char *, spec), (size_t)-1); - for (p = optstr; p != NULL; strsep(&p, ",/ ")) { - if (*p != '\0') - build_iovec(&iov, &iovlen, p, NULL, (size_t)-1); - } + while ((p = strsep(&optstr, ",/")) != NULL) + build_iovec(&iov, &iovlen, p, NULL, (size_t)-1); rv = nmount(iov, iovlen, 0); - free(optstr); + free(tofree); return (rv); } diff --git cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d index 21452d6e96e7..37f928708904 100644 --- cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d +++ cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.inet_ntop.d @@ -28,9 +28,6 @@ #pragma D option quiet -inline int AF_INET = 2; -inline int AF_INET6 = 28; - in_addr_t *ip4a; in_addr_t *ip4b; in_addr_t *ip4c; diff --git cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.c cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.c index e39108366e39..8dd7bb972ef3 100644 --- cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.c +++ cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.c @@ -35,13 +35,13 @@ main(int argc, char **argv) sigset_t ss; (void) sigemptyset(&ss); - (void) sigaddset(&ss, SIGINT); + (void) sigaddset(&ss, SIGUSR1); (void) sigprocmask(SIG_BLOCK, &ss, NULL); do { (void) getpid(); (void) sigpending(&ss); - } while (!sigismember(&ss, SIGINT)); + } while (!sigismember(&ss, SIGUSR1)); return (0); } diff --git cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.d cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.d index cdc7154750b6..30bf5ae4bf0a 100644 --- cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.d +++ cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise1.d @@ -47,7 +47,7 @@ syscall::getpid:entry /pid == $1/ { trace("raised"); - raise(SIGINT); + raise(SIGUSR1); /* * Wait no more than half a second for the process to die. */ @@ -55,6 +55,7 @@ syscall::getpid:entry } syscall::exit:entry +/pid == $1/ { exit(0); } diff --git cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.c cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.c index 9089283f7893..3901d9862097 100644 --- cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.c +++ cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.c @@ -45,7 +45,7 @@ main(int argc, char **argv) sigemptyset(&sa.sa_mask); sa.sa_flags = 0; - (void) sigaction(SIGINT, &sa, NULL); + (void) sigaction(SIGUSR1, &sa, NULL); for (;;) { (void) getpid(); diff --git cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.d cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.d index 4f68a0b93b3b..7d18442d7408 100644 --- cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.d +++ cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise2.d @@ -47,7 +47,7 @@ syscall::getpid:return /pid == $1/ { trace("raised"); - raise(SIGINT); + raise(SIGUSR1); /* * Wait no more than half a second for the process to die. */ @@ -55,6 +55,7 @@ syscall::getpid:return } syscall::exit:entry +/pid == $1/ { exit(0); } diff --git cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.c cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.c index 9089283f7893..3901d9862097 100644 --- cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.c +++ cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.c @@ -45,7 +45,7 @@ main(int argc, char **argv) sigemptyset(&sa.sa_mask); sa.sa_flags = 0; - (void) sigaction(SIGINT, &sa, NULL); + (void) sigaction(SIGUSR1, &sa, NULL); for (;;) { (void) getpid(); diff --git cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.d cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.d index cdc7154750b6..30bf5ae4bf0a 100644 --- cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.d +++ cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/raise/tst.raise3.d @@ -47,7 +47,7 @@ syscall::getpid:entry /pid == $1/ { trace("raised"); - raise(SIGINT); + raise(SIGUSR1); /* * Wait no more than half a second for the process to die. */ @@ -55,6 +55,7 @@ syscall::getpid:entry } syscall::exit:entry +/pid == $1/ { exit(0); } diff --git cddl/contrib/opensolaris/cmd/zdb/zdb.8 cddl/contrib/opensolaris/cmd/zdb/zdb.8 index 6ae25c398f2d..2d294ea3641a 100644 --- cddl/contrib/opensolaris/cmd/zdb/zdb.8 +++ cddl/contrib/opensolaris/cmd/zdb/zdb.8 @@ -1,6 +1,3 @@ -'\" te -.\" Copyright (c) 2012, Martin Matuska <mm@FreeBSD.org>. -.\" All Rights Reserved. .\" .\" This file and its contents are supplied under the terms of the .\" Common Development and Distribution License ("CDDL"), version 1.0. @@ -13,71 +10,75 @@ .\" .\" .\" Copyright 2012, Richard Lowe. -.\" Copyright (c) 2012, Marcelo Araujo <araujo@FreeBSD.org>. -.\" Copyright (c) 2012, 2014 by Delphix. All rights reserved. -.\" All Rights Reserved. +.\" Copyright (c) 2012, 2017 by Delphix. All rights reserved. +.\" Copyright 2017 Nexenta Systems, Inc. .\" -.\" $FreeBSD$ -.\" -.Dd July 26, 2014 +.Dd October 06, 2017 .Dt ZDB 8 .Os .Sh NAME .Nm zdb -.Nd Display zpool debugging and consistency information +.Nd display zpool debugging and consistency information .Sh SYNOPSIS .Nm -.Op Fl CumdibcsDvhLMXFPA -.Op Fl e Op Fl p Ar path... +.Op Fl AbcdDFGhiLMPsvX +.Op Fl e Oo Fl V Oc Op Fl p Ar path ... +.Op Fl I Ar inflight I/Os +.Oo Fl o Ar var Ns = Ns Ar value Oc Ns ... .Op Fl t Ar txg .Op Fl U Ar cache -.Op Fl I Ar inflight I/Os .Op Fl x Ar dumpdir -.Ar poolname -.Op Ar object ... +.Op Ar poolname Op Ar object ... .Nm -.Op Fl divPA -.Op Fl e Op Fl p Ar path... +.Op Fl AdiPv +.Op Fl e Oo Fl V Oc Op Fl p Ar path ... .Op Fl U Ar cache -.Ar dataset -.Op Ar object ... +.Ar dataset Op Ar object ... .Nm -.Fl m Op Fl MLXFPA +.Fl C +.Op Fl A +.Op Fl U Ar cache +.Nm +.Fl E +.Op Fl A +.Ar word0 Ns \&: Ns Ar word1 Ns :...: Ns Ar word15 +.Nm +.Fl l +.Op Fl Aqu +.Ar device +.Nm +.Fl m +.Op Fl AFLPX +.Op Fl e Oo Fl V Oc Op Fl p Ar path ... .Op Fl t Ar txg -.Op Fl e Op Fl p Ar path... .Op Fl U Ar cache -.Ar poolname +.Ar poolname Op Ar vdev Op Ar metaslab ... +.Nm +.Fl O +.Ar dataset path .Nm -.Fl R Op Fl A -.Op Fl e Op Fl p Ar path... +.Fl R +.Op Fl A +.Op Fl e Oo Fl V Oc Op Fl p Ar path ... .Op Fl U Ar cache -.Ar poolname -.Ar poolname -.Ar vdev Ns : Ns Ar offset Ns : Ns Ar size Ns Op Ns : Ns Ar flags +.Ar poolname vdev Ns \&: Ns Ar offset Ns \&: Ns Ar size Ns Op : Ns Ar flags .Nm .Fl S .Op Fl AP -.Op Fl e Op Fl p Ar path... +.Op Fl e Oo Fl V Oc Op Fl p Ar path ... .Op Fl U Ar cache .Ar poolname -.Ar poolname -.Nm -.Fl l -.Op Fl uA -.Ar device -.Nm -.Fl C -.Op Fl A -.Op Fl U Ar cache .Sh DESCRIPTION The .Nm -utility displays information about a ZFS pool useful for debugging and -performs some amount of consistency checking. -It is a not a general purpose tool and options (and facilities) may change. +utility displays information about a ZFS pool useful for debugging and performs +some amount of consistency checking. +It is a not a general purpose tool and options +.Pq and facilities +may change. This is neither a .Xr fsck 8 -nor a +nor an .Xr fsdb 8 utility. .Pp @@ -89,73 +90,96 @@ internals is assumed. If the .Ar dataset argument does not contain any -.Sy / +.Qq Sy / or -.Sy @ +.Qq Sy @ characters, it is interpreted as a pool name. The root dataset can be specified as -.Pa pool Ns Sy / -(pool name followed by a slash). +.Ar pool Ns / +.Pq pool name followed by a slash . .Pp When operating on an imported and active pool it is possible, though unlikely, that zdb may interpret inconsistent pool data and behave erratically. .Sh OPTIONS Display options: -.Bl -tag -width indent +.Bl -tag -width Ds .It Fl b -Display statistics regarding the number, size (logical, physical and -allocated) and deduplication of blocks. +Display statistics regarding the number, size +.Pq logical, physical and allocated +and deduplication of blocks. .It Fl c Verify the checksum of all metadata blocks while printing block statistics -(see -.Fl b Ns ). +.Po see +.Fl b +.Pc . .Pp If specified multiple times, verify the checksums of all blocks. .It Fl C -Display information about the configuration. If specified with no other -options, instead display information about the cache file -.Po Pa /etc/zfs/zpool.cache Pc . +Display information about the configuration. +If specified with no other options, instead display information about the cache +file +.Pq Pa /boot/zfs/zpool.cache . To specify the cache file to display, see -.Fl U +.Fl U . .Pp -If specified multiple times, and a pool name is also specified display both -the cached configuration and the on-disk configuration. +If specified multiple times, and a pool name is also specified display both the +cached configuration and the on-disk configuration. If specified multiple times with .Fl e -also display the configuration that would be used were the pool to be -imported. +also display the configuration that would be used were the pool to be imported. .It Fl d -Display information about datasets. Specified once, displays basic dataset -information: ID, create transaction, size, and object count. +Display information about datasets. +Specified once, displays basic dataset information: ID, create transaction, +size, and object count. .Pp If specified multiple times provides greater and greater verbosity. .Pp -If object IDs are specified, display information about those specific objects only. +If object IDs are specified, display information about those specific objects +only. .It Fl D -Display deduplication statistics, including the deduplication ratio (dedup), -compression ratio (compress), inflation due to the zfs copies property -(copies), and an overall effective ratio (dedup * compress / copies). -.Pp -If specified twice, display a histogram of deduplication statistics, showing -the allocated (physically present on disk) and referenced (logically -referenced in the pool) block counts and sizes by reference count. -.Pp -If specified a third time, display the statistics independently for each deduplication table. -.Pp -If specified a fourth time, dump the contents of the deduplication tables describing duplicate blocks. -.Pp -If specified a fifth time, also dump the contents of the deduplication tables describing unique blocks. +Display deduplication statistics, including the deduplication ratio +.Pq Sy dedup , +compression ratio +.Pq Sy compress , +inflation due to the zfs copies property +.Pq Sy copies , +and an overall effective ratio +.Pq Sy dedup No * Sy compress No / Sy copies . +.It Fl DD +Display a histogram of deduplication statistics, showing the allocated +.Pq physically present on disk +and referenced +.Pq logically referenced in the pool +block counts and sizes by reference count. +.It Fl DDD +Display the statistics independently for each deduplication table. +.It Fl DDDD +Dump the contents of the deduplication tables describing duplicate blocks. +.It Fl DDDDD +Also dump the contents of the deduplication tables describing unique blocks. +.It Fl E Ar word0 Ns \&: Ns Ar word1 Ns :...: Ns Ar word15 +Decode and display block from an embedded block pointer specified by the +.Ar word +arguments. .It Fl h Display pool history similar to -.Cm zpool history , +.Nm zpool Cm history , but include internal changes, transaction, and dataset information. .It Fl i -Display information about intent log (ZIL) entries relating to each -dataset. -If specified multiple times, display counts of each intent log transaction -type. +Display information about intent log +.Pq ZIL +entries relating to each dataset. +If specified multiple times, display counts of each intent log transaction type. .It Fl l Ar device -Display the vdev labels from the specified device. +Read the vdev labels from the specified device. +.Nm Fl l +will return 0 if valid label was found, 1 if error occurred, and 2 if no valid +labels were found. +.Pp +If the +.Fl q +option is also specified, don't print the labels. +.Pp If the .Fl u option is also specified, also display the uberblocks on this device. @@ -166,36 +190,55 @@ By default, verifies that all non-free blocks are referenced, which can be very expensive. .It Fl m Display the offset, spacemap, and free space of each metaslab. -When specified twice, also display information about the on-disk free -space histogram associated with each metaslab. When specified three time, -display the maximum contiguous free space, the in-core free space histogram, -and the percentage of free space in each space map. When specified -four times display every spacemap record. +.It Fl mm +Also display information about the on-disk free space histogram associated with +each metaslab. +.It Fl mmm +Display the maximum contiguous free space, the in-core free space histogram, and +the percentage of free space in each space map. +.It Fl mmmm +Display every spacemap record. .It Fl M Display the offset, spacemap, and free space of each metaslab. -When specified twice, also display information about the maximum contiguous -free space and the percentage of free space in each space map. -When specified three times display every spacemap record. +.It Fl MM +Also display information about the maximum contiguous free space and the +percentage of free space in each space map. +.It Fl MMM +Display every spacemap record. +.It Fl O Ar dataset path +Look up the specified +.Ar path +inside of the +.Ar dataset +and display its metadata and indirect blocks. +Specified +.Ar path +must be relative to the root of +.Ar dataset . +This option can be combined with +.Fl v +for increasing verbosity. .It Xo -.Fl R Ar poolname -.Ar vdev Ns : Ns Ar offset Ns : Ns Ar size Ns Op Ns : Ns Ar flags +.Fl R Ar poolname vdev Ns \&: Ns Ar offset Ns \&: Ns Ar size Ns Op : Ns Ar flags .Xc -Read and display a block from the specified device. By default the block is -displayed as a hex dump, but see the description of the -.Fl r +Read and display a block from the specified device. +By default the block is displayed as a hex dump, but see the description of the +.Sy r flag, below. .Pp The block is specified in terms of a colon-separated tuple .Ar vdev -(an integer vdev identifier) +.Pq an integer vdev identifier .Ar offset -(the offset within the vdev) +.Pq the offset within the vdev .Ar size -(the size of the block to read) and, optionally, +.Pq the size of the block to read +and, optionally, .Ar flags -(a set of flags, described below). -.Bl -tag -width indent -.It Sy b offset +.Pq a set of flags, described below . +.Pp +.Bl -tag -compact -width "b offset" +.It Sy b Ar offset Print block pointer .It Sy d Decompress the block @@ -210,19 +253,20 @@ Dump raw uninterpreted block data .El .It Fl s Report statistics on -.Nm Ns 's +.Nm zdb I/O. Display operation counts, bandwidth, and error counts of I/O to the pool from .Nm . .It Fl S Simulate the effects of deduplication, constructing a DDT and then display -that DDT as with \fB-DD\fR. +that DDT as with +.Fl DD . .It Fl u Display the current uberblock. .El .Pp Other options: -.Bl -tag -width indent +.Bl -tag -width Ds .It Fl A Do not abort should any assertion fail. .It Fl AA @@ -230,28 +274,41 @@ Enable panic recovery, certain errors which would otherwise be fatal are demoted to warnings. .It Fl AAA Do not abort if asserts fail and also enable panic recovery. -.It Fl e Op Fl p Ar path... +.It Fl e Op Fl p Ar path ... Operate on an exported pool, not present in -.Pa /etc/zfs/zpool.cache . +.Pa /boot/zfs/zpool.cache . The .Fl p flag specifies the path under which devices are to be searched. .It Fl x Ar dumpdir All blocks accessed will be copied to files in the specified directory. The blocks will be placed in sparse files whose name is the same as -that of the file or device read. zdb can be then run on the generated files. +that of the file or device read. +.Nm +can be then run on the generated files. Note that the .Fl bbc -flags are sufficient to access (and thus copy) +flags are sufficient to access +.Pq and thus copy all metadata on the pool. .It Fl F Attempt to make an unreadable pool readable by trying progressively older transactions. +.It Fl G +Dump the contents of the zfs_dbgmsg buffer before exiting +.Nm . +zfs_dbgmsg is a buffer used by ZFS to dump advanced debug information. .It Fl I Ar inflight I/Os Limit the number of outstanding checksum I/Os to the specified value. -The default value is 200. This option affects the performance of the +The default value is 200. +This option affects the performance of the .Fl c option. +.It Fl o Ar var Ns = Ns Ar value ... +Set the given global libzpool variable to the provided value. +The value must be an unsigned 32-bit integer. +Currently only little-endian systems are supported to avoid accidentally setting +the high 32 bits of 64-bit variables. .It Fl P Print numbers in an unscaled form more amenable to parsing, eg. 1000000 rather than 1M. @@ -269,9 +326,14 @@ Use a cache file other than .It Fl v Enable verbosity. Specify multiple times for increased verbosity. +.It Fl V +Attempt verbatim import. +This mimics the behavior of the kernel when loading a pool from a cachefile. +Only usable with +.Fl e . .It Fl X Attempt -.Ql extreme +.Qq extreme transaction rewind, that is attempt the same recovery as .Fl F but read transactions otherwise deemed too old. @@ -283,46 +345,58 @@ option, with more occurrences enabling more verbosity. If no options are specified, all information about the named pool will be displayed at default verbosity. .Sh EXAMPLES -.Bl -tag -width 0n -.It Sy Example 1 Display the configuration of imported pool 'rpool' -.Bd -literal -offset 2n -.Li # Ic zdb -C rpool +.Bl -tag -width Ds +.It Xo +.Sy Example 1 +Display the configuration of imported pool +.Pa rpool +.Xc +.Bd -literal +# zdb -C rpool MOS Configuration: version: 28 name: 'rpool' ... .Ed -.It Sy Example 2 Display basic dataset information about 'rpool' -.Bd -literal -offset 2n -.Li # Ic zdb -d rpool +.It Xo +.Sy Example 2 +Display basic dataset information about +.Pa rpool +.Xc +.Bd -literal +# zdb -d rpool Dataset mos [META], ID 0, cr_txg 4, 26.9M, 1051 objects Dataset rpool/swap [ZVOL], ID 59, cr_txg 356, 486M, 2 objects ... .Ed -.It Xo Sy Example 3 Display basic information about object 0 in -.Sy 'rpool/export/home' +.It Xo +.Sy Example 3 +Display basic information about object 0 in +.Pa rpool/export/home .Xc -.Bd -literal -offset 2n -.Li # Ic zdb -d rpool/export/home 0 +.Bd -literal +# zdb -d rpool/export/home 0 Dataset rpool/export/home [ZPL], ID 137, cr_txg 1546, 32K, 8 objects Object lvl iblk dblk dsize lsize %full type 0 7 16K 16K 15.0K 16K 25.00 DMU dnode .Ed -.It Xo Sy Example 4 Display the predicted effect of enabling deduplication on -.Sy 'rpool' +.It Xo +.Sy Example 4 +Display the predicted effect of enabling deduplication on +.Pa rpool .Xc -.Bd -literal -offset 2n -.Li # Ic zdb -S rpool +.Bd -literal +# zdb -S rpool Simulated DDT histogram: -bucket allocated referenced -______ ______________________________ ______________________________ -refcnt blocks LSIZE PSIZE DSIZE blocks LSIZE PSIZE DSIZE ------- ------ ----- ----- ----- ------ ----- ----- ----- - 1 694K 27.1G 15.0G 15.0G 694K 27.1G 15.0G 15.0G - 2 35.0K 1.33G 699M 699M 74.7K 2.79G 1.45G 1.45G +bucket allocated referenced +______ ______________________________ ______________________________ +refcnt blocks LSIZE PSIZE DSIZE blocks LSIZE PSIZE DSIZE +------ ------ ----- ----- ----- ------ ----- ----- ----- + 1 694K 27.1G 15.0G 15.0G 694K 27.1G 15.0G 15.0G + 2 35.0K 1.33G 699M 699M 74.7K 2.79G 1.45G 1.45G ... dedup = 1.11, compress = 1.80, copies = 1.00, dedup * compress / copies = 2.00 .Ed @@ -330,22 +404,3 @@ dedup = 1.11, compress = 1.80, copies = 1.00, dedup * compress / copies = 2.00 .Sh SEE ALSO .Xr zfs 8 , .Xr zpool 8 -.Sh AUTHORS -This manual page is a -.Xr mdoc 7 -reimplementation of the -.Tn illumos -manual page -.Em zdb(1M) , -modified and customized for -.Fx -and licensed under the -Common Development and Distribution License -.Pq Tn CDDL . -.Pp -The -.Xr mdoc 7 -implementation of this manual page was initially written by -.An Martin Matuska Aq mm@FreeBSD.org -and -.An Marcelo Araujo Aq araujo@FreeBSD.org . diff --git cddl/contrib/opensolaris/cmd/zdb/zdb.c cddl/contrib/opensolaris/cmd/zdb/zdb.c index 711377a9fa25..6ca504783a19 100644 --- cddl/contrib/opensolaris/cmd/zdb/zdb.c +++ cddl/contrib/opensolaris/cmd/zdb/zdb.c @@ -23,6 +23,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2017 Nexenta Systems, Inc. */ #include <stdio.h> @@ -60,7 +61,9 @@ #include <sys/ddt.h> #include <sys/zfeature.h> #include <sys/abd.h> +#include <sys/blkptr.h> #include <zfs_comutil.h> +#include <libcmdutils.h> #undef verify #include <libzfs.h> @@ -120,18 +123,24 @@ static void usage(void) { (void) fprintf(stderr, - "Usage: %s [-CumMdibcsDvhLXFPAG] [-t txg] [-e [-p path...]] " - "[-U config] [-I inflight I/Os] [-x dumpdir] poolname [object...]\n" - " %s [-divPA] [-e -p path...] [-U config] dataset " - "[object...]\n" - " %s -mM [-LXFPA] [-t txg] [-e [-p path...]] [-U config] " - "poolname [vdev [metaslab...]]\n" - " %s -R [-A] [-e [-p path...]] poolname " - "vdev:offset:size[:flags]\n" - " %s -S [-PA] [-e [-p path...]] [-U config] poolname\n" - " %s -l [-uA] device\n" - " %s -C [-A] [-U config]\n\n", - cmdname, cmdname, cmdname, cmdname, cmdname, cmdname, cmdname); + "Usage:\t%s [-AbcdDFGhiLMPsvX] [-e [-V] [-p <path> ...]] " + "[-I <inflight I/Os>]\n" + "\t\t[-o <var>=<value>]... [-t <txg>] [-U <cache>] [-x <dumpdir>]\n" + "\t\t[<poolname> [<object> ...]]\n" + "\t%s [-AdiPv] [-e [-V] [-p <path> ...]] [-U <cache>] <dataset> " + "[<object> ...]\n" + "\t%s -C [-A] [-U <cache>]\n" + "\t%s -l [-Aqu] <device>\n" + "\t%s -m [-AFLPX] [-e [-V] [-p <path> ...]] [-t <txg>] " + "[-U <cache>]\n\t\t<poolname> [<vdev> [<metaslab> ...]]\n" + "\t%s -O <dataset> <path>\n" + "\t%s -R [-A] [-e [-V] [-p <path> ...]] [-U <cache>]\n" + "\t\t<poolname> <vdev>:<offset>:<size>[:<flags>]\n" + "\t%s -E [-A] word0:word1:...:word15\n" + "\t%s -S [-AP] [-e [-V] [-p <path> ...]] [-U <cache>] " + "<poolname>\n\n", + cmdname, cmdname, cmdname, cmdname, cmdname, cmdname, cmdname, + cmdname, cmdname); (void) fprintf(stderr, " Dataset name must include at least one " "separator character '/' or '@'\n"); @@ -140,49 +149,57 @@ usage(void) (void) fprintf(stderr, " If object numbers are specified, only " "those objects are dumped\n\n"); (void) fprintf(stderr, " Options to control amount of output:\n"); - (void) fprintf(stderr, " -u uberblock\n"); - (void) fprintf(stderr, " -d dataset(s)\n"); - (void) fprintf(stderr, " -i intent logs\n"); - (void) fprintf(stderr, " -C config (or cachefile if alone)\n"); - (void) fprintf(stderr, " -h pool history\n"); (void) fprintf(stderr, " -b block statistics\n"); - (void) fprintf(stderr, " -m metaslabs\n"); - (void) fprintf(stderr, " -M metaslab groups\n"); (void) fprintf(stderr, " -c checksum all metadata (twice for " "all data) blocks\n"); - (void) fprintf(stderr, " -s report stats on zdb's I/O\n"); + (void) fprintf(stderr, " -C config (or cachefile if alone)\n"); + (void) fprintf(stderr, " -d dataset(s)\n"); (void) fprintf(stderr, " -D dedup statistics\n"); - (void) fprintf(stderr, " -S simulate dedup to measure effect\n"); - (void) fprintf(stderr, " -v verbose (applies to all others)\n"); - (void) fprintf(stderr, " -l dump label contents\n"); + (void) fprintf(stderr, " -E decode and display block from an " + "embedded block pointer\n"); + (void) fprintf(stderr, " -h pool history\n"); + (void) fprintf(stderr, " -i intent logs\n"); + (void) fprintf(stderr, " -l read label contents\n"); (void) fprintf(stderr, " -L disable leak tracking (do not " "load spacemaps)\n"); + (void) fprintf(stderr, " -m metaslabs\n"); + (void) fprintf(stderr, " -M metaslab groups\n"); + (void) fprintf(stderr, " -O perform object lookups by path\n"); (void) fprintf(stderr, " -R read and display block from a " - "device\n\n"); + "device\n"); + (void) fprintf(stderr, " -s report stats on zdb's I/O\n"); + (void) fprintf(stderr, " -S simulate dedup to measure effect\n"); + (void) fprintf(stderr, " -v verbose (applies to all " + "others)\n\n"); (void) fprintf(stderr, " Below options are intended for use " "with other options:\n"); (void) fprintf(stderr, " -A ignore assertions (-A), enable " "panic recovery (-AA) or both (-AAA)\n"); - (void) fprintf(stderr, " -F attempt automatic rewind within " - "safe range of transaction groups\n"); - (void) fprintf(stderr, " -U <cachefile_path> -- use alternate " - "cachefile\n"); - (void) fprintf(stderr, " -X attempt extreme rewind (does not " - "work with dataset)\n"); (void) fprintf(stderr, " -e pool is exported/destroyed/" "has altroot/not in a cachefile\n"); + (void) fprintf(stderr, " -F attempt automatic rewind within " + "safe range of transaction groups\n"); + (void) fprintf(stderr, " -G dump zfs_dbgmsg buffer before " + "exiting\n"); + (void) fprintf(stderr, " -I <number of inflight I/Os> -- " + "specify the maximum number of " + "checksumming I/Os [default is 200]\n"); + (void) fprintf(stderr, " -o <variable>=<value> set global " + "variable to an unsigned 32-bit integer value\n"); (void) fprintf(stderr, " -p <path> -- use one or more with " "-e to specify path to vdev dir\n"); - (void) fprintf(stderr, " -x <dumpdir> -- " - "dump all read blocks into specified directory\n"); (void) fprintf(stderr, " -P print numbers in parseable form\n"); + (void) fprintf(stderr, " -q don't print label contents\n"); (void) fprintf(stderr, " -t <txg> -- highest txg to use when " "searching for uberblocks\n"); - (void) fprintf(stderr, " -I <number of inflight I/Os> -- " - "specify the maximum number of " - "checksumming I/Os [default is 200]\n"); - (void) fprintf(stderr, " -G dump zfs_dbgmsg buffer before " - "exiting\n"); + (void) fprintf(stderr, " -u uberblock\n"); + (void) fprintf(stderr, " -U <cachefile_path> -- use alternate " + "cachefile\n"); + (void) fprintf(stderr, " -V do verbatim import\n"); + (void) fprintf(stderr, " -x <dumpdir> -- " + "dump all read blocks into specified directory\n"); + (void) fprintf(stderr, " -X attempt extreme rewind (does not " + "work with dataset)\n\n"); (void) fprintf(stderr, "Specify an option more than once (e.g. -bb) " "to make only that option verbose\n"); (void) fprintf(stderr, "Default is to dump everything non-verbosely\n"); @@ -260,12 +277,12 @@ dump_history_offsets(objset_t *os, uint64_t object, void *data, size_t size) } static void -zdb_nicenum(uint64_t num, char *buf) +zdb_nicenum(uint64_t num, char *buf, size_t buflen) { if (dump_opt['P']) - (void) sprintf(buf, "%llu", (longlong_t)num); + (void) snprintf(buf, buflen, "%llu", (longlong_t)num); else - nicenum(num, buf); + nicenum(num, buf, sizeof (buf)); } const char histo_stars[] = "****************************************"; @@ -442,12 +459,17 @@ dump_bpobj(objset_t *os, uint64_t object, void *data, size_t size) bpobj_phys_t *bpop = data; char bytes[32], comp[32], uncomp[32]; + /* make sure the output won't get truncated */ + CTASSERT(sizeof (bytes) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (comp) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (uncomp) >= NN_NUMBUF_SZ); + if (bpop == NULL) return; - zdb_nicenum(bpop->bpo_bytes, bytes); - zdb_nicenum(bpop->bpo_comp, comp); - zdb_nicenum(bpop->bpo_uncomp, uncomp); + zdb_nicenum(bpop->bpo_bytes, bytes, sizeof (bytes)); + zdb_nicenum(bpop->bpo_comp, comp, sizeof (comp)); + zdb_nicenum(bpop->bpo_uncomp, uncomp, sizeof (uncomp)); (void) printf("\t\tnum_blkptrs = %llu\n", (u_longlong_t)bpop->bpo_num_blkptrs); @@ -740,7 +762,10 @@ dump_metaslab_stats(metaslab_t *msp) avl_tree_t *t = &msp->ms_size_tree; int free_pct = range_tree_space(rt) * 100 / msp->ms_size; - zdb_nicenum(metaslab_block_maxsize(msp), maxbuf); + /* max sure nicenum has enough space */ + CTASSERT(sizeof (maxbuf) >= NN_NUMBUF_SZ); + + zdb_nicenum(metaslab_block_maxsize(msp), maxbuf, sizeof (maxbuf)); (void) printf("\t %25s %10lu %7s %6s %4s %4d%%\n", "segments", avl_numnodes(t), "maxsize", maxbuf, @@ -757,7 +782,8 @@ dump_metaslab(metaslab_t *msp) space_map_t *sm = msp->ms_sm; char freebuf[32]; - zdb_nicenum(msp->ms_size - space_map_allocated(sm), freebuf); + zdb_nicenum(msp->ms_size - space_map_allocated(sm), freebuf, + sizeof (freebuf)); (void) printf( "\tmetaslab %6llu offset %12llx spacemap %6llu free %5s\n", @@ -1340,6 +1366,9 @@ dump_dsl_dir(objset_t *os, uint64_t object, void *data, size_t size) time_t crtime; char nice[32]; + /* make sure nicenum has enough space */ + CTASSERT(sizeof (nice) >= NN_NUMBUF_SZ); + if (dd == NULL) return; @@ -1355,15 +1384,15 @@ dump_dsl_dir(objset_t *os, uint64_t object, void *data, size_t size) (u_longlong_t)dd->dd_origin_obj); (void) printf("\t\tchild_dir_zapobj = %llu\n", (u_longlong_t)dd->dd_child_dir_zapobj); - zdb_nicenum(dd->dd_used_bytes, nice); + zdb_nicenum(dd->dd_used_bytes, nice, sizeof (nice)); (void) printf("\t\tused_bytes = %s\n", nice); - zdb_nicenum(dd->dd_compressed_bytes, nice); + zdb_nicenum(dd->dd_compressed_bytes, nice, sizeof (nice)); (void) printf("\t\tcompressed_bytes = %s\n", nice); - zdb_nicenum(dd->dd_uncompressed_bytes, nice); + zdb_nicenum(dd->dd_uncompressed_bytes, nice, sizeof (nice)); (void) printf("\t\tuncompressed_bytes = %s\n", nice); - zdb_nicenum(dd->dd_quota, nice); + zdb_nicenum(dd->dd_quota, nice, sizeof (nice)); (void) printf("\t\tquota = %s\n", nice); - zdb_nicenum(dd->dd_reserved, nice); + zdb_nicenum(dd->dd_reserved, nice, sizeof (nice)); (void) printf("\t\treserved = %s\n", nice); (void) printf("\t\tprops_zapobj = %llu\n", (u_longlong_t)dd->dd_props_zapobj); @@ -1373,7 +1402,8 @@ dump_dsl_dir(objset_t *os, uint64_t object, void *data, size_t size) (u_longlong_t)dd->dd_flags); #define DO(which) \ - zdb_nicenum(dd->dd_used_breakdown[DD_USED_ ## which], nice); \ + zdb_nicenum(dd->dd_used_breakdown[DD_USED_ ## which], nice, \ + sizeof (nice)); \ (void) printf("\t\tused_breakdown[" #which "] = %s\n", nice) DO(HEAD); DO(SNAP); @@ -1392,15 +1422,22 @@ dump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size) char used[32], compressed[32], uncompressed[32], unique[32]; char blkbuf[BP_SPRINTF_LEN]; + /* make sure nicenum has enough space */ + CTASSERT(sizeof (used) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (compressed) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (uncompressed) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (unique) >= NN_NUMBUF_SZ); + if (ds == NULL) return; ASSERT(size == sizeof (*ds)); crtime = ds->ds_creation_time; - zdb_nicenum(ds->ds_referenced_bytes, used); - zdb_nicenum(ds->ds_compressed_bytes, compressed); - zdb_nicenum(ds->ds_uncompressed_bytes, uncompressed); - zdb_nicenum(ds->ds_unique_bytes, unique); + zdb_nicenum(ds->ds_referenced_bytes, used, sizeof (used)); + zdb_nicenum(ds->ds_compressed_bytes, compressed, sizeof (compressed)); + zdb_nicenum(ds->ds_uncompressed_bytes, uncompressed, + sizeof (uncompressed)); + zdb_nicenum(ds->ds_unique_bytes, unique, sizeof (unique)); snprintf_blkptr(blkbuf, sizeof (blkbuf), &ds->ds_bp); (void) printf("\t\tdir_obj = %llu\n", @@ -1459,12 +1496,15 @@ dump_bptree(objset_t *os, uint64_t obj, char *name) bptree_phys_t *bt; dmu_buf_t *db; + /* make sure nicenum has enough space */ + CTASSERT(sizeof (bytes) >= NN_NUMBUF_SZ); + if (dump_opt['d'] < 3) return; VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db)); bt = db->db_data; - zdb_nicenum(bt->bt_bytes, bytes); + zdb_nicenum(bt->bt_bytes, bytes, sizeof (bytes)); (void) printf("\n %s: %llu datasets, %s\n", name, (unsigned long long)(bt->bt_end - bt->bt_begin), bytes); dmu_buf_rele(db, FTAG); @@ -1496,13 +1536,18 @@ dump_full_bpobj(bpobj_t *bpo, char *name, int indent) char comp[32]; char uncomp[32]; + /* make sure nicenum has enough space */ + CTASSERT(sizeof (bytes) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (comp) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (uncomp) >= NN_NUMBUF_SZ); + if (dump_opt['d'] < 3) return; - zdb_nicenum(bpo->bpo_phys->bpo_bytes, bytes); + zdb_nicenum(bpo->bpo_phys->bpo_bytes, bytes, sizeof (bytes)); if (bpo->bpo_havesubobj && bpo->bpo_phys->bpo_subobjs != 0) { - zdb_nicenum(bpo->bpo_phys->bpo_comp, comp); - zdb_nicenum(bpo->bpo_phys->bpo_uncomp, uncomp); + zdb_nicenum(bpo->bpo_phys->bpo_comp, comp, sizeof (comp)); + zdb_nicenum(bpo->bpo_phys->bpo_uncomp, uncomp, sizeof (uncomp)); (void) printf(" %*s: object %llu, %llu local blkptrs, " "%llu subobjs in object %llu, %s (%s/%s comp)\n", indent * 8, name, @@ -1556,6 +1601,11 @@ dump_deadlist(dsl_deadlist_t *dl) char comp[32]; char uncomp[32]; + /* make sure nicenum has enough space */ + CTASSERT(sizeof (bytes) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (comp) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (uncomp) >= NN_NUMBUF_SZ); + if (dump_opt['d'] < 3) return; @@ -1564,9 +1614,9 @@ dump_deadlist(dsl_deadlist_t *dl) return; } - zdb_nicenum(dl->dl_phys->dl_used, bytes); - zdb_nicenum(dl->dl_phys->dl_comp, comp); - zdb_nicenum(dl->dl_phys->dl_uncomp, uncomp); + zdb_nicenum(dl->dl_phys->dl_used, bytes, sizeof (bytes)); + zdb_nicenum(dl->dl_phys->dl_comp, comp, sizeof (comp)); + zdb_nicenum(dl->dl_phys->dl_uncomp, uncomp, sizeof (uncomp)); (void) printf("\n Deadlist: %s (%s/%s comp)\n", bytes, comp, uncomp); @@ -1582,8 +1632,9 @@ dump_deadlist(dsl_deadlist_t *dl) dle = AVL_NEXT(&dl->dl_tree, dle)) { if (dump_opt['d'] >= 5) { char buf[128]; - (void) snprintf(buf, sizeof (buf), "mintxg %llu -> " - "obj %llu", (longlong_t)dle->dle_mintxg, + (void) snprintf(buf, sizeof (buf), + "mintxg %llu -> obj %llu", + (longlong_t)dle->dle_mintxg, (longlong_t)dle->dle_bpobj.bpo_object); dump_full_bpobj(&dle->dle_bpobj, buf, 0); } else { @@ -1597,8 +1648,55 @@ dump_deadlist(dsl_deadlist_t *dl) static avl_tree_t idx_tree; static avl_tree_t domain_tree; static boolean_t fuid_table_loaded; -static boolean_t sa_loaded; -sa_attr_type_t *sa_attr_table; +static objset_t *sa_os = NULL; +static sa_attr_type_t *sa_attr_table = NULL; + +static int +open_objset(const char *path, dmu_objset_type_t type, void *tag, objset_t **osp) +{ + int err; + uint64_t sa_attrs = 0; + uint64_t version = 0; + + VERIFY3P(sa_os, ==, NULL); + err = dmu_objset_own(path, type, B_TRUE, tag, osp); + if (err != 0) { + (void) fprintf(stderr, "failed to own dataset '%s': %s\n", path, + strerror(err)); + return (err); + } + + if (dmu_objset_type(*osp) == DMU_OST_ZFS) { + (void) zap_lookup(*osp, MASTER_NODE_OBJ, ZPL_VERSION_STR, + 8, 1, &version); + if (version >= ZPL_VERSION_SA) { + (void) zap_lookup(*osp, MASTER_NODE_OBJ, ZFS_SA_ATTRS, + 8, 1, &sa_attrs); + } + err = sa_setup(*osp, sa_attrs, zfs_attr_table, ZPL_END, + &sa_attr_table); + if (err != 0) { + (void) fprintf(stderr, "sa_setup failed: %s\n", + strerror(err)); + dmu_objset_disown(*osp, tag); + *osp = NULL; + } + } + sa_os = *osp; + + return (0); +} + +static void +close_objset(objset_t *os, void *tag) +{ + VERIFY3P(os, ==, sa_os); + if (os->os_sa != NULL) + sa_tear_down(os); + dmu_objset_disown(os, tag); + sa_attr_table = NULL; + sa_os = NULL; +} static void fuid_table_destroy() @@ -1670,25 +1768,7 @@ dump_znode(objset_t *os, uint64_t object, void *data, size_t size) int idx = 0; int error; - if (!sa_loaded) { - uint64_t sa_attrs = 0; - uint64_t version; - - VERIFY(zap_lookup(os, MASTER_NODE_OBJ, ZPL_VERSION_STR, - 8, 1, &version) == 0); - if (version >= ZPL_VERSION_SA) { - VERIFY(zap_lookup(os, MASTER_NODE_OBJ, ZFS_SA_ATTRS, - 8, 1, &sa_attrs) == 0); - } - if ((error = sa_setup(os, sa_attrs, zfs_attr_table, - ZPL_END, &sa_attr_table)) != 0) { - (void) printf("sa_setup failed errno %d, can't " - "display znode contents\n", error); - return; - } - sa_loaded = B_TRUE; - } - + VERIFY3P(os, ==, sa_os); if (sa_handle_get(os, object, NULL, SA_HDL_PRIVATE, &hdl)) { (void) printf("Failed to get handle for SA znode\n"); return; @@ -1837,6 +1917,13 @@ dump_object(objset_t *os, uint64_t object, int verbosity, int *print_header) char aux[50]; int error; + /* make sure nicenum has enough space */ + CTASSERT(sizeof (iblk) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (dblk) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (lsize) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (asize) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (bonus_size) >= NN_NUMBUF_SZ); + if (*print_header) { (void) printf("\n%10s %3s %5s %5s %5s %5s %6s %s\n", "Object", "lvl", "iblk", "dblk", "dsize", "lsize", @@ -1857,11 +1944,11 @@ dump_object(objset_t *os, uint64_t object, int verbosity, int *print_header) } dmu_object_info_from_dnode(dn, &doi); - zdb_nicenum(doi.doi_metadata_block_size, iblk); - zdb_nicenum(doi.doi_data_block_size, dblk); - zdb_nicenum(doi.doi_max_offset, lsize); - zdb_nicenum(doi.doi_physical_blocks_512 << 9, asize); - zdb_nicenum(doi.doi_bonus_size, bonus_size); + zdb_nicenum(doi.doi_metadata_block_size, iblk, sizeof (iblk)); + zdb_nicenum(doi.doi_data_block_size, dblk, sizeof (dblk)); + zdb_nicenum(doi.doi_max_offset, lsize, sizeof (lsize)); + zdb_nicenum(doi.doi_physical_blocks_512 << 9, asize, sizeof (asize)); + zdb_nicenum(doi.doi_bonus_size, bonus_size, sizeof (bonus_size)); (void) sprintf(fill, "%6.2f", 100.0 * doi.doi_fill_count * doi.doi_data_block_size / (object == 0 ? DNODES_PER_BLOCK : 1) / doi.doi_max_offset); @@ -1924,6 +2011,8 @@ dump_object(objset_t *os, uint64_t object, int verbosity, int *print_header) for (;;) { char segsize[32]; + /* make sure nicenum has enough space */ + CTASSERT(sizeof (segsize) >= NN_NUMBUF_SZ); error = dnode_next_offset(dn, 0, &start, minlvl, blkfill, 0); if (error) @@ -1931,7 +2020,7 @@ dump_object(objset_t *os, uint64_t object, int verbosity, int *print_header) end = start; error = dnode_next_offset(dn, DNODE_FIND_HOLE, &end, minlvl, blkfill, 0); - zdb_nicenum(end - start, segsize); + zdb_nicenum(end - start, segsize, sizeof (segsize)); (void) printf("\t\tsegment [%016llx, %016llx)" " size %5s\n", (u_longlong_t)start, (u_longlong_t)end, segsize); @@ -1962,6 +2051,9 @@ dump_dir(objset_t *os) int print_header = 1; int i, error; + /* make sure nicenum has enough space */ + CTASSERT(sizeof (numbuf) >= NN_NUMBUF_SZ); + dsl_pool_config_enter(dmu_objset_pool(os), FTAG); dmu_objset_fast_stat(os, &dds); dsl_pool_config_exit(dmu_objset_pool(os), FTAG); @@ -1980,7 +2072,7 @@ dump_dir(objset_t *os) ASSERT3U(usedobjs, ==, BP_GET_FILL(os->os_rootbp)); - zdb_nicenum(refdbytes, numbuf); + zdb_nicenum(refdbytes, numbuf, sizeof (numbuf)); if (verbosity >= 4) { (void) snprintf(blkbuf, sizeof (blkbuf), ", rootbp "); @@ -2156,44 +2248,154 @@ dump_label_uberblocks(vdev_label_t *lbl, uint64_t ashift) } } -static void +static char curpath[PATH_MAX]; + +/* + * Iterate through the path components, recursively passing + * current one's obj and remaining path until we find the obj + * for the last one. + */ +static int +dump_path_impl(objset_t *os, uint64_t obj, char *name) +{ + int err; + int header = 1; + uint64_t child_obj; + char *s; + dmu_buf_t *db; + dmu_object_info_t doi; + + if ((s = strchr(name, '/')) != NULL) + *s = '\0'; + err = zap_lookup(os, obj, name, 8, 1, &child_obj); + + (void) strlcat(curpath, name, sizeof (curpath)); + + if (err != 0) { + (void) fprintf(stderr, "failed to lookup %s: %s\n", + curpath, strerror(err)); + return (err); + } + + child_obj = ZFS_DIRENT_OBJ(child_obj); + err = sa_buf_hold(os, child_obj, FTAG, &db); + if (err != 0) { + (void) fprintf(stderr, + "failed to get SA dbuf for obj %llu: %s\n", + (u_longlong_t)child_obj, strerror(err)); + return (EINVAL); + } + dmu_object_info_from_db(db, &doi); + sa_buf_rele(db, FTAG); + + if (doi.doi_bonus_type != DMU_OT_SA && + doi.doi_bonus_type != DMU_OT_ZNODE) { + (void) fprintf(stderr, "invalid bonus type %d for obj %llu\n", + doi.doi_bonus_type, (u_longlong_t)child_obj); + return (EINVAL); + } + + if (dump_opt['v'] > 6) { + (void) printf("obj=%llu %s type=%d bonustype=%d\n", + (u_longlong_t)child_obj, curpath, doi.doi_type, + doi.doi_bonus_type); + } + + (void) strlcat(curpath, "/", sizeof (curpath)); + + switch (doi.doi_type) { + case DMU_OT_DIRECTORY_CONTENTS: + if (s != NULL && *(s + 1) != '\0') + return (dump_path_impl(os, child_obj, s + 1)); + /*FALLTHROUGH*/ + case DMU_OT_PLAIN_FILE_CONTENTS: + dump_object(os, child_obj, dump_opt['v'], &header); + return (0); + default: + (void) fprintf(stderr, "object %llu has non-file/directory " + "type %d\n", (u_longlong_t)obj, doi.doi_type); + break; + } + + return (EINVAL); +} + +/* + * Dump the blocks for the object specified by path inside the dataset. + */ +static int +dump_path(char *ds, char *path) +{ + int err; + objset_t *os; + uint64_t root_obj; + + err = open_objset(ds, DMU_OST_ZFS, FTAG, &os); + if (err != 0) + return (err); + + err = zap_lookup(os, MASTER_NODE_OBJ, ZFS_ROOT_OBJ, 8, 1, &root_obj); + if (err != 0) { + (void) fprintf(stderr, "can't lookup root znode: %s\n", + strerror(err)); + dmu_objset_disown(os, FTAG); + return (EINVAL); + } + + (void) snprintf(curpath, sizeof (curpath), "dataset=%s path=/", ds); + + err = dump_path_impl(os, root_obj, path); + + close_objset(os, FTAG); + return (err); +} + +static int dump_label(const char *dev) { int fd; vdev_label_t label; - char *path, *buf = label.vl_vdev_phys.vp_nvlist; + char path[MAXPATHLEN]; + char *buf = label.vl_vdev_phys.vp_nvlist; size_t buflen = sizeof (label.vl_vdev_phys.vp_nvlist); struct stat64 statbuf; uint64_t psize, ashift; - int len = strlen(dev) + 1; - - if (strncmp(dev, ZFS_DISK_ROOTD, strlen(ZFS_DISK_ROOTD)) == 0) { - len++; - path = malloc(len); - (void) snprintf(path, len, "%s%s", ZFS_RDISK_ROOTD, - dev + strlen(ZFS_DISK_ROOTD)); - } else { - path = strdup(dev); + boolean_t label_found = B_FALSE; + + (void) strlcpy(path, dev, sizeof (path)); + if (dev[0] == '/') { + if (strncmp(dev, ZFS_DISK_ROOTD, + strlen(ZFS_DISK_ROOTD)) == 0) { + (void) snprintf(path, sizeof (path), "%s%s", + ZFS_RDISK_ROOTD, dev + strlen(ZFS_DISK_ROOTD)); + } + } else if (stat64(path, &statbuf) != 0) { + char *s; + + (void) snprintf(path, sizeof (path), "%s%s", ZFS_RDISK_ROOTD, + dev); + if (((s = strrchr(dev, 's')) == NULL && + (s = strchr(dev, 'p')) == NULL) || + !isdigit(*(s + 1))) + (void) strlcat(path, "s0", sizeof (path)); } if ((fd = open64(path, O_RDONLY)) < 0) { - (void) printf("cannot open '%s': %s\n", path, strerror(errno)); - free(path); + (void) fprintf(stderr, "cannot open '%s': %s\n", path, + strerror(errno)); exit(1); } if (fstat64(fd, &statbuf) != 0) { - (void) printf("failed to stat '%s': %s\n", path, + (void) fprintf(stderr, "failed to stat '%s': %s\n", path, strerror(errno)); - free(path); (void) close(fd); exit(1); } if (S_ISBLK(statbuf.st_mode)) { - (void) printf("cannot use '%s': character device required\n", - path); - free(path); + (void) fprintf(stderr, + "cannot use '%s': character device required\n", path); (void) close(fd); exit(1); } @@ -2204,36 +2406,43 @@ dump_label(const char *dev) for (int l = 0; l < VDEV_LABELS; l++) { nvlist_t *config = NULL; - (void) printf("--------------------------------------------\n"); - (void) printf("LABEL %d\n", l); - (void) printf("--------------------------------------------\n"); + if (!dump_opt['q']) { + (void) printf("------------------------------------\n"); + (void) printf("LABEL %d\n", l); + (void) printf("------------------------------------\n"); + } if (pread64(fd, &label, sizeof (label), vdev_label_offset(psize, l, 0)) != sizeof (label)) { - (void) printf("failed to read label %d\n", l); + if (!dump_opt['q']) + (void) printf("failed to read label %d\n", l); continue; } if (nvlist_unpack(buf, buflen, &config, 0) != 0) { - (void) printf("failed to unpack label %d\n", l); + if (!dump_opt['q']) + (void) printf("failed to unpack label %d\n", l); ashift = SPA_MINBLOCKSHIFT; } else { nvlist_t *vdev_tree = NULL; - dump_nvlist(config, 4); + if (!dump_opt['q']) + dump_nvlist(config, 4); if ((nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &vdev_tree) != 0) || (nvlist_lookup_uint64(vdev_tree, ZPOOL_CONFIG_ASHIFT, &ashift) != 0)) ashift = SPA_MINBLOCKSHIFT; nvlist_free(config); + label_found = B_TRUE; } if (dump_opt['u']) dump_label_uberblocks(&label, ashift); } - free(path); (void) close(fd); + + return (label_found ? 0 : 2); } static uint64_t dataset_feature_count[SPA_FEATURES]; @@ -2245,11 +2454,9 @@ dump_one_dir(const char *dsname, void *arg) int error; objset_t *os; - error = dmu_objset_own(dsname, DMU_OST_ANY, B_TRUE, FTAG, &os); - if (error) { - (void) printf("Could not open %s, error %d\n", dsname, error); + error = open_objset(dsname, DMU_OST_ANY, FTAG, &os); + if (error != 0) return (0); - } for (spa_feature_t f = 0; f < SPA_FEATURES; f++) { if (!dmu_objset_ds(os)->ds_feature_inuse[f]) @@ -2260,9 +2467,8 @@ dump_one_dir(const char *dsname, void *arg) } dump_dir(os); - dmu_objset_disown(os, FTAG); + close_objset(os, FTAG); fuid_table_destroy(); - sa_loaded = B_FALSE; return (0); } @@ -2513,6 +2719,9 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, int sec_remaining = (zcb->zcb_totalasize - bytes) / 1024 / kb_per_sec; + /* make sure nicenum has enough space */ + CTASSERT(sizeof (buf) >= NN_NUMBUF_SZ); + zfs_nicenum(bytes, buf, sizeof (buf)); (void) fprintf(stderr, "\r%5s completed (%4dMB/s) " @@ -2862,6 +3071,14 @@ dump_block_stats(spa_t *spa) char avg[32], gang[32]; char *typename; + /* make sure nicenum has enough space */ + CTASSERT(sizeof (csize) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (lsize) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (psize) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (asize) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (avg) >= NN_NUMBUF_SZ); + CTASSERT(sizeof (gang) >= NN_NUMBUF_SZ); + if (t < DMU_OT_NUMTYPES) typename = dmu_ot[t].ot_name; else @@ -2895,12 +3112,17 @@ dump_block_stats(spa_t *spa) zcb.zcb_type[ZB_TOTAL][t].zb_asize) continue; - zdb_nicenum(zb->zb_count, csize); - zdb_nicenum(zb->zb_lsize, lsize); - zdb_nicenum(zb->zb_psize, psize); - zdb_nicenum(zb->zb_asize, asize); - zdb_nicenum(zb->zb_asize / zb->zb_count, avg); - zdb_nicenum(zb->zb_gangs, gang); + zdb_nicenum(zb->zb_count, csize, + sizeof (csize)); + zdb_nicenum(zb->zb_lsize, lsize, + sizeof (lsize)); + zdb_nicenum(zb->zb_psize, psize, + sizeof (psize)); + zdb_nicenum(zb->zb_asize, asize, + sizeof (asize)); + zdb_nicenum(zb->zb_asize / zb->zb_count, avg, + sizeof (avg)); + zdb_nicenum(zb->zb_gangs, gang, sizeof (gang)); (void) printf("%6s\t%5s\t%5s\t%5s\t%5s" "\t%5.2f\t%6.2f\t", @@ -3497,6 +3719,33 @@ out: free(dup); } +static void +zdb_embedded_block(char *thing) +{ + blkptr_t bp = { 0 }; + unsigned long long *words = (void *)&bp; + char buf[SPA_MAXBLOCKSIZE]; + int err; + + err = sscanf(thing, "%llx:%llx:%llx:%llx:%llx:%llx:%llx:%llx:" + "%llx:%llx:%llx:%llx:%llx:%llx:%llx:%llx", + words + 0, words + 1, words + 2, words + 3, + words + 4, words + 5, words + 6, words + 7, + words + 8, words + 9, words + 10, words + 11, + words + 12, words + 13, words + 14, words + 15); + if (err != 16) { + (void) printf("invalid input format\n"); + exit(1); + } + ASSERT3U(BPE_GET_LSIZE(&bp), <=, SPA_MAXBLOCKSIZE); + err = decode_embedded_bp(&bp, buf, BPE_GET_LSIZE(&bp)); + if (err != 0) { + (void) printf("decode failed: %u\n", err); + exit(1); + } + zdb_dump_block_raw(buf, BPE_GET_LSIZE(&bp), 0); +} + static boolean_t pool_match(nvlist_t *cfg, char *tgt) { @@ -3595,6 +3844,7 @@ main(int argc, char **argv) char *target; nvlist_t *policy = NULL; uint64_t max_txg = UINT64_MAX; + int flags = ZFS_IMPORT_MISSING_LOG; int rewind = ZPOOL_NEVER_REWIND; char *spa_config_path_env; boolean_t target_is_spa = B_TRUE; @@ -3614,34 +3864,38 @@ main(int argc, char **argv) spa_config_path = spa_config_path_env; while ((c = getopt(argc, argv, - "bcdhilmMI:suCDRSAFLXx:evp:t:U:PG")) != -1) { + "AbcCdDeEFGhiI:lLmMo:Op:PqRsSt:uU:vVx:X")) != -1) { switch (c) { case 'b': case 'c': + case 'C': case 'd': + case 'D': + case 'E': + case 'G': case 'h': case 'i': case 'l': case 'm': - case 's': - case 'u': - case 'C': - case 'D': case 'M': + case 'O': case 'R': + case 's': case 'S': - case 'G': + case 'u': dump_opt[c]++; dump_all = 0; break; case 'A': + case 'e': case 'F': case 'L': - case 'X': - case 'e': case 'P': + case 'q': + case 'X': dump_opt[c]++; break; + /* NB: Sort single match options below. */ case 'I': max_inflight = strtoull(optarg, NULL, 0); if (max_inflight == 0) { @@ -3651,6 +3905,11 @@ main(int argc, char **argv) usage(); } break; + case 'o': + error = set_global_var(optarg); + if (error != 0) + usage(); + break; case 'p': if (searchdirs == NULL) { searchdirs = umem_alloc(sizeof (char *), @@ -3676,10 +3935,19 @@ main(int argc, char **argv) break; case 'U': spa_config_path = optarg; + if (spa_config_path[0] != '/') { + (void) fprintf(stderr, + "cachefile must be an absolute path " + "(i.e. start with a slash)\n"); + usage(); + } break; case 'v': verbose++; break; + case 'V': + flags = ZFS_IMPORT_VERBATIM; + break; case 'x': vn_dumpdir = optarg; break; @@ -3721,7 +3989,7 @@ main(int argc, char **argv) verbose = MAX(verbose, 1); for (c = 0; c < 256; c++) { - if (dump_all && !strchr("elAFLRSXP", c)) + if (dump_all && strchr("AeEFlLOPRSX", c) == NULL) dump_opt[c] = 1; if (dump_opt[c]) dump_opt[c] += verbose; @@ -3735,6 +4003,14 @@ main(int argc, char **argv) if (argc < 2 && dump_opt['R']) usage(); + + if (dump_opt['E']) { + if (argc != 1) + usage(); + zdb_embedded_block(argv[0]); + return (0); + } + if (argc < 1) { if (!dump_opt['e'] && dump_opt['C']) { dump_cachefile(spa_config_path); @@ -3743,9 +4019,14 @@ main(int argc, char **argv) usage(); } - if (dump_opt['l']) { - dump_label(argv[0]); - return (0); + if (dump_opt['l']) + return (dump_label(argv[0])); + + if (dump_opt['O']) { + if (argc != 2) + usage(); + dump_opt['v'] = verbose + 3; + return (dump_path(argv[0], argv[1])); } if (dump_opt['X'] || dump_opt['F']) @@ -3775,11 +4056,7 @@ main(int argc, char **argv) fatal("can't open '%s': %s", target, strerror(ENOMEM)); } - if ((error = spa_import(name, cfg, NULL, - ZFS_IMPORT_MISSING_LOG)) != 0) { - error = spa_import(name, cfg, NULL, - ZFS_IMPORT_VERBATIM); - } + error = spa_import(name, cfg, NULL, flags); } } @@ -3822,8 +4099,7 @@ main(int argc, char **argv) } } } else { - error = dmu_objset_own(target, DMU_OST_ANY, - B_TRUE, FTAG, &os); + error = open_objset(target, DMU_OST_ANY, FTAG, &os); } } nvlist_free(policy); @@ -3866,10 +4142,12 @@ main(int argc, char **argv) zdb_read_block(argv[i], spa); } - (os != NULL) ? dmu_objset_disown(os, FTAG) : spa_close(spa, FTAG); + if (os != NULL) + close_objset(os, FTAG); + else + spa_close(spa, FTAG); fuid_table_destroy(); - sa_loaded = B_FALSE; dump_debug_buffer(); diff --git cddl/contrib/opensolaris/cmd/zfs/zfs-program.8 cddl/contrib/opensolaris/cmd/zfs/zfs-program.8 new file mode 100644 index 000000000000..0ede564e1fa2 --- /dev/null +++ cddl/contrib/opensolaris/cmd/zfs/zfs-program.8 @@ -0,0 +1,536 @@ +.\" 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) 2016, 2017 by Delphix. All rights reserved. +.\" +.Dd October 02, 2017 +.Dt ZFS-PROGRAM 1M +.Os +.Sh NAME +.Nm zfs program +.Nd executes ZFS channel programs +.Sh SYNOPSIS +.Cm zfs program +.Op Fl t Ar instruction-limit +.Op Fl m Ar memory-limit +.Ar pool +.Ar script +.\".Op Ar optional arguments to channel program +.Sh DESCRIPTION +The ZFS channel program interface allows ZFS administrative operations to be +run programmatically as a Lua script. +The entire script is executed atomically, with no other administrative +operations taking effect concurrently. +A library of ZFS calls is made available to channel program scripts. +Channel programs may only be run with root privileges. +.Pp +A modified version of the Lua 5.2 interpreter is used to run channel program +scripts. +The Lua 5.2 manual can be found at: +.Bd -centered -offset indent +.Lk http://www.lua.org/manual/5.2/ +.Ed +.Pp +The channel program given by +.Ar script +will be run on +.Ar pool , +and any attempts to access or modify other pools will cause an error. +.Sh OPTIONS +.Bl -tag -width "-t" +.It Fl t Ar instruction-limit +Execution time limit, in number of Lua instructions to execute. +If a channel program executes more than the specified number of instructions, +it will be stopped and an error will be returned. +The default limit is 10 million instructions, and it can be set to a maximum of +100 million instructions. +.It Fl m Ar memory-limit +Memory limit, in bytes. +If a channel program attempts to allocate more memory than the given limit, it +will be stopped and an error returned. +The default memory limit is 10 MB, and can be set to a maximum of 100 MB. +.El +.Pp +All remaining argument strings will be passed directly to the Lua script as +described in the +.Sx LUA INTERFACE +section below. +.Sh LUA INTERFACE +A channel program can be invoked either from the command line, or via a library +call to +.Fn lzc_channel_program . +.Ss Arguments +Arguments passed to the channel program are converted to a Lua table. +If invoked from the command line, extra arguments to the Lua script will be +accessible as an array stored in the argument table with the key 'argv': +.Bd -literal -offset indent +args = ... +argv = args["argv"] +-- argv == {1="arg1", 2="arg2", ...} +.Ed +.Pp +If invoked from the libZFS interface, an arbitrary argument list can be +passed to the channel program, which is accessible via the same +"..." syntax in Lua: +.Bd -literal -offset indent +args = ... +-- args == {"foo"="bar", "baz"={...}, ...} +.Ed +.Pp +Note that because Lua arrays are 1-indexed, arrays passed to Lua from the +libZFS interface will have their indices incremented by 1. +That is, the element +in +.Va arr[0] +in a C array passed to a channel program will be stored in +.Va arr[1] +when accessed from Lua. +.Ss Return Values +Lua return statements take the form: +.Bd -literal -offset indent +return ret0, ret1, ret2, ... +.Ed +.Pp +Return statements returning multiple values are permitted internally in a +channel program script, but attempting to return more than one value from the +top level of the channel program is not permitted and will throw an error. +However, tables containing multiple values can still be returned. +If invoked from the command line, a return statement: +.Bd -literal -offset indent +a = {foo="bar", baz=2} +return a +.Ed +.Pp +Will be output formatted as: +.Bd -literal -offset indent +Channel program fully executed with return value: + return: + baz: 2 + foo: 'bar' +.Ed +.Ss Fatal Errors +If the channel program encounters a fatal error while running, a non-zero exit +status will be returned. +If more information about the error is available, a singleton list will be +returned detailing the error: +.Bd -literal -offset indent +error: "error string, including Lua stack trace" +.Ed +.Pp +If a fatal error is returned, the channel program may have not executed at all, +may have partially executed, or may have fully executed but failed to pass a +return value back to userland. +.Pp +If the channel program exhausts an instruction or memory limit, a fatal error +will be generated and the program will be stopped, leaving the program partially +executed. +No attempt is made to reverse or undo any operations already performed. +Note that because both the instruction count and amount of memory used by a +channel program are deterministic when run against the same inputs and +filesystem state, as long as a channel program has run successfully once, you +can guarantee that it will finish successfully against a similar size system. +.Pp +If a channel program attempts to return too large a value, the program will +fully execute but exit with a nonzero status code and no return value. +.Pp +.Em Note: +ZFS API functions do not generate Fatal Errors when correctly invoked, they +return an error code and the channel program continues executing. +See the +.Sx ZFS API +section below for function-specific details on error return codes. +.Ss Lua to C Value Conversion +When invoking a channel program via the libZFS interface, it is necessary to +translate arguments and return values from Lua values to their C equivalents, +and vice-versa. +.Pp +There is a correspondence between nvlist values in C and Lua tables. +A Lua table which is returned from the channel program will be recursively +converted to an nvlist, with table values converted to their natural +equivalents: +.Bd -literal -offset indent +string -> string +number -> int64 +boolean -> boolean_value +nil -> boolean (no value) +table -> nvlist +.Ed +.Pp +Likewise, table keys are replaced by string equivalents as follows: +.Bd -literal -offset indent +string -> no change +number -> signed decimal string ("%lld") +boolean -> "true" | "false" +.Ed +.Pp +Any collision of table key strings (for example, the string "true" and a +true boolean value) will cause a fatal error. +.Pp +Lua numbers are represented internally as signed 64-bit integers. +.Sh LUA STANDARD LIBRARY +The following Lua built-in base library functions are available: +.Bd -literal -offset indent +assert rawlen +collectgarbage rawget +error rawset +getmetatable select +ipairs setmetatable +next tonumber +pairs tostring +rawequal type +.Ed +.Pp +All functions in the +.Em coroutine , +.Em string , +and +.Em table +built-in submodules are also available. +A complete list and documentation of these modules is available in the Lua +manual. +.Pp +The following functions base library functions have been disabled and are +not available for use in channel programs: +.Bd -literal -offset indent +dofile +loadfile +load +pcall +print +xpcall +.Ed +.Sh ZFS API +.Ss Function Arguments +Each API function takes a fixed set of required positional arguments and +optional keyword arguments. +For example, the destroy function takes a single positional string argument +(the name of the dataset to destroy) and an optional "defer" keyword boolean +argument. +When using parentheses to specify the arguments to a Lua function, only +positional arguments can be used: +.Bd -literal -offset indent +zfs.sync.destroy("rpool@snap") +.Ed +.Pp +To use keyword arguments, functions must be called with a single argument that +is a Lua table containing entries mapping integers to positional arguments and +strings to keyword arguments: +.Bd -literal -offset indent +zfs.sync.destroy({1="rpool@snap", defer=true}) +.Ed +.Pp +The Lua language allows curly braces to be used in place of parenthesis as +syntactic sugar for this calling convention: +.Bd -literal -offset indent +zfs.sync.snapshot{"rpool@snap", defer=true} +.Ed +.Ss Function Return Values +If an API function succeeds, it returns 0. +If it fails, it returns an error code and the channel program continues +executing. +API functions do not generate Fatal Errors except in the case of an +unrecoverable internal file system error. +.Pp +In addition to returning an error code, some functions also return extra +details describing what caused the error. +This extra description is given as a second return value, and will always be a +Lua table, or Nil if no error details were returned. +Different keys will exist in the error details table depending on the function +and error case. +Any such function may be called expecting a single return value: +.Bd -literal -offset indent +errno = zfs.sync.promote(dataset) +.Ed +.Pp +Or, the error details can be retrieved: +.Bd -literal -offset indent +errno, details = zfs.sync.promote(dataset) +if (errno == EEXIST) then + assert(details ~= Nil) + list_of_conflicting_snapshots = details +end +.Ed +.Pp +The following global aliases for API function error return codes are defined +for use in channel programs: +.Bd -literal -offset indent +EPERM ECHILD ENODEV ENOSPC +ENOENT EAGAIN ENOTDIR ESPIPE +ESRCH ENOMEM EISDIR EROFS +EINTR EACCES EINVAL EMLINK +EIO EFAULT ENFILE EPIPE +ENXIO ENOTBLK EMFILE EDOM +E2BIG EBUSY ENOTTY ERANGE +ENOEXEC EEXIST ETXTBSY EDQUOT +EBADF EXDEV EFBIG +.Ed +.Ss API Functions +For detailed descriptions of the exact behavior of any zfs administrative +operations, see the main +.Xr zfs 1 +manual page. +.Bl -tag -width "xx" +.It Em zfs.debug(msg) +Record a debug message in the zfs_dbgmsg log. +A log of these messages can be printed via mdb's "::zfs_dbgmsg" command, or +can be monitored live by running: +.Bd -literal -offset indent + dtrace -n 'zfs-dbgmsg{trace(stringof(arg0))}' +.Ed +.Pp +msg (string) +.Bd -ragged -compact -offset "xxxx" +Debug message to be printed. +.Ed +.It Em zfs.exists(dataset) +Returns true if the given dataset exists, or false if it doesn't. +A fatal error will be thrown if the dataset is not in the target pool. +That is, in a channel program running on rpool, +zfs.exists("rpool/nonexistent_fs") returns false, but +zfs.exists("somepool/fs_that_may_exist") will error. +.Pp +dataset (string) +.Bd -ragged -compact -offset "xxxx" +Dataset to check for existence. +Must be in the target pool. +.Ed +.It Em zfs.get_prop(dataset, property) +Returns two values. +First, a string, number or table containing the property value for the given +dataset. +Second, a string containing the source of the property (i.e. the name of the +dataset in which it was set or nil if it is readonly). +Throws a Lua error if the dataset is invalid or the property doesn't exist. +Note that Lua only supports int64 number types whereas ZFS number properties +are uint64. +This means very large values (like guid) may wrap around and appear negative. +.Pp +dataset (string) +.Bd -ragged -compact -offset "xxxx" +Filesystem or snapshot path to retrieve properties from. +.Ed +.Pp +property (string) +.Bd -ragged -compact -offset "xxxx" +Name of property to retrieve. +All filesystem, snapshot and volume properties are supported except +for 'mounted' and 'iscsioptions.' +Also supports the 'written@snap' and 'written#bookmark' properties and +the '<user|group><quota|used>@id' properties, though the id must be in numeric +form. +.Ed +.El +.Bl -tag -width "xx" +.It Sy zfs.sync submodule +The sync submodule contains functions that modify the on-disk state. +They are executed in "syncing context". +.Pp +The available sync submodule functions are as follows: +.Bl -tag -width "xx" +.It Em zfs.sync.destroy(dataset, [defer=true|false]) +Destroy the given dataset. +Returns 0 on successful destroy, or a nonzero error code if the dataset could +not be destroyed (for example, if the dataset has any active children or +clones). +.Pp +dataset (string) +.Bd -ragged -compact -offset "xxxx" +Filesystem or snapshot to be destroyed. +.Ed +.Pp +[optional] defer (boolean) +.Bd -ragged -compact -offset "xxxx" +Valid only for destroying snapshots. +If set to true, and the snapshot has holds or clones, allows the snapshot to be +marked for deferred deletion rather than failing. +.Ed +.It Em zfs.sync.promote(dataset) +Promote the given clone to a filesystem. +Returns 0 on successful promotion, or a nonzero error code otherwise. +If EEXIST is returned, the second return value will be an array of the clone's +snapshots whose names collide with snapshots of the parent filesystem. +.Pp +dataset (string) +.Bd -ragged -compact -offset "xxxx" +Clone to be promoted. +.Ed +.It Em zfs.sync.rollback(filesystem) +Rollback to the previous snapshot for a dataset. +Returns 0 on successful rollback, or a nonzero error code otherwise. +Rollbacks can be performed on filesystems or zvols, but not on snapshots +or mounted datasets. +EBUSY is returned in the case where the filesystem is mounted. +.Pp +filesystem (string) +.Bd -ragged -compact -offset "xxxx" +Filesystem to rollback. +.Ed +.It Em zfs.sync.snapshot(dataset) +Create a snapshot of a filesystem. +Returns 0 if the snapshot was successfully created, +and a nonzero error code otherwise. +.Pp +Note: Taking a snapshot will fail on any pool older than legacy version 27. +To enable taking snapshots from ZCP scripts, the pool must be upgraded. +.Pp +dataset (string) +.Bd -ragged -compact -offset "xxxx" +Name of snapshot to create. +.Ed +.El +.It Sy zfs.check submodule +For each function in the zfs.sync submodule, there is a corresponding zfs.check +function which performs a "dry run" of the same operation. +Each takes the same arguments as its zfs.sync counterpart and returns 0 if the +operation would succeed, or a non-zero error code if it would fail, along with +any other error details. +That is, each has the same behavior as the corresponding sync function except +for actually executing the requested change. +For example, +.Em zfs.check.destroy("fs") +returns 0 if +.Em zfs.sync.destroy("fs") +would successfully destroy the dataset. +.Pp +The available zfs.check functions are: +.Bl -tag -width "xx" +.It Em zfs.check.destroy(dataset, [defer=true|false]) +.It Em zfs.check.promote(dataset) +.It Em zfs.check.rollback(filesystem) +.It Em zfs.check.snapshot(dataset) +.El +.It Sy zfs.list submodule +The zfs.list submodule provides functions for iterating over datasets and +properties. +Rather than returning tables, these functions act as Lua iterators, and are +generally used as follows: +.Bd -literal -offset indent +for child in zfs.list.children("rpool") do + ... +end +.Ed +.Pp +The available zfs.list functions are: +.Bl -tag -width "xx" +.It Em zfs.list.clones(snapshot) +Iterate through all clones of the given snapshot. +.Pp +snapshot (string) +.Bd -ragged -compact -offset "xxxx" +Must be a valid snapshot path in the current pool. +.Ed +.It Em zfs.list.snapshots(dataset) +Iterate through all snapshots of the given dataset. +Each snapshot is returned as a string containing the full dataset name, e.g. +"pool/fs@snap". +.Pp +dataset (string) +.Bd -ragged -compact -offset "xxxx" +Must be a valid filesystem or volume. +.Ed +.It Em zfs.list.children(dataset) +Iterate through all direct children of the given dataset. +Each child is returned as a string containing the full dataset name, e.g. +"pool/fs/child". +.Pp +dataset (string) +.Bd -ragged -compact -offset "xxxx" +Must be a valid filesystem or volume. +.Ed +.It Em zfs.list.properties(dataset) +Iterate through all user properties for the given dataset. +.Pp +dataset (string) +.Bd -ragged -compact -offset "xxxx" +Must be a valid filesystem, snapshot, or volume. +.Ed +.It Em zfs.list.system_properties(dataset) +Returns an array of strings, the names of the valid system (non-user defined) +properties for the given dataset. +Throws a Lua error if the dataset is invalid. +.Pp +dataset (string) +.Bd -ragged -compact -offset "xxxx" +Must be a valid filesystem, snapshot or volume. +.Ed +.El +.El +.Sh EXAMPLES +.Ss Example 1 +The following channel program recursively destroys a filesystem and all its +snapshots and children in a naive manner. +Note that this does not involve any error handling or reporting. +.Bd -literal -offset indent +function destroy_recursive(root) + for child in zfs.list.children(root) do + destroy_recursive(child) + end + for snap in zfs.list.snapshots(root) do + zfs.sync.destroy(snap) + end + zfs.sync.destroy(root) +end +destroy_recursive("pool/somefs") +.Ed +.Ss Example 2 +A more verbose and robust version of the same channel program, which +properly detects and reports errors, and also takes the dataset to destroy +as a command line argument, would be as follows: +.Bd -literal -offset indent +succeeded = {} +failed = {} + +function destroy_recursive(root) + for child in zfs.list.children(root) do + destroy_recursive(child) + end + for snap in zfs.list.snapshots(root) do + err = zfs.sync.destroy(snap) + if (err ~= 0) then + failed[snap] = err + else + succeeded[snap] = err + end + end + err = zfs.sync.destroy(root) + if (err ~= 0) then + failed[root] = err + else + succeeded[root] = err + end +end + +args = ... +argv = args["argv"] + +destroy_recursive(argv[1]) + +results = {} +results["succeeded"] = succeeded +results["failed"] = failed +return results +.Ed +.Ss Example 3 +The following function performs a forced promote operation by attempting to +promote the given clone and destroying any conflicting snapshots. +.Bd -literal -offset indent +function force_promote(ds) + errno, details = zfs.check.promote(ds) + if (errno == EEXIST) then + assert(details ~= Nil) + for i, snap in ipairs(details) do + zfs.sync.destroy(ds .. "@" .. snap) + end + elseif (errno ~= 0) then + return errno + end + return zfs.sync.promote(ds) +end +.Ed diff --git cddl/contrib/opensolaris/cmd/zfs/zfs.8 cddl/contrib/opensolaris/cmd/zfs/zfs.8 index 677b559644ba..d52b30f0c180 100644 --- cddl/contrib/opensolaris/cmd/zfs/zfs.8 +++ cddl/contrib/opensolaris/cmd/zfs/zfs.8 @@ -286,6 +286,12 @@ .Ar snapshot .Op Ar snapshot Ns | Ns Ar filesystem .Nm +.Cm program +.Op Fl t Ar timeout +.Op Fl m Ar memory_limit +.Ar pool script +.Op Ar arg1 No ... +.Nm .Cm jail .Ar jailid Ns | Ns Ar jailname filesystem .Nm @@ -3287,6 +3293,48 @@ Display the path's inode change time as the first column of output. .El .It Xo .Nm +.Cm program +.Op Fl t Ar timeout +.Op Fl m Ar memory_limit +.Ar pool script +.Op Ar arg1 No ... +.Xc +.Pp +Executes +.Ar script +as a ZFS channel program on +.Ar pool . +The ZFS channel +program interface allows ZFS administrative operations to be run +programmatically via a Lua script. +The entire script is executed atomically, with no other administrative +operations taking effect concurrently. +A library of ZFS calls is made available to channel program scripts. +Channel programs may only be run with root privileges. +.Pp +For full documentation of the ZFS channel program interface, see the manual +page for +.Xr zfs-program 8 . +.Bl -tag -width indent +.It Fl t Ar timeout +Execution time limit, in milliseconds. +If a channel program executes for longer than the provided timeout, it will +be stopped and an error will be returned. +The default timeout is 1000 ms, and can be set to a maximum of 10000 ms. +.It Fl m Ar memory-limit +Memory limit, in bytes. +If a channel program attempts to allocate more memory than the given limit, +it will be stopped and an error returned. +The default memory limit is 10 MB, and can be set to a maximum of 100 MB. +.Pp +All remaining argument strings are passed directly to the channel program as +arguments. +See +.Xr zfs-program 8 +for more information. +.El +.It Xo +.Nm .Cm jail .Ar jailid filesystem .Xc diff --git cddl/contrib/opensolaris/cmd/zfs/zfs_main.c cddl/contrib/opensolaris/cmd/zfs/zfs_main.c index 39d3802c910b..4727b9f49223 100644 --- cddl/contrib/opensolaris/cmd/zfs/zfs_main.c +++ cddl/contrib/opensolaris/cmd/zfs/zfs_main.c @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2015 by Delphix. All rights reserved. + * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright 2012 Milan Jurik. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. @@ -51,6 +51,7 @@ #include <grp.h> #include <pwd.h> #include <signal.h> +#include <sys/debug.h> #include <sys/list.h> #include <sys/mntent.h> #include <sys/mnttab.h> @@ -111,6 +112,7 @@ static int zfs_do_diff(int argc, char **argv); static int zfs_do_jail(int argc, char **argv); static int zfs_do_unjail(int argc, char **argv); static int zfs_do_bookmark(int argc, char **argv); +static int zfs_do_channel_program(int argc, char **argv); /* * Enable a reasonable set of defaults for libumem debugging on DEBUG builds. @@ -160,6 +162,7 @@ typedef enum { HELP_RELEASE, HELP_DIFF, HELP_BOOKMARK, + HELP_CHANNEL_PROGRAM, } zfs_help_t; typedef struct zfs_command { @@ -187,6 +190,7 @@ static zfs_command_t command_table[] = { { "promote", zfs_do_promote, HELP_PROMOTE }, { "rename", zfs_do_rename, HELP_RENAME }, { "bookmark", zfs_do_bookmark, HELP_BOOKMARK }, + { "program", zfs_do_channel_program, HELP_CHANNEL_PROGRAM }, { NULL }, { "list", zfs_do_list, HELP_LIST }, { NULL }, @@ -340,6 +344,10 @@ get_usage(zfs_help_t idx) "[snapshot|filesystem]\n")); case HELP_BOOKMARK: return (gettext("\tbookmark <snapshot> <bookmark>\n")); + case HELP_CHANNEL_PROGRAM: + return (gettext("\tprogram [-t <instruction limit>] " + "[-m <memory limit (b)>] <pool> <program file> " + "[lua args...]\n")); } abort(); @@ -368,6 +376,18 @@ safe_malloc(size_t size) return (data); } +void * +safe_realloc(void *data, size_t size) +{ + void *newp; + if ((newp = realloc(data, size)) == NULL) { + free(data); + nomem(); + } + + return (newp); +} + static char * safe_strdup(char *str) { @@ -7101,6 +7121,194 @@ usage: return (-1); } +static int +zfs_do_channel_program(int argc, char **argv) +{ + int ret, fd; + char c; + char *progbuf, *filename, *poolname; + size_t progsize, progread; + nvlist_t *outnvl; + uint64_t instrlimit = ZCP_DEFAULT_INSTRLIMIT; + uint64_t memlimit = ZCP_DEFAULT_MEMLIMIT; + zpool_handle_t *zhp; + + /* check options */ + while (-1 != + (c = getopt(argc, argv, "t:(instr-limit)m:(memory-limit)"))) { + switch (c) { + case 't': + case 'm': { + uint64_t arg; + char *endp; + + errno = 0; + arg = strtoull(optarg, &endp, 0); + if (errno != 0 || *endp != '\0') { + (void) fprintf(stderr, gettext( + "invalid argument " + "'%s': expected integer\n"), optarg); + goto usage; + } + + if (c == 't') { + if (arg > ZCP_MAX_INSTRLIMIT || arg == 0) { + (void) fprintf(stderr, gettext( + "Invalid instruction limit: " + "%s\n"), optarg); + return (1); + } else { + instrlimit = arg; + } + } else { + ASSERT3U(c, ==, 'm'); + if (arg > ZCP_MAX_MEMLIMIT || arg == 0) { + (void) fprintf(stderr, gettext( + "Invalid memory limit: " + "%s\n"), optarg); + return (1); + } else { + memlimit = arg; + } + } + break; + } + case '?': + (void) fprintf(stderr, gettext("invalid option '%c'\n"), + optopt); + goto usage; + } + } + + argc -= optind; + argv += optind; + + if (argc < 2) { + (void) fprintf(stderr, + gettext("invalid number of arguments\n")); + goto usage; + } + + poolname = argv[0]; + filename = argv[1]; + if (strcmp(filename, "-") == 0) { + fd = 0; + filename = "standard input"; + } else if ((fd = open(filename, O_RDONLY)) < 0) { + (void) fprintf(stderr, gettext("cannot open '%s': %s\n"), + filename, strerror(errno)); + return (1); + } + + if ((zhp = zpool_open(g_zfs, poolname)) == NULL) { + (void) fprintf(stderr, gettext("cannot open pool '%s'"), + poolname); + return (1); + } + zpool_close(zhp); + + /* + * Read in the channel program, expanding the program buffer as + * necessary. + */ + progread = 0; + progsize = 1024; + progbuf = safe_malloc(progsize); + do { + ret = read(fd, progbuf + progread, progsize - progread); + progread += ret; + if (progread == progsize && ret > 0) { + progsize *= 2; + progbuf = safe_realloc(progbuf, progsize); + } + } while (ret > 0); + + if (fd != 0) + (void) close(fd); + if (ret < 0) { + free(progbuf); + (void) fprintf(stderr, + gettext("cannot read '%s': %s\n"), + filename, strerror(errno)); + return (1); + } + progbuf[progread] = '\0'; + + /* + * Any remaining arguments are passed as arguments to the lua script as + * a string array: + * { + * "argv" -> [ "arg 1", ... "arg n" ], + * } + */ + nvlist_t *argnvl = fnvlist_alloc(); + fnvlist_add_string_array(argnvl, ZCP_ARG_CLIARGV, argv + 2, argc - 2); + + ret = lzc_channel_program(poolname, progbuf, instrlimit, memlimit, + argnvl, &outnvl); + + if (ret != 0) { + /* + * On error, report the error message handed back by lua if one + * exists. Otherwise, generate an appropriate error message, + * falling back on strerror() for an unexpected return code. + */ + char *errstring = NULL; + if (nvlist_exists(outnvl, ZCP_RET_ERROR)) { + (void) nvlist_lookup_string(outnvl, + ZCP_RET_ERROR, &errstring); + if (errstring == NULL) + errstring = strerror(ret); + } else { + switch (ret) { + case EINVAL: + errstring = + "Invalid instruction or memory limit."; + break; + case ENOMEM: + errstring = "Return value too large."; + break; + case ENOSPC: + errstring = "Memory limit exhausted."; + break; +#ifdef illumos + case ETIME: +#else + case ETIMEDOUT: +#endif + errstring = "Timed out."; + break; + case EPERM: + errstring = "Permission denied. Channel " + "programs must be run as root."; + break; + default: + errstring = strerror(ret); + } + } + (void) fprintf(stderr, + gettext("Channel program execution failed:\n%s\n"), + errstring); + } else { + (void) printf("Channel program fully executed "); + if (nvlist_empty(outnvl)) { + (void) printf("with no return value.\n"); + } else { + (void) printf("with return value:\n"); + dump_nvlist(outnvl, 4); + } + } + + free(progbuf); + fnvlist_free(outnvl); + fnvlist_free(argnvl); + return (ret != 0); + +usage: + usage(B_FALSE); + return (-1); +} + int main(int argc, char **argv) { diff --git cddl/contrib/opensolaris/cmd/zpool/zpool.8 cddl/contrib/opensolaris/cmd/zpool/zpool.8 index c09448a75eed..d021e25b425f 100644 --- cddl/contrib/opensolaris/cmd/zpool/zpool.8 +++ cddl/contrib/opensolaris/cmd/zpool/zpool.8 @@ -19,14 +19,15 @@ .\" information: Portions Copyright [yyyy] [name of copyright owner] .\" .\" Copyright (c) 2010, Sun Microsystems, Inc. All Rights Reserved. -.\" Copyright 2011, Nexenta Systems, Inc. All Rights Reserved. .\" Copyright (c) 2011, Justin T. Gibbs <gibbs@FreeBSD.org> -.\" Copyright (c) 2013 by Delphix. All Rights Reserved. .\" Copyright (c) 2012, Glen Barber <gjb@FreeBSD.org> +.\" Copyright (c) 2013 by Delphix. All Rights Reserved. +.\" Copyright 2017 Nexenta Systems, Inc. +.\" Copyright (c) 2017 Datto Inc. .\" .\" $FreeBSD$ .\" -.Dd July 26, 2014 +.Dd September 08, 2017 .Dt ZPOOL 8 .Os .Sh NAME @@ -153,7 +154,7 @@ .Op Ar new_device .Nm .Cm scrub -.Op Fl s +.Op Fl s | Fl p .Ar pool ... .Nm .Cm set @@ -1543,43 +1544,54 @@ manner. .It Xo .Nm .Cm scrub -.Op Fl s +.Op Fl s | Fl p .Ar pool ... .Xc .Pp -Begins a scrub. The scrub examines all data in the specified pools to verify -that it checksums correctly. For replicated (mirror or -.No raidz ) -devices, -.Tn ZFS -automatically repairs any damage discovered during the scrub. The -.Qq Nm Cm status +Begins a scrub or resumes a paused scrub. +The scrub examines all data in the specified pools to verify that it checksums +correctly. +For replicated +.Pq mirror or raidz +devices, ZFS automatically repairs any damage discovered during the scrub. +The +.Nm zpool Cm status command reports the progress of the scrub and summarizes the results of the scrub upon completion. .Pp -Scrubbing and resilvering are very similar operations. The difference is that -resilvering only examines data that -.Tn ZFS -knows to be out of date (for example, when attaching a new device to a mirror -or replacing an existing device), whereas scrubbing examines all data to -discover silent errors due to hardware faults or disk failure. -.Pp -Because scrubbing and resilvering are -.Tn I/O Ns -intensive -operations, -.Tn ZFS -only allows one at a time. If a scrub is already in progress, the -.Qq Nm Cm scrub -command returns an error. To start a new scrub, you have to stop the old scrub -with the -.Qq Nm Cm scrub Fl s -command first. If a resilver is in progress, -.Tn ZFS -does not allow a scrub to be started until the resilver completes. -.Bl -tag -width indent +Scrubbing and resilvering are very similar operations. +The difference is that resilvering only examines data that ZFS knows to be out +of date +.Po +for example, when attaching a new device to a mirror or replacing an existing +device +.Pc , +whereas scrubbing examines all data to discover silent errors due to hardware +faults or disk failure. +.Pp +Because scrubbing and resilvering are I/O-intensive operations, ZFS only allows +one at a time. +If a scrub is paused, the +.Nm zpool Cm scrub +resumes it. +If a resilver is in progress, ZFS does not allow a scrub to be started until the +resilver completes. +.Bl -tag -width Ds .It Fl s Stop scrubbing. .El +.Bl -tag -width Ds +.It Fl p +Pause scrubbing. +Scrub pause state and progress are periodically synced to disk. +If the system is restarted or pool is exported during a paused scrub, +even after import, scrub will remain paused until it is resumed. +Once resumed the scrub will pick up from the place where it was last +checkpointed to disk. +To resume a paused scrub issue +.Nm zpool Cm scrub +again. +.El .It Xo .Nm .Cm set diff --git cddl/contrib/opensolaris/cmd/zpool/zpool_main.c cddl/contrib/opensolaris/cmd/zpool/zpool_main.c index e2dc24c5fa91..99be59879419 100644 --- cddl/contrib/opensolaris/cmd/zpool/zpool_main.c +++ cddl/contrib/opensolaris/cmd/zpool/zpool_main.c @@ -21,12 +21,13 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2015 by Delphix. All rights reserved. + * Copyright (c) 2011, 2016 by Delphix. 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) 2013 by Prasad Joshi (sTec). All rights reserved. * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>. * Copyright 2016 Nexenta Systems, Inc. + * Copyright (c) 2017 Datto Inc. */ #include <solaris.h> @@ -252,7 +253,7 @@ get_usage(zpool_help_t idx) case HELP_REOPEN: return (gettext("\treopen <pool>\n")); case HELP_SCRUB: - return (gettext("\tscrub [-s] <pool> ...\n")); + return (gettext("\tscrub [-s | -p] <pool> ...\n")); case HELP_STATUS: return (gettext("\tstatus [-vx] [-T d|u] [pool] ... [interval " "[count]]\n")); @@ -704,7 +705,7 @@ zpool_do_labelclear(int argc, char **argv) return (1); } - if (zpool_read_label(fd, &config) != 0 || config == NULL) { + if (zpool_read_label(fd, &config) != 0) { (void) fprintf(stderr, gettext("failed to read label from %s\n"), vdev); return (1); @@ -3825,6 +3826,7 @@ typedef struct scrub_cbdata { int cb_type; int cb_argc; char **cb_argv; + pool_scrub_cmd_t cb_scrub_cmd; } scrub_cbdata_t; int @@ -3842,15 +3844,16 @@ scrub_callback(zpool_handle_t *zhp, void *data) return (1); } - err = zpool_scan(zhp, cb->cb_type); + err = zpool_scan(zhp, cb->cb_type, cb->cb_scrub_cmd); return (err != 0); } /* - * zpool scrub [-s] <pool> ... + * zpool scrub [-s | -p] <pool> ... * * -s Stop. Stops any in-progress scrub. + * -p Pause. Pause in-progress scrub. */ int zpool_do_scrub(int argc, char **argv) @@ -3859,13 +3862,17 @@ zpool_do_scrub(int argc, char **argv) scrub_cbdata_t cb; cb.cb_type = POOL_SCAN_SCRUB; + cb.cb_scrub_cmd = POOL_SCRUB_NORMAL; /* check options */ - while ((c = getopt(argc, argv, "s")) != -1) { + while ((c = getopt(argc, argv, "sp")) != -1) { switch (c) { case 's': cb.cb_type = POOL_SCAN_NONE; break; + case 'p': + cb.cb_scrub_cmd = POOL_SCRUB_PAUSE; + break; case '?': (void) fprintf(stderr, gettext("invalid option '%c'\n"), optopt); @@ -3873,6 +3880,13 @@ zpool_do_scrub(int argc, char **argv) } } + if (cb.cb_type == POOL_SCAN_NONE && + cb.cb_scrub_cmd == POOL_SCRUB_PAUSE) { + (void) fprintf(stderr, gettext("invalid option combination: " + "-s and -p are mutually exclusive\n")); + usage(B_FALSE); + } + cb.cb_argc = argc; cb.cb_argv = argv; argc -= optind; @@ -3901,7 +3915,7 @@ typedef struct status_cbdata { void print_scan_status(pool_scan_stat_t *ps) { - time_t start, end; + time_t start, end, pause; uint64_t elapsed, mins_left, hours_left; uint64_t pass_exam, examined, total; uint_t rate; @@ -3919,6 +3933,7 @@ print_scan_status(pool_scan_stat_t *ps) start = ps->pss_start_time; end = ps->pss_end_time; + pause = ps->pss_pass_scrub_pause; zfs_nicenum(ps->pss_processed, processed_buf, sizeof (processed_buf)); assert(ps->pss_func == POOL_SCAN_SCRUB || @@ -3961,8 +3976,17 @@ print_scan_status(pool_scan_stat_t *ps) * Scan is in progress. */ if (ps->pss_func == POOL_SCAN_SCRUB) { - (void) printf(gettext("scrub in progress since %s"), - ctime(&start)); + if (pause == 0) { + (void) printf(gettext("scrub in progress since %s"), + ctime(&start)); + } else { + char buf[32]; + struct tm *p = localtime(&pause); + (void) strftime(buf, sizeof (buf), "%a %b %e %T %Y", p); + (void) printf(gettext("scrub paused since %s\n"), buf); + (void) printf(gettext("\tscrub started on %s"), + ctime(&start)); + } } else if (ps->pss_func == POOL_SCAN_RESILVER) { (void) printf(gettext("resilver in progress since %s"), ctime(&start)); @@ -3974,6 +3998,7 @@ print_scan_status(pool_scan_stat_t *ps) /* elapsed time for this pass */ elapsed = time(NULL) - ps->pss_pass_start; + elapsed -= ps->pss_pass_scrub_spent_paused; elapsed = elapsed ? elapsed : 1; pass_exam = ps->pss_pass_exam ? ps->pss_pass_exam : 1; rate = pass_exam / elapsed; @@ -3983,19 +4008,25 @@ print_scan_status(pool_scan_stat_t *ps) zfs_nicenum(examined, examined_buf, sizeof (examined_buf)); zfs_nicenum(total, total_buf, sizeof (total_buf)); - zfs_nicenum(rate, rate_buf, sizeof (rate_buf)); /* * do not print estimated time if hours_left is more than 30 days + * or we have a paused scrub */ - (void) printf(gettext(" %s scanned out of %s at %s/s"), - examined_buf, total_buf, rate_buf); - if (hours_left < (30 * 24)) { - (void) printf(gettext(", %lluh%um to go\n"), - (u_longlong_t)hours_left, (uint_t)(mins_left % 60)); + if (pause == 0) { + zfs_nicenum(rate, rate_buf, sizeof (rate_buf)); + (void) printf(gettext("\t%s scanned out of %s at %s/s"), + examined_buf, total_buf, rate_buf); + if (hours_left < (30 * 24)) { + (void) printf(gettext(", %lluh%um to go\n"), + (u_longlong_t)hours_left, (uint_t)(mins_left % 60)); + } else { + (void) printf(gettext( + ", (scan is slow, no estimated time)\n")); + } } else { - (void) printf(gettext( - ", (scan is slow, no estimated time)\n")); + (void) printf(gettext("\t%s scanned out of %s\n"), + examined_buf, total_buf); } if (ps->pss_func == POOL_SCAN_RESILVER) { @@ -5223,6 +5254,11 @@ get_history_one(zpool_handle_t *zhp, void *data) dump_nvlist(fnvlist_lookup_nvlist(rec, ZPOOL_HIST_OUTPUT_NVL), 8); } + if (nvlist_exists(rec, ZPOOL_HIST_ERRNO)) { + (void) printf(" errno: %lld\n", + fnvlist_lookup_int64(rec, + ZPOOL_HIST_ERRNO)); + } } else { if (!cb->internal) continue; diff --git cddl/contrib/opensolaris/cmd/ztest/ztest.c cddl/contrib/opensolaris/cmd/ztest/ztest.c index 2205c9563eeb..64c550e5cc1a 100644 --- cddl/contrib/opensolaris/cmd/ztest/ztest.c +++ cddl/contrib/opensolaris/cmd/ztest/ztest.c @@ -25,6 +25,7 @@ * Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2017 Joyent, Inc. */ /* @@ -125,6 +126,7 @@ #include <errno.h> #include <sys/fs/zfs.h> #include <libnvpair.h> +#include <libcmdutils.h> static int ztest_fd_data = -1; static int ztest_fd_rand = -1; @@ -556,12 +558,13 @@ usage(boolean_t requested) { const ztest_shared_opts_t *zo = &ztest_opts_defaults; - char nice_vdev_size[10]; - char nice_gang_bang[10]; + char nice_vdev_size[NN_NUMBUF_SZ]; + char nice_gang_bang[NN_NUMBUF_SZ]; FILE *fp = requested ? stdout : stderr; - nicenum(zo->zo_vdev_size, nice_vdev_size); - nicenum(zo->zo_metaslab_gang_bang, nice_gang_bang); + nicenum(zo->zo_vdev_size, nice_vdev_size, sizeof (nice_vdev_size)); + nicenum(zo->zo_metaslab_gang_bang, nice_gang_bang, + sizeof (nice_gang_bang)); (void) fprintf(fp, "Usage: %s\n" "\t[-v vdevs (default: %llu)]\n" @@ -583,6 +586,8 @@ usage(boolean_t requested) "\t[-F freezeloops (default: %llu)] max loops in spa_freeze()\n" "\t[-P passtime (default: %llu sec)] time per pass\n" "\t[-B alt_ztest (default: <none>)] alternate ztest path\n" + "\t[-o variable=value] ... set global variable to an unsigned\n" + "\t 32-bit integer value\n" "\t[-h] (print help)\n" "", zo->zo_pool, @@ -618,7 +623,7 @@ process_options(int argc, char **argv) bcopy(&ztest_opts_defaults, zo, sizeof (*zo)); while ((opt = getopt(argc, argv, - "v:s:a:m:r:R:d:t:g:i:k:p:f:VET:P:hF:B:")) != EOF) { + "v:s:a:m:r:R:d:t:g:i:k:p:f:VET:P:hF:B:o:")) != EOF) { value = 0; switch (opt) { case 'v': @@ -705,6 +710,10 @@ process_options(int argc, char **argv) case 'B': (void) strlcpy(altdir, optarg, sizeof (altdir)); break; + case 'o': + if (set_global_var(optarg) != 0) + usage(B_FALSE); + break; case 'h': usage(B_TRUE); break; @@ -1825,13 +1834,14 @@ ztest_get_done(zgd_t *zgd, int error) ztest_object_unlock(zd, object); if (error == 0 && zgd->zgd_bp) - zil_add_block(zgd->zgd_zilog, zgd->zgd_bp); + zil_lwb_add_block(zgd->zgd_lwb, zgd->zgd_bp); umem_free(zgd, sizeof (*zgd)); } static int -ztest_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio) +ztest_get_data(void *arg, lr_write_t *lr, char *buf, struct lwb *lwb, + zio_t *zio) { ztest_ds_t *zd = arg; objset_t *os = zd->zd_os; @@ -1845,6 +1855,10 @@ ztest_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio) zgd_t *zgd; int error; + ASSERT3P(lwb, !=, NULL); + ASSERT3P(zio, !=, NULL); + ASSERT3U(size, !=, 0); + ztest_object_lock(zd, object, RL_READER); error = dmu_bonus_hold(os, object, FTAG, &db); if (error) { @@ -1865,7 +1879,7 @@ ztest_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio) db = NULL; zgd = umem_zalloc(sizeof (*zgd), UMEM_NOFAIL); - zgd->zgd_zilog = zd->zd_zilog; + zgd->zgd_lwb = lwb; zgd->zgd_private = zd; if (buf != NULL) { /* immediate write */ @@ -3147,10 +3161,10 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id) old_class_space, new_class_space); if (ztest_opts.zo_verbose >= 5) { - char oldnumbuf[6], newnumbuf[6]; + char oldnumbuf[NN_NUMBUF_SZ], newnumbuf[NN_NUMBUF_SZ]; - nicenum(old_class_space, oldnumbuf); - nicenum(new_class_space, newnumbuf); + nicenum(old_class_space, oldnumbuf, sizeof (oldnumbuf)); + nicenum(new_class_space, newnumbuf, sizeof (newnumbuf)); (void) printf("%s grew from %s to %s\n", spa->spa_name, oldnumbuf, newnumbuf); } @@ -6193,7 +6207,7 @@ main(int argc, char **argv) ztest_info_t *zi; ztest_shared_callstate_t *zc; char timebuf[100]; - char numbuf[6]; + char numbuf[NN_NUMBUF_SZ]; spa_t *spa; char *cmd; boolean_t hasalt; @@ -6330,7 +6344,7 @@ main(int argc, char **argv) now = MIN(now, zs->zs_proc_stop); print_time(zs->zs_proc_stop - now, timebuf); - nicenum(zs->zs_space, numbuf); + nicenum(zs->zs_space, numbuf, sizeof (numbuf)); (void) printf("Pass %3d, %8s, %3llu ENOSPC, " "%4.1f%% of %5s used, %3.0f%% done, %8s to go\n", diff --git cddl/contrib/opensolaris/lib/libcmdutils/common/nicenum.c cddl/contrib/opensolaris/lib/libcmdutils/common/nicenum.c new file mode 100644 index 000000000000..8e3202f79270 --- /dev/null +++ cddl/contrib/opensolaris/lib/libcmdutils/common/nicenum.c @@ -0,0 +1,130 @@ +/* + * 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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2017 Jason king + */ + +#include <stdio.h> +#include <string.h> +#include <sys/types.h> +#include <sys/debug.h> +#include "libcmdutils.h" + +/* The largest suffix that can fit, aka an exabyte (2^60 / 10^18) */ +#define INDEX_MAX (6) + +/* Verify INDEX_MAX fits */ +CTASSERT(INDEX_MAX * 10 < sizeof (uint64_t) * 8); + +void +nicenum_scale(uint64_t n, size_t units, char *buf, size_t buflen, + uint32_t flags) +{ + uint64_t divamt = 1024; + uint64_t divisor = 1; + int index = 0; + int rc = 0; + char u; + + if (units == 0) + units = 1; + + if (n > 0) { + n *= units; + if (n < units) + goto overflow; + } + + if (flags & NN_DIVISOR_1000) + divamt = 1000; + + /* + * This tries to find the suffix S(n) such that + * S(n) <= n < S(n+1), where S(n) = 2^(n*10) | 10^(3*n) + * (i.e. 1024/1000, 1,048,576/1,000,000, etc). Stop once S(n) + * is the largest prefix supported (i.e. don't bother computing + * and checking S(n+1). Since INDEX_MAX should be the largest + * suffix that fits (currently an exabyte), S(INDEX_MAX + 1) is + * never checked as it would overflow. + */ + while (index < INDEX_MAX) { + uint64_t newdiv = divisor * divamt; + + /* CTASSERT() guarantee these never trip */ + VERIFY3U(newdiv, >=, divamt); + VERIFY3U(newdiv, >=, divisor); + + if (n < newdiv) + break; + + divisor = newdiv; + index++; + } + + u = " KMGTPE"[index]; + + if (index == 0) { + rc = snprintf(buf, buflen, "%llu", n); + } else if (n % divisor == 0) { + /* + * If this is an even multiple of the base, always display + * without any decimal precision. + */ + rc = snprintf(buf, buflen, "%llu%c", n / divisor, u); + } else { + /* + * We want to choose a precision that reflects the best choice + * for fitting in 5 characters. This can get rather tricky + * when we have numbers that are very close to an order of + * magnitude. For example, when displaying 10239 (which is + * really 9.999K), we want only a single place of precision + * for 10.0K. We could develop some complex heuristics for + * this, but it's much easier just to try each combination + * in turn. + */ + int i; + for (i = 2; i >= 0; i--) { + if ((rc = snprintf(buf, buflen, "%.*f%c", i, + (double)n / divisor, u)) <= 5) + break; + } + } + + if (rc + 1 > buflen || rc < 0) + goto overflow; + + return; + +overflow: + /* prefer a more verbose message if possible */ + if (buflen > 10) + (void) strlcpy(buf, "<overflow>", buflen); + else + (void) strlcpy(buf, "??", buflen); +} + +void +nicenum(uint64_t num, char *buf, size_t buflen) +{ + nicenum_scale(num, 1, buf, buflen, 0); +} diff --git cddl/contrib/opensolaris/lib/libcmdutils/libcmdutils.h cddl/contrib/opensolaris/lib/libcmdutils/libcmdutils.h new file mode 100644 index 000000000000..fffdd9de22f1 --- /dev/null +++ cddl/contrib/opensolaris/lib/libcmdutils/libcmdutils.h @@ -0,0 +1,235 @@ +/* + * 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. + */ +/* + * Copyright (c) 2013 RackTop Systems. + */ +/* + * Copyright 2017 Joyent, Inc. + */ + +/* + * Declarations for the functions in libcmdutils. + */ + +#ifndef _LIBCMDUTILS_H +#define _LIBCMDUTILS_H + +#ifdef illumos +#if !defined(_LP64) && \ + !((_FILE_OFFSET_BITS == 64) || defined(_LARGEFILE64_SOURCE)) +#error "libcmdutils.h can only be used in a largefile compilation environment" +#endif +#endif + +/* + * This is a private header file. Applications should not directly include + * this file. + */ + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <stdarg.h> +#include <errno.h> +#include <fcntl.h> +#include <limits.h> +#include <libintl.h> +#include <string.h> +#include <dirent.h> +#ifdef illumos +#include <attr.h> +#endif +#include <sys/avl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <libnvpair.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* extended system attribute support */ +#define _NOT_SATTR 0 +#define _RO_SATTR 1 +#define _RW_SATTR 2 + +#define MAXMAPSIZE (1024*1024*8) /* map at most 8MB */ +#define SMALLFILESIZE (32*1024) /* don't use mmap on little file */ + +/* Type used for a node containing a device id and inode number */ + +#if defined(_LP64) || (_FILE_OFFSET_BITS == 64) +typedef struct tree_node { + dev_t node_dev; + ino_t node_ino; + avl_node_t avl_link; +} tree_node_t; +#else +typedef struct tree_node { + dev_t node_dev; + ino64_t node_ino; + avl_node_t avl_link; +} tree_node_t; +#endif + + /* extended system attribute support */ + +/* Determine if a file is the name of an extended system attribute file */ +extern int sysattr_type(char *); + +/* Determine if the underlying file system supports system attributes */ +extern int sysattr_support(char *, int); + +/* Copies the content of the source file to the target file */ +#if defined(_LP64) || (_FILE_OFFSET_BITS == 64) +extern int writefile(int, int, char *, char *, char *, char *, + struct stat *, struct stat *); +#else +extern int writefile(int, int, char *, char *, char *, char *, + struct stat64 *, struct stat64 *); +#endif + +/* Gets file descriptors of the source and target attribute files */ +extern int get_attrdirs(int, int, char *, int *, int *); + +/* Move extended attribute and extended system attribute */ +extern int mv_xattrs(char *, char *, char *, int, int); + +/* Returns non default extended system attribute list */ +extern nvlist_t *sysattr_list(char *, int, char *); + + + + /* avltree */ + +/* + * Used to compare two nodes. We are attempting to match the 1st + * argument (node) against the 2nd argument (a node which + * is already in the search tree). + */ + +extern int tnode_compare(const void *, const void *); + +/* + * Used to add a single node (containing the input device id and + * inode number) to the specified search tree. The calling + * application must set the tree pointer to NULL before calling + * add_tnode() for the first time. + */ +#if defined(_LP64) || (_FILE_OFFSET_BITS == 64) +extern int add_tnode(avl_tree_t **, dev_t, ino_t); +#else +extern int add_tnode(avl_tree_t **, dev_t, ino64_t); +#endif + +/* + * Used to destroy a whole tree (all nodes) without rebalancing. + * The calling application is responsible for setting the tree + * pointer to NULL upon return. + */ +extern void destroy_tree(avl_tree_t *); + + + + /* user/group id helpers */ + +/* + * Used to get the next available user id in given range. + */ +extern int findnextuid(uid_t, uid_t, uid_t *); + +/* + * Used to get the next available group id in given range. + */ +extern int findnextgid(gid_t, gid_t, gid_t *); + + + + /* dynamic string utilities */ + +typedef struct custr custr_t; + +/* + * Allocate and free a "custr_t" dynamic string object. Returns 0 on success + * and -1 otherwise. + */ +extern int custr_alloc(custr_t **); +extern void custr_free(custr_t *); + +/* + * Allocate a "custr_t" dynamic string object that operates on a fixed external + * buffer. + */ +extern int custr_alloc_buf(custr_t **, void *, size_t); + +/* + * Append a single character, or a NUL-terminated string of characters, to a + * dynamic string. Returns 0 on success and -1 otherwise. The dynamic string + * will be unmodified if the function returns -1. + */ +extern int custr_appendc(custr_t *, char); +extern int custr_append(custr_t *, const char *); + +/* + * Append a format string and arguments as though the contents were being parsed + * through snprintf. Returns 0 on success and -1 otherwise. The dynamic string + * will be unmodified if the function returns -1. + */ +extern int custr_append_printf(custr_t *, const char *, ...); +extern int custr_append_vprintf(custr_t *, const char *, va_list); + +/* + * Determine the length in bytes, not including the NUL terminator, of the + * dynamic string. + */ +extern size_t custr_len(custr_t *); + +/* + * Clear the contents of a dynamic string. Does not free the underlying + * memory. + */ +extern void custr_reset(custr_t *); + +/* + * Retrieve a const pointer to a NUL-terminated string version of the contents + * of the dynamic string. Storage for this string should not be freed, and + * the pointer will be invalidated by any mutations to the dynamic string. + */ +extern const char *custr_cstr(custr_t *str); + +#define NN_DIVISOR_1000 (1U << 0) + +/* Minimum size for the output of nicenum, including NULL */ +#define NN_NUMBUF_SZ (6) + +void nicenum(uint64_t, char *, size_t); +void nicenum_scale(uint64_t, size_t, char *, size_t, uint32_t); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBCMDUTILS_H */ diff --git cddl/contrib/opensolaris/lib/libctf/common/ctf.5 cddl/contrib/opensolaris/lib/libctf/common/ctf.5 index 316e97872c07..5a90b0ef3121 100644 --- cddl/contrib/opensolaris/lib/libctf/common/ctf.5 +++ cddl/contrib/opensolaris/lib/libctf/common/ctf.5 @@ -39,7 +39,8 @@ data contained in each file has information about the layout and sizes of C types, including intrinsic types, enumerations, structures, typedefs, and unions, that are used by the corresponding .Sy ELF -object. The +object. +The .Nm data may also include information about the types of global objects and the return type and arguments of functions in the symbol table. @@ -51,41 +52,43 @@ file itself, it may also be referred to as a .Nm .Sy container . .Lp -On illumos systems, +On +.Fx +systems, .Nm -data is consumed by multiple programs. It can be used by the modular -debugger, -.Xr mdb 1 , -as well as by -.Xr dtrace 1M . +data is consumed by +.Xr dtrace 1 . Programmatic access to .Nm -data can be obtained through -.Xr libctf 3LIB . +data can be obtained through libctf. .Lp The .Nm -file format is broken down into seven different sections. The first -section is the +file format is broken down into seven different sections. +The first section is the .Sy preamble and .Sy header , which describes the version of the .Nm -file, links it has to other +file, the links it has to other .Nm -files, and the sizes of the other sections. The next section is the +files, and the sizes of the other sections. +The next section is the .Sy label section, which provides a way of identifying similar groups of .Nm -data across multiple files. This is followed by the +data across multiple files. +This is followed by the .Sy object -information section, which describes the type of global -symbols. The subsequent section is the +information section, which describes the types of global +symbols. +The subsequent section is the .Sy function information section, which describes the return -types and arguments of functions. The next section is the +types and arguments of functions. +The next section is the .Sy type information section, which describes the format and layout of the C types themselves, and finally the last @@ -106,29 +109,35 @@ A file may contain all of the type information that it requires, or it may optionally refer to another .Nm -file which holds the remaining types. When a +file which holds the remaining types. +When a .Nm file refers to another file, it is called the .Sy child and the file it refers to is called the .Sy parent . -A given file may only refer to one parent. This process is called +A given file may only refer to one parent. +This process is called .Em uniquification because it ensures each child only has type information that is -unique to it. A common example of this is that most kernel modules in -illumos are uniquified against the kernel module +unique to it. +A common example of this is that most kernel modules in illumos are uniquified +against the kernel module .Sy genunix and the type information that comes from the .Sy IP -module. This means that a module only has types that are unique to -itself and the most common types in the kernel are not duplicated. +module. +This means that a module only has types that are unique to itself and the most +common types in the kernel are not duplicated. .Sh FILE FORMAT This documents version .Em two of the .Nm -file format. All applications and tools currently produce and operate on -this version. +file format. +All applications and tools on +.Fx +currently produce and operate on this version. .Lp The file format can be summarized with the following image, the following sections will cover this in more detail. @@ -235,26 +244,31 @@ This .Sy preamble defines the version of the .Nm -file which defines the format of the rest of the header. While the -header may change in subsequent versions, the preamble will not change +file which defines the format of the rest of the header. +While the header may change in subsequent versions, the preamble will not change across versions, though the interpretation of its flags may change from -version to version. The +version to version. +The .Em ctp_magic member defines the magic number for the .Nm -file format. This must always be +file format. +This must always be .Li 0xcff1 . If another value is encountered, then the file should not be treated as a .Nm -file. The +file. +The .Em ctp_version member defines the version of the .Nm -file. The current version is +file. +The current version is .Li 2 . -It is possible to encounter an unsupported version. In that case, -software should not try to parse the format, as it may have changed. +It is possible to encounter an unsupported version. +In that case, software should not try to parse the format, as it may have +changed. Finally, the .Em ctp_flags member describes aspects of the file which modify its interpretation. @@ -273,9 +287,10 @@ has been compressed through the .Sy zlib library and its .Sy deflate -algorithm. If this flag is not present, then the body has not been -compressed and no special action is needed to interpret it. All offsets -into the data as described by +algorithm. +If this flag is not present, then the body has not been compressed and no +special action is needed to interpret it. +All offsets into the data as described by .Sy header , always refer to the .Sy uncompressed @@ -285,13 +300,13 @@ In version two of the .Nm file format, the .Sy header -denotes whether whether or not this +denotes whether or not this .Nm file is the child of another .Nm -file and also indicates the size of the remaining sections. The -structure for the -.Sy header , +file and also indicates the size of the remaining sections. +The structure for the +.Sy header logically contains a copy of the .Sy preamble and the two have a combined size of 36 bytes. @@ -315,37 +330,40 @@ the next two members .Em cth_parlablel and .Em cth_parname , -are used to identify the parent. The value of both members are offsets -into the +are used to identify the parent. +The value of both members are offsets into the .Sy string -section which point to the start of a null-terminated string. For more -information on the encoding of strings, see the subsection on +section which point to the start of a null-terminated string. +For more information on the encoding of strings, see the subsection on .Sx String Identifiers . If the value of either is zero, then there is no entry for that -member. If the member +member. +If the member .Em cth_parlabel is set, then the .Em ctf_parname member must be set, otherwise it will not be possible to find the -parent. If +parent. +If .Em ctf_parname is set, it is not necessary to define .Em cth_parlabel , -as the parent may not have a label. For more information on labels -and their interpretation, see +as the parent may not have a label. +For more information on labels and their interpretation, see .Sx The Label Section . .Lp The remaining members (excepting .Em cth_strlen ) -describe the beginning of the corresponding sections. These offsets are -relative to the end of the +describe the beginning of the corresponding sections. +These offsets are relative to the end of the .Sy header . Therefore, something with an offset of 0 is at an offset of thirty-six bytes relative to the start of the .Nm -file. The difference between members -indicates the size of the section itself. Different offsets have -different alignment requirements. The start of the +file. +The difference between members indicates the size of the section itself. +Different offsets have different alignment requirements. +The start of the .Em cth_objotoff and .Em cth_funcoff @@ -353,13 +371,14 @@ must be two byte aligned, while the sections .Em cth_lbloff and .Em cth_typeoff -must be four-byte aligned. The section +must be four-byte aligned. +The section .Em cth_stroff -has no alignment requirements. To calculate the size of a given section, -excepting the +has no alignment requirements. +To calculate the size of a given section, excepting the .Sy string -section, one should subtract the offset of the section from the following one. For -example, the size of the +section, one should subtract the offset of the section from the following one. +For example, the size of the .Sy types section can be calculated by subtracting .Em cth_stroff @@ -368,8 +387,8 @@ from .Lp Finally, the member .Em cth_strlen -describes the length of the string section itself. From it, you can also -calculate the size of the entire +describes the length of the string section itself. +From it, you can also calculate the size of the entire .Nm file by adding together the size of the .Sy ctf_header_t , @@ -380,9 +399,11 @@ and the size of the string section in .Ss Type Identifiers Through the .Nm ctf -data, types are referred to by identifiers. A given +data, types are referred to by identifiers. +A given .Nm -file supports up to 32767 (0x7fff) types. The first valid type identifier is 0x1. +file supports up to 32767 (0x7fff) types. +The first valid type identifier is 0x1. When a given .Nm file is a child, indicated by a non-zero entry for the @@ -403,18 +424,20 @@ Other consumers of information may use larger or opaque identifiers. .Ss String Identifiers String identifiers are always encoded as four byte unsigned integers -which are an offset into a string table. The +which are an offset into a string table. +The .Nm format supports two different string tables which have an identifier of -zero or one. This identifier is stored in the high-order bit of the -unsigned four byte offset. Therefore, the maximum supported offset into -one of these tables is 0x7ffffffff. +zero or one. +This identifier is stored in the high-order bit of the unsigned four byte +offset. +Therefore, the maximum supported offset into one of these tables is 0x7ffffffff. .Lp Table identifier zero, always refers to the .Sy string -section in the CTF file itself. String table identifier one refers to an -external string table which is the ELF string table for the ELF symbol -table associated with the +section in the CTF file itself. +String table identifier one refers to an external string table which is the ELF +string table for the ELF symbol table associated with the .Nm container. .Ss Type Encoding @@ -434,8 +457,8 @@ The length of the variable data .Lp The 16 bits that make up the encoding are broken down such that you have five bits for the kind, one bit for indicating whether or not it is a -root type, and 10 bits for the variable length. This is laid out as -follows: +root type, and 10 bits for the variable length. +This is laid out as follows: .Bd -literal -offset indent +--------------------+ | kind | root | vlen | @@ -443,12 +466,13 @@ follows: 15 11 10 9 0 .Ed .Lp -The current version of the file format defines 14 different kinds. The -interpretation of these different kinds will be discussed in the section +The current version of the file format defines 14 different kinds. +The interpretation of these different kinds will be discussed in the section .Sx The Type Section . If a kind is encountered that is not listed below, then it is not a valid .Nm -file. The kinds are defined as follows: +file. +The kinds are defined as follows: .Bd -literal -offset indent #define CTF_K_UNKNOWN 0 #define CTF_K_INTEGER 1 @@ -467,14 +491,16 @@ file. The kinds are defined as follows: .Ed .Lp Programs directly reference many types; however, other types are referenced -indirectly because they are part of some other structure. These types that are -referenced directly and used are called +indirectly because they are part of some other structure. +These types that are referenced directly and used are called .Sy root -types. Other types may be used indirectly, for example, a program may reference -a structure directly, but not one of its members which has a type. That type is -not considered a +types. +Other types may be used indirectly, for example, a program may reference +a structure directly, but not one of its members which has a type. +That type is not considered a .Sy root -type. If a type is a +type. +If a type is a .Sy root type, then it will have bit 10 set. .Lp @@ -499,16 +525,17 @@ When consuming .Nm data, it is often useful to know whether two different .Nm -containers come from the same source base and version. For example, when -building illumos, there are many kernel modules that are built against a -single collection of source code. A label is encoded into the +containers come from the same source base and version. +For example, when building illumos, there are many kernel modules that are built +against a single collection of source code. +A label is encoded into the .Nm -files that corresponds with the particular build. This ensures that if -files on the system were to become mixed up from multiple releases, that -they are not used together by tools, particularly when a child needs to -refer to a type in the parent. Because they are linked used the type -identifiers, if the wrong parent is used then the wrong type will be -encountered. +files that corresponds with the particular build. +This ensures that if files on the system were to become mixed up from multiple +releases, that they are not used together by tools, particularly when a child +needs to refer to a type in the parent. +Because they are linked using the type identifiers, if the wrong parent is used +then the wrong type will be encountered. .Lp Each label is encoded in the file format using the following eight byte structure: @@ -530,21 +557,22 @@ section. The type identifier encoded in the member .Em ctl_typeidx refers to the last type identifier that a label refers to in the current -file. Labels only refer to types in the current file, if the +file. +Labels only refer to types in the current file, if the .Nm file is a child, then it will have the same label as its parent; -however, its label will only refer to its types, not its parents. +however, its label will only refer to its types, not its parent's. .Lp It is also possible, though rather uncommon, for a .Nm -file to have multiple labels. Labels are placed one after another, every -eight bytes. When multiple labels are present, types may only belong to -a single label. +file to have multiple labels. +Labels are placed one after another, every eight bytes. +When multiple labels are present, types may only belong to a single label. .Ss The Object Section The object section provides a mapping from ELF symbols of type .Sy STT_OBJECT -in the symbol table to a type identifier. Every entry in this section is -a +in the symbol table to a type identifier. +Every entry in this section is a .Sy uint16_t which contains a type identifier as described in the section .Sx Type Identifiers . @@ -555,9 +583,10 @@ To walk the object section, you need to have a corresponding .Sy symbol table in the ELF object that contains the .Nm -data. Not every object is included in this section. Specifically, when -walking the symbol table. An entry is skipped if it matches any of the -following conditions: +data. +Not every object is included in this section. +Specifically, when walking the symbol table, an entry is skipped if it matches +any of the following conditions: .Lp .Bl -bullet -offset indent -compact .It @@ -628,40 +657,45 @@ walk_symbols(uint16_t *objtoff, Elf_Data *symdata, Elf_Data *strdata, The function section of the .Nm file encodes the types of both the function's arguments and the function's -return type. Similar to +return value. +Similar to .Sx The Object Section , the function section encodes information for all symbols of type .Sy STT_FUNCTION , -excepting those that fit specific criteria. Unlike with objects, because -functions have a variable number of arguments, they start with a type encoding -as defined in +excepting those that fit specific criteria. +Unlike with objects, because functions have a variable number of arguments, they +start with a type encoding as defined in .Sx Type Encoding , which is the size of a .Sy uint16_t . For functions which have no type information available, they are encoded as .Li CTF_TYPE_INFO(CTF_K_UNKNOWN, 0, 0) . -Functions with arguments are encoded differently. Here, the variable length is -turned into the number of arguments in the function. If a function is a +Functions with arguments are encoded differently. +Here, the variable length is turned into the number of arguments in the +function. +If a function is a .Sy varargs -type function, then the number of arguments is increased by one. Functions with -type information are encoded as: +type function, then the number of arguments is increased by one. +Functions with type information are encoded as: .Li CTF_TYPE_INFO(CTF_K_FUNCTION, 0, nargs) . .Lp For functions that have no type information, nothing else is encoded, and the -next function is encoded. For functions with type information, the next +next function is encoded. +For functions with type information, the next .Sy uint16_t -is encoded with the type identifier of the return type of the function. It is -followed by each of the type identifiers of the arguments, if any exist, in the -order that they appear in the function. Therefore, argument 0 is the first type -identifier and so on. When a function has a final varargs argument, that is -encoded with the type identifier of zero. +is encoded with the type identifier of the return type of the function. +It is followed by each of the type identifiers of the arguments, if any exist, +in the order that they appear in the function. +Therefore, argument 0 is the first type identifier and so on. +When a function has a final varargs argument, that is encoded with the type +identifier of zero. .Lp Like .Sx The Object Section , -the function section is encoded in the order of the symbol table. It has -similar, but slightly different considerations from objects. While iterating the -symbol table, if any of the following conditions are true, then the entry is -skipped and no corresponding entry is written: +the function section is encoded in the order of the symbol table. +It has similar, but slightly different considerations from objects. +While iterating the symbol table, if any of the following conditions are true, +then the entry is skipped and no corresponding entry is written: .Lp .Bl -bullet -offset indent -compact .It @@ -683,10 +717,11 @@ ELF. .Ss The Type Section The type section is the heart of the .Nm -data. It encodes all of the information about the types themselves. The base of -the type information comes in two forms, a short form and a long form, each of -which may be followed by a variable number of arguments. The following -definitions describe the short and long forms: +data. +It encodes all of the information about the types themselves. +The base of the type information comes in two forms, a short form and a long +form, each of which may be followed by a variable number of arguments. +The following definitions describe the short and long forms: .Bd -literal #define CTF_MAX_SIZE 0xfffe /* max size of a type in bytes */ #define CTF_LSIZE_SENT 0xffff /* sentinel for ctt_size */ @@ -720,14 +755,17 @@ Type sizes are stored in .Sy bytes . The basic small form uses a .Sy ushort_t -to store the number of bytes. If the number of bytes in a structure would exceed -0xfffe, then the alternate form, the +to store the number of bytes. +If the number of bytes in a structure would exceed 0xfffe, then the alternate +form, the .Sy ctf_type_t , -is used instead. To indicate that the larger form is being used, the member +is used instead. +To indicate that the larger form is being used, the member .Em ctt_size is set to value of .Sy CTF_LSIZE_SENT -(0xffff). In general, when going through the type section, consumers use the +(0xffff). +In general, when going through the type section, consumers use the .Sy ctf_type_t structure, but pay attention to the value of the member .Em ctt_size @@ -739,36 +777,43 @@ Not all kinds of types use .Sy ctt_size . Those which do not, will always use the .Sy ctf_stype_t -structure. The individual sections for each kind have more information. +structure. +The individual sections for each kind have more information. .Lp -Types are written out in order. Therefore the first entry encountered has a type -id of 0x1, or 0x8000 if a child. The member +Types are written out in order. +Therefore the first entry encountered has a type id of 0x1, or 0x8000 if a +child. +The member .Em ctt_name is encoded as described in the section .Sx String Identifiers . -The string that it points to is the name of the type. If the identifier points -to an empty string (one that consists solely of a null terminator) then the type -does not have a name, this is common with anonymous structures and unions that -only have a typedef to name them, as well as, pointers and qualifiers. +The string that it points to is the name of the type. +If the identifier points to an empty string (one that consists solely of a null +terminator) then the type does not have a name, this is common with anonymous +structures and unions that only have a typedef to name them, as well as +pointers and qualifiers. .Lp The next member, the .Em ctt_info , is encoded as described in the section .Sx Type Encoding . -The types kind tells us how to interpret the remaining data in the +The type's kind tells us how to interpret the remaining data in the .Sy ctf_type_t -and any variable length data that may exist. The rest of this section will be -broken down into the interpretation of the various kinds. +and any variable length data that may exist. +The rest of this section will be broken down into the interpretation of the +various kinds. .Ss Encoding of Integers Integers, which are of type .Sy CTF_K_INTEGER , -have no variable length arguments. Instead, they are followed by a four byte +have no variable length arguments. +Instead, they are followed by a four byte .Sy uint_t -which describes their encoding. All integers must be encoded with a variable -length of zero. The +which describes their encoding. +All integers must be encoded with a variable length of zero. +The .Em ctt_size -member describes the length of the integer in bytes. In general, integer sizes -will be rounded up to the closest power of two. +member describes the length of the integer in bytes. +In general, integer sizes will be rounded up to the closest power of two. .Lp The integer encoding contains three different pieces of information: .Bl -bullet -offset indent -compact @@ -804,33 +849,37 @@ The following flags are defined for the encoding at this time: .Lp By default, an integer is considered to be unsigned, unless it has the .Sy CTF_INT_SIGNED -flag set. If the flag +flag set. +If the flag .Sy CTF_INT_CHAR is set, that indicates that the integer is of a type that stores character data, for example the intrinsic C type .Sy char would have the .Sy CTF_INT_CHAR -flag set. If the flag +flag set. +If the flag .Sy CTF_INT_BOOL -is set, that indicates that the integer represents a boolean type. For example, -the intrinsic C type +is set, that indicates that the integer represents a boolean type. +For example, the intrinsic C type .Sy _Bool would have the .Sy CTF_INT_BOOL -flag set. Finally, the flag +flag set. +Finally, the flag .Sy CTF_INT_VARARGS indicates that the integer is used as part of a variable number of arguments. This encoding is rather uncommon. .Ss Encoding of Floats Floats, which are of type .Sy CTF_K_FLOAT , -are similar to their integer counterparts. They have no variable length -arguments and are followed by a four byte encoding which describes the kind of -float that exists. The +are similar to their integer counterparts. +They have no variable length arguments and are followed by a four byte encoding +which describes the kind of float that exists. +The .Em ctt_size -member is the size, in bytes, of the float. The float encoding has three -different pieces of information inside of it: +member is the size, in bytes, of the float. +The float encoding has three different pieces of information inside of it: .Lp .Bl -bullet -offset indent -compact .It @@ -855,11 +904,12 @@ This encoding can be expressed through the following macros: (((encoding) << 24) | ((offset) << 16) | (bits)) .Ed .Lp -Where as the encoding for integers was a series of flags, the encoding for -floats maps to a specific kind of float. It is not a flag-based value. The kinds of floats -correspond to both their size, and the encoding. This covers all of the basic C -intrinsic floating point types. The following are the different kinds of floats -represented in the encoding: +Where as the encoding for integers is a series of flags, the encoding for +floats maps to a specific kind of float. +It is not a flag-based value. +The kinds of floats correspond to both their size, and the encoding. +This covers all of the basic C intrinsic floating point types. +The following are the different kinds of floats represented in the encoding: .Bd -literal -offset indent #define CTF_FP_SINGLE 1 /* IEEE 32-bit float encoding */ #define CTF_FP_DOUBLE 2 /* IEEE 64-bit float encoding */ @@ -877,12 +927,14 @@ represented in the encoding: .Ss Encoding of Arrays Arrays, which are of type .Sy CTF_K_ARRAY , -have no variable length arguments. They are followed by a structure which -describes the number of elements in the array, the type identifier of the -elements in the array, and the type identifier of the index of the array. With -arrays, the +have no variable length arguments. +They are followed by a structure which describes the number of elements in the +array, the type identifier of the elements in the array, and the type identifier +of the index of the array. +With arrays, the .Em ctt_size -member is set to zero. The structure that follows an array is defined as: +member is set to zero. +The structure that follows an array is defined as: .Bd -literal typedef struct ctf_array { ushort_t cta_contents; /* reference to type of array contents */ @@ -901,14 +953,15 @@ are type identifiers which are encoded as per the section .Sx Type Identifiers . The member .Em cta_nelems -is a simple four byte unsigned count of the number of elements. This count may -be zero when encountering C99's flexible array members. +is a simple four byte unsigned count of the number of elements. +This count may be zero when encountering C99's flexible array members. .Ss Encoding of Functions Function types, which are of type .Sy CTF_K_FUNCTION , -use the variable length list to be the number of arguments in the function. When -the function has a final member which is a varargs, then the argument count is -incremented by one to account for the variable argument. Here, the +use the variable length list to be the number of arguments in the function. +When the function has a final member which is a varargs, then the argument count +is incremented by one to account for the variable argument. +Here, the .Em ctt_type member is encoded with the type identifier of the return type of the function. Note that the @@ -916,31 +969,40 @@ Note that the member is not used here. .Lp The variable argument list contains the type identifiers for the arguments of -the function, if any. Each one is represented by a +the function, if any. +Each one is represented by a .Sy uint16_t and encoded according to the .Sx Type Identifiers -section. If the function's last argument is of type varargs, then it is also -written out, but the type identifier is zero. This is included in the count of -the function's arguments. +section. +If the function's last argument is of type varargs, then it is also written out, +but the type identifier is zero. +This is included in the count of the function's arguments. +An extra type identifier may follow the argument and return type identifiers +in order to maintain four-byte alignment for the following type definition. +Such a type identifier is not included in the argument count and has a value +of zero. .Ss Encoding of Structures and Unions Structures and Unions, which are encoded with .Sy CTF_K_STRUCT and .Sy CTF_K_UNION -respectively, are very similar constructs in C. The main difference -between them is the fact that every member of a structure follows one another, -where as in a union, all members share the same memory. They are also very -similar in terms of their encoding in +respectively, are very similar constructs in C. +The main difference between them is the fact that members of a structure +follow one another, where as in a union, all members share the same memory. +They are also very similar in terms of their encoding in .Nm . The variable length argument for structures and unions represents the number of -members that they have. The value of the member +members that they have. +The value of the member .Em ctt_size -is the size of the structure and union. There are two different structures which -are used to encode members in the variable list. When the size of a structure or -union is greater than or equal to the large member threshold, 8192, then a -different structure is used to encode the member, all members are encoded using -the same structure. The structure for members is as follows: +is the size of the structure and union. +There are two different structures which are used to encode members in the +variable list. +When the size of a structure or union is greater than or equal to the large +member threshold, 8192, then a different structure is used to encode the member, +all members are encoded using the same structure. +The structure for members is as follows: .Bd -literal typedef struct ctf_member { uint_t ctm_name; /* reference to name in string table */ @@ -961,54 +1023,66 @@ Both the .Em ctm_name and .Em ctlm_name -refer to the name of the member. The name is encoded as an offset into the -string table as described by the section +refer to the name of the member. +The name is encoded as an offset into the string table as described by the +section .Sx String Identifiers . The members .Sy ctm_type and .Sy ctlm_type -both refer to the type of the member. They are encoded as per the section +both refer to the type of the member. +They are encoded as per the section .Sx Type Identifiers . .Lp The last piece of information that is present is the offset which describes the -offset in memory that the member begins at. For unions, this value will always -be zero because the start of unions in memory is always zero. For structures, -this is the offset in +offset in memory at which the member begins. +For unions, this value will always be zero because each member of a union has +an offset of zero. +For structures, this is the offset in .Sy bits -that the member begins at. Note that a compiler may lay out a type with padding. +at which the member begins. +Note that a compiler may lay out a type with padding. This means that the difference in offset between two consecutive members may be -larger than the size of the member. When the size of the overall structure is -strictly less than 8192 bytes, the normal structure, +larger than the size of the member. +When the size of the overall structure is strictly less than 8192 bytes, the +normal structure, .Sy ctf_member_t , is used and the offset in bits is stored in the member .Em ctm_offset . However, when the size of the structure is greater than or equal to 8192 bytes, -then the number of bits is split into two 32-bit quantities. One member, +then the number of bits is split into two 32-bit quantities. +One member, .Em ctlm_offsethi , represents the upper 32 bits of the offset, while the other member, .Em ctlm_offsetlo , -represents the lower 32 bits of the offset. These can be joined together to get -a 64-bit sized offset in bits by shifting the member +represents the lower 32 bits of the offset. +These can be joined together to get a 64-bit sized offset in bits by shifting +the member .Em ctlm_offsethi to the left by thirty two and then doing a binary or of .Em ctlm_offsetlo . .Ss Encoding of Enumerations Enumerations, noted by the type .Sy CTF_K_ENUM , -are similar to structures. Enumerations use the variable list to note the number -of values that the enumeration contains, which we'll term enumerators. In C, an -enumeration is always equivalent to the intrinsic type +are similar to structures. +Enumerations use the variable list to note the number of values that the +enumeration contains, which we'll term enumerators. +In C, an enumeration is always equivalent to the intrinsic type .Sy int , thus the value of the member .Em ctt_size is always the size of an integer which is determined based on the current model. -For illumos systems, this will always be 4, as an integer is always defined to +For +.Fx +systems, this will always be 4, as an integer is always defined to be 4 bytes large in both .Sy ILP32 and .Sy LP64 , regardless of the architecture. +For further details, see +.Xr arch 7 . .Lp The enumerators encoded in an enumeration have the following structure in the variable list: @@ -1032,25 +1106,27 @@ Forward references, types of kind .Sy CTF_K_FORWARD , in a .Nm -file refer to types which may not have a definition at all, only a name. If -the +file refer to types which may not have a definition at all, only a name. +If the .Nm file is a child, then it may be that the forward is resolved to an actual type in the parent, otherwise the definition may be in another .Nm -container or may not be known at all. The only member of the +container or may not be known at all. +The only member of the .Sy ctf_type_t that matters for a forward declaration is the .Em ctt_name which points to the name of the forward reference in the string table as -described earlier. There is no other information recorded for forward -references. +described earlier. +There is no other information recorded for forward references. .Ss Encoding of Pointers, Typedefs, Volatile, Const, and Restrict Pointers, typedefs, volatile, const, and restrict are all similar in .Nm . -They all refer to another type. In the case of typedefs, they provide an -alternate name, while volatile, const, and restrict change how the type is -interpreted in the C programming language. This covers the +They all refer to another type. +In the case of typedefs, they provide an alternate name, while volatile, const, +and restrict change how the type is interpreted in the C programming language. +This covers the .Nm kinds .Sy CTF_K_POINTER , @@ -1066,43 +1142,49 @@ to refer to the base type that they modify. .Ss Encoding of Unknown Types Types with the kind .Sy CTF_K_UNKNOWN -are used to indicate gaps in the type identifier space. These entries consume an -identifier, but do not define anything. Nothing should refer to these gap -identifiers. +are used to indicate gaps in the type identifier space. +These entries consume an identifier, but do not define anything. +Nothing should refer to these gap identifiers. .Ss Dependencies Between Types -C types can be imagined as a directed, cyclic, graph. Structures and unions may -refer to each other in a way that creates a cyclic dependency. In cases such as -these, the entire type section must be read in and processed. Consumers must -not assume that every type can be laid out in dependency order; they -cannot. +C types can be imagined as a directed, cyclic, graph. +Structures and unions may refer to each other in a way that creates a cyclic +dependency. +In cases such as these, the entire type section must be read in and processed. +Consumers must not assume that every type can be laid out in dependency order; +they cannot. .Ss The String Section The last section of the .Nm file is the .Sy string -section. This section encodes all of the strings that appear throughout -the other sections. It is laid out as a series of characters followed by -a null terminator. Generally, all names are written out in ASCII, as -most C compilers do not allow and characters to appear in identifiers -outside of a subset of ASCII. However, any extended characters sets -should be written out as a series of UTF-8 bytes. +section. +This section encodes all of the strings that appear throughout the other +sections. +It is laid out as a series of characters followed by a null terminator. +Generally, all names are written out in ASCII, as most C compilers do not allow +any characters to appear in identifiers outside of a subset of ASCII. +However, any extended characters sets should be written out as a series of UTF-8 +bytes. .Lp The first entry in the section, at offset zero, is a single null -terminator to reference the empty string. Following that, each C string -should be written out, including the null terminator. Offsets that refer -to something in this section should refer to the first byte which begins -a string. Beyond the first byte in the section being the null -terminator, the order of strings is unimportant. +terminator to reference the empty string. +Following that, each C string should be written out, including the null +terminator. +Offsets that refer to something in this section should refer to the first byte +which begins a string. +Beyond the first byte in the section being the null terminator, the order of +strings is unimportant. .Ss Data Encoding and ELF Considerations .Nm data is generally included in ELF objects which specify information to -identify the architecture and endianness of the file. A +identify the architecture and endianness of the file. +A .Nm -container inside such an object must match the endianness of the ELF -object. Aside from the question of the endian encoding of data, there -should be no other differences between architectures. While many of the -types in this document refer to non-fixed size C integral types, they -are equivalent in the models +container inside such an object must match the endianness of the ELF object. +Aside from the question of the endian encoding of data, there should be no other +differences between architectures. +While many of the types in this document refer to non-fixed size C integral +types, they are equivalent in the models .Sy ILP32 and .Sy LP64 . @@ -1118,15 +1200,16 @@ When placing a container inside of an ELF object, there are certain conventions that are expected for the purposes of tooling being able to find the .Nm -data. In particular, a given ELF object should only contain a single +data. +In particular, a given ELF object should only contain a single .Nm -section. Multiple containers should be merged together into a single -one. +section. +Multiple containers should be merged together into a single one. .Lp The .Nm -file should be included in its own ELF section. The section's name -must be +file should be included in its own ELF section. +The section's name must be .Ql .SUNW_ctf . The type of the section must be .Sy SHT_PROGBITS . @@ -1137,4 +1220,5 @@ alignment must be 4. .Xr elf 3 , .Xr gelf 3 , .Xr a.out 5 , -.Xr elf 5 +.Xr elf 5 , +.Xr arch 7 diff --git cddl/contrib/opensolaris/lib/libdtrace/common/dt_dis.c cddl/contrib/opensolaris/lib/libdtrace/common/dt_dis.c index 0c41bda0aac9..d1335180ec97 100644 --- cddl/contrib/opensolaris/lib/libdtrace/common/dt_dis.c +++ cddl/contrib/opensolaris/lib/libdtrace/common/dt_dis.c @@ -434,7 +434,7 @@ dt_dis(const dtrace_difo_t *dp, FILE *fp) ulong_t i = 0; char type[DT_TYPE_NAMELEN]; - (void) fprintf(fp, "\nDIFO 0x%p returns %s\n", (void *)dp, + (void) fprintf(fp, "\nDIFO %p returns %s\n", (void *)dp, dt_dis_typestr(&dp->dtdo_rtype, type, sizeof (type))); (void) fprintf(fp, "%-3s %-8s %s\n", diff --git cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c index bfd5ec15cc9e..e5d30f0e037d 100644 --- cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c +++ cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c @@ -229,10 +229,12 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf32_t *dep) for (j = 0; j < nrel; j++) { #if defined(__aarch64__) /* XXX */ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); + printf("%s:%s(%d): aarch64 not implemented\n", + __FUNCTION__, __FILE__, __LINE__); #elif defined(__arm__) /* XXX */ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); + printf("%s:%s(%d): arm not implemented\n", + __FUNCTION__, __FILE__, __LINE__); #elif defined(__i386) || defined(__amd64) rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; @@ -240,7 +242,8 @@ printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); R_386_PC32); #elif defined(__mips__) /* XXX */ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); + printf("%s:%s(%d): MIPS not implemented\n", + __FUNCTION__, __FILE__, __LINE__); #elif defined(__powerpc__) /* * Add 4 bytes to hit the low half of this 64-bit @@ -252,7 +255,8 @@ printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); R_PPC_REL32); #elif defined(__riscv) /* XXX */ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); + printf("%s:%s(%d): RISC-V not implemented\n", + __FUNCTION__, __FILE__, __LINE__); #else #error unknown ISA #endif @@ -802,7 +806,8 @@ static int dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, uint32_t *off) { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); + printf("%s:%s(%d): aarch64 not implemented\n", __FUNCTION__, __FILE__, + __LINE__); return (0); } #elif defined(__arm__) @@ -811,7 +816,8 @@ static int dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, uint32_t *off) { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); + printf("%s:%s(%d): arm not implemented\n", __FUNCTION__, __FILE__, + __LINE__); return (0); } #elif defined(__mips__) @@ -820,7 +826,8 @@ static int dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, uint32_t *off) { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); + printf("%s:%s(%d): MIPS not implemented\n", __FUNCTION__, __FILE__, + __LINE__); return (0); } #elif defined(__powerpc__) @@ -910,7 +917,8 @@ static int dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, uint32_t *off) { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); + printf("%s:%s(%d): RISC-V implementation required\n", __FUNCTION__, + __FILE__, __LINE__); return (0); } #elif defined(__sparc) diff --git cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c index 3a8061ed94d0..c28ac38797ab 100644 --- cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c +++ cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c @@ -963,7 +963,7 @@ dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *dfp) (void) snprintf(path, sizeof (path), "/dev/dtrace/%s", p1); - if ((fd = open(path, O_RDONLY)) == -1) + if ((fd = open(path, O_RDONLY | O_CLOEXEC)) == -1) continue; /* failed to open driver; just skip it */ if (((prov = malloc(sizeof (dt_provmod_t))) == NULL) || @@ -1100,7 +1100,7 @@ dt_vopen(int version, int flags, int *errp, */ dt_provmod_open(&provmod, &df); - dtfd = open("/dev/dtrace/dtrace", O_RDWR); + dtfd = open("/dev/dtrace/dtrace", O_RDWR | O_CLOEXEC); err = errno; /* save errno from opening dtfd */ #if defined(__FreeBSD__) /* @@ -1109,14 +1109,14 @@ dt_vopen(int version, int flags, int *errp, */ if (err == ENOENT && modfind("dtraceall") < 0) { kldload("dtraceall"); /* ignore the error */ - dtfd = open("/dev/dtrace/dtrace", O_RDWR); + dtfd = open("/dev/dtrace/dtrace", O_RDWR | O_CLOEXEC); err = errno; } #endif #ifdef illumos ftfd = open("/dev/dtrace/provider/fasttrap", O_RDWR); #else - ftfd = open("/dev/dtrace/fasttrap", O_RDWR); + ftfd = open("/dev/dtrace/fasttrap", O_RDWR | O_CLOEXEC); #endif fterr = ftfd == -1 ? errno : 0; /* save errno from open ftfd */ @@ -1146,9 +1146,6 @@ dt_vopen(int version, int flags, int *errp, return (set_open_errno(dtp, errp, err)); } - (void) fcntl(dtfd, F_SETFD, FD_CLOEXEC); - (void) fcntl(ftfd, F_SETFD, FD_CLOEXEC); - alloc: if ((dtp = malloc(sizeof (dtrace_hdl_t))) == NULL) { dt_provmod_destroy(&provmod); diff --git cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c index 4be0f03d4a43..0a3a10a76954 100644 --- cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c +++ cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c @@ -377,7 +377,7 @@ dt_print_array(ctf_id_t base, ulong_t off, dt_printarg_t *pap) ctf_id_t rtype; if (ctf_array_info(ctfp, base, &car) == CTF_ERR) { - (void) fprintf(fp, "0x%p", (void *)addr); + (void) fprintf(fp, "%p", (void *)addr); return; } diff --git cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c index 79c187140de9..9215b438a40f 100644 --- cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c +++ cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c @@ -426,7 +426,8 @@ dt_proc_attach(dt_proc_t *dpr, int exec) static void dt_proc_waitrun(dt_proc_t *dpr) { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); + printf("%s:%s(%d): not implemented\n", __FUNCTION__, __FILE__, + __LINE__); #ifdef DOODAD struct ps_prochandle *P = dpr->dpr_proc; const lwpstatus_t *psp = &Pstatus(P)->pr_lwp; diff --git cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h index 937e9b2c8592..9133238cb848 100644 --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h @@ -28,6 +28,7 @@ * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2016 Nexenta Systems, Inc. + * Copyright (c) 2017 Datto Inc. */ #ifndef _LIBZFS_H @@ -129,6 +130,7 @@ typedef enum zfs_error { EZFS_DIFF, /* general failure of zfs diff */ EZFS_DIFFDATA, /* bad zfs diff data */ EZFS_POOLREADONLY, /* pool is in read-only mode */ + EZFS_SCRUB_PAUSED, /* scrub currently paused */ EZFS_UNKNOWN } zfs_error_t; @@ -241,7 +243,7 @@ typedef struct splitflags { /* * Functions to manipulate pool and vdev state */ -extern int zpool_scan(zpool_handle_t *, pool_scan_func_t); +extern int zpool_scan(zpool_handle_t *, pool_scan_func_t, pool_scrub_cmd_t); extern int zpool_clear(zpool_handle_t *, const char *, nvlist_t *); extern int zpool_reguid(zpool_handle_t *); extern int zpool_reopen(zpool_handle_t *); @@ -772,6 +774,7 @@ extern int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **, * Label manipulation. */ extern int zpool_read_label(int, nvlist_t **); +extern int zpool_read_all_labels(int, nvlist_t **); extern int zpool_clear_label(int); /* is this zvol valid for use as a dump device? */ diff --git cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c index de78b5479240..d77667d19877 100644 --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c @@ -22,7 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. - * Copyright (c) 2011, 2015 by Delphix. All rights reserved. + * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved. * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved. * Copyright (c) 2013 Martin Matuska. All rights reserved. @@ -2166,6 +2166,7 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src, if (zfs_prop_readonly(prop) && *source != NULL && (*source)[0] == '\0') { *source = NULL; + return (-1); } break; @@ -2354,6 +2355,74 @@ zfs_get_clones_nvl(zfs_handle_t *zhp) return (value); } +/* + * Accepts a property and value and checks that the value + * matches the one found by the channel program. If they are + * not equal, print both of them. + */ +void +zcp_check(zfs_handle_t *zhp, zfs_prop_t prop, uint64_t intval, + const char *strval) +{ + if (!zhp->zfs_hdl->libzfs_prop_debug) + return; + int error; + char *poolname = zhp->zpool_hdl->zpool_name; + const char *program = + "args = ...\n" + "ds = args['dataset']\n" + "prop = args['property']\n" + "value, setpoint = zfs.get_prop(ds, prop)\n" + "return {value=value, setpoint=setpoint}\n"; + nvlist_t *outnvl; + nvlist_t *retnvl; + nvlist_t *argnvl = fnvlist_alloc(); + + fnvlist_add_string(argnvl, "dataset", zhp->zfs_name); + fnvlist_add_string(argnvl, "property", zfs_prop_to_name(prop)); + + error = lzc_channel_program(poolname, program, + 10 * 1000 * 1000, 10 * 1024 * 1024, argnvl, &outnvl); + + if (error == 0) { + retnvl = fnvlist_lookup_nvlist(outnvl, "return"); + if (zfs_prop_get_type(prop) == PROP_TYPE_NUMBER) { + int64_t ans; + error = nvlist_lookup_int64(retnvl, "value", &ans); + if (error != 0) { + (void) fprintf(stderr, "zcp check error: %u\n", + error); + return; + } + if (ans != intval) { + (void) fprintf(stderr, + "%s: zfs found %lld, but zcp found %lld\n", + zfs_prop_to_name(prop), + (longlong_t)intval, (longlong_t)ans); + } + } else { + char *str_ans; + error = nvlist_lookup_string(retnvl, "value", &str_ans); + if (error != 0) { + (void) fprintf(stderr, "zcp check error: %u\n", + error); + return; + } + if (strcmp(strval, str_ans) != 0) { + (void) fprintf(stderr, + "%s: zfs found %s, but zcp found %s\n", + zfs_prop_to_name(prop), + strval, str_ans); + } + } + } else { + (void) fprintf(stderr, + "zcp check failed, channel program error: %u\n", error); + } + nvlist_free(argnvl); + nvlist_free(outnvl); +} + /* * Retrieve a property from the given object. If 'literal' is specified, then * numbers are left as exact values. Otherwise, numbers are converted to a @@ -2400,6 +2469,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, &t) == 0) (void) snprintf(propbuf, proplen, "%llu", val); } + zcp_check(zhp, prop, val, NULL); break; case ZFS_PROP_MOUNTPOINT: @@ -2468,7 +2538,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, /* 'legacy' or 'none' */ (void) strlcpy(propbuf, str, proplen); } - + zcp_check(zhp, prop, NULL, propbuf); break; case ZFS_PROP_ORIGIN: @@ -2476,6 +2546,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, if (str == NULL) return (-1); (void) strlcpy(propbuf, str, proplen); + zcp_check(zhp, prop, NULL, str); break; case ZFS_PROP_CLONES: @@ -2490,7 +2561,6 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, if (get_numeric_property(zhp, prop, src, &source, &val) != 0) return (-1); - /* * If quota or reservation is 0, we translate this into 'none' * (unless literal is set), and indicate that it's the default @@ -2509,6 +2579,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, else zfs_nicenum(val, propbuf, proplen); } + zcp_check(zhp, prop, val, NULL); break; case ZFS_PROP_FILESYSTEM_LIMIT: @@ -2533,6 +2604,8 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, } else { zfs_nicenum(val, propbuf, proplen); } + + zcp_check(zhp, prop, val, NULL); break; case ZFS_PROP_REFRATIO: @@ -2542,6 +2615,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, (void) snprintf(propbuf, proplen, "%llu.%02llux", (u_longlong_t)(val / 100), (u_longlong_t)(val % 100)); + zcp_check(zhp, prop, val, NULL); break; case ZFS_PROP_TYPE: @@ -2562,6 +2636,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, abort(); } (void) snprintf(propbuf, proplen, "%s", str); + zcp_check(zhp, prop, NULL, propbuf); break; case ZFS_PROP_MOUNTED: @@ -2587,6 +2662,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, * consumers. */ (void) strlcpy(propbuf, zhp->zfs_name, proplen); + zcp_check(zhp, prop, NULL, propbuf); break; case ZFS_PROP_MLSLABEL: @@ -2640,26 +2716,33 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, if (get_numeric_property(zhp, prop, src, &source, &val) != 0) return (-1); (void) snprintf(propbuf, proplen, "%llu", (u_longlong_t)val); + zcp_check(zhp, prop, val, NULL); break; default: switch (zfs_prop_get_type(prop)) { case PROP_TYPE_NUMBER: if (get_numeric_property(zhp, prop, src, - &source, &val) != 0) + &source, &val) != 0) { return (-1); - if (literal) + } + + if (literal) { (void) snprintf(propbuf, proplen, "%llu", (u_longlong_t)val); - else + } else { zfs_nicenum(val, propbuf, proplen); + } + zcp_check(zhp, prop, val, NULL); break; case PROP_TYPE_STRING: str = getprop_string(zhp, prop, &source); if (str == NULL) return (-1); + (void) strlcpy(propbuf, str, proplen); + zcp_check(zhp, prop, NULL, str); break; case PROP_TYPE_INDEX: @@ -2668,7 +2751,9 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen, return (-1); if (zfs_prop_index_to_string(prop, val, &strval) != 0) return (-1); + (void) strlcpy(propbuf, strval, proplen); + zcp_check(zhp, prop, NULL, strval); break; default: diff --git cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c index 1447b4cb7a11..840c814ff4c0 100644 --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c @@ -55,15 +55,6 @@ #define ZDIFF_REMOVED '-' #define ZDIFF_RENAMED 'R' -static boolean_t -do_name_cmp(const char *fpath, const char *tpath) -{ - char *fname, *tname; - fname = strrchr(fpath, '/') + 1; - tname = strrchr(tpath, '/') + 1; - return (strcmp(fname, tname) == 0); -} - typedef struct differ_info { zfs_handle_t *zhp; char *fromsnap; @@ -262,7 +253,6 @@ static int write_inuse_diffs_one(FILE *fp, differ_info_t *di, uint64_t dobj) { struct zfs_stat fsb, tsb; - boolean_t same_name; mode_t fmode, tmode; char fobjname[MAXPATHLEN], tobjname[MAXPATHLEN]; int fobjerr, tobjerr; @@ -323,7 +313,6 @@ write_inuse_diffs_one(FILE *fp, differ_info_t *di, uint64_t dobj) if (fmode != tmode && fsb.zs_gen == tsb.zs_gen) tsb.zs_gen++; /* Force a generational difference */ - same_name = do_name_cmp(fobjname, tobjname); /* Simple modification or no change */ if (fsb.zs_gen == tsb.zs_gen) { @@ -334,7 +323,7 @@ write_inuse_diffs_one(FILE *fp, differ_info_t *di, uint64_t dobj) if (change) { print_link_change(fp, di, change, change > 0 ? fobjname : tobjname, &tsb); - } else if (same_name) { + } else if (strcmp(fobjname, tobjname) == 0) { print_file(fp, di, ZDIFF_MODIFIED, fobjname, &tsb); } else { print_rename(fp, di, fobjname, tobjname, &tsb); diff --git cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h index ded3d88237b0..c934cff70506 100644 --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h @@ -79,6 +79,7 @@ struct libzfs_handle { libzfs_fru_t **libzfs_fru_hash; libzfs_fru_t *libzfs_fru_list; char libzfs_chassis_id[256]; + boolean_t libzfs_prop_debug; }; #define ZFSSHARE_MISS 0x01 /* Didn't find entry in cache */ diff --git cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c index 3f6e64370b8e..a8da5b4dc77a 100644 --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c @@ -42,6 +42,7 @@ * using our derived config, and record the results. */ +#include <aio.h> #include <ctype.h> #include <devid.h> #include <dirent.h> @@ -865,6 +866,7 @@ label_offset(uint64_t size, int l) /* * Given a file descriptor, read the label information and return an nvlist * describing the configuration, if there is one. + * Return 0 on success, or -1 on failure */ int zpool_read_label(int fd, nvlist_t **config) @@ -877,7 +879,7 @@ zpool_read_label(int fd, nvlist_t **config) *config = NULL; if (fstat64(fd, &statbuf) == -1) - return (0); + return (-1); size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t); if ((label = malloc(sizeof (vdev_label_t))) == NULL) @@ -911,7 +913,91 @@ zpool_read_label(int fd, nvlist_t **config) free(label); *config = NULL; - return (0); + return (-1); +} + +/* + * Given a file descriptor, read the label information and return an nvlist + * describing the configuration, if there is one. + * returns the number of valid labels found + * If a label is found, returns it via config. The caller is responsible for + * freeing it. + */ +int +zpool_read_all_labels(int fd, nvlist_t **config) +{ + struct stat64 statbuf; + struct aiocb aiocbs[VDEV_LABELS]; + struct aiocb *aiocbps[VDEV_LABELS]; + int l; + vdev_phys_t *labels; + uint64_t state, txg, size; + int nlabels = 0; + + *config = NULL; + + if (fstat64(fd, &statbuf) == -1) + return (0); + size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t); + + if ((labels = calloc(VDEV_LABELS, sizeof (vdev_phys_t))) == NULL) + return (0); + + memset(aiocbs, 0, sizeof(aiocbs)); + for (l = 0; l < VDEV_LABELS; l++) { + aiocbs[l].aio_fildes = fd; + aiocbs[l].aio_offset = label_offset(size, l) + VDEV_SKIP_SIZE; + aiocbs[l].aio_buf = &labels[l]; + aiocbs[l].aio_nbytes = sizeof(vdev_phys_t); + aiocbs[l].aio_lio_opcode = LIO_READ; + aiocbps[l] = &aiocbs[l]; + } + + if (lio_listio(LIO_WAIT, aiocbps, VDEV_LABELS, NULL) != 0) { + if (errno == EAGAIN || errno == EINTR || errno == EIO) { + for (l = 0; l < VDEV_LABELS; l++) { + errno = 0; + int r = aio_error(&aiocbs[l]); + if (r != EINVAL) + (void)aio_return(&aiocbs[l]); + } + } + free(labels); + return (0); + } + + for (l = 0; l < VDEV_LABELS; l++) { + nvlist_t *temp = NULL; + + if (aio_return(&aiocbs[l]) != sizeof(vdev_phys_t)) + continue; + + if (nvlist_unpack(labels[l].vp_nvlist, + sizeof (labels[l].vp_nvlist), &temp, 0) != 0) + continue; + + if (nvlist_lookup_uint64(temp, ZPOOL_CONFIG_POOL_STATE, + &state) != 0 || state > POOL_STATE_L2CACHE) { + nvlist_free(temp); + temp = NULL; + continue; + } + + if (state != POOL_STATE_SPARE && state != POOL_STATE_L2CACHE && + (nvlist_lookup_uint64(temp, ZPOOL_CONFIG_POOL_TXG, + &txg) != 0 || txg == 0)) { + nvlist_free(temp); + temp = NULL; + continue; + } + if (temp) + *config = temp; + + nlabels++; + } + + free(labels); + return (nlabels); } typedef struct rdsk_node { @@ -1089,7 +1175,7 @@ zpool_open_func(void *arg) } #endif /* illumos */ - if ((zpool_read_label(fd, &config)) != 0) { + if ((zpool_read_label(fd, &config)) != 0 && errno == ENOMEM) { (void) close(fd); (void) no_memory(rn->rn_hdl); return; @@ -1590,7 +1676,7 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr, *inuse = B_FALSE; - if (zpool_read_label(fd, &config) != 0) { + if (zpool_read_label(fd, &config) != 0 && errno == ENOMEM) { (void) no_memory(hdl); return (-1); } diff --git cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c index 60c6266adbad..2bf494f9415f 100644 --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c @@ -20,9 +20,11 @@ */ /* + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014 by Delphix. All rights reserved. * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com> + * Copyright 2017 RackTop Systems. */ /* @@ -87,7 +89,7 @@ zfs_share_type_t zfs_is_shared_proto(zfs_handle_t *, char **, zfs_share_proto_t); /* - * The share protocols table must be in the same order as the zfs_share_prot_t + * The share protocols table must be in the same order as the zfs_share_proto_t * enum in libzfs_impl.h */ typedef struct { @@ -872,7 +874,7 @@ unshare_one(libzfs_handle_t *hdl, const char *name, const char *mountpoint, /* make sure libshare initialized */ if ((err = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) { free(mntpt); /* don't need the copy anymore */ - return (zfs_error_fmt(hdl, EZFS_SHARENFSFAILED, + return (zfs_error_fmt(hdl, proto_table[proto].p_unshare_err, dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"), name, _sa_errorstr(err))); } @@ -883,12 +885,13 @@ unshare_one(libzfs_handle_t *hdl, const char *name, const char *mountpoint, if (share != NULL) { err = zfs_sa_disable_share(share, proto_table[proto].p_name); if (err != SA_OK) { - return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED, + return (zfs_error_fmt(hdl, + proto_table[proto].p_unshare_err, dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"), name, _sa_errorstr(err))); } } else { - return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED, + return (zfs_error_fmt(hdl, proto_table[proto].p_unshare_err, dgettext(TEXT_DOMAIN, "cannot unshare '%s': not found"), name)); } diff --git cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c index af1767fac3f5..76f06e54a98b 100644 --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c @@ -25,6 +25,7 @@ * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright 2016 Nexenta Systems, Inc. * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com> + * Copyright (c) 2017 Datto Inc. */ #include <sys/types.h> @@ -1841,22 +1842,39 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, * Scan the pool. */ int -zpool_scan(zpool_handle_t *zhp, pool_scan_func_t func) +zpool_scan(zpool_handle_t *zhp, pool_scan_func_t func, pool_scrub_cmd_t cmd) { zfs_cmd_t zc = { 0 }; char msg[1024]; + int err; libzfs_handle_t *hdl = zhp->zpool_hdl; (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); zc.zc_cookie = func; + zc.zc_flags = cmd; + + if (zfs_ioctl(hdl, ZFS_IOC_POOL_SCAN, &zc) == 0) + return (0); + + err = errno; - if (zfs_ioctl(hdl, ZFS_IOC_POOL_SCAN, &zc) == 0 || - (errno == ENOENT && func != POOL_SCAN_NONE)) + /* ECANCELED on a scrub means we resumed a paused scrub */ + if (err == ECANCELED && func == POOL_SCAN_SCRUB && + cmd == POOL_SCRUB_NORMAL) + return (0); + + if (err == ENOENT && func != POOL_SCAN_NONE && cmd == POOL_SCRUB_NORMAL) return (0); if (func == POOL_SCAN_SCRUB) { - (void) snprintf(msg, sizeof (msg), - dgettext(TEXT_DOMAIN, "cannot scrub %s"), zc.zc_name); + if (cmd == POOL_SCRUB_PAUSE) { + (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, + "cannot pause scrubbing %s"), zc.zc_name); + } else { + assert(cmd == POOL_SCRUB_NORMAL); + (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, + "cannot scrub %s"), zc.zc_name); + } } else if (func == POOL_SCAN_NONE) { (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, "cannot cancel scrubbing %s"), @@ -1865,7 +1883,7 @@ zpool_scan(zpool_handle_t *zhp, pool_scan_func_t func) assert(!"unexpected result"); } - if (errno == EBUSY) { + if (err == EBUSY) { nvlist_t *nvroot; pool_scan_stat_t *ps = NULL; uint_t psc; @@ -1874,14 +1892,18 @@ zpool_scan(zpool_handle_t *zhp, pool_scan_func_t func) ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); (void) nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_SCAN_STATS, (uint64_t **)&ps, &psc); - if (ps && ps->pss_func == POOL_SCAN_SCRUB) - return (zfs_error(hdl, EZFS_SCRUBBING, msg)); - else + if (ps && ps->pss_func == POOL_SCAN_SCRUB) { + if (cmd == POOL_SCRUB_PAUSE) + return (zfs_error(hdl, EZFS_SCRUB_PAUSED, msg)); + else + return (zfs_error(hdl, EZFS_SCRUBBING, msg)); + } else { return (zfs_error(hdl, EZFS_RESILVERING, msg)); - } else if (errno == ENOENT) { + } + } else if (err == ENOENT) { return (zfs_error(hdl, EZFS_NO_SCRUB, msg)); } else { - return (zpool_standard_error(hdl, errno, msg)); + return (zpool_standard_error(hdl, err, msg)); } } @@ -2273,6 +2295,7 @@ vdev_get_physpaths(nvlist_t *nv, char *physpath, size_t phypath_size, return (ret); } } else if (strcmp(type, VDEV_TYPE_MIRROR) == 0 || + strcmp(type, VDEV_TYPE_RAIDZ) == 0 || strcmp(type, VDEV_TYPE_REPLACING) == 0 || (is_spare = (strcmp(type, VDEV_TYPE_SPARE) == 0))) { nvlist_t **child; diff --git cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c index 3e24741b9832..85f6098d82ff 100644 --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c @@ -3212,7 +3212,12 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, /* * Determine the name of the origin snapshot, store in zc_string. */ - if (drrb->drr_flags & DRR_FLAG_CLONE) { + if (originsnap) { + (void) strncpy(zc.zc_string, originsnap, sizeof (zc.zc_string)); + if (flags->verbose) + (void) printf("using provided clone origin %s\n", + zc.zc_string); + } else if (drrb->drr_flags & DRR_FLAG_CLONE) { if (guid_to_name(hdl, zc.zc_value, drrb->drr_fromguid, B_FALSE, zc.zc_string) != 0) { zcmd_free_nvlists(&zc); @@ -3223,11 +3228,6 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, } if (flags->verbose) (void) printf("found clone origin %s\n", zc.zc_string); - } else if (originsnap) { - (void) strncpy(zc.zc_string, originsnap, sizeof (zc.zc_string)); - if (flags->verbose) - (void) printf("using provided clone origin %s\n", - zc.zc_string); } boolean_t resuming = DMU_GET_FEATUREFLAGS(drrb->drr_versioninfo) & diff --git cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c index 0a638016e7a2..b34c9837d7f0 100644 --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c @@ -24,6 +24,7 @@ * Copyright (c) 2013, Joyent, Inc. All rights reserved. * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com> + * Copyright (c) 2017 Datto Inc. */ /* @@ -48,6 +49,7 @@ #include <sys/mnttab.h> #include <sys/mntent.h> #include <sys/types.h> +#include <libcmdutils.h> #include <libzfs.h> #include <libzfs_core.h> @@ -224,6 +226,9 @@ libzfs_error_description(libzfs_handle_t *hdl) case EZFS_POSTSPLIT_ONLINE: return (dgettext(TEXT_DOMAIN, "disk was split from this pool " "into a new one")); + case EZFS_SCRUB_PAUSED: + return (dgettext(TEXT_DOMAIN, "scrub is paused; " + "use 'zpool scrub' to resume")); case EZFS_SCRUBBING: return (dgettext(TEXT_DOMAIN, "currently scrubbing; " "use 'zpool scrub -s' to cancel current scrub")); @@ -575,42 +580,7 @@ zfs_strdup(libzfs_handle_t *hdl, const char *str) void zfs_nicenum(uint64_t num, char *buf, size_t buflen) { - uint64_t n = num; - int index = 0; - char u; - - while (n >= 1024) { - n /= 1024; - index++; - } - - u = " KMGTPE"[index]; - - if (index == 0) { - (void) snprintf(buf, buflen, "%llu", n); - } else if ((num & ((1ULL << 10 * index) - 1)) == 0) { - /* - * If this is an even multiple of the base, always display - * without any decimal precision. - */ - (void) snprintf(buf, buflen, "%llu%c", n, u); - } else { - /* - * We want to choose a precision that reflects the best choice - * for fitting in 5 characters. This can get rather tricky when - * we have numbers that are very close to an order of magnitude. - * For example, when displaying 10239 (which is really 9.999K), - * we want only a single place of precision for 10.0K. We could - * develop some complex heuristics for this, but it's much - * easier just to try each combination in turn. - */ - int i; - for (i = 2; i >= 0; i--) { - if (snprintf(buf, buflen, "%.*f%c", i, - (double)num / (1ULL << 10 * index), u) <= 5) - break; - } - } + nicenum(num, buf, buflen); } void @@ -681,6 +651,10 @@ libzfs_init(void) zpool_feature_init(); libzfs_mnttab_init(hdl); + if (getenv("ZFS_PROP_DEBUG") != NULL) { + hdl->libzfs_prop_debug = B_TRUE; + } + return (hdl); } diff --git cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c index c38c8c64ee1d..ec32486e8c8f 100644 --- cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c +++ cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c @@ -20,7 +20,7 @@ */ /* - * Copyright (c) 2012, 2014 by Delphix. All rights reserved. + * Copyright (c) 2012, 2017 by Delphix. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2017 RackTop Systems. @@ -160,7 +160,12 @@ lzc_ioctl(zfs_ioc_t ioc, const char *name, if (resultp != NULL) { *resultp = NULL; - zc.zc_nvlist_dst_size = MAX(size * 2, 128 * 1024); + if (ioc == ZFS_IOC_CHANNEL_PROGRAM) { + zc.zc_nvlist_dst_size = fnvlist_lookup_uint64(source, + ZCP_ARG_MEMLIMIT); + } else { + zc.zc_nvlist_dst_size = MAX(size * 2, 128 * 1024); + } zc.zc_nvlist_dst = (uint64_t)(uintptr_t) malloc(zc.zc_nvlist_dst_size); #ifdef illumos @@ -174,7 +179,15 @@ lzc_ioctl(zfs_ioc_t ioc, const char *name, } while (ioctl(g_fd, ioc, &zc) != 0) { - if (errno == ENOMEM && resultp != NULL) { + /* + * If ioctl exited with ENOMEM, we retry the ioctl after + * increasing the size of the destination nvlist. + * + * Channel programs that exit with ENOMEM ran over the + * lua memory sandbox; they should not be retried. + */ + if (errno == ENOMEM && resultp != NULL && + ioc != ZFS_IOC_CHANNEL_PROGRAM) { free((void *)(uintptr_t)zc.zc_nvlist_dst); zc.zc_nvlist_dst_size *= 2; zc.zc_nvlist_dst = (uint64_t)(uintptr_t) @@ -904,3 +917,54 @@ lzc_destroy_bookmarks(nvlist_t *bmarks, nvlist_t **errlist) return (error); } + +/* + * Executes a channel program. + * + * If this function returns 0 the channel program was successfully loaded and + * ran without failing. Note that individual commands the channel program ran + * may have failed and the channel program is responsible for reporting such + * errors through outnvl if they are important. + * + * This method may also return: + * + * EINVAL The program contains syntax errors, or an invalid memory or time + * limit was given. No part of the channel program was executed. + * If caused by syntax errors, 'outnvl' contains information about the + * errors. + * + * EDOM The program was executed, but encountered a runtime error, such as + * calling a function with incorrect arguments, invoking the error() + * function directly, failing an assert() command, etc. Some portion + * of the channel program may have executed and committed changes. + * Information about the failure can be found in 'outnvl'. + * + * ENOMEM The program fully executed, but the output buffer was not large + * enough to store the returned value. No output is returned through + * 'outnvl'. + * + * ENOSPC The program was terminated because it exceeded its memory usage + * limit. Some portion of the channel program may have executed and + * committed changes to disk. No output is returned through 'outnvl'. + * + * ETIMEDOUT The program was terminated because it exceeded its Lua instruction + * limit. Some portion of the channel program may have executed and + * committed changes to disk. No output is returned through 'outnvl'. + */ +int +lzc_channel_program(const char *pool, const char *program, uint64_t instrlimit, + uint64_t memlimit, nvlist_t *argnvl, nvlist_t **outnvl) +{ + int error; + nvlist_t *args; + + args = fnvlist_alloc(); + fnvlist_add_string(args, ZCP_ARG_PROGRAM, program); + fnvlist_add_nvlist(args, ZCP_ARG_ARGLIST, argnvl); + fnvlist_add_uint64(args, ZCP_ARG_INSTRLIMIT, instrlimit); + fnvlist_add_uint64(args, ZCP_ARG_MEMLIMIT, memlimit); + error = lzc_ioctl(ZFS_IOC_CHANNEL_PROGRAM, pool, args, outnvl); + fnvlist_free(args); + + return (error); +} diff --git cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h index ea0e752e3524..234dda4a194c 100644 --- cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h +++ cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h @@ -20,7 +20,7 @@ */ /* - * Copyright (c) 2012, 2014 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2013 by Martin Matuska <mm@FreeBSD.org>. All rights reserved. * Copyright 2017 RackTop Systems. */ @@ -86,6 +86,9 @@ boolean_t lzc_exists(const char *); int lzc_rollback(const char *, char *, int); int lzc_rollback_to(const char *, const char *); +int lzc_channel_program(const char *, const char *, uint64_t, uint64_t, + nvlist_t *, nvlist_t **); + #ifdef __cplusplus } #endif diff --git cddl/contrib/opensolaris/lib/libzpool/common/kernel.c cddl/contrib/opensolaris/lib/libzpool/common/kernel.c index 701f0b43bf84..1d43c8d7253c 100644 --- cddl/contrib/opensolaris/lib/libzpool/common/kernel.c +++ cddl/contrib/opensolaris/lib/libzpool/common/kernel.c @@ -735,11 +735,10 @@ static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" }; void vpanic(const char *fmt, va_list adx) { - (void) fprintf(stderr, "error: "); - (void) vfprintf(stderr, fmt, adx); - (void) fprintf(stderr, "\n"); - - abort(); /* think of it as a "user-level crash dump" */ + char buf[512]; + (void) vsnprintf(buf, 512, fmt, adx); + assfail(buf, NULL, 0); + abort(); /* necessary to make vpanic meet noreturn requirements */ } void diff --git cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h index f11174ffa521..019defb04d60 100644 --- cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h +++ cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2012, 2016 by Delphix. All rights reserved. * Copyright (c) 2012, Joyent, Inc. All rights reserved. */ /* @@ -66,6 +66,7 @@ extern "C" { #include <fsshare.h> #include <pthread.h> #include <sched.h> +#include <setjmp.h> #include <sys/debug.h> #include <sys/note.h> #include <sys/types.h> @@ -126,8 +127,8 @@ extern void dprintf_setup(int *argc, char **argv); extern void cmn_err(int, const char *, ...); extern void vcmn_err(int, const char *, __va_list); -extern void panic(const char *, ...); -extern void vpanic(const char *, __va_list); +extern void panic(const char *, ...) __NORETURN; +extern void vpanic(const char *, __va_list) __NORETURN; #define fm_panic panic @@ -349,6 +350,7 @@ extern void cv_broadcast(kcondvar_t *cv); #define KM_SLEEP UMEM_NOFAIL #define KM_PUSHPAGE KM_SLEEP #define KM_NOSLEEP UMEM_DEFAULT +#define KM_NORMALPRI 0 /* not needed with UMEM_DEFAULT */ #define KMC_NODEBUG UMC_NODEBUG #define KMC_NOTOUCH 0 /* not needed for userland caches */ #define KM_NODEBUG 0 @@ -579,8 +581,9 @@ extern void kernel_init(int); extern void kernel_fini(void); struct spa; -extern void nicenum(uint64_t num, char *buf); +extern void nicenum(uint64_t num, char *buf, size_t); extern void show_pool_stats(struct spa *); +extern int set_global_var(char *arg); typedef struct callb_cpr { kmutex_t *cc_lockp; diff --git cddl/contrib/opensolaris/lib/libzpool/common/util.c cddl/contrib/opensolaris/lib/libzpool/common/util.c index 6257e2b3e776..71894c2af290 100644 --- cddl/contrib/opensolaris/lib/libzpool/common/util.c +++ cddl/contrib/opensolaris/lib/libzpool/common/util.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016 by Delphix. All rights reserved. */ #include <assert.h> @@ -31,38 +32,12 @@ #include <sys/spa.h> #include <sys/fs/zfs.h> #include <sys/refcount.h> +#include <dlfcn.h> /* * Routines needed by more than one client of libzpool. */ -void -nicenum(uint64_t num, char *buf) -{ - uint64_t n = num; - int index = 0; - char u; - - while (n >= 1024) { - n = (n + (1024 / 2)) / 1024; /* Round up or down */ - index++; - } - - u = " KMGTPE"[index]; - - if (index == 0) { - (void) sprintf(buf, "%llu", (u_longlong_t)n); - } else if (n < 10 && (num & (num - 1)) != 0) { - (void) sprintf(buf, "%.2f%c", - (double)num / (1ULL << 10 * index), u); - } else if (n < 100 && (num & (num - 1)) != 0) { - (void) sprintf(buf, "%.1f%c", - (double)num / (1ULL << 10 * index), u); - } else { - (void) sprintf(buf, "%llu%c", (u_longlong_t)n, u); - } -} - static void show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent) { @@ -95,15 +70,17 @@ show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent) sec = MAX(1, vs->vs_timestamp / NANOSEC); - nicenum(vs->vs_alloc, used); - nicenum(vs->vs_space - vs->vs_alloc, avail); - nicenum(vs->vs_ops[ZIO_TYPE_READ] / sec, rops); - nicenum(vs->vs_ops[ZIO_TYPE_WRITE] / sec, wops); - nicenum(vs->vs_bytes[ZIO_TYPE_READ] / sec, rbytes); - nicenum(vs->vs_bytes[ZIO_TYPE_WRITE] / sec, wbytes); - nicenum(vs->vs_read_errors, rerr); - nicenum(vs->vs_write_errors, werr); - nicenum(vs->vs_checksum_errors, cerr); + nicenum(vs->vs_alloc, used, sizeof (used)); + nicenum(vs->vs_space - vs->vs_alloc, avail, sizeof (avail)); + nicenum(vs->vs_ops[ZIO_TYPE_READ] / sec, rops, sizeof (rops)); + nicenum(vs->vs_ops[ZIO_TYPE_WRITE] / sec, wops, sizeof (wops)); + nicenum(vs->vs_bytes[ZIO_TYPE_READ] / sec, rbytes, + sizeof (rbytes)); + nicenum(vs->vs_bytes[ZIO_TYPE_WRITE] / sec, wbytes, + sizeof (wbytes)); + nicenum(vs->vs_read_errors, rerr, sizeof (rerr)); + nicenum(vs->vs_write_errors, werr, sizeof (werr)); + nicenum(vs->vs_checksum_errors, cerr, sizeof (cerr)); (void) printf("%*s%s%*s%*s%*s %5s %5s %5s %5s %5s %5s %5s\n", indent, "", @@ -153,3 +130,58 @@ show_pool_stats(spa_t *spa) nvlist_free(config); } + +/* + * Sets given global variable in libzpool to given unsigned 32-bit value. + * arg: "<variable>=<value>" + */ +int +set_global_var(char *arg) +{ + void *zpoolhdl; + char *varname = arg, *varval; + u_longlong_t val; + +#ifndef _LITTLE_ENDIAN + /* + * On big endian systems changing a 64-bit variable would set the high + * 32 bits instead of the low 32 bits, which could cause unexpected + * results. + */ + fprintf(stderr, "Setting global variables is only supported on " + "little-endian systems\n", varname); + return (ENOTSUP); +#endif + if ((varval = strchr(arg, '=')) != NULL) { + *varval = '\0'; + varval++; + val = strtoull(varval, NULL, 0); + if (val > UINT32_MAX) { + fprintf(stderr, "Value for global variable '%s' must " + "be a 32-bit unsigned integer\n", varname); + return (EOVERFLOW); + } + } else { + return (EINVAL); + } + + zpoolhdl = dlopen("libzpool.so", RTLD_LAZY); + if (zpoolhdl != NULL) { + uint32_t *var; + var = dlsym(zpoolhdl, varname); + if (var == NULL) { + fprintf(stderr, "Global variable '%s' does not exist " + "in libzpool.so\n", varname); + return (EINVAL); + } + *var = (uint32_t)val; + + dlclose(zpoolhdl); + } else { + fprintf(stderr, "Failed to open libzpool.so to set global " + "variable\n"); + return (EIO); + } + + return (0); +} diff --git cddl/lib/libavl/Makefile.depend cddl/lib/libavl/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/lib/libavl/Makefile.depend +++ cddl/lib/libavl/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/lib/libctf/Makefile.depend cddl/lib/libctf/Makefile.depend index ff9d79528313..ceebc6a83a34 100644 --- cddl/lib/libctf/Makefile.depend +++ cddl/lib/libctf/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/lib/libdtrace/Makefile cddl/lib/libdtrace/Makefile index d55c0d62a764..c33a8c2dd882 100644 --- cddl/lib/libdtrace/Makefile +++ cddl/lib/libdtrace/Makefile @@ -54,6 +54,7 @@ DSRCS= errno.d \ siftr.d \ signal.d \ tcp.d \ + socket.d \ udp.d \ unistd.d diff --git cddl/lib/libdtrace/Makefile.depend cddl/lib/libdtrace/Makefile.depend index ff38bcc81a9e..68a8d3e9c520 100644 --- cddl/lib/libdtrace/Makefile.depend +++ cddl/lib/libdtrace/Makefile.depend @@ -4,7 +4,6 @@ DIRDEPS = \ cddl/lib/libctf \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git cddl/lib/libdtrace/socket.d cddl/lib/libdtrace/socket.d new file mode 100644 index 000000000000..da8f149b2d10 --- /dev/null +++ cddl/lib/libdtrace/socket.d @@ -0,0 +1,301 @@ +/* + * Copyright (c) 2017 George V. Neville-Neil + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + * + * Translators and flags for the socket structure. FreeBSD specific code. + */ + +#pragma D depends_on module kernel + +/* + * Option flags per-socket. + */ +#pragma D binding "1.13" SO_DEBUG +inline int SO_DEBUG = 0x0001; /* turn on debugging info recording */ +#pragma D binding "1.13" SO_ACCEPTCONN +inline int SO_ACCEPTCONN = 0x0002; /* socket has had listen() */ +#pragma D binding "1.13" SO_REUSEADDR +inline int SO_REUSEADDR = 0x0004; /* allow local address reuse */ +#pragma D binding "1.13" SO_KEEPALIVE +inline int SO_KEEPALIVE = 0x0008; /* keep connections alive */ +#pragma D binding "1.13" SO_DONTROUTE +inline int SO_DONTROUTE = 0x0010; /* just use interface addresses */ +#pragma D binding "1.13" SO_BROADCAST +inline int SO_BROADCAST = 0x0020; /* permit sending of broadcast msgs */ +#pragma D binding "1.13" SO_USELOOPBACK +inline int SO_USELOOPBACK = 0x0040; /* bypass hardware when possible */ +#pragma D binding "1.13" SO_LINGER +inline int SO_LINGER = 0x0080; /* linger on close if data present */ +#pragma D binding "1.13" SO_OOBINLINE +inline int SO_OOBINLINE = 0x0100; /* leave received OOB data in line */ +#pragma D binding "1.13" SO_REUSEPORT +inline int SO_REUSEPORT = 0x0200; /* allow local address & port reuse */ +#pragma D binding "1.13" SO_TIMESTAMP +inline int SO_TIMESTAMP = 0x0400; /* timestamp received dgram traffic */ +#pragma D binding "1.13" SO_NOSIGPIPE +inline int SO_NOSIGPIPE = 0x0800; /* no SIGPIPE from EPIPE */ +#pragma D binding "1.13" SO_ACCEPTFILTER +inline int SO_ACCEPTFILTER = 0x1000; /* there is an accept filter */ +#pragma D binding "1.13" SO_BINTIME +inline int SO_BINTIME = 0x2000; /* timestamp received dgram traffic */ +#pragma D binding "1.13" SO_NO_OFFLOAD +inline int SO_NO_OFFLOAD = 0x4000; /* socket cannot be offloaded */ +#pragma D binding "1.13" SO_NO_DDP +inline int SO_NO_DDP = 0x8000; /* disable direct data placement */ + +/* + * Additional options, not kept in so_options. + */ +#pragma D binding "1.13" SO_SNDBUF +inline int SO_SNDBUF = 0x1001; /* send buffer size */ +#pragma D binding "1.13" SO_RCVBUF +inline int SO_RCVBUF = 0x1002; /* receive buffer size */ +#pragma D binding "1.13" SO_SNDLOWAT +inline int SO_SNDLOWAT = 0x1003; /* send low-water mark */ +#pragma D binding "1.13" SO_RCVLOWAT +inline int SO_RCVLOWAT = 0x1004; /* receive low-water mark */ +#pragma D binding "1.13" SO_SNDTIMEO +inline int SO_SNDTIMEO = 0x1005; /* send timeout */ +#pragma D binding "1.13" SO_RCVTIMEO +inline int SO_RCVTIMEO = 0x1006; /* receive timeout */ +#pragma D binding "1.13" SO_ERROR +inline int SO_ERROR = 0x1007; /* get error status and clear */ +#pragma D binding "1.13" SO_TYPE +inline int SO_TYPE = 0x1008; /* get socket type */ +#pragma D binding "1.13" SO_LABEL +inline int SO_LABEL = 0x1009; /* socket's MAC label */ +#pragma D binding "1.13" SO_PEERLABEL +inline int SO_PEERLABEL = 0x1010; /* socket's peer's MAC label */ +#pragma D binding "1.13" SO_LISTENQLIMIT +inline int SO_LISTENQLIMIT = 0x1011; /* socket's backlog limit */ +#pragma D binding "1.13" SO_LISTENQLEN +inline int SO_LISTENQLEN = 0x1012; /* socket's complete queue length */ +#pragma D binding "1.13" SO_LISTENINCQLEN +inline int SO_LISTENINCQLEN = 0x1013; /* socket's incomplete queue length */ +#pragma D binding "1.13" SO_SETFIB +inline int SO_SETFIB = 0x1014; /* use this FIB to route */ +#pragma D binding "1.13" SO_USER_COOKIE +inline int SO_USER_COOKIE = 0x1015; /* user cookie (dummynet etc.) */ +#pragma D binding "1.13" SO_PROTOCOL +inline int SO_PROTOCOL = 0x1016; /* get socket protocol (Linux name) */ +#pragma D binding "1.13" SO_PROTOTYPE +inline int SO_PROTOTYPE = SO_PROTOCOL; /* alias for SO_PROTOCOL (SunOS name) */ +#pragma D binding "1.13" SO_TS_CLOCK +inline int SO_TS_CLOCK = 0x1017; /* clock type used for SO_TIMESTAMP */ +#pragma D binding "1.13" SO_MAX_PACING_RATE +inline int SO_MAX_PACING_RATE = 0x1018; /* socket's max TX pacing rate (Linux name) */ + +#pragma D binding "1.13" SO_TS_REALTIME_MICRO +inline int SO_TS_REALTIME_MICRO = 0; /* microsecond resolution, realtime */ +#pragma D binding "1.13" SO_TS_BINTIME +inline int SO_TS_BINTIME = 1; /* sub-nanosecond resolution, realtime */ +#pragma D binding "1.13" SO_TS_REALTIME +inline int SO_TS_REALTIME = 2; /* nanosecond resolution, realtime */ +#pragma D binding "1.13" SO_TS_MONOTONIC +inline int SO_TS_MONOTONIC = 3; /* nanosecond resolution, monotonic */ +#pragma D binding "1.13" SO_TS_DEFAULT +inline int SO_TS_DEFAULT = SO_TS_REALTIME_MICRO; +#pragma D binding "1.13" SO_TS_CLOCK_MAX +inline int SO_TS_CLOCK_MAX = SO_TS_MONOTONIC; + +#pragma D binding "1.13" AF_UNSPEC +inline int AF_UNSPEC = 0; /* unspecified */ +#pragma D binding "1.13" AF_UNIX +inline int AF_UNIX = 1; /* standardized name for AF_LOCAL */ +#pragma D binding "1.13" AF_LOCAL +inline int AF_LOCAL = AF_UNIX; /* local to host (pipes, portals) */ +#pragma D binding "1.13" AF_INET +inline int AF_INET = 2; /* internetwork: UDP, TCP, etc. */ +#pragma D binding "1.13" AF_IMPLINK +inline int AF_IMPLINK = 3; /* arpanet imp addresses */ +#pragma D binding "1.13" AF_PUP +inline int AF_PUP = 4; /* pup protocols: e.g. BSP */ +#pragma D binding "1.13" AF_CHAOS +inline int AF_CHAOS = 5; /* mit CHAOS protocols */ +#pragma D binding "1.13" AF_NETBIOS +inline int AF_NETBIOS = 6; /* SMB protocols */ +#pragma D binding "1.13" AF_ISO +inline int AF_ISO = 7; /* ISO protocols */ +#pragma D binding "1.13" AF_OSI +inline int AF_OSI = AF_ISO; +#pragma D binding "1.13" AF_ECMA +inline int AF_ECMA = 8; /* European computer manufacturers */ +#pragma D binding "1.13" AF_DATAKIT +inline int AF_DATAKIT = 9; /* datakit protocols */ +#pragma D binding "1.13" AF_CCITT +inline int AF_CCITT = 10; /* CCITT protocols, X.25 etc */ +#pragma D binding "1.13" AF_SNA +inline int AF_SNA = 11; /* IBM SNA */ +#pragma D binding "1.13" AF_DECnet +inline int AF_DECnet = 12; /* DECnet */ +#pragma D binding "1.13" AF_DLI +inline int AF_DLI = 13; /* DEC Direct data link interface */ +#pragma D binding "1.13" AF_LAT +inline int AF_LAT = 14; /* LAT */ +#pragma D binding "1.13" AF_HYLINK +inline int AF_HYLINK = 15; /* NSC Hyperchannel */ +#pragma D binding "1.13" AF_APPLETALK +inline int AF_APPLETALK = 16; /* Apple Talk */ +#pragma D binding "1.13" AF_ROUTE +inline int AF_ROUTE = 17; /* Internal Routing Protocol */ +#pragma D binding "1.13" AF_LINK +inline int AF_LINK = 18; /* Link layer interface */ +#pragma D binding "1.13" pseudo_AF_XTP +inline int pseudo_AF_XTP = 19; /* eXpress Transfer Protocol (no AF) */ +#pragma D binding "1.13" AF_COIP +inline int AF_COIP = 20; /* connection-oriented IP, aka ST II */ +#pragma D binding "1.13" AF_CNT +inline int AF_CNT = 21; /* Computer Network Technology */ +#pragma D binding "1.13" pseudo_AF_RTIP +inline int pseudo_AF_RTIP = 22; /* Help Identify RTIP packets */ +#pragma D binding "1.13" AF_IPX +inline int AF_IPX = 23; /* Novell Internet Protocol */ +#pragma D binding "1.13" AF_SIP +inline int AF_SIP = 24; /* Simple Internet Protocol */ +#pragma D binding "1.13" pseudo_AF_PIP +inline int pseudo_AF_PIP = 25; /* Help Identify PIP packets */ +#pragma D binding "1.13" AF_ISDN +inline int AF_ISDN = 26; /* Integrated Services Digital Network*/ +#pragma D binding "1.13" AF_E164 +inline int AF_E164 = AF_ISDN; /* CCITT E.164 recommendation */ +#pragma D binding "1.13" pseudo_AF_KEY +inline int pseudo_AF_KEY = 27; /* Internal key-management function */ +#pragma D binding "1.13" AF_INET6 +inline int AF_INET6 = 28; /* IPv6 */ +#pragma D binding "1.13" AF_NATM +inline int AF_NATM = 29; /* native ATM access */ +#pragma D binding "1.13" AF_ATM +inline int AF_ATM = 30; /* ATM */ +#pragma D binding "1.13" pseudo_AF_HDRCMPLT +inline int pseudo_AF_HDRCMPLT = 31; /* Used by BPF to not rewrite headers + * in interface output routine + */ +#pragma D binding "1.13" AF_NETGRAPH +inline int AF_NETGRAPH = 32; /* Netgraph sockets */ +#pragma D binding "1.13" AF_SLOW +inline int AF_SLOW = 33; /* 802.3ad slow protocol */ +#pragma D binding "1.13" AF_SCLUSTER +inline int AF_SCLUSTER = 34; /* Sitara cluster protocol */ +#pragma D binding "1.13" AF_ARP +inline int AF_ARP = 35; /* Address Resolution Protocol */ +#pragma D binding "1.13" AF_BLUETOOTH +inline int AF_BLUETOOTH = 36; /* Bluetooth sockets */ +#pragma D binding "1.13" AF_IEEE80211 +inline int AF_IEEE80211 = 37; /* IEEE 802.11 protocol */ +#pragma D binding "1.13" AF_INET_SDP +inline int AF_INET_SDP = 40; /* OFED Socket Direct Protocol ipv4 */ +#pragma D binding "1.13" AF_INET6_SDP +inline int AF_INET6_SDP = 42; /* OFED Socket Direct Protocol ipv6 */ +#pragma D binding "1.13" AF_MAX +inline int AF_MAX = 42; + +/* + * Protocol families, same as address families for now. + */ +#pragma D binding "1.13" PF_UNSPEC +inline int PF_UNSPEC = AF_UNSPEC; +#pragma D binding "1.13" PF_LOCAL +inline int PF_LOCAL = AF_LOCAL; +#pragma D binding "1.13" PF_UNIX +inline int PF_UNIX = PF_LOCAL; /* backward compatibility */ +#pragma D binding "1.13" PF_INET +inline int PF_INET = AF_INET; +#pragma D binding "1.13" PF_IMPLINK +inline int PF_IMPLINK = AF_IMPLINK; +#pragma D binding "1.13" PF_PUP +inline int PF_PUP = AF_PUP; +#pragma D binding "1.13" PF_CHAOS +inline int PF_CHAOS = AF_CHAOS; +#pragma D binding "1.13" PF_NETBIOS +inline int PF_NETBIOS = AF_NETBIOS; +#pragma D binding "1.13" PF_ISO +inline int PF_ISO = AF_ISO; +#pragma D binding "1.13" PF_OSI +inline int PF_OSI = AF_ISO; +#pragma D binding "1.13" PF_ECMA +inline int PF_ECMA = AF_ECMA; +#pragma D binding "1.13" PF_DATAKIT +inline int PF_DATAKIT = AF_DATAKIT; +#pragma D binding "1.13" PF_CCITT +inline int PF_CCITT = AF_CCITT; +#pragma D binding "1.13" PF_SNA +inline int PF_SNA = AF_SNA; +#pragma D binding "1.13" PF_DECnet +inline int PF_DECnet = AF_DECnet; +#pragma D binding "1.13" PF_DLI +inline int PF_DLI = AF_DLI; +#pragma D binding "1.13" PF_LAT +inline int PF_LAT = AF_LAT; +#pragma D binding "1.13" PF_HYLINK +inline int PF_HYLINK = AF_HYLINK; +#pragma D binding "1.13" PF_APPLETALK +inline int PF_APPLETALK = AF_APPLETALK; +#pragma D binding "1.13" PF_ROUTE +inline int PF_ROUTE = AF_ROUTE; +#pragma D binding "1.13" PF_LINK +inline int PF_LINK = AF_LINK; +#pragma D binding "1.13" PF_XTP +inline int PF_XTP = pseudo_AF_XTP; /* really just proto family, no AF */ +#pragma D binding "1.13" PF_COIP +inline int PF_COIP = AF_COIP; +#pragma D binding "1.13" PF_CNT +inline int PF_CNT = AF_CNT; +#pragma D binding "1.13" PF_SIP +inline int PF_SIP = AF_SIP; +#pragma D binding "1.13" PF_IPX +inline int PF_IPX = AF_IPX; +#pragma D binding "1.13" PF_RTIP +inline int PF_RTIP = pseudo_AF_RTIP; /* same format as AF_INET */ +#pragma D binding "1.13" PF_PIP +inline int PF_PIP = pseudo_AF_PIP; +#pragma D binding "1.13" PF_ISDN +inline int PF_ISDN = AF_ISDN; +#pragma D binding "1.13" PF_KEY +inline int PF_KEY = pseudo_AF_KEY; +#pragma D binding "1.13" PF_INET6 +inline int PF_INET6 = AF_INET6; +#pragma D binding "1.13" PF_NATM +inline int PF_NATM = AF_NATM; +#pragma D binding "1.13" PF_ATM +inline int PF_ATM = AF_ATM; +#pragma D binding "1.13" PF_NETGRAPH +inline int PF_NETGRAPH = AF_NETGRAPH; +#pragma D binding "1.13" PF_SLOW +inline int PF_SLOW = AF_SLOW; +#pragma D binding "1.13" PF_SCLUSTER +inline int PF_SCLUSTER = AF_SCLUSTER; +#pragma D binding "1.13" PF_ARP +inline int PF_ARP = AF_ARP; +#pragma D binding "1.13" PF_BLUETOOTH +inline int PF_BLUETOOTH = AF_BLUETOOTH; +#pragma D binding "1.13" PF_IEEE80211 +inline int PF_IEEE80211 = AF_IEEE80211; +#pragma D binding "1.13" PF_INET_SDP +inline int PF_INET_SDP= AF_INET_SDP; +#pragma D binding "1.13" PF_INET6_SDP +inline int PF_INET6_SDP= AF_INET6_SDP; +#pragma D binding "1.13" PF_MAX +inline int PF_MAX = AF_MAX; diff --git cddl/lib/libnvpair/Makefile.depend cddl/lib/libnvpair/Makefile.depend index c9f9d52f6e26..905e67cc66c9 100644 --- cddl/lib/libnvpair/Makefile.depend +++ cddl/lib/libnvpair/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/lib/libumem/Makefile.depend cddl/lib/libumem/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/lib/libumem/Makefile.depend +++ cddl/lib/libumem/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/lib/libuutil/Makefile.depend cddl/lib/libuutil/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- cddl/lib/libuutil/Makefile.depend +++ cddl/lib/libuutil/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/lib/libzfs/Makefile cddl/lib/libzfs/Makefile index e8de72f18275..c873f3e80d77 100644 --- cddl/lib/libzfs/Makefile +++ cddl/lib/libzfs/Makefile @@ -4,6 +4,7 @@ .PATH: ${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs .PATH: ${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common +.PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libcmdutils/common LIB= zfs LIBADD= md pthread umem util uutil m avl bsdxml geom nvpair z zfs_core @@ -15,6 +16,8 @@ SRCS= deviceid.c \ zmount.c \ zone.c +SRCS+= nicenum.c + SRCS+= libzfs_changelist.c \ libzfs_compat.c \ libzfs_config.c \ @@ -54,5 +57,6 @@ CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libuutil/common CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs_core/common +CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libcmdutils .include <bsd.lib.mk> diff --git cddl/lib/libzfs/Makefile.depend cddl/lib/libzfs/Makefile.depend index d1ae9c336827..c595a33ac32a 100644 --- cddl/lib/libzfs/Makefile.depend +++ cddl/lib/libzfs/Makefile.depend @@ -8,7 +8,6 @@ DIRDEPS = \ cddl/lib/libuutil \ cddl/lib/libzfs_core \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/lib/libzfs_core/Makefile.depend cddl/lib/libzfs_core/Makefile.depend index 86e045ff4aa0..29182b722f62 100644 --- cddl/lib/libzfs_core/Makefile.depend +++ cddl/lib/libzfs_core/Makefile.depend @@ -4,7 +4,6 @@ DIRDEPS = \ cddl/lib/libnvpair \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/lib/libzpool/Makefile cddl/lib/libzpool/Makefile index c0c741f454e8..920cf865aa45 100644 --- cddl/lib/libzpool/Makefile +++ cddl/lib/libzpool/Makefile @@ -4,6 +4,8 @@ # ZFS_COMMON_SRCS .PATH: ${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs +# LUA_SRCS +.PATH: ${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lua # ZFS_SHARED_SRCS .PATH: ${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs # KERNEL_SRCS @@ -23,18 +25,22 @@ ATOMIC_SRCS= opensolaris_atomic.c .endif # UNICODE_SRCS .PATH: ${SRCTOP}/sys/cddl/contrib/opensolaris/common/unicode +# LIBCMDUTILS_SRCS +.PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libcmdutils/common LIB= zpool -ZFS_COMMON_SRCS= ${ZFS_COMMON_OBJS:C/.o$/.c/} vdev_file.c trim_map.c +ZFS_COMMON_SRCS= ${ZFS_COMMON_OBJS:C/.o$/.c/} trim_map.c ZFS_SHARED_SRCS= ${ZFS_SHARED_OBJS:C/.o$/.c/} +LUA_SRCS= ${LUA_OBJS:C/.o$/.c/} KERNEL_SRCS= kernel.c taskq.c util.c LIST_SRCS= list.c UNICODE_SRCS= u8_textprep.c +LIBCMDUTILS_SRCS=nicenum.c -SRCS= ${ZFS_COMMON_SRCS} ${ZFS_SHARED_SRCS} \ +SRCS= ${ZFS_COMMON_SRCS} ${ZFS_SHARED_SRCS} ${LUA_SRCS} \ ${KERNEL_SRCS} ${LIST_SRCS} ${ATOMIC_SRCS} \ - ${UNICODE_SRCS} + ${UNICODE_SRCS} ${LIBCMDUTILS_SRCS} WARNS?= 0 CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris @@ -43,10 +49,12 @@ CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libumem CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzpool/common CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs +CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lua CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/head CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair +CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libcmdutils # XXX: pthread doesn't have mutex_owned() equivalent, so we need to look # into libthr private structures. That's sooo evil, but it's only for # ZFS debugging tools needs. diff --git cddl/lib/libzpool/Makefile.depend cddl/lib/libzpool/Makefile.depend index c91de43e0c03..97914fc35322 100644 --- cddl/lib/libzpool/Makefile.depend +++ cddl/lib/libzpool/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ cddl/lib/libnvpair \ cddl/lib/libumem \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/sbin/zfs/Makefile cddl/sbin/zfs/Makefile index e0d6faa8d873..9d6075e6ad8f 100644 --- cddl/sbin/zfs/Makefile +++ cddl/sbin/zfs/Makefile @@ -3,7 +3,7 @@ .PATH: ${SRCTOP}/cddl/contrib/opensolaris/cmd/zfs PROG= zfs -MAN= zfs.8 +MAN= zfs.8 zfs-program.8 SRCS= zfs_main.c zfs_iter.c WARNS?= 0 diff --git cddl/sbin/zfs/Makefile.depend cddl/sbin/zfs/Makefile.depend index dc8a013df91e..b22dd60b0ef8 100644 --- cddl/sbin/zfs/Makefile.depend +++ cddl/sbin/zfs/Makefile.depend @@ -9,7 +9,6 @@ DIRDEPS = \ cddl/lib/libzfs \ cddl/lib/libzfs_core \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/sbin/zpool/Makefile.depend cddl/sbin/zpool/Makefile.depend index b1a2eff6cb4f..53090da6e2fc 100644 --- cddl/sbin/zpool/Makefile.depend +++ cddl/sbin/zpool/Makefile.depend @@ -9,7 +9,6 @@ DIRDEPS = \ cddl/lib/libzfs \ cddl/lib/libzfs_core \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.bin/ctfconvert/Makefile.depend cddl/usr.bin/ctfconvert/Makefile.depend index 9dafcb6af276..44e570745e22 100644 --- cddl/usr.bin/ctfconvert/Makefile.depend +++ cddl/usr.bin/ctfconvert/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.bin/ctfdump/Makefile.depend cddl/usr.bin/ctfdump/Makefile.depend index ff9d79528313..ceebc6a83a34 100644 --- cddl/usr.bin/ctfdump/Makefile.depend +++ cddl/usr.bin/ctfdump/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.bin/ctfmerge/Makefile.depend cddl/usr.bin/ctfmerge/Makefile.depend index e94f8d4ba875..32a1985bd180 100644 --- cddl/usr.bin/ctfmerge/Makefile.depend +++ cddl/usr.bin/ctfmerge/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.bin/zinject/Makefile.depend cddl/usr.bin/zinject/Makefile.depend index deb1256e93a4..dfb2563fa7d1 100644 --- cddl/usr.bin/zinject/Makefile.depend +++ cddl/usr.bin/zinject/Makefile.depend @@ -10,7 +10,6 @@ DIRDEPS = \ cddl/lib/libzfs_core \ cddl/lib/libzpool \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.bin/zstreamdump/Makefile.depend cddl/usr.bin/zstreamdump/Makefile.depend index 138e88bc6aa4..3089536f9717 100644 --- cddl/usr.bin/zstreamdump/Makefile.depend +++ cddl/usr.bin/zstreamdump/Makefile.depend @@ -7,7 +7,6 @@ DIRDEPS = \ cddl/lib/libumem \ cddl/lib/libzpool \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.bin/ztest/Makefile cddl/usr.bin/ztest/Makefile index 81f120a13116..367512999c41 100644 --- cddl/usr.bin/ztest/Makefile +++ cddl/usr.bin/ztest/Makefile @@ -11,6 +11,7 @@ CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libumem CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzpool/common CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair +CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libcmdutils CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys diff --git cddl/usr.bin/ztest/Makefile.depend cddl/usr.bin/ztest/Makefile.depend index deb1256e93a4..dfb2563fa7d1 100644 --- cddl/usr.bin/ztest/Makefile.depend +++ cddl/usr.bin/ztest/Makefile.depend @@ -10,7 +10,6 @@ DIRDEPS = \ cddl/lib/libzfs_core \ cddl/lib/libzpool \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.sbin/dtrace/Makefile.depend cddl/usr.sbin/dtrace/Makefile.depend index db4aafd0a282..c37ef4acf01e 100644 --- cddl/usr.sbin/dtrace/Makefile.depend +++ cddl/usr.sbin/dtrace/Makefile.depend @@ -5,7 +5,6 @@ DIRDEPS = \ cddl/lib/libctf \ cddl/lib/libdtrace \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.sbin/dtrace/tests/common/io/Makefile.depend cddl/usr.sbin/dtrace/tests/common/io/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/usr.sbin/dtrace/tests/common/io/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/io/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/usr.sbin/dtrace/tests/common/java_api/Makefile.depend cddl/usr.sbin/dtrace/tests/common/java_api/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/usr.sbin/dtrace/tests/common/java_api/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/java_api/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/usr.sbin/dtrace/tests/common/json/Makefile.depend cddl/usr.sbin/dtrace/tests/common/json/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/usr.sbin/dtrace/tests/common/json/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/json/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/usr.sbin/dtrace/tests/common/pid/Makefile.depend cddl/usr.sbin/dtrace/tests/common/pid/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/usr.sbin/dtrace/tests/common/pid/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/pid/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/usr.sbin/dtrace/tests/common/probes/Makefile.depend cddl/usr.sbin/dtrace/tests/common/probes/Makefile.depend index f80275d86ab1..cae7e645ef6a 100644 --- cddl/usr.sbin/dtrace/tests/common/probes/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/probes/Makefile.depend @@ -2,6 +2,11 @@ # Autogenerated - do NOT edit! DIRDEPS = \ + gnu/lib/csu \ + include \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ .include <dirdeps.mk> diff --git cddl/usr.sbin/dtrace/tests/common/proc/Makefile.depend cddl/usr.sbin/dtrace/tests/common/proc/Makefile.depend index 7543607a575c..564eb51e0156 100644 --- cddl/usr.sbin/dtrace/tests/common/proc/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/proc/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile.depend cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile.depend index 43d71f8b2760..03d33794d0e3 100644 --- cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ diff --git cddl/usr.sbin/dtrace/tests/common/raise/Makefile.depend cddl/usr.sbin/dtrace/tests/common/raise/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/usr.sbin/dtrace/tests/common/raise/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/raise/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/usr.sbin/dtrace/tests/common/sdt/Makefile.depend cddl/usr.sbin/dtrace/tests/common/sdt/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/usr.sbin/dtrace/tests/common/sdt/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/sdt/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/usr.sbin/dtrace/tests/common/stop/Makefile.depend cddl/usr.sbin/dtrace/tests/common/stop/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/usr.sbin/dtrace/tests/common/stop/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/stop/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/usr.sbin/dtrace/tests/common/sugar/Makefile.depend cddl/usr.sbin/dtrace/tests/common/sugar/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ cddl/usr.sbin/dtrace/tests/common/sugar/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git cddl/usr.sbin/dtrace/tests/common/syscall/Makefile.depend cddl/usr.sbin/dtrace/tests/common/syscall/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/usr.sbin/dtrace/tests/common/syscall/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/syscall/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/usr.sbin/dtrace/tests/common/uctf/Makefile.depend cddl/usr.sbin/dtrace/tests/common/uctf/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/usr.sbin/dtrace/tests/common/uctf/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/uctf/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/usr.sbin/dtrace/tests/common/usdt/Makefile.depend cddl/usr.sbin/dtrace/tests/common/usdt/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/usr.sbin/dtrace/tests/common/usdt/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/usdt/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/usr.sbin/dtrace/tests/common/ustack/Makefile.depend cddl/usr.sbin/dtrace/tests/common/ustack/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- cddl/usr.sbin/dtrace/tests/common/ustack/Makefile.depend +++ cddl/usr.sbin/dtrace/tests/common/ustack/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git cddl/usr.sbin/lockstat/Makefile.depend cddl/usr.sbin/lockstat/Makefile.depend index 18ce380c1380..04b96e83f1c7 100644 --- cddl/usr.sbin/lockstat/Makefile.depend +++ cddl/usr.sbin/lockstat/Makefile.depend @@ -5,7 +5,6 @@ DIRDEPS = \ cddl/lib/libctf \ cddl/lib/libdtrace \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.sbin/plockstat/Makefile.depend cddl/usr.sbin/plockstat/Makefile.depend index db4aafd0a282..c37ef4acf01e 100644 --- cddl/usr.sbin/plockstat/Makefile.depend +++ cddl/usr.sbin/plockstat/Makefile.depend @@ -5,7 +5,6 @@ DIRDEPS = \ cddl/lib/libctf \ cddl/lib/libdtrace \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.sbin/zdb/Makefile cddl/usr.sbin/zdb/Makefile index 84b64e45c6b2..8f50aaa5f525 100644 --- cddl/usr.sbin/zdb/Makefile +++ cddl/usr.sbin/zdb/Makefile @@ -12,6 +12,7 @@ CSTD= c99 CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libumem +CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libcmdutils CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libuutil/common CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common diff --git cddl/usr.sbin/zdb/Makefile.depend cddl/usr.sbin/zdb/Makefile.depend index deb1256e93a4..dfb2563fa7d1 100644 --- cddl/usr.sbin/zdb/Makefile.depend +++ cddl/usr.sbin/zdb/Makefile.depend @@ -10,7 +10,6 @@ DIRDEPS = \ cddl/lib/libzfs_core \ cddl/lib/libzpool \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.sbin/zfsd/Makefile.depend cddl/usr.sbin/zfsd/Makefile.depend index 35e134179446..023a4456ec68 100644 --- cddl/usr.sbin/zfsd/Makefile.depend +++ cddl/usr.sbin/zfsd/Makefile.depend @@ -9,7 +9,6 @@ DIRDEPS = \ cddl/lib/libzfs \ cddl/lib/libzfs_core \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git cddl/usr.sbin/zfsd/case_file.cc cddl/usr.sbin/zfsd/case_file.cc index 0cd659622e94..c3105853b29c 100644 --- cddl/usr.sbin/zfsd/case_file.cc +++ cddl/usr.sbin/zfsd/case_file.cc @@ -102,7 +102,8 @@ CaseFile::Find(Guid poolGUID, Guid vdevGUID) for (CaseFileList::iterator curCase = s_activeCases.begin(); curCase != s_activeCases.end(); curCase++) { - if ((*curCase)->PoolGUID() != poolGUID + if (((*curCase)->PoolGUID() != poolGUID + && Guid::InvalidGuid() != poolGUID) || (*curCase)->VdevGUID() != vdevGUID) continue; @@ -268,7 +269,8 @@ CaseFile::ReEvaluate(const string &devPath, const string &physPath, Vdev *vdev) } if (vdev != NULL - && vdev->PoolGUID() == m_poolGUID + && ( vdev->PoolGUID() == m_poolGUID + || vdev->PoolGUID() == Guid::InvalidGuid()) && vdev->GUID() == m_vdevGUID) { zpool_vdev_online(pool, vdev->GUIDString().c_str(), diff --git cddl/usr.sbin/zfsd/case_file.h cddl/usr.sbin/zfsd/case_file.h index aa2a447e8a47..fcb1261f2a67 100644 --- cddl/usr.sbin/zfsd/case_file.h +++ cddl/usr.sbin/zfsd/case_file.h @@ -89,6 +89,8 @@ public: * \brief Find a CaseFile object by a vdev's pool/vdev GUID tuple. * * \param poolGUID Pool GUID for the vdev of the CaseFile to find. + * If InvalidGuid, then only match the vdev GUID + * instead of both pool and vdev GUIDs. * \param vdevGUID Vdev GUID for the vdev of the CaseFile to find. * * \return If found, a pointer to a valid CaseFile object. diff --git cddl/usr.sbin/zfsd/vdev_iterator.cc cddl/usr.sbin/zfsd/vdev_iterator.cc index 07f19d2b074c..31a4ce962970 100644 --- cddl/usr.sbin/zfsd/vdev_iterator.cc +++ cddl/usr.sbin/zfsd/vdev_iterator.cc @@ -76,7 +76,9 @@ void VdevIterator::Reset() { nvlist_t *rootVdev; + nvlist **cache_child; int result; + uint_t cache_children; result = nvlist_lookup_nvlist(m_poolConfig, ZPOOL_CONFIG_VDEV_TREE, @@ -85,6 +87,13 @@ VdevIterator::Reset() throw ZfsdException(m_poolConfig, "Unable to extract " "ZPOOL_CONFIG_VDEV_TREE from pool."); m_vdevQueue.assign(1, rootVdev); + result = nvlist_lookup_nvlist_array(rootVdev, + ZPOOL_CONFIG_L2CACHE, + &cache_child, + &cache_children); + if (result == 0) + for (uint_t c = 0; c < cache_children; c++) + m_vdevQueue.push_back(cache_child[c]); } nvlist_t * diff --git cddl/usr.sbin/zfsd/zfsd_event.cc cddl/usr.sbin/zfsd/zfsd_event.cc index c10cc1872900..5594b35a88a8 100644 --- cddl/usr.sbin/zfsd/zfsd_event.cc +++ cddl/usr.sbin/zfsd/zfsd_event.cc @@ -36,6 +36,7 @@ #include <sys/cdefs.h> #include <sys/time.h> #include <sys/fs/zfs.h> +#include <sys/vdev_impl.h> #include <syslog.h> @@ -93,21 +94,32 @@ DevfsEvent::ReadLabel(int devFd, bool &inUse, bool °raded) pool_state_t poolState; char *poolName; boolean_t b_inuse; + int nlabels; inUse = false; degraded = false; poolName = NULL; if (zpool_in_use(g_zfsHandle, devFd, &poolState, &poolName, &b_inuse) == 0) { - nvlist_t *devLabel; + nvlist_t *devLabel = NULL; inUse = b_inuse == B_TRUE; if (poolName != NULL) free(poolName); - if (zpool_read_label(devFd, &devLabel) != 0 - || devLabel == NULL) + nlabels = zpool_read_all_labels(devFd, &devLabel); + /* + * If we find a disk with fewer than the maximum number of + * labels, it might be the whole disk of a partitioned disk + * where ZFS resides on a partition. In that case, we should do + * nothing and wait for the partition to appear. Or, the disk + * might be damaged. In that case, zfsd should do nothing and + * wait for the sysadmin to decide. + */ + if (nlabels != VDEV_LABELS || devLabel == NULL) { + nvlist_free(devLabel); return (NULL); + } try { Vdev vdev(devLabel); @@ -121,6 +133,7 @@ DevfsEvent::ReadLabel(int devFd, bool &inUse, bool °raded) exp.GetString().insert(0, context); exp.Log(); + nvlist_free(devLabel); } } return (NULL); diff --git cddl/usr.sbin/zhack/Makefile.depend cddl/usr.sbin/zhack/Makefile.depend index deb1256e93a4..dfb2563fa7d1 100644 --- cddl/usr.sbin/zhack/Makefile.depend +++ cddl/usr.sbin/zhack/Makefile.depend @@ -10,7 +10,6 @@ DIRDEPS = \ cddl/lib/libzfs_core \ cddl/lib/libzpool \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/binutils/bfd/elf-eh-frame.c contrib/binutils/bfd/elf-eh-frame.c index 092c2c57ec34..baa998676cdd 100644 --- contrib/binutils/bfd/elf-eh-frame.c +++ contrib/binutils/bfd/elf-eh-frame.c @@ -1344,7 +1344,7 @@ _bfd_elf_write_section_eh_frame (bfd *abfd, val = read_value (abfd, buf, per_width, get_DW_EH_PE_signed (per_encoding)); - val += ent->offset - ent->new_offset; + val += (bfd_vma)ent->offset - ent->new_offset; val -= extra_string + extra_data; write_value (abfd, buf, val, per_width); action &= ~4; @@ -1400,7 +1400,7 @@ _bfd_elf_write_section_eh_frame (bfd *abfd, } break; case DW_EH_PE_pcrel: - value += ent->offset - ent->new_offset; + value += (bfd_vma)ent->offset - ent->new_offset; address += sec->output_section->vma + ent->offset + 8; break; } @@ -1428,7 +1428,7 @@ _bfd_elf_write_section_eh_frame (bfd *abfd, if (value) { if ((ent->lsda_encoding & 0xf0) == DW_EH_PE_pcrel) - value += ent->offset - ent->new_offset; + value += (bfd_vma)ent->offset - ent->new_offset; else if (ent->cie_inf->need_lsda_relative) value -= (sec->output_section->vma + ent->new_offset + 8 + ent->lsda_offset); diff --git contrib/binutils/opcodes/i386-dis.c contrib/binutils/opcodes/i386-dis.c index 073afa1a836d..04470d7dc283 100644 --- contrib/binutils/opcodes/i386-dis.c +++ contrib/binutils/opcodes/i386-dis.c @@ -1302,7 +1302,7 @@ static const unsigned char twobyte_uses_REPZ_prefix[256] = { /* 70 */ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, /* 7f */ /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */ /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */ - /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */ + /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, /* af */ /* b0 */ 0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0, /* bf */ /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */ /* d0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */ @@ -1793,10 +1793,10 @@ static const struct dis386 grps[][8] = { }, /* GRP15 */ { - { "fxsave", { Ev } }, - { "fxrstor", { Ev } }, - { "ldmxcsr", { Ev } }, - { "stmxcsr", { Ev } }, + { "fxsave", { { OP_0fae, v_mode } } }, + { "fxrstor", { { OP_0fae, v_mode } } }, + { "ldmxcsr", { { OP_0fae, v_mode } } }, + { "stmxcsr", { { OP_0fae, v_mode } } }, { "xsave", { Ev } }, { "xrstor", { { OP_0fae, v_mode } } }, { "xsaveopt", { { OP_0fae, v_mode } } }, @@ -5997,19 +5997,34 @@ OP_0fae (int bytemode, int sizeflag) { if (modrm.mod == 3) { - if (modrm.reg == 7) - strcpy (obuf + strlen (obuf) - sizeof ("clflush") + 1, "sfence"); - else if (modrm.reg == 6) - strcpy (obuf + strlen (obuf) - sizeof ("xsaveopt") + 1, "mfence"); - else if (modrm.reg == 5) - strcpy (obuf + strlen (obuf) - sizeof ("xrstor") + 1, "lfence"); - - if (modrm.reg < 5 || modrm.rm != 0) + if (modrm.reg >= 5 && modrm.reg <= 7 && modrm.rm == 0) + { + if (modrm.reg == 7) + strcpy (obuf + strlen (obuf) - sizeof ("clflush") + 1, "sfence"); + else if (modrm.reg == 6) + strcpy (obuf + strlen (obuf) - sizeof ("xsaveopt") + 1, "mfence"); + else if (modrm.reg == 5) + strcpy (obuf + strlen (obuf) - sizeof ("xrstor") + 1, "lfence"); + bytemode = 0; + } + else if (modrm.reg <= 3 && (prefixes & PREFIX_REPZ) != 0) + { + if (modrm.reg == 0) + strcpy (obuf + strlen (obuf) - sizeof ("fxsave") + 1, "rdfsbase"); + else if (modrm.reg == 1) + strcpy (obuf + strlen (obuf) - sizeof ("fxrstor") + 1, "rdgsbase"); + else if (modrm.reg == 2) + strcpy (obuf + strlen (obuf) - sizeof ("ldmxcsr") + 1, "wrfsbase"); + else if (modrm.reg == 3) + strcpy (obuf + strlen (obuf) - sizeof ("stmxcsr") + 1, "wrgsbase"); + used_prefixes |= PREFIX_REPZ; + bytemode = dq_mode; + } + else { - BadOp (); /* bad sfence, mfence, or lfence */ + BadOp (); return; } - bytemode = 0; } OP_E (bytemode, sizeflag); diff --git contrib/binutils/opcodes/i386-opc.h contrib/binutils/opcodes/i386-opc.h index ec8019691e37..660fdccca2df 100644 --- contrib/binutils/opcodes/i386-opc.h +++ contrib/binutils/opcodes/i386-opc.h @@ -81,6 +81,7 @@ typedef struct template #define CpuPCLMUL 0x10000000 /* Carry-less Multiplication extensions */ #define CpuRdRnd 0x20000000 /* Intel Random Number Generator extensions */ #define CpuSMAP 0x40000000 /* Intel Supervisor Mode Access Prevention */ +#define CpuFSGSBase 0x80000000 /* Read/write fs/gs segment base registers */ /* SSE4.1/4.2 Instructions required */ #define CpuSSE4 (CpuSSE4_1|CpuSSE4_2) @@ -89,7 +90,8 @@ typedef struct template #define CpuUnknownFlags (Cpu186|Cpu286|Cpu386|Cpu486|Cpu586|Cpu686 \ |CpuP4|CpuSledgehammer|CpuMMX|CpuMMX2|CpuSSE|CpuSSE2|CpuSSE3|CpuVMX \ |Cpu3dnow|Cpu3dnowA|CpuK6|CpuPadLock|CpuSVME|CpuSSSE3|CpuSSE4_1 \ - |CpuSSE4_2|CpuABM|CpuSSE4a|CpuXSAVE|CpuAES|CpuPCLMUL|CpuRdRnd|CpuSMAP) + |CpuSSE4_2|CpuABM|CpuSSE4a|CpuXSAVE|CpuAES|CpuPCLMUL|CpuRdRnd|CpuSMAP \ + |CpuFSGSBase) /* the bits in opcode_modifier are used to generate the final opcode from the base_opcode. These bits also are used to detect alternate forms of diff --git contrib/binutils/opcodes/i386-opc.tbl contrib/binutils/opcodes/i386-opc.tbl index 9d7c207612bd..50c734f608af 100644 --- contrib/binutils/opcodes/i386-opc.tbl +++ contrib/binutils/opcodes/i386-opc.tbl @@ -1525,3 +1525,13 @@ pclmulhqhqdq, 2, 0x660f3a44, 0x11, CpuPCLMUL, Modrm|IgnoreSize|No_bSuf|No_wSuf|N // Intel Random Number Generator extensions rdrand, 1, 0x0fc7, 0x6, CpuRdRnd, Modrm|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf, { Reg16|Reg32|Reg64 } rdseed, 1, 0x0fc7, 0x7, CpuRdRnd, Modrm|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf, { Reg16|Reg32|Reg64 } + +// Intel Supervisor Mode Access Prevention extensions +clac, 0, 0x0f01, 0xca, CpuSMAP, NoSuf|ImmExt, { 0 } +stac, 0, 0x0f01, 0xcb, CpuSMAP, NoSuf|ImmExt, { 0 } + +// Read/write fs/gs segment base registers +rdfsbase, 1, 0xf30fae, 0x0, CpuFSGSBase|Cpu64, Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf, { Reg32|Reg64 } +rdgsbase, 1, 0xf30fae, 0x1, CpuFSGSBase|Cpu64, Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf, { Reg32|Reg64 } +wrfsbase, 1, 0xf30fae, 0x2, CpuFSGSBase|Cpu64, Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf, { Reg32|Reg64 } +wrgsbase, 1, 0xf30fae, 0x3, CpuFSGSBase|Cpu64, Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf, { Reg32|Reg64 } diff --git contrib/binutils/opcodes/i386-tbl.h contrib/binutils/opcodes/i386-tbl.h index d769d09f7dea..9eb313a136be 100644 --- contrib/binutils/opcodes/i386-tbl.h +++ contrib/binutils/opcodes/i386-tbl.h @@ -4400,6 +4400,20 @@ const template i386_optab[] = NoSuf|ImmExt, { 0, 0, 0 } }, {"stac", 0, 0x0f01, 0xcb, CpuSMAP, NoSuf|ImmExt, { 0, 0, 0 } }, + + /* Read/write fs/gs segment base registers */ + {"rdfsbase", 1, 0xf30fae, 0x0, CpuFSGSBase|Cpu64, + Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf, + { Reg32|Reg64 } }, + {"rdgsbase", 1, 0xf30fae, 0x1, CpuFSGSBase|Cpu64, + Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf, + { Reg32|Reg64 } }, + {"wrfsbase", 1, 0xf30fae, 0x2, CpuFSGSBase|Cpu64, + Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf, + { Reg32|Reg64 } }, + {"wrgsbase", 1, 0xf30fae, 0x3, CpuFSGSBase|Cpu64, + Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf, + { Reg32|Reg64 } }, { NULL, 0, 0, 0, 0, 0, { 0 } } }; diff --git contrib/bmake/ChangeLog contrib/bmake/ChangeLog index c15589c284ad..36476d8ccdd4 100644 --- contrib/bmake/ChangeLog +++ contrib/bmake/ChangeLog @@ -1,3 +1,36 @@ +2017-10-28 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION: 20171028 + Merge with NetBSD make, pick up + o main.c: ignore empty MAKEOBJDIR + + * Makefile.config.in: + make @prefix@ @machine*@ and @default_sys_path@ defaults. + +2017-10-05 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION: 20171005 + + * unit-tests/dotwait.mk: redirect stderr through pipe for more + consistent result on some platforms. + +2017-08-13 Simon J. Gerraty <sjg@bad.crufty.net> + + * machine.sh: entry for AIX + +2017-08-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION (_MAKE_VERSION): Move the setting of _MAKE_VERSION + to a file that can be included by configure as well as make. + This allows configure to set set _MAKE_VERSION in make-bootstrap.sh + +2017-08-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170810 + Merge with NetBSD make, pick up + o meta.c: if target is in subdir we only need subdir name in + meta_name. + 2017-07-20 Simon J. Gerraty <sjg@bad.crufty.net> * Makefile (_MAKE_VERSION): 20170720 diff --git contrib/bmake/FILES contrib/bmake/FILES index 720eb1b9bfb7..24cd0451f077 100644 --- contrib/bmake/FILES +++ contrib/bmake/FILES @@ -5,6 +5,7 @@ Makefile.config.in PSD.doc/Makefile PSD.doc/tutorial.ms README +VERSION aclocal.m4 arch.c bmake.1 diff --git contrib/bmake/Makefile contrib/bmake/Makefile index f0b94966ab07..28d8bf713a00 100644 --- contrib/bmake/Makefile +++ contrib/bmake/Makefile @@ -1,7 +1,4 @@ -# $Id: Makefile,v 1.95 2017/07/20 19:36:13 sjg Exp $ - -# Base version on src date -_MAKE_VERSION= 20170720 +# $Id: Makefile,v 1.99 2017/08/13 20:12:53 sjg Exp $ PROG= bmake @@ -58,6 +55,8 @@ SRCS+= \ lstReplace.c \ lstSucc.c +.-include "VERSION" + # this file gets generated by configure .-include "Makefile.config" @@ -192,11 +191,13 @@ MANDIR= ${MANDIR.bmake:U${SHAREDIR}/man} ${OBJS}: config.h .endif +# start-delete2 for bsd.after-import.mk + # make sure that MAKE_VERSION gets updated. -main.o: ${SRCS} ${MAKEFILE} +main.o: ${SRCS} ${.CURDIR}/VERSION -# start-delete2 for bsd.after-import.mk .if ${MK_AUTOCONF_MK} == "yes" +CONFIGURE_DEPS += ${.CURDIR}/VERSION .include <autoconf.mk> .endif SHARE_MK?=${SHAREDIR}/mk diff --git contrib/bmake/Makefile.config.in contrib/bmake/Makefile.config.in index 1f9aefe1dfad..7b417cef2604 100644 --- contrib/bmake/Makefile.config.in +++ contrib/bmake/Makefile.config.in @@ -1,11 +1,13 @@ # things set by configure -prefix= @prefix@ +_MAKE_VERSION=@_MAKE_VERSION@ + +prefix?= @prefix@ srcdir= @srcdir@ CC?= @CC@ -MACHINE= @machine@ -MACHINE_ARCH= @machine_arch@ -DEFAULT_SYS_PATH= @default_sys_path@ +MACHINE?= @machine@ +MACHINE_ARCH?= @machine_arch@ +DEFAULT_SYS_PATH?= @default_sys_path@ CPPFLAGS+= @CPPFLAGS@ CFLAGS+= ${CPPFLAGS} @DEFS@ @@ -17,4 +19,3 @@ FILEMON_H= @filemon_h@ BMAKE_PATH_MAX?= @bmake_path_max@ # used if MAXPATHLEN not defined CPPFLAGS+= -DBMAKE_PATH_MAX=${BMAKE_PATH_MAX} - diff --git contrib/bmake/VERSION contrib/bmake/VERSION new file mode 100644 index 000000000000..5117e28f593c --- /dev/null +++ contrib/bmake/VERSION @@ -0,0 +1,2 @@ +# keep this compatible with sh and make +_MAKE_VERSION=20171028 diff --git contrib/bmake/bsd.after-import.mk contrib/bmake/bsd.after-import.mk index 9a65096a9597..275b443b657d 100644 --- contrib/bmake/bsd.after-import.mk +++ contrib/bmake/bsd.after-import.mk @@ -1,4 +1,4 @@ -# $Id: bsd.after-import.mk,v 1.12 2014/02/14 23:45:49 sjg Exp $ +# $Id: bsd.after-import.mk,v 1.13 2017/08/13 00:56:10 sjg Exp $ # This makefile is for use when integrating bmake into a BSD build # system. Use this makefile after importing bmake. @@ -56,6 +56,7 @@ bootstrap: ${BMAKE_SRC}/boot-strap ${MAKEFILE} # Makefiles need a little more tweaking than say config.h MAKEFILE_SED = sed -e '/^MACHINE/d' \ + -e '/include.*VERSION/d' \ -e '/^PROG/ { s,=,?=,;s,bmake,$${.CURDIR:T},; }' \ -e 's,^.-include,.sinclude,' \ -e '/^\..*include *</ { s,<,<bsd.,;/autoconf/d; }' \ diff --git contrib/bmake/configure contrib/bmake/configure index 1a70f3d1bf3e..ce79403c5df1 100755 --- contrib/bmake/configure +++ contrib/bmake/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.64 for bmake 20160606. +# Generated by GNU Autoconf 2.64 for bmake 20170812. # # Report bugs to <sjg@NetBSD.org>. # @@ -549,8 +549,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='bmake' PACKAGE_TARNAME='bmake' -PACKAGE_VERSION='20160606' -PACKAGE_STRING='bmake 20160606' +PACKAGE_VERSION='20170812' +PACKAGE_STRING='bmake 20170812' PACKAGE_BUGREPORT='sjg@NetBSD.org' PACKAGE_URL='' @@ -591,6 +591,7 @@ ac_includes_default="\ #endif" ac_subst_vars='LTLIBOBJS +_MAKE_VERSION filemon_h use_meta diff_u @@ -1221,7 +1222,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures bmake 20160606 to adapt to many kinds of systems. +\`configure' configures bmake 20170812 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1282,7 +1283,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of bmake 20160606:";; + short | recursive ) echo "Configuration of bmake 20170812:";; esac cat <<\_ACEOF @@ -1387,7 +1388,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -bmake configure 20160606 +bmake configure 20170812 generated by GNU Autoconf 2.64 Copyright (C) 2009 Free Software Foundation, Inc. @@ -1960,7 +1961,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by bmake $as_me 20160606, which was +It was created by bmake $as_me 20170812, which was generated by GNU Autoconf 2.64. Invocation command line was $ $0 $@ @@ -2315,6 +2316,8 @@ case "$srcdir" in *) srcdir=`cd $srcdir && pwd`;; esac +. $srcdir/VERSION + # Check whether --with-defshell was given. if test "${with_defshell+set}" = set; then : @@ -6005,6 +6008,7 @@ fi + ac_config_files="$ac_config_files makefile Makefile.config make-bootstrap.sh unit-tests/Makefile" cat >confcache <<\_ACEOF @@ -6513,7 +6517,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by bmake $as_me 20160606, which was +This file was extended by bmake $as_me 20170812, which was generated by GNU Autoconf 2.64. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6573,7 +6577,7 @@ Report bugs to <sjg@NetBSD.org>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -bmake config.status 20160606 +bmake config.status 20170812 configured by $0, generated by GNU Autoconf 2.64, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git contrib/bmake/configure.in contrib/bmake/configure.in index 29d368b2ed29..aed426ef8ede 100644 --- contrib/bmake/configure.in +++ contrib/bmake/configure.in @@ -1,11 +1,11 @@ dnl dnl RCSid: -dnl $Id: configure.in,v 1.57 2016/06/07 00:49:44 sjg Exp $ +dnl $Id: configure.in,v 1.58 2017/08/13 00:56:10 sjg Exp $ dnl dnl Process this file with autoconf to produce a configure script dnl AC_PREREQ(2.50) -AC_INIT([bmake], [20160606], [sjg@NetBSD.org]) +AC_INIT([bmake], [20170812], [sjg@NetBSD.org]) AC_CONFIG_HEADERS(config.h) dnl make srcdir absolute @@ -14,6 +14,9 @@ case "$srcdir" in *) srcdir=`cd $srcdir && pwd`;; esac +dnl get _MAKE_VERSION +. $srcdir/VERSION + dnl AC_ARG_WITH(defshell, [ --with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions], @@ -386,6 +389,7 @@ AC_SUBST(GCC) AC_SUBST(diff_u) AC_SUBST(use_meta) AC_SUBST(filemon_h) +AC_SUBST(_MAKE_VERSION) AC_OUTPUT(makefile Makefile.config make-bootstrap.sh unit-tests/Makefile) cat <<EOF diff --git contrib/bmake/machine.sh contrib/bmake/machine.sh index 2209eaa884bf..0cf9daeeef3a 100755 --- contrib/bmake/machine.sh +++ contrib/bmake/machine.sh @@ -2,7 +2,7 @@ # derrived from /etc/rc_d/os.sh # RCSid: -# $Id: machine.sh,v 1.17 2015/05/05 00:10:54 sjg Exp $ +# $Id: machine.sh,v 1.18 2017/08/13 19:11:28 sjg Exp $ # # @(#) Copyright (c) 1994-2002 Simon J. Gerraty # @@ -44,6 +44,12 @@ Which() { } case $OS in +AIX) # from http://gnats.netbsd.org/29386 + OSMAJOR=`uname -v` + OSMINOR=`uname -r` + MACHINE=$OS$OSMAJOR.$OSMINOR + MACHINE_ARCH=`bootinfo -T` + ;; OpenBSD) MACHINE=$OS$OSMAJOR.$machine arch=`Which arch /usr/bin:/usr/ucb:$PATH` diff --git contrib/bmake/main.c contrib/bmake/main.c index cca44c5b4648..7dd4c504f122 100644 --- contrib/bmake/main.c +++ contrib/bmake/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.272 2017/06/19 19:58:24 christos Exp $ */ +/* $NetBSD: main.c,v 1.273 2017/10/28 21:54:54 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.272 2017/06/19 19:58:24 christos Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.273 2017/10/28 21:54:54 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.272 2017/06/19 19:58:24 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.273 2017/10/28 21:54:54 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -792,7 +792,8 @@ Main_SetVarObjdir(const char *var, const char *suffix) { char *p, *path, *xpath; - if ((path = Var_Value(var, VAR_CMD, &p)) == NULL) + if ((path = Var_Value(var, VAR_CMD, &p)) == NULL || + *path == '\0') return FALSE; /* expand variable substitutions */ diff --git contrib/bmake/make-bootstrap.sh.in contrib/bmake/make-bootstrap.sh.in index 83336b47d5af..a39427284586 100755 --- contrib/bmake/make-bootstrap.sh.in +++ contrib/bmake/make-bootstrap.sh.in @@ -13,7 +13,7 @@ esac CC="@CC@" CFLAGS="@CFLAGS@ -I. -I${srcdir} @DEFS@ @CPPFLAGS@ -DMAKE_NATIVE ${XDEFS} -DBMAKE_PATH_MAX=@bmake_path_max@" -MAKE_VERSION=`sed -n '/^_MAKE_VERSION=/s,.*=[^0-9]*,,p' $srcdir/Makefile` +MAKE_VERSION=@_MAKE_VERSION@ MDEFS="-DMAKE_VERSION=\"$MAKE_VERSION\" \ -D@force_machine@MACHINE=\"@machine@\" -DMACHINE_ARCH=\"@machine_arch@\" \ diff --git contrib/bmake/meta.c contrib/bmake/meta.c index b8ddfb0b5e1b..4be13b5d0a97 100644 --- contrib/bmake/meta.c +++ contrib/bmake/meta.c @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.68 2017/07/09 04:54:00 sjg Exp $ */ +/* $NetBSD: meta.c,v 1.69 2017/08/10 21:07:48 sjg Exp $ */ /* * Implement 'meta' mode. @@ -250,6 +250,8 @@ meta_name(char *mname, size_t mnamelen, char *rp; char *cp; char *tp; + char *dtp; + size_t ldname; /* * Weed out relative paths from the target file name. @@ -286,10 +288,15 @@ meta_name(char *mname, size_t mnamelen, } /* on some systems dirname may modify its arg */ tp = bmake_strdup(tname); - if (strcmp(dname, dirname(tp)) == 0) + dtp = dirname(tp); + if (strcmp(dname, dtp) == 0) snprintf(mname, mnamelen, "%s.meta", tname); else { - snprintf(mname, mnamelen, "%s/%s.meta", dname, tname); + ldname = strlen(dname); + if (strncmp(dname, dtp, ldname) == 0 && dtp[ldname] == '/') + snprintf(mname, mnamelen, "%s/%s.meta", dname, &tname[ldname+1]); + else + snprintf(mname, mnamelen, "%s/%s.meta", dname, tname); /* * Replace path separators in the file name after the diff --git contrib/bmake/mk/ChangeLog contrib/bmake/mk/ChangeLog index 179d191e9008..cd473d8d07cc 100644 --- contrib/bmake/mk/ChangeLog +++ contrib/bmake/mk/ChangeLog @@ -1,3 +1,21 @@ +2017-10-25 Simon J. Gerraty <sjg@bad.crufty.net> + + * Allow for host32 on rare occasions. + +2017-10-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20171018 + + * whats.mk: include what_thing in what_uuid to avoid problem + when building multiple apps in the same directory. + +2017-08-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170812 + + * autoconf.mk: Use CONFIGURE_DEPS so Makefile can + add dependencies for config.recheck and config.gen + 2017-06-30 Simon J. Gerraty <sjg@bad.crufty.net> * install-mk (MK_VERSION): 20170630 diff --git contrib/bmake/mk/autoconf.mk contrib/bmake/mk/autoconf.mk index 573a7159957b..38f4ece48ad6 100644 --- contrib/bmake/mk/autoconf.mk +++ contrib/bmake/mk/autoconf.mk @@ -1,4 +1,4 @@ -# $Id: autoconf.mk,v 1.8 2012/11/19 05:37:48 sjg Exp $ +# $Id: autoconf.mk,v 1.9 2017/08/13 20:03:13 sjg Exp $ # # @(#) Copyright (c) 1996-2009, Simon J. Gerraty # @@ -15,8 +15,10 @@ .NOPATH: config.h config.status +CONFIGURE_DEPS += ${.CURDIR}/config.h.in ${.CURDIR}/configure + .if !target(config.h) -config.h: ${.CURDIR}/config.h.in config.status +config.h: ${CONFIGURE_DEPS} config.status ./config.status .endif @@ -28,11 +30,11 @@ config.status: config.recheck config.status: config.gen .endif -config.recheck: config.h.in ${.CURDIR}/configure +config.recheck: ${CONFIGURE_DEPS} ./config.status --recheck @touch $@ -config.gen: config.h.in ${.CURDIR}/configure +config.gen: ${CONFIGURE_DEPS} CC="${CC} ${CCMODE}" ${.CURDIR}/configure --no-create ${CONFIGURE_ARGS} @touch $@ config.recheck diff --git contrib/bmake/mk/dirdeps.mk contrib/bmake/mk/dirdeps.mk index 1ae0fbb635ab..2ff875770660 100644 --- contrib/bmake/mk/dirdeps.mk +++ contrib/bmake/mk/dirdeps.mk @@ -1,4 +1,4 @@ -# $Id: dirdeps.mk,v 1.89 2017/05/17 17:41:47 sjg Exp $ +# $Id: dirdeps.mk,v 1.90 2017/10/25 23:44:20 sjg Exp $ # Copyright (c) 2010-2013, Juniper Networks, Inc. # All rights reserved. @@ -536,10 +536,14 @@ _machines := ${DEP_MACHINE} # this is the machine list we actually use below _machines := ${_only_machines} -.if defined(HOSTPROG) || ${DEP_MACHINE} == "host" +.if defined(HOSTPROG) || ${DEP_MACHINE:Nhost*} == "" # we need to build this guy's dependencies for host as well. +.if ${DEP_MACHINE:Nhost*} == "" +_machines += ${DEP_MACHINE} +.else _machines += host .endif +.endif _machines := ${_machines:O:u} .endif diff --git contrib/bmake/mk/dpadd.mk contrib/bmake/mk/dpadd.mk index 650d61bf9a80..731b915e604f 100644 --- contrib/bmake/mk/dpadd.mk +++ contrib/bmake/mk/dpadd.mk @@ -1,4 +1,4 @@ -# $Id: dpadd.mk,v 1.23 2017/02/13 16:46:01 sjg Exp $ +# $Id: dpadd.mk,v 1.24 2017/10/25 23:44:20 sjg Exp $ # # @(#) Copyright (c) 2004, Simon J. Gerraty # @@ -195,7 +195,7 @@ __dpadd_incs += ${__dpadd_libs:O:u:@s@${SRC_LIBS_${s:T:R}:U}@:@x@${INCLUDES_${x: __dpadd_last_incs += ${__dpadd_libs:u:@x@${INCLUDES_LAST_${x:T:R}}@} __dpadd_last_incs += ${__dpadd_libs:O:u:@s@${SRC_LIBS_${s:T:R}:U}@:@x@${INCLUDES_LAST_${x:T:R}}@} -.if defined(HOSTPROG) || ${MACHINE} == "host" +.if defined(HOSTPROG) || ${MACHINE:Nhost*} == "" # we want any -I/usr/* last __dpadd_last_incs := \ ${__dpadd_last_incs:N-I/usr/*} \ diff --git contrib/bmake/mk/gendirdeps.mk contrib/bmake/mk/gendirdeps.mk index 9ac7dcdba644..66158c411ad9 100644 --- contrib/bmake/mk/gendirdeps.mk +++ contrib/bmake/mk/gendirdeps.mk @@ -1,4 +1,4 @@ -# $Id: gendirdeps.mk,v 1.33 2016/10/11 22:37:28 sjg Exp $ +# $Id: gendirdeps.mk,v 1.34 2017/10/26 00:46:26 sjg Exp $ # Copyright (c) 2010-2013, Juniper Networks, Inc. # All rights reserved. @@ -194,7 +194,7 @@ dpadd_dir_list += ${f:H:tA} .endfor .if !empty(ddep_list) ddeps != cat ${ddep_list:O:u} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \ - sed 's,//*$$,,;s,\.${HOST_TARGET}$$,.host,;s,\.${MACHINE}$$,,' + sed 's,//*$$,,;s,\.${HOST_TARGET:Uhost}$$,.host,;s,\.${HOST_TARGET32:Uhost32}$$,.host32,;s,\.${MACHINE}$$,,' .if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != "" .info ${RELDIR}: raw_dir_list='${dir_list}' diff --git contrib/bmake/mk/install-mk contrib/bmake/mk/install-mk index 0950b109a276..15486a10ce4d 100644 --- contrib/bmake/mk/install-mk +++ contrib/bmake/mk/install-mk @@ -55,7 +55,7 @@ # Simon J. Gerraty <sjg@crufty.net> # RCSid: -# $Id: install-mk,v 1.148 2017/06/30 23:46:15 sjg Exp $ +# $Id: install-mk,v 1.150 2017/10/19 03:50:51 sjg Exp $ # # @(#) Copyright (c) 1994 Simon J. Gerraty # @@ -70,7 +70,7 @@ # sjg@crufty.net # -MK_VERSION=20170630 +MK_VERSION=20171018 OWNER= GROUP= MODE=444 diff --git contrib/bmake/mk/meta.autodep.mk contrib/bmake/mk/meta.autodep.mk index 06fa98c6a5a7..10f9ca307762 100644 --- contrib/bmake/mk/meta.autodep.mk +++ contrib/bmake/mk/meta.autodep.mk @@ -1,4 +1,4 @@ -# $Id: meta.autodep.mk,v 1.45 2016/06/03 17:22:32 sjg Exp $ +# $Id: meta.autodep.mk,v 1.46 2017/10/25 23:44:20 sjg Exp $ # # @(#) Copyright (c) 2010, Simon J. Gerraty @@ -261,7 +261,7 @@ META_FILES = ${.MAKE.META.FILES:T:N.depend*:N*o.meta:O:u} \ _makesyspath:= ${_PARSEDIR} ${_DEPENDFILE}: ${_depend} ${.PARSEDIR}/gendirdeps.mk ${META2DEPS} $${.MAKE.META.CREATED} @echo Checking $@: ${.OODATE:T:[1..8]} - @(cd . && \ + @(cd . && ${GENDIRDEPS_ENV} \ SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS:O:u}' \ DPADD='${FORCE_DPADD:O:u}' ${_gendirdeps_mutex} \ MAKESYSPATH=${_makesyspath} \ diff --git contrib/bmake/mk/meta.stage.mk contrib/bmake/mk/meta.stage.mk index 03906a8d7507..5c54f81fb378 100644 --- contrib/bmake/mk/meta.stage.mk +++ contrib/bmake/mk/meta.stage.mk @@ -1,4 +1,4 @@ -# $Id: meta.stage.mk,v 1.54 2017/07/06 23:20:33 sjg Exp $ +# $Id: meta.stage.mk,v 1.55 2017/10/27 01:17:09 sjg Exp $ # # @(#) Copyright (c) 2011-2017, Simon J. Gerraty # @@ -20,9 +20,9 @@ .if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} != "" # this is generally safer anyway -_dirdep = ${RELDIR}.${MACHINE} +_dirdep ?= ${RELDIR}.${MACHINE} .else -_dirdep = ${RELDIR} +_dirdep ?= ${RELDIR} .endif CLEANFILES+= .dirdep diff --git contrib/bmake/mk/sys.clean-env.mk contrib/bmake/mk/sys.clean-env.mk index 396599bd7832..5ac74bba9342 100644 --- contrib/bmake/mk/sys.clean-env.mk +++ contrib/bmake/mk/sys.clean-env.mk @@ -1,4 +1,4 @@ -# $Id: sys.clean-env.mk,v 1.21 2016/02/18 21:16:40 sjg Exp $ +# $Id: sys.clean-env.mk,v 1.22 2017/10/25 23:44:20 sjg Exp $ # # @(#) Copyright (c) 2009, Simon J. Gerraty # @@ -97,7 +97,7 @@ _objroot := ${OBJROOT:U${SB_OBJROOT:U${SB}/${SB_OBJPREFIX}}} .if ${MAKE_VERSION} < 20160218 _objtop := ${OBJTOP:U${_objroot}${MACHINE}} # Take care of ${MACHINE} -.if ${MACHINE} == "host" || ${OBJTOP} == ${HOST_OBJTOP:Uno} +.if ${MACHINE:Nhost*} == "" || ${OBJTOP} == ${HOST_OBJTOP:Uno} OBJTOP = ${_objtop:S,${HOST_TARGET}$,\${MACHINE},} .else OBJTOP = ${_objtop:S,${MACHINE}$,\${MACHINE},} diff --git contrib/bmake/mk/whats.mk contrib/bmake/mk/whats.mk index d17c3ef290ea..4080c12e00f8 100644 --- contrib/bmake/mk/whats.mk +++ contrib/bmake/mk/whats.mk @@ -1,4 +1,4 @@ -# $Id: whats.mk,v 1.1 2014/08/30 22:40:47 sjg Exp $ +# $Id: whats.mk,v 1.3 2017/10/19 06:09:14 sjg Exp $ # # @(#) Copyright (c) 2014, Simon J. Gerraty # @@ -36,7 +36,8 @@ what_build_thing?= ${KMOD}.ko .if !empty(what_thing) # a unique name that won't conflict with anything -what_uuid = what_${.CURDIR:T:hash} +what_uuid = what_${what_thing}_${.CURDIR:T:hash} +what_var = what_${.CURDIR:T:hash} .if !empty(what_build_thing) ${what_build_thing}: ${what_build_exts:@e@${what_uuid}.$e@} @@ -57,7 +58,7 @@ _what1:= @(\#)${what_thing:tu} built ${%Y%m%d:L:localtime} by ${USER} _what2:= @(\#)${what_location} ${what_uuid}.c: - echo '${_what_t} ${what_uuid}1[] = "${_what1}";' > $@ ${.OODATE:MNO_META_CMP} - echo '${_what_t} ${what_uuid}2[] = "${_what2}";' >> $@ + echo '${_what_t} ${what_var}1[] = "${_what1}";' > $@ ${.OODATE:MNO_META_CMP} + echo '${_what_t} ${what_var}2[] = "${_what2}";' >> $@ .endif .endif diff --git contrib/bmake/os.sh contrib/bmake/os.sh index 8468ba1b3e7d..5815ea2874fb 100755 --- contrib/bmake/os.sh +++ contrib/bmake/os.sh @@ -17,7 +17,7 @@ # Simon J. Gerraty <sjg@crufty.net> # RCSid: -# $Id: os.sh,v 1.53 2017/01/11 20:01:09 sjg Exp $ +# $Id: os.sh,v 1.54 2017/09/08 06:17:22 sjg Exp $ # # @(#) Copyright (c) 1994 Simon J. Gerraty # @@ -246,5 +246,7 @@ case /$0 in echo "$v='$vv'" done ;; +*/host_target32) echo $HOST_TARGET32;; +*/host_target) echo $HOST_TARGET;; esac diff --git contrib/bmake/unit-tests/dotwait.exp contrib/bmake/unit-tests/dotwait.exp index 6bf96e301c19..bdc0a0eb1504 100644 --- contrib/bmake/unit-tests/dotwait.exp +++ contrib/bmake/unit-tests/dotwait.exp @@ -22,9 +22,9 @@ shared.2.1 shared.2.1 shared.2.99 shared.2.99 +cycle.1.99 +cycle.1.99 make: Graph cycles through `cycle.2.99' make: Graph cycles through `cycle.2.98' make: Graph cycles through `cycle.2.97' -cycle.1.99 -cycle.1.99 exit status 0 diff --git contrib/bmake/unit-tests/dotwait.mk contrib/bmake/unit-tests/dotwait.mk index 9bdaaba399d1..bab5993e7481 100644 --- contrib/bmake/unit-tests/dotwait.mk +++ contrib/bmake/unit-tests/dotwait.mk @@ -1,4 +1,4 @@ -# $NetBSD: dotwait.mk,v 1.1 2014/08/21 13:44:51 apb Exp $ +# $NetBSD: dotwait.mk,v 1.2 2017/10/08 20:44:19 sjg Exp $ THISMAKEFILE:= ${.PARSEDIR}/${.PARSEFILE} @@ -11,7 +11,7 @@ PAUSE= sleep 1 # Ignore "--- target ---" lines printed by parallel make. all: .for t in ${TESTS} - @${.MAKE} -f ${THISMAKEFILE} -j4 $t | grep -v "^--- " + @${.MAKE} -f ${THISMAKEFILE} -j4 $t 2>&1 | grep -v "^--- " .endfor # diff --git contrib/compiler-rt/lib/builtins/arm/aeabi_dcmp.S contrib/compiler-rt/lib/builtins/arm/aeabi_dcmp.S index 51539c0ac813..9fa78b461248 100644 --- contrib/compiler-rt/lib/builtins/arm/aeabi_dcmp.S +++ contrib/compiler-rt/lib/builtins/arm/aeabi_dcmp.S @@ -18,11 +18,20 @@ // } // } +#if defined(COMPILER_RT_ARMHF_TARGET) +# define CONVERT_DCMP_ARGS_TO_DF2_ARGS \ + vmov d0, r0, r1 SEPARATOR \ + vmov d1, r2, r3 +#else +# define CONVERT_DCMP_ARGS_TO_DF2_ARGS +#endif + #define DEFINE_AEABI_DCMP(cond) \ .syntax unified SEPARATOR \ .p2align 2 SEPARATOR \ DEFINE_COMPILERRT_FUNCTION(__aeabi_dcmp ## cond) \ push { r4, lr } SEPARATOR \ + CONVERT_DCMP_ARGS_TO_DF2_ARGS SEPARATOR \ bl SYMBOL_NAME(__ ## cond ## df2) SEPARATOR \ cmp r0, #0 SEPARATOR \ b ## cond 1f SEPARATOR \ diff --git contrib/compiler-rt/lib/builtins/arm/aeabi_fcmp.S contrib/compiler-rt/lib/builtins/arm/aeabi_fcmp.S index 8e7774b58974..ea5b96c21d57 100644 --- contrib/compiler-rt/lib/builtins/arm/aeabi_fcmp.S +++ contrib/compiler-rt/lib/builtins/arm/aeabi_fcmp.S @@ -18,11 +18,20 @@ // } // } +#if defined(COMPILER_RT_ARMHF_TARGET) +# define CONVERT_FCMP_ARGS_TO_SF2_ARGS \ + vmov s0, r0 SEPARATOR \ + vmov s1, r1 +#else +# define CONVERT_FCMP_ARGS_TO_SF2_ARGS +#endif + #define DEFINE_AEABI_FCMP(cond) \ .syntax unified SEPARATOR \ .p2align 2 SEPARATOR \ DEFINE_COMPILERRT_FUNCTION(__aeabi_fcmp ## cond) \ push { r4, lr } SEPARATOR \ + CONVERT_FCMP_ARGS_TO_SF2_ARGS SEPARATOR \ bl SYMBOL_NAME(__ ## cond ## sf2) SEPARATOR \ cmp r0, #0 SEPARATOR \ b ## cond 1f SEPARATOR \ diff --git contrib/compiler-rt/lib/builtins/int_lib.h contrib/compiler-rt/lib/builtins/int_lib.h index 5021b82f3cc2..97ca42e0023d 100644 --- contrib/compiler-rt/lib/builtins/int_lib.h +++ contrib/compiler-rt/lib/builtins/int_lib.h @@ -92,12 +92,13 @@ * does not have dedicated bit counting instructions. */ #if defined(__FreeBSD__) && (defined(__sparc64__) || \ - defined(__mips_n64) || defined(__mips_o64) || defined(__riscv)) + defined(__mips_n32) || defined(__mips_n64) || defined(__mips_o64) || \ + defined(__riscv)) si_int __clzsi2(si_int); si_int __ctzsi2(si_int); #define __builtin_clz __clzsi2 #define __builtin_ctz __ctzsi2 -#endif /* FreeBSD && (sparc64 || mips_n64 || mips_o64) */ +#endif /* FreeBSD && (sparc64 || mips_n32 || mips_n64 || mips_o64 || riscv) */ COMPILER_RT_ABI si_int __paritysi2(si_int a); COMPILER_RT_ABI si_int __paritydi2(di_int a); diff --git contrib/compiler-rt/lib/esan/esan_sideline_linux.cpp contrib/compiler-rt/lib/esan/esan_sideline_linux.cpp index d04f5909d6a2..bc272dfe49f8 100644 --- contrib/compiler-rt/lib/esan/esan_sideline_linux.cpp +++ contrib/compiler-rt/lib/esan/esan_sideline_linux.cpp @@ -70,7 +70,7 @@ int SidelineThread::runSideline(void *Arg) { // Set up a signal handler on an alternate stack for safety. InternalScopedBuffer<char> StackMap(SigAltStackSize); - struct sigaltstack SigAltStack; + stack_t SigAltStack; SigAltStack.ss_sp = StackMap.data(); SigAltStack.ss_size = SigAltStackSize; SigAltStack.ss_flags = 0; diff --git contrib/compiler-rt/lib/profile/InstrProfilingNameVar.c contrib/compiler-rt/lib/profile/InstrProfilingNameVar.c index a0c448c679b5..264568fbc912 100644 --- contrib/compiler-rt/lib/profile/InstrProfilingNameVar.c +++ contrib/compiler-rt/lib/profile/InstrProfilingNameVar.c @@ -1,11 +1,11 @@ -//===- InstrProfilingNameVar.c - profile name variable setup --------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// +/*===- InstrProfilingNameVar.c - profile name variable setup -------------===*\ +|* +|* The LLVM Compiler Infrastructure +|* +|* This file is distributed under the University of Illinois Open Source +|* License. See LICENSE.TXT for details. +|* +\*===----------------------------------------------------------------------===*/ #include "InstrProfiling.h" diff --git contrib/cortex-strings/src/aarch64/memcpy.S contrib/cortex-strings/src/aarch64/memcpy.S index cbae37121844..46fb166e345e 100644 --- contrib/cortex-strings/src/aarch64/memcpy.S +++ contrib/cortex-strings/src/aarch64/memcpy.S @@ -77,8 +77,8 @@ #define D_h x13 #define E_l src #define E_h count -#define F_l srcend -#define F_h dst +#define F_l dst +#define F_h srcend #define tmp1 x9 #define L(l) .L ## l diff --git contrib/dma/dma.c contrib/dma/dma.c index 62b1bad4d754..b553c0fa0eef 100644 --- contrib/dma/dma.c +++ contrib/dma/dma.c @@ -331,8 +331,8 @@ retry: switch (error) { case 0: - delqueue(it); syslog(LOG_INFO, "<%s> delivery successful", it->addr); + delqueue(it); exit(EX_OK); case 1: diff --git contrib/elftoolchain/readelf/readelf.c contrib/elftoolchain/readelf/readelf.c index 2657ed9518e9..46fe8025bc7b 100644 --- contrib/elftoolchain/readelf/readelf.c +++ contrib/elftoolchain/readelf/readelf.c @@ -1141,7 +1141,9 @@ note_type_freebsd_core(unsigned int nt) case 14: return "NT_PROCSTAT_OSREL"; case 15: return "NT_PROCSTAT_PSSTRINGS"; case 16: return "NT_PROCSTAT_AUXV"; + case 17: return "NT_PTLWPINFO"; case 0x202: return "NT_X86_XSTATE (x86 XSAVE extended state)"; + case 0x400: return "NT_ARM_VFP (arm VFP registers)"; default: return (note_type_unknown(nt)); } } @@ -2693,6 +2695,9 @@ dump_arch_dyn_val(struct readelf *re, GElf_Dyn *dyn) case DT_MIPS_TIME_STAMP: printf(" %s\n", timestamp(dyn->d_un.d_val)); break; + default: + printf("\n"); + break; } break; default: diff --git contrib/file/ChangeLog contrib/file/ChangeLog index 2b6606d2979b..2063a23befed 100644 --- contrib/file/ChangeLog +++ contrib/file/ChangeLog @@ -1,6 +1,60 @@ +2017-09-02 11:53 Christos Zoulas <christos@zoulas.com> + + * release 5.32 + +2017-08-28 16:37 Christos Zoulas <christos@zoulas.com> + + * Always reset state in {file,buffer}_apprentice (Krzysztof Wilczynski) + +2017-08-27 03:55 Christos Zoulas <christos@zoulas.com> + + * Fix always true condition (Thomas Jarosch) + +2017-05-24 17:30 Christos Zoulas <christos@zoulas.com> + + * pickier parsing of numeric values in magic files. + +2017-05-23 17:55 Christos Zoulas <christos@zoulas.com> + + * PR/615 add magic_getflags() + +2017-05-23 13:55 Christos Zoulas <christos@zoulas.com> + + * release 5.31 + +2017-03-17 20:32 Christos Zoulas <christos@zoulas.com> + + * remove trailing spaces from magic files + * refactor is_tar + * better bounds checks for cdf + +2017-02-10 12:24 Christos Zoulas <christos@zoulas.com> + + * release 5.30 + +2017-02-07 23:27 Christos Zoulas <christos@zoulas.com> + + * If we exceeded the offset in a search return no match + (Christoph Biedl) + * Be more lenient on corrupt CDF files (Christoph Biedl) + +2017-02-04 16:46 Christos Zoulas <christos@zoulas.com> + + * pacify ubsan sign extension (oss-fuzz/524) + +2017-02-01 12:42 Christos Zoulas <christos@zoulas.com> + + * off by one in cdf parsing (PR/593) + * report debugging sections in elf (PR/591) + +2016-11-06 10:52 Christos Zoulas <christos@zoulas.com> + + * Allow @@@ in extensions + * Add missing overflow check in der magic (Jonas Wagner) + 2016-10-25 10:40 Christos Zoulas <christos@zoulas.com> - * release 5.28 + * release 5.29 2016-10-24 11:20 Christos Zoulas <christos@zoulas.com> @@ -387,7 +441,7 @@ ` 2013-11-06 14:40 Christos Zoulas <christos@zoulas.com> - * fix erroneous non-zero exit code from non-existant file and message + * fix erroneous non-zero exit code from non-existent file and message 2013-10-29 14:25 Christos Zoulas <christos@zoulas.com> diff --git contrib/file/aclocal.m4 contrib/file/aclocal.m4 index 4398374d8259..158e1494b339 100644 --- contrib/file/aclocal.m4 +++ contrib/file/aclocal.m4 @@ -21,7 +21,7 @@ If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # visibility.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2005, 2008, 2010-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2008, 2010-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git contrib/file/config.guess contrib/file/config.guess index f7eb141e75a9..bbd48b60e88b 100755 --- contrib/file/config.guess +++ contrib/file/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2017 Free Software Foundation, Inc. -timestamp='2015-03-04' +timestamp='2017-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ timestamp='2015-03-04' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to <config-patches@gnu.org>. @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -186,9 +186,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. + # to ELF recently (or will in the future) and ABI. case "${UNAME_MACHINE_ARCH}" in - arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ @@ -221,7 +224,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: @@ -237,6 +240,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} + exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; @@ -249,6 +256,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; + *:Sortix:*:*) + echo ${UNAME_MACHINE}-unknown-sortix + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) @@ -265,42 +275,42 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 @@ -373,16 +383,16 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build - SUN_ARCH="i386" + SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` @@ -407,7 +417,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} @@ -632,13 +642,13 @@ EOF sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi @@ -677,11 +687,11 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if [ ${HP_ARCH} = hppa2.0w ] then eval $set_cc_for_build @@ -694,12 +704,12 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} @@ -804,14 +814,14 @@ EOF echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) @@ -893,7 +903,7 @@ EOF exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix @@ -916,7 +926,7 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) @@ -962,6 +972,9 @@ EOF ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; + k1om:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; @@ -987,6 +1000,9 @@ EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; + mips64el:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; @@ -1019,6 +1035,9 @@ EOF ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; @@ -1038,7 +1057,7 @@ EOF echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} @@ -1117,7 +1136,7 @@ EOF # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that + # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; @@ -1266,6 +1285,9 @@ EOF SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux${UNAME_RELEASE} + exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; @@ -1279,9 +1301,9 @@ EOF UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in @@ -1303,7 +1325,7 @@ EOF exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi @@ -1334,7 +1356,7 @@ EOF # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" @@ -1376,7 +1398,7 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos @@ -1387,23 +1409,25 @@ EOF x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; esac cat >&2 <<EOF $0: unable to guess system type -This script, last modified $timestamp, has failed to recognize -the operating system you are using. It is advised that you -download the most up to date version of the config scripts from +This script (version $timestamp), has failed to recognize the +operating system you are using. If your script is old, overwrite +config.guess and config.sub with the latest versions from: - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess and - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub -If the version you run ($0) is already up to date, please -send the following data and any information you think might be -pertinent to <config-patches@gnu.org> in order to provide the needed -information to handle your system. +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp diff --git contrib/file/config.sub contrib/file/config.sub index 8f1229c6f7dd..7e792b4ae17b 100755 --- contrib/file/config.sub +++ contrib/file/config.sub @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2017 Free Software Foundation, Inc. -timestamp='2015-03-08' +timestamp='2017-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ timestamp='2015-03-08' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -53,8 +53,7 @@ timestamp='2015-03-08' me=`echo "$0" | sed -e 's,.*/,,'` usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. @@ -68,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -118,7 +117,7 @@ case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` @@ -255,6 +254,7 @@ case $basic_machine in | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ + | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ @@ -301,11 +301,12 @@ case $basic_machine in | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ @@ -376,6 +377,7 @@ case $basic_machine in | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ @@ -427,13 +429,15 @@ case $basic_machine in | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ | pyramid-* \ + | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ @@ -518,7 +522,7 @@ case $basic_machine in basic_machine=i386-pc os=-aros ;; - asmjs) + asmjs) basic_machine=asmjs-unknown ;; aux) @@ -641,6 +645,14 @@ case $basic_machine in basic_machine=m68k-bull os=-sysv3 ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + os=$os"spe" + ;; ebmon29k) basic_machine=a29k-amd os=-ebmon @@ -1020,7 +1032,7 @@ case $basic_machine in ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle | ppc-le | powerpc-little) + ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) @@ -1030,7 +1042,7 @@ case $basic_machine in ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) + ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) @@ -1376,18 +1388,18 @@ case $os in | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* | -cloudabi* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ + | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ + | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ @@ -1396,7 +1408,8 @@ case $os in | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1528,6 +1541,8 @@ case $os in ;; -nacl*) ;; + -ios) + ;; -none) ;; *) @@ -1623,6 +1638,9 @@ case $basic_machine in sparc-* | *-sun) os=-sunos4.1.1 ;; + pru-*) + os=-elf + ;; *-be) os=-beos ;; diff --git contrib/file/configure contrib/file/configure index 47f7cbfb8587..eaf97ab0622e 100755 --- contrib/file/configure +++ contrib/file/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for file 5.29. +# Generated by GNU Autoconf 2.69 for file 5.32. # # Report bugs to <christos@astron.com>. # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='file' PACKAGE_TARNAME='file' -PACKAGE_VERSION='5.29' -PACKAGE_STRING='file 5.29' +PACKAGE_VERSION='5.32' +PACKAGE_STRING='file 5.32' PACKAGE_BUGREPORT='christos@astron.com' PACKAGE_URL='' @@ -1328,7 +1328,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures file 5.29 to adapt to many kinds of systems. +\`configure' configures file 5.32 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1398,7 +1398,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of file 5.29:";; + short | recursive ) echo "Configuration of file 5.32:";; esac cat <<\_ACEOF @@ -1509,7 +1509,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -file configure 5.29 +file configure 5.32 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2165,7 +2165,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by file $as_me 5.29, which was +It was created by file $as_me 5.32, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3031,7 +3031,7 @@ fi # Define the identity of the package. PACKAGE='file' - VERSION='5.29' + VERSION='5.32' cat >>confdefs.h <<_ACEOF @@ -15075,7 +15075,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by file $as_me 5.29, which was +This file was extended by file $as_me 5.32, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15141,7 +15141,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -file config.status 5.29 +file config.status 5.32 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git contrib/file/configure.ac contrib/file/configure.ac index da2fbbf5fbfa..946198be643d 100644 --- contrib/file/configure.ac +++ contrib/file/configure.ac @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([file],[5.29],[christos@astron.com]) +AC_INIT([file],[5.32],[christos@astron.com]) AM_INIT_AUTOMAKE([subdir-objects foreign]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) diff --git contrib/file/doc/file.man contrib/file/doc/file.man index 6b9abdac87cd..321c995c7c76 100644 --- contrib/file/doc/file.man +++ contrib/file/doc/file.man @@ -1,4 +1,4 @@ -.\" $File: file.man,v 1.124 2016/10/19 20:52:45 christos Exp $ +.\" $File: file.man,v 1.125 2017/01/03 11:24:46 christos Exp $ .Dd October 19, 2016 .Dt FILE __CSECTION__ .Os @@ -238,8 +238,8 @@ or at least one filename argument must be present; to test the standard input, use .Sq - as a filename argument. -Please note that -.Ar namefile +Please note that +.Ar namefile is unwrapped and the enclosed filenames are processed when this option is encountered and before any further options processing is done. This allows one to process multiple lists of files with different command line @@ -411,10 +411,10 @@ and .Fl h options. .Sh SEE ALSO -.Xr magic __FSECTION__ , .Xr hexdump 1 , .Xr od 1 , .Xr strings 1 , +.Xr magic __FSECTION__ , .Xr fstyp 8 .Sh STANDARDS CONFORMANCE This program is believed to exceed the System V Interface Definition @@ -531,16 +531,15 @@ John Gilmore revised the code extensively, making it better than the first version. Geoff Collyer found several inadequacies and provided some magic file entries. -Contributions by the +Contributions of the .Sq \*[Am] operator by Rob McMahon, .Aq cudcv@warwick.ac.uk , 1989. .Pp -Guy Harris, +Guy Harris, .Aq guy@netapp.com , made many changes from 1993 to the present. -1989. .Pp Primary development and maintenance from 1990 to the present by Christos Zoulas @@ -588,7 +587,6 @@ program, and are not covered by the above license. .Nm returns 0 on success, and non-zero on error. .Sh BUGS -.Pp Please report bugs and send patches to the bug tracker at .Pa http://bugs.gw.com/ or the mailing list at @@ -597,7 +595,6 @@ or the mailing list at .Pa http://mx.gw.com/mailman/listinfo/file first to subscribe). .Sh TODO -.Pp Fix output so that tests for MIME and APPLE flags are not needed all over the place, and actual output is only done in one place. This needs a design. @@ -646,16 +643,16 @@ Fix .Dq name and .Dq use -to check for consistency at compile time (duplicate +to check for consistency at compile time (duplicate .Dq name , .Dq use pointing to undefined .Dq name ). -Make +Make .Dq name / -.Dq use +.Dq use more efficient by keeping a sorted list of names. Special-case ^ to flip endianness in the parser so that it does not have to be escaped, and document it. diff --git contrib/file/doc/libmagic.man contrib/file/doc/libmagic.man index a3de98139c21..4c7e42ff4f9c 100644 --- contrib/file/doc/libmagic.man +++ contrib/file/doc/libmagic.man @@ -1,4 +1,4 @@ -.\" $File: libmagic.man,v 1.40 2016/03/31 17:51:12 christos Exp $ +.\" $File: libmagic.man,v 1.41 2017/05/23 21:54:07 christos Exp $ .\" .\" Copyright (c) Christos Zoulas 2003. .\" All Rights Reserved. @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 11, 2015 +.Dd May 23, 2017 .Dt LIBMAGIC 3 .Os .Sh NAME @@ -35,6 +35,7 @@ .Nm magic_errno , .Nm magic_descriptor , .Nm magic_buffer , +.Nm magic_getflags , .Nm magic_setflags , .Nm magic_check , .Nm magic_compile , @@ -64,6 +65,8 @@ .Ft const char * .Fn magic_buffer "magic_t cookie" "const void *buffer" "size_t length" .Ft int +.Fn magic_getflags "magic_t cookie" +.Ft int .Fn magic_setflags "magic_t cookie" "int flags" .Ft int .Fn magic_check "magic_t cookie" "const char *filename" @@ -206,6 +209,12 @@ argument with bytes size. .Pp The +.Fn magic_getflags +functions returns a value representing current +.Ar flags +set. +.Pp +The .Fn magic_setflags function sets the .Ar flags diff --git contrib/file/doc/magic.man contrib/file/doc/magic.man index bc374040dc2f..4c69bca2ab24 100644 --- contrib/file/doc/magic.man +++ contrib/file/doc/magic.man @@ -1,5 +1,5 @@ -.\" $File: magic.man,v 1.88 2016/07/27 09:42:49 rrt Exp $ -.Dd July 20, 2016 +.\" $File: magic.man,v 1.91 2017/02/12 15:30:08 christos Exp $ +.Dd February 12, 2017 .Dt MAGIC __FSECTION__ .Os .\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems. @@ -7,7 +7,7 @@ .Nm magic .Nd file command's magic pattern file .Sh DESCRIPTION -This manual page documents the format of the magic file as +This manual page documents the format of magic files as used by the .Xr file __CSECTION__ command, version __VERSION__. @@ -17,13 +17,19 @@ command identifies the type of a file using, among other tests, a test for whether the file contains certain .Dq "magic patterns" . -The file -.Pa __MAGIC__ -specifies what patterns are to be tested for, what message or +The database of these +.Dq "magic patterns" +is usually located in a binary file in +.Pa __MAGIC__.mgc +or a directory of source text magic pattern fragment files in +.Pa __MAGIC__ . +The database specifies what patterns are to be tested for, what message or MIME type to print if a particular pattern is found, and additional information to extract from the file. .Pp -Each line of the file specifies a test to be performed. +The format of the source fragment files that are used to build this database +is as follows: +Each line of a fragment file specifies a test to be performed. A test compares the data starting at a particular offset in the file with a byte value, a string or a numeric value. If the test succeeds, a message is printed. @@ -98,13 +104,13 @@ The following modifiers are supported: .It B A byte length (default). .It H -A 2 byte big endian length. +A 4 byte big endian length. .It h -A 2 byte big little length. +A 2 byte big endian length. .It L -A 4 byte big endian length. +A 4 byte little endian length. .It l -A 4 byte big little length. +A 2 byte little endian length. .It J The length includes itself in its count. .El @@ -651,7 +657,7 @@ start of the main indirect offset. \*[Gt]\*[Gt]\*[Gt]\*[Gt](\*[Am]0xe.l+(-4)) string PK\e3\e4 \eb, ZIP self-extracting archive .Ed .Pp -If you have a list of known avalues at a particular continuation level, +If you have a list of known values at a particular continuation level, and you want to provide a switch-like default case: .Bd -literal -offset indent # clear that continuation level match diff --git contrib/file/magic/Localstuff contrib/file/magic/Localstuff index 419855fb6220..aef809524b80 100644 --- contrib/file/magic/Localstuff +++ contrib/file/magic/Localstuff @@ -2,6 +2,6 @@ #------------------------------------------------------------------------------ # Localstuff: file(1) magic for locally observed files # -# $File: Localstuff,v 1.4 2003/03/23 04:17:27 christos Exp $ +# $File: Localstuff,v 1.5 2007/01/12 17:38:27 christos Exp $ # Add any locally observed files here. Remember: # text if readable, executable if runnable binary, data if unreadable. diff --git contrib/file/magic/Magdir/adventure contrib/file/magic/Magdir/adventure index 94835e11ed39..6fae85adfd40 100644 --- contrib/file/magic/Magdir/adventure +++ contrib/file/magic/Magdir/adventure @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: adventure,v 1.15 2015/09/07 10:03:21 christos Exp $ +# $File: adventure,v 1.17 2017/07/03 16:03:40 christos Exp $ # adventure: file(1) magic for Adventure game files # # from Allen Garvin <earendil@faeryland.tamu-commerce.edu> @@ -36,11 +36,12 @@ >0 ubyte <9 >>16 belong&0xfe00f0f0 0x3030 >>>0 ubyte < 10 ->>>>2 ubeshort < 10 +>>>>2 ubeshort x >>>>>18 regex [0-9][0-9][0-9][0-9][0-9][0-9] ->>>>>>0 ubyte < 10 Infocom (Z-machine %d, ->>>>>>>2 ubeshort < 10 Release %d / ->>>>>>>>18 string >\0 Serial %.6s) +>>>>>>0 ubyte < 10 Infocom (Z-machine %d +>>>>>>>2 ubeshort x \b, Release %d +>>>>>>>>18 string >\0 \b, Serial %.6s +>>>>>>>>18 string x \b) !:strength + 40 !:mime application/x-zmachine @@ -78,7 +79,7 @@ !:mime application/x-tads # Some saved game files start with "TADS2 save/g\n\r\032\0", a little-endian # 2-byte length N, the N-char name of the game file *without* a NUL (darn!), -# "TADS2 save\n\r\032\0" and the interpreter version. +# "TADS2 save\n\r\032\0" and the interpreter version. 0 string TADS2\ save/g TADS >12 belong !0x0A0D1A00 saved game data, CORRUPTED >12 belong 0x0A0D1A00 @@ -109,7 +110,7 @@ # edited by David Griffith <dave@661.org> # Danny Milosavljevic <danny.milo@gmx.net> # These are ADRIFT (adventure game standard) game files, extension .taf -# Checked from source at (http://www.adrift.co/) and various taf files +# Checked from source at (http://www.adrift.co/) and various taf files # found at the Interactive Fiction Archive (http://ifarchive.org/) 0 belong 0x3C423FC9 >4 belong 0x6A87C2CF Adrift game file version diff --git contrib/file/magic/Magdir/amanda contrib/file/magic/Magdir/amanda index 395ef545c2ba..e7fa53901388 100644 --- contrib/file/magic/Magdir/amanda +++ contrib/file/magic/Magdir/amanda @@ -1,9 +1,9 @@ #------------------------------------------------------------------------------ -# $File: amanda,v 1.5 2009/09/19 16:28:07 christos Exp $ +# $File: amanda,v 1.6 2017/03/17 21:35:28 christos Exp $ # amanda: file(1) magic for amanda file format # -0 string AMANDA:\ AMANDA +0 string AMANDA:\ AMANDA >8 string TAPESTART\ DATE tape header file, >>23 string X >>>25 string >\ Unused %s diff --git contrib/file/magic/Magdir/amigaos contrib/file/magic/Magdir/amigaos index 8fdf37662c57..d9330bd1493c 100644 --- contrib/file/magic/Magdir/amigaos +++ contrib/file/magic/Magdir/amigaos @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: amigaos,v 1.15 2012/06/21 01:13:59 christos Exp $ +# $File: amigaos,v 1.16 2017/03/17 21:35:28 christos Exp $ # amigaos: file(1) magic for AmigaOS binary formats: # @@ -11,7 +11,7 @@ 0 belong 0x000003e7 AmigaOS object/library data # 0 beshort 0xe310 Amiga Workbench ->2 beshort 1 +>2 beshort 1 >>48 byte 1 disk icon >>48 byte 2 drawer icon >>48 byte 3 tool icon @@ -49,7 +49,7 @@ 0 string/c @database AmigaGuide file # Amiga disk types -# +# 0 string RDSK Rigid Disk Block >160 string x on %.24s 0 string DOS\0 Amiga DOS disk diff --git contrib/file/magic/Magdir/android contrib/file/magic/Magdir/android index f1340d53a38b..dca5c33482bf 100644 --- contrib/file/magic/Magdir/android +++ contrib/file/magic/Magdir/android @@ -1,6 +1,6 @@ #------------------------------------------------------------ -# $File: android,v 1.9 2016/01/11 21:19:18 christos Exp $ +# $File: android,v 1.10 2017/03/17 21:35:28 christos Exp $ # Various android related magic entries #------------------------------------------------------------ @@ -61,9 +61,9 @@ # http://forum.xda-developers.com/showthread.php?t=816449 # Partition Information Table for Samsung's smartphone with Android # used by flash software Odin -0 ulelong 0x12349876 +0 ulelong 0x12349876 # 1st pit entry marker ->0x01C ulequad&0xFFFFFFFCFFFFFFFC =0x0000000000000000 +>0x01C ulequad&0xFFFFFFFCFFFFFFFC =0x0000000000000000 # minimal 13 and maximal 18 PIT entries found >>4 ulelong <128 Partition Information Table for Samsung smartphone >>>4 ulelong x \b, %d entries @@ -109,9 +109,9 @@ 0 name PIT-entry # garbage value implies end of pit entries ->0x00 ulequad&0xFFFFFFFCFFFFFFFC =0x0000000000000000 +>0x00 ulequad&0xFFFFFFFCFFFFFFFC =0x0000000000000000 # skip empty partition name ->>0x24 ubyte !0 +>>0x24 ubyte !0 # partition name >>>0x24 string >\0 %-.32s # flags @@ -122,7 +122,7 @@ >>>0x08 ulelong x (0x%x) # filename >>>0x44 string >\0 "%-.64s" -#>>>0x18 ulelong >0 +#>>>0x18 ulelong >0 # blocksize in 512 byte units ? #>>>>0x18 ulelong x \b, %db # partition size in blocks ? diff --git contrib/file/magic/Magdir/animation contrib/file/magic/Magdir/animation index faa839e8783b..a6e50ff86b09 100644 --- contrib/file/magic/Magdir/animation +++ contrib/file/magic/Magdir/animation @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: animation,v 1.58 2016/07/03 14:13:11 christos Exp $ +# $File: animation,v 1.63 2017/05/26 14:33:07 christos Exp $ # animation: file(1) magic for animation/movie formats # # animation formats @@ -34,14 +34,23 @@ !:mime image/jp2 # http://www.ftyps.com/ with local additions 4 string ftyp ISO Media +# http://aeroquartet.com/wordpress/2016/03/05/3-xavc-s/ +>8 string XAVC \b, MPEG v4 system, Sony XAVC Codec +>>96 string x \b, Audio "%.4s" +>>118 beshort x at %dHz +>>140 string x \b, Video "%.4s" +>>168 beshort x %d +>>170 beshort x \bx%d >8 string 3g2 \b, MPEG v4 system, 3GPP2 !:mime video/3gpp2 >>11 byte 4 \b v4 (H.263/AMR GSM 6.10) >>11 byte 5 \b v5 (H.263/AMR GSM 6.10) >>11 byte 6 \b v6 (ITU H.264/AMR GSM 6.10) ->>11 byte a \b C.S0050-0 V1.0 ->>11 byte b \b C.S0050-0-A V1.0.0 ->>11 byte c \b C.S0050-0-B V1.0 +# http://www.3gpp2.org/Public_html/Specs/C.S0050-B_v1.0_070521.pdf +# Section 8.1.1, corresponds to a, b, c +>>11 byte 0x61 \b C.S0050-0 V1.0 +>>11 byte 0x62 \b C.S0050-0-A V1.0.0 +>>11 byte 0x63 \b C.S0050-0-B V1.0 >8 string 3ge \b, MPEG v4 system, 3GPP !:mime video/3gpp >>11 byte 6 \b, Release 6 MBMS Extended Presentations @@ -186,13 +195,13 @@ # MPEG sequences # Scans for all common MPEG header start codes -0 belong 0x00000001 +0 belong 0x00000001 >4 byte&0x1F 0x07 JVT NAL sequence, H.264 video >>5 byte 66 \b, baseline >>5 byte 77 \b, main >>5 byte 88 \b, extended >>7 byte x \b @ L %u -0 belong&0xFFFFFF00 0x00000100 +0 belong&0xFFFFFF00 0x00000100 >3 byte 0xBA MPEG sequence !:mime video/mpeg >>4 byte &0x40 \b, v2, program multiplex @@ -493,8 +502,8 @@ # GRR the original test are too common for many DOS files, so test 32 <= kbits <= 448 # GRR this test is still too general as it catches a BOM of UTF-16 files (0xFFFE) # FIXME: Almost all little endian UTF-16 text with BOM are clobbered by these entries -#0 beshort&0xFFFE 0xFFFE -#>2 ubyte&0xF0 >0x0F +#0 beshort&0xFFFE 0xFFFE +#>2 ubyte&0xF0 >0x0F #>>2 ubyte&0xF0 <0xE1 MPEG ADTS, layer I, v1 ## rate #>>>2 byte&0xF0 0x10 \b, 32 kbps @@ -566,9 +575,9 @@ # MP2, M2A 0 beshort&0xFFFE 0xFFF4 MPEG ADTS, layer II, v2 !:mime audio/mpeg -# rate +# rate >2 byte&0xF0 0x10 \b, 8 kbps ->2 byte&0xF0 0x20 \b, 16 kbps +>2 byte&0xF0 0x20 \b, 16 kbps >2 byte&0xF0 0x30 \b, 24 kbps >2 byte&0xF0 0x40 \b, 32 kbps >2 byte&0xF0 0x50 \b, 40 kbps @@ -636,7 +645,7 @@ # MP3, M25A 0 beshort&0xFFFE 0xFFE2 MPEG ADTS, layer III, v2.5 !:mime audio/mpeg -# rate +# rate >2 byte&0xF0 0x10 \b, 8 kbps >2 byte&0xF0 0x20 \b, 16 kbps >2 byte&0xF0 0x30 \b, 24 kbps @@ -855,10 +864,12 @@ # X3D (Extensible 3D) [http://www.web3d.org/specifications/x3d-3.0.dtd] # From Michel Briand <michelbriand@free.fr> -0 string/t \<?xml\ version=" -!:strength +1 ->20 search/1000/cw \<!DOCTYPE\ X3D X3D (Extensible 3D) model xml text -!:mime model/x3d +# mimetype from https://www.iana.org/assignments/media-types/model/x3d+xml +# Example http://www.web3d.org/x3d/content/examples/Basic/course/CreateX3DFromStringRandomSpheres.x3d +0 string/w \<?xml\ version= +!:strength + 5 +>20 search/1000/w \<!DOCTYPE\ X3D X3D (Extensible 3D) model xml text +!:mime model/x3d+xml #--------------------------------------------------------------------------- # HVQM4: compressed movie format designed by Hudson for Nintendo GameCube diff --git contrib/file/magic/Magdir/apache contrib/file/magic/Magdir/apache new file mode 100755 index 000000000000..d896b5055127 --- /dev/null +++ contrib/file/magic/Magdir/apache @@ -0,0 +1,28 @@ + +#------------------------------------------------------------------------------ +# $File: apache,v 1.1 2017/04/11 14:52:15 christos Exp $ +# apache: file(1) magic for Apache Big Data formats + +# Avro files +0 string Obj Apache Avro +>3 byte x version %d + +# ORC files +# Important information is in file footer, which we can't index to :( +0 string ORC Apache ORC + +# Parquet files +0 string PAR1 Apache Parquet + +# Hive RC files +0 string RCF Apache Hive RC file +>3 byte x version %d + +# Sequence files (and the careless first version of RC file) + +0 string SEQ +>3 byte <6 Apache Hadoop Sequence file version %d +>3 byte >6 Apache Hadoop Sequence file version %d +>3 byte =6 +>>5 string org.apache.hadoop.hive.ql.io.RCFile$KeyBuffer Apache Hive RC file version 0 +>>3 default x Apache Hadoop Sequence file version 6 diff --git contrib/file/magic/Magdir/apple contrib/file/magic/Magdir/apple index ce03298f95f2..391205f265fc 100644 --- contrib/file/magic/Magdir/apple +++ contrib/file/magic/Magdir/apple @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: apple,v 1.35 2016/08/17 09:45:13 christos Exp $ +# $File: apple,v 1.36 2017/03/17 21:35:28 christos Exp $ # apple: file(1) magic for Apple file formats # 0 search/1/t FiLeStArTfIlEsTaRt binscii (apple ][) text @@ -67,15 +67,15 @@ # AppleWorks word processor: # URL: https://en.wikipedia.org/wiki/AppleWorks # Reference: http://www.gno.org/pub/apple2/doc/apple/filetypes/ftn.1a.xxxx -# Update: Joerg Jenderek +# Update: Joerg Jenderek # NOTE: # The "O" is really the magic number, but that's so common that it's # necessary to check the tab stops that follow it to avoid false positives. # and/or look for unused bits of booleans bytes like zoom, paginated, mail merge # the newer AppleWorks is from claris with extension CWK -4 string O +4 string O # test for unused bits of zoom- , paginated-boolean bytes ->84 ubequad ^0x00Fe00000000Fe00 +>84 ubequad ^0x00Fe00000000Fe00 # look for tabstop definitions "=" no tab, "|" no tab # "<" left tab,"^" center tab,">" right tab, "." decimal tab, # unofficial "!" other , "\x8a" other @@ -92,9 +92,9 @@ !:ext awp # minimum version needed to read this files. SFMinVers (0 , 30~3.0 ) >>>183 ubyte 30 3.0 ->>>183 ubyte !30 +>>>183 ubyte !30 >>>>183 ubyte !0 0x%x -# usual tabstop start sequence "=====<" +# usual tabstop start sequence "=====<" >>>5 string x \b, tabstop ruler "%6.6s" # tabstop ruler #>>>5 string >\0 \b, tabstops "%-79s" @@ -105,7 +105,7 @@ # contains any mail-merge commands >>>92 byte&0x01 >0 \b, with mail merge # left margin in 1/10 inches ( normally 0 or 10 ) ->>>91 ubyte >0 +>>>91 ubyte >0 >>>>91 ubyte x \b, %d/10 inch left margin # AppleWorks database: @@ -140,13 +140,13 @@ # GRR: this test is still too general as it catches also Gujin BOOT144.SYS (0xfa080000) #0 belong&0xff00ff 0x80000 Applesoft BASIC program data -0 belong&0x00ff00ff 0x00080000 +0 belong&0x00ff00ff 0x00080000 # assuming that line number must be positive >2 leshort >0 Applesoft BASIC program data, first line number %d #>2 leshort x \b, first line number %d # ORCA/EZ assembler: -# +# # This will not identify ORCA/M source files, since those have # some sort of date code instead of the two zero bytes at 6 and 7 # XXX Conflicts with ELF @@ -186,18 +186,18 @@ # From Johan Gade. # These entries are disabled for now until we fix the following issues. # -# Note there might be some problems with the "VAX COFF executable" -# entry. Note this entry should be placed before the mac filesystem section, +# Note there might be some problems with the "VAX COFF executable" +# entry. Note this entry should be placed before the mac filesystem section, # particularly the "Apple Partition data" entry. # -# The intended meaning of these tests is, that the file is only of the +# The intended meaning of these tests is, that the file is only of the # specified type if both of the lines are correct - i.e. if the first # line matches and the second doesn't then it is not of that type. # #0 long 0x7801730d #>4 long 0x62626060 UDIF read-only zlib-compressed image (UDZO) # -# Note that this entry is recognized correctly by the "Apple Partition +# Note that this entry is recognized correctly by the "Apple Partition # data" entry - however since this entry is more specific - this # information seems to be more useful. #0 long 0x45520200 @@ -288,7 +288,7 @@ # Apple disk partition stuff # URL: https://en.wikipedia.org/wiki/Apple_Partition_Map # Reference: https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/sys/bootblock.h -# Update: Joerg Jenderek +# Update: Joerg Jenderek # "ER" is APPLE_DRVR_MAP_MAGIC signature 0 beshort 0x4552 # display Apple Driver Map (strength=50) after Syslinux bootloader (71) @@ -315,7 +315,7 @@ # device id 0 1 (37008 garbage for super_grub2_disk_hybrid_2.02s3.iso) >>10 ubeshort x \b, devid %u # driver data 0 (2425393296 garbage for super_grub2_disk_hybrid_2.02s3.iso) ->>12 ubelong >0 +>>12 ubelong >0 >>>12 ubelong x \b, driver data %u # number of driver descriptors sbDrvrCount <= 61 # (37008 garbage for super_grub2_disk_hybrid_2.02s3.iso) @@ -327,26 +327,26 @@ # >>500 use apple-driver-map # number of partitions is always same in every partition (map block count) #>>0x0204 ubelong x \b, %u partitions ->>0x0204 ubelong >0 \b, contains[@0x200]: +>>0x0204 ubelong >0 \b, contains[@0x200]: >>>0x0200 use apple-apm ->>0x0204 ubelong >1 \b, contains[@0x400]: +>>0x0204 ubelong >1 \b, contains[@0x400]: >>>0x0400 use apple-apm ->>0x0204 ubelong >2 \b, contains[@0x600]: +>>0x0204 ubelong >2 \b, contains[@0x600]: >>>0x0600 use apple-apm ->>0x0204 ubelong >3 \b, contains[@0x800]: +>>0x0204 ubelong >3 \b, contains[@0x800]: >>>0x0800 use apple-apm ->>0x0204 ubelong >4 \b, contains[@0xA00]: +>>0x0204 ubelong >4 \b, contains[@0xA00]: >>>0x0A00 use apple-apm ->>0x0204 ubelong >5 \b, contains[@0xC00]: +>>0x0204 ubelong >5 \b, contains[@0xC00]: >>>0x0C00 use apple-apm ->>0x0204 ubelong >6 \b, contains[@0xE00]: +>>0x0204 ubelong >6 \b, contains[@0xE00]: >>>0x0E00 use apple-apm ->>0x0204 ubelong >7 \b, contains[@0x1000]: +>>0x0204 ubelong >7 \b, contains[@0x1000]: >>>0x1000 use apple-apm # display apple driver descriptor map (start-block, # blocks in sbBlkSize sizes, type) 0 name apple-driver-map ->0 ubequad !0 -# descBlock first block of driver +>0 ubequad !0 +# descBlock first block of driver >>0 ubelong x \b, driver start block %u # descSize driver size in blocks >>4 ubeshort x \b, size %u @@ -355,11 +355,11 @@ # URL: https://en.wikipedia.org/wiki/Apple_Partition_Map # Reference: http://opensource.apple.com/source/IOStorageFamily/IOStorageFamily-116/IOApplePartitionScheme.h -# Update: Joerg Jenderek +# Update: Joerg Jenderek # Yes, the 3rd and 4th bytes pmSigPad are reserved, but we use them to make the # magic stronger. # for apple partition map stored as a single file -0 belong 0x504d0000 +0 belong 0x504d0000 # to display Apple Partition Map (strength=70) after Syslinux bootloader (71) #!:strength +0 >0 use apple-apm @@ -417,7 +417,7 @@ 0 name appleworks >0 belong&0x00ffffff 0x07e100 AppleWorks CWK Document >0 belong&0x00ffffff 0x008803 ClarisWorks CWK Document ->0 default x +>0 default x >>0 belong x AppleWorks/ClarisWorks CWK Document >0 byte x \b, version %d >30 beshort x \b, %d diff --git contrib/file/magic/Magdir/archive contrib/file/magic/Magdir/archive index e737550c76a7..abecf7101f15 100644 --- contrib/file/magic/Magdir/archive +++ contrib/file/magic/Magdir/archive @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# $File: archive,v 1.103 2016/05/05 17:07:40 christos Exp $ +# $File: archive,v 1.108 2017/08/30 13:45:10 christos Exp $ # archive: file(1) magic for archive formats (see also "msdos" for self- # extracting compressed archives) # @@ -249,9 +249,9 @@ # URL: http://fileformats.archiveteam.org/wiki/TTComp_archive # Update: Joerg Jenderek # GRR: line below is too general as it matches also Panorama database "TCDB 2003-10 demo.pan", others -0 string \0\6 +0 string \0\6 # look for first keyword of Panorama database *.pan ->12 search/261 DESIGN +>12 search/261 DESIGN # skip keyword with low entropy >12 default x TTComp archive, binary, 4K dictionary # (version 5.25) labeled the above entry as "TTComp archive data" @@ -447,9 +447,9 @@ 0 string SZ\x0a\4 SZip archive data # XPack DiskImage # *.XDI updated by Joerg Jenderek Sep 2015 -# ftp://ftp.sac.sk/pub/sac/pack/0index.txt +# ftp://ftp.sac.sk/pub/sac/pack/0index.txt # GRR: this test is still too general as it catches also text files starting with jm -0 string jm +0 string jm # only found examples with this additional characteristic 2 bytes >2 string \x2\x4 Xpack DiskImage archive data #!:ext xdi @@ -462,7 +462,7 @@ # ftp://ftp.elf.stuba.sk/pub/pc/pack/xpa32.zip # created by XPA32.EXE version 1.0.2 for Windows >0 string xpa\0\1 \b32 archive data -# created by XPACK.COM version 1.67m or 1.67r with short 0x1800 +# created by XPACK.COM version 1.67m or 1.67r with short 0x1800 >3 ubeshort !0x0001 \bck archive data # XPack Single Data # changed by Joerg Jenderek Sep 2015 back to like in version 5.12 @@ -552,7 +552,7 @@ >>0x36 string >\0 fstype %.8s # LHARC/LHA archiver (Greg Roelofs, newt@uchicago.edu) -# Update: Joerg Jenderek +# Update: Joerg Jenderek # URL: https://en.wikipedia.org/wiki/LHA_(file_format) # Reference: http://web.archive.org/web/20021005080911/http://www.osirusoft.com/joejared/lzhformat.html # @@ -561,14 +561,14 @@ # check 1st character of method id like -lz4- -lh5- or -pm2- >2 string - # check 5th character of method id ->>6 string - +>>6 string - # check header level 0 1 2 3 ->>>20 ubyte <4 +>>>20 ubyte <4 # check 2nd, 3th and 4th character of method id >>>>3 regex \^(lh[0-9a-ex]|lz[s2-8]|pm[012]|pc1) \b !:mime application/x-lzh-compressed # creator type "LHA " -!:apple ????LHA +!:apple ????LHA # display archive type name like "LHa/LZS archive data" or "LArc archive" >>>>>2 string -lz \b !:ext lzs @@ -578,7 +578,7 @@ # missing -lz?- with wikipedia names >>>>>>3 regex \^lz[2378] LArc archive # display archive type name like "LHa (2.x) archive data" ->>>>>2 string -lh \b +>>>>>2 string -lh \b # already known -lh0- -lh1- -lh2- -lh3- -lh4- -lh5- -lh6- -lh7- -lhd- variants with old names >>>>>>3 regex \^lh[01] LHarc 1.x/ARX archive data # LHice archiver use ".ICE" as name extension instead usual one ".lzh" @@ -614,28 +614,28 @@ # check and display information of lharc header 0 name lharc-header # header size 0x4 , 0x1b-0x61 ->0 ubyte x +>0 ubyte x # compressed data size != compressed file size #>7 ulelong x \b, data size %d -# attribute: 0x2~?? 0x10~symlink|target 0x20~normal +# attribute: 0x2~?? 0x10~symlink|target 0x20~normal #>19 ubyte x \b, 19_0x%x # level identifier 0 1 2 3 #>20 ubyte x \b, level %d # time stamp #>15 ubelong x DATE 0x%8.8x # OS ID for level 1 ->20 ubyte 1 +>20 ubyte 1 # 0x20 types find for *.rom files >>(21.b+24) ubyte <0x21 \b, 0x%x OS # ascii type like M for MSDOS >>(21.b+24) ubyte >0x20 \b, '%c' OS # OS ID for level 2 ->20 ubyte 2 +>20 ubyte 2 #>>23 ubyte x \b, OS ID 0x%x >>23 ubyte <0x21 \b, 0x%x OS >>23 ubyte >0x20 \b, '%c' OS # filename only for level 0 and 1 ->20 ubyte <2 +>20 ubyte <2 # length of filename >>21 ubyte >0 \b, with # filename @@ -643,73 +643,73 @@ # #2 string -lh0- LHarc 1.x/ARX archive data [lh0] #!:mime application/x-lharc -2 string -lh0- +2 string -lh0- >0 use lharc-file #2 string -lh1- LHarc 1.x/ARX archive data [lh1] #!:mime application/x-lharc -2 string -lh1- +2 string -lh1- >0 use lharc-file # NEW -lz2- ... -lz8- -2 string -lz2- +2 string -lz2- >0 use lharc-file -2 string -lz3- +2 string -lz3- >0 use lharc-file -2 string -lz4- +2 string -lz4- >0 use lharc-file -2 string -lz5- +2 string -lz5- >0 use lharc-file -2 string -lz7- +2 string -lz7- >0 use lharc-file -2 string -lz8- +2 string -lz8- >0 use lharc-file # [never seen any but the last; -lh4- reported in comp.compression:] #2 string -lzs- LHa/LZS archive data [lzs] -2 string -lzs- +2 string -lzs- >0 use lharc-file # According to wikipedia and others such a version does not exist #2 string -lh\40- LHa 2.x? archive data [lh ] #2 string -lhd- LHa 2.x? archive data [lhd] -2 string -lhd- +2 string -lhd- >0 use lharc-file #2 string -lh2- LHa 2.x? archive data [lh2] -2 string -lh2- +2 string -lh2- >0 use lharc-file #2 string -lh3- LHa 2.x? archive data [lh3] -2 string -lh3- +2 string -lh3- >0 use lharc-file #2 string -lh4- LHa (2.x) archive data [lh4] -2 string -lh4- +2 string -lh4- >0 use lharc-file #2 string -lh5- LHa (2.x) archive data [lh5] -2 string -lh5- +2 string -lh5- >0 use lharc-file #2 string -lh6- LHa (2.x) archive data [lh6] -2 string -lh6- +2 string -lh6- >0 use lharc-file #2 string -lh7- LHa (2.x)/LHark archive data [lh7] -2 string -lh7- +2 string -lh7- # !:mime application/x-lha # >20 byte x - header level %d >0 use lharc-file # NEW -lh8- ... -lhe- , -lhx- -2 string -lh8- +2 string -lh8- >0 use lharc-file -2 string -lh9- +2 string -lh9- >0 use lharc-file -2 string -lha- +2 string -lha- >0 use lharc-file -2 string -lhb- +2 string -lhb- >0 use lharc-file -2 string -lhc- +2 string -lhc- >0 use lharc-file -2 string -lhe- +2 string -lhe- >0 use lharc-file -2 string -lhx- +2 string -lhx- >0 use lharc-file # taken from idarc [JW] 2 string -lZ PUT archive data # already done by LHarc magics -# this should never happen if all sub types of LZS archive are identified +# this should never happen if all sub types of LZS archive are identified #2 string -lz LZS archive data 2 string -sw1- Swag archive data @@ -908,7 +908,17 @@ >>>4 byte 0x0a \b, at least v1.0 to extract >>>4 byte 0x0b \b, at least v1.1 to extract >>>4 byte 0x14 \b, at least v2.0 to extract +>>>4 byte 0x15 \b, at least v2.1 to extract +>>>4 byte 0x19 \b, at least v2.5 to extract +>>>4 byte 0x1b \b, at least v2.7 to extract >>>4 byte 0x2d \b, at least v4.5 to extract +>>>4 byte 0x2e \b, at least v4.6 to extract +>>>4 byte 0x32 \b, at least v5.0 to extract +>>>4 byte 0x33 \b, at least v5.1 to extract +>>>4 byte 0x34 \b, at least v5.2 to extract +>>>4 byte 0x3d \b, at least v6.1 to extract +>>>4 byte 0x3e \b, at least v6.2 to extract +>>>4 byte 0x3f \b, at least v6.3 to extract >>>0x161 string WINZIP \b, WinZIP self-extracting # StarView Metafile @@ -940,17 +950,17 @@ 0 string \0\ \ \ \ \ \ \ \ \ \ \ \0\0 LBR archive data # # PMA (CP/M derivative of LHA) -# Update: Joerg Jenderek +# Update: Joerg Jenderek # URL: https://en.wikipedia.org/wiki/LHA_(file_format) # #2 string -pm0- PMarc archive data [pm0] -2 string -pm0- +2 string -pm0- >0 use lharc-file #2 string -pm1- PMarc archive data [pm1] -2 string -pm1- +2 string -pm1- >0 use lharc-file #2 string -pm2- PMarc archive data [pm2] -2 string -pm2- +2 string -pm2- >0 use lharc-file 2 string -pms- PMarc SFX archive (CP/M, DOS) #!:mime application/x-foobar-exec @@ -1145,12 +1155,12 @@ >3 ubyte 0 \b, no compression >3 ubyte 2 \b, fast compression (Z1) >3 ubyte 3 \b, medium compression (Z2) ->3 ubyte >3 +>3 ubyte >3 >>3 ubyte <11 \b, compression (Z%d-1) ->2 ubyte&0x08 0x00 +>2 ubyte&0x08 0x00 # ~ 30 byte password field only for *.gho >>12 ubequad !0 \b, password protected ->>44 ubyte !1 +>>44 ubyte !1 # 1~Image All, sector-by-sector only for *.gho >>>10 ubyte 1 \b, sector copy # 1~Image Boot track only for *.gho @@ -1160,8 +1170,8 @@ # optional image description only *.gho >>0xff string >\0 "%-.254s" # look for DOS sector end sequence ->0xE08 search/7776 \x55\xAA ->>&-512 indirect x \b; contains +>0xE08 search/7776 \x55\xAA +>>&-512 indirect x \b; contains # Google Chrome extensions # https://developer.chrome.com/extensions/crx @@ -1169,3 +1179,10 @@ 0 string Cr24 Google Chrome extension !:mime application/x-chrome-extension >4 ulong x \b, version %u + +# SeqBox - Sequenced container +# ext: sbx, seqbox +# Marco Pontello marcopon@gmail.com +# reference: https://github.com/MarcoPon/SeqBox +0 string SBx SeqBox, +>3 byte x version %d diff --git contrib/file/magic/Magdir/att3b contrib/file/magic/Magdir/att3b index a3ed9c0037a9..b83ae2ec08d8 100644 --- contrib/file/magic/Magdir/att3b +++ contrib/file/magic/Magdir/att3b @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: att3b,v 1.9 2014/04/30 21:41:02 christos Exp $ +# $File: att3b,v 1.10 2017/03/17 21:35:28 christos Exp $ # att3b: file(1) magic for AT&T 3B machines # # The `versions' should be un-commented if they work for you. @@ -36,6 +36,6 @@ #>18 beshort &00040000 and MAU hardware required #>22 beshort >0 - version %d # -# core file for 3b2 +# core file for 3b2 0 string \000\004\036\212\200 3b2 core file >364 string >\0 of '%s' diff --git contrib/file/magic/Magdir/audio contrib/file/magic/Magdir/audio index 29442a51b3cf..0330bbfa8078 100644 --- contrib/file/magic/Magdir/audio +++ contrib/file/magic/Magdir/audio @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: audio,v 1.75 2016/02/08 17:30:11 christos Exp $ +# $File: audio,v 1.80 2017/08/13 00:21:47 christos Exp $ # audio: file(1) magic for sound formats (see also "iff") # # Jan Nicolai Langfeldt (janl@ifi.uio.no), Dan Quinlan (quinlan@yggdrasil.com), @@ -300,7 +300,7 @@ >>5 byte &0x40 \b, extended header >>5 byte &0x20 \b, experimental >>5 byte &0x10 \b, footer present ->(6.I+10) indirect x \b, contains: +>(6.I+10) indirect x \b, contains: # NSF (NES sound file) magic 0 string NESM\x1a NES Sound File @@ -314,7 +314,7 @@ >122 byte&0x1 =0 NTSC # NSFE (Extended NES sound file) magic -# http://slickproductions.org/docs/NSF/nsfespec.txt +# http://slickproductions.org/docs/NSF/nsfespec.txt # From: David Pflug <david@pflug.email> 0 string NSFE Extended NES Sound File >48 search/0x1000 auth @@ -469,6 +469,8 @@ >>20 byte&0xe 0xc \b, 7 channels >>20 byte&0xe 0xe \b, 8 channels # some common sample rates +>>17 belong&0xfffff0 0x2ee000 \b, 192 kHz +>>17 belong&0xfffff0 0x158880 \b, 88.2 kHz >>17 belong&0xfffff0 0x0ac440 \b, 44.1 kHz >>17 belong&0xfffff0 0x0bb800 \b, 48 kHz >>17 belong&0xfffff0 0x07d000 \b, 32 kHz @@ -658,7 +660,7 @@ # From Fabio R. Schmidlin <frs@pop.com.br> # VGM music file -0 string Vgm\ +0 string Vgm\040 >9 ubyte >0 VGM Video Game Music dump v >>9 ubyte/16 >0 \b%d >>9 ubyte&0x0F x \b%d @@ -723,7 +725,7 @@ # URL: http://www.garmin.com/ # Reference: http://turboccc.wikispaces.com/share/view/28622555 # NOTE: there exist 2 other Garmin VPM formats -0 string AUDIMG +0 string AUDIMG # skip text files starting with string "AUDIMG" >13 ubyte <13 Garmin Voice Processing Module !:mime audio/x-vpm-wav-garmin @@ -743,16 +745,68 @@ # second of release (0-59) >>9 ubyte x \b:%.2d # if you select a language like german on your garmin device -# you can only select voice modules with correponding language byte ID like 1 +# you can only select voice modules with corresponding language byte ID like 1 >>18 ubyte x \b, language ID %d # pointer to 1st audio WAV sample ->>16 uleshort >0 +>>16 uleshort >0 >>>(16.s) ulelong >0 \b, at offset 0x%x # WAV length >>>>(16.s+4) ulelong >0 %d Bytes # look for magic ->>>>>(&-8.l) string RIFF +>>>>>(&-8.l) string RIFF # determine type by ./riff ->>>>>>&-4 indirect x \b +>>>>>>&-4 indirect x \b # 2 - ~ 131 WAV samples following same way +# From Martin Mueller Skarbiniks Pedersen +0 string GDM +>0x3 byte 0xFE General Digital Music. +>0x4 string >\0 title: "%s" +>0x24 string >\0 musician: "%s" +>>0x44 beshort 0x0D0A +>>>0x46 byte 0x1A +>>>>0x47 string GMFS Version +>>>>0x4B byte x %d. +>>>>0x4C byte x \b%02d +>>>>0x4D beshort 0x000 (2GDM v +>>>>0x4F byte x \b%d. +>>>>>0x50 byte x \b%d) + +0 string MTM Multitracker +>0x3 byte/16 x Version %d. +>0x3 byte&0x0F x \b%02d +>>0x4 string >\0 title: "%s" + +0 string HVL +>3 byte <2 Hively Tracker Song +>3 byte 0 1 module data +>3 byte 1 2 module data + +0 string MO3 +>3 ubyte <6 MOdule with MP3 +>>3 byte 0 Version 0 (With MP3 and lossless) +>>3 byte 1 Version 1 (With ogg and lossless) +>>3 byte 3 Version 2.2 +>>3 byte 4 (With no LAME header) +>>3 byte 5 Version 2.4 + +0 string ADRVPACK AProSys module + +# ftp://ftp.modland.com/pub/documents/format_documentation/\ +# Art%20Of%20Noise%20(.aon).txt +0 string AON +>4 string "ArtOfNoise by Bastian Spiegel(twice/lego)" +>0x2e string NAME Art of Noise Tracker Song +>3 string <9 +>3 string 4 (4 voices) +>3 string 8 (8 voices) +>>0x36 string >\0 Title: "%s" + +0 string FAR +>0x2c byte 0x0d +>0x2d byte 0x0a +>0x2e byte 0x1a +>>0x3 byte 0xFE Farandole Tracker Song +>>>0x31 byte/16 x Version %d. +>>>0x31 byte&0x0F x \b%02d +>>>>0x4 string >\0 \b, title: "%s" diff --git contrib/file/magic/Magdir/bhl contrib/file/magic/Magdir/bhl new file mode 100644 index 000000000000..6f57f0343395 --- /dev/null +++ contrib/file/magic/Magdir/bhl @@ -0,0 +1,10 @@ + +#------------------------------------------------------------------------------ +# $File: bhl,v 1.1 2017/06/11 22:20:02 christos Exp $ +# BlockHashLoc +# ext: bhl +# Marco Pontello marcopon@gmail.com +# reference: https://github.com/MarcoPon/BlockHashLoc +0 string BlockHashLoc\x1a BlockHashLoc recovery info, +>13 byte x version %d +!:ext bhl diff --git contrib/file/magic/Magdir/blackberry contrib/file/magic/Magdir/blackberry index 4a61d4e98cfa..2e38a54f42d6 100644 --- contrib/file/magic/Magdir/blackberry +++ contrib/file/magic/Magdir/blackberry @@ -1,8 +1,8 @@ #------------------------------------------------------------------------------ -# $File: blackberry,v 1.1 2014/01/31 01:51:32 christos Exp $ +# $File: blackberry,v 1.2 2017/03/17 21:35:28 christos Exp $ # blackberry: file(1) magic for BlackBerry file formats # -5 belong 0 +5 belong 0 >8 belong 010010010 BlackBerry RIM ETP file >>22 string x \b for %s diff --git contrib/file/magic/Magdir/blender contrib/file/magic/Magdir/blender index 5b9c8556e521..09485702b15b 100644 --- contrib/file/magic/Magdir/blender +++ contrib/file/magic/Magdir/blender @@ -1,11 +1,11 @@ #------------------------------------------------------------------------------ -# $File: blender,v 1.6 2014/08/30 08:34:17 christos Exp $ +# $File: blender,v 1.7 2017/03/17 21:35:28 christos Exp $ # blender: file(1) magic for Blender 3D related files # -# Native format rule v1.2. For questions use the developers list +# Native format rule v1.2. For questions use the developers list # http://lists.blender.org/mailman/listinfo/bf-committers -# GLOB chunk was moved near start and provides subversion info since 2.42 +# GLOB chunk was moved near start and provides subversion info since 2.42 0 string =BLENDER Blender3D, >7 string =_ saved as 32-bits diff --git contrib/file/magic/Magdir/c-lang contrib/file/magic/Magdir/c-lang index bb594b069fc7..7b3f703ef3ec 100644 --- contrib/file/magic/Magdir/c-lang +++ contrib/file/magic/Magdir/c-lang @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# $File: c-lang,v 1.24 2016/07/01 23:31:13 christos Exp $ +# $File: c-lang,v 1.26 2017/08/14 07:40:38 christos Exp $ # c-lang: file(1) magic for C and related languages programs # # The strength is to beat standard HTML @@ -11,49 +11,72 @@ !:mime text/x-bcpl # C -0 regex \^#include C source text -!:strength +25 +# Check for class if include is found, otherwise class is beaten by include becouse of lowered strength +0 regex \^#include C +>0 regex \^class[[:space:]]+ +>>&0 regex \\{[\.\*]\\}(;)?$ \b++ +>&0 clear x source text +!:strength + 13 +!:mime text/x-c +0 regex \^#[[:space:]]*pragma C source text +!:mime text/x-c +0 regex \^#[[:space:]]*(if\|ifn)def +>&0 regex \^#[[:space:]]*endif$ C source text !:mime text/x-c -0 regex \^char[\ \t\n]+ C source text +0 regex \^#[[:space:]]*(if\|ifn)def +>&0 regex \^#[[:space:]]*define C source text !:mime text/x-c -0 regex \^double[\ \t\n]+ C source text +0 regex \^[[:space:]]*char(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text !:mime text/x-c -0 regex \^extern[\ \t\n]+ C source text +0 regex \^[[:space:]]*double(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text !:mime text/x-c -0 regex \^float[\ \t\n]+ C source text +0 regex \^[[:space:]]*extern[[:space:]]+ C source text !:mime text/x-c -0 regex \^struct[\ \t\n]+ C source text +0 regex \^[[:space:]]*float(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text !:mime text/x-c -0 regex \^union[\ \t\n]+ C source text +0 regex \^struct[[:space:]]+ C source text !:mime text/x-c -0 search/8192 main( C source text +0 regex \^union[[:space:]]+ C source text +!:mime text/x-c +0 search/8192 main( +>&0 regex \\)[[:space:]]*\\{ C source text !:mime text/x-c # C++ # The strength of these rules is increased so they beat the C rules above -0 regex \^template[\ \t]+<.*>[\ \t\n]+ C++ source text +0 regex \^namespace[[:space:]]+[_[:alpha:]]{1,30}[[:space:]]*\\{ C++ source text +!:strength + 30 +!:mime text/x-c++ +# using namespace [namespace] or using std::[lib] +0 regex \^using[[:space:]]+(namespace\ )?std(::)?[[:alpha:]]*[[:space:]]*; C++ source text +!:strength + 30 +!:mime text/x-c++ +0 regex \^[[:space:]]*template[[:space:]]*<.*>[[:space:]]*$ C++ source text !:strength + 30 !:mime text/x-c++ -0 regex \^virtual[\ \t\n]+ C++ source text +0 regex \^[[:space:]]*virtual[[:space:]]+.*[};][[:space:]]*$ C++ source text !:strength + 30 !:mime text/x-c++ -0 regex \^class[\ \t\n]+ C++ source text -# But class is reduced to avoid beating php (Jens Schleusener) +# But class alone is reduced to avoid beating php (Jens Schleusener) +0 regex \^[[:space:]]*class[[:space:]]+[[:digit:][:alpha:]:_]+[[:space:]]*\\{(.*[\n]*)*\\}(;)?$ C++ source text !:strength + 13 !:mime text/x-c++ -0 regex \^public: C++ source text +0 regex \^[[:space:]]*public: C++ source text +!:strength + 30 +!:mime text/x-c++ +0 regex \^[[:space:]]*private: C++ source text !:strength + 30 !:mime text/x-c++ -0 regex \^private: C++ source text +0 regex \^[[:space:]]*protected: C++ source text !:strength + 30 !:mime text/x-c++ # Objective-C -0 regex \^#import Objective-C source text -!:strength +25 +0 regex \^#import Objective-C source text +!:strength + 25 !:mime text/x-objective-c -# From: Mikhail Teterin <mi@aldan.algebra.com> +# From: Mikhail Teterin <mi@aldan.algebra.com> 0 string cscope cscope reference data >7 string x version %.2s # We skip the path here, because it is often long (so file will diff --git contrib/file/magic/Magdir/cad contrib/file/magic/Magdir/cad index 9b09fd7a1917..daafba9d444c 100644 --- contrib/file/magic/Magdir/cad +++ contrib/file/magic/Magdir/cad @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: cad,v 1.13 2014/03/23 18:05:38 christos Exp $ +# $File: cad,v 1.15 2017/06/24 15:24:56 christos Exp $ # autocad: file(1) magic for cad files # @@ -9,7 +9,7 @@ # DGN is the default file extension of Microstation/Intergraph CAD files. # CIT is the proprietary raster format (similar to TIFF) used to attach # raster underlays to Microstation DGN (vector) drawings. -# +# # http://www.wotsit.org/search.asp # http://filext.com/detaillist.php?extdetail=DGN # http://filext.com/detaillist.php?extdetail=CIT @@ -42,7 +42,7 @@ >4 string \030\000\000 CITFile >4 string \030\000\003 CITFile -# AutoCAD +# AutoCAD # Merge of the different contributions and updates from http://en.wikipedia.org/wiki/Dwg # and http://www.iana.org/assignments/media-types/image/vnd.dwg 0 string MC0.0 DWG AutoDesk AutoCAD Release 1.0 @@ -99,42 +99,42 @@ 0 string AC1027 DWG AutoDesk AutoCAD 2013/2014 !:mime image/vnd.dwg -# KOMPAS 2D drawing from ASCON +# KOMPAS 2D drawing from ASCON # This is KOMPAS 2D drawing or fragment of drawing but is not detailed nor # gathered nor specification # ASCON http://ascon.net/main/ in English, # http://ascon.ru/ main site in Russian -# Extension is CDW for drawing and FRW for fragment of drawing +# Extension is CDW for drawing and FRW for fragment of drawing # Sergey Zaykov (mail_of_sergey@mail.ru, sergey_zaikov@rambler.ru, # ICQ 358572321, http://vkontakte.ru/id16076543) # From: # http://sd.ascon.ru/otrs/customer.pl?Action=CustomerFAQ&CategoryID=4&ItemID=292 # (in russian) and my experiments 0 string KF ->2 belong 0x4E00000C Kompas drawing 12.0 SP1 ->2 belong 0x4D00000C Kompas drawing 12.0 ->2 belong 0x3200000B Kompas drawing 11.0 SP1 ->2 belong 0x3100000B Kompas drawing 11.0 ->2 belong 0x2310000A Kompas drawing 10.0 SP1 ->2 belong 0x2110000A Kompas drawing 10.0 ->2 belong 0x08000009 Kompas drawing 9.0 SP1 ->2 belong 0x05000009 Kompas drawing 9.0 ->2 belong 0x33010008 Kompas drawing 8+ ->2 belong 0x1A000008 Kompas drawing 8.0 ->2 belong 0x2C010107 Kompas drawing 7+ ->2 belong 0x05000007 Kompas drawing 7.0 ->2 belong 0x32000006 Kompas drawing 6+ ->2 belong 0x09000006 Kompas drawing 6.0 ->2 belong 0x5C009005 Kompas drawing 5.11R03 ->2 belong 0x54009005 Kompas drawing 5.11R02 ->2 belong 0x51009005 Kompas drawing 5.11R01 ->2 belong 0x22009005 Kompas drawing 5.10R03 ->2 belong 0x22009005 Kompas drawing 5.10R02 mar ->2 belong 0x21009005 Kompas drawing 5.10R02 febr ->2 belong 0x19009005 Kompas drawing 5.10R01 ->2 belong 0xF4008005 Kompas drawing 5.9R01.003 ->2 belong 0x1C008005 Kompas drawing 5.9R01.002 ->2 belong 0x11008005 Kompas drawing 5.8R01.003 +>2 belong 0x4E00000C Kompas drawing 12.0 SP1 +>2 belong 0x4D00000C Kompas drawing 12.0 +>2 belong 0x3200000B Kompas drawing 11.0 SP1 +>2 belong 0x3100000B Kompas drawing 11.0 +>2 belong 0x2310000A Kompas drawing 10.0 SP1 +>2 belong 0x2110000A Kompas drawing 10.0 +>2 belong 0x08000009 Kompas drawing 9.0 SP1 +>2 belong 0x05000009 Kompas drawing 9.0 +>2 belong 0x33010008 Kompas drawing 8+ +>2 belong 0x1A000008 Kompas drawing 8.0 +>2 belong 0x2C010107 Kompas drawing 7+ +>2 belong 0x05000007 Kompas drawing 7.0 +>2 belong 0x32000006 Kompas drawing 6+ +>2 belong 0x09000006 Kompas drawing 6.0 +>2 belong 0x5C009005 Kompas drawing 5.11R03 +>2 belong 0x54009005 Kompas drawing 5.11R02 +>2 belong 0x51009005 Kompas drawing 5.11R01 +>2 belong 0x22009005 Kompas drawing 5.10R03 +>2 belong 0x22009005 Kompas drawing 5.10R02 mar +>2 belong 0x21009005 Kompas drawing 5.10R02 febr +>2 belong 0x19009005 Kompas drawing 5.10R01 +>2 belong 0xF4008005 Kompas drawing 5.9R01.003 +>2 belong 0x1C008005 Kompas drawing 5.9R01.002 +>2 belong 0x11008005 Kompas drawing 5.8R01.003 # CAD: file(1) magic for computer aided design files # Phillip Griffith <phillip dot griffith at gmail dot com> @@ -147,8 +147,13 @@ >0x02 byte 0xfe >>0x04 beshort 0x1800 CIT raster CAD -# 3DS (3d Studio files) Conflicts with diff output 0x3d '=' -#16 beshort 0x3d3d image/x-3ds +# 3DS (3d Studio files) +0 leshort 0x4d4d +>6 leshort 0x2 +>>8 lelong 0xa +>>>16 leshort 0x3d3d 3D Studio model +!:mime image/x-3ds +!:extension 3ds # MegaCAD 2D/3D drawing (.prt) # http://megacad.de/ diff --git contrib/file/magic/Magdir/cafebabe contrib/file/magic/Magdir/cafebabe index 6d97cebc4fa1..6482858fc62c 100644 --- contrib/file/magic/Magdir/cafebabe +++ contrib/file/magic/Magdir/cafebabe @@ -1,14 +1,14 @@ #------------------------------------------------------------------------------ -# $File: cafebabe,v 1.21 2015/10/15 20:56:51 christos Exp $ +# $File: cafebabe,v 1.23 2017/05/25 20:07:23 christos Exp $ # Cafe Babes unite! # # Since Java bytecode and Mach-O universal binaries have the same magic number, # the test must be performed in the same "magic" sequence to get both right. # The long at offset 4 in a Mach-O universal binary tells the number of # architectures; the short at offset 4 in a Java bytecode file is the JVM minor -# version and the short at offset 6 is the JVM major version. Since there are only -# only 18 labeled Mach-O architectures at current, and the first released +# version and the short at offset 6 is the JVM major version. Since there are only +# only 18 labeled Mach-O architectures at current, and the first released # Java class format was version 43.0, we can safely choose any number # between 18 and 39 to test the number of architectures against # (and use as a hack). Let's not use 18, because the Mach-O people @@ -47,7 +47,7 @@ 0 name mach-o \b [ >0 use mach-o-cpu \b ->(8.L) indirect \b: +>(8.L) indirect x \b: >0 belong x \b] 0 belong 0xcafebabe diff --git contrib/file/magic/Magdir/clipper contrib/file/magic/Magdir/clipper index 98278ebf0615..2768b3af501d 100644 --- contrib/file/magic/Magdir/clipper +++ contrib/file/magic/Magdir/clipper @@ -1,13 +1,13 @@ #------------------------------------------------------------------------------ -# $File: clipper,v 1.7 2014/04/30 21:41:02 christos Exp $ +# $File: clipper,v 1.8 2017/03/17 21:35:28 christos Exp $ # clipper: file(1) magic for Intergraph (formerly Fairchild) Clipper. # # XXX - what byte order does the Clipper use? # # XXX - what's the "!" stuff: # -# >18 short !074000,000000 C1 R1 +# >18 short !074000,000000 C1 R1 # >18 short !074000,004000 C2 R1 # >18 short !074000,010000 C3 R1 # >18 short !074000,074000 TEST @@ -15,7 +15,7 @@ # I shall assume it's ANDing the field with the first value and # comparing it with the second, and rewrite it as: # -# >18 short&074000 000000 C1 R1 +# >18 short&074000 000000 C1 R1 # >18 short&074000 004000 C2 R1 # >18 short&074000 010000 C3 R1 # >18 short&074000 074000 TEST @@ -37,7 +37,7 @@ >12 long >0 not stripped >22 short >0 - version %d 0 short 0577 CLIPPER COFF executable ->18 short&074000 000000 C1 R1 +>18 short&074000 000000 C1 R1 >18 short&074000 004000 C2 R1 >18 short&074000 010000 C3 R1 >18 short&074000 074000 TEST diff --git contrib/file/magic/Magdir/coff contrib/file/magic/Magdir/coff index 02cbf9ce7413..b4addec58ffd 100644 --- contrib/file/magic/Magdir/coff +++ contrib/file/magic/Magdir/coff @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: coff,v 1.1 2015/09/30 20:32:35 christos Exp $ +# $File: coff,v 1.2 2017/03/17 21:35:28 christos Exp $ # coff: file(1) magic for Common Object Files not specific to known cpu types or manufactures # # COFF @@ -15,7 +15,7 @@ # mips,motorola,msdos,osf1,sharc,varied.out,vax 0 name display-coff # test for unused flag bits (0x8000,0x0800,0x0400,0x0200,x0080) in f_flags ->18 uleshort&0x8E80 0 +>18 uleshort&0x8E80 0 >>0 clear x # f_magic - magic number # DJGPP, 80386 COFF executable, MS Windows COFF Intel 80386 object file (./intel) @@ -25,7 +25,7 @@ # Hitachi SH little-endian COFF (./hitachi-sh) >>0 uleshort 0x0550 Hitachi SH little-endian # executable (RISC System/6000 V3.1) or obj module (./ibm6000) -#>>0 uleshort 0x01DF +#>>0 uleshort 0x01DF # TODO for other COFFs #>>0 uleshort 0xABCD COFF_TEMPLATE >>0 default x @@ -45,12 +45,12 @@ >>18 leshort &0x0008 \b, stripped >>18 leshort ^0x0008 \b, not stripped # flags in other COFF versions -#0x0010 F_FDPR_PROF +#0x0010 F_FDPR_PROF #0x0020 F_FDPR_OPTI #0x0040 F_DSA # F_AR32WR flag bit #>>>18 leshort &0x0100 \b, 32 bit little endian -#0x1000 F_DYNLOAD +#0x1000 F_DYNLOAD #0x2000 F_SHROBJ #0x4000 F_LOADONLY # f_nscns - number of sections @@ -62,7 +62,7 @@ >>8 ulelong >0 \b, symbol offset=0x%x # f_nsyms - number of symbols, only for not stripped >>12 ulelong >0 \b, %d symbols -# f_opthdr - optional header size +# f_opthdr - optional header size >>16 uleshort >0 \b, optional header size %d # at offset 20 can be optional header, extra bytes FILHSZ-20 because # do not rely on sizeof(FILHDR) to give the correct size for header. diff --git contrib/file/magic/Magdir/commands contrib/file/magic/Magdir/commands index 48d706358c0e..f6ad1c878a31 100644 --- contrib/file/magic/Magdir/commands +++ contrib/file/magic/Magdir/commands @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: commands,v 1.56 2016/07/14 19:01:12 christos Exp $ +# $File: commands,v 1.59 2017/08/14 07:40:38 christos Exp $ # commands: file(1) magic for various shells and interpreters # #0 string/w : shell archive or script for antique kernel text @@ -56,7 +56,7 @@ !:mime text/x-awk 0 string/wt #!\ /usr/bin/awk awk script text executable !:mime text/x-awk -0 regex/4096 =^\\s{0,100}BEGIN\\s{0,100}[{] awk or perl script text +0 regex/4096 =^[\040\t\f\r\n]{0,100}BEGIN[\040\t\f\r\n]{0,100}[{] awk or perl script text # AT&T Bell Labs' Plan 9 shell 0 string/wt #!\ /bin/rc Plan 9 rc shell script text executable @@ -84,7 +84,7 @@ # PHP scripts # Ulf Harnhammar <ulfh@update.uu.se> 0 search/1/c =<?php PHP script text -!:strength + 10 +!:strength + 30 !:mime text/x-php 0 search/1 =<?\n PHP script text !:mime text/x-php diff --git contrib/file/magic/Magdir/compress contrib/file/magic/Magdir/compress index 3297d5dc6b9b..6fa8f3215031 100644 --- contrib/file/magic/Magdir/compress +++ contrib/file/magic/Magdir/compress @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# $File: compress,v 1.66 2016/09/16 12:12:05 christos Exp $ +# $File: compress,v 1.68 2017/05/25 20:07:23 christos Exp $ # compress: file(1) magic for pure-compression formats (no archives) # # compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc. @@ -223,7 +223,7 @@ # Zstandard/LZ4 skippable frames # https://github.com/facebook/zstd/blob/dev/zstd_compression_format.md 0 lelong&0xFFFFFFF0 0x184D2A50 ->(4.l+8) indirect +>(4.l+8) indirect x # Zstandard Dictionary ID subroutine 0 name zstd-dictionary-id @@ -310,7 +310,7 @@ # Zlib https://www.ietf.org/rfc/rfc6713.txt 0 string/b x ->0 beshort%31 =0 +>0 beshort%31 =0 >>0 byte&0xf =8 >>>0 byte&0x80 =0 zlib compressed data !:mime application/zlib diff --git contrib/file/magic/Magdir/console contrib/file/magic/Magdir/console index 2a1c9af7f035..66f5dbda294e 100644 --- contrib/file/magic/Magdir/console +++ contrib/file/magic/Magdir/console @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: console,v 1.26 2016/06/12 15:20:37 christos Exp $ +# $File: console,v 1.32 2017/08/13 00:21:47 christos Exp $ # Console game magic # Toby Deshane <hac@shoelace.digivill.net> @@ -9,17 +9,19 @@ # References: # - http://wiki.nesdev.com/w/index.php/INES # - http://wiki.nesdev.com/w/index.php/NES_2.0 -0 string NES\x1A iNES ROM image + +# Common header for iNES, NES 2.0, and Wii U iNES. +0 name nes-rom-image-ines >7 byte&0x0C =0x8 (NES 2.0) >4 byte x \b: %ux16k PRG ->5 byte x \b, %ux16k CHR +>5 byte x \b, %ux8k CHR >6 byte&0x08 =0x8 [4-Scr] >6 byte&0x09 =0x0 [H-mirror] >6 byte&0x09 =0x1 [V-mirror] >6 byte&0x02 =0x2 [SRAM] >6 byte&0x04 =0x4 [Trainer] >7 byte&0x03 =0x2 [PC10] ->7 byte&0x03 =0x1 [VS +>7 byte&0x03 =0x1 [VS] >>7 byte&0x0C =0x8 # NES 2.0: VS PPU >>>13 byte&0x0F =0x0 \b, RP2C03B @@ -43,17 +45,24 @@ >>12 byte&0x03 =0x1 [PAL] >>12 byte&0x02 =0x2 [NTSC+PAL] +# Standard iNES ROM header. +0 string NES\x1A NES ROM image (iNES) +>0 use nes-rom-image-ines + +# Wii U Virtual Console iNES ROM header. +0 belong 0x4E455300 NES ROM image (Wii U Virtual Console) +>0 use nes-rom-image-ines + #------------------------------------------------------------------------------ # unif: file(1) magic for UNIF-format Nintendo Entertainment System ROM images # Reference: http://wiki.nesdev.com/w/index.php/UNIF # From: David Korth <gerbilsoft@gerbilsoft.com> -# TODO commit on 2016/03/21 # # NOTE: The UNIF format uses chunks instead of a fixed header, # so most of the data isn't easily parseable. # 0 string UNIF ->4 lelong <16 UNIF v%d format NES ROM image +>4 lelong <16 NES ROM image (UNIF v%d format) #------------------------------------------------------------------------------ # fds: file(1) magic for Famciom Disk System disk images @@ -63,24 +72,39 @@ # Disk info block. (block 1) 0 name nintendo-fds-disk-info-block ->1 string *NINTENDO-HVC* Famicom Disk System disk image: >23 byte !1 FMC- >23 byte 1 FSC- >16 string x \b%.3s ->15 byte x \b, mfr 0x%02X +>15 byte x \b, mfr %02X >20 byte x (Rev.%02u) # Headered version. 0 string FDS\x1A ->0x11 string *NINTENDO-HVC* +>0x11 string *NINTENDO-HVC* Famicom Disk System disk image: >>0x10 use nintendo-fds-disk-info-block >4 byte 1 (%u side) >4 byte !1 (%u sides) # Unheadered version. -1 string *NINTENDO-HVC* +1 string *NINTENDO-HVC* Famicom Disk System disk image: >0 use nintendo-fds-disk-info-block +#------------------------------------------------------------------------------ +# tnes: file(1) magic for TNES-format Nintendo Entertainment System ROM images +# Used by Nintendo 3DS NES Virtual Console games. +# From: David Korth <gerbilsoft@gerbilsoft.com> +# +0 string TNES NES ROM image (Nintendo 3DS Virtual Console) +>4 byte 100 \b: FDS, +>>0x2010 use nintendo-fds-disk-info-block +>4 byte !100 \b: TNES mapper %u +>>5 byte x \b, %ux8k PRG +>>6 byte x \b, %ux8k CHR +>>7 byte&0x08 =1 [WRAM] +>>8 byte&0x09 =1 [H-mirror] +>>8 byte&0x09 =2 [V-mirror] +>>8 byte&0x02 =3 [VRAM] + #------------------------------------------------------------------------------ # gameboy: file(1) magic for the Nintendo (Color) Gameboy raw ROM format # Reference: http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header @@ -389,6 +413,15 @@ >0x1E byte x \b, Rev.%02u) >0x12 byte 2 (DSi enhanced) >0x12 byte 3 (DSi only) +# Secure Area check. +>0x20 lelong <0x4000 (homebrew) +>0x20 lelong >0x3FFF +>>0x4000 lequad 0x0000000000000000 (multiboot) +>>0x4000 lequad !0x0000000000000000 +>>>0x4000 lequad 0xE7FFDEFFE7FFDEFF (decrypted) +>>>0x4000 lequad !0xE7FFDEFFE7FFDEFF +>>>>0x1000 lequad 0x0000000000000000 (encrypted) +>>>>0x1000 lequad !0x0000000000000000 (mask ROM) #------------------------------------------------------------------------------ # nds_passme: file(1) magic for Nintendo DS ROM images for GBA cartridge boot. @@ -412,7 +445,7 @@ #------------------------------------------------------------------------------ # msx: file(1) magic for MSX game cartridge dumps # Too simple - MPi -#0 beshort 0x4142 MSX game cartridge dump +#0 beshort 0x4142 MSX game cartridge dump #------------------------------------------------------------------------------ # Sony Playstation executables (Adam Sjoegren <asjo@diku.dk>) : @@ -467,7 +500,7 @@ # Double-check that the image type matches too, 0x8008 conflicts with # 8 character OMF-86 object file headers. -0 beshort 0x8008 +0 beshort 0x8008 >6 string BS93 Lynx homebrew cartridge >>2 beshort x \b, RAM start $%04x >6 string LYNX Lynx cartridge @@ -482,7 +515,7 @@ # is the offset 12 or the offset 16 correct? # GBS (Game Boy Sound) magic # ftp://ftp.modland.com/pub/documents/format_documentation/\ -# Gameboy%20Sound%20System%20(.gbs).txt +# Gameboy%20Sound%20System%20(.gbs).txt 0 string GBS Nintendo Gameboy Music/Audio Data #12 string GameBoy\ Music\ Module Nintendo Gameboy Music Module >16 string >\0 ("%s" by @@ -491,6 +524,10 @@ >3 byte x version %d, >4 byte x %d tracks +# IPS Patch Files from: From: Thomas Klausner <tk@giga.or.at> +# see http://zerosoft.zophar.net/ips.php +0 string PATCH IPS patch file + # Playstations Patch Files from: From: Thomas Klausner <tk@giga.or.at> 0 string PPF30 Playstation Patch File version 3.0 >5 byte 0 \b, PPF 1.0 patch @@ -518,7 +555,7 @@ # SNES9x .smv "movie" file format. 0 string SMV\x1A SNES9x input recording >0x4 lelong x \b, version %d -# version 4 is latest so far +# version 4 is latest so far >0x4 lelong <5 >>0x8 ledate x \b, recorded at %s >>0xc lelong >0 \b, rerecorded %d times @@ -617,6 +654,52 @@ >0x218 belong 0x5D1C9EA3 Nintendo Wii disc image (WBFS format): >>0x200 use nintendo-gcn-disc-common +# Type: Nintendo GameCube/Wii disc image (CISO format) +# NOTE: This is NOT the same as Compact ISO or PSP CISO, +# though it has the same magic number. +0 string CISO +# Other fields are used to determine what type of CISO this is: +# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size) +# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size) +# - None of the above: Compact ISO. +>4 lelong 0x200000 +>>8 byte 1 +>>>0x801C belong 0xC2339F3D Nintendo GameCube disc image (CISO format): +>>>>0x8000 use nintendo-gcn-disc-common +>>>0x8018 belong 0x5D1C9EA3 Nintendo Wii disc image (CISO format): +>>>>0x8000 use nintendo-gcn-disc-common + +# Type: Nintendo GameCube/Wii disc image (GCZ format) +# Due to zlib compression, we can't get the actual disc information. +0 lelong 0xB10BC001 +>4 lelong 0 Nintendo GameCube disc image (GCZ format) +>4 lelong 1 Nintendo Wii disc image (GCZ format) +>4 lelong >1 Nintendo GameCube/Wii disc image (GCZ format) + +# Type: Nintendo GameCube/Wii disc image (WDF format) +0 string WII\001DISC +>8 belong 1 +# WDFv1 +>>0x54 belong 0xC2339F3D Nintendo GameCube disc image (WDFv1 format): +>>>0x38 use nintendo-gcn-disc-common +>>0x58 belong 0x5D1C9EA3 Nintendo Wii disc image (WDFv1 format): +>>>0x38 use nintendo-gcn-disc-common +>8 belong 2 +# WDFv2 +>>(12.L+0x1C) belong 0xC2339F3D Nintendo GameCube disc image (WDFv2 format): +>>>(12.L) use nintendo-gcn-disc-common +>>(12.L+0x18) belong 0x5D1C9EA3 Nintendo Wii disc image (WDFv2 format): +>>>(12.L) use nintendo-gcn-disc-common + +# Type: Nintendo GameCube/Wii disc image (WIA format) +0 string WIA\001 Nintendo +>0x48 belong 0 GameCube/Wii +>0x48 belong 1 GameCube +>0x48 belong 2 Wii +>0x48 belong >2 GameCube/Wii +>0x48 belong x disc image (WIA format): +>>0x58 use nintendo-gcn-disc-common + #------------------------------------------------------------------------------ # Nintendo 3DS file formats. # @@ -722,7 +805,7 @@ # Type: Nintendo 3DS Homebrew Application. # From: David Korth <gerbilsoft@gerbilsoft.com> -# Refernece: https://3dbrew.org/wiki/3DSX_Format +# Reference: https://3dbrew.org/wiki/3DSX_Format 0 string 3DSX Nintendo 3DS Homebrew Application (3DSX) #------------------------------------------------------------------------------ @@ -750,3 +833,17 @@ # 0 string g\ GCE Vectrex ROM image >0x11 string >\0 \b: "%.16s" + +#------------------------------------------------------------------------------ +# amiibo: file(1) magic for Nintendo amiibo NFC dumps. +# From: David Korth <gerbilsoft@gerbilsoft.com> +# Reference: https://www.3dbrew.org/wiki/Amiibo +0x00 byte 0x04 +>0x0A beshort 0x0FE0 +>>0x0C belong 0xF110FFEE +>>>0x208 beshort 0x0100 +>>>>0x020A byte 0x0F +>>>>>0x020C bequad 0x000000045F000000 +>>>>>>0x5B byte 0x02 +>>>>>>>0x54 belong x Nintendo amiibo NFC dump - amiibo ID: %08X- +>>>>>>>0x58 belong x \b%08X diff --git contrib/file/magic/Magdir/cups contrib/file/magic/Magdir/cups index 4d0056bb4b57..a065de39637d 100644 --- contrib/file/magic/Magdir/cups +++ contrib/file/magic/Magdir/cups @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: cups,v 1.4 2016/10/17 18:51:02 christos Exp $ +# $File: cups,v 1.5 2017/03/17 21:35:28 christos Exp $ # Cups: file(1) magic for the cups raster file format # From: Laurent Martelli <martellilaurent@gmail.com> # http://www.cups.org/documentation.php/spec-raster.html @@ -39,7 +39,7 @@ >404 lelong 20 ColorSpace=AdobeRGB # Cups Raster image format, Big Endian -0 string RaS +0 string RaS >3 string t Cups Raster version 1, Big Endian >3 string 2 Cups Raster version 2, Big Endian >3 string 3 Cups Raster version 3, Big Endian @@ -48,7 +48,7 @@ # Cups Raster image format, Little Endian -1 string SaR +1 string SaR >0 string t Cups Raster version 1, Little Endian >0 string 2 Cups Raster version 2, Little Endian >0 string 3 Cups Raster version 3, Little Endian diff --git contrib/file/magic/Magdir/database contrib/file/magic/Magdir/database index 15f94b1faab4..a0300ae772ce 100644 --- contrib/file/magic/Magdir/database +++ contrib/file/magic/Magdir/database @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: database,v 1.49 2016/06/11 17:01:51 christos Exp $ +# $File: database,v 1.52 2017/08/13 00:21:47 christos Exp $ # database: file(1) magic for various databases # # extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk) @@ -84,7 +84,7 @@ # From Max Bowsher. 12 long 0x00040988 Berkeley DB >16 long >0 (Log, version %d, native byte-order) -12 belong 0x00040988 Berkeley DB +12 belong 0x00040988 Berkeley DB >16 belong >0 (Log, version %d, big-endian) 12 lelong 0x00040988 Berkeley DB >16 lelong >0 (Log, version %d, little-endian) @@ -103,7 +103,7 @@ >>>12 long !0 32bit aligned >>>>12 bedouble 8.642135e+130 big-endian >>>>>20 long 0 64bit long ->>>>>20 long !0 32bit long +>>>>>20 long !0 32bit long >>>>12 ledouble 8.642135e+130 little-endian >>>>>24 long 0 64bit long >>>>>24 long !0 32bit long (i386) @@ -128,22 +128,22 @@ # XXX: Weak magic. # Alex Ott <ott@jet.msk.su> ## Paradox file formats -#2 leshort 0x0800 Paradox -#>0x39 byte 3 v. 3.0 -#>0x39 byte 4 v. 3.5 -#>0x39 byte 9 v. 4.x -#>0x39 byte 10 v. 5.x -#>0x39 byte 11 v. 5.x -#>0x39 byte 12 v. 7.x -#>>0x04 byte 0 indexed .DB data file -#>>0x04 byte 1 primary index .PX file -#>>0x04 byte 2 non-indexed .DB data file -#>>0x04 byte 3 non-incrementing secondary index .Xnn file -#>>0x04 byte 4 secondary index .Ynn file -#>>0x04 byte 5 incrementing secondary index .Xnn file -#>>0x04 byte 6 non-incrementing secondary index .XGn file -#>>0x04 byte 7 secondary index .YGn file -#>>>0x04 byte 8 incrementing secondary index .XGn file +#2 leshort 0x0800 Paradox +#>0x39 byte 3 v. 3.0 +#>0x39 byte 4 v. 3.5 +#>0x39 byte 9 v. 4.x +#>0x39 byte 10 v. 5.x +#>0x39 byte 11 v. 5.x +#>0x39 byte 12 v. 7.x +#>>0x04 byte 0 indexed .DB data file +#>>0x04 byte 1 primary index .PX file +#>>0x04 byte 2 non-indexed .DB data file +#>>0x04 byte 3 non-incrementing secondary index .Xnn file +#>>0x04 byte 4 secondary index .Ynn file +#>>0x04 byte 5 incrementing secondary index .Xnn file +#>>0x04 byte 6 non-incrementing secondary index .XGn file +#>>0x04 byte 7 secondary index .YGn file +#>>>0x04 byte 8 incrementing secondary index .XGn file ## XBase database files # updated by Joerg Jenderek at Feb 2013 @@ -151,33 +151,33 @@ # http://www.clicketyclick.dk/databases/xbase/format/dbf.html # http://home.f1.htw-berlin.de/scheibl/db/intern/dBase.htm # inspect VVYYMMDD , where 1<= MM <= 12 and 1<= DD <= 31 -0 ubelong&0x0000FFFF <0x00000C20 +0 ubelong&0x0000FFFF <0x00000C20 # skip Infocom game Z-machine ->2 ubyte >0 +>2 ubyte >0 # skip Androids *.xml ->>3 ubyte >0 ->>>3 ubyte <32 +>>3 ubyte >0 +>>>3 ubyte <32 # 1 < version VV ->>>>0 ubyte >1 +>>>>0 ubyte >1 # skip HELP.CA3 by test for reserved byte ( NULL ) ->>>>>27 ubyte 0 +>>>>>27 ubyte 0 # reserved bytes not always 0 ; also found 0x3901 (T4.DBF) ,0x7101 (T5.DBF,T6.DBF) #>>>>>30 ubeshort x 30NULL?%x -# possible production flag,tag numbers(<=0x30),tag length(<=0x20), reserved (NULL) ->>>>>>24 ubelong&0xffFFFFff >0x01302000 +# possible production flag,tag numbers(<=0x30),tag length(<=0x20), reserved (NULL) +>>>>>>24 ubelong&0xffFFFFff >0x01302000 # .DBF or .MDX ->>>>>>24 ubelong&0xffFFFFff <0x01302001 +>>>>>>24 ubelong&0xffFFFFff <0x01302001 # for Xbase Database file (*.DBF) reserved (NULL) for multi-user ->>>>>>>24 ubelong&0xffFFFFff =0 +>>>>>>>24 ubelong&0xffFFFFff =0 # test for 2 reserved NULL bytes,transaction and encryption byte flag ->>>>>>>>12 ubelong&0xFFFFfEfE 0 +>>>>>>>>12 ubelong&0xFFFFfEfE 0 # test for MDX flag ->>>>>>>>>28 ubyte x ->>>>>>>>>28 ubyte&0xf8 0 +>>>>>>>>>28 ubyte x +>>>>>>>>>28 ubyte&0xf8 0 # header size >= 32 ->>>>>>>>>>8 uleshort >31 +>>>>>>>>>>8 uleshort >31 # skip PIC15736.PCX by test for language driver name or field name ->>>>>>>>>>>32 ubyte >0 +>>>>>>>>>>>32 ubyte >0 #!:mime application/x-dbf; charset=unknown-8bit ?? #!:mime application/x-dbase >>>>>>>>>>>>0 use xbase-type @@ -202,22 +202,22 @@ >>>>>>>>>>>>28 ubyte&0x02 2 \b, with memo .FPT >>>>>>>>>>>>28 ubyte&0x04 4 \b, DataBaseContainer # 1st record offset + 1 = header size ->>>>>>>>>>>>8 uleshort >0 ->>>>>>>>>>>>(8.s+1) ubyte >0 +>>>>>>>>>>>>8 uleshort >0 +>>>>>>>>>>>>(8.s+1) ubyte >0 >>>>>>>>>>>>>8 uleshort >0 \b, at offset %d ->>>>>>>>>>>>>(8.s+1) ubyte >0 +>>>>>>>>>>>>>(8.s+1) ubyte >0 >>>>>>>>>>>>>>&-1 string >\0 1st record "%s" -# for multiple index files (*.MDX) Production flag,tag numbers(<=0x30),tag length(<=0x20), reserverd (NULL) ->>>>>>>24 ubelong&0x0133f7ff >0 +# for multiple index files (*.MDX) Production flag,tag numbers(<=0x30),tag length(<=0x20), reserved (NULL) +>>>>>>>24 ubelong&0x0133f7ff >0 # test for reserved NULL byte ->>>>>>>>47 ubyte 0 +>>>>>>>>47 ubyte 0 # test for valid TAG key format (0x10 or 0) ->>>>>>>>>559 ubyte&0xeF 0 +>>>>>>>>>559 ubyte&0xeF 0 # test MM <= 12 ->>>>>>>>>>45 ubeshort <0x0C20 ->>>>>>>>>>>45 ubyte >0 ->>>>>>>>>>>>46 ubyte <32 ->>>>>>>>>>>>>46 ubyte >0 +>>>>>>>>>>45 ubeshort <0x0C20 +>>>>>>>>>>>45 ubyte >0 +>>>>>>>>>>>>46 ubyte <32 +>>>>>>>>>>>>>46 ubyte >0 #!:mime application/x-mdx >>>>>>>>>>>>>>0 use xbase-type >>>>>>>>>>>>>>0 ubyte x \b MDX @@ -236,11 +236,11 @@ # 2nd tag name #>>>>>>>>>>>>(26.b+548) string x \b, 2nd tag "%.11s" # -# Print the xBase names of different version variants +# Print the xBase names of different version variants 0 name xbase-type ->0 ubyte <2 +>0 ubyte <2 # 1 < version ->0 ubyte >1 +>0 ubyte >1 >>0 ubyte 0x02 FoxBase # FoxBase+/dBaseIII+, no memo >>0 ubyte 0x03 FoxBase+/dBase III @@ -293,7 +293,7 @@ # dBASE IV with SQL table, with memo .DBT >>0 ubyte 0xCB dBase IV with SQL table, with memo .DBT !:mime application/x-dbf -# HiPer-Six format;Clipper SIX, with SMT memo file +# HiPer-Six format;Clipper SIX, with SMT memo file >>0 ubyte 0xE5 Clipper SIX with memo !:mime application/x-dbf # http://msdn.microsoft.com/en-US/library/st4a0s68(v=vs.80).aspx @@ -318,12 +318,12 @@ # test and print the date of xBase .DBF .MDX 0 name xbase-date # inspect YYMMDD , where 1<= MM <= 12 and 1<= DD <= 31 ->0 ubelong x ->1 ubyte <13 ->>1 ubyte >0 ->>>2 ubyte >0 ->>>>2 ubyte <32 ->>>>>0 ubyte x +>0 ubelong x +>1 ubyte <13 +>>1 ubyte >0 +>>>2 ubyte >0 +>>>>2 ubyte <32 +>>>>>0 ubyte x # YY is interpreted as 20YY or 19YY >>>>>>0 ubyte <100 \b %.2d # YY is interpreted 1900+YY; TODO: display yy or 20yy instead 1YY @@ -333,56 +333,56 @@ # dBase memo files .DBT or .FPT # http://msdn.microsoft.com/en-us/library/8599s21w(v=vs.80).aspx -16 ubyte <4 ->16 ubyte !2 ->>16 ubyte !1 +16 ubyte <4 +>16 ubyte !2 +>>16 ubyte !1 # next free block index is positive ->>>0 ulelong >0 +>>>0 ulelong >0 # skip many JPG. ZIP, BZ2 by test for reserved bytes NULL , 0|2 , 0|1 , low byte of block size ->>>>17 ubelong&0xFFfdFE00 0x00000000 +>>>>17 ubelong&0xFFfdFE00 0x00000000 # skip many RAR by test for low byte 0 ,high byte 0|2|even of block size, 0|a|e|d7 , 0|64h ->>>>>20 ubelong&0xFF01209B 0x00000000 +>>>>>20 ubelong&0xFF01209B 0x00000000 # dBASE III ->>>>>>16 ubyte 3 +>>>>>>16 ubyte 3 # dBASE III DBT >>>>>>>0 use dbase3-memo-print # dBASE III DBT without version, dBASE IV DBT , FoxPro FPT , or many ZIP , DBF garbage ->>>>>>16 ubyte 0 +>>>>>>16 ubyte 0 # unusual dBASE III DBT like angest.dbt, dBASE IV DBT with block size 0 , FoxPro FPT , or garbage PCX DBF ->>>>>>>20 uleshort 0 +>>>>>>>20 uleshort 0 # FoxPro FPT , unusual dBASE III DBT like biblio.dbt or garbage ->>>>>>>>8 ulong =0 ->>>>>>>>>6 ubeshort >0 +>>>>>>>>8 ulong =0 +>>>>>>>>>6 ubeshort >0 # skip emacs.PIF ->>>>>>>>>>4 ushort 0 +>>>>>>>>>>4 ushort 0 >>>>>>>>>>>0 use foxpro-memo-print # dBASE III DBT , garbage ->>>>>>>>>6 ubeshort 0 +>>>>>>>>>6 ubeshort 0 # skip MM*DD*.bin by test for for reserved NULL byte ->>>>>>>>>>510 ubeshort 0 +>>>>>>>>>>510 ubeshort 0 # skip TK-DOS11.img image by looking for memo text ->>>>>>>>>>>512 ubelong <0xfeffff03 +>>>>>>>>>>>512 ubelong <0xfeffff03 # skip EFI executables by looking for memo text ->>>>>>>>>>>>512 ubelong >0x1F202020 ->>>>>>>>>>>>>513 ubyte >0 +>>>>>>>>>>>>512 ubelong >0x1F202020 +>>>>>>>>>>>>>513 ubyte >0 # unusual dBASE III DBT like adressen.dbt >>>>>>>>>>>>>>0 use dbase3-memo-print # dBASE III DBT like angest.dbt, or garbage PCX DBF ->>>>>>>>8 ubelong !0 +>>>>>>>>8 ubelong !0 # skip PCX and some DBF by test for for reserved NULL bytes ->>>>>>>>>510 ubeshort 0 +>>>>>>>>>510 ubeshort 0 # skip some DBF by test of invalid version ->>>>>>>>>>0 ubyte >5 ->>>>>>>>>>>0 ubyte <48 +>>>>>>>>>>0 ubyte >5 +>>>>>>>>>>>0 ubyte <48 >>>>>>>>>>>>0 use dbase3-memo-print # dBASE IV DBT with positive block size ->>>>>>>20 uleshort >0 -# dBASE IV DBT with valid block length like 512, 1024 +>>>>>>>20 uleshort >0 +# dBASE IV DBT with valid block length like 512, 1024 # multiple of 2 in between 16 and 16 K ,implies upper and lower bits are zero ->>>>>>>>20 uleshort&0x800f 0 +>>>>>>>>20 uleshort&0x800f 0 >>>>>>>>>0 use dbase4-memo-print -# Print the information of dBase III DBT memo file +# Print the information of dBase III DBT memo file 0 name dbase3-memo-print >0 ubyte x dBase III DBT # instead 3 as version number 0 for unusual examples like biblio.dbt @@ -395,45 +395,45 @@ >20 uleshort !0 \b, block length %u # dBase III memo field terminated by \032\032 >512 string >\0 \b, 1st item "%s" -# Print the information of dBase IV DBT memo file +# Print the information of dBase IV DBT memo file 0 name dbase4-memo-print >0 lelong x dBase IV DBT !:mime application/x-dbt !:ext dbt # 8 character shorted main name of coresponding dBASE IV DBF file ->8 ubelong >0x20000000 +>8 ubelong >0x20000000 # skip unusual like for angest.dbt ->>20 uleshort >0 +>>20 uleshort >0 >>>8 string >\0 \b of %-.8s.DBF # value 0 implies 512 as size #>4 ulelong =0 \b, blocks size %u # size of blocks not reliable like 0x2020204C in angest.dbt ->4 ulelong !0 +>4 ulelong !0 >>4 ulelong&0x0000003f 0 \b, blocks size %u # dBase IV DBT with positive block length (found 512 , 1024) >20 uleshort >0 \b, block length %u # next available block #>0 lelong =0 \b, next free block index %u >0 lelong !0 \b, next free block index %u ->20 uleshort >0 ->>(20.s) ubelong x +>20 uleshort >0 +>>(20.s) ubelong x >>>&-4 use dbase4-memofield-print # unusual dBase IV DBT without block length (implies 512 as length) ->20 uleshort =0 ->>512 ubelong x +>20 uleshort =0 +>>512 ubelong x >>>&-4 use dbase4-memofield-print -# Print the information of dBase IV memo field +# Print the information of dBase IV memo field 0 name dbase4-memofield-print # free dBase IV memo field ->0 ubelong !0xFFFF0800 +>0 ubelong !0xFFFF0800 >>0 lelong x \b, next free block %u >>4 lelong x \b, next used block %u # used dBase IV memo field ->0 ubelong =0xFFFF0800 +>0 ubelong =0xFFFF0800 # length of memo field >>4 lelong x \b, field length %d >>>8 string >\0 \b, 1st used item "%s" -# Print the information of FoxPro FPT memo file +# Print the information of FoxPro FPT memo file 0 name foxpro-memo-print >0 belong x FoxPro FPT # Size of blocks for FoxPro ( 64,256 ) @@ -441,14 +441,14 @@ # next available block #>0 belong =0 \b, next free block index %u >0 belong !0 \b, next free block index %u -# field type ( 0~picture, 1~memo, 2~object ) +# field type ( 0~picture, 1~memo, 2~object ) >512 ubelong <3 \b, field type %u # length of memo field ->512 ubelong 1 +>512 ubelong 1 >>516 belong >0 \b, field length %d >>>520 string >\0 \b, 1st item "%s" -# TODO: +# TODO: # DBASE index file *.NDX # DBASE Compound Index file *.CDX # dBASE IV Printer Driver *.PRF @@ -465,9 +465,9 @@ # Reference: https://github.com/libyal/libesedb/archive/master.zip # libesedb-master/documentation/ # Extensible Storage Engine (ESE) Database File (EDB) format.asciidoc -# Note: also known as "JET Blue". Used by numerous Windows components such as +# Note: also known as "JET Blue". Used by numerous Windows components such as # Windows Search, Mail, Exchange and Active Directory. -4 ubelong 0xefcdab89 +4 ubelong 0xefcdab89 # unknown1 >132 ubelong 0 Extensible storage engine !:mime application/x-ms-ese @@ -497,8 +497,8 @@ # From: Joerg Jenderek # URL: http://forensicswiki.org/wiki/Windows_Application_Compatibility # Note: files contain application compatibility fixes, application compatibility modes and application help messages. -8 string sdbf ->7 ubyte 0 +8 string sdbf +>7 ubyte 0 # TAG_TYPE_LIST+TAG_INDEXES >>12 uleshort 0x7802 Windows application compatibility Shim DataBase # version? 2 3 @@ -600,10 +600,10 @@ # Reference: http://www.provue.com/Panorama/ # From: Joerg Jenderek # NOTE: test only versions 4 and 6.0 with Windows -# length of Panorama database name -5 ubyte >0 +# length of Panorama database name +5 ubyte >0 # look after database name for "some" null bits ->(5.B+7) ubelong&0xF3ffF000 0 +>(5.B+7) ubelong&0xF3ffF000 0 # look for first keyword >>&1 search/2 DESIGN Panorama database #!:mime application/x-panorama-database @@ -622,3 +622,13 @@ # MUIbase Database Tool by Stefan A. Haubenthal <polluks@web.de> 0 string MBSTV\040 MUIbase DB >6 string x version %s + +# +# CDB database +0 string NBCDB\012 NetBSD Constant Database +>7 byte x \b, version %d +>8 string x \b, for '%s' +>24 lelong x \b, datasize %d +>28 lelong x \b, entries %d +>32 lelong x \b, index %d +>36 lelong x \b, seed %#x diff --git contrib/file/magic/Magdir/der contrib/file/magic/Magdir/der index abfbf9b8c0a2..9c25f00cc611 100644 --- contrib/file/magic/Magdir/der +++ contrib/file/magic/Magdir/der @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# $File: der,v 1.1 2016/01/19 15:07:45 christos Exp $ +# $File: der,v 1.2 2017/03/17 21:35:28 christos Exp $ # der: file(1) magic for DER encoded files # @@ -32,37 +32,37 @@ # Key Pairs 0 der seq ->&0 der int1=00 +>&0 der int1=00 >&0 der int65=x >&0 der int3=010001 DER Encoded Key Pair, 512 bits 0 der seq ->&0 der int1=00 +>&0 der int1=00 >&0 der int129=x >&0 der int3=010001 DER Encoded Key Pair, 1024 bits 0 der seq ->&0 der int1=00 +>&0 der int1=00 >&0 der int257=x >&0 der int3=010001 DER Encoded Key Pair, 2048 bits 0 der seq ->&0 der int1=00 +>&0 der int1=00 >&0 der int513=x >&0 der int3=010001 DER Encoded Key Pair, 4096 bits 0 der seq ->&0 der int1=00 +>&0 der int1=00 >&0 der int1025=x >&0 der int3=010001 DER Encoded Key Pair, 8192 bits 0 der seq ->&0 der int1=00 +>&0 der int1=00 >&0 der int2049=x >&0 der int3=010001 DER Encoded Key Pair, 16k bits 0 der seq ->&0 der int1=00 +>&0 der int1=00 >&0 der int4097=x >&0 der int3=010001 DER Encoded Key Pair, 32k bits diff --git contrib/file/magic/Magdir/diff contrib/file/magic/Magdir/diff index 59243801eb5a..cd530d345e32 100644 --- contrib/file/magic/Magdir/diff +++ contrib/file/magic/Magdir/diff @@ -1,15 +1,15 @@ #------------------------------------------------------------------------------ -# $File: diff,v 1.14 2012/09/16 23:08:54 christos Exp $ +# $File: diff,v 1.16 2017/03/17 22:20:22 christos Exp $ # diff: file(1) magic for diff(1) output # -0 search/1 diff\ diff output text +0 search/1 diff\040 diff output text !:mime text/x-diff -0 search/1 ***\ diff output text +0 search/1 ***\040 diff output text !:mime text/x-diff -0 search/1 Only\ in\ diff output text +0 search/1 Only\040in\040 diff output text !:mime text/x-diff -0 search/1 Common\ subdirectories:\ diff output text +0 search/1 Common\040subdirectories:\040 diff output text !:mime text/x-diff 0 search/1 Index: RCS/CVS diff output text @@ -20,9 +20,9 @@ # unified diff -0 search/4096 ---\ +0 search/4096 ---\040 >&0 search/1024 \n ->>&0 search/1 +++\ +>>&0 search/1 +++\040 >>>&0 search/1024 \n >>>>&0 search/1 @@ unified diff output text !:mime text/x-diff diff --git contrib/file/magic/Magdir/dolby contrib/file/magic/Magdir/dolby index 573398f347c8..8034eddc2a8f 100644 --- contrib/file/magic/Magdir/dolby +++ contrib/file/magic/Magdir/dolby @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: dolby,v 1.7 2014/01/08 22:37:23 christos Exp $ +# $File: dolby,v 1.8 2017/03/17 21:35:28 christos Exp $ # ATSC A/53 aka AC-3 aka Dolby Digital <ashitaka@gmx.at> # from http://www.atsc.org/standards/a_52a.pdf # corrections, additions, etc. are always welcome! @@ -23,7 +23,7 @@ >5 byte&0x07 = 0x04 \b, dialogue (D) >5 byte&0x07 = 0x05 \b, commentary (C) >5 byte&0x07 = 0x06 \b, emergency (E) ->5 beshort&0x07e0 0x0720 \b, voiceover (VO) +>5 beshort&0x07e0 0x0720 \b, voiceover (VO) >5 beshort&0x07e0 >0x0720 \b, karaoke # acmod >6 byte&0xe0 = 0x00 1+1 front, diff --git contrib/file/magic/Magdir/dump contrib/file/magic/Magdir/dump index 1a20ace29c4b..73de3dc87a0b 100644 --- contrib/file/magic/Magdir/dump +++ contrib/file/magic/Magdir/dump @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: dump,v 1.13 2014/04/30 21:41:02 christos Exp $ +# $File: dump,v 1.16 2017/07/22 19:21:02 christos Exp $ # dump: file(1) magic for dump file format--for new and old dump filesystems # # We specify both byte orders in order to recognize byte-swapped dumps. @@ -62,23 +62,25 @@ >824 string >\0 Host %s, >888 belong >0 Flags %x -24 belong 60012 new-fs dump file (big endian), +24 belong 60012 new-fs dump file (big endian), >0 use new-dump-be -24 belong 60011 old-fs dump file (big endian), +24 belong 60011 old-fs dump file (big endian), >0 use old-dump-be -24 lelong 60012 new-fs dump file (little endian), +24 lelong 60012 new-fs dump file (little endian), +# to correctly recognize '*.mo' GNU message catalog (little endian) +!:strength - 15 >0 use \^new-dump-be -24 lelong 60011 old-fs dump file (little endian), +24 lelong 60011 old-fs dump file (little endian), >0 use \^old-dump-be -24 belong 0x19540119 new-fs dump file (ufs2, big endian), +24 belong 0x19540119 new-fs dump file (ufs2, big endian), >0 use ufs2-dump-be -24 lelong 0x19540119 new-fs dump file (ufs2, little endian), +24 lelong 0x19540119 new-fs dump file (ufs2, little endian), >0 use \^ufs2-dump-be 18 leshort 60011 old-fs dump file (16-bit, assuming PDP-11 endianness), diff --git contrib/file/magic/Magdir/dyadic contrib/file/magic/Magdir/dyadic index ab7346586eab..185970e4ee00 100644 --- contrib/file/magic/Magdir/dyadic +++ contrib/file/magic/Magdir/dyadic @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: dyadic,v 1.7 2015/05/27 18:02:48 christos Exp $ +# $File: dyadic,v 1.8 2017/03/17 21:35:28 christos Exp $ # Dyadic: file(1) magic for Dyalog APL. # # updated by Joerg Jenderek at Oct 2013 @@ -10,9 +10,9 @@ # .DIN Dyalog APL Input Table # .DOT Dyalog APL Output Table # .DFT Dyalog APL Format File -0 ubeshort&0xFF60 0xaa00 +0 ubeshort&0xFF60 0xaa00 # skip biblio.dbt ->1 byte !4 +>1 byte !4 # real Dyalog APL have non zero version numbers like 7.3 or 13.4 >>2 ubeshort >0x0000 Dyalog APL >>>1 byte 0x00 aplcore diff --git contrib/file/magic/Magdir/editors contrib/file/magic/Magdir/editors index fa6cbc64c095..78f3a84056e6 100644 --- contrib/file/magic/Magdir/editors +++ contrib/file/magic/Magdir/editors @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------ -# $File: editors,v 1.10 2016/07/18 17:44:49 christos Exp $ -# T602 editor documents +# $File: editors,v 1.11 2017/03/17 21:35:28 christos Exp $ +# T602 editor documents # by David Necas <yeti@physics.muni.cz> 0 string @CT\ T602 document data, >4 string 0 Kamenicky @@ -9,7 +9,7 @@ >4 string 2 KOI8-CS >4 string >2 unknown encoding -# Vi IMproved Encrypted file +# Vi IMproved Encrypted file # by David Necas <yeti@physics.muni.cz> 0 string VimCrypt~ Vim encrypted file data diff --git contrib/file/magic/Magdir/filesystems contrib/file/magic/Magdir/filesystems index b7c6e5b32fa7..48b74e04c8ff 100644 --- contrib/file/magic/Magdir/filesystems +++ contrib/file/magic/Magdir/filesystems @@ -1,8 +1,8 @@ #------------------------------------------------------------------------------ -# $File: filesystems,v 1.114 2016/09/05 08:34:25 christos Exp $ +# $File: filesystems,v 1.122 2017/07/21 10:34:41 christos Exp $ # filesystems: file(1) magic for different filesystems # -0 name partid +0 name partid >0 ubyte 0x00 Unused >0 ubyte 0x01 12-bit FAT >0 ubyte 0x02 XENIX / @@ -187,7 +187,7 @@ 0 string \366\366\366\366 PC formatted floppy with no filesystem # Sun disk labels # From /usr/include/sun/dklabel.h: -0774 beshort 0xdabe +0774 beshort 0xdabe # modified by Joerg Jenderek, because original test # succeeds for Cabinet archive dao360.dl_ with negative blocks >0770 long >0 Sun disk label @@ -213,50 +213,50 @@ # (http://btmgr.sourceforge.net/docs/user-guide-3.html) 0 string SBMBAKUP_ Smart Boot Manager backup file >9 string x \b, version %-5.5s ->>14 string =_ +>>14 string =_ >>>15 string x %-.1s >>>>16 string =_ \b. >>>>>17 string x \b%-.1s >>>>>>18 string =_ \b. >>>>>>>19 string x \b%-.1s ->>>22 ubyte 0 +>>>22 ubyte 0 >>>>21 ubyte x \b, from drive 0x%x ->>>22 ubyte >0 +>>>22 ubyte >0 >>>>21 string x \b, from drive %s ->>>535 search/17 \x55\xAA ->>>>&-512 indirect x \b; contains +>>>535 search/17 \x55\xAA +>>>>&-512 indirect x \b; contains # updated by Joerg Jenderek at Nov 2012 # DOS Emulator image is 128 byte, null right padded header + harddisc image -0 string DOSEMU\0 ->0x27E leshort 0xAA55 +0 string DOSEMU\0 +>0x27E leshort 0xAA55 #offset is 128 ->>19 ubyte 128 +>>19 ubyte 128 >>>(19.b-1) ubyte 0x0 DOS Emulator image >>>>7 ulelong >0 \b, %u heads >>>>11 ulelong >0 \b, %d sectors/track >>>>15 ulelong >0 \b, %d cylinders ->>>>128 indirect x \b; contains +>>>>128 indirect x \b; contains # added by Joerg Jenderek at Nov 2012 # http://www.thenakedpc.com/articles/v04/08/0408-05.html # Symantec (Peter Norton) Image.dat file consists of variable header, bootrecord, part of FAT and root directory data 0 string PNCIHISK\0 Norton Utilities disc image data # real x86 boot sector with jump instruction ->509 search/1026 \x55\xAA\xeb ->>&-1 indirect x \b; contains +>509 search/1026 \x55\xAA\xeb +>>&-1 indirect x \b; contains # http://file-extension.net/seeker/file_extension_dat 0 string PNCIUNDO Norton Disk Doctor UnDo file # # DOS/MBR boot sector updated by Joerg Jenderek at Sep 2007,May 2011,2013 # for any allowed sector sizes -30 search/481 \x55\xAA +30 search/481 \x55\xAA # to display DOS/MBR boot sector (40) before old one (strength=50+21),Syslinux bootloader (71),SYSLINUX MBR (37+36),NetBSD mbr (110),AdvanceMAME mbr (111) # DOS BPB information (70) and after DOS floppy (120) like in previous file version !:strength +65 # for sector sizes < 512 Bytes ->11 uleshort <512 +>11 uleshort <512 >>(11.s-2) uleshort 0xAA55 DOS/MBR boot sector # for sector sizes with 512 or more Bytes >0x1FE leshort 0xAA55 DOS/MBR boot sector @@ -270,18 +270,18 @@ >2 string OSBS OS/BS MBR # added by Joerg Jenderek at Feb 2013 according to http://thestarman.pcministry.com/asm/mbr/ # and http://en.wikipedia.org/wiki/Master_Boot_Record -# test for nearly all MS-DOS Master Boot Record initial program loader (IPL) is now done by +# test for nearly all MS-DOS Master Boot Record initial program loader (IPL) is now done by # characteristic assembler instructions: xor ax,ax;mov ss,ax;mov sp,7c00 >0 search/2 \x33\xc0\x8e\xd0\xbc\x00\x7c MS-MBR # Microsoft Windows 95A and early ( http://thestarman.pcministry.com/asm/mbr/STDMBR.htm ) # assembler instructions: mov si,sp;push ax;pop es;push ax;pop ds;sti;cld ->>8 ubequad 0x8bf45007501ffbfc +>>8 ubequad 0x8bf45007501ffbfc # http://thestarman.pcministry.com/asm/mbr/200MBR.htm >>>0x16 ubyte 0xF3 \b,DOS 2 >>>>219 regex Author\ -\ Author: # found "David Litton" , "A Pehrsson " >>>>>&0 string x "%s" ->>>0x16 ubyte 0xF2 +>>>0x16 ubyte 0xF2 # NEC MS-DOS 3.30 Rev. 3 . See http://thestarman.pcministry.com/asm/mbr/DOS33MBR.htm # assembler instructions: mov di,077c;cmp word ptrl[di],a55a;jnz >>>>0x22 ubequad 0xbf7c07813d5aa575 \b,NEC 3.3 @@ -316,7 +316,7 @@ >>>>>>(0x79.b) string >\0 "%s" # Microsoft Windows 95B to XP (http://thestarman.pcministry.com/asm/mbr/95BMEMBR.htm) # assembler instructions: push ax;pop es;push ax;pop ds;cld;mov si,7c1b ->>8 ubequad 0x5007501ffcbe1b7c +>>8 ubequad 0x5007501ffcbe1b7c # assembler instructions: rep;movsb;retf;mov si,07be;mov cl,04 >>>24 ubequad 0xf3a4cbbebe07b104 9M # "Invalid partition table" nn=0x10F for english version @@ -361,7 +361,7 @@ >>>>(0x1b7.b+0x100) string >\0 "%s" # Microsoft Windows Vista or 7 # assembler instructions: ..;mov ds,ax;mov si,7c00;mov di,..00 ->>8 ubequad 0xc08ed8be007cbf00 +>>8 ubequad 0xc08ed8be007cbf00 # Microsoft Windows Vista (http://thestarman.pcministry.com/asm/mbr/VistaMBR.htm) # assembler instructions: jnz 0729;cmp ebx,"TCPA" >>>0xEC ubequad 0x753b6681fb544350 Vista @@ -402,38 +402,38 @@ # http://en.wikipedia.org/wiki/MBR_disk_signature#ID >>0x1b8 ulelong >0 \b, disk signature 0x%-.4x # driveID/timestamp for Win 95B,98,98SE and ME. See http://thestarman.pcministry.com/asm/mbr/mystery.htm ->>0xDA uleshort 0 +>>0xDA uleshort 0 >>>0xDC ulelong >0 \b, created # physical drive number (0x80-0xFF) when the Windows wrote that byte to the drive >>>>0xDC ubyte x with driveID 0x%x -# hours, minutes and seconds +# hours, minutes and seconds >>>>0xDf ubyte x at %x >>>>0xDe ubyte x \b:%x >>>>0xDd ubyte x \b:%x # special case for Microsoft MS-DOS 3.21 spanish -# assembler instructions: cli;mov $0x30,%ax;mov %ax,%ss;mov ->0 ubequad 0xfab830008ed0bc00 -# assembler instructions: $0x1f00,%sp;mov $0x80cb,%di;add %cl,(%bx,%si);in (%dx),%ax;mov +# assembler instructions: cli;mov $0x30,%ax;mov %ax,%ss;mov +>0 ubequad 0xfab830008ed0bc00 +# assembler instructions: $0x1f00,%sp;mov $0x80cb,%di;add %cl,(%bx,%si);in (%dx),%ax;mov >>8 ubequad 0x1fbfcb800008ed8 MS-MBR,D0S version 3.21 spanish # Microsoft MBR IPL end # dr-dos with some upper-, lowercase variants ->0x9D string Invalid\ partition\ table$ ->>181 string No\ Operating\ System$ +>0x9D string Invalid\ partition\ table$ +>>181 string No\ Operating\ System$ >>>201 string Operating\ System\ load\ error$ \b, DR-DOS MBR, Version 7.01 to 7.03 ->0x9D string Invalid\ partition\ table$ ->>181 string No\ operating\ system$ +>0x9D string Invalid\ partition\ table$ +>>181 string No\ operating\ system$ >>>201 string Operating\ system\ load\ error$ \b, DR-DOS MBR, Version 7.01 to 7.03 ->342 string Invalid\ partition\ table$ ->>366 string No\ operating\ system$ +>342 string Invalid\ partition\ table$ +>>366 string No\ operating\ system$ >>>386 string Operating\ system\ load\ error$ \b, DR-DOS MBR, version 7.01 to 7.03 ->295 string NEWLDR\0 ->>302 string Bad\ PT\ $ ->>>310 string No\ OS\ $ ->>>>317 string OS\ load\ err$ ->>>>>329 string Moved\ or\ missing\ IBMBIO.LDR\n\r ->>>>>>358 string Press\ any\ key\ to\ continue.\n\r$ ->>>>>>>387 string Copyright\ (c)\ 1984,1998 +>295 string NEWLDR\0 +>>302 string Bad\ PT\ $ +>>>310 string No\ OS\ $ +>>>>317 string OS\ load\ err$ +>>>>>329 string Moved\ or\ missing\ IBMBIO.LDR\n\r +>>>>>>358 string Press\ any\ key\ to\ continue.\n\r$ +>>>>>>>387 string Copyright\ (c)\ 1984,1998 >>>>>>>>411 string Caldera\ Inc.\0 \b, DR-DOS MBR (IBMBIO.LDR) # # tests for different MS-DOS Master Boot Records (MBR) moved and merged @@ -441,15 +441,15 @@ #>0x145 string Default:\ F \b, FREE-DOS MBR #>0x14B string Default:\ F \b, FREE-DOS 1.0 MBR >0x145 search/7 Default:\ F \b, FREE-DOS MBR -#>>313 string F0\ .\ .\ . -#>>>322 string disk\ 1 -#>>>>382 string FAT3 ->64 string no\ active\ partition\ found +#>>313 string F0\ .\ .\ . +#>>>322 string disk\ 1 +#>>>>382 string FAT3 +>64 string no\ active\ partition\ found >>96 string read\ error\ while\ reading\ drive \b, FREE-DOS Beta 0.9 MBR # Ranish Partition Manager http://www.ranish.com/part/ ->387 search/4 \0\ Error!\r ->>378 search/7 Virus! ->>>397 search/4 Booting\ +>387 search/4 \0\ Error!\r +>>378 search/7 Virus! +>>>397 search/4 Booting\040 >>>>408 search/4 HD1/\0 \b, Ranish MBR ( >>>>>416 string Writing\ changes... \b2.37 >>>>>>438 ubyte x \b,0x%x dots @@ -466,23 +466,23 @@ # # SYSLINUX MBR moved # http://www.acronis.de/ ->362 string MBR\ Error\ \0\r ->>376 string ress\ any\ key\ to\ +>362 string MBR\ Error\ \0\r +>>376 string ress\ any\ key\ to\040 >>>392 string boot\ from\ floppy...\0 \b, Acronis MBR # added by Joerg Jenderek # http://www.visopsys.org/ # http://partitionlogic.org.uk/ ->309 string No\ bootable\ partition\ found\r +>309 string No\ bootable\ partition\ found\r >>339 string I/O\ Error\ reading\ boot\ sector\r \b, Visopsys MBR ->349 string No\ bootable\ partition\ found\r +>349 string No\ bootable\ partition\ found\r >>379 string I/O\ Error\ reading\ boot\ sector\r \b, simple Visopsys MBR # bootloader, bootmanager ->0x40 string SBML +>0x40 string SBML # label with 11 characters of FAT 12 bit filesystem ->>43 string SMART\ BTMGR +>>43 string SMART\ BTMGR >>>430 string SBMK\ Bad!\r \b, Smart Boot Manager # OEM-ID not always "SBM" -#>>>>3 strings SBM +#>>>>3 strings SBM >>>>6 string >\0 \b, version %s >382 string XOSLLOADXCF \b, eXtended Operating System Loader >6 string LILO \b, LInux i386 boot LOader @@ -492,11 +492,11 @@ # variables according to grub-0.97/stage1/stage1.S or # http://www.gnu.org/software/grub/manual/grub.html#Embedded-data # usual values are marked with comments to get only informations of strange GRUB loaders ->342 search/60 \0Geom\0 +>342 search/60 \0Geom\0 #>0 ulelong x %x=0x009048EB , 0x2a9048EB 0 ->>0x41 ubyte <2 +>>0x41 ubyte <2 >>>0x3E ubyte >2 \b; GRand Unified Bootloader -# 0x3 for 0.5.95,0.93,0.94,0.96 0x4 for 1.90 +# 0x3 for 0.5.95,0.93,0.94,0.96 0x4 for 1.90 >>>>0x3E ubyte x \b, stage1 version 0x%x #If it is 0xFF, use a drive passed by BIOS >>>>0x40 ubyte <0xFF \b, boot drive 0x%x @@ -521,497 +521,497 @@ >>>>391 string Geom\0Hard\ Disk\0Read\0\ Error\0 >>>>>385 string GRUB\ \0 \b, GRUB version 0.97 # unknown version ->>>343 string Geom\0Read\0\ Error\0 +>>>343 string Geom\0Read\0\ Error\0 >>>>321 string Loading\ stage1.5 \b, GRUB version x.y >>>380 string Geom\0Hard\ Disk\0Read\0\ Error\0 >>>>374 string GRUB\ \0 \b, GRUB version n.m # SYSLINUX bootloader moved >395 string chksum\0\ ERROR!\0 \b, Gujin bootloader # http://www.bcdwb.de/bcdw/index_e.htm ->3 string BCDL +>3 string BCDL >>498 string BCDL\ \ \ \ BIN \b, Bootable CD Loader (1.50Z) # mbr partition table entries updated by Joerg Jenderek at Sep 2013 # skip Norton Utilities disc image data ->3 string !IHISK +>3 string !IHISK # skip Linux style boot sector starting with assember instructions mov 0x7c0,ax; ->>0 belong !0xb8c0078e -# not Linux kernel ->>>514 string !HdrS +>>0 belong !0xb8c0078e +# not Linux kernel +>>>514 string !HdrS # not BeOS ->>>>422 string !Be\ Boot\ Loader -# jump over BPB instruction implies DOS bootsector or AdvanceMAME mbr ->>>>>0 ubelong&0xFD000000 =0xE9000000 +>>>>422 string !Be\ Boot\ Loader +# jump over BPB instruction implies DOS bootsector or AdvanceMAME mbr +>>>>>0 ubelong&0xFD000000 =0xE9000000 # AdvanceMAME mbr ->>>>>>(1.b+2) ubequad 0xfa31c08ed88ec08e +>>>>>>(1.b+2) ubequad 0xfa31c08ed88ec08e >>>>>>>446 use partition-table # mbr, Norton Utilities disc image data, or 2nd,etc. sector of x86 bootloader ->>>>>0 ubelong&0xFD000000 !0xE9000000 +>>>>>0 ubelong&0xFD000000 !0xE9000000 # skip FSInfosector ->>>>>>0 string !RRaA +>>>>>>0 string !RRaA # skip 3rd sector of MS x86 bootloader with assember instructions cli;MOVZX EAX,BYTE PTR [BP+10];MOV ECX, # http://thestarman.pcministry.com/asm/mbr/MSWIN41.htm ->>>>>>>0 ubequad !0xfa660fb64610668b +>>>>>>>0 ubequad !0xfa660fb64610668b # skip 13rd sector of MS x86 bootloader ->>>>>>>>0 ubequad !0x660fb64610668b4e +>>>>>>>>0 ubequad !0x660fb64610668b4e # skip sector starting with DOS new line ->>>>>>>>>0 string !\r\n +>>>>>>>>>0 string !\r\n # allowed active flag 0,80h-FFh ->>>>>>>>>>446 ubyte 0 +>>>>>>>>>>446 ubyte 0 >>>>>>>>>>>446 use partition-table ->>>>>>>>>>446 ubyte >0x7F +>>>>>>>>>>446 ubyte >0x7F >>>>>>>>>>>446 use partition-table # TODO: test for extended bootrecord (ebr) moved and merged with mbr partition table entries # mbr partition table entries end # http://www.acronis.de/ #FAT label=ACRONIS\ SZ #OEM-ID=BOOTWIZ0 ->442 string Non-system\ disk,\ +>442 string Non-system\ disk,\040 >>459 string press\ any\ key...\x7\0 \b, Acronis Startup Recovery Loader # updated by Joerg Jenderek at Nov 2012, Sep 2013 # DOS names like F11.SYS or BOOTWIZ.SYS are 8 right space padded bytes+3 bytes # display 1 space ->>>447 ubyte x \b +>>>447 ubyte x \b >>>477 use DOS-filename # ->185 string FDBOOT\ Version\ ->>204 string \rNo\ Systemdisk.\ ->>>220 string Booting\ from\ harddisk.\n\r ->>>245 string Cannot\ load\ from\ harddisk.\n\r ->>>>273 string Insert\ Systemdisk\ +>185 string FDBOOT\ Version\040 +>>204 string \rNo\ Systemdisk.\040 +>>>220 string Booting\ from\ harddisk.\n\r +>>>245 string Cannot\ load\ from\ harddisk.\n\r +>>>>273 string Insert\ Systemdisk\040 >>>>>291 string and\ press\ any\ key.\n\r \b, FDBOOT harddisk Bootloader >>>>>>200 string >\0 \b, version %-3s ->242 string Bootsector\ from\ C.H.\ Hochst\204 +>242 string Bootsector\ from\ C.H.\ Hochst\204 # http://freecode.com/projects/dosfstools dosfstools-n.m/src/mkdosfs.c # updated by Joerg Jenderek at Nov 2012. Use search directive with offset instead of string # skip name "C.H. Hochstaetter" partly because it is sometimes written without umlaut ->242 search/127 Bootsector\ from\ C.H.\ Hochst ->>278 search/127 No\ Systemdisk.\ Booting\ from\ harddisk +>242 search/127 Bootsector\ from\ C.H.\ Hochst +>>278 search/127 No\ Systemdisk.\ Booting\ from\ harddisk # followed by variants with point,CR-NL or NL-CR ->>>208 search/261 Cannot\ load\ from\ harddisk. +>>>208 search/261 Cannot\ load\ from\ harddisk. # followed by variants CR-NL or NL-CR ->>>>236 search/235 Insert\ Systemdisk\ and\ press\ any\ key. +>>>>236 search/235 Insert\ Systemdisk\ and\ press\ any\ key. # followed by variants with point,CR-NL or NL-CR >>>>>180 search/96 Disk\ formatted\ with\ WinImage\ \b, WinImage harddisk Bootloader # followed by string like "6.50 (c) 1993-2004 Gilles Vollant" >>>>>>&0 string x \b, version %-4.4s ->(1.b+2) ubyte 0xe ->>(1.b+3) ubyte 0x1f ->>>(1.b+4) ubyte 0xbe +>(1.b+2) ubyte 0xe +>>(1.b+3) ubyte 0x1f +>>>(1.b+4) ubyte 0xbe # message offset found at (1.b+5) is 0x77 for FAT32 or 0x5b for others ->>>>(1.b+5) ubyte&0xd3 0x53 ->>>>>(1.b+6) ubyte 0x7c +>>>>(1.b+5) ubyte&0xd3 0x53 +>>>>>(1.b+6) ubyte 0x7c # assembler instructions: lodsb;and al,al;jz 0xb;push si;mov ah, ->>>>>>(1.b+7) ubyte 0xac ->>>>>>>(1.b+8) ubyte 0x22 ->>>>>>>>(1.b+9) ubyte 0xc0 ->>>>>>>>>(1.b+10) ubyte 0x74 ->>>>>>>>>>(1.b+11) ubyte 0x0b ->>>>>>>>>>>(1.b+12) ubyte 0x56 +>>>>>>(1.b+7) ubyte 0xac +>>>>>>>(1.b+8) ubyte 0x22 +>>>>>>>>(1.b+9) ubyte 0xc0 +>>>>>>>>>(1.b+10) ubyte 0x74 +>>>>>>>>>>(1.b+11) ubyte 0x0b +>>>>>>>>>>>(1.b+12) ubyte 0x56 >>>>>>>>>>>>(1.b+13) ubyte 0xb4 \b, mkdosfs boot message display # FAT1X version ->>>>>>>>>>>>>(1.b+5) ubyte 0x5b +>>>>>>>>>>>>>(1.b+5) ubyte 0x5b >>>>>>>>>>>>>>0x5b string >\0 "%-s" # FAT32 version ->>>>>>>>>>>>>(1.b+5) ubyte 0x77 +>>>>>>>>>>>>>(1.b+5) ubyte 0x77 >>>>>>>>>>>>>>0x77 string >\0 "%-s" >214 string Please\ try\ to\ install\ FreeDOS\ \b, DOS Emulator boot message display -#>>244 string from\ dosemu-freedos-*-bin.tgz\r -#>>>170 string Sorry,\ could\ not\ load\ an\ -#>>>>195 string operating\ system.\r\n +#>>244 string from\ dosemu-freedos-*-bin.tgz\r +#>>>170 string Sorry,\ could\ not\ load\ an\040 +#>>>>195 string operating\ system.\r\n # ->103 string This\ is\ not\ a\ bootable\ disk.\ ->>132 string Please\ insert\ a\ bootable\ ->>>157 string floppy\ and\r\n +>103 string This\ is\ not\ a\ bootable\ disk.\040 +>>132 string Please\ insert\ a\ bootable\040 +>>>157 string floppy\ and\r\n >>>>169 string press\ any\ key\ to\ try\ again...\r \b, FREE-DOS message display # ->66 string Solaris\ Boot\ Sector ->>99 string Incomplete\ MDBoot\ load. +>66 string Solaris\ Boot\ Sector +>>99 string Incomplete\ MDBoot\ load. >>>89 string Version \b, Sun Solaris Bootloader >>>>97 byte x version %c # ->408 string OS/2\ !!\ SYS01475\r\0 ->>429 string OS/2\ !!\ SYS02025\r\0 ->>>450 string OS/2\ !!\ SYS02027\r\0 +>408 string OS/2\ !!\ SYS01475\r\0 +>>429 string OS/2\ !!\ SYS02025\r\0 +>>>450 string OS/2\ !!\ SYS02027\r\0 >>>469 string OS2BOOT\ \ \ \ \b, IBM OS/2 Warp bootloader # ->409 string OS/2\ !!\ SYS01475\r\0 ->>430 string OS/2\ !!\ SYS02025\r\0 ->>>451 string OS/2\ !!\ SYS02027\r\0 +>409 string OS/2\ !!\ SYS01475\r\0 +>>430 string OS/2\ !!\ SYS02025\r\0 +>>>451 string OS/2\ !!\ SYS02027\r\0 >>>470 string OS2BOOT\ \ \ \ \b, IBM OS/2 Warp Bootloader ->112 string This\ disk\ is\ not\ bootable\r ->>142 string If\ you\ wish\ to\ make\ it\ bootable ->>>176 string run\ the\ DOS\ program\ SYS\ ->>>200 string after\ the\r ->>>>216 string system\ has\ been\ loaded\r\n ->>>>>242 string Please\ insert\ a\ DOS\ diskette\ ->>>>>271 string into\r\n\ the\ drive\ and\ +>112 string This\ disk\ is\ not\ bootable\r +>>142 string If\ you\ wish\ to\ make\ it\ bootable +>>>176 string run\ the\ DOS\ program\ SYS\040 +>>>200 string after\ the\r +>>>>216 string system\ has\ been\ loaded\r\n +>>>>>242 string Please\ insert\ a\ DOS\ diskette\040 +>>>>>271 string into\r\n\ the\ drive\ and\040 >>>>>>292 string strike\ any\ key...\0 \b, IBM OS/2 Warp message display # XP ->430 string NTLDR\ is\ missing\xFF\r\n ->>449 string Disk\ error\xFF\r\n +>430 string NTLDR\ is\ missing\xFF\r\n +>>449 string Disk\ error\xFF\r\n >>>462 string Press\ any\ key\ to\ restart\r \b, Microsoft Windows XP Bootloader # DOS names like NTLDR,CMLDR,$LDR$ are 8 right space padded bytes+3 bytes ->>>>417 ubyte&0xDF >0 +>>>>417 ubyte&0xDF >0 >>>>>417 string x %-.5s ->>>>>>422 ubyte&0xDF >0 +>>>>>>422 ubyte&0xDF >0 >>>>>>>422 string x \b%-.3s ->>>>>425 ubyte&0xDF >0 +>>>>>425 ubyte&0xDF >0 >>>>>>425 string >\ \b.%-.3s # ->>>>371 ubyte >0x20 ->>>>>368 ubyte&0xDF >0 +>>>>371 ubyte >0x20 +>>>>>368 ubyte&0xDF >0 >>>>>>368 string x %-.5s ->>>>>>>373 ubyte&0xDF >0 +>>>>>>>373 ubyte&0xDF >0 >>>>>>>>373 string x \b%-.3s ->>>>>>376 ubyte&0xDF >0 +>>>>>>376 ubyte&0xDF >0 >>>>>>>376 string x \b.%-.3s # ->430 string NTLDR\ nicht\ gefunden\xFF\r\n ->>453 string Datentr\204gerfehler\xFF\r\n +>430 string NTLDR\ nicht\ gefunden\xFF\r\n +>>453 string Datentr\204gerfehler\xFF\r\n >>>473 string Neustart\ mit\ beliebiger\ Taste\r \b, Microsoft Windows XP Bootloader (german) ->>>>417 ubyte&0xDF >0 +>>>>417 ubyte&0xDF >0 >>>>>417 string x %-.5s ->>>>>>422 ubyte&0xDF >0 +>>>>>>422 ubyte&0xDF >0 >>>>>>>422 string x \b%-.3s ->>>>>425 ubyte&0xDF >0 +>>>>>425 ubyte&0xDF >0 >>>>>>425 string >\ \b.%-.3s # offset variant ->>>>379 string \0 ->>>>>368 ubyte&0xDF >0 +>>>>379 string \0 +>>>>>368 ubyte&0xDF >0 >>>>>>368 string x %-.5s ->>>>>>>373 ubyte&0xDF >0 +>>>>>>>373 ubyte&0xDF >0 >>>>>>>>373 string x \b%-.3s # ->430 string NTLDR\ fehlt\xFF\r\n ->>444 string Datentr\204gerfehler\xFF\r\n +>430 string NTLDR\ fehlt\xFF\r\n +>>444 string Datentr\204gerfehler\xFF\r\n >>>464 string Neustart\ mit\ beliebiger\ Taste\r \b, Microsoft Windows XP Bootloader (2.german) ->>>>417 ubyte&0xDF >0 +>>>>417 ubyte&0xDF >0 >>>>>417 string x %-.5s ->>>>>>422 ubyte&0xDF >0 +>>>>>>422 ubyte&0xDF >0 >>>>>>>422 string x \b%-.3s ->>>>>425 ubyte&0xDF >0 +>>>>>425 ubyte&0xDF >0 >>>>>>425 string >\ \b.%-.3s # variant ->>>>371 ubyte >0x20 ->>>>>368 ubyte&0xDF >0 +>>>>371 ubyte >0x20 +>>>>>368 ubyte&0xDF >0 >>>>>>368 string x %-.5s ->>>>>>>373 ubyte&0xDF >0 +>>>>>>>373 ubyte&0xDF >0 >>>>>>>>373 string x \b%-.3s ->>>>>>376 ubyte&0xDF >0 +>>>>>>376 ubyte&0xDF >0 >>>>>>>376 string x \b.%-.3s # ->430 string NTLDR\ fehlt\xFF\r\n ->>444 string Medienfehler\xFF\r\n +>430 string NTLDR\ fehlt\xFF\r\n +>>444 string Medienfehler\xFF\r\n >>>459 string Neustart:\ Taste\ dr\201cken\r \b, Microsoft Windows XP Bootloader (3.german) ->>>>371 ubyte >0x20 ->>>>>368 ubyte&0xDF >0 +>>>>371 ubyte >0x20 +>>>>>368 ubyte&0xDF >0 >>>>>>368 string x %-.5s ->>>>>>>373 ubyte&0xDF >0 +>>>>>>>373 ubyte&0xDF >0 >>>>>>>>373 string x \b%-.3s ->>>>>>376 ubyte&0xDF >0 +>>>>>>376 ubyte&0xDF >0 >>>>>>>376 string x \b.%-.3s # variant ->>>>417 ubyte&0xDF >0 +>>>>417 ubyte&0xDF >0 >>>>>417 string x %-.5s ->>>>>>422 ubyte&0xDF >0 +>>>>>>422 ubyte&0xDF >0 >>>>>>>422 string x \b%-.3s ->>>>>425 ubyte&0xDF >0 +>>>>>425 ubyte&0xDF >0 >>>>>>425 string >\ \b.%-.3s # ->430 string Datentr\204ger\ entfernen\xFF\r\n ->>454 string Medienfehler\xFF\r\n +>430 string Datentr\204ger\ entfernen\xFF\r\n +>>454 string Medienfehler\xFF\r\n >>>469 string Neustart:\ Taste\ dr\201cken\r \b, Microsoft Windows XP Bootloader (4.german) ->>>>379 string \0 ->>>>>368 ubyte&0xDF >0 +>>>>379 string \0 +>>>>>368 ubyte&0xDF >0 >>>>>>368 string x %-.5s ->>>>>>>373 ubyte&0xDF >0 +>>>>>>>373 ubyte&0xDF >0 >>>>>>>>373 string x \b%-.3s ->>>>>>376 ubyte&0xDF >0 +>>>>>>376 ubyte&0xDF >0 >>>>>>>376 string x \b.%-.3s # variant ->>>>417 ubyte&0xDF >0 +>>>>417 ubyte&0xDF >0 >>>>>417 string x %-.5s ->>>>>>422 ubyte&0xDF >0 +>>>>>>422 ubyte&0xDF >0 >>>>>>>422 string x \b%-.3s ->>>>>425 ubyte&0xDF >0 +>>>>>425 ubyte&0xDF >0 >>>>>>425 string >\ \b.%-.3s # -#>3 string NTFS\ \ \ \ ->389 string Fehler\ beim\ Lesen\ +#>3 string NTFS\ \ \ \040 +>389 string Fehler\ beim\ Lesen\040 >>407 string des\ Datentr\204gers ->>>426 string NTLDR\ fehlt +>>>426 string NTLDR\ fehlt >>>>440 string NTLDR\ ist\ komprimiert >>>>>464 string Neustart\ mit\ Strg+Alt+Entf\r \b, Microsoft Windows XP Bootloader NTFS (german) -#>3 string NTFS\ \ \ \ +#>3 string NTFS\ \ \ \040 >313 string A\ disk\ read\ error\ occurred.\r ->>345 string A\ kernel\ file\ is\ missing\ ->>>370 string from\ the\ disk.\r ->>>>484 string NTLDR\ is\ compressed ->>>>>429 string Insert\ a\ system\ diskette\ +>>345 string A\ kernel\ file\ is\ missing\040 +>>>370 string from\ the\ disk.\r +>>>>484 string NTLDR\ is\ compressed +>>>>>429 string Insert\ a\ system\ diskette\040 >>>>>>454 string and\ restart\r\nthe\ system.\r \b, Microsoft Windows XP Bootloader NTFS # DOS loader variants different languages,offsets >472 ubyte&0xDF >0 ->>389 string Invalid\ system\ disk\xFF\r\n ->>>411 string Disk\ I/O\ error ->>>>428 string Replace\ the\ disk,\ and\ +>>389 string Invalid\ system\ disk\xFF\r\n +>>>411 string Disk\ I/O\ error +>>>>428 string Replace\ the\ disk,\ and\040 >>>>>455 string press\ any\ key \b, Microsoft Windows 98 Bootloader #IO.SYS ->>>>>>472 ubyte&0xDF >0 +>>>>>>472 ubyte&0xDF >0 >>>>>>>472 string x \b %-.2s ->>>>>>>>474 ubyte&0xDF >0 +>>>>>>>>474 ubyte&0xDF >0 >>>>>>>>>474 string x \b%-.5s ->>>>>>>>>>479 ubyte&0xDF >0 +>>>>>>>>>>479 ubyte&0xDF >0 >>>>>>>>>>>479 string x \b%-.1s ->>>>>>>480 ubyte&0xDF >0 +>>>>>>>480 ubyte&0xDF >0 >>>>>>>>480 string x \b.%-.3s #MSDOS.SYS >>>>>>>483 ubyte&0xDF >0 \b+ >>>>>>>>483 string x \b%-.5s ->>>>>>>>>488 ubyte&0xDF >0 +>>>>>>>>>488 ubyte&0xDF >0 >>>>>>>>>>488 string x \b%-.3s ->>>>>>>>491 ubyte&0xDF >0 +>>>>>>>>491 ubyte&0xDF >0 >>>>>>>>>491 string x \b.%-.3s # ->>390 string Invalid\ system\ disk\xFF\r\n ->>>412 string Disk\ I/O\ error\xFF\r\n ->>>>429 string Replace\ the\ disk,\ and\ +>>390 string Invalid\ system\ disk\xFF\r\n +>>>412 string Disk\ I/O\ error\xFF\r\n +>>>>429 string Replace\ the\ disk,\ and\040 >>>>>451 string then\ press\ any\ key\r \b, Microsoft Windows 98 Bootloader ->>388 string Ungueltiges\ System\ \xFF\r\n ->>>410 string E/A-Fehler\ \ \ \ \xFF\r\n ->>>>427 string Datentraeger\ wechseln\ und\ +>>388 string Ungueltiges\ System\ \xFF\r\n +>>>410 string E/A-Fehler\ \ \ \ \xFF\r\n +>>>>427 string Datentraeger\ wechseln\ und\040 >>>>>453 string Taste\ druecken\r \b, Microsoft Windows 95/98/ME Bootloader (german) #WINBOOT.SYS only not spaces (0xDF) ->>>>>>497 ubyte&0xDF >0 +>>>>>>497 ubyte&0xDF >0 >>>>>>>497 string x %-.5s ->>>>>>>>502 ubyte&0xDF >0 +>>>>>>>>502 ubyte&0xDF >0 >>>>>>>>>502 string x \b%-.1s ->>>>>>>>>>503 ubyte&0xDF >0 +>>>>>>>>>>503 ubyte&0xDF >0 >>>>>>>>>>>503 string x \b%-.1s ->>>>>>>>>>>>504 ubyte&0xDF >0 +>>>>>>>>>>>>504 ubyte&0xDF >0 >>>>>>>>>>>>>504 string x \b%-.1s ->>>>>>505 ubyte&0xDF >0 +>>>>>>505 ubyte&0xDF >0 >>>>>>>505 string x \b.%-.3s #IO.SYS >>>>>>472 ubyte&0xDF >0 or >>>>>>>472 string x \b %-.2s ->>>>>>>>474 ubyte&0xDF >0 +>>>>>>>>474 ubyte&0xDF >0 >>>>>>>>>474 string x \b%-.5s ->>>>>>>>>>479 ubyte&0xDF >0 +>>>>>>>>>>479 ubyte&0xDF >0 >>>>>>>>>>>479 string x \b%-.1s ->>>>>>>480 ubyte&0xDF >0 +>>>>>>>480 ubyte&0xDF >0 >>>>>>>>480 string x \b.%-.3s #MSDOS.SYS >>>>>>>483 ubyte&0xDF >0 \b+ >>>>>>>>483 string x \b%-.5s ->>>>>>>>>488 ubyte&0xDF >0 +>>>>>>>>>488 ubyte&0xDF >0 >>>>>>>>>>488 string x \b%-.3s ->>>>>>>>491 ubyte&0xDF >0 +>>>>>>>>491 ubyte&0xDF >0 >>>>>>>>>491 string x \b.%-.3s # ->>390 string Ungueltiges\ System\ \xFF\r\n ->>>412 string E/A-Fehler\ \ \ \ \xFF\r\n ->>>>429 string Datentraeger\ wechseln\ und\ +>>390 string Ungueltiges\ System\ \xFF\r\n +>>>412 string E/A-Fehler\ \ \ \ \xFF\r\n +>>>>429 string Datentraeger\ wechseln\ und\040 >>>>>455 string Taste\ druecken\r \b, Microsoft Windows 95/98/ME Bootloader (German) #WINBOOT.SYS only not spaces (0xDF) ->>>>>>497 ubyte&0xDF >0 +>>>>>>497 ubyte&0xDF >0 >>>>>>>497 string x %-.7s ->>>>>>>>504 ubyte&0xDF >0 +>>>>>>>>504 ubyte&0xDF >0 >>>>>>>>>504 string x \b%-.1s ->>>>>>505 ubyte&0xDF >0 +>>>>>>505 ubyte&0xDF >0 >>>>>>>505 string x \b.%-.3s #IO.SYS >>>>>>472 ubyte&0xDF >0 or >>>>>>>472 string x \b %-.2s ->>>>>>>>474 ubyte&0xDF >0 +>>>>>>>>474 ubyte&0xDF >0 >>>>>>>>>474 string x \b%-.6s ->>>>>>>480 ubyte&0xDF >0 +>>>>>>>480 ubyte&0xDF >0 >>>>>>>>480 string x \b.%-.3s #MSDOS.SYS >>>>>>>483 ubyte&0xDF >0 \b+ >>>>>>>>483 string x \b%-.5s ->>>>>>>>>488 ubyte&0xDF >0 +>>>>>>>>>488 ubyte&0xDF >0 >>>>>>>>>>488 string x \b%-.3s ->>>>>>>>491 ubyte&0xDF >0 +>>>>>>>>491 ubyte&0xDF >0 >>>>>>>>>491 string x \b.%-.3s # ->>389 string Ungueltiges\ System\ \xFF\r\n ->>>411 string E/A-Fehler\ \ \ \ \xFF\r\n ->>>>428 string Datentraeger\ wechseln\ und\ +>>389 string Ungueltiges\ System\ \xFF\r\n +>>>411 string E/A-Fehler\ \ \ \ \xFF\r\n +>>>>428 string Datentraeger\ wechseln\ und\040 >>>>>454 string Taste\ druecken\r \b, Microsoft Windows 95/98/ME Bootloader (GERMAN) # DOS names like IO.SYS,WINBOOT.SYS,MSDOS.SYS,WINBOOT.INI are 8 right space padded bytes+3 bytes >>>>>>472 string x %-.2s ->>>>>>>474 ubyte&0xDF >0 +>>>>>>>474 ubyte&0xDF >0 >>>>>>>>474 string x \b%-.5s ->>>>>>>>479 ubyte&0xDF >0 +>>>>>>>>479 ubyte&0xDF >0 >>>>>>>>>479 string x \b%-.1s ->>>>>>480 ubyte&0xDF >0 +>>>>>>480 ubyte&0xDF >0 >>>>>>>480 string x \b.%-.3s >>>>>>483 ubyte&0xDF >0 \b+ >>>>>>>483 string x \b%-.5s ->>>>>>>488 ubyte&0xDF >0 +>>>>>>>488 ubyte&0xDF >0 >>>>>>>>488 string x \b%-.2s ->>>>>>>>490 ubyte&0xDF >0 +>>>>>>>>490 ubyte&0xDF >0 >>>>>>>>>490 string x \b%-.1s ->>>>>>>491 ubyte&0xDF >0 +>>>>>>>491 ubyte&0xDF >0 >>>>>>>>491 string x \b.%-.3s >479 ubyte&0xDF >0 ->>416 string Kein\ System\ oder\ ->>>433 string Laufwerksfehler +>>416 string Kein\ System\ oder\040 +>>>433 string Laufwerksfehler >>>>450 string Wechseln\ und\ Taste\ dr\201cken \b, Microsoft DOS Bootloader (german) #IO.SYS >>>>>479 string x \b %-.2s ->>>>>>481 ubyte&0xDF >0 +>>>>>>481 ubyte&0xDF >0 >>>>>>>481 string x \b%-.6s ->>>>>487 ubyte&0xDF >0 +>>>>>487 ubyte&0xDF >0 >>>>>>487 string x \b.%-.3s #MSDOS.SYS >>>>>>490 ubyte&0xDF >0 \b+ >>>>>>>490 string x \b%-.5s ->>>>>>>>495 ubyte&0xDF >0 +>>>>>>>>495 ubyte&0xDF >0 >>>>>>>>>495 string x \b%-.3s ->>>>>>>498 ubyte&0xDF >0 +>>>>>>>498 ubyte&0xDF >0 >>>>>>>>498 string x \b.%-.3s # ->376 search/41 Non-System\ disk\ or\ ->>395 search/41 disk\ error\r ->>>407 search/41 Replace\ and\ +>376 search/41 Non-System\ disk\ or\040 +>>395 search/41 disk\ error\r +>>>407 search/41 Replace\ and\040 >>>>419 search/41 press\ \b, >>>>419 search/41 strike\ \b, old >>>>426 search/41 any\ key\ when\ ready\r MS or PC-DOS bootloader #449 Disk\ Boot\ failure\r MS 3.21 #466 Boot\ Failure\r MS 3.30 ->>>>>468 search/18 \0 +>>>>>468 search/18 \0 #IO.SYS,IBMBIO.COM >>>>>>&0 string x \b %-.2s ->>>>>>>&-20 ubyte&0xDF >0 +>>>>>>>&-20 ubyte&0xDF >0 >>>>>>>>&-1 string x \b%-.4s ->>>>>>>>>&-16 ubyte&0xDF >0 +>>>>>>>>>&-16 ubyte&0xDF >0 >>>>>>>>>>&-1 string x \b%-.2s >>>>>>&8 ubyte&0xDF >0 \b. >>>>>>>&-1 string x \b%-.3s #MSDOS.SYS,IBMDOS.COM >>>>>>&11 ubyte&0xDF >0 \b+ >>>>>>>&-1 string x \b%-.5s ->>>>>>>>&-6 ubyte&0xDF >0 +>>>>>>>>&-6 ubyte&0xDF >0 >>>>>>>>>&-1 string x \b%-.1s ->>>>>>>>>>&-5 ubyte&0xDF >0 +>>>>>>>>>>&-5 ubyte&0xDF >0 >>>>>>>>>>>&-1 string x \b%-.2s >>>>>>>&7 ubyte&0xDF >0 \b. >>>>>>>>&-1 string x \b%-.3s >441 string Cannot\ load\ from\ harddisk.\n\r ->>469 string Insert\ Systemdisk\ +>>469 string Insert\ Systemdisk\040 >>>487 string and\ press\ any\ key.\n\r \b, MS (2.11) DOS bootloader -#>43 string \224R-LOADER\ \ SYS =label +#>43 string \224R-LOADER\ \ SYS =label >54 string SYS >>324 string VASKK >>>495 string NEWLDR\0 \b, DR-DOS Bootloader (LOADER.SYS) # ->98 string Press\ a\ key\ to\ retry\0\r ->>120 string Cannot\ find\ file\ \0\r ->>>139 string Disk\ read\ error\0\r +>98 string Press\ a\ key\ to\ retry\0\r +>>120 string Cannot\ find\ file\ \0\r +>>>139 string Disk\ read\ error\0\r >>>>156 string Loading\ ...\0 \b, DR-DOS (3.41) Bootloader #DRBIOS.SYS ->>>>>44 ubyte&0xDF >0 +>>>>>44 ubyte&0xDF >0 >>>>>>44 string x \b %-.6s ->>>>>>>50 ubyte&0xDF >0 +>>>>>>>50 ubyte&0xDF >0 >>>>>>>>50 string x \b%-.2s ->>>>>>52 ubyte&0xDF >0 +>>>>>>52 ubyte&0xDF >0 >>>>>>>52 string x \b.%-.3s # ->70 string IBMBIO\ \ COM ->>472 string Cannot\ load\ DOS!\ +>70 string IBMBIO\ \ COM +>>472 string Cannot\ load\ DOS!\040 >>>489 string Any\ key\ to\ retry \b, DR-DOS Bootloader ->>471 string Cannot\ load\ DOS\ +>>471 string Cannot\ load\ DOS\040 >>487 string press\ key\ to\ retry \b, Open-DOS Bootloader #?? ->444 string KERNEL\ \ SYS +>444 string KERNEL\ \ SYS >>314 string BOOT\ error! \b, FREE-DOS Bootloader ->499 string KERNEL\ \ SYS +>499 string KERNEL\ \ SYS >>305 string BOOT\ err!\0 \b, Free-DOS Bootloader ->449 string KERNEL\ \ SYS +>449 string KERNEL\ \ SYS >>319 string BOOT\ error! \b, FREE-DOS 0.5 Bootloader # ->449 string Loading\ FreeDOS +>449 string Loading\ FreeDOS >>0x1AF ulelong >0 \b, FREE-DOS 0.95,1.0 Bootloader ->>>497 ubyte&0xDF >0 +>>>497 ubyte&0xDF >0 >>>>497 string x \b %-.6s ->>>>>503 ubyte&0xDF >0 +>>>>>503 ubyte&0xDF >0 >>>>>>503 string x \b%-.1s ->>>>>>>504 ubyte&0xDF >0 +>>>>>>>504 ubyte&0xDF >0 >>>>>>>>504 string x \b%-.1s ->>>>505 ubyte&0xDF >0 +>>>>505 ubyte&0xDF >0 >>>>>505 string x \b.%-.3s # >331 string Error!.0 \b, FREE-DOS 1.0 bootloader # ->125 string Loading\ FreeDOS...\r +>125 string Loading\ FreeDOS...\r >>311 string BOOT\ error!\r \b, FREE-DOS bootloader ->>>441 ubyte&0xDF >0 +>>>441 ubyte&0xDF >0 >>>>441 string x \b %-.6s ->>>>>447 ubyte&0xDF >0 +>>>>>447 ubyte&0xDF >0 >>>>>>447 string x \b%-.1s ->>>>>>>448 ubyte&0xDF >0 +>>>>>>>448 ubyte&0xDF >0 >>>>>>>>448 string x \b%-.1s ->>>>449 ubyte&0xDF >0 +>>>>449 ubyte&0xDF >0 >>>>>449 string x \b.%-.3s ->124 string FreeDOS\0 +>124 string FreeDOS\0 >>331 string \ err\0 \b, FREE-DOS BETa 0.9 Bootloader # DOS names like KERNEL.SYS,KERNEL16.SYS,KERNEL32.SYS,METAKERN.SYS are 8 right space padded bytes+3 bytes ->>>497 ubyte&0xDF >0 +>>>497 ubyte&0xDF >0 >>>>497 string x \b %-.6s ->>>>>503 ubyte&0xDF >0 +>>>>>503 ubyte&0xDF >0 >>>>>>503 string x \b%-.1s ->>>>>>>504 ubyte&0xDF >0 +>>>>>>>504 ubyte&0xDF >0 >>>>>>>>504 string x \b%-.1s ->>>>505 ubyte&0xDF >0 +>>>>505 ubyte&0xDF >0 >>>>>505 string x \b.%-.3s >>333 string \ err\0 \b, FREE-DOS BEta 0.9 Bootloader ->>>497 ubyte&0xDF >0 +>>>497 ubyte&0xDF >0 >>>>497 string x \b %-.6s ->>>>>503 ubyte&0xDF >0 +>>>>>503 ubyte&0xDF >0 >>>>>>503 string x \b%-.1s ->>>>>>>504 ubyte&0xDF >0 +>>>>>>>504 ubyte&0xDF >0 >>>>>>>>504 string x \b%-.1s ->>>>505 ubyte&0xDF >0 +>>>>505 ubyte&0xDF >0 >>>>>505 string x \b.%-.3s >>334 string \ err\0 \b, FREE-DOS Beta 0.9 Bootloader ->>>497 ubyte&0xDF >0 +>>>497 ubyte&0xDF >0 >>>>497 string x \b %-.6s ->>>>>503 ubyte&0xDF >0 +>>>>>503 ubyte&0xDF >0 >>>>>>503 string x \b%-.1s ->>>>>>>504 ubyte&0xDF >0 +>>>>>>>504 ubyte&0xDF >0 >>>>>>>>504 string x \b%-.1s ->>>>505 ubyte&0xDF >0 +>>>>505 ubyte&0xDF >0 >>>>>505 string x \b.%-.3s ->336 string Error!\ +>336 string Error!\040 >>343 string Hit\ a\ key\ to\ reboot. \b, FREE-DOS Beta 0.9sr1 Bootloader ->>>497 ubyte&0xDF >0 +>>>497 ubyte&0xDF >0 >>>>497 string x \b %-.6s ->>>>>503 ubyte&0xDF >0 +>>>>>503 ubyte&0xDF >0 >>>>>>503 string x \b%-.1s ->>>>>>>504 ubyte&0xDF >0 +>>>>>>>504 ubyte&0xDF >0 >>>>>>>>504 string x \b%-.1s ->>>>505 ubyte&0xDF >0 +>>>>505 ubyte&0xDF >0 >>>>>505 string x \b.%-.3s # added by Joerg Jenderek # http://www.visopsys.org/ # http://partitionlogic.org.uk/ # OEM-ID=Visopsys ->478 ulelong 0 ->>(1.b+326) string I/O\ Error\ reading\ ->>>(1.b+344) string Visopsys\ loader\r +>478 ulelong 0 +>>(1.b+326) string I/O\ Error\ reading\040 +>>>(1.b+344) string Visopsys\ loader\r >>>>(1.b+361) string Press\ any\ key\ to\ continue.\r \b, Visopsys loader # http://alexfru.chat.ru/epm.html#bootprog ->494 ubyte >0x4D ->>495 string >E ->>>495 string <S +>494 ubyte >0x4D +>>495 string >E +>>>495 string <S #OEM-ID is not reliable ->>>>3 string BootProg +>>>>3 string BootProg # It just looks for a program file name at the root directory # and loads corresponding file with following execution. # DOS names like STARTUP.BIN,STARTUPC.COM,STARTUPE.EXE are 8 right space padded bytes+3 bytes ->>>>499 ubyte&0xDF >0 \b, COM/EXE Bootloader +>>>>499 ubyte&0xDF >0 \b, COM/EXE Bootloader >>>>>499 use DOS-filename #If the boot sector fails to read any other sector, #it prints a very short message ("RE") to the screen and hangs the computer. @@ -1025,23 +1025,23 @@ # added by Joerg Jenderek at Feb 2013 according to http://thestarman.pcministry.com/asm/mbr/MSWIN41.htm#FSINFO # and http://en.wikipedia.org/wiki/File_Allocation_Table#FS_Information_Sector ->0 string RRaA +>0 string RRaA >>0x1E4 string rrAa \b, FSInfosector #>>0x1FC uleshort =0 SHOULD BE ZERO >>>0x1E8 ulelong <0xffffffff \b, %u free clusters >>>0x1EC ulelong <0xffffffff \b, last allocated cluster %u # updated by Joerg Jenderek at Sep 2007 ->3 ubyte 0 +>3 ubyte 0 #no active flag ->>446 ubyte 0 +>>446 ubyte 0 # partition 1 not empty ->>>450 ubyte >0 +>>>450 ubyte >0 # partitions 3,4 empty ->>>>482 ubyte 0 ->>>>>498 ubyte 0 +>>>>482 ubyte 0 +>>>>>498 ubyte 0 # partition 2 ID=0,5,15 ->>>>>>466 ubyte <0x10 +>>>>>>466 ubyte <0x10 >>>>>>>466 ubyte 0x05 \b, extended partition table >>>>>>>466 ubyte 0x0F \b, extended partition table (LBA) >>>>>>>466 ubyte 0x0 \b, extended partition table (last) @@ -1054,35 +1054,35 @@ # Print the DOS filenames from directory entry form with 8 right space padded bytes + 3 bytes for extension # like IO.SYS. MSDOS.SYS , KERNEL.SYS , DRBIO.SYS 0 name DOS-filename -# space=0x20 (00100000b) means empty ->0 ubyte&0xDF >0 +# space=0x20 (00100000b) means empty +>0 ubyte&0xDF >0 >>0 ubyte x \b%c ->>>1 ubyte&0xDF >0 +>>>1 ubyte&0xDF >0 >>>>1 ubyte x \b%c ->>>>>2 ubyte&0xDF >0 +>>>>>2 ubyte&0xDF >0 >>>>>>2 ubyte x \b%c ->>>>>>>3 ubyte&0xDF >0 +>>>>>>>3 ubyte&0xDF >0 >>>>>>>>3 ubyte x \b%c ->>>>>>>>>4 ubyte&0xDF >0 +>>>>>>>>>4 ubyte&0xDF >0 >>>>>>>>>>4 ubyte x \b%c ->>>>>>>>>>>5 ubyte&0xDF >0 +>>>>>>>>>>>5 ubyte&0xDF >0 >>>>>>>>>>>>5 ubyte x \b%c ->>>>>>>>>>>>>6 ubyte&0xDF >0 +>>>>>>>>>>>>>6 ubyte&0xDF >0 >>>>>>>>>>>>>>6 ubyte x \b%c ->>>>>>>>>>>>>>>7 ubyte&0xDF >0 +>>>>>>>>>>>>>>>7 ubyte&0xDF >0 >>>>>>>>>>>>>>>>7 ubyte x \b%c # DOS filename extension >>8 ubyte&0xDF >0 \b. >>>8 ubyte x \b%c ->>>>9 ubyte&0xDF >0 +>>>>9 ubyte&0xDF >0 >>>>>9 ubyte x \b%c ->>>>>>10 ubyte&0xDF >0 +>>>>>>10 ubyte&0xDF >0 >>>>>>>10 ubyte x \b%c # Print 2 following DOS filenames from directory entry form # like IO.SYS+MSDOS.SYS or ibmbio.com+ibmdos.com 0 name 2xDOS-filename # display 1 space ->0 ubyte x \b +>0 ubyte x \b >0 use DOS-filename >11 ubyte x \b+ >11 use DOS-filename @@ -1101,10 +1101,10 @@ # partition type ID > 0 >4 ubyte >0 # active flag 0 ->>0 ubyte 0 +>>0 ubyte 0 >>>0 use partition-entry -# active flag 0x80, 0x81, ... ->>0 ubyte >0x7F +# active flag 0x80, 0x81, ... +>>0 ubyte >0x7F >>>0 use partition-entry # Print entry of partition table 0 name partition-entry @@ -1136,7 +1136,7 @@ # sector >1 ubyte&0x3F x \b,%u -# FATX +# FATX 0 string FATX FATX filesystem data # romfs filesystems - Juan Cespedes <cespedes@debian.org> @@ -1157,7 +1157,7 @@ # http://syslinux.zytor.com/iso.php # tested with versions 1.47,1.48,1.49,1.50,1.62,1.76,2.00,2.10;3.00,3.11,3.31,;3.70,3.71,3.73,3.75,3.80,3.82,3.84,3.86,4.01,4.03 and 4.05 # assembler instructions: cli;jmp 0:7Cyy (yy=0x40,0x5e,0x6c,0x6e,0x77);nop;nop -0 ulequad&0x909000007cc0eafa 0x909000007c40eafa +0 ulequad&0x909000007cc0eafa 0x909000007c40eafa >631 search/689 ISOLINUX\ isolinux Loader >>&0 string x (version %-4.4s) # http://syslinux.zytor.com/pxe.php @@ -1174,88 +1174,88 @@ >11 string x (version %-4.4s) # syslinux updated and separated from "DOS/MBR boot sector" by Joerg Jenderek at Sep 2012 # assembler instructions: jmp yy (yy=0x3c,0x58);nop;"SYSLINUX" -0 ulelong&0x80909bEB 0x009018EB +0 ulelong&0x80909bEB 0x009018EB # OEM-ID not always "SYSLINUX" ->434 search/47 Boot\ failed -# followed by \r\n\0 or :\ +>434 search/47 Boot\ failed +# followed by \r\n\0 or :\ >>482 search/132 \0LDLINUX\ SYS Syslinux bootloader (version 2.13 or older) >>1 ubyte 0x58 Syslinux bootloader (version 3.0-3.9) ->459 search/30 Boot\ error\r\n\0 +>459 search/30 Boot\ error\r\n\0 >>1 ubyte 0x58 Syslinux bootloader (version 3.10 or newer) # SYSLINUX MBR updated and separated from "DOS/MBR boot sector" by Joerg Jenderek at Sep 2012 # assembler instructions: mov di,0600h;mov cx,0100h -16 search/4 \xbf\x00\x06\xb9\x00\x01 +16 search/4 \xbf\x00\x06\xb9\x00\x01 # to display SYSLINUX MBR (36) before old DOS/MBR boot sector one with partition table (strength=50+21) !:strength +36 ->94 search/249 Missing\ operating\ system +>94 search/249 Missing\ operating\ system # followed by \r for versions older 3.35 , .\r for versions newer 3.52 and point for other # skip Ranish MBR ->>408 search/4 HD1/\0 ->>408 default x +>>408 search/4 HD1/\0 +>>408 default x >>>250 search/118 \0Operating\ system\ load SYSLINUX MBR # followed by "ing " or space ->>>>292 search/98 error +>>>>292 search/98 error >>>>>&0 string \r (version 3.35 or older) >>>>>&0 string .\r (version 3.52 or newer) >>>>>&0 default x (version 3.36-3.51 ) >368 search/106 \0Disk\ error\ on\ boot\r\n SYSLINUX GPT-MBR ->>156 search/10 \0Boot\ partition\ not\ found\r\n +>>156 search/10 \0Boot\ partition\ not\ found\r\n >>>270 search/10 \0OS\ not\ bootable\r\n (version 3.86 or older) ->>174 search/10 \0Missing\ OS\r\n +>>174 search/10 \0Missing\ OS\r\n >>>189 search/10 \0Multiple\ active\ partitions\r\n (version 4.00 or newer) # SYSLINUX END # NetBSD mbr variants (master-boot-code version 1.22) added by Joerg Jenderek at Nov 2012 # assembler instructions: xor ax,ax;mov ax,ss;mov sp,0x7c00;mov ax, -0 ubequad 0x31c08ed0bc007c8e +0 ubequad 0x31c08ed0bc007c8e # mbr_bootsel magic before partition table not reliable with small ipl fragments -#>444 uleshort 0xb5e1 ->0004 uleshort x +#>444 uleshort 0xb5e1 +>0004 uleshort x # ERRorTeXT >>181 search/166 Error\ \0\r\n NetBSD mbr # NT Drive Serial Number http://thestarman.pcministry.com/asm/mbr/Win2kmbr.htm#DS >>>0x1B8 ubelong >0 \b,Serial 0x%-.8x # BOOTSEL definitions contains assembler instructions: int 0x13;pop dx;push dx;push dx >>>0xbb search/71 \xcd\x13\x5a\x52\x52 \b,bootselector -# BOOT_EXTENDED definitions contains assembler instructions: +# BOOT_EXTENDED definitions contains assembler instructions: # xchg ecx,edx;addl ecx,edx;movw lba_info,si;movb 0x42,ah;pop dx;push dx;int 0x13 >>>0x96 search/1 \x66\x87\xca\x66\x01\xca\x66\x89\x16\x3a\x07\xbe\x32\x07\xb4\x42\x5a\x52\xcd\x13 \b,boot extended # COM_PORT_VAL definitions contains assembler instructions: outb al,dx;add 5,dl;inb %dx;test 0x40,al >>>0x130 search/55 \xee\x80\xc2\x05\xec\xa8\x40 \b,serial IO # not TERSE_ERROR ->>>196 search/106 No\ active\ partition\0 ->>>>&0 string Disk\ read\ error\0 +>>>196 search/106 No\ active\ partition\0 +>>>>&0 string Disk\ read\ error\0 >>>>>&0 string No\ operating\ system\0 \b,verbose # not NO_CHS definitions contains assembler instructions: pop dx;push dx;movb $8,ah;int0x13 >>>0x7d search/7 \x5a\x52\xb4\x08\xcd\x13 \b,CHS # not NO_LBA_CHECK definitions contains assembler instructions: movw 0x55aa,bx;movb 0x41,ah;pop dx;push dx;int 0x13 >>>0xa4 search/84 \xbb\xaa\x55\xb4\x41\x5a\x52\xcd\x13 \b,LBA-check # assembler instructions: movw nametab,bx ->>>0x26 search/21 \xBB\x94\x07 +>>>0x26 search/21 \xBB\x94\x07 # not NO_BANNER definitions contains assembler instructions: mov banner,si;call message_crlf ->>>>&-9 ubequad&0xBE00f0E800febb94 0xBE0000E80000bb94 ->>>>>181 search/166 Error\ \0 +>>>>&-9 ubequad&0xBE00f0E800febb94 0xBE0000E80000bb94 +>>>>>181 search/166 Error\ \0 # "a: disk" , "Fn: diskn" or "NetBSD MBR boot" >>>>>>&3 string x \b,"%s" >>>446 use partition-table # Andrea Mazzoleni AdvanceCD mbr loader of http://advancemame.sourceforge.net/boot-readme.html # added by Joerg Jenderek at Nov 2012 for versions 1.3 - 1.4 # assembler instructions: jmp short 0x58;nop;ASCII -0 ubequad&0xeb58908000000000 0xeb58900000000000 +0 ubequad&0xeb58908000000000 0xeb58900000000000 # assembler instructions: cli;xor ax,ax;mov ds,ax;mov es,ax;mov ss, ->(1.b+2) ubequad 0xfa31c08ed88ec08e +>(1.b+2) ubequad 0xfa31c08ed88ec08e # Error messages at end of code ->>376 string No\ operating\ system\r\n\0 ->>>398 string Disk\ error\r\n\0FDD\0HDD\0 +>>376 string No\ operating\ system\r\n\0 +>>>398 string Disk\ error\r\n\0FDD\0HDD\0 >>>>419 string \ EBIOS\r\n\0 AdvanceMAME mbr -# Neil Turton mbr loader variant of http://www.chiark.greenend.org.uk/~neilt/mbr/ +# Neil Turton mbr loader variant of http://www.chiark.greenend.org.uk/~neilt/mbr/ # added by Joerg Jenderek at Mar 2011 for versions 1.0.0 - 1.1.11 # for 1st version assembler instructions: cld;xor ax,ax;mov DS,ax;MOV ES,AX;mov SI, # or cld;xor ax,ax;mov SS,ax;XOR SP,SP;mov DS, -0 ulequad&0xcE1b40D48EC031FC 0x8E0000D08EC031FC +0 ulequad&0xcE1b40D48EC031FC 0x8E0000D08EC031FC # pointer to the data starting with Neil Turton signature string ->(0x1BC.s) string NDTmbr +>(0x1BC.s) string NDTmbr >>&-14 string 1234F\0 Turton mbr ( # parameters also viewed by install-mbr --list >>>(0x1BC.s+7) ubyte x \b%u<= @@ -1269,23 +1269,23 @@ #0x0~1,0x1~2,...,0x3~4,0x4~F,0x7~D default boot #>>>(0x1BC.s+11) ubyte x \b,cfg_def 0x%x # for older versions ->>>(0x1BC.s+9) ubyte <2 +>>>(0x1BC.s+9) ubyte <2 #>>>>(0x1BC.s+12) ubyte 18 \b,%hhu/18 seconds >>>>(0x1BC.s+12) ubyte !18 \b,%u/18 seconds # floppy A: or B: >>>>(0x1BC.s+13) ubyte <2 \b,floppy 0x%x ->>>>(0x1BC.s+13) ubyte >1 +>>>>(0x1BC.s+13) ubyte >1 # 1st hard disc #>>>>>(0x1BC.s+13) ubyte 0x80 \b,drive 0x%x # not 1st hard disc >>>>>(0x1BC.s+13) ubyte !0x80 \b,drive 0x%x # for version >= 2 maximal timeout can be 65534 ->>>(0x1BC.s+9) ubyte >1 +>>>(0x1BC.s+9) ubyte >1 #>>>>(0x1BC.s+12) uleshort 18 \b,%u/18 seconds >>>>(0x1BC.s+12) uleshort !18 \b,%u/18 seconds # floppy A: or B: >>>>(0x1BC.s+14) ubyte <2 \b,floppy 0x%x ->>>>(0x1BC.s+14) ubyte >1 +>>>>(0x1BC.s+14) ubyte >1 # 1st hard disc #>>>>>(0x1BC.s+14) ubyte 0x80 \b,drive 0x%x # not 1st hard disc @@ -1297,14 +1297,14 @@ # grub-1.94/kern/i386/pc/startup.S # http://www.gnu.org/software/grub/manual/grub.html#Embedded-data # usual values are marked with comments to get only informations of strange GRUB loaders -0x200 uleshort 0x70EA +0x200 uleshort 0x70EA # found only version 3.{1,2} ->0x206 ubeshort >0x0300 +>0x206 ubeshort >0x0300 # GRUB version (0.5.)95,0.93,0.94,0.96,0.97 > "00" ->>0x212 ubyte >0x29 ->>>0x213 ubyte >0x29 +>>0x212 ubyte >0x29 +>>>0x213 ubyte >0x29 # not iso9660_stage1_5 -#>>>0 ulelong&0x00BE5652 0x00BE5652 +#>>>0 ulelong&0x00BE5652 0x00BE5652 >>>>0x213 ubyte >0x29 GRand Unified Bootloader # config_file for stage1_5 is 0xffffffff + default "/boot/grub/stage2" >>>>0x217 ubyte 0xFF stage1_5 @@ -1316,7 +1316,7 @@ #>>>>0x208 ulelong =0xffffff \b, %lu (default) >>>>0x208 ulelong >0xffffff \b, installed partition %u # GRUB 0.5.95 unofficial ->>>>0x20C ulelong&0x2E300000 0x2E300000 +>>>>0x20C ulelong&0x2E300000 0x2E300000 # 0=stage2 1=ffs 2=e2fs 3=fat 4=minix 5=reiserfs >>>>>0x20C ubyte x \b, identifier 0x%x #>>>>>0x20D ubyte =0 \b, LBA flag 0x%x (default) @@ -1324,17 +1324,17 @@ # GRUB version as string >>>>>0x20E string >\0 \b, GRUB version %-s # for stage1_5 is 0xffffffff + config_file "/boot/grub/stage2" default ->>>>>>0x215 ulong 0xffffffff +>>>>>>0x215 ulong 0xffffffff >>>>>>>0x219 string >\0 \b, configuration file %-s ->>>>>>0x215 ulong !0xffffffff +>>>>>>0x215 ulong !0xffffffff >>>>>>>0x215 string >\0 \b, configuration file %-s # newer GRUB versions ->>>>0x20C ulelong&0x2E300000 !0x2E300000 +>>>>0x20C ulelong&0x2E300000 !0x2E300000 ##>>>>>0x20C ulelong =0 \b, saved entry %d (usual) >>>>>0x20C ulelong >0 \b, saved entry %d # for 1.94 contains kernel image size # for 0.93,0.94,0.96,0.97 -# 0=stage2 1=ffs 2=e2fs 3=fat 4=minix 5=reiserfs 6=vstafs 7=jfs 8=xfs 9=iso9660 a=ufs2 +# 0=stage2 1=ffs 2=e2fs 3=fat 4=minix 5=reiserfs 6=vstafs 7=jfs 8=xfs 9=iso9660 a=ufs2 >>>>>0x210 ubyte x \b, identifier 0x%x # The flag for LBA forcing is in most cases 0 #>>>>>0x211 ubyte =0 \b, LBA flag 0x%x (default) @@ -1342,9 +1342,9 @@ # GRUB version as string >>>>>0x212 string >\0 \b, GRUB version %-s # for stage1_5 is 0xffffffff + config_file "/boot/grub/stage2" default ->>>>>0x217 ulong 0xffffffff +>>>>>0x217 ulong 0xffffffff >>>>>>0x21b string >\0 \b, configuration file %-s ->>>>>0x217 ulong !0xffffffff +>>>>>0x217 ulong !0xffffffff >>>>>>0x217 string >\0 \b, configuration file %-s # DOS x86 sector updated and separated from "DOS/MBR boot sector" by Joerg Jenderek at May 2011 @@ -1360,13 +1360,13 @@ # mtools-3.9.8/msdos.h # usual values are marked with comments to get only informations of strange FAT systems # valid sectorsize must be a power of 2 from 32 to 32768 ->11 uleshort&0x001f 0 ->>11 uleshort <32769 ->>>11 uleshort >31 ->>>>21 ubyte&0xf0 0xF0 +>11 uleshort&0x001f 0 +>>11 uleshort <32769 +>>>11 uleshort >31 +>>>>21 ubyte&0xf0 0xF0 >>>>>0 ubyte 0xEB DOS/MBR boot sector >>>>>>1 ubyte x \b, code offset 0x%x+2 ->>>>>0 ubyte 0xE9 +>>>>>0 ubyte 0xE9 >>>>>>1 uleshort x \b, code offset 0x%x+3 >>>>>3 string >\0 \b, OEM-ID "%-.8s" #http://mirror.href.com/thestarman/asm/debug/debug2.htm#IHC @@ -1377,10 +1377,10 @@ >>>>>13 ubyte >1 \b, sectors/cluster %u #>>>>>13 ubyte =1 \b, sectors/cluster %u (usual on Floppies) # for lazy FAT32 implementation like Transcend digital photo frame PF830 ->>>>>82 string/c fat32 +>>>>>82 string/c fat32 >>>>>>14 uleshort !32 \b, reserved sectors %u #>>>>>>14 uleshort =32 \b, reserved sectors %u (usual Fat32) ->>>>>82 string/c !fat32 +>>>>>82 string/c !fat32 >>>>>>14 uleshort >1 \b, reserved sectors %u #>>>>>>14 uleshort =1 \b, reserved sectors %u (usual FAT12,FAT16) #>>>>>>14 uleshort 0 \b, reserved sectors %u (usual NTFS) @@ -1390,7 +1390,7 @@ >>>>>16 ubyte >0 >>>>>17 uleshort >0 \b, root entries %u #>>>>>17 uleshort =0 \b, root entries %hu=0 (usual Fat32) ->>>>>19 uleshort >0 \b, sectors %u (volumes <=32 MB) +>>>>>19 uleshort >0 \b, sectors %u (volumes <=32 MB) #>>>>>19 uleshort =0 \b, sectors %hu=0 (usual Fat32) >>>>>21 ubyte >0xF0 \b, Media descriptor 0x%x #>>>>>21 ubyte =0xF0 \b, Media descriptor 0x%x (usual floppy) @@ -1402,20 +1402,20 @@ #>>>>>26 ubyte =2 \b, heads %u (usual floppy) >>>>>26 ubyte =1 \b, heads %u # valid only for sector sizes with more then 32 Bytes ->>>>>11 uleshort >32 +>>>>>11 uleshort >32 # http://en.wikipedia.org/wiki/Design_of_the_FAT_file_system#Extended_BIOS_Parameter_Block # skip for values 2,2Ah,70h,73h,DFh # and continue for extended boot signature values 0,28h,29h,80h ->>>>>>38 ubyte&0x56 =0 +>>>>>>38 ubyte&0x56 =0 >>>>>>>28 ulelong >0 \b, hidden sectors %u #>>>>>>>28 ulelong =0 \b, hidden sectors %u (usual floppy) ->>>>>>>32 ulelong >0 \b, sectors %u (volumes > 32 MB) +>>>>>>>32 ulelong >0 \b, sectors %u (volumes > 32 MB) #>>>>>>>32 ulelong =0 \b, sectors %u (volumes > 32 MB) -# FAT<32 bit specific ->>>>>>>82 string/c !fat32 +# FAT<32 bit specific +>>>>>>>82 string/c !fat32 #>>>>>>>>36 ubyte 0x80 \b, physical drive 0x%x=0x80 (usual harddisk) #>>>>>>>>36 ubyte 0 \b, physical drive 0x%x=0 (usual floppy) ->>>>>>>>36 ubyte !0x80 +>>>>>>>>36 ubyte !0x80 >>>>>>>>>36 ubyte !0 \b, physical drive 0x%x # VGA-copy CRC or # in Windows NT bit 0 is a dirty flag to request chkdsk at boot time. bit 1 requests surface scan too @@ -1435,27 +1435,27 @@ # if it is small enough FAT is 12 bit, if it is too big enough FAT is 32 bit, # otherwise FAT is 16 bit. # http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-fat-widths.html ->>>>>82 string/c !fat32 +>>>>>82 string/c !fat32 >>>>>>54 string FAT12 \b, FAT (12 bit) >>>>>>54 string FAT16 \b, FAT (16 bit) ->>>>>>54 default x +>>>>>>54 default x # determinate FAT bit size by media descriptor # small floppies implies FAT12 >>>>>>>21 ubyte <0xF0 \b, FAT (12 bit by descriptor) # with media descriptor F0h floppy or maybe superfloppy with FAT16 ->>>>>>>21 ubyte =0xF0 +>>>>>>>21 ubyte =0xF0 # superfloppy (many sectors) implies FAT16 >>>>>>>>32 ulelong >0xFFFF \b, FAT (16 bit by descriptor+sectors) # no superfloppy with media descriptor F0h implies FAT12 >>>>>>>>32 default x \b, FAT (12 bit by descriptor+sectors) # with media descriptor F8h floppy or hard disc with FAT12 or FAT16 ->>>>>>>21 ubyte =0xF8 +>>>>>>>21 ubyte =0xF8 # 360 KiB with media descriptor F8h, 9 sectors per track ,single sided floppy implies FAT12 >>>>>>>>19 ubequad 0xd002f80300090001 \b, FAT (12 bit by descriptor+geometry) # hard disc with FAT12 or FAT16 >>>>>>>>19 default x \b, FAT (1Y bit by descriptor) # with media descriptor FAh floppy, RAM disc with FAT12 or FAT16 or Tandy hard disc ->>>>>>>21 ubyte =0xFA +>>>>>>>21 ubyte =0xFA # 320 KiB with media descriptor FAh, 8 sectors per track ,single sided floppy implies FAT12 >>>>>>>>19 ubequad 0x8002fa0200080001 \b, FAT (12 bit by descriptor+geometry) # RAM disc with FAT12 or FAT16 or Tandy hard disc @@ -1479,17 +1479,17 @@ # 0 or 0xFFFF instead of usual 6 means no backup sector >>>>>>50 uleshort =0xFFFF \b, no Backup boot sector >>>>>>50 uleshort =0 \b, no Backup boot sector -#>>>>>>50 uleshort =6 \b, Backup boot sector %u (usual) ->>>>>>50 default x +#>>>>>>50 uleshort =6 \b, Backup boot sector %u (usual) +>>>>>>50 default x >>>>>>>50 uleshort x \b, Backup boot sector %u # corrected by Joerg Jenderek at Feb 2011 according to http://thestarman.pcministry.com/asm/mbr/MSWIN41.htm#FSINFO >>>>>>52 ulelong >0 \b, reserved1 0x%x >>>>>>56 ulelong >0 \b, reserved2 0x%x >>>>>>60 ulelong >0 \b, reserved3 0x%x -# same structure as FAT1X +# same structure as FAT1X #>>>>>>64 ubyte =0x80 \b, physical drive 0x%x=80 (usual harddisk) #>>>>>>64 ubyte =0 \b, physical drive 0x%x=0 (usual floppy) ->>>>>>64 ubyte !0x80 +>>>>>>64 ubyte !0x80 >>>>>>>64 ubyte >0 \b, physical drive 0x%x # in Windows NT bit 0 is a dirty flag to request chkdsk at boot time. bit 1 requests surface scan too >>>>>>65 ubyte >0 \b, reserved 0x%x @@ -1500,10 +1500,10 @@ >>>>>>>71 string >NO\ NAME \b, label: "%11.11s" >>>>>>>71 string =NO\ NAME \b, unlabeled # additional tests for floppy image added by Joerg Jenderek -# no fixed disk ->>>>>21 ubyte !0xF8 +# no fixed disk +>>>>>21 ubyte !0xF8 # floppy media with 12 bit FAT ->>>>>>54 string !FAT16 +>>>>>>54 string !FAT16 # test for FAT after bootsector >>>>>>>(11.s) ulelong&0x00ffffF0 0x00ffffF0 \b, followed by FAT # floppy image @@ -1511,11 +1511,11 @@ # NTFS specific added by Joerg Jenderek at Mar 2011 according to http://thestarman.pcministry.com/asm/mbr/NTFSBR.htm # and http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/bios-parameter-block.html # 0 FATs ->>>>>16 ubyte =0 +>>>>>16 ubyte =0 # 0 root entries ->>>>>>17 uleshort =0 +>>>>>>17 uleshort =0 # 0 DOS sectors ->>>>>>>19 uleshort =0 +>>>>>>>19 uleshort =0 # 0 sectors/FAT # dos < 4.0 BootSector value found is 0x80 #38 ubyte =0x80 \b, dos < 4.0 BootSector (0x%x) @@ -1526,33 +1526,43 @@ >>>>>>>>>48 ulequad >0 \b, $MFT start cluster %lld >>>>>>>>>56 ulequad >0 \b, $MFTMirror start cluster %lld # Values 0 to 127 represent MFT record sizes of 0 to 127 clusters. -# Values 128 to 255 represent MFT record sizes of 2^(256-N) bytes. ->>>>>>>>>64 lelong <256 +# Values 128 to 255 represent MFT record sizes of 2^(256-N) bytes. +>>>>>>>>>64 lelong <256 >>>>>>>>>>64 lelong <128 \b, clusters/RecordSegment %d >>>>>>>>>>64 ubyte >127 \b, bytes/RecordSegment 2^(-1*%i) # Values 0 to 127 represent index block sizes of 0 to 127 clusters. # Values 128 to 255 represent index block sizes of 2^(256-N) byte ->>>>>>>>>68 ulelong <256 +>>>>>>>>>68 ulelong <256 >>>>>>>>>>68 ulelong <128 \b, clusters/index block %d #>>>>>>>>>>68 ulelong >127 \b, bytes/index block 2^(256-%d) >>>>>>>>>>68 ubyte >127 \b, bytes/index block 2^(-1*%i) >>>>>>>>>72 ulequad x \b, serial number 0%llx >>>>>>>>>80 ulelong >0 \b, checksum 0x%x #>>>>>>>>>80 ulelong =0 \b, checksum 0x%x=0 (usual) ->>>>>>>>>0x258 ulelong&0x00009090 =0x00009090 ->>>>>>>>>>&-92 indirect x \b; contains +>>>>>>>>>0x258 ulelong&0x00009090 =0x00009090 +>>>>>>>>>>&-92 indirect x \b; contains # For 2nd NTFS sector added by Joerg Jenderek at Jan 2013 # http://thestarman.pcministry.com/asm/mbr/NTFSbrHexEd.htm # unused assembler instructions JMP y2;NOP;NOP -0x056 ulelong&0xFFFF0FFF 0x909002EB +0x056 ulelong&0xFFFF0FFF 0x909002EB # unicode loadername terminated by CTRL-D ->(0.s*2) ulelong&0xFFFFFF00 0x00040000 +>(0.s*2) ulelong&0xFFFFFF00 0x00040000 # loadernames are NTLDR,CMLDR,PELDR,$LDR$ or BOOTMGR >>0x002 lestring16 x Microsoft Windows XP/VISTA bootloader %-5.5s ->>0x12 string $ +>>0x12 string $ >>>0x0c lestring16 x \b%-2.2s ### DOS,NTFS boot sectors end +# ntfsclone-image is a special save format for NTFS volumes, +# created and restored by the ntfsclone program +0 string \0ntfsclone-image ntfsclone image, +>0x10 byte x version %d. +>0x11 byte x \b%d, +>0x12 lelong x cluster size %d, +>0x16 lequad x device size %lld, +>0x1e lequad x %lld total clusters, +>0x26 lequad x %lld clusters in use + 9564 lelong 0x00011954 Unix Fast File system [v1] (little-endian), >8404 string x last mounted on %s, #>9504 ledate x last checked at %s, @@ -1669,6 +1679,13 @@ >&-1248 belong 0 TIME optimization >&-1248 belong 1 SPACE optimization +0 ulequad 0xc8414d4dc5523031 HAMMER filesystem (little-endian), +>0x90 lelong+1 x volume %d +>0x94 lelong x (of %d), +>0x50 string x name %s, +>0x98 ulelong x version %u, +>0xa0 ulelong x flags 0x%x + # ext2/ext3 filesystems - Andreas Dilger <adilger@dilger.ca> # ext4 filesystem - Eric Sandeen <sandeen@sandeen.net> # volume label and UUID Russell Coker @@ -1818,7 +1835,7 @@ # FE 250K 8-inch, 1-sided, single-density # FD 500K 8-inch, 2-sided, single-density # FE 1.2 MB 8-inch, 2-sided, double-density -# F8 ----- Fixed disk +# F8 ----- Fixed disk # # FC xxxK Apricot 70x1x9 boot disk. # @@ -1846,7 +1863,7 @@ # all FAT12 (strength=70) floppies with sectorsize 512 added by Joerg Jenderek at Jun 2013 # http://en.wikipedia.org/wiki/File_Allocation_Table#Exceptions # Too Weak. -#512 ubelong&0xE0ffff00 0xE0ffff00 +#512 ubelong&0xE0ffff00 0xE0ffff00 # without valid Media descriptor in place of BPB, cases with are done at other places #>21 ubyte <0xE5 floppy with old FAT filesystem # but valid Media descriptor at begin of FAT @@ -1858,61 +1875,61 @@ #>>512 ubyte =0xfb 640k #>>512 ubyte =0xfc 180k # look like an an old DOS directory entry -#>>>0xA0E ubequad 0 -#>>>>0xA00 ubequad !0 +#>>>0xA0E ubequad 0 +#>>>>0xA00 ubequad !0 #!:mime application/x-ima -#>>512 ubyte =0xfd +#>>512 ubyte =0xfd # look for 2nd FAT at different location to distinguish between 360k and 500k #>>>0x600 ubelong&0xE0ffff00 0xE0ffff00 360k #>>>0x500 ubelong&0xE0ffff00 0xE0ffff00 500k -#>>>0xA0E ubequad 0 +#>>>0xA0E ubequad 0 #!:mime application/x-ima -#>>512 ubyte =0xfe +#>>512 ubyte =0xfe #>>>0x400 ubelong&0xE0ffff00 0xE0ffff00 160k -#>>>>0x60E ubequad 0 -#>>>>>0x600 ubequad !0 +#>>>>0x60E ubequad 0 +#>>>>>0x600 ubequad !0 #!:mime application/x-ima #>>>0xC00 ubelong&0xE0ffff00 0xE0ffff00 1200k #>>512 ubyte =0xff 320k -#>>>0x60E ubequad 0 -#>>>>0x600 ubequad !0 +#>>>0x60E ubequad 0 +#>>>>0x600 ubequad !0 #!:mime application/x-ima #>>512 ubyte x \b, Media descriptor 0x%x # without x86 jump instruction -#>>0 ulelong&0x804000E9 !0x000000E9 -# assembler instructions: CLI;MOV SP,1E7;MOV AX;07c0;MOV +#>>0 ulelong&0x804000E9 !0x000000E9 +# assembler instructions: CLI;MOV SP,1E7;MOV AX;07c0;MOV #>>>0 ubequad 0xfabce701b8c0078e \b, MS-DOS 1.12 bootloader # IOSYS.COM+MSDOS.COM #>>>>0xc4 use 2xDOS-filename -#>>0 ulelong&0x804000E9 =0x000000E9 +#>>0 ulelong&0x804000E9 =0x000000E9 # only x86 short jump instruction found #>>>0 ubyte =0xEB #>>>>1 ubyte x \b, code offset 0x%x+2 # http://thestarman.pcministry.com/DOS/ibm100/Boot.htm -# assembler instructions: CLI;MOV AX,CS;MOV DS,AX;MOV DX,0 -#>>>>(1.b+2) ubequad 0xfa8cc88ed8ba0000 \b, PC-DOS 1.0 bootloader +# assembler instructions: CLI;MOV AX,CS;MOV DS,AX;MOV DX,0 +#>>>>(1.b+2) ubequad 0xfa8cc88ed8ba0000 \b, PC-DOS 1.0 bootloader # ibmbio.com+ibmdos.com #>>>>>0x176 use DOS-filename #>>>>>0x181 ubyte x \b+ #>>>>>0x182 use DOS-filename # http://thestarman.pcministry.com/DOS/ibm110/Boot.htm -# assembler instructions: CLI;MOV AX,CS;MOV DS,AX;XOR DX,DX;MOV -#>>>>(1.b+2) ubequad 0xfa8cc88ed833d28e \b, PC-DOS 1.1 bootloader +# assembler instructions: CLI;MOV AX,CS;MOV DS,AX;XOR DX,DX;MOV +#>>>>(1.b+2) ubequad 0xfa8cc88ed833d28e \b, PC-DOS 1.1 bootloader # ibmbio.com+ibmdos.com #>>>>>0x18b use DOS-filename #>>>>>0x196 ubyte x \b+ #>>>>>0x197 use DOS-filename # http://en.wikipedia.org/wiki/Zenith_Data_Systems -# assembler instructions: MOV BX,07c0;MOV SS,BX;MOV SP,01c6 +# assembler instructions: MOV BX,07c0;MOV SS,BX;MOV SP,01c6 #>>>>(1.b+2) ubequad 0xbbc0078ed3bcc601 \b, Zenith Data Systems MS-DOS 1.25 bootloader # IO.SYS+MSDOS.SYS #>>>>>0x20 use 2xDOS-filename # http://en.wikipedia.org/wiki/Corona_Data_Systems -# assembler instructions: MOV AX,CS;MOV DS,AX;CLI;MOV SS,AX; +# assembler instructions: MOV AX,CS;MOV DS,AX;CLI;MOV SS,AX; #>>>>(1.b+2) ubequad 0x8cc88ed8fa8ed0bc \b, MS-DOS 1.25 bootloader # IO.SYS+MSDOS.SYS #>>>>>0x69 use 2xDOS-filename -# assembler instructions: CLI;PUSH CS;POP SS;MOV SP,7c00; +# assembler instructions: CLI;PUSH CS;POP SS;MOV SP,7c00; #>>>>(1.b+2) ubequad 0xfa0e17bc007cb860 \b, MS-DOS 2.11 bootloader # defect IO.SYS+MSDOS.SYS ? #>>>>>0x162 use 2xDOS-filename @@ -1942,14 +1959,25 @@ 32769 string CD001 # mime line at that position does not work # to display CD-ROM (70=81-11) after MBR (113=40+72+1), partition-table (71=50+21) and before Apple Driver Map (51) -!:strength -11 +#!:strength -11 # to display CD-ROM (114=81+33) before MBR (113=40+72+1), partition-table (71=50+21) and Apple Driver Map (51) -# does not work -#!:strength +33 ->0 use cdrom +!:strength +34 +>0 use cdrom # .cso files -0 string CISO Compressed ISO CD image +# Reference: http://pismotec.com/ciso/ciso.h +# NOTE: There are two other formats with the same magic but +# completely incompatible specifications: +# - GameCube/Wii CISO: https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/DiscIO/CISOBlob.h +# - PSP CISO: https://github.com/jamie/ciso/blob/master/ciso.h +0 string CISO +# Other fields are used to determine what type of CISO this is: +# - 0x04 == 0x00200000: GameCube/Wii CISO (block_size) +# - 0x10 == 0x00000800: PSP CISO (ISO-9660 sector size) +# - None of the above: Compact ISO. +>4 lelong !0 +>>4 lelong !0x200000 +>>>0x10 lelong !0x800 Compressed ISO CD image # cramfs filesystem - russell@coker.com.au 0 lelong 0x28cd3d45 Linux Compressed ROM File System data, little endian @@ -2041,6 +2069,13 @@ >29 byte 16 \bBlackfin, >29 byte 17 \bAVR32, >29 byte 18 \bSTMicroelectronics ST200, +>29 byte 19 \bSandbox architecture, +>29 byte 20 \bANDES Technology NDS32, +>29 byte 21 \bOpenRISC 1000, +>29 byte 22 \bARM 64-bit, +>29 byte 23 \bDesignWare ARC, +>29 byte 24 \bx86_64, +>29 byte 25 \bXtensa, >30 byte 0 Invalid Image >30 byte 1 Standalone Program >30 byte 2 OS Kernel Image @@ -2114,7 +2149,7 @@ >>8 ledate x created: %s # AFS Dump Magic -# From: Ty Sarna <tsarna@sarna.org> +# From: Ty Sarna <tsarna@sarna.org> 0 string \x01\xb3\xa1\x13\x22 AFS Dump >&0 belong x (v%d) >>&0 byte 0x76 @@ -2229,7 +2264,7 @@ # From: "Nelson A. de Oliveira" <naoliv@gmail.com> 0 string *dvdisaster* dvdisaster error correction file -# xfs metadump image +# xfs metadump image # mb_magic XFSM at 0; superblock magic XFSB at 1 << mb_blocklog # but can we do the << ? For now it's always 512 (0x200) anyway. 0 string XFSM @@ -2301,8 +2336,8 @@ 0 string td\000 floppy image data (TeleDisk, compressed) 0 string TD\000 floppy image data (TeleDisk) -0 string CQ\024 floppy image data (CopyQM, ->16 leshort x %d sectors, +0 string CQ\024 floppy image data (CopyQM, +>16 leshort x %d sectors, >18 leshort x %d heads.) 0 string ACT\020Apricot\020disk\020image\032\004 floppy image data (ApriDisk) @@ -2352,3 +2387,13 @@ >>>>>>>>0x1B ubyte 0x30 \b, media=1D >>>>>>>>0x1B ubyte 0x40 \b, media=1DD >>>>>>>>0x1A ubyte 0x10 \b, write-protected + +# HDD Raw Copy Tool disk image, file extension: .imgc +# From Benjamin Vanheuverzwijn <bvanheu@gmail.com> +0 pstring HDD\ Raw\ Copy\ Tool %s +>0x100 pstring x %s +>0x200 pstring x - HD model: %s +#>0x300 pstring x unknown %s +>0x400 pstring x serial: %s +#>0x500 pstring x unknown: %s +!:ext imgc diff --git contrib/file/magic/Magdir/flash contrib/file/magic/Magdir/flash index b06f879efcd5..b48abe968eb4 100644 --- contrib/file/magic/Magdir/flash +++ contrib/file/magic/Magdir/flash @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: flash,v 1.11 2014/05/02 00:26:49 christos Exp $ +# $File: flash,v 1.14 2017/05/25 20:09:55 christos Exp $ # flash: file(1) magic for Macromedia Flash file format # # See @@ -10,23 +10,45 @@ # en/devnet/swf/pdf/swf-file-format-spec.pdf page 27 # -0 name swf-details ->0 string F Macromedia Flash data +0 name swf-details + +>0 string F +>>8 byte&0xfd 0x08 Macromedia Flash data +!:mime application/x-shockwave-flash +>>>3 byte x \b, version %d +>>8 byte&0xfe 0x10 Macromedia Flash data +!:mime application/x-shockwave-flash +>>>3 byte x \b, version %d +>>8 byte 0x18 Macromedia Flash data +!:mime application/x-shockwave-flash +>>>3 byte x \b, version %d +>>8 beshort&0xff87 0x2000 Macromedia Flash data !:mime application/x-shockwave-flash ->0 string C Macromedia Flash data (compressed) +>>>3 byte x \b, version %d +>>8 beshort&0xffe0 0x3000 Macromedia Flash data !:mime application/x-shockwave-flash ->0 string Z Macromedia Flash data (lzma compressed) +>>>3 byte x \b, version %d +>>8 byte&0x7 0 +>>>8 ubyte >0x2f +>>>>9 ubyte <0x20 Macromedia Flash data +!:mime application/x-shockwave-flash +>>>>>3 byte x \b, version %d + +>0 string C +>>8 byte 0x78 Macromedia Flash data (compressed) +!:mime application/x-shockwave-flash +>>>3 byte x \b, version %d + +>0 string Z +>>8 byte 0x5d Macromedia Flash data (lzma compressed) !:mime application/x-shockwave-flash ->3 byte x \b, version %d +>>>3 byte x \b, version %d -1 string WS ->4 lelong !0 ->>3 byte 255 Suspicious ->>>0 use swf-details ->>3 ubyte <32 ->>>3 ubyte !0 ->>>>0 use swf-details +1 string WS +>4 ulelong >14 +>>3 ubyte !0 +>>>0 use swf-details # From: Cal Peake <cp@absolutedigital.net> 0 string FLV\x01 Macromedia Flash Video @@ -34,7 +56,7 @@ # # Yosu Gomez -0 string AGD2\xbe\xb8\xbb\xcd\x00 Macromedia Freehand 7 Document -0 string AGD3\xbe\xb8\xbb\xcc\x00 Macromedia Freehand 8 Document +0 string AGD2\xbe\xb8\xbb\xcd\x00 Macromedia Freehand 7 Document +0 string AGD3\xbe\xb8\xbb\xcc\x00 Macromedia Freehand 8 Document # From Dave Wilson -0 string AGD4\xbe\xb8\xbb\xcb\x00 Macromedia Freehand 9 Document +0 string AGD4\xbe\xb8\xbb\xcb\x00 Macromedia Freehand 9 Document diff --git contrib/file/magic/Magdir/fonts contrib/file/magic/Magdir/fonts index be489cba01e0..7e9b0da914df 100644 --- contrib/file/magic/Magdir/fonts +++ contrib/file/magic/Magdir/fonts @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: fonts,v 1.33 2016/09/14 01:26:26 christos Exp $ +# $File: fonts,v 1.37 2017/06/24 00:39:00 christos Exp $ # fonts: file(1) magic for font data # 0 search/1 FONT ASCII vfont text @@ -19,17 +19,17 @@ # URL: https://en.wikipedia.org/wiki/PostScript_fonts # Reference: http://partners.adobe.com/public/developer/en/font/5178.PFM.pdf # Modified by: Joerg Jenderek -# Note: moved from ./msdos magic -# dfVersion 256=0100h -0 uleshort 0x0100 +# Note: moved from ./msdos magic +# dfVersion 256=0100h +0 uleshort 0x0100 # GRR: line above is too general as it catches also TrueType font, # raw G3 data FAX, WhatsApp encrypted and Panorama database # dfType 129=0081h ->66 uleshort 0x0081 +>66 uleshort 0x0081 # dfVertRes 300=012Ch not needed as additional test -#>>70 uleshort 0x012c +#>>70 uleshort 0x012c # dfHorizRes 300=012Ch -#>>>72 uleshort 0x012c +#>>>72 uleshort 0x012c # dfDriverInfo points to postscript information section >>(101.l) string/c Postscript Printer Font Metrics # above labeled "PFM data" by ./msdos (version 5.28) or "Adobe Printer Font Metrics" by TrID @@ -40,13 +40,13 @@ # dfCopyright 60 byte null padded Copyright string. uncomment it to get old looking #>>>6 string >\060 - %-.60s # dfDriverInfo ->>>139 ulelong >0 +>>>139 ulelong >0 # often abbreviated and same as filename >>>>(139.l) string x %s # dfSize >>>2 ulelong x \b, %d bytes # dfFace 210=D2h 9Eh ->>>105 ulelong >0 +>>>105 ulelong >0 # Windows font name >>>>(105.l) string x \b, %s # dfItalic @@ -72,7 +72,7 @@ #>104 belong 00000004 X11 SNF font data, MSB first !:mime application/x-font-sfn # GRR: line below too general as it catches also Xbase index file t3-CHAR.NDX -0 lelong 00000004 +0 lelong 00000004 >104 lelong 00000004 X11 SNF font data, LSB first !:mime application/x-font-sfn @@ -82,27 +82,29 @@ # From: Joerg Jenderek # URL: http://grub.gibibit.com/New_font_format # Reference: util/grub-mkfont.c -# include/grub/fontformat.h +# include/grub/fontformat.h # FONT_FORMAT_SECTION_NAMES_FILE -0 string FILE +0 string FILE # FONT_FORMAT_PFF2_MAGIC ->8 string PFF2 +>8 string PFF2 # leng 4 only at the moment ->>4 ubelong 4 +>>4 ubelong 4 # FONT_FORMAT_SECTION_NAMES_FONT_NAME >>>12 string NAME GRUB2 font !:mime application/x-font-pf2 !:ext pf2 # length of font_name ->>>>16 ubelong >0 +>>>>16 ubelong >0 # font_name >>>>>20 string >\0 "%-s" # X11 fonts, from Daniel Quinlan (quinlan@yggdrasil.com) # PCF must come before SGI additions ("MIPSEL MIPS-II COFF" collides) -0 string \001fcp X11 Portable Compiled Font data ->12 byte 0x02 \b, LSB first ->12 byte 0x0a \b, MSB first +0 string \001fcp X11 Portable Compiled Font data, +>12 lelong ^0x08 bit: LSB, +>12 lelong &0x08 bit: MSB, +>12 lelong ^0x04 byte: LSB first +>12 lelong &0x04 byte: MSB first 0 string D1.0\015 X11 Speedo font data #------------------------------------------------------------------------------ @@ -134,28 +136,166 @@ >4 beshort >0 version %d # True Type fonts -0 string \000\001\000\000\000 TrueType font data -!:mime application/x-font-ttf +# Modified by: Joerg Jenderek +# URL: https://en.wikipedia.org/wiki/TrueType +# Reference: https://developer.apple.com/fonts/TrueType-Reference-Manual/ +# +# sfnt version "typ1" used by some Apple, but no example found +0 string typ1 +>0 use sfnt-font +>0 use sfnt-names +# sfnt version "true" used by some Apple +0 string true +>0 use sfnt-font +>0 use sfnt-names +# GRR: below test is too general +# sfnt version often 0x00010000 +0 string \000\001\000\000 +>0 use sfnt-font +>0 use sfnt-names +# validate and display sfnt font data like number of tables +0 name sfnt-font +# file 5.30 version assumes 00FFh as maximal number of tables +#>4 ubeshort <0x0100 +# maximal 27 tables found like in Skia.ttf +# 46 different table names mentioned on Apple specification +# skip 1st sequence of DOS 2 backup with path separator (\~92 or /~47) misinterpreted as table number +>4 ubeshort <47 +# skip bad examples with garbage table names like in a5.show HYPERC MAC +# tag names consist of up to four characters padded with spaces at end like +# BASE DSIG OS/2 Zapf acnt glyf cvt vmtx xref ... +>>12 regex/4l \^[A-Za-z][A-Za-z][A-Za-z/][A-Za-z2\ ] +#>>>0 ubelong x \b, sfnt version 0x%x +>>>0 ubelong !0x4f54544f TrueType +!:mime application/font-sfnt +#!:mime font/ttf +!:apple ????tfil +# .ttf for TrueType font +# EUDC.tte created by privat character editor %WINDIR%\system32\eudcedit.exe +!:ext ttf/tte +# sfnt version 4F54544Fh~OTTO +>>>0 ubelong =0x4f54544f OpenType +!:mime application/font-sfnt +#!:mime font/otf +!:apple ????OTTO +!:ext otf +>>>0 ubelong x Font data +# DSIG=44454947h table name implies a digitally signed font +# search range = number of tables * 16 =< maximal number of tables * 16 = 27 * 16 = 432 +>>>12 search/432 DSIG \b, digitally signed +>>>4 ubeshort x \b, %d tables +# minimal 9 tables found like in NISC18030.ttf +#>>>4 ubeshort <10 TMIN +#>>>4 ubeshort >24 TBIG +# table directory entries +>>>12 string x \b, 1st "%4.4s" + +# search and display 1st name in sfnt font which is often copyright text +# does not work inside font collections +0 name sfnt-names +# search for naming table +>12 search/432/s name +# biggest offset 0x0100bd28 like Windows10 Fonts\simsunb.ttf +#>>>>&8 ubelong >0x0100bd27 BIGGEST OFFSET +>>&8 ubelong >0x00100000 +# offset of name table +>>>&-4 ubelong x \b, name offset 0x%x +# GRR: pointer to name table only works if offset ~< FILE_BYTES_MAX = 100000h defined in src\file.h +>>&8 ubelong <0x00100000 +>>>&-16 ubelong x +# name table +>>>>(&8.L) ubequad x +# invalid format selector +#>>>>>&-8 ubeshort !0 \b, invalid selector %x +# minimal 3 name records found like in c:\Program Files (x86)\Tesseract-OCR\tessdata\pdf.ttf +# maximal 1227 name records found like in Apple Chancery.ttf +#>>>>>&-6 ubeshort <0x4 mincount +#>>>>>&-6 ubeshort >130 maxcount +>>>>>&-6 ubeshort x \b, %d names +# offset to start of string storage from start of table +#>>>>>&-4 ubeshort x \b, record offset %d +# 1st name record +# string offset from start of storage area +#>>>>>&8 ubeshort x \b, string offset %d +# string length +#>>>>>&6 ubeshort x \b, string length %d +# minimal name string 7 like in c:\Program Files (x86)\Kodi\addons\webinterface.default\lib\video-js\font\VideoJS.ttf +# also found 0 like in SWZCONLN.TTF +#>>>>>&6 ubeshort <8 MIN STRING +# maximal name string 806 like in c:\Windows\Fonts\palabi.ttf +#>>>>>&6 ubeshort >805 MAX STRING +# platform identifier: 0~Apple Unicode, 1~Macintosh, 3~Microsoft +#>>>>>&-2 ubeshort >3 BAD PLATFORM +>>>>>&-2 ubeshort 0 \b, Unicode +>>>>>&-2 ubeshort 1 \b, Macintosh +>>>>>&-2 ubeshort 3 \b, Microsoft +# languageID (0~english Macintosh, 0409h~english Microsoft, ...) +>>>>>&2 ubeshort >0 \b, language 0x%x +# name identifiers +# often 0~copyright, 1~font, 2~font subfamily, 5~version, 13~license, 19~sample, ... +>>>>>&4 ubeshort >0 \b, type %d string +# platform specific encoding: +# 0~undefined character set, 1~UGL set with Unicode, 3~Unicode 2.0 BMP only, 4~Unicode 2.0 +#>>>>>&0 ubeshort x \b, %d encoding +>>>>>&0 ubeshort 0 +# handle only name string offset 0 because do not know how to add 2 relative offsets +>>>>>>&6 ubeshort 0 +>>>>>>>&(&-14.S-18) ubyte !0 +# GRR: instead 806 only first MAXstring = 96 characters are displayed as defined in src\file.h +# often copyright string that starts like \251 2006 The Monotype Corporation +>>>>>>>>&-1 string x \b, %-11.96s +# test for unicode string +>>>>>>>&(&-14.S-18) ubyte 0 +>>>>>>>>&0 lestring16 x \b, %-11.96s +# unicode encoding +>>>>>&0 ubeshort >0 +>>>>>>&6 ubeshort 0 +>>>>>>>&(&-14.S-17) lestring16 x \b, %-11.96s 0 string \007\001\001\000Copyright\ (c)\ 199 Adobe Multiple Master font 0 string \012\001\001\000Copyright\ (c)\ 199 Adobe Multiple Master font # TrueType/OpenType font collections (.ttc) +# URL: https://en.wikipedia.org/wiki/OpenType # http://www.microsoft.com/typography/otspec/otff.htm -0 string ttcf TrueType font collection data ->4 belong 0x00010000 \b, 1.0 ->>8 belong >0 \b, %d fonts ->4 belong 0x00020000 \b, 2.0 ->>8 belong >0 \b, %d fonts +# Modified by: Joerg Jenderek +# Note: container for TrueType, OpenType font +0 string ttcf +# skip ASCII text +>4 ubyte 0 +# sfnt version often 0x00010000 of 1st table is TrueType +>>(12.L) ubelong !0x4f54544f TrueType +#!:mime font/ttf +!:apple ????tfil +!:ext ttc +# sfnt version 4F54544Fh~OTTO of 1st table is OpenType font +>>(12.L) ubelong =0x4f54544f OpenType +#!:mime font/otf +!:apple ????OTTO +# no example found for otc +!:ext ttc/otc +>>4 ubyte x font collection data +!:mime application/font-sfnt +#!:mime font/collection +# TCC version +>>4 belong 0x00010000 \b, 1.0 +>>4 belong 0x00020000 \b, 2.0 +>>8 ubelong >0 \b, %d fonts +# array offset size = fonts * offsetsize = fonts * 4 +>>(8.L*4) ubequad x # 0x44454947 = 'DSIG' ->>>16 belong 0x44534947 \b, digitally signed +>>>&4 belong 0x44534947 \b, digitally signed +# offset to 1st font +>>12 ubelong x \b, at 0x%x +# point to 1st font that starts with sfnt version +>>(12.L) use sfnt-font # Opentype font data from Avi Bercovich 0 string OTTO OpenType font data !:mime application/vnd.ms-opentype -# Gurkan Sengun <gurkan@linuks.mine.nu>, www.linuks.mine.nu -0 string SplineFontDB: Spline Font Database +# Gurkan Sengun <gurkan@linuks.mine.nu>, www.linuks.mine.nu +0 string SplineFontDB: Spline Font Database !:mime application/vnd.font-fontforge-sfd >14 string x version %s diff --git contrib/file/magic/Magdir/fsav contrib/file/magic/Magdir/fsav index ecdc4f654b7c..5714798e9131 100644 --- contrib/file/magic/Magdir/fsav +++ contrib/file/magic/Magdir/fsav @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: fsav,v 1.13 2013/03/25 17:18:47 christos Exp $ +# $File: fsav,v 1.14 2017/03/17 21:35:28 christos Exp $ # fsav: file(1) magic for datafellows fsav virus definition files # Anthon van der Neut (anthon@mnt.org) @@ -29,11 +29,11 @@ #>>>>10 byte 11 \b12- #>>>>9 ubyte >0 \b%02d) # ftp://ftp.f-prot.com/pub/sign2.zip -#0 ubyte 0x62 -#>1 ubyte 0xF5 -#>>2 ubyte 0x1 -#>>>3 ubyte 0x1 -#>>>>4 ubyte 0x0e +#0 ubyte 0x62 +#>1 ubyte 0xF5 +#>>2 ubyte 0x1 +#>>>3 ubyte 0x1 +#>>>>4 ubyte 0x0e #>>>>>13 ubyte >0 fsav virus signatures #>>>>>>11 ubyte x size 0x%02x #>>>>>>12 ubyte x \b%02x @@ -44,16 +44,16 @@ # .cvd files start with a 512 bytes colon separated header # ClamAV-VDB:buildDate:version:signaturesNumbers:functionalityLevelRequired:MD5:Signature:builder:buildTime # + gzipped tarball files -0 string ClamAV-VDB: +0 string ClamAV-VDB: >11 string >\0 Clam AntiVirus database %-.23s ->>34 string : ->>>35 string !: \b, version +>>34 string : +>>>35 string !: \b, version >>>>35 string x \b%-.1s ->>>>>36 string !: +>>>>>36 string !: >>>>>>36 string x \b%-.1s ->>>>>>>37 string !: +>>>>>>>37 string !: >>>>>>>>37 string x \b%-.1s ->>>>>>>>>38 string !: +>>>>>>>>>38 string !: >>>>>>>>>>38 string x \b%-.1s >512 string \037\213 \b, gzipped >769 string ustar\0 \b, tarred diff --git contrib/file/magic/Magdir/games contrib/file/magic/Magdir/games index 779bc6cfd643..9f72661d82fb 100644 --- contrib/file/magic/Magdir/games +++ contrib/file/magic/Magdir/games @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: games,v 1.14 2014/04/30 21:41:02 christos Exp $ +# $File: games,v 1.15 2017/03/17 21:35:28 christos Exp $ # games: file(1) for games # Fabio Bonelli <fabiobonelli@libero.it> @@ -39,7 +39,7 @@ #0 string -1\x0a Quake I demo #>30 string x version %.4s -#>61 string x level %s +#>61 string x level %s #0 string 5\x0a Quake I save @@ -240,7 +240,7 @@ # Summary: NetImmerse game engine file # Extension .nif # Created by: Abel Cheung <abelcheung@gmail.com> -0 string NetImmerse\ File\ Format,\ Versio +0 string NetImmerse\ File\ Format,\ Versio >&0 string n\ NetImmerse game engine file >>&0 regex [0-9a-z.]+ \b, version %s diff --git contrib/file/magic/Magdir/gconv contrib/file/magic/Magdir/gconv new file mode 100644 index 000000000000..eec5ddcd7a57 --- /dev/null +++ contrib/file/magic/Magdir/gconv @@ -0,0 +1,10 @@ + +#------------------------------------------------------------------------------ +# $File: gconv +# gconv: file(1) magic for iconv/gconv module configuration cache +# +# Magic number defined in glibc/iconv/iconvconfig.h as GCONVCACHE_MAGIC +# +# From: Marek Cermak <macermak@redhat.com> +# +0 lelong 0x20010324 gconv module configuration cache data diff --git contrib/file/magic/Magdir/geo contrib/file/magic/Magdir/geo index 9a765fed0c11..f93abd806c27 100644 --- contrib/file/magic/Magdir/geo +++ contrib/file/magic/Magdir/geo @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: geo,v 1.3 2013/01/04 00:47:02 christos Exp $ +# $File: geo,v 1.4 2017/03/17 21:35:28 christos Exp $ # Geo- files from Kurt Schwehr <schwehr@ccom.unh.edu> ###################################################################### @@ -57,7 +57,7 @@ 4 beshort 0x2002 GeoSwath RDF 0 string Start:- GeoSwatch auf text file -# Seabeam 2100 +# Seabeam 2100 # mbsystem code mb41 0 string SB2100 SeaBeam 2100 multibeam sonar 0 string SB2100DR SeaBeam 2100 DR multibeam sonar diff --git contrib/file/magic/Magdir/gnu contrib/file/magic/Magdir/gnu index 24609c16459c..8d5c9721588b 100644 --- contrib/file/magic/Magdir/gnu +++ contrib/file/magic/Magdir/gnu @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: gnu,v 1.17 2016/07/16 22:17:04 christos Exp $ +# $File: gnu,v 1.18 2017/03/17 21:35:28 christos Exp $ # gnu: file(1) magic for various GNU tools # # GNU nlsutils message catalog file format @@ -71,7 +71,7 @@ # they will ordinarily reported as "compressed", but at least -z helps 39 string =<gmr:Workbook Gnumeric spreadsheet -# From: James Youngman <jay@gnu.org> +# From: James Youngman <jay@gnu.org> # gnu find magic 0 string \0LOCATE GNU findutils locate database data >7 string >\0 \b, format %s diff --git contrib/file/magic/Magdir/gpt contrib/file/magic/Magdir/gpt index c48a58f7fe63..76a223c3a030 100644 --- contrib/file/magic/Magdir/gpt +++ contrib/file/magic/Magdir/gpt @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: gpt,v 1.3 2014/04/30 21:41:02 christos Exp $ +# $File: gpt,v 1.4 2017/03/17 21:35:28 christos Exp $ # # GPT Partition table patterns. # Author: Rogier Goossens (goossens.rogier@gmail.com) @@ -36,7 +36,7 @@ >>>>>>>>>>>>>(454.l*8192) string EFI\ PART GPT partition table >>>>>>>>>>>>>>0 use gpt-mbr-type >>>>>>>>>>>>>>&-8 use gpt-table ->>>>>>>>>>>>>>0 ubyte x of 8192 bytes +>>>>>>>>>>>>>>0 ubyte x of 8192 bytes >>>>>>>>>>>>>(454.l*8192) string !EFI\ PART >>>>>>>>>>>>>>(454.l*4096) string EFI\ PART GPT partition table >>>>>>>>>>>>>>>0 use gpt-mbr-type @@ -66,7 +66,7 @@ >>>>>>>>>>>>>(470.l*8192) string EFI\ PART GPT partition table >>>>>>>>>>>>>>0 use gpt-mbr-type >>>>>>>>>>>>>>&-8 use gpt-table ->>>>>>>>>>>>>>0 ubyte x of 8192 bytes +>>>>>>>>>>>>>>0 ubyte x of 8192 bytes >>>>>>>>>>>>>(470.l*8192) string !EFI\ PART >>>>>>>>>>>>>>(470.l*4096) string EFI\ PART GPT partition table >>>>>>>>>>>>>>>0 use gpt-mbr-type @@ -96,7 +96,7 @@ >>>>>>>>>>>>>(486.l*8192) string EFI\ PART GPT partition table >>>>>>>>>>>>>>0 use gpt-mbr-type >>>>>>>>>>>>>>&-8 use gpt-table ->>>>>>>>>>>>>>0 ubyte x of 8192 bytes +>>>>>>>>>>>>>>0 ubyte x of 8192 bytes >>>>>>>>>>>>>(486.l*8192) string !EFI\ PART >>>>>>>>>>>>>>(486.l*4096) string EFI\ PART GPT partition table >>>>>>>>>>>>>>>0 use gpt-mbr-type @@ -126,7 +126,7 @@ >>>>>>>>>>>>>(502.l*8192) string EFI\ PART GPT partition table >>>>>>>>>>>>>>0 use gpt-mbr-type >>>>>>>>>>>>>>&-8 use gpt-table ->>>>>>>>>>>>>>0 ubyte x of 8192 bytes +>>>>>>>>>>>>>>0 ubyte x of 8192 bytes >>>>>>>>>>>>>(502.l*8192) string !EFI\ PART >>>>>>>>>>>>>>(502.l*4096) string EFI\ PART GPT partition table >>>>>>>>>>>>>>>0 use gpt-mbr-type @@ -166,7 +166,7 @@ ##>(8.l*8192) string EFI\ PART ##>>(8.l*8192) use gpt-mbr-type ##>>&-8 use gpt-table -##>>0 ubyte x of 8192 bytes +##>>0 ubyte x of 8192 bytes ##>(8.l*8192) string !EFI\ PART ##>>(8.l*4096) string EFI\ PART GPT partition table ##>>>0 use gpt-mbr-type @@ -212,7 +212,7 @@ >>486 ulelong !1 \b (nonstandard: not at LBA 1) # GPT with protective MBR entry in partition 4 >498 ubyte 0xee ->>502 ulelong 1 +>>502 ulelong 1 >>>446 string !\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \b (with hybrid MBR) >>502 ulelong !1 \b (nonstandard: not at LBA 1) diff --git contrib/file/magic/Magdir/gpu contrib/file/magic/Magdir/gpu new file mode 100644 index 000000000000..62e30d0f7a25 --- /dev/null +++ contrib/file/magic/Magdir/gpu @@ -0,0 +1,28 @@ + +#------------------------------------------------------------------------------ +# $File: gpu,v 1.2 2017/03/23 22:11:53 christos Exp $ +# gpu: file(1) magic for GPU input files + +# Standard Portable Intermediate Representation (SPIR) +# Documentation: https://www.khronos.org/spir +# Typical file extension: .spv + +0 belong 0x07230203 Khronos SPIR-V binary, big-endian +>4 belong x \b, version 0x%08x +>8 belong x \b, generator 0x%08x + +0 lelong 0x07230203 Khronos SPIR-V binary, little-endian +>4 lelong x \b, version 0x%08x +>8 lelong x \b, generator 0x%08x + +# Vulkan Trace file +# Documentation: +# https://github.com/LunarG/VulkanTools/blob/master/vktrace/vktrace_common/\ +# vktrace_trace_packet_identifiers.h +# Typical file extension: .vktrace + +8 lequad 0xABADD068ADEAFD0C Vulkan trace file, little-endian +>0 leshort x \b, version %d + +8 bequad 0xABADD068ADEAFD0C Vulkan trace file, big-endian +>0 beshort x \b, version %d diff --git contrib/file/magic/Magdir/gringotts contrib/file/magic/Magdir/gringotts index 2bfef1b7f7de..b67475406a7b 100644 --- contrib/file/magic/Magdir/gringotts +++ contrib/file/magic/Magdir/gringotts @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: gringotts,v 1.5 2009/09/19 16:28:09 christos Exp $ +# $File: gringotts,v 1.6 2017/03/17 21:35:28 christos Exp $ # gringotts: file(1) magic for Gringotts # http://devel.pluto.linux.it/projects/Gringotts/ # author: Germano Rizzo <mano@pluto.linux.it> @@ -9,10 +9,10 @@ #file format 1 >3 string 1 v.1, MCRYPT S2K, SERPENT crypt, SHA-256 hash, ZLib lvl.9 #file format 2 ->3 string 2 v.2, MCRYPT S2K, +>3 string 2 v.2, MCRYPT S2K, >>8 byte&0x70 0x00 RIJNDAEL-128 crypt, >>8 byte&0x70 0x10 SERPENT crypt, ->>8 byte&0x70 0x20 TWOFISH crypt, +>>8 byte&0x70 0x20 TWOFISH crypt, >>8 byte&0x70 0x30 CAST-256 crypt, >>8 byte&0x70 0x40 SAFER+ crypt, >>8 byte&0x70 0x50 LOKI97 crypt, @@ -27,10 +27,10 @@ >>8 byte&0x03 0x02 lvl.6 >>8 byte&0x03 0x03 lvl.9 #file format 3 ->3 string 3 v.3, OpenPGP S2K, +>3 string 3 v.3, OpenPGP S2K, >>8 byte&0x70 0x00 RIJNDAEL-128 crypt, >>8 byte&0x70 0x10 SERPENT crypt, ->>8 byte&0x70 0x20 TWOFISH crypt, +>>8 byte&0x70 0x20 TWOFISH crypt, >>8 byte&0x70 0x30 CAST-256 crypt, >>8 byte&0x70 0x40 SAFER+ crypt, >>8 byte&0x70 0x50 LOKI97 crypt, diff --git contrib/file/magic/Magdir/hitachi-sh contrib/file/magic/Magdir/hitachi-sh index 1b615ae9256e..0238ed7ebc4e 100644 --- contrib/file/magic/Magdir/hitachi-sh +++ contrib/file/magic/Magdir/hitachi-sh @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: hitachi-sh,v 1.7 2015/09/30 20:32:35 christos Exp $ +# $File: hitachi-sh,v 1.8 2017/03/17 21:35:28 christos Exp $ # hitach-sh: file(1) magic for Hitachi Super-H # # Super-H COFF @@ -9,20 +9,20 @@ # https://en.wikipedia.org/wiki/COFF # https://de.wikipedia.org/wiki/Common_Object_File_Format # http://www.delorie.com/djgpp/doc/coff/filhdr.html -# below test line conflicts with 2nd NTFS filesystem sector +# below test line conflicts with 2nd NTFS filesystem sector # 2nd NTFS filesystem sector often starts with 0x05004e00 for unicode string 5 NTLDR # and Portable Gaming Notation Compressed format (*.WID http://pgn.freeservers.com/) -0 beshort 0x0500 +0 beshort 0x0500 # test for unused flag bits (0x8000,0x0800,0x0400,0x0200,x0080) in f_flags ->18 ubeshort&0x8E80 0 +>18 ubeshort&0x8E80 0 # use big endian variant of subroutine to display name+variables+flags -# for common object formated files +# for common object formated files >>0 use \^display-coff -0 leshort 0x0550 +0 leshort 0x0550 # test for unused flag bits in f_flags ->18 uleshort&0x8E80 0 -# use little endian variant of subroutine to -# display name+variables+flags for common object formated files +>18 uleshort&0x8E80 0 +# use little endian variant of subroutine to +# display name+variables+flags for common object formated files >>0 use display-coff diff --git contrib/file/magic/Magdir/ibm370 contrib/file/magic/Magdir/ibm370 index 7887dc3c5c7a..a49b28f5db80 100644 --- contrib/file/magic/Magdir/ibm370 +++ contrib/file/magic/Magdir/ibm370 @@ -1,28 +1,28 @@ #------------------------------------------------------------------------------ -# $File: ibm370,v 1.9 2014/04/30 21:41:02 christos Exp $ +# $File: ibm370,v 1.10 2017/03/17 21:35:28 christos Exp $ # ibm370: file(1) magic for IBM 370 and compatibles. # # "ibm370" said that 0x15d == 0535 was "ibm 370 pure executable". # What the heck *is* "USS/370"? # AIX 4.1's "/etc/magic" has # -# 0 short 0535 370 sysV executable +# 0 short 0535 370 sysV executable # >12 long >0 not stripped # >22 short >0 - version %d # >30 long >0 - 5.2 format -# 0 short 0530 370 sysV pure executable +# 0 short 0530 370 sysV pure executable # >12 long >0 not stripped # >22 short >0 - version %d # >30 long >0 - 5.2 format # # instead of the "USS/370" versions of the same magic numbers. # -0 beshort 0537 370 XA sysV executable +0 beshort 0537 370 XA sysV executable >12 belong >0 not stripped >22 beshort >0 - version %d >30 belong >0 - 5.2 format -0 beshort 0532 370 XA sysV pure executable +0 beshort 0532 370 XA sysV pure executable >12 belong >0 not stripped >22 beshort >0 - version %d >30 belong >0 - 5.2 format diff --git contrib/file/magic/Magdir/ibm6000 contrib/file/magic/Magdir/ibm6000 index 7f45072a187a..8b48f370eb79 100644 --- contrib/file/magic/Magdir/ibm6000 +++ contrib/file/magic/Magdir/ibm6000 @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: ibm6000,v 1.12 2013/09/16 15:12:42 christos Exp $ +# $File: ibm6000,v 1.13 2017/03/17 21:35:28 christos Exp $ # ibm6000: file(1) magic for RS/6000 and the RT PC. # 0 beshort 0x01df executable (RISC System/6000 V3.1) or obj module @@ -21,7 +21,7 @@ 0 beshort 0x01f7 64-bit XCOFF executable or object module >20 belong 0 not stripped # GRR: this test is still too general as it catches also many FATs of DOS filesystems -4 belong &0x0feeddb0 +4 belong &0x0feeddb0 # real core dump could not be 32-bit and 64-bit together >7 byte&0x03 !3 AIX core file >>1 byte &0x01 fulldump diff --git contrib/file/magic/Magdir/icc contrib/file/magic/Magdir/icc index 37fa30e8cb8c..55583b7b4f26 100644 --- contrib/file/magic/Magdir/icc +++ contrib/file/magic/Magdir/icc @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: icc,v 1.1 2013/01/08 01:43:18 christos Exp $ +# $File: icc,v 1.5 2017/08/13 00:21:47 christos Exp $ # icc: file(1) magic for International Color Consortium file formats # @@ -11,41 +11,204 @@ # http://www.color.org/specification/ICC1v43_2010-12.pdf # # for Specification ICC.1:2010 (Profile version 4.3.0.0). +# URL: http://fileformats.archiveteam.org/wiki/ICC_profile +# Reference: http://www.color.org/iccmax/ICC.2-2016-7.pdf +# Update: Joerg Jenderek # # Bytes 36 to 39 contain a generic profile file signature of "acsp"; # bytes 40 to 43 "may be used to identify the primary platform/operating # system framework for which the profile was created". # -# There are other fields that might be worth dumping as well. -# +# check and display ICC/ICM color profile +0 name color-profile +>36 string acsp +# skip ASCII like Cognacspirit.txt by month <= 12 +>>26 ubeshort <13 +# platform/operating system. Only 5 mentioned +# # This appears to be what's used for Apple ColorSync profiles. # Instead of adding that, Apple just changed the generic "acsp" entry # to be for "ColorSync ICC Color Profile" rather than "Kodak Color # Management System, ICC Profile". # Yes, it's "APPL", not "AAPL"; see the spec. -36 string acspAPPL ColorSync ICC Profile -!:mime application/vnd.iccprofile +>>>40 string APPL ColorSync # Microsoft ICM color profile -36 string acspMSFT Microsoft ICM Color Profile -!:mime application/vnd.iccprofile +>>>40 string MSFT Microsoft # Yes, that's a blank after "SGI". -36 string acspSGI\ SGI ICC Profile -!:mime application/vnd.iccprofile +>>>40 string SGI\ SGI # XXX - is this what's used for the Sun KCMS or not? The standard file # uses just "acsp" for that, but Apple's file uses it for "ColorSync", # and there *is* an identified "primary platform" value of SUNW. -36 string acspSUNW Sun KCMS ICC Profile +>>>40 string SUNW Sun KCMS + +# 5th platform +>>>40 string TGNT Taligent + +# remaining "l" "e" of "color profile" printed later to avoid error +>>>40 string x color profi +#>>>40 string x (%.4s) !:mime application/vnd.iccprofile +# for "ICM" extension only versions 2.x and for Kodak "CC" 2.0 is found +>>>8 ubyte =2 +# do not use empty message text to a avoid error like +# icc, 82: Warning: Current entry does not yet have a description for adding a EXTENSION type +# file.exe: could not find any valid magic files! +>>>>9 ubyte !0 \ble +!:ext icc/icm +# minor version +>>>>9 ubyte =0 \bl +# Kodak colour management system +>>>>>4 string =KCMS \be +!:ext icc/icm/cc +>>>>>4 string !KCMS \be +!:ext icc/icm +>>>8 ubyte !2 \ble +!:ext icc +# Profile version major.4bit-minor.sub1.sub2 like 4.3.0.0 (04300000h) +>>>8 ubyte x %u +>>>9 ubyte/16 x \b.%u +# reserved and shall be null but 205.205 in umx1220u.icm +>>>10 ubyte >0 \b.%u +>>>>11 ubyte >0 \b.%u +# preferred colour management module like appl CCMS KCMS Lino UCCM "Win " "FF " +# skip space like in brmsl08f.icm and null like in brmsl09f.icm, brmsl07f.icm +>>>4 string >\ \b, type %.2s +>>>>6 string >\ \b%.1s +>>>>>7 string >\ \b%.1s +# colour space "XYZ " "Lab " "RGB " CMYK GRAY ... +>>>16 string x \b, %.3s +>>>19 string >\ \b%.1s +# Profile Connection Space (PCS) field usually "XYZ " or "Lab " but sometimes +# null or CMYK like in ISOcoated_v2_to_PSOcoated_v3_DeviceLink.icc +>>>20 string >\0 \b/%.3s +>>>>23 string >\ \b%.1s +# eleven device classes +>>>12 string x \b-%.4s device +# skip 00001964h in hpf69000.icc or 0h in XRDC50Q.ICM or " ROT" in brmsl05f.icm +>>>52 string >\040 +# skip "none" model like in "Trinitron Compatible 9300K G2.2.icm" +>>>>52 ubelong !0x6e6f6e65 +# device manufacturer field like "HP " "IBM " EPSO +>>>>>48 string x \b, %.2s +>>>>>50 string >\ \b%.1s +>>>>>51 string >\ \b%.1s +# model like "ADI " "A265" and skip 20000404h in IS330.icm for RICOH RUSSIAN-SC +>>>>>52 string >\ \ \b/%.3s +>>>>>>55 string >\ \b%.1s +>>>>>52 string x model +# creator (often same as manufacture) like HP SONY XROX or null like in A925A.icm +>>>80 string >\0 by %.2s +>>>>82 string >\ \b%.1s +>>>>>83 string >\ \b%.1s +# profile size +>>>0 ubelong x \b, %u bytes +# skip invalid date 0 like in linearSRGB.icc +>>>24 ubequad !0 +# datetime dd-mm-yyyy hh:mm:ss +>>>>28 ubeshort x \b, %u +# month <= 12 +>>>>26 ubeshort x \b-%u +# year +>>>>24 ubeshort x \b-%u +# do not display midnight time like in CNHP8308.ICC +>>>>30 ubequad&0xFFffFFffFFff0000 !0 +# hour <= 24 +>>>>>30 ubeshort x %u +# minutes <= 59 +>>>>>32 ubeshort x \b:%.2u +# seconds <= 59 +>>>>>34 ubeshort x \b:%.2u +# vendor specific flags like 2 in HPCLJ5.ICM +>>>44 ubeshort >0 \b, 0x%x vendor flags +# profile flags bits 0-2 of least 16 used by ICC +#>>>44 ubelong >0 \b, 0x%x flags +# icEmbeddedProfileTrue +>>>44 ubelong &1 \b, embedded +# icEmbeddedProfileFalse +#>>>44 ubelong ^1 \b, not embedded +# icUseWithEmbeddedDataOnly +>>>44 ubelong &2 \b, dependently +# icUseAnywhere +#>>>44 ubelong ^2 \b, independently +>>>44 ubelong &4 \b, MCS +#>>>44 ubelong ^4 \b, no MCS +# vendor specific device attributes 1~srgb.icc +# E000D00h~CNB7QEDA.ICM C000A00h~CNB5FCAA.ICM 01040401h~CNB25PE3.ICM +>>>56 ubelong >0 \b, 0x%x vendor attribute +# ICC device attributes bits 0-7 used +#>>>60 ubelong x \b, 0x%x attribute +# http://www.color.org/icc34.h +>>>60 ubelong &0x01 \b, transparent +#>>>60 ubelong ^0x01 \b, reflective +>>>60 ubelong &0x02 \b, matte +#>>>60 ubelong ^0x02 \b, glossy +>>>60 ubelong &0x04 \b, negative +#>>>60 ubelong ^0x04 \b, positive +>>>60 ubelong &0x08 \b, black&white +#>>>60 ubelong ^0x08 \b, colour +>>>60 ubelong &0x10 \b, non-paper +#>>>60 ubelong ^0x10 \b, paper +>>>60 ubelong &0x20 \b, non-textured +#>>>60 ubelong ^0x20 \b, textured +>>>60 ubelong &0x40 \b, non-isotropic +#>>>60 ubelong ^0x40 \b, isotropic +>>>60 ubelong &0x80 \b, self-luminous +#>>>60 ubelong ^0x80 \b, non-self-luminous +# rendering intent 0-3 but 7AEA5027h in EE051__1.ICM 6CB1BCh in EE061__1.ICM +>>>64 ubelong >3 \b, 0x%x rendering intent +#>>>64 ubelong =0 \b, perceptual +>>>64 ubelong =1 \b, relative colorimetric +>>>64 ubelong =2 \b, saturation +>>>64 ubelong =3 \b, absolute colorimetric +# PCS illuminant (3*s15Fixed16Numbers) often 0000f6d6 00010000 0000d32d +>>>71 ubequad !0xd6000100000000d3 \b, PCS +# usually X~0.9642*65536=63189.8112~63190=F6D5h ; but also found +# often F6D6 in gt5000r.icm, F6B8 in kodakce.icm, F6CA in RSWOP.icm +>>>>68 ubelong !0x0000f6d5 X=0x%x +# usually Y=1.0~00010000h but Y=0 in brmsl07f.icm +>>>>72 ubelong !0x00010000 Y=0x%x +# usually Z~0.8249*65536=54060.6464~54061=D32Dh ; but also found +# D2F7 in hp1200c.icm, often D32C in A925A.icm, D309 in RSWOP.icm , D2F8 in kodak_dc.icm +>>>>76 ubelong !0x0000d32d Z=0x%x +# Profile ID. MD5 fingerprinting method as defined in Internet RFC 1321. +>>>84 ubequad >0 \b, 0x%llx MD5 +# reserved in older versions should be zero but also found CDCDCDCDCDCDCDCD +#>>100 ubequad x \b 0x%llx reserved +# tag table +# 6 <= tags count <= 43 +#>>>128 ubelong >43 \b, %u tags +>>>128 ubelong x +# shall contain the profileDescriptionTag "desc" , copyrightTag "cprt" +# search range = tags count * 12 -8=< maximal tag count * 12 -8= 43 * 12 -8= 508 +>>>>132 search/508 cprt +# but no copyright tag in linearSRGB.icc +# beneath /System/Library/Frameworks/WebKit.framework/ +# Versions/A/Frameworks/WebCore.framework/Versions/A/Resources +>>>>132 default x \b, no copyright tag +# 1st tag +#>>>132 string x \b, 1st tag %.4s +#>>>136 ubelong x 0x%x offset +#>>>140 ubelong x 0x%x len +# 2nd tag,... +# look also for profileDescriptionTag "desc" +>>>132 search/508 desc +# look further for TextDescriptionType "desc" signature +>>>>(&0.L) string =desc +>>>>>&4 pstring/l x "%s" +# look alternative for multiLocalizedUnicodeType "mluc" signature like in VideoPAL.icc +>>>>(&0.L) string =mluc +>>>>>&(&8.L) ubequad x +>>>>>>&4 bestring16 x '%s' # Any other profile. # XXX - should we use "acsp\0\0\0\0" for "no primary platform" profiles, # and use "acsp" for everything else and dump the "primary platform" # string in those cases? -36 string acsp ICC Profile -!:mime application/vnd.iccprofile +36 string acsp +>0 use color-profile diff --git contrib/file/magic/Magdir/images contrib/file/magic/Magdir/images index 3e9cd81f3198..f0d087b3b4b6 100644 --- contrib/file/magic/Magdir/images +++ contrib/file/magic/Magdir/images @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: images,v 1.117 2016/07/05 19:12:21 christos Exp $ +# $File: images,v 1.126 2017/06/11 22:25:44 christos Exp $ # images: file(1) magic for image formats (see also "iff", and "c-lang" for # XPM bitmaps) # @@ -26,23 +26,28 @@ # test of Color Map Type 0~no 1~color map # and Image Type 1 2 3 9 10 11 32 33 # and Color Map Entry Size 0 15 16 24 32 -0 ubequad&0x00FeC400000000C0 0 +0 ubequad&0x00FeC400000000C0 0 # skip more garbage by looking for positive image type ->2 ubyte >0 +>2 ubyte >0 # skip some compiled terminfo by looking for image type less equal 33 ->>2 ubyte <34 +>>2 ubyte <34 # skip arches.3200 , Finder.Root , Slp.1 by looking for low pixel sizes 15 16 24 32 ->>>16 ubyte <33 +>>>16 ubyte <33 # skip more by looking for pixel size 0Fh 10h 18h 20h ->>>>16 ubyte&0xC0 0x00 -# skip 260-16.ico by looking for no color map ->>>>>1 ubyte 0 -# implies no first map entry ->>>>>>3 uleshort 0 ->>>>>>>0 use tga-image +>>>>16 ubyte&0xC0 0x00 # Color Map ->>>>>1 ubyte >0 +>>>>>1 belong&0xfff7ffff 0x01010000 +>>>>>>0 use tga-image +>>>>>1 belong&0xfff7ffff 0x00020000 +>>>>>>0 use tga-image +>>>>>1 belong&0xfff7ffff 0x00030000 >>>>>>0 use tga-image +>>>>>1 default x +# skip 260-16.ico by looking for no color map +>>>>>>1 ubyte 0 +# implies no first map entry +>>>>>>>3 uleshort 0 +>>>>>>>>0 use tga-image # display tga bitmap image information 0 name tga-image >2 ubyte <34 Targa image data @@ -78,7 +83,7 @@ >14 uleshort =0 65536 # Image Pixel Size 15 16 24 32 >16 ubyte x x %d -# X origin of image. 0 normal +# X origin of image. 0 normal >8 uleshort >0 +%d # Y origin of image. 0 normal; positive for top >10 uleshort >0 +%d @@ -90,27 +95,27 @@ >17 ubyte &0x10 - right #>17 ubyte ^0x10 - left # some info say other bits 6-7 should be zero -# but data storage interleave by http://www.fileformat.info/format/tga/corion.htm +# but data storage interleave by http://www.fileformat.info/format/tga/corion.htm # 00 - no interleave;01 - even/odd interleave; 10 - four way interleave; 11 - reserved #>17 ubyte&0xC0 0x00 - no interleave >17 ubyte&0xC0 0x40 - interleave >17 ubyte&0xC0 0x80 - four way interleave >17 ubyte&0xC0 0xC0 - reserved -# positive length implies identification field ->0 ubyte >0 +# positive length implies identification field +>0 ubyte >0 >>18 string x "%s" # last 18 bytes of newer tga file footer signature ->18 search/4261301/s TRUEVISION-XFILE.\0 +>18 search/4261301/s TRUEVISION-XFILE.\0 # extension area offset if not 0 ->>&-8 ulelong >0 +>>&-8 ulelong >0 # length of the extension area. normal 495 for version 2.0 ->>>(&-4.l) uleshort 0x01EF +>>>(&-4.l) uleshort 0x01EF # AuthorName[41] >>>>&0 string >\0 - author "%-.40s" # Comment[324]=4 * 80 null terminated >>>>&41 string >\0 - comment "%-.80s" # date ->>>>&365 ubequad&0xffffFFFFffff0000 !0 +>>>>&365 ubequad&0xffffFFFFffff0000 !0 # Day >>>>>&-6 uleshort x %d # Month @@ -118,7 +123,7 @@ # Year >>>>>&-4 uleshort x \b-%d # time ->>>>&371 ubequad&0xffffFFFFffff0000 !0 +>>>>&371 ubequad&0xffffFFFFffff0000 !0 # hour >>>>>&-8 uleshort x %d # minutes @@ -128,14 +133,14 @@ # JobName[41] >>>>&377 string >\0 - job "%-.40s" # JobHour Jobminute Jobsecond ->>>>&418 ubequad&0xffffFFFFffff0000 !0 +>>>>&418 ubequad&0xffffFFFFffff0000 !0 >>>>>&-8 uleshort x %d >>>>>&-6 uleshort x \b:%.2d >>>>>&-4 uleshort x \b:%.2d # SoftwareId[41] >>>>&424 string >\0 - %-.40s # SoftwareVersionNumber ->>>>&424 ubyte >0 +>>>>&424 ubyte >0 >>>>>&40 uleshort/100 x %d >>>>>&40 uleshort%100 x \b.%d # VersionLetter @@ -143,16 +148,16 @@ # KeyColor >>>>&468 ulelong >0 - keycolor 0x%8.8x # Denominator of Pixel ratio. 0~no pixel aspect ->>>>&474 uleshort >0 +>>>>&474 uleshort >0 # Numerator >>>>>&-4 uleshort >0 - aspect %d >>>>>&-2 uleshort x \b/%d # Denominator of Gamma ratio. 0~no Gamma value ->>>>&478 uleshort >0 +>>>>&478 uleshort >0 # Numerator >>>>>&-4 uleshort >0 - gamma %d >>>>>&-2 uleshort x \b/%d -# ColorOffset +# ColorOffset #>>>>&480 ulelong x - col offset 0x%8.8x # StampOffset #>>>>&484 ulelong x - stamp offset 0x%8.8x @@ -170,43 +175,43 @@ >>&0 regex =[0-9]{1,50} \b, size = %s x >>>&0 regex =[0-9]{1,50} \b %s -0 search/1 P1 ->0 regex/4 P1\\s +0 search/1 P1 +>0 regex/4 P1[\040\t\f\r\n] >>0 use netpbm >>>0 string x \b, bitmap !:strength + 45 !:mime image/x-portable-bitmap -0 search/1 P2 ->0 regex/4 P2\\s +0 search/1 P2 +>0 regex/4 P2[\040\t\f\r\n] >>0 use netpbm >>>0 string x \b, greymap !:strength + 45 !:mime image/x-portable-greymap 0 search/1 P3 ->0 regex/4 P3\\s +>0 regex/4 P3[\040\t\f\r\n] >>0 use netpbm >>>0 string x \b, pixmap !:strength + 45 !:mime image/x-portable-pixmap -0 string P4 ->0 regex/4 P4\\s +0 string P4 +>0 regex/4 P4[\040\t\f\r\n] >>0 use netpbm >>>0 string x \b, rawbits, bitmap !:strength + 45 !:mime image/x-portable-bitmap -0 string P5 ->0 regex/4 P5\\s +0 string P5 +>0 regex/4 P5[\040\t\f\r\n] >>0 use netpbm >>>0 string x \b, rawbits, greymap !:strength + 45 !:mime image/x-portable-greymap -0 string P6 ->0 regex/4 P6\\s +0 string P6 +>0 regex/4 P6[\040\t\f\r\n] >>0 use netpbm >>>0 string x \b, rawbits, pixmap !:strength + 45 @@ -303,7 +308,7 @@ >>>8 leshort 0x8765 \bJBIG >>>8 leshort 0x8798 \bJPEG2000 >>>8 leshort 0x8799 \bNikon NEF Compressed ->>>8 default x +>>>8 default x >>>>8 leshort x \b(unknown 0x%x) >>>12 use tiff_entry >0 leshort 0x106 \b, PhotometricIntepretation= @@ -414,21 +419,35 @@ # (Greg Roelofs, newt@uchicago.edu) # (Albert Cahalan, acahalan@cs.uml.edu) # -# 137 P N G \r \n ^Z \n [4-byte length] H E A D [HEAD data] [HEAD crc] ... +# 137 P N G \r \n ^Z \n [4-byte length] I H D R [HEAD data] [HEAD crc] ... # -0 string \x89PNG\x0d\x0a\x1a\x0a PNG image data + +# IHDR parser +0 name png-ihdr +>0 belong x \b, %d x +>4 belong x %d, +>8 byte x %d-bit +>9 byte 0 grayscale, +>9 byte 2 \b/color RGB, +>9 byte 3 colormap, +>9 byte 4 gray+alpha, +>9 byte 6 \b/color RGBA, +#>10 byte 0 deflate/32K, +>12 byte 0 non-interlaced +>12 byte 1 interlaced + +# Standard PNG image. +0 string \x89PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0DIHDR PNG image data !:mime image/png ->16 belong x \b, %d x ->20 belong x %d, ->24 byte x %d-bit ->25 byte 0 grayscale, ->25 byte 2 \b/color RGB, ->25 byte 3 colormap, ->25 byte 4 gray+alpha, ->25 byte 6 \b/color RGBA, -#>26 byte 0 deflate/32K, ->28 byte 0 non-interlaced ->28 byte 1 interlaced +!:strength +10 +>16 use png-ihdr + +# Apple CgBI PNG image. +0 string \x89PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x04CgBI +>24 string \x00\x00\x00\x0DIHDR PNG image data (CgBI) +!:mime image/png +!:strength +10 +>>32 use png-ihdr # possible GIF replacements; none yet released! # (Greg Roelofs, newt@uchicago.edu) @@ -438,13 +457,13 @@ !:mime image/x-unknown # # GRR 950115: this is Jeremy Wohl's Free Graphics Format (better): -# +# 0 string FGF95a FGF image (GIF+deflate beta) !:mime image/x-unknown # # GRR 950115: this is Thomas Boutell's Portable Bitmap Format proposal # (best; not yet implemented): -# +# 0 string PBF PBF image (deflate compression) !:mime image/x-unknown @@ -528,19 +547,19 @@ # http://www.blackfiveservices.co.uk/awbmtools.shtml # http://biosgfx.narod.ru/v3/ # http://biosgfx.narod.ru/abr-2/ -0 string AWBM +0 string AWBM >4 leshort <1981 Award BIOS bitmap !:mime image/x-award-bmp # image width is a multiple of 4 ->>4 leshort&0x0003 0 +>>4 leshort&0x0003 0 >>>4 leshort x \b, %d >>>6 leshort x x %d >>4 leshort&0x0003 >0 \b, ->>>4 leshort&0x0003 =1 +>>>4 leshort&0x0003 =1 >>>>4 leshort x %d+3 ->>>4 leshort&0x0003 =2 +>>>4 leshort&0x0003 =2 >>>>4 leshort x %d+2 ->>>4 leshort&0x0003 =3 +>>>4 leshort&0x0003 =3 >>>>4 leshort x %d+1 >>>6 leshort x x %d # at offset 8 starts imagedata followed by "RGB " marker @@ -764,11 +783,11 @@ # http://web.archive.org/web/20100206055706/http://www.qzx.com/pc-gpe/pcx.txt # GRR: original test was still too general as it catches xbase examples T5.DBT,T6.DBT with 0xa000000 # test for bytes 0x0a,version byte (0,2,3,4,5),compression byte flag(0,1), bit depth (>0) of PCX or T5.DBT,T6.DBT -0 ubelong&0xffF8fe00 0x0a000000 -# for PCX bit depth > 0 ->3 ubyte >0 +0 ubelong&0xffF8fe00 0x0a000000 +# for PCX bit depth > 0 +>3 ubyte >0 # test for valid versions ->>1 ubyte <6 +>>1 ubyte <6 >>>1 ubyte !1 PCX !:mime image/x-pcx #!:mime image/pcx @@ -828,29 +847,29 @@ # Update: Joerg Jenderek # See http://fileformats.archiveteam.org/wiki/GEM_Raster # For variations, also see: -# http://www.seasip.info/Gem/ff_img.html (Ventura) +# http://www.seasip.info/Gem/ff_img.html (Ventura) # http://www.atari-wiki.com/?title=IMG_file (XIMG, STTT) # http://www.fileformat.info/format/gemraster/spec/index.htm (XIMG, STTT) # http://sylvana.net/1stguide/1STGUIDE.ENG (TIMG) 0 beshort 0x0001 # header_size ->2 beshort 0x0008 +>2 beshort 0x0008 >>0 use gem_info ->2 beshort 0x0009 +>2 beshort 0x0009 >>0 use gem_info # no example for NOSIG ->2 beshort 24 +>2 beshort 24 >>0 use gem_info # no example for HYPERPAINT ->2 beshort 25 +>2 beshort 25 >>0 use gem_info -16 string XIMG\0 +16 string XIMG\0 >0 use gem_info # no example -16 string STTT\0\x10 +16 string STTT\0\x10 >0 use gem_info # no example or description -16 string TIMG\0 +16 string TIMG\0 >0 use gem_info 0 name gem_info @@ -859,15 +878,15 @@ # http://www.snowstone.org.uk/riscos/mimeman/mimemap.txt !:mime image/x-gem # header_size 24 25 27 59 779 words for colored bitmaps ->>2 beshort >9 +>>2 beshort >9 >>>16 string STTT\0\x10 STTT >>>16 string TIMG\0 TIMG # HYPERPAINT or NOSIG variant ->>>16 string \0\x80 +>>>16 string \0\x80 >>>>2 beshort =24 NOSIG >>>>2 beshort !24 HYPERPAINT # NOSIG or XIMG variant ->>>16 default x +>>>16 default x >>>>16 string !XIMG\0 NOSIG >>16 string =XIMG\0 XIMG Image data !:ext img/ximg @@ -1177,7 +1196,7 @@ # updated by: Joerg Jenderek # URL: http://techmods.net/nuvi/ 0 string GARMIN\ BITMAP\ 01 Garmin Bitmap file -# extension is also used for +# extension is also used for # Sony SRF raw image (image/x-sony-srf) # SRF map # Terragen Surface Map (http://www.planetside.co.uk/terragen) @@ -1318,7 +1337,7 @@ !:mime image/x-icns !:apple ????icns !:ext icns ->4 ubelong >0 +>4 ubelong >0 # file size >>4 ubelong x \b, %d bytes # icon type @@ -1451,3 +1470,12 @@ >0x10 string GVRT Sega GVR image: >>0x10 use sega-gvr-image-header >>0x08 belong x \b, global index = %u + +# Light Field Picture +# Documentation: http://optics.miloush.net/lytro/TheFileFormat.aspx +# Typical file extensions: .lfp .lfr .lfx + +0 belong 0x894C4650 +>4 belong 0x0D0A1A0A +>12 belong 0x00000000 Lytro Light Field Picture +>8 belong x \b, version %d diff --git contrib/file/magic/Magdir/intel contrib/file/magic/Magdir/intel index 3f96b758fdd4..c4f02544d638 100644 --- contrib/file/magic/Magdir/intel +++ contrib/file/magic/Magdir/intel @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: intel,v 1.14 2015/11/10 00:13:27 christos Exp $ +# $File: intel,v 1.15 2017/03/17 21:35:28 christos Exp $ # intel: file(1) magic for x86 Unix # # Various flavors of x86 UNIX executable/object (other than Xenix, which @@ -36,8 +36,8 @@ # ./msdos (version 5.25) labeled the next entry as "MS Windows COFF Intel 80386 object file" # ./intel (version 5.25) label labeled the next entry as "80386 COFF executable" # SGI labeled the next entry as "iAPX 386 executable" --Dan Quinlan -0 leshort =0514 -# use subroutine to display name+flags+variables for common object formated files +0 leshort =0514 +# use subroutine to display name+flags+variables for common object formated files >0 use display-coff #>12 lelong >0 not stripped # no hint found, that at offset 22 is version diff --git contrib/file/magic/Magdir/isz contrib/file/magic/Magdir/isz index 3388a82a5b9d..af68db2b3e2e 100644 --- contrib/file/magic/Magdir/isz +++ contrib/file/magic/Magdir/isz @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------ -# $File: isz,v 1.3 2014/04/30 21:41:02 christos Exp $ -# ISO Zipped file format +# $File: isz,v 1.4 2017/03/17 21:35:28 christos Exp $ +# ISO Zipped file format # http://www.ezbsystems.com/isz/iszspec.txt 0 string IsZ! ISO Zipped file >4 byte x \b, header size %u diff --git contrib/file/magic/Magdir/jpeg contrib/file/magic/Magdir/jpeg index 2b49c21c6053..57adb1e546b0 100644 --- contrib/file/magic/Magdir/jpeg +++ contrib/file/magic/Magdir/jpeg @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: jpeg,v 1.30 2016/07/04 15:18:23 christos Exp $ +# $File: jpeg,v 1.31 2017/03/17 21:35:28 christos Exp $ # JPEG images # SunOS 5.5.1 had # @@ -53,14 +53,14 @@ >>5 beshort x \b%d >>9 byte x \b, frames %d ->0 beshort 0xFFC1 +>0 beshort 0xFFC1 >>(2.S+2) use jpeg_segment >>4 byte x \b, extended sequential, precision %d >>7 beshort x \b, %dx >>5 beshort x \b%d >>9 byte x \b, frames %d ->0 beshort 0xFFC2 +>0 beshort 0xFFC2 >>(2.S+2) use jpeg_segment >>4 byte x \b, progressive, precision %d >>7 beshort x \b, %dx @@ -71,11 +71,11 @@ >0 beshort 0xFFC4 >>(2.S+2) use jpeg_segment ->0 beshort 0xFFE1 +>0 beshort 0xFFE1 # Recursion handled by FFE0 #>>(2.S+2) use jpeg_segment >>4 string Exif \b, Exif Standard: [ ->>>10 indirect/r x +>>>10 indirect/r x >>>10 string x \b] # Application specific markers diff --git contrib/file/magic/Magdir/kerberos contrib/file/magic/Magdir/kerberos index cb07fedbe27f..93b8f79de99b 100644 --- contrib/file/magic/Magdir/kerberos +++ contrib/file/magic/Magdir/kerberos @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: kerberos,v 1.1 2014/12/10 18:45:43 christos Exp $ +# $File: kerberos,v 1.2 2017/03/17 21:35:28 christos Exp $ # kerberos: MIT kerberos file binary formats # @@ -38,7 +38,7 @@ >>>>>&0 bedate x \b, date=%s >>>>>>&0 byte x \b, kvno=%u #>>>>>>>&0 pstring/H x -#>>>>>>>>&0 belong x +#>>>>>>>>&0 belong x #>>>>>>>>>>&0 use keytab_entry 0 belong 0x05020000 Kerberos Keytab file diff --git contrib/file/magic/Magdir/kml contrib/file/magic/Magdir/kml index ed0f42ed8533..d603ea806288 100644 --- contrib/file/magic/Magdir/kml +++ contrib/file/magic/Magdir/kml @@ -1,13 +1,13 @@ #------------------------------------------------------------------------------ -# $File: kml,v 1.3 2010/11/25 15:00:12 christos Exp $ +# $File: kml,v 1.4 2017/03/17 21:35:28 christos Exp $ # Type: Google KML, formerly Keyhole Markup Language # Future development of this format has been handed # over to the Open Geospatial Consortium. # http://www.opengeospatial.org/standards/kml/ # From: Asbjoern Sloth Toennesen <asbjorn@lila.io> 0 string/t \<?xml ->20 search/400 \ xmlns= +>20 search/400 \ xmlns= >>&0 regex ['"]http://earth.google.com/kml Google KML document !:mime application/vnd.google-earth.kml+xml >>>&1 string 2.0' \b, version 2.0 @@ -25,7 +25,7 @@ >>>&1 string/t 2.2 \b, version 2.2 #------------------------------------------------------------------------------ -# Type: Google KML Archive (ZIP based) +# Type: Google KML Archive (ZIP based) # http://code.google.com/apis/kml/documentation/kml_tut.html # From: Asbjoern Sloth Toennesen <asbjorn@lila.io> 0 string PK\003\004 diff --git contrib/file/magic/Magdir/linux contrib/file/magic/Magdir/linux index c8cc0df5e50e..0630a8a7ce10 100644 --- contrib/file/magic/Magdir/linux +++ contrib/file/magic/Magdir/linux @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: linux,v 1.63 2015/08/24 05:16:11 christos Exp $ +# $File: linux,v 1.64 2017/03/17 21:35:28 christos Exp $ # linux: file(1) magic for Linux files # # Values for Linux/i386 binaries, from Daniel Quinlan <quinlan@yggdrasil.com> @@ -199,7 +199,7 @@ ############################################################################ # Linux 8086 executable 0 lelong&0xFF0000FF 0xC30000E9 Linux-Dev86 executable, headerless ->5 string . +>5 string . >>4 string >\0 \b, libc version %s 0 lelong&0xFF00FFFF 0x4000301 Linux-8086 executable @@ -213,7 +213,7 @@ >2 byte&0x40 !0 \b, A_PURE >2 byte&0x80 !0 \b, A_TOVLY >28 long !0 \b, not stripped ->37 string . +>37 string . >>36 string >\0 \b, libc version %s # 0 lelong&0xFF00FFFF 0x10000301 ld86 I80386 executable @@ -241,7 +241,7 @@ >24 lelong x %d symbols >28 lelong x %d ocons -# Linux Logical Volume Manager (LVM) +# Linux Logical Volume Manager (LVM) # Emmanuel VARAGNAT <emmanuel.varagnat@guzu.net> # # System ID, UUID and volume group name are 128 bytes long @@ -301,7 +301,7 @@ >>&0x20 lequad x \b, size: %lld 0x618 string LVM2\ 001 LVM2 PV (Linux Logical Volume Manager) ->&(&-12.l-0x21) byte x +>&(&-12.l-0x21) byte x # display UUID in LVM format + display all 32 bytes (instead of max string length: 31) >>&0x0 string >\x2f \b, UUID: %.6s >>&0x6 string >\x2f \b-%.4s @@ -340,7 +340,7 @@ # Summary: Xen saved domain file # Created by: Radek Vokal <rvokal@redhat.com> 0 string LinuxGuestRecord Xen saved domain ->20 search/256 (name +>20 search/256 (name >>&1 string x (name %s) # Type: Xen, the virtual machine monitor @@ -397,7 +397,7 @@ >>0x1046 ubeshort x \b%04x # Linux device tree: -# File format description can be found in the Linux kernel sources at +# File format description can be found in the Linux kernel sources at # Documentation/devicetree/booting-without-of.txt # From Christoph Biedl 0 belong 0xd00dfeed diff --git contrib/file/magic/Magdir/lisp contrib/file/magic/Magdir/lisp index db0592e730c7..43d102e1dd76 100644 --- contrib/file/magic/Magdir/lisp +++ contrib/file/magic/Magdir/lisp @@ -1,13 +1,13 @@ #------------------------------------------------------------------------------ -# $File: lisp,v 1.24 2015/11/30 20:54:26 christos Exp $ +# $File: lisp,v 1.25 2017/03/17 21:35:28 christos Exp $ # lisp: file(1) magic for lisp programs # # various lisp types, from Daniel Quinlan (quinlan@yggdrasil.com) # updated by Joerg Jenderek # GRR: This lot is too weak -#0 string ;; +#0 string ;; # windows INF files often begin with semicolon and use CRLF as line end # lisp files are mainly created on unix system with LF as line end #>2 search/4096 !\r Lisp/Scheme program text @@ -28,9 +28,9 @@ # URL: https://en.wikipedia.org/wiki/Emacs_Lisp # Reference: http://ftp.gnu.org/old-gnu/emacs/elisp-manual-18-1.03.tar.gz -# Update: Joerg Jenderek +# Update: Joerg Jenderek # Emacs 18 - this is always correct, but not very magical. -0 string \012( +0 string \012( # look for emacs lisp keywords # GRR: split regex because it is too long or get error like # lisp, 36: Warning: cannot get string from `^(defun|defvar|defconst|defmacro|setq|fset|put|provide|require|' @@ -50,13 +50,13 @@ # Emacs 19+ - ver. recognition added by Ian Springer # Also applies to XEmacs 19+ .elc files; could tell them apart with regexs # - Chris Chittleborough <cchittleborough@yahoo.com.au> -# Update: Joerg Jenderek -0 string ;ELC +# Update: Joerg Jenderek +0 string ;ELC # version\0\0\0 >4 byte >18 Emacs/XEmacs v%d byte-compiled Lisp data # why less than 32 ? does not make sense to me. GNU Emacs version is 24.5 at April 2015 #>4 byte <32 Emacs/XEmacs v%d byte-compiled Lisp data -!:mime application/x-elc +!:mime application/x-elc !:apple EMAxTEXT !:ext elc @@ -67,7 +67,7 @@ 0 long 0x70768BD2 CLISP memory image data 0 long 0xD28B7670 CLISP memory image data, other endian -#.com and .bin for MIT scheme +#.com and .bin for MIT scheme 0 string \372\372\372\372 MIT scheme (library?) # From: David Allouche <david@allouche.net> diff --git contrib/file/magic/Magdir/m4 contrib/file/magic/Magdir/m4 index f6b5e52640f9..3a1c6d19f7db 100644 --- contrib/file/magic/Magdir/m4 +++ contrib/file/magic/Magdir/m4 @@ -1,6 +1,9 @@ #------------------------------------------------------------------------------ -# $File: m4,v 1.1 2011/12/08 12:12:46 rrt Exp $ +# $File: m4,v 1.2 2017/08/14 07:40:38 christos Exp $ # make: file(1) magic for M4 scripts # 0 regex \^dnl\ M4 macro processor script text !:mime text/x-m4 +0 regex \^AC_DEFUN\\(\\[ M4 macro processor script text +!:strength + 15 +!:mime text/x-m4 diff --git contrib/file/magic/Magdir/macintosh contrib/file/magic/Magdir/macintosh index d7f20f2027f1..e7c0e5e81da6 100644 --- contrib/file/magic/Magdir/macintosh +++ contrib/file/magic/Magdir/macintosh @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: macintosh,v 1.26 2015/11/25 00:36:02 christos Exp $ +# $File: macintosh,v 1.27 2017/03/17 21:35:28 christos Exp $ # macintosh description # # BinHex is the Macintosh ASCII-encoded file format (see also "apple") @@ -109,9 +109,9 @@ # the assumption that 65-72 will all be ASCII (0x20-0x7F), that 73 will # have bits 1 (changed), 2 (busy), 3 (bozo), and 6 (invisible) unset, # and that 74 will be 0. So something like -# +# # 71 belong&0x80804EFF 0x00000000 Macintosh MacBinary data -# +# # >73 byte&0x01 0x01 \b, inited # >73 byte&0x02 0x02 \b, changed # >73 byte&0x04 0x04 \b, busy @@ -254,7 +254,7 @@ >0x9C string INDEX data file index >0x9C string VIEW data view -# spss magic for SPSS system and portable files, +# spss magic for SPSS system and portable files, # from Bruce Foster (bef@nwu.edu). 0 long 0xc1e2c3c9 SPSS Portable File @@ -273,7 +273,7 @@ # entries depend on the data arithmetic added after v.35 # There's also some Pascal strings in here, ditto... -# The boot block signature, according to IM:Files, is +# The boot block signature, according to IM:Files, is # "for HFS volumes, this field always contains the value 0x4C4B." # But if this is true for MFS or HFS+ volumes, I don't know. # Alternatively, the boot block is supposed to be zeroed if it's @@ -291,10 +291,10 @@ # *.hfs updated by Joerg Jenderek # http://en.wikipedia.org/wiki/Hierarchical_File_System # "BD" gives many false positives -0x400 beshort 0x4244 +0x400 beshort 0x4244 # ftp://ftp.mars.org/pub/hfs/hfsutils-3.2.6.tar.gz/hfsutils-3.2.6/libhfs/apple.h # first block of volume bit map (always 3) ->0x40e ubeshort 0x0003 +>0x40e ubeshort 0x0003 # maximal length of volume name is 27 >>0x424 ubyte <28 Macintosh HFS data !:mime application/x-apple-diskimage @@ -351,15 +351,15 @@ #>0x230 string x first type: %s, #>0x210 string x name: %s, #>0x254 belong x number of blocks: %d, -#>0x400 beshort 0x504D +#>0x400 beshort 0x504D #>>0x430 string x second type: %s, #>>0x410 string x name: %s, #>>0x454 belong x number of blocks: %d, -#>>0x800 beshort 0x504D +#>>0x800 beshort 0x504D #>>>0x830 string x third type: %s, #>>>0x810 string x name: %s, #>>>0x854 belong x number of blocks: %d, -#>>>0xa00 beshort 0x504D +#>>>0xa00 beshort 0x504D #>>>>0xa30 string x fourth type: %s, #>>>>0xa10 string x name: %s, #>>>>0xa54 belong x number of blocks: %d diff --git contrib/file/magic/Magdir/make contrib/file/magic/Magdir/make index f8509d6bdbcf..2895325a6e62 100644 --- contrib/file/magic/Magdir/make +++ contrib/file/magic/Magdir/make @@ -1,7 +1,8 @@ #------------------------------------------------------------------------------ -# $File: make,v 1.2 2015/08/25 07:34:06 christos Exp $ +# $File: make,v 1.3 2016/12/10 14:21:29 christos Exp $ # make: file(1) magic for makefiles # +# URL: https://en.wikipedia.org/wiki/Make_(software) 0 regex/100l \^CFLAGS makefile script text !:mime text/x-makefile 0 regex/100l \^VPATH makefile script text @@ -10,12 +11,19 @@ !:mime text/x-makefile 0 regex/100l \^all: makefile script text !:mime text/x-makefile -0 regex/100l \^\.PRECIOUS makefile script text +0 regex/100l \^\\.PRECIOUS makefile script text !:mime text/x-makefile -0 regex/100l \^\.BEGIN BSD makefile script text +# Update: Joerg Jenderek +# Reference: https://www.freebsd.org/cgi/man.cgi?make(1) +# exclude grub-core\lib\libgcrypt\mpi\Makefile.am with "#BEGIN_ASM_LIST" +# by additional escaping point character +0 regex/100l \^\\.BEGIN BSD makefile script text with "%s" !:mime text/x-makefile -0 regex/100l \^\.include BSD makefile script text +!:ext /mk +# exclude MS Windows help file CoNtenT with ":include FOOBAR.CNT" +# and NSIS script with "!include" by additional escaping point character +0 regex/100l \^\\.include BSD makefile script text with "%s" !:mime text/x-makefile - +!:ext /mk 0 regex/100l \^SUBDIRS automake makefile script text !:mime text/x-makefile diff --git contrib/file/magic/Magdir/maple contrib/file/magic/Magdir/maple index 05a8eaf298be..44ab2842b604 100644 --- contrib/file/magic/Magdir/maple +++ contrib/file/magic/Magdir/maple @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: maple,v 1.7 2013/01/11 16:45:23 christos Exp $ +# $File: maple,v 1.8 2017/03/17 21:35:28 christos Exp $ # maple: file(1) magic for maple files # "H. Nanosecond" <aldomel@ix.netcom.com> # Maple V release 4, a multi-purpose math program @@ -13,7 +13,7 @@ # no magic for these :-( # they are compiled indexes for maple files -# .hdb +# .hdb 0 string \000\004\000\000 Maple help database # .mhp @@ -40,7 +40,7 @@ # from byte 4 it is either 'nul E' or 'soh R' # I think 'nul E' means a file that was saved as a different name # a sort of revision marking -# 'soh R' means new +# 'soh R' means new >4 string \000\105 An old revision >4 string \001\122 The latest save diff --git contrib/file/magic/Magdir/marc21 contrib/file/magic/Magdir/marc21 index 7e859a3893b9..fd509ec15245 100644 --- contrib/file/magic/Magdir/marc21 +++ contrib/file/magic/Magdir/marc21 @@ -2,27 +2,29 @@ # marc21: file(1) magic for MARC 21 Format # # Kevin Ford (kefo@loc.gov) -# +# # MARC21 formats are for the representation and communication # of bibliographic and related information in machine-readable # form. For more info, see http://www.loc.gov/marc/ # leader position 20-21 must be 45 -20 string 45 +# and 22-23 also 00 so far, but we check that later. +20 string 45 +>0 search/2048 \x1e # leader starts with 5 digits, followed by codes specific to MARC format ->0 regex/1l (^[0-9]{5})[acdnp][^bhlnqsu-z] MARC21 Bibliographic +>>0 regex/1l (^[0-9]{5})[acdnp][^bhlnqsu-z] MARC21 Bibliographic !:mime application/marc ->0 regex/1l (^[0-9]{5})[acdnosx][z] MARC21 Authority +>>0 regex/1l (^[0-9]{5})[acdnosx][z] MARC21 Authority !:mime application/marc ->0 regex/1l (^[0-9]{5})[cdn][uvxy] MARC21 Holdings +>>0 regex/1l (^[0-9]{5})[cdn][uvxy] MARC21 Holdings !:mime application/marc -0 regex/1l (^[0-9]{5})[acdn][w] MARC21 Classification +>>0 regex/1l (^[0-9]{5})[acdn][w] MARC21 Classification !:mime application/marc ->0 regex/1l (^[0-9]{5})[cdn][q] MARC21 Community +>>0 regex/1l (^[0-9]{5})[cdn][q] MARC21 Community !:mime application/marc # leader position 22-23, should be "00" but is it? ->0 regex/1l (^.{21})([^0]{2}) (non-conforming) +>>0 regex/1l (^.{21})([^0]{2}) (non-conforming) !:mime application/marc diff --git contrib/file/magic/Magdir/mathematica contrib/file/magic/Magdir/mathematica index a93899e83c2e..e76957eea43a 100644 --- contrib/file/magic/Magdir/mathematica +++ contrib/file/magic/Magdir/mathematica @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: mathematica,v 1.8 2015/04/09 20:01:40 christos Exp $ +# $File: mathematica,v 1.9 2017/03/17 21:35:28 christos Exp $ # mathematica: file(1) magic for mathematica files # "H. Nanosecond" <aldomel@ix.netcom.com> # Mathematica a multi-purpose math program @@ -49,7 +49,7 @@ #0 string (*This\ is\ a\ Mathematica\ binary\ dump\ file.\ It\ can\ be\ loaded\ with\ Get.*) Mathematica binary file 0 string (*This\ is\ a\ Mathematica\ binary\ Mathematica binary file -#>71 string \000\010\010\010\010\000\000\000\000\000\000\010\100\010\000\000\000 +#>71 string \000\010\010\010\010\000\000\000\000\000\000\010\100\010\000\000\000 # >71... is optional >88 string >\0 from %s @@ -59,7 +59,7 @@ 0 string MMAPBF\000\001\000\000\000\203\000\001\000 Mathematica PBF (fonts I think) # .ml files These are menu resources I think -# these start with "[0-9][0-9][0-9]\ A~[0-9][0-9][0-9]\ +# these start with "[0-9][0-9][0-9]\ A~[0-9][0-9][0-9]\ # how to put that into a magic rule? 4 string \ A~ MAthematica .ml file diff --git contrib/file/magic/Magdir/metastore contrib/file/magic/Magdir/metastore index 285c3cfa0cca..53f5b37c936a 100644 --- contrib/file/magic/Magdir/metastore +++ contrib/file/magic/Magdir/metastore @@ -1,8 +1,8 @@ #------------------------------------------------------------------------------ -# $File: metastore,v 1.1 2011/04/06 12:37:44 christos Exp $ +# $File: metastore,v 1.2 2017/03/17 21:35:28 christos Exp $ # metastore: file(1) magic for metastore files # From: Thomas Wissen # see http://david.hardeman.nu/software.php#metastore -0 string MeTaSt00r3 Metastore data file, +0 string MeTaSt00r3 Metastore data file, >10 bequad x version %0llx diff --git contrib/file/magic/Magdir/meteorological contrib/file/magic/Magdir/meteorological index 541bbbffb894..9e7a3f1bcca6 100644 --- contrib/file/magic/Magdir/meteorological +++ contrib/file/magic/Magdir/meteorological @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: meteorological,v 1.1 2014/08/04 06:26:16 christos Exp $ +# $File: meteorological,v 1.2 2017/03/17 21:35:28 christos Exp $ # rinex: file(1) magic for RINEX files # http://igscb.jpl.nasa.gov/igscb/data/format/rinex210.txt # ftp://cddis.gsfc.nasa.gov/pub/reports/formats/rinex300.pdf @@ -34,7 +34,7 @@ >>&32 string x \b, date %15.15s >>5 string x \b, version %6.6s !:mime rinex/meteorological ->80 search/256 XXRINEXN RINEX Data, Navigation +>80 search/256 XXRINEXN RINEX Data, Navigation >>&32 string x \b, date %15.15s >>5 string x \b, version %6.6s !:mime rinex/navigation diff --git contrib/file/magic/Magdir/microfocus contrib/file/magic/Magdir/microfocus index b2d204b1b0c3..e5b247cd3d90 100644 --- contrib/file/magic/Magdir/microfocus +++ contrib/file/magic/Magdir/microfocus @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------ -# $File: microfocus,v 1.1 2016/02/09 01:22:49 christos Exp $ -# Micro Focus COBOL data files. +# $File: microfocus,v 1.2 2017/03/17 21:35:28 christos Exp $ +# Micro Focus COBOL data files. # http://documentation.microfocus.com/help/index.jsp?topic=\ # %2FGUID-0E0191D8-C39A-44D1-BA4C-D67107BAF784%2FHRFLRHFILE05.html diff --git contrib/file/magic/Magdir/mime contrib/file/magic/Magdir/mime index 42ca52dc6b58..57b2dd557ba2 100644 --- contrib/file/magic/Magdir/mime +++ contrib/file/magic/Magdir/mime @@ -1,9 +1,9 @@ #------------------------------------------------------------------------------ -# $File: mime,v 1.6 2010/11/25 15:00:12 christos Exp $ +# $File: mime,v 1.8 2017/03/17 22:20:22 christos Exp $ # mime: file(1) magic for MIME encoded files # -0 string/t Content-Type:\ +0 string/t Content-Type:\040 >14 string >\0 %s 0 string/t Content-Type: >13 string >\0 %s diff --git contrib/file/magic/Magdir/misctools contrib/file/magic/Magdir/misctools index eeb518d4f92a..3ce91b560bf7 100644 --- contrib/file/magic/Magdir/misctools +++ contrib/file/magic/Magdir/misctools @@ -1,6 +1,6 @@ #----------------------------------------------------------------------------- -# $File: misctools,v 1.16 2016/02/14 15:46:52 christos Exp $ +# $File: misctools,v 1.17 2017/03/17 21:35:28 christos Exp $ # misctools: file(1) magic for miscellaneous UNIX tools. # 0 search/1 %%!! X-Post-It-Note text @@ -14,7 +14,7 @@ #!:mime text/x-vcard !:mime text/vcard # VERSION must come right after BEGIN for 3.0 or 4.0 except in 2.1 , where it can be anywhere ->12 search/14000/c VERSION: +>12 search/14000/c VERSION: # VERSION 2.1 , 3.0 or 4.0 >>&0 string x \b, version %-.3s @@ -48,7 +48,7 @@ >12 ulelong !0x20 \b, 0x%8.8x RVA # CheckSum 0 >16 ulelong !0 \b, CheckSum 0x%8.8x -# Reserved or TimeDateStamp +# Reserved or TimeDateStamp >20 ledate x \b, %s # https://msdn.microsoft.com/en-us/library/windows/desktop/ms680519%28v=vs.85%29.aspx # Flags MINIDUMP_TYPE enumeration type 0 0x121 0x800 diff --git contrib/file/magic/Magdir/modem contrib/file/magic/Magdir/modem index e4decfda5195..d988e903bfcf 100644 --- contrib/file/magic/Magdir/modem +++ contrib/file/magic/Magdir/modem @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: modem,v 1.7 2016/01/08 00:56:42 christos Exp $ +# $File: modem,v 1.8 2017/03/17 21:35:28 christos Exp $ # modem: file(1) magic for modem programs # # From: Florian La Roche <florian@knorke.saar.de> @@ -13,24 +13,24 @@ # URL: https://de.wikipedia.org/wiki/Fax # Reference: http://web.archive.org/web/20020628195336/http://www.netnam.vn/unescocourse/computervision/104.htm # GRR: EOL of G3 is too general as it catches also TrueType fonts, Postscript PrinterFontMetric, others -0 short 0x0100 +0 short 0x0100 # 16 0-bits near beginning like True Type fonts *.ttf, Postscript PrinterFontMetric *.pfm, FTYPE.HYPERCARD, XFER ->2 search/9 \0\0 +>2 search/9 \0\0 # maximal 7 0-bits for pixel sequences or 11 0-bits for EOL in G3 ->2 default x +>2 default x # skip IRCAM file (VAX big-endian) ./audio ->>0 belong !0x0001a364 +>>0 belong !0x0001a364 # skip GEM Image data ./images ->>>2 beshort !0x0008 +>>>2 beshort !0x0008 # look for first keyword of Panorama database *.pan ->>>>11 search/262 \x06DESIGN +>>>>11 search/262 \x06DESIGN # skip Panorama database ->>>>11 default x +>>>>11 default x # old Apple DreamWorld DreamGrafix *.3200 with keyword at end of g3 looking files ->>>>>27118 search/1864 DreamWorld ->>>>>27118 default x +>>>>>27118 search/1864 DreamWorld +>>>>>27118 default x # skip MouseTrap/Mt.Defaults with file size 16 found on Golden Orchard Apple II CD Rom ->>>>>>8 ubequad !0x2e01010454010203 +>>>>>>8 ubequad !0x2e01010454010203 # skip PICTUREH.SML found on Golden Orchard Apple II CD Rom >>>>>>>8 ubequad !0x5dee74ad1aa56394 raw G3 (Group 3) FAX, byte-padded # version 5.25 labeled the entry above "raw G3 data, byte-padded" @@ -39,9 +39,9 @@ !:ext g3 # unusual image starting with black pixel #0 short 0x1300 raw G3 (Group 3) FAX -0 short 0x1400 +0 short 0x1400 # 16 0-bits near beginning like PicturePuzzler found on Golden Orchard Apple CD Rom ->2 search/9 \0\0 +>2 search/9 \0\0 # maximal 7 0-bits for pixel sequences or 11 0-bits for EOL in G3 >2 default x raw G3 (Group 3) FAX # version 5.25 labeled the above entry as "raw G3 data" diff --git contrib/file/magic/Magdir/mozilla contrib/file/magic/Magdir/mozilla index 173018c3fbb8..23288019f1aa 100644 --- contrib/file/magic/Magdir/mozilla +++ contrib/file/magic/Magdir/mozilla @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------ -# $File: mozilla,v 1.6 2015/01/25 16:20:46 christos Exp $ -# mozilla: file(1) magic for Mozilla XUL fastload files +# $File: mozilla,v 1.7 2017/03/17 21:35:28 christos Exp $ +# mozilla: file(1) magic for Mozilla XUL fastload files # (XUL.mfasl and XPC.mfasl) # URL: http://www.mozilla.org/ # From: Josh Triplett <josh@freedesktop.org> diff --git contrib/file/magic/Magdir/msdos contrib/file/magic/Magdir/msdos index 55ea3e83c3a7..6eb12c215774 100644 --- contrib/file/magic/Magdir/msdos +++ contrib/file/magic/Magdir/msdos @@ -1,12 +1,12 @@ #------------------------------------------------------------------------------ -# $File: msdos,v 1.111 2016/09/14 01:26:26 christos Exp $ +# $File: msdos,v 1.120 2017/08/13 00:21:47 christos Exp $ # msdos: file(1) magic for MS-DOS files # # .BAT files (Daniel Quinlan, quinlan@yggdrasil.com) # updated by Joerg Jenderek at Oct 2008,Apr 2011 -0 string/t @ +0 string/t @ >1 string/cW \ echo\ off DOS batch file text !:mime text/x-msdos-batch >1 string/cW echo\ off DOS batch file text @@ -230,7 +230,7 @@ >>(8.s*16) string go32stub for MS-DOS, DJGPP go32 DOS extender >>(8.s*16) string emx >>>&1 string x for DOS, Win or OS/2, emx %s ->>&(&0x42.l-3) byte x +>>&(&0x42.l-3) byte x >>>&0x26 string UPX \b, UPX compressed # and yet another guess: small .text, and after large .data is unusal, could be 32lite >>&0x2c search/0xa0 .text @@ -240,8 +240,8 @@ >(8.s*16) string $WdX \b, WDos/X DOS extender # By now an executable type should have been printed out. The executable -# may be a self-uncompressing archive, so look for evidence of that and -# print it out. +# may be a self-uncompressing archive, so look for evidence of that and +# print it out. # # Some signatures below from Greg Roelofs, newt@uchicago.edu. # @@ -283,8 +283,8 @@ # Skip to the end of the EXE. This will usually work fine in the PE case # because the MZ image is hardcoded into the toolchain and almost certainly # won't match any of these signatures. ->(4.s*512) long x ->>&(2.s-517) byte x +>(4.s*512) long x +>>&(2.s-517) byte x >>>&0 string PK\3\4 \b, ZIP self-extracting archive >>>&0 string Rar! \b, RAR self-extracting archive >>>&0 string =!\x11 \b, AIN 2.x self-extracting archive @@ -312,71 +312,77 @@ # only version=0x100 found >3 uleshort x \b, version 0x%x # length of string containing author,info and special characters ->6 ubyte >0 +>6 ubyte >0 #>>6 pstring x \b, name=%s >>7 string >\0 \b, author=%-.14s >>7 search/254 \xff \b, info= #>>>&0 string x \b%-s >>>&0 string x \b%-.15s -# for FreeDOS *.KL files +# for FreeDOS *.KL files 0 string/b KLF FreeDOS KEYBoard Layout file # only version=0x100 or 0x101 found >3 uleshort x \b, version 0x%x # stringlength ->5 ubyte >0 +>5 ubyte >0 >>8 string x \b, name=%-.2s -0 string \xffKEYB\ \ \ \0\0\0\0 +0 string \xffKEYB\ \ \ \0\0\0\0 >12 string \0\0\0\0`\004\360 MS-DOS KEYBoard Layout file -# DOS device driver updated by Joerg Jenderek at May 2011 -# http://maben.homeip.net/static/S100/IBM/software/DOS/DOS%20techref/CHAPTER.009 -0 ulequad&0x07a0ffffffff 0xffffffff DOS executable ( ->40 search/7 UPX! \bUPX compressed +# DOS device driver updated by Joerg Jenderek at May 2011,Mar 2017 +# https://amaus.net/static/S100/IBM/software/DOS/DOS%20techref/CHAPTER.009 +0 ulequad&0x07a0ffffffff 0xffffffff +>0 use msdos-driver +0 name msdos-driver DOS executable ( +#!:mime application/octet-stream +!:mime application/x-dosdriver +# also found FreeDOS print driver SPOOL.DEV and disc compression driver STACLOAD.BIN +!:ext sys/dev/bin +>40 search/7 UPX! \bUPX compressed # DOS device driver attributes >4 uleshort&0x8000 0x0000 \bblock device driver # character device >4 uleshort&0x8000 0x8000 \b ->>4 uleshort&0x0008 0x0008 \bclock +>>4 uleshort&0x0008 0x0008 \bclock # fast video output by int 29h ->>4 uleshort&0x0010 0x0010 \bfast +>>4 uleshort&0x0010 0x0010 \bfast # standard input/output device ->>4 uleshort&0x0003 >0 \bstandard +>>4 uleshort&0x0003 >0 \bstandard >>>4 uleshort&0x0001 0x0001 \binput >>>4 uleshort&0x0003 0x0003 \b/ ->>>4 uleshort&0x0002 0x0002 \boutput +>>>4 uleshort&0x0002 0x0002 \boutput >>4 uleshort&0x8000 0x8000 \bcharacter device driver ->0 ubyte x +>0 ubyte x # upx compressed device driver has garbage instead of real in name field of header ->>40 search/7 UPX! ->>40 default x +>>40 search/7 UPX! +>>40 default x # leading/trailing nulls, zeros or non ASCII characters in 8-byte name field at offset 10 are skipped ->>>12 ubyte >0x27 \b ->>>>10 ubyte >0x20 ->>>>>10 ubyte !0x2E +>>>12 ubyte >0x2E \b +>>>>10 ubyte >0x20 +>>>>>10 ubyte !0x2E >>>>>>10 ubyte !0x2A \b%c ->>>>11 ubyte >0x20 +>>>>11 ubyte >0x20 >>>>>11 ubyte !0x2E \b%c ->>>>12 ubyte >0x20 ->>>>>12 ubyte !0x39 +>>>>12 ubyte >0x20 +>>>>>12 ubyte !0x39 >>>>>>12 ubyte !0x2E \b%c ->>>13 ubyte >0x20 +>>>13 ubyte >0x20 >>>>13 ubyte !0x2E \b%c ->>>>14 ubyte >0x20 +>>>>14 ubyte >0x20 >>>>>14 ubyte !0x2E \b%c ->>>>15 ubyte >0x20 +>>>>15 ubyte >0x20 >>>>>15 ubyte !0x2E \b%c ->>>>16 ubyte >0x20 ->>>>>16 ubyte !0x2E +>>>>16 ubyte >0x20 +>>>>>16 ubyte !0x2E >>>>>>16 ubyte <0xCB \b%c ->>>>17 ubyte >0x20 ->>>>>17 ubyte !0x2E +>>>>17 ubyte >0x20 +>>>>>17 ubyte !0x2E >>>>>>17 ubyte <0x90 \b%c # some character device drivers like ASPICD.SYS, btcdrom.sys and Cr_atapi.sys contain only spaces or points in name field ->>>4 uleshort&0x8000 0x8000 ->>>>12 ubyte <0x2F +>>>12 ubyte <0x2F # they have their real name at offset 22 ->>>>>22 string >\0 \b%-.5s ->4 uleshort&0x8000 0x0000 +# also block device drivers like DUMBDRV.SYS +>>>>22 string >\056 %-.6s +>4 uleshort&0x8000 0x0000 # 32 bit sector addressing ( > 32 MB) for block devices >>4 uleshort&0x0002 0x0002 \b,32-bit sector- # support by driver functions 13h, 17h, 18h @@ -384,33 +390,42 @@ # open, close, removable media support by driver functions 0Dh, 0Eh, 0Fh >4 uleshort&0x0800 0x0800 \b,close media- # output until busy support by int 10h for character device driver ->4 uleshort&0x8000 0x8000 +>4 uleshort&0x8000 0x8000 >>4 uleshort&0x2000 0x2000 \b,until busy- # direct read/write support by driver functions 03h,0Ch >4 uleshort&0x4000 0x4000 \b,control strings- ->4 uleshort&0x8000 0x8000 +>4 uleshort&0x8000 0x8000 >>4 uleshort&0x6840 >0 \bsupport ->4 uleshort&0x8000 0x0000 +>4 uleshort&0x8000 0x0000 >>4 uleshort&0x4842 >0 \bsupport >0 ubyte x \b) -# DOS driver cmd640x.sys has 0x12 instead of 0xffffffff for pointer field to next device header -# Too weak, matches files that only contain 0's -#0 ulequad&0x000007a0ffffffed 0x0000000000000000 DOS-executable ( -#>4 uleshort&0x8000 0x8000 \bcharacter device driver -#>>10 string x %-.8s -#>4 uleshort&0x4000 0x4000 \b,control strings-support) +# DOS driver cmd640x.sys has 0x12 instead of 0xffffffff for pointer field to next device header +0 ulequad 0x0513c00000000012 +>0 use msdos-driver +# DOS drivers DC2975.SYS, DUMBDRV.SYS, ECHO.SYS has also none 0xffffffff for pointer field +0 ulequad 0x32f28000ffff0016 +>0 use msdos-driver +0 ulequad 0x007f00000000ffff +>0 use msdos-driver +0 ulequad 0x001600000000ffff +>0 use msdos-driver +# DOS drivers LS120.SYS, MKELS120.SYS use reserved bits of attribute field +0 ulequad 0x0bf708c2ffffffff +>0 use msdos-driver +0 ulequad 0x07bd08c2ffffffff +>0 use msdos-driver # updated by Joerg Jenderek -# GRR: line below too general as it catches also +# GRR: line below too general as it catches also # rt.lib DYADISKS.PIC and many more # start with assembler instruction MOV -0 ubyte 0x8c +0 ubyte 0x8c # skip "AppleWorks word processor data" like ARTICLE.1 ./apple ->4 string !O==== +>4 string !O==== # skip some unknown basic binaries like RocketRnger.SHR ->>5 string !MAIN +>>5 string !MAIN # skip "GPG symmetrically encrypted data" ./gnu -# skip "PGP symmetric key encrypted data" ./pgp +# skip "PGP symmetric key encrypted data" ./pgp # openpgpdefs.h: fourth byte < 14 indicate cipher algorithm type >>>4 ubyte >13 DOS executable (COM, 0x8C-variant) # the remaining files should be DOS *.COM executables @@ -428,7 +443,7 @@ # updated by Joerg Jenderek at Oct 2008 0 ulelong 0xffff10eb DR-DOS executable (COM) # byte 0xeb conflicts with "sequent" magic leshort 0xn2eb -0 ubeshort&0xeb8d >0xeb00 +0 ubeshort&0xeb8d >0xeb00 # DR-DOS STACKER.COM SCREATE.SYS missed 0 name msdos-com @@ -463,9 +478,9 @@ # updated by Joerg Jenderek at Oct 2008,2015 # following line is too general -0 ubyte 0xb8 +0 ubyte 0xb8 # skip 2 linux kernels like memtest.bin with "\xb8\xc0\x07\x8e" in ./linux ->0 string !\xb8\xc0\x07\x8e +>0 string !\xb8\xc0\x07\x8e # modified by Joerg Jenderek # syslinux COM32 or COM32R executable >>1 lelong&0xFFFFFFFe 0x21CD4CFe COM executable (32-bit COMBOOT @@ -496,8 +511,8 @@ #!:mime application/x-msdos-program !:ext com -0 string/b \x81\xfc ->4 string \x77\x02\xcd\x20\xb9 +0 string/b \x81\xfc +>4 string \x77\x02\xcd\x20\xb9 >>36 string UPX! FREE-DOS executable (COM), UPX compressed 252 string Must\ have\ DOS\ version DR-DOS executable (COM) # added by Joerg Jenderek at Oct 2008 @@ -514,10 +529,10 @@ #IFMEMDSK.cOM ASSIGN.cOM COMP.cOM 5 string \xcd\x21 COM executable for DOS #DELTMP.COm HASFAT32.cOM -7 string \xcd\x21 +7 string \xcd\x21 >0 byte !0xb8 COM executable for DOS #COMP.cOM MORE.COm -10 string \xcd\x21 +10 string \xcd\x21 >5 string !\xcd\x21 COM executable for DOS #comecho.com 13 string \xcd\x21 COM executable for DOS @@ -565,10 +580,23 @@ 0 string/b PO^Q` Microsoft Word 6.0 Document !:mime application/msword # -0 string/b \376\067\0\043 Microsoft Office Document +4 long 0 +>0 belong 0xfe320000 Microsoft Word for Macintosh 1.0 !:mime application/msword -0 string/b \333\245-\0\0\0 Microsoft Office Document +!:ext mcw +>0 belong 0xfe340000 Microsoft Word for Macintosh 3.0 !:mime application/msword +!:ext mcw +>0 belong 0xfe37001c Microsoft Word for Macintosh 4.0 +!:mime application/msword +!:ext mcw +>0 belong 0xfe370023 Microsoft Word for Macintosh 5.0 +!:mime application/msword +!:ext mcw + +0 string/b \333\245-\0\0\0 Microsoft Word 2.0 Document +!:mime application/msword +!:ext doc 512 string/b \354\245\301 Microsoft Word Document !:mime application/msword @@ -599,11 +627,11 @@ # Reference: http://www.aboutvb.de/bas/formate/pdf/wk3.pdf # Note: newer Lotus versions >2 use longer BOF record # record type (BeginningOfFile=0000h) + length (001Ah) -0 belong 0x00001a00 +0 belong 0x00001a00 # reserved should be 0h but 8c0dh for TUTMAC.WK3, 5h for SAMPADNS.WK3, 1h for a_readme.wk3, 1eh for K&G86.WK3 -#>18 uleshort&0x73E0 0 +#>18 uleshort&0x73E0 0 # Lotus Multi Byte Character Set (LMBCS=1-31) ->20 ubyte >0 +>20 ubyte >0 >>20 ubyte <32 Lotus 1-2-3 #!:mime application/x-123 !:mime application/vnd.lotus-1-2-3 @@ -640,10 +668,10 @@ !:ext fXX # main revision number >>>>4 uleshort x \b, revision 0x%x ->>>6 uleshort =0x0004 \b, cell range +>>>6 uleshort =0x0004 \b, cell range # active cellcoord range (start row, page,column ; end row, page, column) # start values normally 0~1st sheet A1 ->>>>8 ulelong !0 +>>>>8 ulelong !0 >>>>>10 ubyte >0 \b%d* >>>>>8 uleshort x \b%d, >>>>>11 ubyte x \b%d- @@ -656,9 +684,9 @@ >>>>20 ubyte >1 \b, character set 0x%x # flags >>>>21 ubyte x \b, flags 0x%x ->>>6 uleshort !0x0004 +>>>6 uleshort !0x0004 # record type (FONTNAME=00AEh) ->>>>30 search/29 \0\xAE +>>>>30 search/29 \0\xAE # variable length m (2) + entries (1) + ?? (1) + LCMBS string (n) >>>>>&4 string >\0 \b, 1st font "%s" # @@ -667,12 +695,12 @@ # Reference: http://www.schnarff.com/file-formats/lotus-1-2-3/WSFF2.TXT # Note: Used by both old Lotus 1-2-3 and Lotus Symphony (DOS) til version 2.x # record type (BeginningOfFile=0000h) + length (0002h) -0 belong 0x00000200 +0 belong 0x00000200 # GRR: line above is too general as it catches also MS Windows CURsor # to display MS Windows cursor (strength=70) before Lotus 1-2-3 (strength=70-1) !:strength -1 # skip Windows cursors with image height <256 and keep Lotus with low opcode 0001-0083h ->7 ubyte 0 +>7 ubyte 0 # skip Windows cursors with image width 256 and keep Lotus with positiv opcode >>6 ubyte >0 Lotus # !:mime application/x-123 @@ -737,9 +765,9 @@ # check and then display Lotus worksheet cells range 0 name lotus-cells # look for type (RANGE=0006h) + length (0008h) at record begin ->0 ubelong 0x06000800 \b, cell range +>0 ubelong 0x06000800 \b, cell range # cell range (start column, row, end column, row) start values normally 0,0~A1 cell ->>4 ulong !0 +>>4 ulong !0 >>>4 uleshort x \b%d, >>>6 uleshort x \b%d- # end of cell range @@ -792,19 +820,19 @@ # Windows icons # Update: Joerg Jenderek # URL: https://en.wikipedia.org/wiki/CUR_(file_format) -# Note: similiar to Windows CURsor. container for BMP (only DIB part) or PNG +# Note: similar to Windows CURsor. container for BMP (only DIB part) or PNG 0 belong 0x00000100 >9 byte 0 ->>0 byte x +>>0 byte x >>0 use cur-ico-dir >9 ubyte 0xff ->>0 byte x +>>0 byte x >>0 use cur-ico-dir # displays number of icons and information for icon or cursor 0 name cur-ico-dir # skip some Lotus 1-2-3 worksheets, CYCLE.PIC and keep Windows cursors with # 1st data offset = dir header size + n * dir entry size = 6 + n * 10h = ?6h ->18 ulelong &0x00000006 +>18 ulelong &0x00000006 # skip remaining worksheets, because valid only for DIB image (40) or PNG image (\x89PNG) >>(18.l) ulelong x MS Windows >>>0 ubelong 0x00000100 icon resource @@ -817,7 +845,7 @@ # 1st icon >>>>0x06 use ico-entry # 2nd icon ->>>>4 uleshort >1 +>>>>4 uleshort >1 >>>>>0x16 use ico-entry >>>0 ubelong 0x00000200 cursor resource #!:mime image/x-cur @@ -854,16 +882,16 @@ # offset of PNG or DIB image #>12 ulelong x \b, offset 0x%x # PNG header (\x89PNG) ->(12.l) ubelong =0x89504e47 ->>&-4 indirect x \b with +>(12.l) ubelong =0x89504e47 +>>&-4 indirect x \b with # DIB image ->(12.l) ubelong !0x89504e47 +>(12.l) ubelong !0x89504e47 #>>&-4 use dib-image # Windows non-animated cursors # Update: Joerg Jenderek # URL: https://en.wikipedia.org/wiki/CUR_(file_format) -# Note: similiar to Windows ICOn. container for BMP ( only DIB part) +# Note: similar to Windows ICOn. container for BMP ( only DIB part) # GRR: line below is too general as it catches also Lotus 1-2-3 files 0 belong 0x00000200 >9 byte 0 @@ -872,13 +900,13 @@ >>0 use cur-ico-dir # .chr files -0 string/b PK\010\010BGI Borland font +0 string/b PK\010\010BGI Borland font >4 string >\0 %s # then there is a copyright notice # .bgi files -0 string/b pk\010\010BGI Borland device +0 string/b pk\010\010BGI Borland device >4 string >\0 %s # then there is a copyright notice @@ -909,7 +937,7 @@ 0 lelong 0x08086b70 TurboC BGI file 0 lelong 0x08084b50 TurboC Font file -# Debian#712046: The magic below identifies "Delphi compiled form data". +# Debian#712046: The magic below identifies "Delphi compiled form data". # An additional source of information is available at: # http://www.woodmann.com/fravia/dafix_t1.htm 0 string TPF0 @@ -918,7 +946,7 @@ # tests for DBase files moved, updated and merged to database 0 string PMCC Windows 3.x .GRP file -1 string RDC-meg MegaDots +1 string RDC-meg MegaDots >8 byte >0x2F version %c >9 byte >0x2F \b.%c file 0 lelong 0x4C @@ -935,16 +963,16 @@ #>0x181 leshort x \b, offset %x #>0x183 leshort x \b, offsetdata %x #>0x185 leshort x \b, section length %x ->0x187 search/0xB55 WINDOWS\ VMM\ 4.0\0 ->>&0x5e ubyte >0 +>0x187 search/0xB55 WINDOWS\ VMM\ 4.0\0 +>>&0x5e ubyte >0 >>>&-1 string <PIFMGR.DLL \b, icon=%s #>>>&-1 string PIFMGR.DLL \b, icon=%s >>>&-1 string >PIFMGR.DLL \b, icon=%s ->>&0xF0 ubyte >0 +>>&0xF0 ubyte >0 >>>&-1 string <Terminal \b, font=%.32s #>>>&-1 string =Terminal \b, font=%.32s >>>&-1 string >Terminal \b, font=%.32s ->>&0x110 ubyte >0 +>>&0x110 ubyte >0 >>>&-1 string <Lucida\ Console \b, TrueTypeFont=%.32s #>>>&-1 string =Lucida\ Console \b, TrueTypeFont=%.32s >>>&-1 string >Lucida\ Console \b, TrueTypeFont=%.32s @@ -960,6 +988,7 @@ # DOS EPS Binary File Header # From: Ed Sznyter <ews@Black.Market.NET> 0 belong 0xC5D0D3C6 DOS EPS Binary File +!:mime image/x-eps >4 long >0 Postscript starts at byte %d >>8 long >0 length %d >>>12 long >0 Metafile starts at byte %d @@ -967,15 +996,15 @@ >>>20 long >0 TIFF starts at byte %d >>>>24 long >0 length %d -# TNEF magic From "Joomy" <joomy@se-ed.net> +# TNEF magic From "Joomy" <joomy@se-ed.net> # Microsoft Outlook's Transport Neutral Encapsulation Format (TNEF) -0 leshort 0x223e9f78 TNEF +0 lelong 0x223e9f78 TNEF !:mime application/vnd.ms-tnef # Norton Guide (.NG , .HLP) files added by Joerg Jenderek from source NG2HTML.C # of http://www.davep.org/norton-guides/ng2h-105.tgz # http://en.wikipedia.org/wiki/Norton_Guides -0 string NG\0\001 +0 string NG\0\001 # only value 0x100 found at offset 2 >2 ulelong 0x00000100 Norton Guide # Title[40] @@ -985,7 +1014,7 @@ >>48 string >\0 \b, %-.66s >>114 string >\0 %-.66s -# 4DOS help (.HLP) files added by Joerg Jenderek from source TPHELP.PAS +# 4DOS help (.HLP) files added by Joerg Jenderek from source TPHELP.PAS # of http://www.4dos.info/ # pointer,HelpID[8]=4DHnnnmm 0 ulelong 0x48443408 4DOS help file @@ -1033,7 +1062,7 @@ # Windows Enhanced Metafile (EMF) -# See msdn.microsoft.com/archive/en-us/dnargdi/html/msdn_enhmeta.asp +# See msdn.microsoft.com/archive/en-us/dnargdi/html/msdn_enhmeta.asp # for further information. 0 ulelong 1 >40 string \ EMF Windows Enhanced Metafile (EMF) image data @@ -1095,7 +1124,7 @@ 0 string/b MSWIM\000\000\000 Windows imaging (WIM) image 0 string/b WLPWM\000\000\000 Windows imaging (WIM) image, wimlib pipable format -# The second byte of these signatures is a file version; I don't know what, +# The second byte of these signatures is a file version; I don't know what, # if anything, produced files with version numbers 0-2. # From: John Elliott <johne@seasip.demon.co.uk> 0 string \xfc\x03\x00 Mallard BASIC program data (v1.11) @@ -1106,3 +1135,66 @@ 0 string MIOPEN Mallard BASIC Jetsam data 0 string Jetsam0 Mallard BASIC Jetsam index data +# DOS backup 2.0 to 3.2 + +# backupid.@@@ + +# plausibility check for date +0x3 ushort >1979 +>0x5 ubyte-1 <31 +>>0x6 ubyte-1 <12 +# actually 121 nul bytes +>>>0x7 string \0\0\0\0\0\0\0\0 +>>>>0x1 ubyte x DOS 2.0 backup id file, sequence %d +!:ext @@@ +>>>>0x0 ubyte 0xff \b, last disk + +# backed up file + +# skip some AppleWorks word like Tomahawk.Awp, WIN98SE-DE.vhd +# by looking for trailing nul of maximal file name string +0x52 ubyte 0 +# test for flag byte: FFh~complete file, 00h~split file +# FFh -127 = -1 -127 = -128 +# 00h -127 = 0 -127 = -127 +>0 byte-127 <-126 +# plausibility check for file name length +>>0x53 ubyte-1 <78 +# looking for terminating nul of file name string +>>>(0x53.b+4) ubyte 0 +# looking if last char of string is valid DOS file name +>>>>(0x53.b+3) ubyte >0x1F +# actually 44 nul bytes +# but sometimes garbage according to Ralf Quint. So can not be used as test +#>0x54 string \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 +# first char of full file name is DOS (5Ch) or UNIX (2Fh) path separator +# only DOS variant found. UNIX variant according to V32SLASH.TXT in archive PD0315.EXE +>>>>>5 ubyte&0x8C 0x0C +# ./msdos (version 5.30) labeled the entry as +# "DOS 2.0 backed up file %s, split file, sequence %d" or +# "DOS 2.0 backed up file %s, complete file" +>>>>>>0 ubyte x DOS 2.0-3.2 backed up +#>>>>>>0 ubyte 0xff complete +>>>>>>0 ubyte 0 +>>>>>>>1 uleshort x sequence %d of +# full file name with path but without drive letter and colon stored from 0x05 til 0x52 +>>>>>>0x5 string x file %s +# backup name is original filename +#!:ext * +# magic/Magdir/msdos, 1169: Warning: EXTENSION type ` *' has bad char '*' +# file: line 1169: Bad magic entry ' *' +# after header original file content +>>>>>>128 indirect x \b; + + +# DOS backup 3.3 to 5.x + +# CONTROL.nnn files +0 string \x8bBACKUP\x20 +# actually 128 nul bytes +>0xa string \0\0\0\0\0\0\0\0 +>>0x9 ubyte x DOS 3.3 backup control file, sequence %d +>>0x8a ubyte 0xff \b, last disk + +# NB: The BACKUP.nnn files consist of the files backed up, +# concatenated. diff --git contrib/file/magic/Magdir/msvc contrib/file/magic/Magdir/msvc index bf4ab0ca6147..13f847fbb20e 100644 --- contrib/file/magic/Magdir/msvc +++ contrib/file/magic/Magdir/msvc @@ -1,10 +1,10 @@ #------------------------------------------------------------------------------ -# $File: msvc,v 1.6 2016/01/26 00:03:19 christos Exp $ +# $File: msvc,v 1.9 2017/08/02 08:15:20 christos Exp $ # msvc: file(1) magic for msvc # "H. Nanosecond" <aldomel@ix.netcom.com> # Microsoft visual C -# +# # I have version 1.0 # .aps @@ -30,10 +30,10 @@ # Summary: Symbol Table / Debug info used by Microsoft compilers # URL: https://en.wikipedia.org/wiki/Program_database # Reference: https://code.google.com/p/pdbparser/wiki/MSF_Format -# Update: Joerg Jenderek +# Update: Joerg Jenderek # Note: test only for Windows XP+SP3 x86 , 8.1 x64 arm and 10.1 x86 # info does only applies partly for older files like msvbvm50.pdb about year 2001 -0 string Microsoft\ C/C++\ +0 string Microsoft\ C/C++\040 # "Microsoft Program DataBase" by TrID >24 search/14 \r\n\x1A MSVC program database !:mime application/x-ms-pdb @@ -42,18 +42,21 @@ >>16 regex \([0-9.]+\) ver %s #>>>0x38 search/128123456 /LinkInfo \b with linkinfo # "MSF 7.00" variant ->>0x1e leshort 0 +>>0x1e leshort 0 # PageSize 400h 1000h >>>0x20 lelong x \b, %d # Page Count >>>0x28 lelong x \b*%d bytes # "program database 2.00" variant ->>0x1e leshort !0 +>>0x1e leshort !0 # PageSize 400h >>>0x2c lelong x \b, %d # Page Count for msoo-dll.pdb 4379h >>>0x32 leshort x \b*%d bytes +# Reference: https://github.com/Microsoft/vstest/pull/856/commits/fdc7a9f074ca5a8dfeec83b1be9162bf0cf4000d +0 string/c bsjb\001\000\001\000\000\000\000\000\f\000\000\000pdb\ v1.0 Microsoft Rosyln C# debugging symbols version 1.0 + #.sbr 0 string \000\002\000\007\000 MSVC .sbr >5 string >\0 %s diff --git contrib/file/magic/Magdir/msx contrib/file/magic/Magdir/msx index ef2a7bb29891..69df6416fe7c 100644 --- contrib/file/magic/Magdir/msx +++ contrib/file/magic/Magdir/msx @@ -7,7 +7,7 @@ ############## MSX Music file formats ############## # Gigamix MGSDRV music file -0 string/b MGS MSX Gigamix MGSDRV3 music file, +0 string/b MGS MSX Gigamix MGSDRV3 music file, >6 ubeshort 0x0D0A >>3 byte x \bv%c >>4 byte x \b.%c @@ -35,7 +35,7 @@ >>0xF byte&0x02 0 \b, soundchips: AY-3-8910, SCC(+) >>0xF byte&0x02 0x02 \b, soundchips: SN76489 >>>0xF byte&0x04 0x04 stereo ->>0xF byte&0x01 0x01 \b, +>>0xF byte&0x01 0x01 \b, >>>0xF byte&0x18 0x00 \bYM2413 >>>0xF byte&0x18 0x08 \bYM2413, Y8950 >>>0xF byte&0x18 0x18 \bYM2413+Y8950 pseudostereo @@ -245,18 +245,18 @@ 0x4000 string/b AB >0x4002 uleshort >0x400F >>0x400A string \0\0\0\0\0\0 MSX ROM with nonstandard page order ->>0x4002 uleshort x \b, init=0x%04x ->>0x4004 uleshort >0 \b, stahdl=0x%04x ->>0x4006 uleshort >0 \b, devhdl=0x%04x ->>0x4008 uleshort >0 \b, bas=0x%04x +>>>0x4002 uleshort x \b, init=0x%04x +>>>0x4004 uleshort >0 \b, stahdl=0x%04x +>>>0x4006 uleshort >0 \b, devhdl=0x%04x +>>>0x4008 uleshort >0 \b, bas=0x%04x 0x8000 string/b AB >0x8002 uleshort >0x400F >>0x800A string \0\0\0\0\0\0 MSX ROM with nonstandard page order ->>0x8002 uleshort x \b, init=0x%04x ->>0x8004 uleshort >0 \b, stahdl=0x%04x ->>0x8006 uleshort >0 \b, devhdl=0x%04x ->>0x8008 uleshort >0 \b, bas=0x%04x +>>>0x8002 uleshort x \b, init=0x%04x +>>>0x8004 uleshort >0 \b, stahdl=0x%04x +>>>0x8006 uleshort >0 \b, devhdl=0x%04x +>>>0x8008 uleshort >0 \b, bas=0x%04x 0x3C000 string/b AB @@ -296,7 +296,7 @@ 4 uleshort 0x0900 >0xF byte 1 >>0x14 byte 0 ->>>0x1E string \ \ \ +>>>0x1E string \040\040\040 >>>>0x23 byte 1 >>>>>0x25 byte 0 >>>>>>0x15 string >\x30 diff --git contrib/file/magic/Magdir/mup contrib/file/magic/Magdir/mup index 5060c01dd8bf..05b9471b0755 100644 --- contrib/file/magic/Magdir/mup +++ contrib/file/magic/Magdir/mup @@ -1,6 +1,6 @@ # ------------------------------------------------------------------------ -# $File: mup,v 1.4 2009/09/19 16:28:11 christos Exp $ +# $File: mup,v 1.5 2017/03/17 21:35:28 christos Exp $ # mup: file(1) magic for Mup (Music Publisher) input file. # # From: Abel Cheung <abel (@) oaka.org> @@ -12,13 +12,13 @@ # 0 search/1 //!Mup Mup music publication program input text >6 string -Arkkra (Arkkra) ->>13 string - ->>>16 string . +>>13 string - +>>>16 string . >>>>14 string x \b, need V%.4s ->>>15 string . +>>>15 string . >>>>14 string x \b, need V%.3s ->6 string - ->>9 string . +>6 string - +>>9 string . >>>7 string x \b, need V%.4s ->>8 string . +>>8 string . >>>7 string x \b, need V%.3s diff --git contrib/file/magic/Magdir/nasa contrib/file/magic/Magdir/nasa index 49673b32fb99..de3545f80800 100644 --- contrib/file/magic/Magdir/nasa +++ contrib/file/magic/Magdir/nasa @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# nasa: file(1) magic +# nasa: file(1) magic # From: Barry Carter <carter.barry@gmail.com> 0 string DAF/SPK NASA SPICE file (binary format) diff --git contrib/file/magic/Magdir/netbsd contrib/file/magic/Magdir/netbsd index eb0847b67de4..5ee2d712d05f 100644 --- contrib/file/magic/Magdir/netbsd +++ contrib/file/magic/Magdir/netbsd @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: netbsd,v 1.23 2015/11/29 01:55:14 christos Exp $ +# $File: netbsd,v 1.24 2017/03/17 21:35:28 christos Exp $ # netbsd: file(1) magic for NetBSD objects # # All new-style magic numbers are in network byte order. @@ -10,7 +10,7 @@ # 0 belong&0377777777 041400413 a.out NetBSD/i386 demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -32,7 +32,7 @@ >32 lelong !0 (signal %d) 0 belong&0377777777 041600413 a.out NetBSD/m68k demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <8192 shared library >>20 belong =8192 dynamically linked executable >>20 belong >8192 dynamically linked executable @@ -54,7 +54,7 @@ >32 belong !0 (signal %d) 0 belong&0377777777 042000413 a.out NetBSD/m68k4k demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <4096 shared library >>20 belong =4096 dynamically linked executable >>20 belong >4096 dynamically linked executable @@ -76,7 +76,7 @@ >32 belong !0 (signal %d) 0 belong&0377777777 042200413 a.out NetBSD/ns32532 demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -101,7 +101,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 042400413 a.out NetBSD/SPARC demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <8192 shared library >>20 belong =8192 dynamically linked executable >>20 belong >8192 dynamically linked executable @@ -123,7 +123,7 @@ >32 belong !0 (signal %d) 0 belong&0377777777 042600413 a.out NetBSD/pmax demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -145,7 +145,7 @@ >32 lelong !0 (signal %d) 0 belong&0377777777 043000413 a.out NetBSD/vax 1k demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -167,7 +167,7 @@ >32 lelong !0 (signal %d) 0 belong&0377777777 045400413 a.out NetBSD/vax 4k demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -189,7 +189,7 @@ >32 lelong !0 (signal %d) # NetBSD/alpha does not support (and has never supported) a.out objects, -# so no rules are provided for them. NetBSD/alpha ELF objects are +# so no rules are provided for them. NetBSD/alpha ELF objects are # dealt with in "elf". 0 lelong 0x00070185 ECOFF NetBSD/alpha binary >10 leshort 0x0001 not stripped @@ -199,7 +199,7 @@ >32 lelong !0 (signal %d) 0 belong&0377777777 043400413 a.out NetBSD/mips demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <8192 shared library >>20 belong =8192 dynamically linked executable >>20 belong >8192 dynamically linked executable diff --git contrib/file/magic/Magdir/netscape contrib/file/magic/Magdir/netscape index a9b43cdd5f1d..0e1ca61334cf 100644 --- contrib/file/magic/Magdir/netscape +++ contrib/file/magic/Magdir/netscape @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: netscape,v 1.7 2015/08/24 05:20:52 christos Exp $ +# $File: netscape,v 1.8 2017/03/17 21:35:28 christos Exp $ # netscape: file(1) magic for Netscape files # "H. Nanosecond" <aldomel@ix.netcom.com> # version 3 and 4 I think @@ -15,8 +15,8 @@ # .snm Caches 0 string #\ Netscape\ folder\ cache Netscape folder cache 0 string \000\036\204\220\000 Netscape folder cache -# .n2p -# Net 2 Phone +# .n2p +# Net 2 Phone #0 string 123\130\071\066\061\071\071\071\060\070\061\060\061\063\060 0 string SX961999 Net2phone diff --git contrib/file/magic/Magdir/nitpicker contrib/file/magic/Magdir/nitpicker index 2486dee037f4..48c3d63a288a 100644 --- contrib/file/magic/Magdir/nitpicker +++ contrib/file/magic/Magdir/nitpicker @@ -1,9 +1,9 @@ #------------------------------------------------------------------------------ -# $File: nitpicker,v 1.6 2014/04/30 21:41:02 christos Exp $ +# $File: nitpicker,v 1.7 2017/03/17 21:35:28 christos Exp $ # nitpicker: file(1) magic for Flowfiles. # From: Christian Jachmann <C.Jachmann@gmx.net> http://www.nitpicker.de -0 string NPFF NItpicker Flow File +0 string NPFF NItpicker Flow File >4 byte x V%d. >5 byte x %d >6 bedate x started: %s diff --git contrib/file/magic/Magdir/os2 contrib/file/magic/Magdir/os2 index 21c1c0019dfd..ace69cb34b23 100644 --- contrib/file/magic/Magdir/os2 +++ contrib/file/magic/Magdir/os2 @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: os2,v 1.9 2016/05/11 15:51:57 christos Exp $ +# $File: os2,v 1.10 2017/03/17 21:35:28 christos Exp $ # os2: file(1) magic for OS/2 files # @@ -25,7 +25,7 @@ #>5 string >\ (Local file) <%s> # >>>>> OS/2 INF/HLP <<<<< (source: Daniel Dissett ddissett@netcom.com) -# Carl Hauser (chauser.parc@xerox.com) and +# Carl Hauser (chauser.parc@xerox.com) and # Marcus Groeber (marcusg@ph-cip.uni-koeln.de) # list the following header format in inf02a.doc: # @@ -35,11 +35,11 @@ # // bit 0: set if INF style file # // bit 4: set if HLP style file # // patching this byte allows reading HLP files -# // using the VIEW command, while help files +# // using the VIEW command, while help files # // seem to work with INF settings here as well. # int16 hdrsize; // total size of header # int16 unknown2; // unknown purpose -# +# 0 string HSP\x01\x9b\x00 OS/2 INF >107 string >0 (%s) 0 string HSP\x10\x9b\x00 OS/2 HLP diff --git contrib/file/magic/Magdir/os9 contrib/file/magic/Magdir/os9 index 52b04be3059c..74b47f358514 100644 --- contrib/file/magic/Magdir/os9 +++ contrib/file/magic/Magdir/os9 @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: os9,v 1.7 2011/05/13 22:15:54 christos Exp $ +# $File: os9,v 1.8 2017/03/17 21:35:28 christos Exp $ # # Copyright (c) 1996 Ignatios Souvatzis. All rights reserved. # @@ -15,7 +15,7 @@ # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; diff --git contrib/file/magic/Magdir/pbf contrib/file/magic/Magdir/pbf index d133d12bf621..8de6db025047 100644 --- contrib/file/magic/Magdir/pbf +++ contrib/file/magic/Magdir/pbf @@ -1,11 +1,11 @@ #------------------------------------------------------------------------------ -# $File: pbf,v 1.1 2013/12/21 14:27:24 christos Exp $ +# $File: pbf,v 1.2 2017/01/18 16:16:21 christos Exp $ # file(1) magic(5) data for OpenStreetMap # OpenStreetMap Protocolbuffer Binary Format (.osm.pbf) # http://wiki.openstreetmap.org/wiki/PBF_Format # From: Markus Heidelberg <markus.heidelberg@web.de> -0 belong 0x0000000D ->4 beshort 0x0A09 ->>6 string OSMHeader OpenStreetMap Protocolbuffer Binary Format +0 belong&0xfffffff0 0 +>4 beshort 0x0A09 +>>6 string OSMHeader OpenStreetMap Protocolbuffer Binary Format diff --git contrib/file/magic/Magdir/pc88 contrib/file/magic/Magdir/pc88 index e604a3b478ec..03822f50279f 100644 --- contrib/file/magic/Magdir/pc88 +++ contrib/file/magic/Magdir/pc88 @@ -9,7 +9,7 @@ >>0x280 string \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 >>>0x1A ubyte&0xEF 0 >>>>0x1B ubyte&0x8F 0 ->>>>>0x1B ubyte&70 <0x40 +>>>>>0x1B ubyte&70 <0x40 >>>>>>0x1C ulelong >0x21 >>>>>>>0 regex [[:print:]]* NEC PC-88 disk image, name=%s >>>>>>>>0x1B ubyte 0 \b, media=2D diff --git contrib/file/magic/Magdir/pc98 contrib/file/magic/Magdir/pc98 index 30f1ea386c46..3b995ed013d4 100644 --- contrib/file/magic/Magdir/pc98 +++ contrib/file/magic/Magdir/pc98 @@ -8,7 +8,7 @@ # http://www.jisyo.com/viewer/faq/maki_tech.htm 0 string/b MAKI01 Maki-chan v1. >6 ubyte|0x20 x \b%c image ->8 ubelong >0x40404040 \b, system ID: +>8 ubelong >0x40404040 \b, system ID: >>8 byte x %c >>9 byte x \b%c >>10 byte x \b%c diff --git contrib/file/magic/Magdir/pdf contrib/file/magic/Magdir/pdf index b43a675cec0c..04b564dd56b6 100644 --- contrib/file/magic/Magdir/pdf +++ contrib/file/magic/Magdir/pdf @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: pdf,v 1.8 2015/01/11 18:19:18 christos Exp $ +# $File: pdf,v 1.9 2017/05/24 17:35:20 christos Exp $ # pdf: file(1) magic for Portable Document Format # @@ -20,3 +20,8 @@ !:mime application/vnd.fdf >5 byte x \b, version %c >7 byte x \b.%c + +0 search/256 %PDF- PDF document +!:mime application/pdf +>&0 byte x \b, version %c +>&2 byte x \b.%c diff --git contrib/file/magic/Magdir/pdp contrib/file/magic/Magdir/pdp index 0afee0c9ba5c..2d18b62df595 100644 --- contrib/file/magic/Magdir/pdp +++ contrib/file/magic/Magdir/pdp @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: pdp,v 1.10 2014/04/30 21:41:02 christos Exp $ +# $File: pdp,v 1.11 2017/03/17 21:35:28 christos Exp $ # pdp: file(1) magic for PDP-11 executable/object and APL workspace # 0 lelong 0101555 PDP-11 single precision APL workspace @@ -14,8 +14,8 @@ # updated by Joerg Jenderek at Mar 2013 # GRR: line below too general as it catches also Windows precompiled setup information *.PNF -0 leshort 0401 -# skip *.PNF with WinDirPathOffset 58h +0 leshort 0401 +# skip *.PNF with WinDirPathOffset 58h >68 ulelong !0x00000058 PDP-11 UNIX/RT ldp # skip *.PNF with high byte of InfVersionDatumCount zero #>>15 byte !0 PDP-11 UNIX/RT ldp diff --git contrib/file/magic/Magdir/perl contrib/file/magic/Magdir/perl index 099a22d11298..c391d4a72036 100644 --- contrib/file/magic/Magdir/perl +++ contrib/file/magic/Magdir/perl @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------ -# $File: perl,v 1.25 2016/06/07 23:28:37 rrt Exp $ +# $File: perl,v 1.26 2017/02/21 18:34:55 christos Exp $ # perl: file(1) magic for Larry Wall's perl language. # # The `eval' lines recognizes an outrageously clever hack. @@ -33,14 +33,14 @@ # by Dmitry V. Levin and Alexey Tourbin # check the first line -0 search/1024 package +0 search/8192 package >0 regex \^package[\ \t]+[0-9A-Za-z_:]+\ *; Perl5 module source text -!:strength + 10 +!:strength + 40 # not 'p', check other lines -0 search/1024 !p +0 search/8192 !p >0 regex \^package[\ \t]+[0-9A-Za-z_:]+\ *; >>0 regex \^1\ *;|\^(use|sub|my)\ .*[(;{=] Perl5 module source text -!:strength + 10 +!:strength + 75 # Perl POD documents # From: Tom Hukins <tom@eborcom.com> diff --git contrib/file/magic/Magdir/pgf contrib/file/magic/Magdir/pgf index 825f5f685690..b5a251efdf38 100644 --- contrib/file/magic/Magdir/pgf +++ contrib/file/magic/Magdir/pgf @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: pgf,v 1.1 2013/04/22 15:19:49 christos Exp $ +# $File: pgf,v 1.2 2017/03/17 21:35:28 christos Exp $ # pgf: file(1) magic for Progressive Graphics File (PGF) # # <http://www.libpgf.org/uploads/media/PGF_Details_01.pdf> @@ -42,7 +42,7 @@ >>20 byte 19 RGB color 12, >>20 byte 20 RGB color 16, >>20 byte 255 unknown format, ->>20 default x format +>>20 default x format >>>20 byte x \b %d, >>21 byte x %d bpc # PGFPostHeader diff --git contrib/file/magic/Magdir/pgp contrib/file/magic/Magdir/pgp index 6e685fcfc979..585475dbb38c 100644 --- contrib/file/magic/Magdir/pgp +++ contrib/file/magic/Magdir/pgp @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: pgp,v 1.12 2016/10/07 20:22:12 christos Exp $ +# $File: pgp,v 1.14 2017/03/17 21:35:28 christos Exp $ # pgp: file(1) magic for Pretty Good Privacy # see http://lists.gnupg.org/pipermail/gnupg-devel/1999-September/016052.html # @@ -19,15 +19,15 @@ #>15 string SIGNED\040MESSAGE- signed message #>15 string PGP\040SIGNATURE- signature -2 string ---BEGIN\ PGP\ PUBLIC\ KEY\ BLOCK- PGP public key block +2 string ---BEGIN\040PGP\040PUBLIC\040KEY\040BLOCK- PGP public key block !:mime application/pgp-keys >10 search/100 \n\n >>&0 use pgp -0 string -----BEGIN\040PGP\40MESSAGE- PGP message +0 string -----BEGIN\040PGP\040MESSAGE- PGP message !:mime application/pgp >10 search/100 \n\n >>&0 use pgp -0 string -----BEGIN\040PGP\40SIGNATURE- PGP signature +0 string -----BEGIN\040PGP\040SIGNATURE- PGP signature !:mime application/pgp-signature >10 search/100 \n\n >>&0 use pgp @@ -77,7 +77,7 @@ >0 byte 0x30 >>1 byte&0xc0 0x00 Unused [0%x] >>1 byte&0xc0 0x40 User Attribute ->>1 byte&0xc0 0x80 Sym. Encrypted and Integrity Protected Data +>>1 byte&0xc0 0x80 Sym. Encrypted and Integrity Protected Data >>1 byte&0xc0 0xc0 Modification Detection Code # magic signatures to detect PGP crypto material (from stef) @@ -206,7 +206,7 @@ >0 byte 19 ECDSA >0 byte 20 ElGamal (Encrypt or Sign) >0 byte 21 Diffie-Hellman ->0 default x +>0 default x >>0 ubyte <22 unknown (pub %d) # this should never happen >>0 ubyte >21 invalid (%d) @@ -482,16 +482,16 @@ >1 use pgpkey 0 byte 0x97 PGP Secret Sub-key - >1 use pgpkey -0 byte 0x9d +0 byte 0x9d # Update: Joerg Jenderek # secret subkey packet (tag 7) with same structure as secret key packet (tag 5) # skip Fetus.Sys16 CALIBUS.MAIN OrbFix.Sys16.Ex by looking for positive len ->1 ubeshort >0 +>1 ubeshort >0 #>1 ubeshort x \b, body length 0x%x # next packet type often 88h,89h~(tag 2)~Signature Packet #>>(1.S+3) ubyte x \b, next packet type 0x%x # skip Dragon.SHR DEMO.INIT by looking for positive version ->>3 ubyte >0 +>>3 ubyte >0 # skip BUISSON.13 GUITAR1 by looking for low version number >>>3 ubyte <5 PGP Secret Sub-key # sub-key are normally part of secret key. So it does not occur as standalone file @@ -500,7 +500,7 @@ >>>>3 ubyte x (v%d) >>>>3 ubyte x - # old versions 2 or 3 but no real example found ->>>>3 ubyte <4 +>>>>3 ubyte <4 # 2 byte for key bits in version 5.28 look >>>>>11 ubeshort x %db >>>>>4 beldate x created on %s - @@ -508,15 +508,15 @@ #>>>>>8 ubeshort x 0x%x # display key algorithm 1~RSA Encrypt|Sign - 21~Diffie-Hellman >>>>>10 use key_algo ->>>>>(11.S/8) ubequad x +>>>>>(11.S/8) ubequad x # look after first key >>>>>>&5 use keyend # new version ->>>>3 ubyte >3 +>>>>3 ubyte >3 >>>>>9 ubeshort x %db >>>>>4 beldate x created on %s - # display key algorithm >>>>>8 use key_algo ->>>>>(9.S/8) ubequad x +>>>>>(9.S/8) ubequad x # look after first key for something like s2k >>>>>>&3 use keyend diff --git contrib/file/magic/Magdir/printer contrib/file/magic/Magdir/printer index 10168266c924..98fc1dfaad42 100644 --- contrib/file/magic/Magdir/printer +++ contrib/file/magic/Magdir/printer @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: printer,v 1.26 2014/04/12 14:51:52 christos Exp $ +# $File: printer,v 1.28 2017/03/17 22:20:22 christos Exp $ # printer: file(1) magic for printer-formatted files # @@ -13,7 +13,7 @@ >>>15 string EPS \b, type %s >>>15 string Query \b, type %s >>>15 string ExitServer \b, type %s ->>>15 search/1000 %%LanguageLevel:\ +>>>15 search/1000 %%LanguageLevel:\040 >>>>&0 string >\0 \b, Level %s # Some PCs have the annoying habit of adding a ^D as a document separator 0 string \004%! PostScript document text @@ -24,7 +24,7 @@ >>>16 string EPS \b, type %s >>>16 string Query \b, type %s >>>16 string ExitServer \b, type %s ->>>16 search/1000 %%LanguageLevel:\ +>>>16 search/1000 %%LanguageLevel:\040 >>>>&0 string >\0 \b, Level %s 0 string \033%-12345X%!PS PostScript document @@ -49,18 +49,18 @@ # HP Printer Job Language 0 string \033%-12345X@PJL HP Printer Job Language data # HP Printer Job Language -# The header found on Win95 HP plot files is the "Silliest Thing possible" +# The header found on Win95 HP plot files is the "Silliest Thing possible" # (TM) # Every driver puts the language at some random position, with random case # (LANGUAGE and Language) # For example the LaserJet 5L driver puts the "PJL ENTER LANGUAGE" in line 10 # From: Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de> -# +# 0 string \033%-12345X@PJL HP Printer Job Language data ->&0 string >\0 %s ->>&0 string >\0 %s ->>>&0 string >\0 %s ->>>>&0 string >\0 %s +>&0 string >\0 %s +>>&0 string >\0 %s +>>>&0 string >\0 %s +>>>>&0 string >\0 %s #>15 string \ ENTER\ LANGUAGE\ = #>31 string PostScript PostScript @@ -143,8 +143,8 @@ #------------------------------------------------------------------------------ # HP LaserJet 1000 series downloadable firmware file -0 string \xbe\xefABCDEFGH HP LaserJet 1000 series downloadable firmware +0 string \xbe\xefABCDEFGH HP LaserJet 1000 series downloadable firmware # From: Paolo <oopla@users.sf.net> -# Epson ESC/Page, ESC/PageColor +# Epson ESC/Page, ESC/PageColor 0 string \x1b\x01@EJL Epson ESC/Page language printer data diff --git contrib/file/magic/Magdir/project contrib/file/magic/Magdir/project index efa5d40f7afe..9180b57d63e5 100644 --- contrib/file/magic/Magdir/project +++ contrib/file/magic/Magdir/project @@ -1,8 +1,8 @@ #------------------------------------------------------------------------------ -# $File: project,v 1.4 2009/09/19 16:28:11 christos Exp $ +# $File: project,v 1.5 2017/03/17 21:35:28 christos Exp $ # project: file(1) magic for Project management -# +# # Magic strings for ftnchek project files. Alexander Mai 0 string FTNCHEK_\ P project file for ftnchek >10 string 1 version 2.7 diff --git contrib/file/magic/Magdir/psdbms contrib/file/magic/Magdir/psdbms index 1d218c0b8548..3eec965731a6 100644 --- contrib/file/magic/Magdir/psdbms +++ contrib/file/magic/Magdir/psdbms @@ -1,12 +1,12 @@ #------------------------------------------------------------------------------ -# $File: psdbms,v 1.7 2016/01/08 00:41:02 christos Exp $ +# $File: psdbms,v 1.8 2017/03/17 21:35:28 christos Exp $ # psdbms: file(1) magic for psdatabase # # Update: Joerg Jenderek # GRR: line below too general as it catches also some Panorama database *.pan , # AppleWorks word processor -0 belong&0xff00ffff 0x56000000 +0 belong&0xff00ffff 0x56000000 # assume version starts with digit >1 regex/s =^[0-9] ps database >>1 string >\0 version %s diff --git contrib/file/magic/Magdir/python contrib/file/magic/Magdir/python index 29dcc15a8519..f21ff659b453 100644 --- contrib/file/magic/Magdir/python +++ contrib/file/magic/Magdir/python @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: python,v 1.29 2016/07/27 09:42:16 rrt Exp $ +# $File: python,v 1.34 2017/08/14 07:40:38 christos Exp $ # python: file(1) magic for python # # Outlook puts """ too for urgent messages @@ -24,7 +24,11 @@ 0 belong 0x6c0c0d0a python 3.2 byte-compiled 0 belong 0x9e0c0d0a python 3.3 byte-compiled 0 belong 0xee0c0d0a python 3.4 byte-compiled -0 belong 0x160d0d0a python 3.5 byte-compiled +0 belong 0x160d0d0a python 3.5.1- byte-compiled +0 belong 0x170d0d0a python 3.5.2+ byte-compiled +0 belong 0x330d0d0a python 3.6 byte-compiled +0 belong 0x3e0d0d0a python 3.7 byte-compiled + 0 search/1/w #!\ /usr/bin/python Python script text executable !:strength + 15 @@ -41,12 +45,25 @@ # from module.submodule import func1, func2 -0 regex \^from\\s+(\\w|\\.)+\\s+import.*$ Python script text executable +0 regex \^from[\040\t\f\r\n]+([A-Za-z0-9_]|\\.)+[\040\t\f\r\n]+import.*$ Python script text executable +!:strength + 15 !:mime text/x-python # def __init__ (self, ...): 0 search/4096 def\ __init__ >&0 search/64 self Python script text executable +!:strength + 15 +!:mime text/x-python + +# if __name__ == "__main__": +0 search/4096 if\ __name__ +>&0 search/64 '__main__' Python script text executable +>&0 search/64 "__main__" Python script text executable +!:strength + 15 +!:mime text/x-python + +# import module [as abrev] +0 regex \^import\ [_[:alpha:]]+\ as\ [[:alpha:]][[:space:]]*$ Python script text executable !:mime text/x-python # comments @@ -62,12 +79,19 @@ # except: or finally: # block 0 search/4096 try: ->&0 regex \^\\s*except.*: Python script text executable +>&0 regex \^[[:space:]]*except.*:$ Python script text executable +!:strength + 15 !:mime text/x-python >&0 search/4096 finally: Python script text executable !:mime text/x-python -# def name(args, args): -0 regex \^(\ |\\t){0,50}def\ {1,50}[a-zA-Z]{1,100} ->&0 regex \ {0,50}\\(([a-zA-Z]|,|\ ){1,255}\\):$ Python script text executable +# class name[(base classes,)]: [pass] +0 regex \^class\ [_[:alpha:]]+(\\(.*\\))?(\ )*:([\ \t]+pass)?$ Python script text executable +!:strength + 15 +!:mime text/x-python + +# def name(*args, **kwargs): +0 regex \^[[:space:]]{0,50}def\ {1,50}[_a-zA-Z]{1,100} +>&0 regex \\(([[:alpha:]*_,\ ]){0,255}\\):$ Python script text executable +!:strength + 15 !:mime text/x-python diff --git contrib/file/magic/Magdir/riff contrib/file/magic/Magdir/riff index 55cfb20b63f2..adf0fc9fb9ed 100644 --- contrib/file/magic/Magdir/riff +++ contrib/file/magic/Magdir/riff @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: riff,v 1.31 2015/02/14 17:30:03 christos Exp $ +# $File: riff,v 1.32 2017/03/17 21:35:28 christos Exp $ # riff: file(1) magic for RIFF format # See # @@ -75,7 +75,7 @@ >>18 leshort x \b, %d entries # RIFF Device Independent Bitmap format >8 string RDIB \b, device-independent bitmap ->>16 string BM +>>16 string BM >>>30 leshort 12 \b, OS/2 1.x format >>>>34 leshort x \b, %d x >>>>36 leshort x %d @@ -226,9 +226,9 @@ >8 string sfbk SoundFont/Bank # MPEG-1 wrapped in a RIFF, apparently >8 string CDXA \b, wrapped MPEG-1 (CDXA) ->8 string 4XMV \b, 4X Movie file +>8 string 4XMV \b, 4X Movie file # AMV-type AVI file: http://wiki.multimedia.cx/index.php?title=AMV ->8 string AMV\040 \b, AMV +>8 string AMV\040 \b, AMV >8 string WEBP \b, Web/P image !:mime image/webp >>12 use riff-walk @@ -246,7 +246,7 @@ >>18 beshort x \b, %d entries # RIFF Device Independent Bitmap format >8 string RDIB \b, device-independent bitmap ->>16 string BM +>>16 string BM >>>30 beshort 12 \b, OS/2 1.x format >>>>34 beshort x \b, %d x >>>>36 beshort x %d @@ -284,7 +284,7 @@ #------------------------------------------------------------------------------ # Sony Wave64 # see http://www.vcs.de/fileadmin/user_upload/MBS/PDF/Whitepaper/Informations_about_Sony_Wave64.pdf -# 128 bit RIFF-GUID { 66666972-912E-11CF-A5D6-28DB04C10000 } in little-endian +# 128 bit RIFF-GUID { 66666972-912E-11CF-A5D6-28DB04C10000 } in little-endian 0 string riff\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00 Sony Wave64 RIFF data # 128 bit + total file size (64 bits) so 24 bytes # then WAVE-GUID { 65766177-ACF3-11D3-8CD1-00C04F8EDB8A } diff --git contrib/file/magic/Magdir/ruby contrib/file/magic/Magdir/ruby index cc3abd0408ae..45a253cb5f69 100644 --- contrib/file/magic/Magdir/ruby +++ contrib/file/magic/Magdir/ruby @@ -1,32 +1,51 @@ #------------------------------------------------------------------------------ -# $File: ruby,v 1.6 2016/07/27 09:46:29 rrt Exp $ +# $File: ruby,v 1.7 2017/08/14 13:39:18 christos Exp $ # ruby: file(1) magic for Ruby scripting language # URL: http://www.ruby-lang.org/ # From: Reuben Thomas <rrt@sc3d.org> # Ruby scripts -0 search/1/w #!\ /usr/bin/ruby Ruby script text executable +0 search/1/w #!\ /usr/bin/ruby Ruby script text executable !:strength + 15 !:mime text/x-ruby 0 search/1/w #!\ /usr/local/bin/ruby Ruby script text executable !:strength + 15 !:mime text/x-ruby -0 search/1 #!/usr/bin/env\ ruby Ruby script text executable +0 search/1 #!/usr/bin/env\ ruby Ruby script text executable !:strength + 15 !:mime text/x-ruby -0 search/1 #!\ /usr/bin/env\ ruby Ruby script text executable +0 search/1 #!\ /usr/bin/env\ ruby Ruby script text executable !:strength + 15 !:mime text/x-ruby # What looks like ruby, but does not have a shebang # (modules and such) # From: Lubomir Rintel <lkundrak@v3.sk> -0 regex \^[\ \t]*require[\ \t]'[A-Za-z_/]+' ->0 regex include\ [A-Z]|def\ [a-z]|\ do$ ->>0 regex \^[\ \t]*end([\ \t]*[;#].*)?$ Ruby script text +0 regex \^[[:space:]]*require[[:space:]]'[A-Za-z_/]+' +>0 regex def\ [a-z]|\ do$ +>>&0 regex \^[[:space:]]*end([[:space:]]+[;#].*)?$ Ruby script text +!:strength + 30 !:mime text/x-ruby -0 regex \^[\ \t]*(class|module)[\ \t][A-Z] +0 regex \^[[:space:]]*(class|module)[[:space:]][A-Z] >0 regex (modul|includ)e\ [A-Z]|def\ [a-z] ->>0 regex \^[\ \t]*end([\ \t]*[;#].*)?$ Ruby module source text +>>&0 regex \^[[:space:]]*end([[:space:]]+[;#].*)?$ Ruby script text +!:strength + 30 +!:mime text/x-ruby +# Classes with no modules or defs, beats simple ASCII +0 regex \^[[:space:]]*(class|module)[[:space:]][A-Z] +>&0 regex \^[[:space:]]*end([[:space:]]+[;#if].*)?$ Ruby script text +!:strength + 10 +!:mime text/x-ruby +# Looks for function definition to balance python magic +# def name (args) +# end +0 regex \^[[:space:]]*def\ [a-z]|def\ [[:alpha:]]+::[a-z] +>&0 regex \^[[:space:]]*end([[:space:]]+[;#].*)?$ Ruby script text +!:strength + 10 +!:mime text/x-ruby + +0 regex \^[[:space:]]*require[[:space:]]'[A-Za-z_/]+' Ruby script text +!:mime text/x-ruby +0 regex \^[[:space:]]*include\ ([A-Z]+[a-z]*(::))+ Ruby script text !:mime text/x-ruby diff --git contrib/file/magic/Magdir/sccs contrib/file/magic/Magdir/sccs index 95b3a5db128d..4717948fdbfc 100644 --- contrib/file/magic/Magdir/sccs +++ contrib/file/magic/Magdir/sccs @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: sccs,v 1.6 2009/09/19 16:28:12 christos Exp $ +# $File: sccs,v 1.7 2017/03/17 21:35:28 christos Exp $ # sccs: file(1) magic for SCCS archives # # SCCS archive structure: @@ -17,6 +17,6 @@ # Maybe we should just switch everybody from SCCS to RCS! # Further, you can't just say '\001h0', because the five-digit number # is a checksum that could (presumably) have any leading digit, -# and we don't have regular expression matching yet. +# and we don't have regular expression matching yet. # Hence the following official kludge: 8 string \001s\ SCCS archive data diff --git contrib/file/magic/Magdir/scientific contrib/file/magic/Magdir/scientific index e39720cf8784..2e0cf49bee74 100644 --- contrib/file/magic/Magdir/scientific +++ contrib/file/magic/Magdir/scientific @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------ -# $File: scientific,v 1.10 2015/08/24 05:18:55 christos Exp $ -# scientific: file(1) magic for scientific formats +# $File: scientific,v 1.12 2017/03/17 22:20:22 christos Exp $ +# scientific: file(1) magic for scientific formats # # From: Joe Krahn <krahn@niehs.nih.gov> @@ -90,7 +90,7 @@ # format DD-MMM-YY, e.g., 01-JAN-70, and the IDcode consists of numbers and # uppercase letters. However, examples have been seen without the date string, # e.g., the example on the chemime site. -0 string HEADER\ \ \ \ +0 string HEADER\ \ \ \040 >&0 regex/1l \^.{40} >>&0 regex/1l [0-9]{2}-[A-Z]{3}-[0-9]{2}\ {3} >>>&0 regex/1ls [A-Z0-9]{4}.{14}$ diff --git contrib/file/magic/Magdir/sendmail contrib/file/magic/Magdir/sendmail index 29004104d012..840859c56232 100644 --- contrib/file/magic/Magdir/sendmail +++ contrib/file/magic/Magdir/sendmail @@ -1,27 +1,27 @@ #------------------------------------------------------------------------------ -# $File: sendmail,v 1.8 2015/11/11 15:27:03 christos Exp $ +# $File: sendmail,v 1.10 2017/08/13 00:21:47 christos Exp $ # sendmail: file(1) magic for sendmail config files # # XXX - byte order? # -# Update: Joerg Jenderek +# Update: Joerg Jenderek # GRR: this test is too general as it catches also # READ.ME.FIRST.AWP Sendmail frozen configuration # - version ====|====|====|====|====|====|====|====|====|====|====|====|=== # Email_23_f217153422.ts Sendmail frozen configuration # - version \330jK\354 -0 byte 046 +0 byte 046 # http://www.sendmail.com/sm/open_source/docs/older_release_notes/ # freezed configuration file (dbm format?) created from sendmal.cf with -bz # by older sendmail. til version 8.6 support for frozen configuration files is removed -# valid version numbers look like "7.14.4" and should be simliar to output of commands -# "sendmail -d0 -bt < /dev/null |grep -i Version" or "egrep '^DZ' /etc/sendmail.cf" +# valid version numbers look like "7.14.4" and should be similar to output of commands +# "sendmail -d0 -bt < /dev/null |grep -i Version" or "egrep '^DZ' /etc/sendmail.cf" >16 regex/s =^[0-78][0-9.]{4} Sendmail frozen configuration # normally only /etc/sendmail.fc or /var/adm/sendmail/sendmail.fc !:ext fc >>16 string >\0 - version %s -0 short 0x271c +0 short 0x271c # look for valid version number >16 regex/s =^[0-78][0-9.]{4} Sendmail frozen configuration !:ext fc diff --git contrib/file/magic/Magdir/sequent contrib/file/magic/Magdir/sequent index 5137c0ed9af4..780d77e5d6ab 100644 --- contrib/file/magic/Magdir/sequent +++ contrib/file/magic/Magdir/sequent @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: sequent,v 1.12 2014/08/16 16:07:12 christos Exp $ +# $File: sequent,v 1.13 2017/03/17 21:35:28 christos Exp $ # sequent: file(1) magic for Sequent machines # # Sequent information updated by Don Dwiggins <atsun!dwiggins>. @@ -33,9 +33,9 @@ # http://en.wikipedia.org/wiki/Sequent_Computer_Systems # below test line conflicts with MS-DOS 2.11 floppies and Acronis loader #0 leshort 0x42eb SYMMETRY i386 standalone executable -0 leshort 0x42eb +0 leshort 0x42eb # skip unlike negative version ->124 lelong >-1 +>124 lelong >-1 # assuming version 28867614 is very low probable >>124 lelong !28867614 SYMMETRY i386 standalone executable >>>16 lelong >0 not stripped diff --git contrib/file/magic/Magdir/sgml contrib/file/magic/Magdir/sgml index e3dcc26c89b7..34edd3c30cdc 100644 --- contrib/file/magic/Magdir/sgml +++ contrib/file/magic/Magdir/sgml @@ -1,8 +1,10 @@ -#------------------------------------------------------------------------------ # $File: sgml,v 1.34 2016/09/11 13:56:42 christos Exp $ + +#------------------------------------------------------------------------------ +# $File: sgml,v 1.37 2017/07/23 08:23:33 christos Exp $ # Type: SVG Vectorial Graphics # From: Noel Torres <tecnico@ejerciciosresueltos.com> -0 string \<?xml\ version=" ->15 string >\0 +0 string \<?xml\ version= +>14 regex ['"\ \t]*[0-9.]+['"\ \t]* >>19 search/4096 \<svg SVG Scalable Vector Graphics image !:mime image/svg+xml >>19 search/4096 \<gnc-v2 GnuCash file @@ -11,16 +13,16 @@ !:mime image/svg # Sitemap file -0 string/t \<?xml\ version=" ->15 string >\0 +0 string/t \<?xml\ version= +>14 regex ['"\ \t]*[0-9.]+['"\ \t]* >>19 search/4096 \<urlset XML Sitemap document text !:mime application/xml-sitemap # OpenStreetMap XML (.osm) # http://wiki.openstreetmap.org/wiki/OSM_XML # From: Markus Heidelberg <markus.heidelberg@web.de> -0 string \<?xml\ version=" ->15 string >\0 +0 string \<?xml\ version= +>14 regex ['"\ \t]*[0-9.]+['"\ \t]* >>19 search/4096 \<osm OpenStreetMap XML data # xhtml @@ -46,6 +48,12 @@ !:mime text/html !:strength + 5 +# SVG document +# https://www.w3.org/TR/SVG/single-page.html +0 search/4096/cWbt \<!doctype\ svg SVG XML document +!:mime image/svg+xml +!:strength + 5 + 0 search/4096/cwt \<head\> HTML document text !:mime text/html !:strength + 5 diff --git contrib/file/magic/Magdir/sharc contrib/file/magic/Magdir/sharc index b40e65234282..e54088bc8f75 100644 --- contrib/file/magic/Magdir/sharc +++ contrib/file/magic/Magdir/sharc @@ -1,9 +1,9 @@ #------------------------------------------------------------------------ -# $File: sharc,v 1.7 2014/04/30 21:41:02 christos Exp $ +# $File: sharc,v 1.8 2017/03/17 21:35:28 christos Exp $ # file(1) magic for sharc files # -# SHARC DSP, MIDI SysEx and RiscOS filetype definitions added by +# SHARC DSP, MIDI SysEx and RiscOS filetype definitions added by # FutureGroove Music (dsp@futuregroove.de) #------------------------------------------------------------------------ diff --git contrib/file/magic/Magdir/sketch contrib/file/magic/Magdir/sketch index 82dacb8f06dc..ee731ddd52f8 100644 --- contrib/file/magic/Magdir/sketch +++ contrib/file/magic/Magdir/sketch @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: sketch,v 1.4 2009/09/19 16:28:12 christos Exp $ -# Sketch Drawings: http://sketch.sourceforge.net/ +# $File: sketch,v 1.5 2017/03/17 21:35:28 christos Exp $ +# Sketch Drawings: http://sketch.sourceforge.net/ # From: Edwin Mons <e@ik.nu> 0 search/1 ##Sketch Sketch document text diff --git contrib/file/magic/Magdir/sql contrib/file/magic/Magdir/sql index b07350a6b474..acc452931084 100644 --- contrib/file/magic/Magdir/sql +++ contrib/file/magic/Magdir/sql @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: sql,v 1.20 2016/07/05 19:49:59 christos Exp $ +# $File: sql,v 1.21 2017/03/17 21:35:28 christos Exp $ # sql: file(1) magic for SQL files # # From: "Marty Leisner" <mleisner@eng.mc.xerox.com> @@ -73,7 +73,7 @@ >>3 byte x Version %d #------------------------------------------------------------------------------ -# iRiver H Series database file +# iRiver H Series database file # From Ken Guest <ken@linux.ie> # As observed from iRivNavi.iDB and unencoded firmware # @@ -133,9 +133,9 @@ 0 string PSDB\0 Panasonic channel list DataBase !:ext db/bin #!:mime application/x-db-svl-panasonic ->126 string SQLite\ format\ 3 +>126 string SQLite\ format\ 3 #!:mime application/x-panasonic-sqlite3 ->>&-15 indirect x \b; contains +>>&-15 indirect x \b; contains # H2 Database from http://www.h2database.com/ 0 string --\ H2\ 0.5/B\ --\ \n H2 Database file diff --git contrib/file/magic/Magdir/ssl contrib/file/magic/Magdir/ssl index 5d5daeeaf30f..2094ef5e7c6f 100644 --- contrib/file/magic/Magdir/ssl +++ contrib/file/magic/Magdir/ssl @@ -1,8 +1,20 @@ + +#------------------------------------------------------------------------------ +# $File: ssl,v 1.4 2017/01/22 21:14:25 christos Exp $ +# ssl: file(1) magic for SSL file formats + # Type: OpenSSL certificates/key files # From: Nicolas Collignon <tsointsoin@gmail.com> -0 string -----BEGIN\ CERTIFICATE----- PEM certificate -0 string -----BEGIN\ CERTIFICATE\ REQ PEM certificate request -0 string -----BEGIN\ RSA\ PRIVATE PEM RSA private key -0 string -----BEGIN\ DSA\ PRIVATE PEM DSA private key -0 string -----BEGIN\ EC\ PRIVATE PEM EC private key +0 string -----BEGIN\040CERTIFICATE----- PEM certificate +0 string -----BEGIN\040CERTIFICATE\040REQ PEM certificate request +0 string -----BEGIN\040RSA\040PRIVATE PEM RSA private key +0 string -----BEGIN\040DSA\040PRIVATE PEM DSA private key +0 string -----BEGIN\040EC\040PRIVATE PEM EC private key +0 string -----BEGIN\040ECDSA\040PRIVATE PEM ECDSA private key + +# From Luc Gommans +# OpenSSL enc file (recognized by a magic string preceding the password's salt) +0 string Salted__ openssl enc'd data with salted password +# Using the -a or -base64 option, OpenSSL will base64-encode the data. +0 string U2FsdGVkX19 openssl enc'd data with salted password, base64 encoded diff --git contrib/file/magic/Magdir/sysex contrib/file/magic/Magdir/sysex index 97472e275548..fc9cbf4ed4a2 100644 --- contrib/file/magic/Magdir/sysex +++ contrib/file/magic/Magdir/sysex @@ -1,6 +1,6 @@ #------------------------------------------------------------------------ -# $File: sysex,v 1.8 2014/06/03 19:17:27 christos Exp $ +# $File: sysex,v 1.9 2017/03/17 21:35:28 christos Exp $ # sysex: file(1) magic for MIDI sysex files # # GRR: original 1 byte test at offset was too general as it catches also many FATs of DOS filesystems @@ -256,7 +256,7 @@ >1 belong&0xffffff00 0x00011d00 Nemesys >1 belong&0xffffff00 0x00011e00 DBX >1 belong&0xffffff00 0x00011f00 Syndyne ->1 belong&0xffffff00 0x00012000 Bitheadz +>1 belong&0xffffff00 0x00012000 Bitheadz >1 belong&0xffffff00 0x00012100 Cakewalk >1 belong&0xffffff00 0x00012200 Staccato >1 belong&0xffffff00 0x00012300 National Semicon. diff --git contrib/file/magic/Magdir/terminfo contrib/file/magic/Magdir/terminfo index b201bcae5b7a..43e9d43179eb 100644 --- contrib/file/magic/Magdir/terminfo +++ contrib/file/magic/Magdir/terminfo @@ -1,24 +1,51 @@ #------------------------------------------------------------------------------ -# $File: terminfo,v 1.7 2016/03/17 21:02:29 christos Exp $ +# $File: terminfo,v 1.9 2017/04/28 16:28:58 christos Exp $ # terminfo: file(1) magic for terminfo # -# XXX - byte order for screen images? +# URL: http://invisible-island.net/ncurses/man/term.5.html +# URL: http://invisible-island.net/ncurses/man/scr_dump.5.html # -# URL: https://en.wikipedia.org/wiki/Terminfo -# Reference: ncurses-5.9/ncurses/tinfo/write_entry.c -# Update: Joerg Jenderek -# -# GRR: line below too general as it catches also +# Workaround for Targa image type by Joerg Jenderek +# GRR: line below too general as it catches also # Targa image type 1 with 26 long identification field # and HELP.DSK -0 string \032\001 +0 string \032\001 # 5th character of terminal name list, but not Targa image pixel size (15 16 24 32) ->16 ubyte >32 +>16 ubyte >32 # namelist, if more than 1 separated by "|" like "st|stterm| simpleterm 0.4.1" >>12 regex \^[a-zA-Z0-9][a-zA-Z0-9.][^|]* Compiled terminfo entry "%-s" !:mime application/x-terminfo # no extension -#!:ext -0 short 0433 Curses screen image -0 short 0434 Curses screen image +#!:ext +# +# While the compiled terminfo uses little-endian format irregardless of +# platform, SystemV screen dumps do not. They came later, and that detail was +# overlooked. +# +# AIX and HPUX use the SVr4 big-endian format +# Solaris uses the SVr3 formats (sparc and x86 differ endian-ness) +0 beshort 0433 SVr2 curses screen image, big-endian +0 beshort 0434 SVr3 curses screen image, big-endian +0 beshort 0435 SVr4 curses screen image, big-endian +# +0 leshort 0433 SVr2 curses screen image, little-endian +0 leshort 0434 SVr3 curses screen image, little-endian +0 leshort 0435 SVr4 curses screen image, little-endian +# +# Rather than SVr4, Solaris "xcurses" writes this header: +0 regex \^MAX=[0-9]+,[0-9]+$ +>1 regex \^BEG=[0-9]+,[0-9]+$ +>2 regex \^SCROLL=[0-9]+,[0-9]+$ +>3 regex \^VMIN=[0-9]+$ +>4 regex \^VTIME=[0-9]+$ +>5 regex \^FLAGS=0x[[:xdigit:]]+$ +>6 regex \^FG=[0-9],[0-9]+$ +>7 regex \^BG=[0-9]+,[0-9]+, Solaris xcurses screen image +# +# ncurses5 (and before) did not use a magic number, making screen dumps "data". +# ncurses6 (2015) uses this format, ignoring byte-order +0 string \210\210\210\210ncurses ncurses6 screen image +# +# PDCurses added this in 2005 +0 string PDC\001 PDCurses screen image diff --git contrib/file/magic/Magdir/vms contrib/file/magic/Magdir/vms index 493930394865..56d57ae93280 100644 --- contrib/file/magic/Magdir/vms +++ contrib/file/magic/Magdir/vms @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: vms,v 1.9 2014/08/17 13:47:59 christos Exp $ +# $File: vms,v 1.10 2017/03/17 21:35:28 christos Exp $ # vms: file(1) magic for VMS executables (experimental) # # VMS .exe formats, both VAX and AXP (Greg Roelofs, newt@uchicago.edu) @@ -25,6 +25,6 @@ # 00040 00 00 00 00 ff ff ff ff ff ff ff ff 02 00 00 00 ................ # # GRR this test is still too general as it catches example adressen.dbt -0 belong 0x03000000 +0 belong 0x03000000 >8 ubelong 0xec020000 VMS Alpha executable >>75264 string PK\003\004 \b, Info-ZIP SFX archive v5.12 w/decryption diff --git contrib/file/magic/Magdir/vmware contrib/file/magic/Magdir/vmware index b6b6a619b3ee..cd1a9d95765c 100644 --- contrib/file/magic/Magdir/vmware +++ contrib/file/magic/Magdir/vmware @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: vmware,v 1.7 2009/09/19 16:28:13 christos Exp $ +# $File: vmware,v 1.8 2017/03/17 21:35:28 christos Exp $ # VMware specific files (deducted from version 1.1 and log file entries) # Anthon van der Neut (anthon@mnt.org) -0 belong 0x4d52564e VMware nvram +0 belong 0x4d52564e VMware nvram diff --git contrib/file/magic/Magdir/vorbis contrib/file/magic/Magdir/vorbis index 3b5e51f5c8e8..5335ca8777c1 100644 --- contrib/file/magic/Magdir/vorbis +++ contrib/file/magic/Magdir/vorbis @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: vorbis,v 1.22 2015/03/28 15:14:55 christos Exp $ +# $File: vorbis,v 1.23 2017/03/17 21:35:28 christos Exp $ # vorbis: file(1) magic for Ogg/Vorbis files # # From Felix von Leitner <leitner@fefe.de> @@ -95,7 +95,7 @@ # in a different place, so we must use an indirect offset. >>>(84.b+85) string \x03vorbis >>>>(84.b+96) string/c Xiphophorus\ libVorbis\ I \b, created by: Xiphophorus libVorbis I ->>>>>(84.b+120) string >00000000 +>>>>>(84.b+120) string >00000000 # Map to beta version numbers: >>>>>>(84.b+120) string <20000508 (<beta1, prepublic) >>>>>>(84.b+120) string 20000508 (1.0 beta 1 or beta 2) @@ -117,7 +117,7 @@ >>>>>>(84.b+120) string >20011231 (pre-1.0 CVS) # For the 1.0 release, Xiphophorus is replaced by Xiph.Org >>>>(84.b+96) string/c Xiph.Org\ libVorbis\ I \b, created by: Xiph.Org libVorbis I ->>>>>(84.b+117) string >00000000 +>>>>>(84.b+117) string >00000000 >>>>>>(84.b+117) string <20020717 (pre-1.0 CVS) >>>>>>(84.b+117) string 20020717 (1.0) >>>>>>(84.b+117) string 20030909 (1.0.1) @@ -128,13 +128,13 @@ !:mime audio/ogg >>>36 ubyte >0x0F UNKNOWN VERSION %u, >>>36 ubyte &0x0F version 0.%d ->>>>46 ubyte >1 +>>>>46 ubyte >1 >>>>>46 ubyte !255 unknown channel mapping family %u, >>>>>37 ubyte x %u channels >>>>46 ubyte 0 >>>>>37 ubyte 1 mono >>>>>37 ubyte 2 stereo ->>>>46 ubyte 1 +>>>>46 ubyte 1 >>>>>37 ubyte 1 mono >>>>>37 ubyte 2 stereo >>>>>37 ubyte 3 linear surround diff --git contrib/file/magic/Magdir/webassembly contrib/file/magic/Magdir/webassembly new file mode 100644 index 000000000000..8a4ce1b1a599 --- /dev/null +++ contrib/file/magic/Magdir/webassembly @@ -0,0 +1,15 @@ +#------------------------------------------------------------------------------ +# $File: webassembly,v 1.2 2017/05/02 14:05:29 christos Exp $ +# webassembly: file(1) magic for WebAssembly modules +# +# WebAssembly is a virtual architecture developed by a W3C Community +# Group at http://webassembly.org/. The file extension is .wasm, and +# the MIME type is application/wasm. +# +# http://webassembly.org/docs/binary-encoding/ is the main +# document describing the binary format. +# From: Pip Cet <pipcet@gmail.com> and Joel Martin + +0 string \0asm WebAssembly (wasm) binary module +>4 lelong =1 version %#x (MVP) +>4 lelong >1 version %#x diff --git contrib/file/magic/Magdir/windows contrib/file/magic/Magdir/windows index faaa7e290028..169d4f8d0976 100644 --- contrib/file/magic/Magdir/windows +++ contrib/file/magic/Magdir/windows @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: windows,v 1.14 2015/12/15 01:06:17 christos Exp $ +# $File: windows,v 1.16 2017/03/17 22:20:22 christos Exp $ # windows: file(1) magic for Microsoft Windows # # This file is mainly reserved for files where programs @@ -29,7 +29,7 @@ # Created by: Andreas Schuster (http://computer.forensikblog.de/) # Reference (1): http://computer.forensikblog.de/en/2008/02/64bit_magic.html # Modified by (1): Abel Cheung (Avoid match with first 4 bytes only) -0 string PAGE +0 string PAGE >4 string DUMP MS Windows 32bit crash dump >>0x05c byte 0 \b, no PAE >>0x05c byte 1 \b, PAE @@ -66,13 +66,13 @@ # Summary: Old format help files # URL: https://en.wikipedia.org/wiki/WinHelp # Reference: http://www.oocities.org/mwinterhoff/helpfile.htm -# Update: Joerg Jenderek +# Update: Joerg Jenderek # Created by: Dirk Jagdmann <doj@cubic.org> # # check and then display version and date inside MS Windows HeLP file fragment 0 name help-ver-date # look for Magic of SYSTEMHEADER ->0 leshort 0x036C +>0 leshort 0x036C # version Major 1 for right file fragment >>4 leshort 1 Windows # print non empty string above to avoid error message @@ -93,7 +93,7 @@ >>>6 ldate x \b, %s # # Magic for HeLP files -0 lelong 0x00035f3f +0 lelong 0x00035f3f # ./windows (version 5.25) labeled the entry as "MS Windows 3.x help file" # file header magic 0x293B at DirectoryStart+9 >(4.l+9) uleshort 0x293B MS @@ -101,37 +101,37 @@ >>0xD4 string =\x62\x6D\x66\x01\x00 Windows help annotation !:mime application/x-winhelp !:ext ann ->>0xD4 string !\x62\x6D\x66\x01\x00 +>>0xD4 string !\x62\x6D\x66\x01\x00 # "GID Help index" by TrID >>>(4.l+0x65) string =|Pete Windows help Global Index !:mime application/x-winhelp !:ext gid # HeLP Bookmark or # "Windows HELP File" by TrID ->>>(4.l+0x65) string !|Pete +>>>(4.l+0x65) string !|Pete # maybe there exist a cleaner way to detect HeLP fragments # brute search for Magic 0x036C with matching Major maximal 7 iterations # discapp.hlp ->>>>16 search/0x49AF/s \x6c\x03 +>>>>16 search/0x49AF/s \x6c\x03 >>>>>&0 use help-ver-date ->>>>>&4 leshort !1 +>>>>>&4 leshort !1 # putty.hlp ->>>>>>&0 search/0x69AF/s \x6c\x03 +>>>>>>&0 search/0x69AF/s \x6c\x03 >>>>>>>&0 use help-ver-date ->>>>>>>&4 leshort !1 ->>>>>>>>&0 search/0x49AF/s \x6c\x03 +>>>>>>>&4 leshort !1 +>>>>>>>>&0 search/0x49AF/s \x6c\x03 >>>>>>>>>&0 use help-ver-date ->>>>>>>>>&4 leshort !1 ->>>>>>>>>>&0 search/0x49AF/s \x6c\x03 +>>>>>>>>>&4 leshort !1 +>>>>>>>>>>&0 search/0x49AF/s \x6c\x03 >>>>>>>>>>>&0 use help-ver-date ->>>>>>>>>>>&4 leshort !1 ->>>>>>>>>>>>&0 search/0x49AF/s \x6c\x03 +>>>>>>>>>>>&4 leshort !1 +>>>>>>>>>>>>&0 search/0x49AF/s \x6c\x03 >>>>>>>>>>>>>&0 use help-ver-date ->>>>>>>>>>>>>&4 leshort !1 ->>>>>>>>>>>>>>&0 search/0x49AF/s \x6c\x03 +>>>>>>>>>>>>>&4 leshort !1 +>>>>>>>>>>>>>>&0 search/0x49AF/s \x6c\x03 >>>>>>>>>>>>>>>&0 use help-ver-date ->>>>>>>>>>>>>>>&4 leshort !1 ->>>>>>>>>>>>>>>>&0 search/0x49AF/s \x6c\x03 +>>>>>>>>>>>>>>>&4 leshort !1 +>>>>>>>>>>>>>>>>&0 search/0x49AF/s \x6c\x03 # GCC.HLP is detected after 7 iterations >>>>>>>>>>>>>>>>>&0 use help-ver-date # this only happens if bigger hlp file is detected after used search iterations @@ -139,7 +139,7 @@ !:mime application/winhelp !:ext hlp # repeat search again or following default line does not work ->>>>16 search/0x49AF/s \x6c\x03 +>>>>16 search/0x49AF/s \x6c\x03 # remaining files should be HeLP Bookmark WinHlp32.BMK (XP 32-bit) or WinHlp32 (Windows 8.1 64-bit) >>>>16 default x Windows help Bookmark !:mime application/x-winhelp @@ -180,21 +180,21 @@ #>>(4.l+47) ubequad x \b, PageStart 0x%16.16llx # start with colon or semicolon for comment line like Back2Life.cnt -0 regex \^(:|;) +0 regex \^(:|;) # look for first keyword Base ->0 search/45 :Base +>0 search/45 :Base >>&0 use cnt-name # only solution to search again from beginning , because relative offsets changes when use is called ->0 search/45 :Base ->0 default x +>0 search/45 :Base +>0 default x # look for other keyword Title like in putty.cnt ->>0 search/45 :Title +>>0 search/45 :Title >>>&0 use cnt-name # # display mime type and name of Windows help Content source 0 name cnt-name # skip space at beginning ->0 string \ +>0 string \040 # name without extension and greater character or name with hlp extension >>1 regex/c \^([^\xd>]*|.*\.hlp) MS Windows help file Content, based "%s" !:mime text/plain @@ -210,10 +210,10 @@ # Summary: Hyper terminal # Extension: .ht # Created by: unknown -0 string HyperTerminal\ +0 string HyperTerminal\040 >15 string 1.0\ --\ HyperTerminal\ data\ file MS Windows HyperTerminal profile -# http://ithreats.files.wordpress.com/2009/05/\ +# http://ithreats.files.wordpress.com/2009/05/\040 # lnk_the_windows_shortcut_file_format.pdf # Summary: Windows shortcut # Extension: .lnk @@ -293,7 +293,7 @@ # Extension: .reg # Submitted by: Abel Cheung <abelcheung@gmail.com> 0 string REGEDIT4\r\n\r\n Windows Registry text (Win95 or above) -0 string Windows\ Registry\ Editor\ +0 string Windows\ Registry\ Editor\040 >&0 string Version\ 5.00\r\n\r\n Windows Registry text (Win2K or above) # Windows *.INF *.INI files updated by Joerg Jenderek at Apr 2013 @@ -301,10 +301,10 @@ # PR/383: remove unicode BOM because it is not portable across regex impls 0 regex/s \\`(\\r\\n|;|[[]) # left bracket in section line ->&0 search/8192 [ +>&0 search/8192 [ # http://en.wikipedia.org/wiki/Autorun.inf # http://msdn.microsoft.com/en-us/library/windows/desktop/cc144200.aspx ->>&0 regex/c \^(autorun)]\r\n +>>&0 regex/c \^(autorun)]\r\n >>>&0 ubyte =0x5b INItialization configuration !:mime application/x-wine-extension-ini # From: Pal Tamas <folti@balabit.hu> @@ -343,31 +343,31 @@ # http://en.wikipedia.org/wiki/NTLDR Windows Boot Loader information >>&0 regex/c \^(boot\x20loader)] Windows boot.ini !:mime application/x-wine-extension-ini ->>>&0 ubyte x +>>>&0 ubyte x # http://en.wikipedia.org/wiki/CONFIG.SYS >>&0 regex/c \^(menu)]\r\n MS-DOS CONFIG.SYS # http://support.microsoft.com/kb/118579/ >>&0 regex/c \^(Paths)]\r\n MS-DOS MSDOS.SYS # VERS string unicoded case-independent ->>&0 ubequad&0xFFdfFFdfFFdfFFdf 0x0056004500520053 +>>&0 ubequad&0xFFdfFFdfFFdfFFdf 0x0056004500520053 # ION] string unicoded case-independent ->>>&0 ubequad&0xFFdfFFdfFFdfFFff 0x0049004f004e005d Windows setup INFormation +>>>&0 ubequad&0xFFdfFFdfFFdfFFff 0x0049004f004e005d Windows setup INFormation !:mime application/x-setupscript # STRI string unicoded case-independent ->>&0 ubequad&0xFFdfFFdfFFdfFFdf 0x0053005400520049 +>>&0 ubequad&0xFFdfFFdfFFdfFFdf 0x0053005400520049 # NGS] string unicoded case-independent ->>>&0 ubequad&0xFFdfFFdfFFdfFFff 0x004e00470053005D Windows setup INFormation +>>>&0 ubequad&0xFFdfFFdfFFdfFFff 0x004e00470053005D Windows setup INFormation !:mime application/x-setupscript # unknown keyword after opening bracket ->>&0 default x ->>>&0 search/8192 [ +>>&0 default x +>>>&0 search/8192 [ # version Strings FileIdentification ->>>>&0 string/c version Windows setup INFormation +>>>>&0 string/c version Windows setup INFormation !:mime application/x-setupscript # VERS string unicoded case-independent ->>>>&0 ubequad&0xFFdfFFdfFFdfFFdf 0x0056004500520053 +>>>>&0 ubequad&0xFFdfFFdfFFdfFFdf 0x0056004500520053 # ION] string unicoded case-independent ->>>>>&0 ubequad&0xFFdfFFdfFFdfFFff 0x0049004f004e005d Windows setup INFormation +>>>>>&0 ubequad&0xFFdfFFdfFFdfFFff 0x0049004f004e005d Windows setup INFormation !:mime application/x-setupscript # http://en.wikipedia.org/wiki/Initialization_file Windows Initialization File or other #>>>>&0 default x Generic INItialization configuration @@ -376,21 +376,21 @@ # Windows Precompiled INF files *.PNF added by Joerg Jenderek at Mar 2013 of _PNF_HEADER inf.h # http://read.pudn.com/downloads3/sourcecode/windows/248345/win2k/private/windows/setup/setupapi/inf.h__.htm # GRR: line below too general as it catches also PDP-11 UNIX/RT ldp -0 leshort&0xFeFe 0x0000 +0 leshort&0xFeFe 0x0000 !:strength -5 # test for unused null bits in PNF_FLAGs ->4 ulelong&0xFCffFe00 0x00000000 +>4 ulelong&0xFCffFe00 0x00000000 # only found 58h for Offset of WinDirPath immediately after _PNF_HEADER structure ->>68 ulelong >0x57 +>>68 ulelong >0x57 # test for zero high byte of InfValueBlockSize, followed by WinDirPath like # C:\WINDOWS (ASCII 0x433a5c.. , unicode 0x43003a005c..) or X:\MININT >>>(68.l-1) ubelong&0xffE0C519 =0x00400018 Windows Precompiled iNF !:mime application/x-pnf # currently only found Major Version=1 and Minor Version=1 -#>>>>0 uleshort =0x0101 +#>>>>0 uleshort =0x0101 #>>>>>1 ubyte x \b, version %u #>>>>>0 ubyte x \b.%u ->>>>0 uleshort !0x0101 +>>>>0 uleshort !0x0101 >>>>>1 ubyte x \b, version %u >>>>>0 ubyte x \b.%u # 1 ,2 (windows 98 SE) @@ -416,10 +416,10 @@ #>>>>16 ulelong x \b, InfVersionDataSize 0x%x # only found positive values lower 0x00ffFFff for InfVersionDataOffset >>>>20 ulelong x \b, at 0x%x ->>>>4 ulelong&0x00000001 =0x00000001 -# case independent: CatalogFile Class DriverVer layoutfile LayoutFile SetupClass signature Signature +>>>>4 ulelong&0x00000001 =0x00000001 +# case independent: CatalogFile Class DriverVer layoutfile LayoutFile SetupClass signature Signature >>>>>(20.l) lestring16 x "%s" ->>>>4 ulelong&0x00000001 !0x00000001 +>>>>4 ulelong&0x00000001 !0x00000001 >>>>>(20.l) string x "%s" # FILETIME is number of 100-nanosecond intervals since 1 January 1601 #>>>>24 ulequad x \b, InfVersionLastWriteTime %16.16llx @@ -435,23 +435,23 @@ #>>>>64 ulelong x \b, InfValueBlockSize 0x%x # WinDirPathOffset #>>>>68 ulelong x \b, at 0x%x ->>>>68 ulelong >0x57 ->>>>>4 ulelong&0x00000001 =0x00000001 ->>>>>>(68.l) ubequad =0x43003a005c005700 +>>>>68 ulelong >0x57 +>>>>>4 ulelong&0x00000001 =0x00000001 +>>>>>>(68.l) ubequad =0x43003a005c005700 # normally unicoded C:\Windows #>>>>>>>(68.l) lestring16 x \b, WinDirPath "%s" ->>>>>>(68.l) ubequad !0x43003a005c005700 +>>>>>>(68.l) ubequad !0x43003a005c005700 >>>>>>>(68.l) lestring16 x \b, WinDirPath "%s" ->>>>>4 ulelong&0x00000001 !0x00000001 +>>>>>4 ulelong&0x00000001 !0x00000001 # normally ASCII C:\WINDOWS #>>>>>>(68.l) string =C:\\WINDOWS \b, WinDirPath "%s" >>>>>>(68.l) string !C:\\WINDOWS \b, WinDirPath "%s" -# found OsLoaderPathOffset values often 0 , once 70h corelist.PNF, once 68h ASCII machine.PNF +# found OsLoaderPathOffset values often 0 , once 70h corelist.PNF, once 68h ASCII machine.PNF #>>>>72 ulelong >0 \b, at 0x%x >>>>72 ulelong >0 \b, ->>>>>4 ulelong&0x00000001 =0x00000001 +>>>>>4 ulelong&0x00000001 =0x00000001 >>>>>>(72.l) lestring16 x OsLoaderPath "%s" ->>>>>4 ulelong&0x00000001 !0x00000001 +>>>>>4 ulelong&0x00000001 !0x00000001 # seldom C:\ instead empty >>>>>>(72.l) string x OsLoaderPath "%s" # 1fdh @@ -462,16 +462,16 @@ # InfSourcePathOffset often 0 #>>>>80 ulelong >0 \b, at 0x%x >>>>80 ulelong >0 \b, ->>>>>4 ulelong&0x00000001 =0x00000001 +>>>>>4 ulelong&0x00000001 =0x00000001 >>>>>>(80.l) lestring16 x SourcePath "%s" ->>>>>4 ulelong&0x00000001 !0x00000001 +>>>>>4 ulelong&0x00000001 !0x00000001 >>>>>>(80.l) string >\0 SourcePath "%s" # OriginalInfNameOffset often 0 #>>>>84 ulelong >0 \b, at 0x%x >>>>84 ulelong >0 \b, ->>>>>4 ulelong&0x00000001 =0x00000001 +>>>>>4 ulelong&0x00000001 =0x00000001 >>>>>>(84.l) lestring16 x InfName "%s" ->>>>>4 ulelong&0x00000001 !0x00000001 +>>>>>4 ulelong&0x00000001 !0x00000001 >>>>>>(84.l) string >\0 InfName "%s" # Summary: backup file created with utility like NTBACKUP.EXE shipped with Windows NT/2K/XP/2003 @@ -480,13 +480,13 @@ # URL: http://en.wikipedia.org/wiki/NTBackup # Reference: http://laytongraphics.com/mtf/MTF_100a.PDF # Descriptor BloCK name of Microsoft Tape Format -0 string TAPE +0 string TAPE # Format Logical Address is zero ->20 ulequad 0 +>20 ulequad 0 # Reserved for MBC is zero ->>28 uleshort 0 +>>28 uleshort 0 # Control Block ID is zero ->>>36 ulelong 0 +>>>36 ulelong 0 # BIT4-BIT15, BIT18-BIT31 of block attributes are unused >>>>4 ulelong&0xFFfcFFe0 0 Windows NTbackup archive #!:mime application/x-ntbackup @@ -508,7 +508,7 @@ >>>>>4 ulelong&0x00000004 !0 \b, compressed # MTF_EOS_AT_EOM End Of Medium was hit during end of set processing >>>>>4 ulelong&0x00000008 !0 \b, End Of Medium hit ->>>>>4 ulelong&0x00020000 0 +>>>>>4 ulelong&0x00020000 0 # MTF_SET_MAP_EXISTS A Media Based Catalog Set Map may exist on tape >>>>>>4 ulelong&0x00010000 !0 \b, with catalog # MTF_FDD_ALLOWED However File/Directory Detail can only exist if a Set Map is also present @@ -531,37 +531,37 @@ # Media Based Catalog Type (1,2) #>>>>>66 uleshort x \b, catalog type %4.4x # size of Media Name (66,68,6Eh) ->>>>>68 uleshort >0 +>>>>>68 uleshort >0 # offset of Media Name (5Eh) ->>>>>>70 uleshort >0 +>>>>>>70 uleshort >0 # 0~, 1~ANSI, 2~UNICODE ->>>>>>>48 ubyte 1 +>>>>>>>48 ubyte 1 # size terminated ansi coded string normally followed by "MTF Media Label" >>>>>>>>(70.s) string >\0 \b, name: %s ->>>>>>>48 ubyte 2 +>>>>>>>48 ubyte 2 # Not null, but size terminated unicoded string >>>>>>>>(70.s) lestring16 x \b, name: %s # size of Media Label (104h) ->>>>>72 uleshort >0 +>>>>>72 uleshort >0 # offset of Media Label (C4h,C6h,CCh) ->>>>>74 uleshort >0 ->>>>>>48 ubyte 1 +>>>>>74 uleshort >0 +>>>>>>48 ubyte 1 #Tag|Version|Vendor|Vendor ID|Creation Time Stamp|Cartridge Label|Side|Media ID|Media Domain ID|Vendor Specific fields >>>>>>>(74.s) string >\0 \b, label: %s ->>>>>>48 ubyte 2 +>>>>>>48 ubyte 2 >>>>>>>(74.s) lestring16 x \b, label: %s # size of password name (0,1Ch) #>>>>>76 uleshort >0 \b, password size %4.4x # Software Vendor ID (CBEh) >>>>>86 uleshort x \b, software (0x%x) # size of Software Name (6Eh) ->>>>>80 uleshort >0 +>>>>>80 uleshort >0 # offset of Software Name (1C8h,1CAh,1D0h) ->>>>>>82 uleshort >0 +>>>>>>82 uleshort >0 # 1~ANSI, 2~UNICODE ->>>>>>>48 ubyte 1 +>>>>>>>48 ubyte 1 >>>>>>>>(82.s) string >\0 \b: %s ->>>>>>>48 ubyte 2 +>>>>>>>48 ubyte 2 # size terminated unicoded coded string normally followed by "SPAD" >>>>>>>>(82.s) lestring16 x \b: %s # Format Logical Block Size (512,1024) diff --git contrib/file/magic/Magdir/xenix contrib/file/magic/Magdir/xenix index 89de6033268c..fb83faa876ed 100644 --- contrib/file/magic/Magdir/xenix +++ contrib/file/magic/Magdir/xenix @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: xenix,v 1.10 2016/04/19 18:14:19 christos Exp $ +# $File: xenix,v 1.11 2017/03/17 21:35:28 christos Exp $ # xenix: file(1) magic for Microsoft Xenix # # "Middle model" stuff, and "Xenix 8086 relocatable or 80286 small @@ -16,14 +16,14 @@ # Reference: http://www.azillionmonkeys.com/qed/Omfg.pdf # Update: Joerg Jenderek # recordtype~TranslatorHEADerRecord -0 byte 0x80 +0 byte 0x80 # GRR: line above is too general as it catches also Extensible storage engine DataBase # skip examples like GENA.SND Switch.Snd by looking for record length maximal 1024-3 ->1 uleshort <1022 +>1 uleshort <1022 # skip examples like GAME.PICTURE Strange.Pic by looking for positiv record length ->>1 uleshort >0 +>>1 uleshort >0 # skip examples like Xtable.Data FRACTAL.GEN SHR.VIEW by looking for positiv string length ->>>3 ubyte >0 +>>>3 ubyte >0 # skip examples like OMBRE.6 with "UUUUUU" by looking for filename like "hello.c" >>>>4 regex [a-zA-Z_/]{1,8}[.] 8086 relocatable (Microsoft) #!:mime application/octet-stream @@ -54,8 +54,8 @@ >0x1c byte &0x9 286 >0x1c byte &0xa 386 >0x1f byte <0x040 small model ->0x1f byte =0x048 large model ->0x1f byte =0x049 huge model +>0x1f byte =0x048 large model +>0x1f byte =0x049 huge model >0x1e leshort &0x1 executable >0x1e leshort ^0x1 object file >0x1e leshort &0x40 Large Text diff --git contrib/file/magic/Magdir/xilinx contrib/file/magic/Magdir/xilinx index 91e84d91d0ee..a5219778d390 100644 --- contrib/file/magic/Magdir/xilinx +++ contrib/file/magic/Magdir/xilinx @@ -1,12 +1,12 @@ #------------------------------------------------------------------------------ -# $File: xilinx,v 1.7 2014/04/30 21:41:02 christos Exp $ +# $File: xilinx,v 1.8 2017/03/17 21:35:28 christos Exp $ # This is Aaron's attempt at a MAGIC file for Xilinx .bit files. # Xilinx-Magic@RevRagnarok.com # Got the info from FPGA-FAQ 0026 # -# Rewritten to use pstring/H instead of hardcoded lengths by O. Freyermuth, -# fixes at least reading of bitfiles from Spartan 2, 3, 6. +# Rewritten to use pstring/H instead of hardcoded lengths by O. Freyermuth, +# fixes at least reading of bitfiles from Spartan 2, 3, 6. # http://www.fpga-faq.com/FAQ_Pages/0026_Tell_me_about_bit_files.htm # # First there is the sync header and its length @@ -20,7 +20,7 @@ >>>>&0 pstring/H x - from %s # And then 'b' >>>>>&1 string b -# Then the model / part number: +# Then the model / part number: >>>>>>&0 pstring/H x - for %s # Then 'c' >>>>>>>&1 string c @@ -36,5 +36,5 @@ >>>>>>>>>>>>&0 belong x - data length 0x%x # Raw bitstream files -0 long 0xffffffff +0 long 0xffffffff >&0 belong 0xaa995566 Xilinx RAW bitstream (.BIN) diff --git contrib/file/magic/Magdir/xwindows contrib/file/magic/Magdir/xwindows index eb208927f01e..85f64c8c36a4 100644 --- contrib/file/magic/Magdir/xwindows +++ contrib/file/magic/Magdir/xwindows @@ -1,9 +1,9 @@ #------------------------------------------------------------------------------ -# $File: xwindows,v 1.9 2014/04/30 21:41:02 christos Exp $ +# $File: xwindows,v 1.10 2017/03/17 21:35:28 christos Exp $ # xwindows: file(1) magic for various X/Window system file formats. -# Compiled X Keymap +# Compiled X Keymap # XKM (compiled X keymap) files (including version and byte ordering) 1 string mkx Compiled XKB Keymap: lsb, >0 byte >0 version %d diff --git contrib/file/magic/Magdir/yara contrib/file/magic/Magdir/yara new file mode 100644 index 000000000000..523a2d05f410 --- /dev/null +++ contrib/file/magic/Magdir/yara @@ -0,0 +1,17 @@ + + +#------------------------------------------------------------------------------ +# $File: yara,v 1.2 2017/05/25 20:07:23 christos Exp $ +# yara: file(1) magic for http://virustotal.github.io/yara/ +# + +0 string YARA +>4 lelong >2047 +>8 byte <20 YARA 3.x compiled rule set +# version +>>8 clear x +>>8 byte 6 created with version 3.3.0 +>>8 byte 8 created with version 3.4.0 +>>8 byte 11 created with version 3.5.0 +>>8 default x +>>>8 byte x development version 0x%02x diff --git contrib/file/magic/Makefile.am contrib/file/magic/Makefile.am index 19701ecd179b..5259a478368d 100644 --- contrib/file/magic/Makefile.am +++ contrib/file/magic/Makefile.am @@ -1,5 +1,5 @@ # -# $File: Makefile.am,v 1.120 2016/10/17 19:52:29 christos Exp $ +# $File: Makefile.am,v 1.126 2017/08/10 11:01:38 christos Exp $ # MAGIC_FRAGMENT_BASE = Magdir MAGIC_DIR = $(top_srcdir)/magic @@ -21,6 +21,7 @@ $(MAGIC_FRAGMENT_DIR)/amigaos \ $(MAGIC_FRAGMENT_DIR)/android \ $(MAGIC_FRAGMENT_DIR)/animation \ $(MAGIC_FRAGMENT_DIR)/aout \ +$(MAGIC_FRAGMENT_DIR)/apache \ $(MAGIC_FRAGMENT_DIR)/apl \ $(MAGIC_FRAGMENT_DIR)/apple \ $(MAGIC_FRAGMENT_DIR)/application \ @@ -34,6 +35,7 @@ $(MAGIC_FRAGMENT_DIR)/audio \ $(MAGIC_FRAGMENT_DIR)/basis \ $(MAGIC_FRAGMENT_DIR)/ber \ $(MAGIC_FRAGMENT_DIR)/bflt \ +$(MAGIC_FRAGMENT_DIR)/bhl \ $(MAGIC_FRAGMENT_DIR)/bioinformatics \ $(MAGIC_FRAGMENT_DIR)/blackberry \ $(MAGIC_FRAGMENT_DIR)/blcr \ @@ -97,6 +99,7 @@ $(MAGIC_FRAGMENT_DIR)/fsav \ $(MAGIC_FRAGMENT_DIR)/fusecompress \ $(MAGIC_FRAGMENT_DIR)/games \ $(MAGIC_FRAGMENT_DIR)/gcc \ +$(MAGIC_FRAGMENT_DIR)/gconv \ $(MAGIC_FRAGMENT_DIR)/geo \ $(MAGIC_FRAGMENT_DIR)/geos \ $(MAGIC_FRAGMENT_DIR)/gimp \ @@ -104,6 +107,7 @@ $(MAGIC_FRAGMENT_DIR)/gnome \ $(MAGIC_FRAGMENT_DIR)/gnu \ $(MAGIC_FRAGMENT_DIR)/gnumeric \ $(MAGIC_FRAGMENT_DIR)/gpt \ +$(MAGIC_FRAGMENT_DIR)/gpu \ $(MAGIC_FRAGMENT_DIR)/grace \ $(MAGIC_FRAGMENT_DIR)/graphviz \ $(MAGIC_FRAGMENT_DIR)/gringotts \ @@ -275,6 +279,7 @@ $(MAGIC_FRAGMENT_DIR)/vorbis \ $(MAGIC_FRAGMENT_DIR)/vxl \ $(MAGIC_FRAGMENT_DIR)/warc \ $(MAGIC_FRAGMENT_DIR)/weak \ +$(MAGIC_FRAGMENT_DIR)/webassembly \ $(MAGIC_FRAGMENT_DIR)/windows \ $(MAGIC_FRAGMENT_DIR)/wireless \ $(MAGIC_FRAGMENT_DIR)/wordprocessors \ @@ -285,6 +290,7 @@ $(MAGIC_FRAGMENT_DIR)/xenix \ $(MAGIC_FRAGMENT_DIR)/xilinx \ $(MAGIC_FRAGMENT_DIR)/xo65 \ $(MAGIC_FRAGMENT_DIR)/xwindows \ +$(MAGIC_FRAGMENT_DIR)/yara \ $(MAGIC_FRAGMENT_DIR)/zfs \ $(MAGIC_FRAGMENT_DIR)/zilog \ $(MAGIC_FRAGMENT_DIR)/zyxel diff --git contrib/file/magic/Makefile.in contrib/file/magic/Makefile.in index 0de849d603bd..3555f9e6b332 100644 --- contrib/file/magic/Makefile.in +++ contrib/file/magic/Makefile.in @@ -273,7 +273,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # -# $File: Makefile.am,v 1.120 2016/10/17 19:52:29 christos Exp $ +# $File: Makefile.am,v 1.126 2017/08/10 11:01:38 christos Exp $ # MAGIC_FRAGMENT_BASE = Magdir MAGIC_DIR = $(top_srcdir)/magic @@ -293,6 +293,7 @@ $(MAGIC_FRAGMENT_DIR)/amigaos \ $(MAGIC_FRAGMENT_DIR)/android \ $(MAGIC_FRAGMENT_DIR)/animation \ $(MAGIC_FRAGMENT_DIR)/aout \ +$(MAGIC_FRAGMENT_DIR)/apache \ $(MAGIC_FRAGMENT_DIR)/apl \ $(MAGIC_FRAGMENT_DIR)/apple \ $(MAGIC_FRAGMENT_DIR)/application \ @@ -306,6 +307,7 @@ $(MAGIC_FRAGMENT_DIR)/audio \ $(MAGIC_FRAGMENT_DIR)/basis \ $(MAGIC_FRAGMENT_DIR)/ber \ $(MAGIC_FRAGMENT_DIR)/bflt \ +$(MAGIC_FRAGMENT_DIR)/bhl \ $(MAGIC_FRAGMENT_DIR)/bioinformatics \ $(MAGIC_FRAGMENT_DIR)/blackberry \ $(MAGIC_FRAGMENT_DIR)/blcr \ @@ -369,6 +371,7 @@ $(MAGIC_FRAGMENT_DIR)/fsav \ $(MAGIC_FRAGMENT_DIR)/fusecompress \ $(MAGIC_FRAGMENT_DIR)/games \ $(MAGIC_FRAGMENT_DIR)/gcc \ +$(MAGIC_FRAGMENT_DIR)/gconv \ $(MAGIC_FRAGMENT_DIR)/geo \ $(MAGIC_FRAGMENT_DIR)/geos \ $(MAGIC_FRAGMENT_DIR)/gimp \ @@ -376,6 +379,7 @@ $(MAGIC_FRAGMENT_DIR)/gnome \ $(MAGIC_FRAGMENT_DIR)/gnu \ $(MAGIC_FRAGMENT_DIR)/gnumeric \ $(MAGIC_FRAGMENT_DIR)/gpt \ +$(MAGIC_FRAGMENT_DIR)/gpu \ $(MAGIC_FRAGMENT_DIR)/grace \ $(MAGIC_FRAGMENT_DIR)/graphviz \ $(MAGIC_FRAGMENT_DIR)/gringotts \ @@ -547,6 +551,7 @@ $(MAGIC_FRAGMENT_DIR)/vorbis \ $(MAGIC_FRAGMENT_DIR)/vxl \ $(MAGIC_FRAGMENT_DIR)/warc \ $(MAGIC_FRAGMENT_DIR)/weak \ +$(MAGIC_FRAGMENT_DIR)/webassembly \ $(MAGIC_FRAGMENT_DIR)/windows \ $(MAGIC_FRAGMENT_DIR)/wireless \ $(MAGIC_FRAGMENT_DIR)/wordprocessors \ @@ -557,6 +562,7 @@ $(MAGIC_FRAGMENT_DIR)/xenix \ $(MAGIC_FRAGMENT_DIR)/xilinx \ $(MAGIC_FRAGMENT_DIR)/xo65 \ $(MAGIC_FRAGMENT_DIR)/xwindows \ +$(MAGIC_FRAGMENT_DIR)/yara \ $(MAGIC_FRAGMENT_DIR)/zfs \ $(MAGIC_FRAGMENT_DIR)/zilog \ $(MAGIC_FRAGMENT_DIR)/zyxel diff --git contrib/file/python/magic.py contrib/file/python/magic.py index b0f7a1765e8f..662569e889d0 100644 --- contrib/file/python/magic.py +++ contrib/file/python/magic.py @@ -117,30 +117,43 @@ class Magic(object): """ _close(self._magic_t) + @staticmethod + def __tostr(s): + if s is None: + return None + if isinstance(s, str): + return s + try: # keep Python 2 compatibility + return str(s, 'utf-8') + except TypeError: + return str(s) + + @staticmethod + def __tobytes(b): + if b is None: + return None + if isinstance(b, bytes): + return b + try: # keep Python 2 compatibility + return bytes(b, 'utf-8') + except TypeError: + return bytes(b) + def file(self, filename): """ Returns a textual description of the contents of the argument passed as a filename or None if an error occurred and the MAGIC_ERROR flag - is set. A call to errno() will return the numeric error code. + is set. A call to errno() will return the numeric error code. """ - if isinstance(filename, bytes): - bi = filename - else: - try: # keep Python 2 compatibility - bi = bytes(filename, 'utf-8') - except TypeError: - bi = bytes(filename) - r = _file(self._magic_t, bi) - if isinstance(r, str): - return r - else: - return str(r, 'utf-8') + return Magic.__tostr(_file(self._magic_t, Magic.__tobytes(filename))) def descriptor(self, fd): """ - Like the file method, but the argument is a file descriptor. + Returns a textual description of the contents of the argument passed + as a file descriptor or None if an error occurred and the MAGIC_ERROR + flag is set. A call to errno() will return the numeric error code. """ - return _descriptor(self._magic_t, fd) + return Magic.__tostr(_descriptor(self._magic_t, fd)) def buffer(self, buf): """ @@ -148,22 +161,14 @@ class Magic(object): as a buffer or None if an error occurred and the MAGIC_ERROR flag is set. A call to errno() will return the numeric error code. """ - r = _buffer(self._magic_t, buf, len(buf)) - if isinstance(r, str): - return r - else: - return str(r, 'utf-8') + return Magic.__tostr(_buffer(self._magic_t, buf, len(buf))) def error(self): """ Returns a textual explanation of the last error or None if there was no error. """ - e = _error(self._magic_t) - if isinstance(e, str): - return e - else: - return str(e, 'utf-8') + return Magic.__tostr(_error(self._magic_t)) def setflags(self, flags): """ @@ -184,35 +189,38 @@ class Magic(object): Returns 0 on success and -1 on failure. """ - return _load(self._magic_t, filename) + return _load(self._magic_t, Magic.__tobytes(filename)) def compile(self, dbs): """ Compile entries in the colon separated list of database files passed as argument or the default database file if no argument. - Returns 0 on success and -1 on failure. The compiled files created are named from the basename(1) of each file argument with ".mgc" appended to it. + + Returns 0 on success and -1 on failure. """ - return _compile(self._magic_t, dbs) + return _compile(self._magic_t, Magic.__tobytes(dbs)) def check(self, dbs): """ Check the validity of entries in the colon separated list of database files passed as argument or the default database file if no argument. + Returns 0 on success and -1 on failure. """ - return _check(self._magic_t, dbs) + return _check(self._magic_t, Magic.__tobytes(dbs)) def list(self, dbs): """ Check the validity of entries in the colon separated list of database files passed as argument or the default database file if no argument. + Returns 0 on success and -1 on failure. """ - return _list(self._magic_t, dbs) + return _list(self._magic_t, Magic.__tobytes(dbs)) def errno(self): """ diff --git contrib/file/src/apprentice.c contrib/file/src/apprentice.c index f2622c081284..a7b4dd8f9115 100644 --- contrib/file/src/apprentice.c +++ contrib/file/src/apprentice.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: apprentice.c,v 1.255 2016/10/24 18:02:17 christos Exp $") +FILE_RCSID("@(#)$File: apprentice.c,v 1.262 2017/08/28 13:39:18 christos Exp $") #endif /* lint */ #include "magic.h" @@ -549,8 +549,10 @@ apprentice_unmap(struct magic_map *map) break; case MAP_TYPE_MALLOC: for (i = 0; i < MAGIC_SETS; i++) { - if ((char *)map->magic[i] >= (char *)map->p && - (char *)map->magic[i] <= (char *)map->p + map->len) + void *b = map->magic[i]; + void *p = map->p; + if (CAST(char *, b) >= CAST(char *, p) && + CAST(char *, b) <= CAST(char *, p) + map->len) continue; free(map->magic[i]); } @@ -610,8 +612,7 @@ buffer_apprentice(struct magic_set *ms, struct magic **bufs, if (nbufs == 0) return -1; - if (ms->mlist[0] != NULL) - file_reset(ms); + (void)file_reset(ms, 0); init_file_tables(); @@ -654,8 +655,7 @@ file_apprentice(struct magic_set *ms, const char *fn, int action) int file_err, errs = -1; size_t i; - if (ms->mlist[0] != NULL) - file_reset(ms); + (void)file_reset(ms, 0); if ((fn = magic_getpath(fn, action)) == NULL) return -1; @@ -777,6 +777,59 @@ nonmagic(const char *str) return rv == 0 ? 1 : rv; /* Return at least 1 */ } + +private size_t +typesize(int type) +{ + switch (type) { + case FILE_BYTE: + return 1; + + case FILE_SHORT: + case FILE_LESHORT: + case FILE_BESHORT: + return 2; + + case FILE_LONG: + case FILE_LELONG: + case FILE_BELONG: + case FILE_MELONG: + return 4; + + case FILE_DATE: + case FILE_LEDATE: + case FILE_BEDATE: + case FILE_MEDATE: + case FILE_LDATE: + case FILE_LELDATE: + case FILE_BELDATE: + case FILE_MELDATE: + case FILE_FLOAT: + case FILE_BEFLOAT: + case FILE_LEFLOAT: + return 4; + + case FILE_QUAD: + case FILE_BEQUAD: + case FILE_LEQUAD: + case FILE_QDATE: + case FILE_LEQDATE: + case FILE_BEQDATE: + case FILE_QLDATE: + case FILE_LEQLDATE: + case FILE_BEQLDATE: + case FILE_QWDATE: + case FILE_LEQWDATE: + case FILE_BEQWDATE: + case FILE_DOUBLE: + case FILE_BEDOUBLE: + case FILE_LEDOUBLE: + return 8; + default: + return (size_t)~0; + } +} + /* * Get weight of this magic entry, for sorting purposes. */ @@ -784,7 +837,7 @@ private size_t apprentice_magic_strength(const struct magic *m) { #define MULT 10 - size_t v, val = 2 * MULT; /* baseline strength */ + size_t ts, v, val = 2 * MULT; /* baseline strength */ switch (m->type) { case FILE_DEFAULT: /* make sure this sorts last */ @@ -793,41 +846,13 @@ apprentice_magic_strength(const struct magic *m) return 0; case FILE_BYTE: - val += 1 * MULT; - break; - case FILE_SHORT: case FILE_LESHORT: case FILE_BESHORT: - val += 2 * MULT; - break; - case FILE_LONG: case FILE_LELONG: case FILE_BELONG: case FILE_MELONG: - val += 4 * MULT; - break; - - case FILE_PSTRING: - case FILE_STRING: - val += m->vallen * MULT; - break; - - case FILE_BESTRING16: - case FILE_LESTRING16: - val += m->vallen * MULT / 2; - break; - - case FILE_SEARCH: - val += m->vallen * MAX(MULT / m->vallen, 1); - break; - - case FILE_REGEX: - v = nonmagic(m->value.s); - val += v * MAX(MULT / v, 1); - break; - case FILE_DATE: case FILE_LEDATE: case FILE_BEDATE: @@ -839,9 +864,6 @@ apprentice_magic_strength(const struct magic *m) case FILE_FLOAT: case FILE_BEFLOAT: case FILE_LEFLOAT: - val += 4 * MULT; - break; - case FILE_QUAD: case FILE_BEQUAD: case FILE_LEQUAD: @@ -857,7 +879,29 @@ apprentice_magic_strength(const struct magic *m) case FILE_DOUBLE: case FILE_BEDOUBLE: case FILE_LEDOUBLE: - val += 8 * MULT; + ts = typesize(m->type); + if (ts == (size_t)~0) + abort(); + val += ts * MULT; + break; + + case FILE_PSTRING: + case FILE_STRING: + val += m->vallen * MULT; + break; + + case FILE_BESTRING16: + case FILE_LESTRING16: + val += m->vallen * MULT / 2; + break; + + case FILE_SEARCH: + val += m->vallen * MAX(MULT / m->vallen, 1); + break; + + case FILE_REGEX: + v = nonmagic(m->value.s); + val += v * MAX(MULT / v, 1); break; case FILE_INDIRECT: @@ -1314,6 +1358,8 @@ apprentice_load(struct magic_set *ms, const char *fn, int action) goto out; } while ((d = readdir(dir)) != NULL) { + if (d->d_name[0] == '.') + continue; if (asprintf(&mfn, "%s/%s", fn, d->d_name) < 0) { file_oomem(ms, strlen(fn) + strlen(d->d_name) + 2); @@ -2291,7 +2337,7 @@ parse_ext(struct magic_set *ms, struct magic_entry *me, const char *line) return parse_extra(ms, me, line, CAST(off_t, offsetof(struct magic, ext)), - sizeof(m->ext), "EXTENSION", ",!+-/", 0); + sizeof(m->ext), "EXTENSION", ",!+-/@", 0); } /* @@ -2352,6 +2398,8 @@ check_format_type(const char *ptr, int type, const char **estr) ptr++; if (*ptr == '.') ptr++; + if (*ptr == '#') + ptr++; #define CHECKLEN() do { \ for (len = cnt = 0; isdigit((unsigned char)*ptr); ptr++, cnt++) \ len = len * 10 + (*ptr - '0'); \ @@ -2617,9 +2665,46 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action) default: if (m->reln != 'x') { char *ep; + uint64_t ull; errno = 0; - m->value.q = file_signextend(ms, m, - (uint64_t)strtoull(*p, &ep, 0)); + ull = (uint64_t)strtoull(*p, &ep, 0); + m->value.q = file_signextend(ms, m, ull); + if (*p == ep) { + file_magwarn(ms, "Unparseable number `%s'", *p); + } else { + size_t ts = typesize(m->type); + uint64_t x; + const char *q; + + if (ts == (size_t)~0) { + file_magwarn(ms, "Expected numeric type got `%s'", + type_tbl[m->type].name); + } + for (q = *p; isspace((unsigned char)*q); q++) + continue; + if (*q == '-') + ull = -(int64_t)ull; + switch (ts) { + case 1: + x = ull & ~0xffULL; + break; + case 2: + x = ull & ~0xffffULL; + break; + case 4: + x = ull & ~0xffffffffULL; + break; + case 8: + x = 0; + break; + default: + abort(); + } + if (x) { + file_magwarn(ms, "Overflow for numeric type `%s' value %#" PRIx64, + type_tbl[m->type].name, ull); + } + } if (errno == 0) { *p = ep; eatsize(p); @@ -3271,22 +3356,35 @@ file_pstring_get_length(const struct magic *m, const char *ss) { size_t len = 0; const unsigned char *s = (const unsigned char *)ss; + unsigned int s3, s2, s1, s0; switch (m->str_flags & PSTRING_LEN) { case PSTRING_1_LE: len = *s; break; case PSTRING_2_LE: - len = (s[1] << 8) | s[0]; + s0 = s[0]; + s1 = s[1]; + len = (s1 << 8) | s0; break; case PSTRING_2_BE: - len = (s[0] << 8) | s[1]; + s0 = s[0]; + s1 = s[1]; + len = (s0 << 8) | s1; break; case PSTRING_4_LE: - len = (s[3] << 24) | (s[2] << 16) | (s[1] << 8) | s[0]; + s0 = s[0]; + s1 = s[1]; + s2 = s[2]; + s3 = s[3]; + len = (s3 << 24) | (s2 << 16) | (s1 << 8) | s0; break; case PSTRING_4_BE: - len = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]; + s0 = s[0]; + s1 = s[1]; + s2 = s[2]; + s3 = s[3]; + len = (s0 << 24) | (s1 << 16) | (s2 << 8) | s3; break; default: abort(); /* Impossible */ diff --git contrib/file/src/cdf.c contrib/file/src/cdf.c index d38e793612fc..accfb325b999 100644 --- contrib/file/src/cdf.c +++ contrib/file/src/cdf.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: cdf.c,v 1.85 2016/10/24 18:02:17 christos Exp $") +FILE_RCSID("@(#)$File: cdf.c,v 1.106 2017/04/30 17:05:02 christos Exp $") #endif #include <assert.h> @@ -80,6 +80,34 @@ static union { CDF_TOLE8(CAST(uint64_t, x)))) #define CDF_GETUINT32(x, y) cdf_getuint32(x, y) +#define CDF_MALLOC(n) cdf_malloc(__FILE__, __LINE__, (n)) +#define CDF_REALLOC(p, n) cdf_realloc(__FILE__, __LINE__, (p), (n)) +#define CDF_CALLOC(n, u) cdf_calloc(__FILE__, __LINE__, (n), (u)) + + +static void * +cdf_malloc(const char *file __attribute__((__unused__)), + size_t line __attribute__((__unused__)), size_t n) +{ + DPRINTF(("%s,%zu: %s %zu\n", file, line, __func__, n)); + return malloc(n); +} + +static void * +cdf_realloc(const char *file __attribute__((__unused__)), + size_t line __attribute__((__unused__)), void *p, size_t n) +{ + DPRINTF(("%s,%zu: %s %zu\n", file, line, __func__, n)); + return realloc(p, n); +} + +static void * +cdf_calloc(const char *file __attribute__((__unused__)), + size_t line __attribute__((__unused__)), size_t n, size_t u) +{ + DPRINTF(("%s,%zu: %s %zu %zu\n", file, line, __func__, n, u)); + return calloc(n, u); +} /* * swap a short @@ -340,18 +368,18 @@ cdf_read_header(const cdf_info_t *info, cdf_header_t *h) cdf_unpack_header(h, buf); cdf_swap_header(h); if (h->h_magic != CDF_MAGIC) { - DPRINTF(("Bad magic 0x%" INT64_T_FORMAT "x != 0x%" + DPRINTF(("Bad magic %#" INT64_T_FORMAT "x != %#" INT64_T_FORMAT "x\n", (unsigned long long)h->h_magic, (unsigned long long)CDF_MAGIC)); goto out; } if (h->h_sec_size_p2 > 20) { - DPRINTF(("Bad sector size 0x%u\n", h->h_sec_size_p2)); + DPRINTF(("Bad sector size %hu\n", h->h_sec_size_p2)); goto out; } if (h->h_short_sec_size_p2 > 20) { - DPRINTF(("Bad short sector size 0x%u\n", + DPRINTF(("Bad short sector size %hu\n", h->h_short_sec_size_p2)); goto out; } @@ -408,7 +436,7 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat) if (h->h_master_sat[i] == CDF_SECID_FREE) break; -#define CDF_SEC_LIMIT (UINT32_MAX / (4 * ss)) +#define CDF_SEC_LIMIT (UINT32_MAX / (8 * ss)) if ((nsatpersec > 0 && h->h_num_sectors_in_master_sat > CDF_SEC_LIMIT / nsatpersec) || i > CDF_SEC_LIMIT) { @@ -421,7 +449,7 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat) sat->sat_len = h->h_num_sectors_in_master_sat * nsatpersec + i; DPRINTF(("sat_len = %" SIZE_T_FORMAT "u ss = %" SIZE_T_FORMAT "u\n", sat->sat_len, ss)); - if ((sat->sat_tab = CAST(cdf_secid_t *, calloc(sat->sat_len, ss))) + if ((sat->sat_tab = CAST(cdf_secid_t *, CDF_CALLOC(sat->sat_len, ss))) == NULL) return -1; @@ -435,7 +463,7 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat) } } - if ((msa = CAST(cdf_secid_t *, calloc(1, ss))) == NULL) + if ((msa = CAST(cdf_secid_t *, CDF_CALLOC(1, ss))) == NULL) goto out1; mid = h->h_secid_first_sector_in_master_sat; @@ -527,13 +555,16 @@ cdf_read_long_sector_chain(const cdf_info_t *info, const cdf_header_t *h, ssize_t nr; scn->sst_tab = NULL; scn->sst_len = cdf_count_chain(sat, sid, ss); - scn->sst_dirlen = len; + scn->sst_dirlen = MAX(h->h_min_size_standard_stream, len); scn->sst_ss = ss; + if (sid == CDF_SECID_END_OF_CHAIN || len == 0) + return cdf_zero_stream(scn); + if (scn->sst_len == (size_t)-1) goto out; - scn->sst_tab = calloc(scn->sst_len, ss); + scn->sst_tab = CDF_CALLOC(scn->sst_len, ss); if (scn->sst_tab == NULL) return cdf_zero_stream(scn); @@ -579,7 +610,7 @@ cdf_read_short_sector_chain(const cdf_header_t *h, if (scn->sst_len == (size_t)-1) goto out; - scn->sst_tab = calloc(scn->sst_len, ss); + scn->sst_tab = CDF_CALLOC(scn->sst_len, ss); if (scn->sst_tab == NULL) return cdf_zero_stream(scn); @@ -637,11 +668,11 @@ cdf_read_dir(const cdf_info_t *info, const cdf_header_t *h, dir->dir_len = ns * nd; dir->dir_tab = CAST(cdf_directory_t *, - calloc(dir->dir_len, sizeof(dir->dir_tab[0]))); + CDF_CALLOC(dir->dir_len, sizeof(dir->dir_tab[0]))); if (dir->dir_tab == NULL) return -1; - if ((buf = CAST(char *, malloc(ss))) == NULL) { + if ((buf = CAST(char *, CDF_MALLOC(ss))) == NULL) { free(dir->dir_tab); return -1; } @@ -687,7 +718,7 @@ cdf_read_ssat(const cdf_info_t *info, const cdf_header_t *h, if (ssat->sat_len == (size_t)-1) goto out; - ssat->sat_tab = CAST(cdf_secid_t *, calloc(ssat->sat_len, ss)); + ssat->sat_tab = CAST(cdf_secid_t *, CDF_CALLOC(ssat->sat_len, ss)); if (ssat->sat_tab == NULL) goto out1; @@ -808,13 +839,107 @@ cdf_find_stream(const cdf_dir_t *dir, const char *name, int type) == 0) break; if (i > 0) - return i; + return CAST(int, i); DPRINTF(("Cannot find type %d `%s'\n", type, name)); errno = ESRCH; return 0; } +#define CDF_SHLEN_LIMIT (UINT32_MAX / 8) +#define CDF_PROP_LIMIT (UINT32_MAX / (8 * sizeof(cdf_property_info_t))) + +static const void * +cdf_offset(const void *p, size_t l) +{ + return CAST(const void *, CAST(const uint8_t *, p) + l); +} + +static const uint8_t * +cdf_get_property_info_pos(const cdf_stream_t *sst, const cdf_header_t *h, + const uint8_t *p, const uint8_t *e, size_t i) +{ + size_t tail = (i << 1) + 1; + size_t ofs; + const uint8_t *q; + + if (p >= e) { + DPRINTF(("Past end %p < %p\n", e, p)); + return NULL; + } + if (cdf_check_stream_offset(sst, h, p, (tail + 1) * sizeof(uint32_t), + __LINE__) == -1) + return NULL; + ofs = CDF_GETUINT32(p, tail); + q = CAST(const uint8_t *, cdf_offset(CAST(const void *, p), + ofs - 2 * sizeof(uint32_t))); + + if (q < p) { + DPRINTF(("Wrapped around %p < %p\n", q, p)); + return NULL; + } + + if (q >= e) { + DPRINTF(("Ran off the end %p >= %p\n", q, e)); + return NULL; + } + return q; +} + +static cdf_property_info_t * +cdf_grow_info(cdf_property_info_t **info, size_t *maxcount, size_t incr) +{ + cdf_property_info_t *inp; + size_t newcount = *maxcount + incr; + + if (newcount > CDF_PROP_LIMIT) { + DPRINTF(("exceeded property limit %zu > %zu\n", + newcount, CDF_PROP_LIMIT)); + goto out; + } + inp = CAST(cdf_property_info_t *, + CDF_REALLOC(*info, newcount * sizeof(*inp))); + if (inp == NULL) + goto out; + + *info = inp; + *maxcount = newcount; + return inp; +out: + free(*info); + *maxcount = 0; + *info = NULL; + return NULL; +} + +static int +cdf_copy_info(cdf_property_info_t *inp, const void *p, const void *e, + size_t len) +{ + if (inp->pi_type & CDF_VECTOR) + return 0; + + if ((size_t)(CAST(const char *, e) - CAST(const char *, p)) < len) + return 0; + + (void)memcpy(&inp->pi_val, p, len); + + switch (len) { + case 2: + inp->pi_u16 = CDF_TOLE2(inp->pi_u16); + break; + case 4: + inp->pi_u32 = CDF_TOLE4(inp->pi_u32); + break; + case 8: + inp->pi_u64 = CDF_TOLE8(inp->pi_u64); + break; + default: + abort(); + } + return 1; +} + int cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, uint32_t offs, cdf_property_info_t **info, size_t *count, size_t *maxcount) @@ -822,92 +947,69 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, const cdf_section_header_t *shp; cdf_section_header_t sh; const uint8_t *p, *q, *e; - int16_t s16; - int32_t s32; - uint32_t u32; - int64_t s64; - uint64_t u64; - cdf_timestamp_t tp; - size_t i, o, o4, nelements, j; + size_t i, o4, nelements, j, slen, left; cdf_property_info_t *inp; if (offs > UINT32_MAX / 4) { errno = EFTYPE; goto out; } - shp = CAST(const cdf_section_header_t *, (const void *) - ((const char *)sst->sst_tab + offs)); + shp = CAST(const cdf_section_header_t *, + cdf_offset(sst->sst_tab, offs)); if (cdf_check_stream_offset(sst, h, shp, sizeof(*shp), __LINE__) == -1) goto out; sh.sh_len = CDF_TOLE4(shp->sh_len); -#define CDF_SHLEN_LIMIT (UINT32_MAX / 8) if (sh.sh_len > CDF_SHLEN_LIMIT) { errno = EFTYPE; goto out; } - sh.sh_properties = CDF_TOLE4(shp->sh_properties); -#define CDF_PROP_LIMIT (UINT32_MAX / (4 * sizeof(*inp))) - if (sh.sh_properties > CDF_PROP_LIMIT) + + if (cdf_check_stream_offset(sst, h, shp, sh.sh_len, __LINE__) == -1) goto out; + + sh.sh_properties = CDF_TOLE4(shp->sh_properties); DPRINTF(("section len: %u properties %u\n", sh.sh_len, sh.sh_properties)); - if (*maxcount) { - if (*maxcount > CDF_PROP_LIMIT) - goto out; - *maxcount += sh.sh_properties; - inp = CAST(cdf_property_info_t *, - realloc(*info, *maxcount * sizeof(*inp))); - } else { - *maxcount = sh.sh_properties; - inp = CAST(cdf_property_info_t *, - malloc(*maxcount * sizeof(*inp))); - } + if (sh.sh_properties > CDF_PROP_LIMIT) + goto out; + inp = cdf_grow_info(info, maxcount, sh.sh_properties); if (inp == NULL) - goto out1; - *info = inp; + goto out; inp += *count; *count += sh.sh_properties; - p = CAST(const uint8_t *, (const void *) - ((const char *)(const void *)sst->sst_tab + - offs + sizeof(sh))); - e = CAST(const uint8_t *, (const void *) - (((const char *)(const void *)shp) + sh.sh_len)); - if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1) + p = CAST(const uint8_t *, cdf_offset(sst->sst_tab, offs + sizeof(sh))); + e = CAST(const uint8_t *, cdf_offset(shp, sh.sh_len)); + if (p >= e || cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1) goto out; + for (i = 0; i < sh.sh_properties; i++) { - size_t tail = (i << 1) + 1; - size_t ofs; - if (cdf_check_stream_offset(sst, h, p, tail * sizeof(uint32_t), - __LINE__) == -1) - goto out; - ofs = CDF_GETUINT32(p, tail); - q = (const uint8_t *)(const void *) - ((const char *)(const void *)p + ofs - - 2 * sizeof(uint32_t)); - if (q < p) { - DPRINTF(("Wrapped around %p < %p\n", q, p)); + if ((q = cdf_get_property_info_pos(sst, h, p, e, i)) == NULL) goto out; - } - if (q > e) { - DPRINTF(("Ran of the end %p > %p\n", q, e)); + inp[i].pi_id = CDF_GETUINT32(p, i << 1); + left = CAST(size_t, e - q); + if (left < sizeof(uint32_t)) { + DPRINTF(("short info (no type)_\n")); goto out; } - inp[i].pi_id = CDF_GETUINT32(p, i << 1); inp[i].pi_type = CDF_GETUINT32(q, 0); - DPRINTF(("%" SIZE_T_FORMAT "u) id=%x type=%x offs=0x%tx,0x%x\n", + DPRINTF(("%" SIZE_T_FORMAT "u) id=%#x type=%#x offs=%#tx,%#x\n", i, inp[i].pi_id, inp[i].pi_type, q - p, offs)); if (inp[i].pi_type & CDF_VECTOR) { + if (left < sizeof(uint32_t) * 2) { + DPRINTF(("missing CDF_VECTOR length\n")); + goto out; + } nelements = CDF_GETUINT32(q, 1); if (nelements == 0) { DPRINTF(("CDF_VECTOR with nelements == 0\n")); goto out; } - o = 2; + slen = 2; } else { nelements = 1; - o = 1; + slen = 1; } - o4 = o * sizeof(uint32_t); + o4 = slen * sizeof(uint32_t); if (inp[i].pi_type & (CDF_ARRAY|CDF_BYREF|CDF_RESERVED)) goto unknown; switch (inp[i].pi_type & CDF_TYPEMASK) { @@ -915,109 +1017,83 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, case CDF_EMPTY: break; case CDF_SIGNED16: - if (inp[i].pi_type & CDF_VECTOR) + if (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int16_t))) goto unknown; - (void)memcpy(&s16, &q[o4], sizeof(s16)); - inp[i].pi_s16 = CDF_TOLE2(s16); break; case CDF_SIGNED32: - if (inp[i].pi_type & CDF_VECTOR) - goto unknown; - (void)memcpy(&s32, &q[o4], sizeof(s32)); - inp[i].pi_s32 = CDF_TOLE4((uint32_t)s32); - break; case CDF_BOOL: case CDF_UNSIGNED32: - if (inp[i].pi_type & CDF_VECTOR) + case CDF_FLOAT: + if (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int32_t))) goto unknown; - (void)memcpy(&u32, &q[o4], sizeof(u32)); - inp[i].pi_u32 = CDF_TOLE4(u32); break; case CDF_SIGNED64: - if (inp[i].pi_type & CDF_VECTOR) - goto unknown; - (void)memcpy(&s64, &q[o4], sizeof(s64)); - inp[i].pi_s64 = CDF_TOLE8((uint64_t)s64); - break; case CDF_UNSIGNED64: - if (inp[i].pi_type & CDF_VECTOR) - goto unknown; - (void)memcpy(&u64, &q[o4], sizeof(u64)); - inp[i].pi_u64 = CDF_TOLE8((uint64_t)u64); - break; - case CDF_FLOAT: - if (inp[i].pi_type & CDF_VECTOR) - goto unknown; - (void)memcpy(&u32, &q[o4], sizeof(u32)); - u32 = CDF_TOLE4(u32); - memcpy(&inp[i].pi_f, &u32, sizeof(inp[i].pi_f)); - break; case CDF_DOUBLE: - if (inp[i].pi_type & CDF_VECTOR) + case CDF_FILETIME: + if (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int64_t))) goto unknown; - (void)memcpy(&u64, &q[o4], sizeof(u64)); - u64 = CDF_TOLE8((uint64_t)u64); - memcpy(&inp[i].pi_d, &u64, sizeof(inp[i].pi_d)); break; case CDF_LENGTH32_STRING: case CDF_LENGTH32_WSTRING: if (nelements > 1) { size_t nelem = inp - *info; - if (*maxcount > CDF_PROP_LIMIT - || nelements > CDF_PROP_LIMIT) - goto out; - *maxcount += nelements; - inp = CAST(cdf_property_info_t *, - realloc(*info, *maxcount * sizeof(*inp))); + inp = cdf_grow_info(info, maxcount, nelements); if (inp == NULL) - goto out1; - *info = inp; - inp = *info + nelem; + goto out; + inp += nelem; } DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n", nelements)); for (j = 0; j < nelements && i < sh.sh_properties; j++, i++) { - uint32_t l = CDF_GETUINT32(q, o); + uint32_t l; + + if (o4 + sizeof(uint32_t) > left) + goto out; + + l = CDF_GETUINT32(q, slen); + o4 += sizeof(uint32_t); + if (o4 + l > left) + goto out; + inp[i].pi_str.s_len = l; - inp[i].pi_str.s_buf = (const char *) - (const void *)(&q[o4 + sizeof(l)]); - DPRINTF(("l = %d, r = %" SIZE_T_FORMAT - "u, s = %s\n", l, - CDF_ROUND(l, sizeof(l)), + inp[i].pi_str.s_buf = CAST(const char *, + CAST(const void *, &q[o4])); + + DPRINTF(("o=%zu l=%d(%" SIZE_T_FORMAT + "u), t=%zu s=%s\n", o4, l, + CDF_ROUND(l, sizeof(l)), left, inp[i].pi_str.s_buf)); + if (l & 1) l++; - o += l >> 1; - if (q + o >= e) - goto out; - o4 = o * sizeof(uint32_t); + + slen += l >> 1; + o4 = slen * sizeof(uint32_t); } i--; break; - case CDF_FILETIME: - if (inp[i].pi_type & CDF_VECTOR) - goto unknown; - (void)memcpy(&tp, &q[o4], sizeof(tp)); - inp[i].pi_tp = CDF_TOLE8((uint64_t)tp); - break; case CDF_CLIPBOARD: if (inp[i].pi_type & CDF_VECTOR) goto unknown; break; default: unknown: - DPRINTF(("Don't know how to deal with %x\n", + memset(&inp[i].pi_val, 0, sizeof(inp[i].pi_val)); + DPRINTF(("Don't know how to deal with %#x\n", inp[i].pi_type)); break; } } return 0; out: - errno = EFTYPE; -out1: free(*info); + *info = NULL; + *count = 0; + *maxcount = 0; + errno = EFTYPE; return -1; } @@ -1065,7 +1141,7 @@ cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst, { size_t ss = cdf_check_stream(sst, h); const char *b = CAST(const char *, sst->sst_tab); - const char *eb = b + ss * sst->sst_len; + const char *nb, *eb = b + ss * sst->sst_len; size_t nr, i, j, k; cdf_catalog_entry_t *ce; uint16_t reclen; @@ -1084,7 +1160,7 @@ cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst, return -1; nr--; *cat = CAST(cdf_catalog_t *, - malloc(sizeof(cdf_catalog_t) + nr * sizeof(*ce))); + CDF_MALLOC(sizeof(cdf_catalog_t) + nr * sizeof(*ce))); if (*cat == NULL) return -1; ce = (*cat)->cat_e; @@ -1110,7 +1186,9 @@ cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst, cep->ce_namlen = rlen; np = CAST(const uint16_t *, CAST(const void *, (b + 16))); - if (RCAST(const char *, np + cep->ce_namlen) > eb) { + nb = CAST(const char *, CAST(const void *, + (np + cep->ce_namlen))); + if (nb > eb) { cep->ce_namlen = 0; break; } @@ -1169,7 +1247,7 @@ cdf_print_property_name(char *buf, size_t bufsiz, uint32_t p) for (i = 0; i < __arraycount(vn); i++) if (vn[i].v == p) return snprintf(buf, bufsiz, "%s", vn[i].n); - return snprintf(buf, bufsiz, "0x%x", p); + return snprintf(buf, bufsiz, "%#x", p); } int @@ -1228,7 +1306,7 @@ cdf_dump_header(const cdf_header_t *h) h->h_ ## b, 1 << h->h_ ## b) DUMP("%d", revision); DUMP("%d", version); - DUMP("0x%x", byte_order); + DUMP("%#x", byte_order); DUMP2("%d", sec_size_p2); DUMP2("%d", short_sec_size_p2); DUMP("%d", num_sectors_in_sat); @@ -1322,7 +1400,7 @@ cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h, d->d_color ? "black" : "red"); (void)fprintf(stderr, "Left child: %d\n", d->d_left_child); (void)fprintf(stderr, "Right child: %d\n", d->d_right_child); - (void)fprintf(stderr, "Flags: 0x%x\n", d->d_flags); + (void)fprintf(stderr, "Flags: %#x\n", d->d_flags); cdf_timestamp_to_timespec(&ts, d->d_created); (void)fprintf(stderr, "Created %s", cdf_ctime(&ts.tv_sec, buf)); cdf_timestamp_to_timespec(&ts, d->d_modified); @@ -1415,7 +1493,7 @@ cdf_dump_property_info(const cdf_property_info_t *info, size_t count) (void)fprintf(stderr, "CLIPBOARD %u\n", info[i].pi_u32); break; default: - DPRINTF(("Don't know how to deal with %x\n", + DPRINTF(("Don't know how to deal with %#x\n", info[i].pi_type)); break; } @@ -1434,7 +1512,7 @@ cdf_dump_summary_info(const cdf_header_t *h, const cdf_stream_t *sst) (void)&h; if (cdf_unpack_summary_info(sst, h, &ssi, &info, &count) == -1) return; - (void)fprintf(stderr, "Endian: %x\n", ssi.si_byte_order); + (void)fprintf(stderr, "Endian: %#x\n", ssi.si_byte_order); (void)fprintf(stderr, "Os Version %d.%d\n", ssi.si_os_version & 0xff, ssi.si_os_version >> 8); (void)fprintf(stderr, "Os %d\n", ssi.si_os); diff --git contrib/file/src/cdf.h contrib/file/src/cdf.h index 0b345ab49615..f2df8306b17d 100644 --- contrib/file/src/cdf.h +++ contrib/file/src/cdf.h @@ -127,9 +127,9 @@ typedef struct { typedef struct { void *sst_tab; - size_t sst_len; - size_t sst_dirlen; - size_t sst_ss; + size_t sst_len; /* Number of sectors */ + size_t sst_dirlen; /* Directory sector size */ + size_t sst_ss; /* Sector size */ } cdf_stream_t; typedef struct { diff --git contrib/file/src/cdf_time.c contrib/file/src/cdf_time.c index 1e572de539f8..2bdcd2a7f7a8 100644 --- contrib/file/src/cdf_time.c +++ contrib/file/src/cdf_time.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: cdf_time.c,v 1.15 2014/05/14 23:15:42 christos Exp $") +FILE_RCSID("@(#)$File: cdf_time.c,v 1.16 2017/03/29 15:57:48 christos Exp $") #endif #include <time.h> @@ -171,7 +171,7 @@ cdf_ctime(const time_t *sec, char *buf) char *ptr = ctime_r(sec, buf); if (ptr != NULL) return buf; - (void)snprintf(buf, 26, "*Bad* 0x%16.16" INT64_T_FORMAT "x\n", + (void)snprintf(buf, 26, "*Bad* %#16.16" INT64_T_FORMAT "x\n", (long long)*sec); return buf; } diff --git contrib/file/src/compress.c contrib/file/src/compress.c index 95f095529da5..2f789cd2bc44 100644 --- contrib/file/src/compress.c +++ contrib/file/src/compress.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: compress.c,v 1.100 2016/10/24 18:02:17 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.105 2017/05/25 00:13:03 christos Exp $") #endif #include "magic.h" @@ -62,7 +62,7 @@ typedef void (*sig_t)(int); #if defined(HAVE_SYS_TIME_H) #include <sys/time.h> #endif -#if defined(HAVE_ZLIB_H) +#if defined(HAVE_ZLIB_H) && defined(ZLIBSUPPORT) #define BUILTIN_DECOMPRESS #include <zlib.h> #endif @@ -83,6 +83,7 @@ int tty = -1; /* * The following python code is not really used because ZLIBSUPPORT is only * defined if we have a built-in zlib, and the built-in zlib handles that. + * That is not true for android where we have zlib.h and not -lz. */ static const char zlibcode[] = "import sys, zlib; sys.stdout.write(zlib.decompress(sys.stdin.read()))"; @@ -93,7 +94,7 @@ static int zlibcmp(const unsigned char *buf) { unsigned short x = 1; - unsigned char *s = (unsigned char *)&x; + unsigned char *s = CAST(unsigned char *, CAST(void *, &x)); if ((buf[0] & 0xf) != 8 || (buf[0] & 0x80) != 0) return 0; @@ -497,7 +498,7 @@ uncompresszlib(const unsigned char *old, unsigned char **newch, z.next_in = CCAST(Bytef *, old); z.avail_in = CAST(uint32_t, *n); z.next_out = *newch; - z.avail_out = bytes_max; + z.avail_out = CAST(unsigned int, bytes_max); z.zalloc = Z_NULL; z.zfree = Z_NULL; z.opaque = Z_NULL; @@ -632,7 +633,7 @@ filter_error(unsigned char *ubuf, ssize_t n) while (isspace((unsigned char)*p)) p++; n = strlen(p); - memmove(ubuf, p, n + 1); + memmove(ubuf, p, CAST(size_t, n + 1)); } DPRINTF("Filter error after[[[%s]]]\n", (char *)ubuf); if (islower(*ubuf)) @@ -688,7 +689,7 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old, } for (i = 0; i < __arraycount(fdp); i++) - copydesc(i, fdp[i]); + copydesc(CAST(int, i), fdp[i]); (void)execvp(compr[method].argv[0], (char *const *)(intptr_t)compr[method].argv); @@ -748,9 +749,9 @@ err: rv = makeerror(newch, n, "Wait failed, %s", strerror(errno)); DPRINTF("Child wait return %#x\n", status); } else if (!WIFEXITED(status)) { - DPRINTF("Child not exited (0x%x)\n", status); + DPRINTF("Child not exited (%#x)\n", status); } else if (WEXITSTATUS(status) != 0) { - DPRINTF("Child exited (0x%d)\n", WEXITSTATUS(status)); + DPRINTF("Child exited (%#x)\n", WEXITSTATUS(status)); } closefd(fdp[STDIN_FILENO], 0); diff --git contrib/file/src/der.c contrib/file/src/der.c index 8ae638fb9897..4e22caf41d4a 100644 --- contrib/file/src/der.c +++ contrib/file/src/der.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: der.c,v 1.10 2016/10/24 18:02:17 christos Exp $") +FILE_RCSID("@(#)$File: der.c,v 1.12 2017/02/10 18:14:01 christos Exp $") #endif #endif @@ -159,31 +159,49 @@ gettag(const uint8_t *c, size_t *p, size_t l) return tag; } +/* + * Read the length of a DER tag from the input. + * + * `c` is the input, `p` is an output parameter that specifies how much of the + * input we consumed, and `l` is the maximum input length. + * + * Returns the length, or DER_BAD if the end of the input is reached or the + * length exceeds the remaining input. + */ static uint32_t getlength(const uint8_t *c, size_t *p, size_t l) { uint8_t digits, i; size_t len; + int is_onebyte_result; if (*p >= l) return DER_BAD; - digits = c[(*p)++]; + /* + * Digits can either be 0b0 followed by the result, or 0b1 + * followed by the number of digits of the result. In either case, + * we verify that we can read so many bytes from the input. + */ + is_onebyte_result = (c[*p] & 0x80) == 0; + digits = c[(*p)++] & 0x7f; + if (*p + digits >= l) + return DER_BAD; - if ((digits & 0x80) == 0) + if (is_onebyte_result) return digits; - digits &= 0x7f; + /* + * Decode len. We've already verified that we're allowed to read + * `digits` bytes. + */ len = 0; - - if (*p + digits >= l) - return DER_BAD; - for (i = 0; i < digits; i++) len = (len << 8) | c[(*p)++]; + if (*p + len >= l) return DER_BAD; - return len; + return CAST(uint32_t, len); } static const char * @@ -242,12 +260,12 @@ der_offs(struct magic_set *ms, struct magic *m, size_t nbytes) #endif if (m->cont_level != 0) { if (offs + tlen > nbytes) - return DER_BAD; - ms->c.li[m->cont_level - 1].off = offs + tlen; + return -1; + ms->c.li[m->cont_level - 1].off = CAST(int, offs + tlen); DPRINTF(("cont_level[%u] = %u\n", m->cont_level - 1, ms->c.li[m->cont_level - 1].off)); } - return offs; + return CAST(int32_t, offs); } int diff --git contrib/file/src/file.h contrib/file/src/file.h index 180efd3525ce..eb9c05421db6 100644 --- contrib/file/src/file.h +++ contrib/file/src/file.h @@ -27,7 +27,7 @@ */ /* * file.h - definitions for file(1) program - * @(#)$File: file.h,v 1.180 2016/07/20 11:27:08 christos Exp $ + * @(#)$File: file.h,v 1.183 2017/08/28 13:39:18 christos Exp $ */ #ifndef __file_h__ @@ -36,6 +36,10 @@ #ifdef HAVE_CONFIG_H #include <config.h> #endif +#ifdef HAVE_STDINT_H +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS +#endif #ifdef WIN32 #ifdef _WIN64 @@ -50,16 +54,12 @@ #define INT64_T_FORMAT "ll" #define INTMAX_T_FORMAT "j" #endif +#include <stdint.h> +#endif #include <stdio.h> /* Include that here, to make sure __P gets defined */ #include <errno.h> #include <fcntl.h> /* For open and flags */ -#ifdef HAVE_STDINT_H -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS -#endif -#include <stdint.h> -#endif #ifdef HAVE_INTTYPES_H #include <inttypes.h> #endif @@ -447,7 +447,7 @@ protected size_t file_printedlen(const struct magic_set *); protected int file_replace(struct magic_set *, const char *, const char *); protected int file_printf(struct magic_set *, const char *, ...) __attribute__((__format__(__printf__, 2, 3))); -protected int file_reset(struct magic_set *); +protected int file_reset(struct magic_set *, int); protected int file_tryelf(struct magic_set *, int, const unsigned char *, size_t); protected int file_trycdf(struct magic_set *, int, const unsigned char *, diff --git contrib/file/src/fsmagic.c contrib/file/src/fsmagic.c index 27f982a58348..c0a437a8f6d0 100644 --- contrib/file/src/fsmagic.c +++ contrib/file/src/fsmagic.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: fsmagic.c,v 1.76 2015/04/09 20:01:41 christos Exp $") +FILE_RCSID("@(#)$File: fsmagic.c,v 1.77 2017/05/24 19:17:50 christos Exp $") #endif /* lint */ #include "magic.h" @@ -104,14 +104,13 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) { int ret, did = 0; int mime = ms->flags & MAGIC_MIME; + int silent = ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION); #ifdef S_IFLNK char buf[BUFSIZ+4]; ssize_t nch; struct stat tstatbuf; #endif - if (ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION)) - return 0; if (fn == NULL) return 0; @@ -168,7 +167,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) } ret = 1; - if (!mime) { + if (!mime && !silent) { #ifdef S_ISUID if (sb->st_mode & S_ISUID) if (file_printf(ms, "%ssetuid", COMMA) == -1) @@ -191,6 +190,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) if (mime) { if (handle_mime(ms, mime, "directory") == -1) return -1; + } else if (silent) { } else if (file_printf(ms, "%sdirectory", COMMA) == -1) return -1; break; @@ -208,6 +208,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) if (mime) { if (handle_mime(ms, mime, "chardevice") == -1) return -1; + } else if (silent) { } else { #ifdef HAVE_STRUCT_STAT_ST_RDEV # ifdef dv_unit @@ -242,6 +243,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) if (mime) { if (handle_mime(ms, mime, "blockdevice") == -1) return -1; + } else if (silent) { } else { #ifdef HAVE_STRUCT_STAT_ST_RDEV # ifdef dv_unit @@ -270,6 +272,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) if (mime) { if (handle_mime(ms, mime, "fifo") == -1) return -1; + } else if (silent) { } else if (file_printf(ms, "%sfifo (named pipe)", COMMA) == -1) return -1; break; @@ -279,6 +282,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) if (mime) { if (handle_mime(ms, mime, "door") == -1) return -1; + } else if (silent) { } else if (file_printf(ms, "%sdoor", COMMA) == -1) return -1; break; @@ -294,6 +298,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) if (mime) { if (handle_mime(ms, mime, "symlink") == -1) return -1; + } else if (silent) { } else if (file_printf(ms, "%sunreadable symlink `%s' (%s)", COMMA, fn, strerror(errno)) == -1) @@ -323,6 +328,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) if (handle_mime(ms, mime, "x-path-too-long") == -1) return -1; + } else if (silent) { } else if (file_printf(ms, "%spath too long: `%s'", COMMA, fn) == -1) @@ -352,6 +358,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) if (mime) { if (handle_mime(ms, mime, "symlink") == -1) return -1; + } else if (silent) { } else if (file_printf(ms, "%ssymbolic link to %s", COMMA, buf) == -1) return -1; @@ -364,6 +371,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) if (mime) { if (handle_mime(ms, mime, "socket") == -1) return -1; + } else if (silent) { } else if (file_printf(ms, "%ssocket", COMMA) == -1) return -1; break; @@ -386,6 +394,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) if (mime) { if (handle_mime(ms, mime, "x-empty") == -1) return -1; + } else if (silent) { } else if (file_printf(ms, "%sempty", COMMA) == -1) return -1; break; @@ -399,7 +408,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) /*NOTREACHED*/ } - if (!mime && did && ret == 0) { + if (!silent && !mime && did && ret == 0) { if (file_printf(ms, " ") == -1) return -1; } diff --git contrib/file/src/funcs.c contrib/file/src/funcs.c index c8918a45963a..d7a18f451a7e 100644 --- contrib/file/src/funcs.c +++ contrib/file/src/funcs.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: funcs.c,v 1.90 2016/10/19 20:51:17 christos Exp $") +FILE_RCSID("@(#)$File: funcs.c,v 1.93 2017/08/28 13:39:18 christos Exp $") #endif /* lint */ #include "magic.h" @@ -76,7 +76,7 @@ file_vprintf(struct magic_set *ms, const char *fmt, va_list ap) ms->o.buf = buf; return 0; out: - file_error(ms, errno, "vasprintf failed"); + fprintf(stderr, "vasprintf failed (%s)", strerror(errno)); return -1; } @@ -328,9 +328,9 @@ simple: #endif protected int -file_reset(struct magic_set *ms) +file_reset(struct magic_set *ms, int checkloaded) { - if (ms->mlist[0] == NULL) { + if (checkloaded && ms->mlist[0] == NULL) { file_error(ms, 0, "no magic files loaded"); return -1; } @@ -509,6 +509,8 @@ file_regexec(file_regex_t *rx, const char *str, size_t nmatch, regmatch_t* pmatch, int eflags) { assert(rx->rc == 0); + /* XXX: force initialization because glibc does not always do this */ + memset(pmatch, 0, nmatch * sizeof(*pmatch)); return regexec(&rx->rx, str, nmatch, pmatch, eflags); } diff --git contrib/file/src/is_tar.c contrib/file/src/is_tar.c index a3e5dbf24c36..1953a7fc102e 100644 --- contrib/file/src/is_tar.c +++ contrib/file/src/is_tar.c @@ -40,7 +40,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: is_tar.c,v 1.38 2015/04/09 20:01:41 christos Exp $") +FILE_RCSID("@(#)$File: is_tar.c,v 1.39 2017/03/17 20:45:01 christos Exp $") #endif #include "magic.h" @@ -51,7 +51,7 @@ FILE_RCSID("@(#)$File: is_tar.c,v 1.38 2015/04/09 20:01:41 christos Exp $") #define isodigit(c) ( ((c) >= '0') && ((c) <= '7') ) private int is_tar(const unsigned char *, size_t); -private int from_oct(int, const char *); /* Decode octal number */ +private int from_oct(const char *, size_t); /* Decode octal number */ static const char tartype[][32] = { "tar archive", @@ -93,31 +93,35 @@ private int is_tar(const unsigned char *buf, size_t nbytes) { const union record *header = (const union record *)(const void *)buf; - int i; - int sum, recsum; - const unsigned char *p; + size_t i; + int sum, recsum; + const unsigned char *p, *ep; - if (nbytes < sizeof(union record)) + if (nbytes < sizeof(*header)) return 0; - recsum = from_oct(8, header->header.chksum); + recsum = from_oct(header->header.chksum, sizeof(header->header.chksum)); sum = 0; p = header->charptr; - for (i = sizeof(union record); --i >= 0;) + ep = header->charptr + sizeof(*header); + while (p < ep) sum += *p++; /* Adjust checksum to count the "chksum" field as blanks. */ - for (i = sizeof(header->header.chksum); --i >= 0;) + for (i = 0; i < sizeof(header->header.chksum); i++) sum -= header->header.chksum[i]; - sum += ' ' * sizeof header->header.chksum; + sum += ' ' * sizeof(header->header.chksum); if (sum != recsum) return 0; /* Not a tar archive */ - if (strcmp(header->header.magic, GNUTMAGIC) == 0) + if (strncmp(header->header.magic, GNUTMAGIC, + sizeof(header->header.magic)) == 0) return 3; /* GNU Unix Standard tar archive */ - if (strcmp(header->header.magic, TMAGIC) == 0) + + if (strncmp(header->header.magic, TMAGIC, + sizeof(header->header.magic)) == 0) return 2; /* Unix Standard tar archive */ return 1; /* Old fashioned tar archive */ @@ -130,19 +134,22 @@ is_tar(const unsigned char *buf, size_t nbytes) * Result is -1 if the field is invalid (all blank, or non-octal). */ private int -from_oct(int digs, const char *where) +from_oct(const char *where, size_t digs) { int value; + if (digs == 0) + return -1; + while (isspace((unsigned char)*where)) { /* Skip spaces */ where++; - if (--digs <= 0) + if (digs-- == 0) return -1; /* All blank field */ } value = 0; while (digs > 0 && isodigit(*where)) { /* Scan til non-octal */ value = (value << 3) | (*where++ - '0'); - --digs; + digs--; } if (digs > 0 && *where && !isspace((unsigned char)*where)) diff --git contrib/file/src/magic.c contrib/file/src/magic.c index b61ad29d7a5d..1448a69bcad5 100644 --- contrib/file/src/magic.c +++ contrib/file/src/magic.c @@ -33,7 +33,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: magic.c,v 1.100 2016/07/18 11:43:05 christos Exp $") +FILE_RCSID("@(#)$File: magic.c,v 1.102 2017/08/28 13:39:18 christos Exp $") #endif /* lint */ #include "magic.h" @@ -167,7 +167,7 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason, { if (fdwReason == DLL_PROCESS_ATTACH) _w32_dll_instance = hinstDLL; - return TRUE; + return 1; } #endif @@ -409,7 +409,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd) int ispipe = 0; off_t pos = (off_t)-1; - if (file_reset(ms) == -1) + if (file_reset(ms, 1) == -1) goto out; /* @@ -538,7 +538,7 @@ magic_buffer(struct magic_set *ms, const void *buf, size_t nb) { if (ms == NULL) return NULL; - if (file_reset(ms) == -1) + if (file_reset(ms, 1) == -1) return NULL; /* * The main work is done here! @@ -567,6 +567,15 @@ magic_errno(struct magic_set *ms) return (ms->event_flags & EVENT_HAD_ERR) ? ms->error : 0; } +public int +magic_getflags(struct magic_set *ms) +{ + if (ms == NULL) + return -1; + + return ms->flags; +} + public int magic_setflags(struct magic_set *ms, int flags) { diff --git contrib/file/src/magic.h.in contrib/file/src/magic.h.in index 3d6954a2a6d4..1134bdc886d4 100644 --- contrib/file/src/magic.h.in +++ contrib/file/src/magic.h.in @@ -73,6 +73,35 @@ 0 \ ) +#define MAGIC_SNPRINTB "\177\020\ +b\0debug\0\ +b\1symlink\0\ +b\2compress\0\ +b\3devices\0\ +b\4mime_type\0\ +b\5continue\0\ +b\6check\0\ +b\7preserve_atime\0\ +b\10raw\0\ +b\11error\0\ +b\12mime_encoding\0\ +b\13apple\0\ +b\14no_check_compress\0\ +b\15no_check_tar\0\ +b\16no_check_soft\0\ +b\17no_check_sapptype\0\ +b\20no_check_elf\0\ +b\21no_check_text\0\ +b\22no_check_cdf\0\ +b\23no_check_reserved0\0\ +b\24no_check_tokens\0\ +b\25no_check_encoding\0\ +b\26no_check_reserved1\0\ +b\27no_check_reserved2\0\ +b\30extension\0\ +b\31transp_compression\0\ +" + /* Defined for backwards compatibility (renamed) */ #define MAGIC_NO_CHECK_ASCII MAGIC_NO_CHECK_TEXT @@ -97,6 +126,7 @@ const char *magic_descriptor(magic_t, int); const char *magic_buffer(magic_t, const void *, size_t); const char *magic_error(magic_t); +int magic_getflags(magic_t); int magic_setflags(magic_t, int); int magic_version(void); diff --git contrib/file/src/print.c contrib/file/src/print.c index a0221b126ecb..0b918636bc5e 100644 --- contrib/file/src/print.c +++ contrib/file/src/print.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: print.c,v 1.81 2016/01/19 15:09:03 christos Exp $") +FILE_RCSID("@(#)$File: print.c,v 1.82 2017/02/10 18:14:01 christos Exp $") #endif /* lint */ #include <string.h> @@ -238,7 +238,7 @@ file_fmttime(uint64_t v, int flags, char *buf) if (flags & FILE_T_WINDOWS) { struct timespec ts; - cdf_timestamp_to_timespec(&ts, v); + cdf_timestamp_to_timespec(&ts, CAST(cdf_timestamp_t, v)); t = ts.tv_sec; } else { // XXX: perhaps detect and print something if overflow diff --git contrib/file/src/readcdf.c contrib/file/src/readcdf.c index 20e631d6db6f..80c8d26e3fec 100644 --- contrib/file/src/readcdf.c +++ contrib/file/src/readcdf.c @@ -26,7 +26,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: readcdf.c,v 1.63 2016/10/18 22:25:42 christos Exp $") +FILE_RCSID("@(#)$File: readcdf.c,v 1.65 2017/04/08 20:58:03 christos Exp $") #endif #include <assert.h> @@ -152,7 +152,7 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info, struct timespec ts; char buf[64]; const char *str = NULL; - const char *s; + const char *s, *e; int len; if (!NOTMIME(ms) && root_storage) @@ -199,7 +199,9 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info, if (info[i].pi_type == CDF_LENGTH32_WSTRING) k++; s = info[i].pi_str.s_buf; - for (j = 0; j < sizeof(vbuf) && len--; s += k) { + e = info[i].pi_str.s_buf + len; + for (j = 0; s < e && j < sizeof(vbuf) + && len--; s += k) { if (*s == '\0') break; if (isprint((unsigned char)*s)) @@ -603,7 +605,7 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf, if ((i = cdf_read_user_stream(&info, &h, &sat, &ssat, &sst, &dir, "FileHeader", &scn)) != -1) { #define HWP5_SIGNATURE "HWP Document File" - if (scn.sst_dirlen >= sizeof(HWP5_SIGNATURE) - 1 + if (scn.sst_len * scn.sst_ss >= sizeof(HWP5_SIGNATURE) - 1 && memcmp(scn.sst_tab, HWP5_SIGNATURE, sizeof(HWP5_SIGNATURE) - 1) == 0) { if (NOTMIME(ms)) { diff --git contrib/file/src/readelf.c contrib/file/src/readelf.c index 90dae392f699..5f425c974e76 100644 --- contrib/file/src/readelf.c +++ contrib/file/src/readelf.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: readelf.c,v 1.128 2016/10/04 21:43:10 christos Exp $") +FILE_RCSID("@(#)$File: readelf.c,v 1.138 2017/08/27 07:55:02 christos Exp $") #endif #ifdef BUILTIN_ELF @@ -310,16 +310,18 @@ private const char os_style_names[][8] = { "NetBSD", }; -#define FLAGS_DID_CORE 0x001 -#define FLAGS_DID_OS_NOTE 0x002 -#define FLAGS_DID_BUILD_ID 0x004 -#define FLAGS_DID_CORE_STYLE 0x008 -#define FLAGS_DID_NETBSD_PAX 0x010 -#define FLAGS_DID_NETBSD_MARCH 0x020 -#define FLAGS_DID_NETBSD_CMODEL 0x040 -#define FLAGS_DID_NETBSD_UNKNOWN 0x080 -#define FLAGS_IS_CORE 0x100 -#define FLAGS_DID_AUXV 0x200 +#define FLAGS_CORE_STYLE 0x003 + +#define FLAGS_DID_CORE 0x004 +#define FLAGS_DID_OS_NOTE 0x008 +#define FLAGS_DID_BUILD_ID 0x010 +#define FLAGS_DID_CORE_STYLE 0x020 +#define FLAGS_DID_NETBSD_PAX 0x040 +#define FLAGS_DID_NETBSD_MARCH 0x080 +#define FLAGS_DID_NETBSD_CMODEL 0x100 +#define FLAGS_DID_NETBSD_UNKNOWN 0x200 +#define FLAGS_IS_CORE 0x400 +#define FLAGS_DID_AUXV 0x800 private int dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off, @@ -509,7 +511,7 @@ do_bid_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, size_t noff, size_t doff, int *flags) { if (namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 && - type == NT_GNU_BUILD_ID && (descsz >= 4 || descsz <= 20)) { + type == NT_GNU_BUILD_ID && (descsz >= 4 && descsz <= 20)) { uint8_t desc[20]; const char *btype; uint32_t i; @@ -709,32 +711,30 @@ do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, == -1) return 1; *flags |= FLAGS_DID_CORE_STYLE; + *flags |= os_style; } switch (os_style) { case OS_STYLE_NETBSD: if (type == NT_NETBSD_CORE_PROCINFO) { char sbuf[512]; - uint32_t signo; - /* - * Extract the program name. It is at - * offset 0x7c, and is up to 32-bytes, - * including the terminating NUL. - */ - if (file_printf(ms, ", from '%.31s'", + struct NetBSD_elfcore_procinfo pi; + memset(&pi, 0, sizeof(pi)); + memcpy(&pi, nbuf + doff, descsz); + + if (file_printf(ms, ", from '%.31s', pid=%u, uid=%u, " + "gid=%u, nlwps=%u, lwp=%u (signal %u/code %u)", file_printable(sbuf, sizeof(sbuf), - (const char *)&nbuf[doff + 0x7c])) == -1) - return 1; - - /* - * Extract the signal number. It is at - * offset 0x08. - */ - (void)memcpy(&signo, &nbuf[doff + 0x08], - sizeof(signo)); - if (file_printf(ms, " (signal %u)", - elf_getu32(swap, signo)) == -1) + CAST(char *, pi.cpi_name)), + elf_getu32(swap, pi.cpi_pid), + elf_getu32(swap, pi.cpi_euid), + elf_getu32(swap, pi.cpi_egid), + elf_getu32(swap, pi.cpi_nlwps), + elf_getu32(swap, pi.cpi_siglwp), + elf_getu32(swap, pi.cpi_signo), + elf_getu32(swap, pi.cpi_sigcode)) == -1) return 1; + *flags |= FLAGS_DID_CORE; return 1; } @@ -890,7 +890,7 @@ get_string_on_virtaddr(struct magic_set *ms, offset = get_offset_from_virtaddr(ms, swap, clazz, fd, ph_off, ph_num, fsize, virtaddr); - if ((buflen = pread(fd, buf, buflen, offset)) <= 0) { + if ((buflen = pread(fd, buf, CAST(size_t, buflen), offset)) <= 0) { file_badread(ms); return 0; } @@ -924,8 +924,28 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, int is_string; size_t nval; - if (type != NT_AUXV || (*flags & FLAGS_IS_CORE) == 0) + if ((*flags & (FLAGS_IS_CORE|FLAGS_DID_CORE_STYLE)) != + (FLAGS_IS_CORE|FLAGS_DID_CORE_STYLE)) + return 0; + + switch (*flags & FLAGS_CORE_STYLE) { + case OS_STYLE_SVR4: + if (type != NT_AUXV) + return 0; + break; +#ifdef notyet + case OS_STYLE_NETBSD: + if (type != NT_NETBSD_CORE_AUXV) + return 0; + break; + case OS_STYLE_FREEBSD: + if (type != NT_FREEBSD_PROCSTAT_AUXV) + return 0; + break; +#endif + default: return 0; + } *flags |= FLAGS_DID_AUXV; @@ -1031,13 +1051,13 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, } if (namesz & 0x80000000) { - (void)file_printf(ms, ", bad note name size 0x%lx", + (void)file_printf(ms, ", bad note name size %#lx", (unsigned long)namesz); return 0; } if (descsz & 0x80000000) { - (void)file_printf(ms, ", bad note description size 0x%lx", + (void)file_printf(ms, ", bad note description size %#lx", (unsigned long)descsz); return 0; } @@ -1185,12 +1205,12 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, { Elf32_Shdr sh32; Elf64_Shdr sh64; - int stripped = 1; + int stripped = 1, has_debug_info = 0; size_t nbadcap = 0; void *nbuf; off_t noff, coff, name_off; - uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilites */ - uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilites */ + uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilities */ + uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilities */ char name[50]; ssize_t namesize; @@ -1203,8 +1223,9 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, /* Read offset of name section to be able to read section names later */ if (pread(fd, xsh_addr, xsh_sizeof, CAST(off_t, (off + size * strtab))) < (ssize_t)xsh_sizeof) { - file_badread(ms); - return -1; + if (file_printf(ms, ", missing section headers") == -1) + return -1; + return 0; } name_off = xsh_offset; @@ -1215,8 +1236,10 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, return -1; } name[namesize] = '\0'; - if (strcmp(name, ".debug_info") == 0) + if (strcmp(name, ".debug_info") == 0) { + has_debug_info = 1; stripped = 0; + } if (pread(fd, xsh_addr, xsh_sizeof, off) < (ssize_t)xsh_sizeof) { file_badread(ms); @@ -1247,9 +1270,9 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, if ((uintmax_t)(xsh_size + xsh_offset) > (uintmax_t)fsize) { if (file_printf(ms, - ", note offset/size 0x%" INTMAX_T_FORMAT - "x+0x%" INTMAX_T_FORMAT "x exceeds" - " file size 0x%" INTMAX_T_FORMAT "x", + ", note offset/size %#" INTMAX_T_FORMAT + "x+%#" INTMAX_T_FORMAT "x exceeds" + " file size %#" INTMAX_T_FORMAT "x", (uintmax_t)xsh_offset, (uintmax_t)xsh_size, (uintmax_t)fsize) == -1) return -1; @@ -1353,7 +1376,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, default: if (file_printf(ms, ", with unknown capability " - "0x%" INT64_T_FORMAT "x = 0x%" + "%#" INT64_T_FORMAT "x = %#" INT64_T_FORMAT "x", (unsigned long long)xcap_tag, (unsigned long long)xcap_val) == -1) @@ -1370,6 +1393,10 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, } } + if (has_debug_info) { + if (file_printf(ms, ", with debug_info") == -1) + return -1; + } if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1) return -1; if (cap_hw1) { @@ -1403,13 +1430,13 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, } if (cap_hw1) if (file_printf(ms, - " unknown hardware capability 0x%" + " unknown hardware capability %#" INT64_T_FORMAT "x", (unsigned long long)cap_hw1) == -1) return -1; } else { if (file_printf(ms, - " hardware capability 0x%" INT64_T_FORMAT "x", + " hardware capability %#" INT64_T_FORMAT "x", (unsigned long long)cap_hw1) == -1) return -1; } @@ -1425,7 +1452,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, cap_sf1 &= ~SF1_SUNW_MASK; if (cap_sf1) if (file_printf(ms, - ", with unknown software capability 0x%" + ", with unknown software capability %#" INT64_T_FORMAT "x", (unsigned long long)cap_sf1) == -1) return -1; @@ -1479,7 +1506,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, if (((align = xph_align) & 0x80000000UL) != 0 || align < 4) { if (file_printf(ms, - ", invalid note alignment 0x%lx", + ", invalid note alignment %#lx", (unsigned long)align) == -1) return -1; align = 4; diff --git contrib/file/src/readelf.h contrib/file/src/readelf.h index f443b298585c..ef880b9cbe22 100644 --- contrib/file/src/readelf.h +++ contrib/file/src/readelf.h @@ -141,7 +141,7 @@ typedef struct { #define SHT_SYMTAB 2 #define SHT_NOTE 7 #define SHT_DYNSYM 11 -#define SHT_SUNW_cap 0x6ffffff5 /* SunOS 5.x hw/sw capabilites */ +#define SHT_SUNW_cap 0x6ffffff5 /* SunOS 5.x hw/sw capabilities */ /* elf type */ #define ELFDATANONE 0 /* e_ident[EI_DATA] */ @@ -230,6 +230,33 @@ typedef struct { } Elf64_Shdr; #define NT_NETBSD_CORE_PROCINFO 1 +#define NT_NETBSD_CORE_AUXV 2 + +struct NetBSD_elfcore_procinfo { + /* Version 1 fields start here. */ + uint32_t cpi_version; /* our version */ + uint32_t cpi_cpisize; /* sizeof(this struct) */ + uint32_t cpi_signo; /* killing signal */ + uint32_t cpi_sigcode; /* signal code */ + uint32_t cpi_sigpend[4]; /* pending signals */ + uint32_t cpi_sigmask[4]; /* blocked signals */ + uint32_t cpi_sigignore[4]; /* ignored signals */ + uint32_t cpi_sigcatch[4]; /* caught signals */ + int32_t cpi_pid; /* process ID */ + int32_t cpi_ppid; /* parent process ID */ + int32_t cpi_pgrp; /* process group ID */ + int32_t cpi_sid; /* session ID */ + uint32_t cpi_ruid; /* real user ID */ + uint32_t cpi_euid; /* effective user ID */ + uint32_t cpi_svuid; /* saved user ID */ + uint32_t cpi_rgid; /* real group ID */ + uint32_t cpi_egid; /* effective group ID */ + uint32_t cpi_svgid; /* saved group ID */ + uint32_t cpi_nlwps; /* number of LWPs */ + int8_t cpi_name[32]; /* copy of p->p_comm */ + /* Add version 2 fields below here. */ + int32_t cpi_siglwp; /* LWP target of killing signal */ +}; /* Note header in a PT_NOTE section */ typedef struct elf_note { @@ -328,6 +355,11 @@ typedef struct { */ #define NT_NETBSD_CMODEL 6 +/* + * FreeBSD specific notes + */ +#define NT_FREEBSD_PROCSTAT_AUXV 16 + #if !defined(ELFSIZE) && defined(ARCH_ELFSIZE) #define ELFSIZE ARCH_ELFSIZE #endif diff --git contrib/file/src/softmagic.c contrib/file/src/softmagic.c index 0e9d433ddd99..b9e975374b40 100644 --- contrib/file/src/softmagic.c +++ contrib/file/src/softmagic.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: softmagic.c,v 1.238 2016/10/24 18:02:17 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.249 2017/06/19 18:30:25 christos Exp $") #endif /* lint */ #include "magic.h" @@ -192,6 +192,7 @@ flush: while (magindex < nmagic - 1 && magic[magindex + 1].cont_level != 0) magindex++; + cont_level = 0; continue; /* Skip to next top-level test*/ } @@ -370,6 +371,7 @@ flush: case -1: case 0: flush = 1; + cont_level--; break; default: break; @@ -1017,9 +1019,8 @@ private int mconvert(struct magic_set *ms, struct magic *m, int flip) { union VALUETYPE *p = &ms->ms_value; - uint8_t type; - switch (type = cvt_flip(m->type, flip)) { + switch (cvt_flip(m->type, flip)) { case FILE_BYTE: if (cvt_8(p, m) == -1) goto out; @@ -1184,7 +1185,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, case FILE_DER: case FILE_SEARCH: if (offset > nbytes) - offset = nbytes; + offset = CAST(uint32_t, nbytes); ms->search.s = RCAST(const char *, s) + offset; ms->search.s_len = nbytes - offset; ms->search.offset = offset; @@ -1198,7 +1199,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, const char *end; size_t lines, linecnt, bytecnt; - if (s == NULL) { + if (s == NULL || nbytes < offset) { ms->search.s_len = 0; ms->search.s = NULL; return 0; @@ -1260,7 +1261,8 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, if (*dst == '\0') { if (type == FILE_BESTRING16 ? *(src - 1) != '\0' : - *(src + 1) != '\0') + ((src + 1 < esrc) && + *(src + 1) != '\0')) *dst = ' '; } } @@ -1365,7 +1367,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m, return -1; if ((ms->flags & MAGIC_DEBUG) != 0) { - fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%" + fprintf(stderr, "mget(type=%d, flag=%#x, offset=%u, o=%" SIZE_T_FORMAT "u, " "nbytes=%" SIZE_T_FORMAT "u, il=%hu, nc=%hu)\n", m->type, m->flag, offset, o, nbytes, @@ -1632,6 +1634,7 @@ file_strncmp(const char *s1, const char *s2, size_t len, uint32_t flags) */ const unsigned char *a = (const unsigned char *)s1; const unsigned char *b = (const unsigned char *)s2; + const unsigned char *eb = b + len; uint64_t v; /* @@ -1646,6 +1649,10 @@ file_strncmp(const char *s1, const char *s2, size_t len, uint32_t flags) } else { /* combine the others */ while (len-- > 0) { + if (b >= eb) { + v = 1; + break; + } if ((flags & STRING_IGNORE_LOWERCASE) && islower(*a)) { if ((v = tolower(*b++) - *a++) != '\0') @@ -1661,7 +1668,7 @@ file_strncmp(const char *s1, const char *s2, size_t len, uint32_t flags) a++; if (isspace(*b++)) { if (!isspace(*a)) - while (isspace(*b)) + while (b < eb && isspace(*b)) b++; } else { @@ -1672,7 +1679,7 @@ file_strncmp(const char *s1, const char *s2, size_t len, uint32_t flags) else if ((flags & STRING_COMPACT_OPTIONAL_WHITESPACE) && isspace(*a)) { a++; - while (isspace(*b)) + while (b < eb && isspace(*b)) b++; } else { @@ -1843,13 +1850,13 @@ magiccheck(struct magic_set *ms, struct magic *m) for (idx = 0; m->str_range == 0 || idx < m->str_range; idx++) { if (slen + idx > ms->search.s_len) - break; + return 0; v = file_strncmp(m->value.s, ms->search.s + idx, slen, m->str_flags); if (v == 0) { /* found match */ ms->search.offset += idx; - ms->search.rm_len = m->str_range - idx; + ms->search.rm_len = ms->search.s_len - idx; break; } } @@ -1887,7 +1894,7 @@ magiccheck(struct magic_set *ms, struct magic *m) copy[--slen] = '\0'; search = copy; } else { - search = ms->search.s; + search = CCAST(char *, ""); copy = NULL; } rc = file_regexec(&rx, (const char *)search, diff --git contrib/file/src/vasprintf.c contrib/file/src/vasprintf.c index 7a18bed763b6..ad1d3165534d 100644 --- contrib/file/src/vasprintf.c +++ contrib/file/src/vasprintf.c @@ -88,7 +88,7 @@ type: d i o u x X f e g E G c s p n The function needs to allocate memory to store the full text before to -actually writting it. i.e if you want to fnprintf() 1000 characters, the +actually writing it. i.e if you want to fnprintf() 1000 characters, the functions will allocate 1000 bytes. This behaviour can be modified: you have to customise the code to flush the internal buffer (writing to screen or file) when it reach a given size. Then @@ -108,7 +108,7 @@ you use strange formats. #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: vasprintf.c,v 1.13 2014/12/04 15:56:46 christos Exp $") +FILE_RCSID("@(#)$File: vasprintf.c,v 1.14 2017/08/13 00:21:47 christos Exp $") #endif /* lint */ #include <assert.h> diff --git contrib/file/tests/Makefile.am contrib/file/tests/Makefile.am index 46c02e820b9f..8bf4f27cef5d 100644 --- contrib/file/tests/Makefile.am +++ contrib/file/tests/Makefile.am @@ -1,12 +1,14 @@ check_PROGRAMS = test test_LDADD = $(top_builddir)/src/libmagic.la -test_CPPFLAGS = -I$(top_srcdir)/src +test_CPPFLAGS = -I$(top_builddir)/src EXTRA_DIST = \ escapevel.result \ escapevel.testfile \ gedcom.result \ gedcom.testfile \ +hddrawcopytool.result \ +hddrawcopytool.testfile \ issue311docx.result \ issue311docx.testfile diff --git contrib/file/tests/Makefile.in contrib/file/tests/Makefile.in index 92f623e8454b..094034c69993 100644 --- contrib/file/tests/Makefile.in +++ contrib/file/tests/Makefile.in @@ -290,12 +290,14 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ test_LDADD = $(top_builddir)/src/libmagic.la -test_CPPFLAGS = -I$(top_srcdir)/src +test_CPPFLAGS = -I$(top_builddir)/src EXTRA_DIST = \ escapevel.result \ escapevel.testfile \ gedcom.result \ gedcom.testfile \ +hddrawcopytool.result \ +hddrawcopytool.testfile \ issue311docx.result \ issue311docx.testfile diff --git contrib/file/tests/hddrawcopytool.result contrib/file/tests/hddrawcopytool.result new file mode 100644 index 000000000000..0fe077dca388 --- /dev/null +++ contrib/file/tests/hddrawcopytool.result @@ -0,0 +1 @@ +HDD Raw Copy Tool 1.10 - HD model: ST500DM0 02-1BD142 serial: 51D20233A7C0 \ No newline at end of file diff --git contrib/file/tests/hddrawcopytool.testfile contrib/file/tests/hddrawcopytool.testfile new file mode 100644 index 000000000000..36ad7c64d148 Binary files /dev/null and contrib/file/tests/hddrawcopytool.testfile differ diff --git contrib/file/tests/test.c contrib/file/tests/test.c index db91c62f2ece..330a357b3d4c 100644 --- contrib/file/tests/test.c +++ contrib/file/tests/test.c @@ -80,7 +80,8 @@ main(int argc, char **argv) return 10; } if (magic_load(ms, NULL) == -1) { - (void)fprintf(stderr, "ERROR loading with NULL file: %s\n", magic_error(ms)); + (void)fprintf(stderr, "ERROR loading with NULL file: %s\n", + magic_error(ms)); return 11; } diff --git contrib/gcc/config/arm/unwind-arm.c contrib/gcc/config/arm/unwind-arm.c index fff5fdf288a8..7c668a3b0de0 100644 --- contrib/gcc/config/arm/unwind-arm.c +++ contrib/gcc/config/arm/unwind-arm.c @@ -625,8 +625,8 @@ __gnu_Unwind_RaiseException (_Unwind_Control_Block * ucbp, do { /* Find the entry for this routine. */ - if (get_eit_entry (ucbp, saved_vrs.core.r[R_PC]) != _URC_OK) - return _URC_FAILURE; + if ((pr_result = get_eit_entry (ucbp, saved_vrs.core.r[R_PC])) != _URC_OK) + return pr_result; /* Call the pr to decide what to do. */ pr_result = ((personality_routine) UCB_PR_ADDR (ucbp)) @@ -773,11 +773,8 @@ __gnu_Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument, do { /* Find the entry for this routine. */ - if (get_eit_entry (ucbp, saved_vrs.core.r[R_PC]) != _URC_OK) - { - code = _URC_FAILURE; + if ((code = get_eit_entry (ucbp, saved_vrs.core.r[R_PC])) != _URC_OK) break; - } /* The dwarf unwinder assumes the context structure holds things like the function and LSDA pointers. The ARM implementation diff --git contrib/jemalloc/include/jemalloc/internal/tsd.h contrib/jemalloc/include/jemalloc/internal/tsd.h index 155a2ec6c44b..fc14f8cea031 100644 --- contrib/jemalloc/include/jemalloc/internal/tsd.h +++ contrib/jemalloc/include/jemalloc/internal/tsd.h @@ -120,7 +120,8 @@ struct tsd_s { t use_a_getter_or_setter_instead_##n; MALLOC_TSD #undef O -}; +/* AddressSanitizer requires TLS data to be aligned to at least 8 bytes. */ +} JEMALLOC_ALIGNED(16); /* * Wrapper around tsd_t that makes it possible to avoid implicit conversion diff --git contrib/libarchive/cat/test/test_empty.zst.uu contrib/libarchive/cat/test/test_empty.zst.uu new file mode 100644 index 000000000000..44ae9a966c13 --- /dev/null +++ contrib/libarchive/cat/test/test_empty.zst.uu @@ -0,0 +1,4 @@ +begin 644 test_empty.zst +-*+4O_010`0``F>G840`` +` +end diff --git sys/boot/arm/at91/libat91/memcpy.c contrib/libarchive/cat/test/test_empty_zstd.c similarity index 65% rename from sys/boot/arm/at91/libat91/memcpy.c rename to contrib/libarchive/cat/test/test_empty_zstd.c index f7544fee64ad..c2d5ea106fa1 100644 --- sys/boot/arm/at91/libat91/memcpy.c +++ contrib/libarchive/cat/test/test_empty_zstd.c @@ -1,5 +1,6 @@ /*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. + * Copyright (c) 2017 Sean Purcell + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,30 +11,31 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * */ +#include "test.h" -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include "lib.h" - -void -memcpy(void *dst, const void *src, unsigned len) +DEFINE_TEST(test_empty_zstd) { - const char *s = src; - char *d = dst; + const char *reffile = "test_empty.zst"; + int f; - while (len--) - *d++ = *s++; + extract_reference_file(reffile); + f = systemf("%s %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canZstd()) { + assertEqualInt(0, f); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems zstd is not supported on this platform"); + } } diff --git contrib/libarchive/cat/test/test_expand.zst.uu contrib/libarchive/cat/test/test_expand.zst.uu new file mode 100644 index 000000000000..89c28b1bc2f8 --- /dev/null +++ contrib/libarchive/cat/test/test_expand.zst.uu @@ -0,0 +1,4 @@ +begin 644 test_expand.zst +J*+4O_010Z0``8V]N=&5N=',@;V8@=&5S=%]E>'!A;F0N>G-T+@J;23#F +` +end diff --git sys/boot/arm/at91/libat91/memcmp.c contrib/libarchive/cat/test/test_expand_zstd.c similarity index 64% rename from sys/boot/arm/at91/libat91/memcmp.c rename to contrib/libarchive/cat/test/test_expand_zstd.c index 322042f23cf2..23d918252ad1 100644 --- sys/boot/arm/at91/libat91/memcmp.c +++ contrib/libarchive/cat/test/test_expand_zstd.c @@ -1,5 +1,6 @@ /*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. + * Copyright (c) 2017 Sean Purcell + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,29 +11,31 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * */ +#include "test.h" -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include "lib.h" - -int -p_memcmp(const char *to, const char *from, unsigned size) +DEFINE_TEST(test_expand_zstd) { - while ((--size) && (*to++ == *from++)) - continue; + const char *reffile = "test_expand.zst"; + int f; - return (size || (*to != *from)); + extract_reference_file(reffile); + f = systemf("%s %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canZstd()) { + assertEqualInt(0, f); + assertTextFileContents("contents of test_expand.zst.\n", "test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems zstd is not supported on this platform"); + } } diff --git contrib/libarchive/cpio/bsdcpio.1 contrib/libarchive/cpio/bsdcpio.1 index e52546e6f761..786a717097ed 100644 --- contrib/libarchive/cpio/bsdcpio.1 +++ contrib/libarchive/cpio/bsdcpio.1 @@ -187,6 +187,11 @@ In input mode, this option is ignored. Compress the archive with lz4-compatible compression before writing it. In input mode, this option is ignored; lz4 compression is recognized automatically on input. +.It Fl Fl zstd +(o mode only) +Compress the archive with zstd-compatible compression before writing it. +In input mode, this option is ignored; zstd compression is recognized +automatically on input. .It Fl Fl lzma (o mode only) Compress the file with lzma-compatible compression before writing it. diff --git contrib/libarchive/cpio/cmdline.c contrib/libarchive/cpio/cmdline.c index f37fe5e8431e..830caf659a07 100644 --- contrib/libarchive/cpio/cmdline.c +++ contrib/libarchive/cpio/cmdline.c @@ -92,6 +92,7 @@ static const struct option { { "verbose", 0, 'v' }, { "version", 0, OPTION_VERSION }, { "xz", 0, 'J' }, + { "zstd", 0, OPTION_ZSTD }, { NULL, 0, 0 } }; diff --git contrib/libarchive/cpio/cpio.c contrib/libarchive/cpio/cpio.c index cade829571bb..8396f1f98ce1 100644 --- contrib/libarchive/cpio/cpio.c +++ contrib/libarchive/cpio/cpio.c @@ -269,6 +269,7 @@ main(int argc, char *argv[]) case OPTION_LZ4: case OPTION_LZMA: /* GNU tar, others */ case OPTION_LZOP: /* GNU tar, others */ + case OPTION_ZSTD: cpio->compress = opt; break; case 'm': /* POSIX 1997 */ @@ -546,6 +547,9 @@ mode_out(struct cpio *cpio) case OPTION_LZOP: r = archive_write_add_filter_lzop(cpio->archive); break; + case OPTION_ZSTD: + r = archive_write_add_filter_zstd(cpio->archive); + break; case 'j': case 'y': r = archive_write_add_filter_bzip2(cpio->archive); break; diff --git contrib/libarchive/cpio/cpio.h contrib/libarchive/cpio/cpio.h index a383560bcf7b..b10f387be0e3 100644 --- contrib/libarchive/cpio/cpio.h +++ contrib/libarchive/cpio/cpio.h @@ -111,7 +111,8 @@ enum { OPTION_PRESERVE_OWNER, OPTION_QUIET, OPTION_UUENCODE, - OPTION_VERSION + OPTION_VERSION, + OPTION_ZSTD, }; int cpio_getopt(struct cpio *cpio); diff --git contrib/libarchive/cpio/test/test_extract.cpio.zst.uu contrib/libarchive/cpio/test/test_extract.cpio.zst.uu new file mode 100644 index 000000000000..5ec854b85d28 --- /dev/null +++ contrib/libarchive/cpio/test/test_extract.cpio.zst.uu @@ -0,0 +1,6 @@ +begin 644 test_extract.cpio.zst +M*+4O_01090,`,@41%X")&@#'G6T\K16_MR)#=DK)5:.1,2J0HY2"!(1!`!7R +M$(UB`2"*D41;J2UF&)<0!Y7X'TU<%W.\W^R]GO-WW^OO^QX0`%P<]30-!#U` +?!KD!`#XP,_`U4`HT3+RF:#!7Y\V@R)5"7P"^;WEUK@`` +` +end diff --git sys/boot/arm/at91/libat91/strcmp.c contrib/libarchive/cpio/test/test_extract_cpio_zstd.c similarity index 56% rename from sys/boot/arm/at91/libat91/strcmp.c rename to contrib/libarchive/cpio/test/test_extract_cpio_zstd.c index de1d9e0c1e0b..289f33d0583c 100644 --- sys/boot/arm/at91/libat91/strcmp.c +++ contrib/libarchive/cpio/test/test_extract_cpio_zstd.c @@ -1,5 +1,6 @@ /*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. + * Copyright (c) 2017 Sean Purcell + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,27 +11,38 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * */ - -#include <sys/cdefs.h> +#include "test.h" __FBSDID("$FreeBSD$"); -#include "lib.h" - -int -strcmp(const char *s1, const char *s2) +DEFINE_TEST(test_extract_cpio_zstd) { - for (; *s1 == *s2 && *s1; s1++, s2++); - return (unsigned char)*s1 - (unsigned char)*s2; + const char *reffile = "test_extract.cpio.zst"; + int f; + + extract_reference_file(reffile); + f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canZstd()) { + assertEqualInt(0, systemf("%s -i < %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertTextFileContents("1 block\n", "test.err"); + } else { + skipping("It seems zstd is not supported on this platform"); + } } diff --git contrib/libarchive/cpio/test/test_option_zstd.c contrib/libarchive/cpio/test/test_option_zstd.c new file mode 100644 index 000000000000..29b8c78b94aa --- /dev/null +++ contrib/libarchive/cpio/test/test_option_zstd.c @@ -0,0 +1,85 @@ +/*- + * Copyright (c) 2017 Sean Purcell + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "test.h" +__FBSDID("$FreeBSD$"); + +DEFINE_TEST(test_option_zstd) +{ + char *p; + int r; + size_t s; + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Archive it with zstd compression. */ + r = systemf("echo f | %s -o --zstd >archive.out 2>archive.err", + testprog); + p = slurpfile(&s, "archive.err"); + p[s] = '\0'; + if (r != 0) { + if (strstr(p, "Unsupported compression") != NULL) { + skipping("This version of bsdcpio was compiled " + "without zstd support"); + goto done; + } + /* POSIX permits different handling of the spawnp + * system call used to launch the subsidiary + * program: */ + /* Some systems fail immediately to spawn the new process. */ + if (strstr(p, "Can't launch") != NULL && !canZstd()) { + skipping("This version of bsdcpio uses an external zstd program " + "but no such program is available on this system."); + goto done; + } + /* Some systems successfully spawn the new process, + * but fail to exec a program within that process. + * This results in failure at the first attempt to + * write. */ + if (strstr(p, "Can't write") != NULL && !canZstd()) { + skipping("This version of bsdcpio uses an external zstd program " + "but no such program is available on this system."); + goto done; + } + /* On some systems the error won't be detected until closing + time, by a 127 exit error returned by waitpid. */ + if (strstr(p, "Error closing") != NULL && !canZstd()) { + skipping("This version of bsdcpio uses an external zstd program " + "but no such program is available on this system."); + return; + } + failure("--zstd option is broken: %s", p); + assertEqualInt(r, 0); + goto done; + } + free(p); + /* Check that the archive file has an zstd signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "\x28\xb5\x2f\xfd", 4); + +done: + free(p); +} diff --git contrib/libarchive/libarchive/archive.h contrib/libarchive/libarchive/archive.h index c3681e60c50a..46938ad20cdf 100644 --- contrib/libarchive/libarchive/archive.h +++ contrib/libarchive/libarchive/archive.h @@ -177,6 +177,7 @@ __LA_DECL const char * archive_zlib_version(void); __LA_DECL const char * archive_liblzma_version(void); __LA_DECL const char * archive_bzlib_version(void); __LA_DECL const char * archive_liblz4_version(void); +__LA_DECL const char * archive_libzstd_version(void); /* Declare our basic types. */ struct archive; @@ -276,6 +277,7 @@ typedef const char *archive_passphrase_callback(struct archive *, #define ARCHIVE_FILTER_LZOP 11 #define ARCHIVE_FILTER_GRZIP 12 #define ARCHIVE_FILTER_LZ4 13 +#define ARCHIVE_FILTER_ZSTD 14 #if ARCHIVE_VERSION_NUMBER < 4000000 #define ARCHIVE_COMPRESSION_NONE ARCHIVE_FILTER_NONE @@ -433,6 +435,7 @@ __LA_DECL int archive_read_support_filter_program_signature __LA_DECL int archive_read_support_filter_rpm(struct archive *); __LA_DECL int archive_read_support_filter_uu(struct archive *); __LA_DECL int archive_read_support_filter_xz(struct archive *); +__LA_DECL int archive_read_support_filter_zstd(struct archive *); __LA_DECL int archive_read_support_format_7zip(struct archive *); __LA_DECL int archive_read_support_format_all(struct archive *); @@ -778,6 +781,7 @@ __LA_DECL int archive_write_add_filter_program(struct archive *, const char *cmd); __LA_DECL int archive_write_add_filter_uuencode(struct archive *); __LA_DECL int archive_write_add_filter_xz(struct archive *); +__LA_DECL int archive_write_add_filter_zstd(struct archive *); /* A convenience function to set the format based on the code or name. */ diff --git contrib/libarchive/libarchive/archive_cmdline.c contrib/libarchive/libarchive/archive_cmdline.c index 7d3bac53bb5c..5c519cd17f1b 100644 --- contrib/libarchive/libarchive/archive_cmdline.c +++ contrib/libarchive/libarchive/archive_cmdline.c @@ -100,10 +100,10 @@ get_argument(struct archive_string *as, const char *p) /* * Set up command line arguments. - * Returns ARChIVE_OK if everything okey. - * Returns ARChIVE_FAILED if there is a lack of the `"' terminator or an + * Returns ARCHIVE_OK if everything okey. + * Returns ARCHIVE_FAILED if there is a lack of the `"' terminator or an * empty command line. - * Returns ARChIVE_FATAL if no memory. + * Returns ARCHIVE_FATAL if no memory. */ int __archive_cmdline_parse(struct archive_cmdline *data, const char *cmd) diff --git contrib/libarchive/libarchive/archive_platform.h contrib/libarchive/libarchive/archive_platform.h index 692238277a84..3ade7887222a 100644 --- contrib/libarchive/libarchive/archive_platform.h +++ contrib/libarchive/libarchive/archive_platform.h @@ -52,6 +52,17 @@ #error Oops: No config.h and no pre-built configuration in archive_platform.h. #endif +/* On macOS check for some symbols based on the deployment target version. */ +#if defined(__APPLE__) +# undef HAVE_FUTIMENS +# undef HAVE_UTIMENSAT +# include <AvailabilityMacros.h> +# if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 +# define HAVE_FUTIMENS 1 +# define HAVE_UTIMENSAT 1 +# endif +#endif + /* It should be possible to get rid of this by extending the feature-test * macros to cover Windows API functions, probably along with non-trivial * refactoring of code to find structures that sit more cleanly on top of diff --git contrib/libarchive/libarchive/archive_read_append_filter.c contrib/libarchive/libarchive/archive_read_append_filter.c index 5e4d16307987..da7c55b9b088 100644 --- contrib/libarchive/libarchive/archive_read_append_filter.c +++ contrib/libarchive/libarchive/archive_read_append_filter.c @@ -89,6 +89,10 @@ archive_read_append_filter(struct archive *_a, int code) strcpy(str, "lz4"); r1 = archive_read_support_filter_lz4(_a); break; + case ARCHIVE_FILTER_ZSTD: + strcpy(str, "zstd"); + r1 = archive_read_support_filter_zstd(_a); + break; case ARCHIVE_FILTER_LZIP: strcpy(str, "lzip"); r1 = archive_read_support_filter_lzip(_a); diff --git contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c index 548ba89ef3db..1786cff38453 100644 --- contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c +++ contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c @@ -127,7 +127,7 @@ archive_read_disk_entry_setup_acls(struct archive_read_disk *a, /* * Enter working directory and return working pathname of archive_entry. * If a pointer to an integer is provided and its value is below zero - * open a file descriptor on this pahtname. + * open a file descriptor on this pathname. */ const char * archive_read_disk_entry_setup_path(struct archive_read_disk *a, diff --git contrib/libarchive/libarchive/archive_read_filter.3 contrib/libarchive/libarchive/archive_read_filter.3 index 7f020e3734b8..ef0a70175332 100644 --- contrib/libarchive/libarchive/archive_read_filter.3 +++ contrib/libarchive/libarchive/archive_read_filter.3 @@ -38,6 +38,7 @@ .Nm archive_read_support_filter_rpm , .Nm archive_read_support_filter_uu , .Nm archive_read_support_filter_xz , +.Nm archive_read_support_filter_zstd , .Nm archive_read_support_filter_program , .Nm archive_read_support_filter_program_signature .Nd functions for reading streaming archives @@ -73,6 +74,8 @@ Streaming Archive Library (libarchive, -larchive) .Ft int .Fn archive_read_support_filter_xz "struct archive *" .Ft int +.Fn archive_read_support_filter_zstd "struct archive *" +.Ft int .Fo archive_read_support_filter_program .Fa "struct archive *" .Fa "const char *cmd" @@ -99,7 +102,8 @@ Streaming Archive Library (libarchive, -larchive) .Fn archive_read_support_filter_none , .Fn archive_read_support_filter_rpm , .Fn archive_read_support_filter_uu , -.Fn archive_read_support_filter_xz +.Fn archive_read_support_filter_xz , +.Fn archive_read_support_filter_zstd , .Xc Enables auto-detection code and decompression support for the specified compression. diff --git contrib/libarchive/libarchive/archive_read_support_filter_all.c contrib/libarchive/libarchive/archive_read_support_filter_all.c index 68c53de41f2d..edb508c1dfd8 100644 --- contrib/libarchive/libarchive/archive_read_support_filter_all.c +++ contrib/libarchive/libarchive/archive_read_support_filter_all.c @@ -71,6 +71,8 @@ archive_read_support_filter_all(struct archive *a) archive_read_support_filter_grzip(a); /* Lz4 falls back to "lz4 -d" command-line program. */ archive_read_support_filter_lz4(a); + /* Zstd falls back to "zstd -d" command-line program. */ + archive_read_support_filter_zstd(a); /* Note: We always return ARCHIVE_OK here, even if some of the * above return ARCHIVE_WARN. The intent here is to enable diff --git contrib/libarchive/libarchive/archive_read_support_filter_zstd.c contrib/libarchive/libarchive/archive_read_support_filter_zstd.c new file mode 100644 index 000000000000..c8bb36be703c --- /dev/null +++ contrib/libarchive/libarchive/archive_read_support_filter_zstd.c @@ -0,0 +1,292 @@ +/*- + * Copyright (c) 2009-2011 Sean Purcell + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "archive_platform.h" + +__FBSDID("$FreeBSD$"); + +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif + +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif +#include <stdio.h> +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#if HAVE_ZSTD_H +#include <zstd.h> +#endif + +#include "archive.h" +#include "archive_endian.h" +#include "archive_private.h" +#include "archive_read_private.h" + +#if HAVE_ZSTD_H && HAVE_LIBZSTD + +struct private_data { + ZSTD_DStream *dstream; + unsigned char *out_block; + size_t out_block_size; + int64_t total_out; + char in_frame; /* True = in the middle of a zstd frame. */ + char eof; /* True = found end of compressed data. */ +}; + +/* Zstd Filter. */ +static ssize_t zstd_filter_read(struct archive_read_filter *, const void**); +static int zstd_filter_close(struct archive_read_filter *); +#endif + +/* + * Note that we can detect zstd compressed files even if we can't decompress + * them. (In fact, we like detecting them because we can give better error + * messages.) So the bid framework here gets compiled even if no zstd library + * is available. + */ +static int zstd_bidder_bid(struct archive_read_filter_bidder *, + struct archive_read_filter *); +static int zstd_bidder_init(struct archive_read_filter *); + +int +archive_read_support_filter_zstd(struct archive *_a) +{ + struct archive_read *a = (struct archive_read *)_a; + struct archive_read_filter_bidder *bidder; + + archive_check_magic(_a, ARCHIVE_READ_MAGIC, + ARCHIVE_STATE_NEW, "archive_read_support_filter_zstd"); + + if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK) + return (ARCHIVE_FATAL); + + bidder->data = NULL; + bidder->name = "zstd"; + bidder->bid = zstd_bidder_bid; + bidder->init = zstd_bidder_init; + bidder->options = NULL; + bidder->free = NULL; +#if HAVE_ZSTD_H && HAVE_LIBZSTD + return (ARCHIVE_OK); +#else + archive_set_error(_a, ARCHIVE_ERRNO_MISC, + "Using external zstd program for zstd decompression"); + return (ARCHIVE_WARN); +#endif +} + +/* + * Test whether we can handle this data. + */ +static int +zstd_bidder_bid(struct archive_read_filter_bidder *self, + struct archive_read_filter *filter) +{ + const unsigned char *buffer; + ssize_t avail; + unsigned prefix; + + /* Zstd frame magic values */ + const unsigned zstd_magic = 0xFD2FB528U; + + (void) self; /* UNUSED */ + + buffer = __archive_read_filter_ahead(filter, 4, &avail); + if (buffer == NULL) + return (0); + + prefix = archive_le32dec(buffer); + if (prefix == zstd_magic) + return (32); + + return (0); +} + +#if !(HAVE_ZSTD_H && HAVE_LIBZSTD) + +/* + * If we don't have the library on this system, we can't do the + * decompression directly. We can, however, try to run "zstd -d" + * in case that's available. + */ +static int +zstd_bidder_init(struct archive_read_filter *self) +{ + int r; + + r = __archive_read_program(self, "zstd -d -qq"); + /* Note: We set the format here even if __archive_read_program() + * above fails. We do, after all, know what the format is + * even if we weren't able to read it. */ + self->code = ARCHIVE_FILTER_ZSTD; + self->name = "zstd"; + return (r); +} + +#else + +/* + * Initialize the filter object + */ +static int +zstd_bidder_init(struct archive_read_filter *self) +{ + struct private_data *state; + const size_t out_block_size = ZSTD_DStreamOutSize(); + void *out_block; + ZSTD_DStream *dstream; + + self->code = ARCHIVE_FILTER_ZSTD; + self->name = "zstd"; + + state = (struct private_data *)calloc(sizeof(*state), 1); + out_block = (unsigned char *)malloc(out_block_size); + dstream = ZSTD_createDStream(); + + if (state == NULL || out_block == NULL || dstream == NULL) { + free(out_block); + free(state); + ZSTD_freeDStream(dstream); /* supports free on NULL */ + archive_set_error(&self->archive->archive, ENOMEM, + "Can't allocate data for zstd decompression"); + return (ARCHIVE_FATAL); + } + + self->data = state; + + state->out_block_size = out_block_size; + state->out_block = out_block; + state->dstream = dstream; + self->read = zstd_filter_read; + self->skip = NULL; /* not supported */ + self->close = zstd_filter_close; + + state->eof = 0; + state->in_frame = 0; + + return (ARCHIVE_OK); +} + +static ssize_t +zstd_filter_read(struct archive_read_filter *self, const void **p) +{ + struct private_data *state; + size_t decompressed; + ssize_t avail_in; + ZSTD_outBuffer out; + ZSTD_inBuffer in; + + state = (struct private_data *)self->data; + + out = (ZSTD_outBuffer) { state->out_block, state->out_block_size, 0 }; + + /* Try to fill the output buffer. */ + while (out.pos < out.size && !state->eof) { + if (!state->in_frame) { + const size_t ret = ZSTD_initDStream(state->dstream); + if (ZSTD_isError(ret)) { + archive_set_error(&self->archive->archive, + ARCHIVE_ERRNO_MISC, + "Error initializing zstd decompressor: %s", + ZSTD_getErrorName(ret)); + return (ARCHIVE_FATAL); + } + } + in.src = __archive_read_filter_ahead(self->upstream, 1, + &avail_in); + if (avail_in < 0) { + return avail_in; + } + if (in.src == NULL && avail_in == 0) { + if (!state->in_frame) { + /* end of stream */ + state->eof = 1; + break; + } else { + archive_set_error(&self->archive->archive, + ARCHIVE_ERRNO_MISC, + "Truncated zstd input"); + return (ARCHIVE_FATAL); + } + } + in.size = avail_in; + in.pos = 0; + + { + const size_t ret = + ZSTD_decompressStream(state->dstream, &out, &in); + + if (ZSTD_isError(ret)) { + archive_set_error(&self->archive->archive, + ARCHIVE_ERRNO_MISC, + "Zstd decompression failed: %s", + ZSTD_getErrorName(ret)); + return (ARCHIVE_FATAL); + } + + /* Decompressor made some progress */ + __archive_read_filter_consume(self->upstream, in.pos); + + /* ret guaranteed to be > 0 if frame isn't done yet */ + state->in_frame = (ret != 0); + } + } + + decompressed = out.pos; + state->total_out += decompressed; + if (decompressed == 0) + *p = NULL; + else + *p = state->out_block; + return (decompressed); +} + +/* + * Clean up the decompressor. + */ +static int +zstd_filter_close(struct archive_read_filter *self) +{ + struct private_data *state; + + state = (struct private_data *)self->data; + + ZSTD_freeDStream(state->dstream); + free(state->out_block); + free(state); + + return (ARCHIVE_OK); +} + +#endif /* HAVE_ZLIB_H && HAVE_LIBZSTD */ diff --git contrib/libarchive/libarchive/archive_read_support_format_cpio.c contrib/libarchive/libarchive/archive_read_support_format_cpio.c index 6b4d241fd34a..665acaeff459 100644 --- contrib/libarchive/libarchive/archive_read_support_format_cpio.c +++ contrib/libarchive/libarchive/archive_read_support_format_cpio.c @@ -633,6 +633,13 @@ header_newc(struct archive_read *a, struct cpio *cpio, /* Pad name to 2 more than a multiple of 4. */ *name_pad = (2 - *namelength) & 3; + /* Make sure that the padded name length fits into size_t. */ + if (*name_pad > SIZE_MAX - *namelength) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "cpio archive has invalid namelength"); + return (ARCHIVE_FATAL); + } + /* * Note: entry_bytes_remaining is at least 64 bits and * therefore guaranteed to be big enough for a 33-bit file diff --git contrib/libarchive/libarchive/archive_read_support_format_mtree.c contrib/libarchive/libarchive/archive_read_support_format_mtree.c index d2770f1cf701..69a62e189bc5 100644 --- contrib/libarchive/libarchive/archive_read_support_format_mtree.c +++ contrib/libarchive/libarchive/archive_read_support_format_mtree.c @@ -77,6 +77,8 @@ __FBSDID("$FreeBSD$"); #define MTREE_HASHTABLE_SIZE 1024 +#define MAX_LINE_LEN (1024 * 1024) + struct mtree_option { struct mtree_option *next; char *value; @@ -334,6 +336,14 @@ next_line(struct archive_read *a, size_t nbytes_req = (*ravail+1023) & ~1023U; ssize_t tested; + /* + * Place an arbitrary limit on the line length. + * mtree is almost free-form input and without line length limits, + * it can consume a lot of memory. + */ + if (len >= MAX_LINE_LEN) + return (-1); + /* Increase reading bytes if it is not enough to at least * new two lines. */ if (nbytes_req < (size_t)*ravail + 160) diff --git contrib/libarchive/libarchive/archive_read_support_format_rar.c contrib/libarchive/libarchive/archive_read_support_format_rar.c index cbb14c32dc3b..751de6979ba5 100644 --- contrib/libarchive/libarchive/archive_read_support_format_rar.c +++ contrib/libarchive/libarchive/archive_read_support_format_rar.c @@ -1496,7 +1496,11 @@ read_header(struct archive_read *a, struct archive_entry *entry, return (ARCHIVE_FATAL); } filename[filename_size++] = '\0'; - filename[filename_size++] = '\0'; + /* + * Do not increment filename_size here as the computations below + * add the space for the terminating NUL explicitly. + */ + filename[filename_size] = '\0'; /* Decoded unicode form is UTF-16BE, so we have to update a string * conversion object for it. */ diff --git contrib/libarchive/libarchive/archive_read_support_format_tar.c contrib/libarchive/libarchive/archive_read_support_format_tar.c index e956f40cd6ad..7348e2d5c07e 100644 --- contrib/libarchive/libarchive/archive_read_support_format_tar.c +++ contrib/libarchive/libarchive/archive_read_support_format_tar.c @@ -2243,7 +2243,7 @@ gnu_add_sparse_entry(struct archive_read *a, struct tar *tar, else tar->sparse_list = p; tar->sparse_last = p; - if (remaining < 0 || offset < 0) { + if (remaining < 0 || offset < 0 || offset > INT64_MAX - remaining) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Malformed sparse map data"); return (ARCHIVE_FATAL); } diff --git contrib/libarchive/libarchive/archive_read_support_format_xar.c contrib/libarchive/libarchive/archive_read_support_format_xar.c index 7a22beb9d8e4..602fc7722144 100644 --- contrib/libarchive/libarchive/archive_read_support_format_xar.c +++ contrib/libarchive/libarchive/archive_read_support_format_xar.c @@ -1040,6 +1040,9 @@ atol10(const char *p, size_t char_cnt) uint64_t l; int digit; + if (char_cnt == 0) + return (0); + l = 0; digit = *p - '0'; while (digit >= 0 && digit < 10 && char_cnt-- > 0) { @@ -1054,7 +1057,10 @@ atol8(const char *p, size_t char_cnt) { int64_t l; int digit; - + + if (char_cnt == 0) + return (0); + l = 0; while (char_cnt-- > 0) { if (*p >= '0' && *p <= '7') @@ -2623,6 +2629,14 @@ strappend_base64(struct xar *xar, archive_strncat(as, (const char *)buff, len); } +static int +is_string(const char *known, const char *data, size_t len) +{ + if (strlen(known) != len) + return -1; + return memcmp(data, known, len); +} + static void xml_data(void *userData, const char *s, int len) { @@ -2674,26 +2688,26 @@ xml_data(void *userData, const char *s, int len) archive_strncpy(&(xar->file->symlink), s, len); break; case FILE_TYPE: - if (strncmp("file", s, len) == 0 || - strncmp("hardlink", s, len) == 0) + if (is_string("file", s, len) == 0 || + is_string("hardlink", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFREG; - if (strncmp("directory", s, len) == 0) + if (is_string("directory", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFDIR; - if (strncmp("symlink", s, len) == 0) + if (is_string("symlink", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFLNK; - if (strncmp("character special", s, len) == 0) + if (is_string("character special", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFCHR; - if (strncmp("block special", s, len) == 0) + if (is_string("block special", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFBLK; - if (strncmp("socket", s, len) == 0) + if (is_string("socket", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFSOCK; - if (strncmp("fifo", s, len) == 0) + if (is_string("fifo", s, len) == 0) xar->file->mode = (xar->file->mode & ~AE_IFMT) | AE_IFIFO; xar->file->has |= HAS_TYPE; diff --git contrib/libarchive/libarchive/archive_read_support_format_zip.c contrib/libarchive/libarchive/archive_read_support_format_zip.c index c88e7bbbe0d5..d6c957045625 100644 --- contrib/libarchive/libarchive/archive_read_support_format_zip.c +++ contrib/libarchive/libarchive/archive_read_support_format_zip.c @@ -723,6 +723,11 @@ process_extra(struct archive_read *a, const char *p, size_t extra_length, struct } case 0x9901: /* WinZip AES extra data field. */ + if (datasize < 6) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Incomplete AES field"); + return ARCHIVE_FAILED; + } if (p[offset + 2] == 'A' && p[offset + 3] == 'E') { /* Vendor version. */ zip_entry->aes_extra.vendor = diff --git contrib/libarchive/libarchive/archive_string.c contrib/libarchive/libarchive/archive_string.c index 3501a9e09143..c12355f08916 100644 --- contrib/libarchive/libarchive/archive_string.c +++ contrib/libarchive/libarchive/archive_string.c @@ -214,7 +214,8 @@ archive_wstring_append(struct archive_wstring *as, const wchar_t *p, size_t s) { if (archive_wstring_ensure(as, as->length + s + 1) == NULL) return (NULL); - wmemmove(as->s + as->length, p, s); + if (s) + wmemmove(as->s + as->length, p, s); as->length += s; as->s[as->length] = 0; return (as); diff --git contrib/libarchive/libarchive/archive_version_details.c contrib/libarchive/libarchive/archive_version_details.c index e10b83e5b7e4..2651503e6fda 100644 --- contrib/libarchive/libarchive/archive_version_details.c +++ contrib/libarchive/libarchive/archive_version_details.c @@ -45,6 +45,9 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_LZ4_H #include <lz4.h> #endif +#ifdef HAVE_ZSTD_H +#include <zstd.h> +#endif #include "archive.h" #include "archive_private.h" @@ -59,6 +62,7 @@ archive_version_details(void) const char *liblzma = archive_liblzma_version(); const char *bzlib = archive_bzlib_version(); const char *liblz4 = archive_liblz4_version(); + const char *libzstd = archive_libzstd_version(); if (!init) { archive_string_init(&str); @@ -84,6 +88,10 @@ archive_version_details(void) archive_strcat(&str, " liblz4/"); archive_strcat(&str, liblz4); } + if (libzstd) { + archive_strcat(&str, " libzstd/"); + archive_strcat(&str, libzstd); + } } return str.s; } @@ -131,3 +139,13 @@ archive_liblz4_version(void) return NULL; #endif } + +const char * +archive_libzstd_version(void) +{ +#if HAVE_ZSTD_H && HAVE_LIBZSTD + return ZSTD_VERSION_STRING; +#else + return NULL; +#endif +} diff --git contrib/libarchive/libarchive/archive_write.3 contrib/libarchive/libarchive/archive_write.3 index 376d71dee20e..c1164f5b5fdb 100644 --- contrib/libarchive/libarchive/archive_write.3 +++ contrib/libarchive/libarchive/archive_write.3 @@ -71,7 +71,7 @@ support. .\" .Ss Set options See -.Xr archive_read_set_options 3 . +.Xr archive_write_set_options 3 . .\" .Ss Open archive See diff --git contrib/libarchive/libarchive/archive_write_add_filter.c contrib/libarchive/libarchive/archive_write_add_filter.c index 08f518adec4b..203f4142b5c9 100644 --- contrib/libarchive/libarchive/archive_write_add_filter.c +++ contrib/libarchive/libarchive/archive_write_add_filter.c @@ -53,6 +53,7 @@ struct { int code; int (*setter)(struct archive *); } codes[] = { ARCHIVE_FILTER_LZOP, archive_write_add_filter_lzip }, { ARCHIVE_FILTER_UU, archive_write_add_filter_uuencode }, { ARCHIVE_FILTER_XZ, archive_write_add_filter_xz }, + { ARCHIVE_FILTER_ZSTD, archive_write_add_filter_zstd }, { -1, NULL } }; diff --git contrib/libarchive/libarchive/archive_write_add_filter_by_name.c contrib/libarchive/libarchive/archive_write_add_filter_by_name.c index 85a8d4753415..ffa633c96371 100644 --- contrib/libarchive/libarchive/archive_write_add_filter_by_name.c +++ contrib/libarchive/libarchive/archive_write_add_filter_by_name.c @@ -57,6 +57,7 @@ struct { const char *name; int (*setter)(struct archive *); } names[] = { "lzop", archive_write_add_filter_lzop }, { "uuencode", archive_write_add_filter_uuencode }, { "xz", archive_write_add_filter_xz }, + { "zstd", archive_write_add_filter_zstd }, { NULL, NULL } }; diff --git contrib/libarchive/libarchive/archive_write_add_filter_zstd.c contrib/libarchive/libarchive/archive_write_add_filter_zstd.c new file mode 100644 index 000000000000..671fc6affbaa --- /dev/null +++ contrib/libarchive/libarchive/archive_write_add_filter_zstd.c @@ -0,0 +1,335 @@ +/*- + * Copyright (c) 2017 Sean Purcell + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "archive_platform.h" + +__FBSDID("$FreeBSD$"); + + +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif +#ifdef HAVE_ZSTD_H +#include <zstd.h> +#endif + +#include "archive.h" +#include "archive_private.h" +#include "archive_string.h" +#include "archive_write_private.h" + +/* Don't compile this if we don't have zstd.h */ + +struct private_data { + int compression_level; +#if HAVE_ZSTD_H && HAVE_LIBZSTD + ZSTD_CStream *cstream; + int64_t total_in; + ZSTD_outBuffer out; +#else + struct archive_write_program_data *pdata; +#endif +}; + +static int archive_compressor_zstd_options(struct archive_write_filter *, + const char *, const char *); +static int archive_compressor_zstd_open(struct archive_write_filter *); +static int archive_compressor_zstd_write(struct archive_write_filter *, + const void *, size_t); +static int archive_compressor_zstd_close(struct archive_write_filter *); +static int archive_compressor_zstd_free(struct archive_write_filter *); +#if HAVE_ZSTD_H && HAVE_LIBZSTD +static int drive_compressor(struct archive_write_filter *, + struct private_data *, int, const void *, size_t); +#endif + + +/* + * Add a zstd compression filter to this write handle. + */ +int +archive_write_add_filter_zstd(struct archive *_a) +{ + struct archive_write *a = (struct archive_write *)_a; + struct archive_write_filter *f = __archive_write_allocate_filter(_a); + struct private_data *data; + archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, + ARCHIVE_STATE_NEW, "archive_write_add_filter_zstd"); + + data = calloc(1, sizeof(*data)); + if (data == NULL) { + archive_set_error(&a->archive, ENOMEM, "Out of memory"); + return (ARCHIVE_FATAL); + } + f->data = data; + f->open = &archive_compressor_zstd_open; + f->options = &archive_compressor_zstd_options; + f->close = &archive_compressor_zstd_close; + f->free = &archive_compressor_zstd_free; + f->code = ARCHIVE_FILTER_ZSTD; + f->name = "zstd"; + data->compression_level = 3; /* Default level used by the zstd CLI */ +#if HAVE_ZSTD_H && HAVE_LIBZSTD + data->cstream = ZSTD_createCStream(); + if (data->cstream == NULL) { + free(data); + archive_set_error(&a->archive, ENOMEM, + "Failed to allocate zstd compressor object"); + return (ARCHIVE_FATAL); + } + + return (ARCHIVE_OK); +#else + data->pdata = __archive_write_program_allocate("zstd"); + if (data->pdata == NULL) { + free(data); + archive_set_error(&a->archive, ENOMEM, "Out of memory"); + return (ARCHIVE_FATAL); + } + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Using external zstd program"); + return (ARCHIVE_WARN); +#endif +} + +static int +archive_compressor_zstd_free(struct archive_write_filter *f) +{ + struct private_data *data = (struct private_data *)f->data; +#if HAVE_ZSTD_H && HAVE_LIBZSTD + ZSTD_freeCStream(data->cstream); + free(data->out.dst); +#else + __archive_write_program_free(data->pdata); +#endif + free(data); + f->data = NULL; + return (ARCHIVE_OK); +} + +/* + * Set write options. + */ +static int +archive_compressor_zstd_options(struct archive_write_filter *f, const char *key, + const char *value) +{ + struct private_data *data = (struct private_data *)f->data; + + if (strcmp(key, "compression-level") == 0) { + int level = atoi(value); +#if HAVE_ZSTD_H && HAVE_LIBZSTD + if (level < 1 || level > ZSTD_maxCLevel()) { +#else + /* If we don't have the library, hard-code the max level */ + if (level < 1 || level > 22) { +#endif + return (ARCHIVE_WARN); + } + data->compression_level = level; + return (ARCHIVE_OK); + } + + /* Note: The "warn" return is just to inform the options + * supervisor that we didn't handle it. It will generate + * a suitable error if no one used this option. */ + return (ARCHIVE_WARN); +} + +#if HAVE_ZSTD_H && HAVE_LIBZSTD +/* + * Setup callback. + */ +static int +archive_compressor_zstd_open(struct archive_write_filter *f) +{ + struct private_data *data = (struct private_data *)f->data; + int ret; + + ret = __archive_write_open_filter(f->next_filter); + if (ret != ARCHIVE_OK) + return (ret); + + if (data->out.dst == NULL) { + size_t bs = ZSTD_CStreamOutSize(), bpb; + if (f->archive->magic == ARCHIVE_WRITE_MAGIC) { + /* Buffer size should be a multiple number of + * the of bytes per block for performance. */ + bpb = archive_write_get_bytes_per_block(f->archive); + if (bpb > bs) + bs = bpb; + else if (bpb != 0) + bs -= bs % bpb; + } + data->out.size = bs; + data->out.pos = 0; + data->out.dst + = (unsigned char *)malloc(data->out.size); + if (data->out.dst == NULL) { + archive_set_error(f->archive, ENOMEM, + "Can't allocate data for compression buffer"); + return (ARCHIVE_FATAL); + } + } + + f->write = archive_compressor_zstd_write; + + if (ZSTD_isError(ZSTD_initCStream(data->cstream, + data->compression_level))) { + archive_set_error(f->archive, ARCHIVE_ERRNO_MISC, + "Internal error initializing zstd compressor object"); + return (ARCHIVE_FATAL); + } + + return (ARCHIVE_OK); +} + +/* + * Write data to the compressed stream. + */ +static int +archive_compressor_zstd_write(struct archive_write_filter *f, const void *buff, + size_t length) +{ + struct private_data *data = (struct private_data *)f->data; + int ret; + + /* Update statistics */ + data->total_in += length; + + if ((ret = drive_compressor(f, data, 0, buff, length)) != ARCHIVE_OK) + return (ret); + + return (ARCHIVE_OK); +} + +/* + * Finish the compression... + */ +static int +archive_compressor_zstd_close(struct archive_write_filter *f) +{ + struct private_data *data = (struct private_data *)f->data; + int r1, r2; + + /* Finish zstd frame */ + r1 = drive_compressor(f, data, 1, NULL, 0); + + r2 = __archive_write_close_filter(f->next_filter); + + return r1 < r2 ? r1 : r2; +} + +/* + * Utility function to push input data through compressor, + * writing full output blocks as necessary. + * + * Note that this handles both the regular write case (finishing == + * false) and the end-of-archive case (finishing == true). + */ +static int +drive_compressor(struct archive_write_filter *f, + struct private_data *data, int finishing, const void *src, size_t length) +{ + ZSTD_inBuffer in = (ZSTD_inBuffer) { src, length, 0 }; + + for (;;) { + if (data->out.pos == data->out.size) { + const int ret = __archive_write_filter(f->next_filter, + data->out.dst, data->out.size); + if (ret != ARCHIVE_OK) + return (ARCHIVE_FATAL); + data->out.pos = 0; + } + + /* If there's nothing to do, we're done. */ + if (!finishing && in.pos == in.size) + return (ARCHIVE_OK); + + { + const size_t zstdret = !finishing ? + ZSTD_compressStream(data->cstream, &data->out, &in) + : ZSTD_endStream(data->cstream, &data->out); + + if (ZSTD_isError(zstdret)) { + archive_set_error(f->archive, + ARCHIVE_ERRNO_MISC, + "Zstd compression failed: %s", + ZSTD_getErrorName(zstdret)); + return (ARCHIVE_FATAL); + } + + /* If we're finishing, 0 means nothing left to flush */ + if (finishing && zstdret == 0) { + const int ret = __archive_write_filter(f->next_filter, + data->out.dst, data->out.pos); + return (ret); + } + } + } +} + +#else /* HAVE_ZSTD_H && HAVE_LIBZSTD */ + +static int +archive_compressor_zstd_open(struct archive_write_filter *f) +{ + struct private_data *data = (struct private_data *)f->data; + struct archive_string as; + int r; + + archive_string_init(&as); + archive_string_sprintf(&as, "zstd -%d", data->compression_level); + + f->write = archive_compressor_zstd_write; + r = __archive_write_program_open(f, data->pdata, as.s); + archive_string_free(&as); + return (r); +} + +static int +archive_compressor_zstd_write(struct archive_write_filter *f, const void *buff, + size_t length) +{ + struct private_data *data = (struct private_data *)f->data; + + return __archive_write_program_write(f, data->pdata, buff, length); +} + +static int +archive_compressor_zstd_close(struct archive_write_filter *f) +{ + struct private_data *data = (struct private_data *)f->data; + + return __archive_write_program_close(f, data->pdata); +} + +#endif /* HAVE_ZSTD_H && HAVE_LIBZSTD */ diff --git contrib/libarchive/libarchive/archive_write_filter.3 contrib/libarchive/libarchive/archive_write_filter.3 index e1d189150644..d6fa07131a80 100644 --- contrib/libarchive/libarchive/archive_write_filter.3 +++ contrib/libarchive/libarchive/archive_write_filter.3 @@ -42,7 +42,8 @@ .Nm archive_write_add_filter_none , .Nm archive_write_add_filter_program , .Nm archive_write_add_filter_uuencode , -.Nm archive_write_add_filter_xz +.Nm archive_write_add_filter_xz , +.Nm archive_write_add_filter_zstd , .Nd functions enabling output filters .Sh LIBRARY Streaming Archive Library (libarchive, -larchive) @@ -76,6 +77,8 @@ Streaming Archive Library (libarchive, -larchive) .Fn archive_write_add_filter_uuencode "struct archive *" .Ft int .Fn archive_write_add_filter_xz "struct archive *" +.Ft int +.Fn archive_write_add_filter_zstd "struct archive *" .Sh DESCRIPTION .Bl -tag -width indent .It Xo @@ -89,6 +92,7 @@ Streaming Archive Library (libarchive, -larchive) .Fn archive_write_add_filter_lzma , .Fn archive_write_add_filter_lzop , .Fn archive_write_add_filter_xz , +.Fn archive_write_add_filter_zstd , .Xc The resulting archive will be compressed as specified. Note that the compressed output is always properly blocked. diff --git contrib/libarchive/libarchive/archive_write_set_format_pax.c contrib/libarchive/libarchive/archive_write_set_format_pax.c index 318ca78c554d..650b4529060a 100644 --- contrib/libarchive/libarchive/archive_write_set_format_pax.c +++ contrib/libarchive/libarchive/archive_write_set_format_pax.c @@ -1654,7 +1654,7 @@ build_pax_attribute_name(char *dest, const char *src) * GNU PAX Format 1.0 requires the special name, which pattern is: * <dir>/GNUSparseFile.<pid>/<original file name> * - * Since reproducable archives are more important, use 0 as pid. + * Since reproducible archives are more important, use 0 as pid. * * This function is used for only Sparse file, a file type of which * is regular file. diff --git contrib/libarchive/libarchive/test/test_archive_write_add_filter_by_name.c contrib/libarchive/libarchive/test/test_archive_write_add_filter_by_name.c index 38b606b9d165..d962af92311b 100644 --- contrib/libarchive/libarchive/test/test_archive_write_add_filter_by_name.c +++ contrib/libarchive/libarchive/test/test_archive_write_add_filter_by_name.c @@ -207,3 +207,8 @@ DEFINE_TEST(test_archive_write_add_filter_by_name_xz) { test_filter_by_name("xz", ARCHIVE_FILTER_XZ, cannot); } + +DEFINE_TEST(test_archive_write_add_filter_by_name_zstd) +{ + test_filter_by_name("zstd", ARCHIVE_FILTER_ZSTD, canZstd); +} diff --git contrib/libarchive/libarchive/test/test_compat_zstd.c contrib/libarchive/libarchive/test/test_compat_zstd.c new file mode 100644 index 000000000000..1d63a2845ff5 --- /dev/null +++ contrib/libarchive/libarchive/test/test_compat_zstd.c @@ -0,0 +1,82 @@ +/*- + * Copyright (c) 2017 Sean Purcell + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "test.h" +__FBSDID("$FreeBSD$"); + +/* + * Verify our ability to read sample files compatibly with 'zstd -d'. + * + * In particular: + * * zstd -d will read multiple zstd streams, concatenating the output + * * zstd -d will skip over zstd skippable frames + */ + +static void +compat_zstd(const char *name) +{ + const char *n[7] = { "f1", "f2", "f3", "d1/f1", "d1/f2", "d1/f3", NULL }; + struct archive_entry *ae; + struct archive *a; + int i, r; + + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); + r = archive_read_support_filter_zstd(a); + if (r == ARCHIVE_WARN) { + skipping("zstd reading not fully supported on this platform"); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); + return; + } + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + extract_reference_file(name); + assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2)); + + /* Read entries, match up names with list above. */ + for (i = 0; i < 6; ++i) { + failure("Could not read file %d (%s) from %s", i, n[i], name); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_next_header(a, &ae)); + assertEqualString(n[i], archive_entry_pathname(ae)); + } + + /* Verify the end-of-archive. */ + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + + /* Verify that the format detection worked. */ + assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_ZSTD); + assertEqualString(archive_filter_name(a, 0), "zstd"); + assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR); + + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} + + +DEFINE_TEST(test_compat_zstd) +{ + /* This sample was compressed as 3 separate streams with a zstd skippable + * frame placed in the middle */ + compat_zstd("test_compat_zstd_1.tar.zst"); +} diff --git contrib/libarchive/libarchive/test/test_compat_zstd_1.tar.zst.uu contrib/libarchive/libarchive/test/test_compat_zstd_1.tar.zst.uu new file mode 100644 index 000000000000..4b0b98447ffa --- /dev/null +++ contrib/libarchive/libarchive/test/test_compat_zstd_1.tar.zst.uu @@ -0,0 +1,12 @@ +begin 644 test_compat_zstd_1.tar.zst +M*+4O_010)0,`HL0.%;`Q&>>\/$2[#IQF[<1+Z3T<0CX]!77&0@R.6+/F,0+I +M.$1A$QE2`J!+*_6[_YT9_W_M1KC-EG*V>10.`,M`%3*@#F#\`-FT#J:1#U1" +M`H1!&R#<!.<"@#3@M58XY1,8`DMMD\@HM2_]!%!=`P`B!1`5H#D!0!.SELJ" +M5#509I*T/YQ^]?H/3T1D>A5\*'"JYIJ;C&4=B2CL(L)*E-IJT/RV?.:A_]_N +MB&[7SDG;/=4&#P";0!5D0`=8T0&R&19,)1^HA`0(@S9`N`G.!0!IP&NM<,K! +M-#8!%A]U]K10*DT8!`````$"`P0HM2_]!%!]`P`B11`6H+$)"%]@,Z6OH`"L +MM$R2MAN&*MSG`W?OJ7+4P*B::VXR`NM(1&$7&58"J*U'_&V^S$/_O]U1N%T[ +M)VW7J'+4!A``_4$%^T`],J`8P.0!L@D63"4?J(0$"(,V0+@)S@4`:<!KK7!J +)P51V`E@!9CD# +` +end diff --git contrib/libarchive/libarchive/test/test_fuzz.c contrib/libarchive/libarchive/test/test_fuzz.c index 61c2dfc0fcdf..76557d541d00 100644 --- contrib/libarchive/libarchive/test/test_fuzz.c +++ contrib/libarchive/libarchive/test/test_fuzz.c @@ -412,6 +412,12 @@ DEFINE_TEST(test_fuzz_tar) "test_compat_lzop_1.tar.lzo", NULL }; +#endif +#if HAVE_ZSTD_H && HAVE_LIBZSTD + static const char *fileset10[] = { + "test_compat_zstd_1.tar.zst", + NULL + }; #endif static const struct files filesets[] = { {0, fileset1}, /* Exercise bzip2 decompressor. */ @@ -425,6 +431,9 @@ DEFINE_TEST(test_fuzz_tar) {0, fileset8}, #if HAVE_LIBLZO2 && HAVE_LZO_LZO1X_H && HAVE_LZO_LZOCONF_H {0, fileset9}, /* Exercise lzo decompressor. */ +#endif +#if HAVE_ZSTD_H && HAVE_LIBZSTD + {0, fileset10}, /* Excercise zstd decompressor. */ #endif {1, NULL} }; diff --git contrib/libarchive/libarchive/test/test_write_filter_zstd.c contrib/libarchive/libarchive/test/test_write_filter_zstd.c new file mode 100644 index 000000000000..5637aa5e29b3 --- /dev/null +++ contrib/libarchive/libarchive/test/test_write_filter_zstd.c @@ -0,0 +1,201 @@ +/*- + * Copyright (c) 2017 Sean Purcell + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "test.h" +__FBSDID("$FreeBSD$"); + +DEFINE_TEST(test_write_filter_zstd) +{ + struct archive_entry *ae; + struct archive *a; + char *buff, *data; + size_t buffsize, datasize; + char path[16]; + size_t used1, used2; + int i, r; + + buffsize = 2000000; + assert(NULL != (buff = (char *)malloc(buffsize))); + if (buff == NULL) + return; + + datasize = 10000; + assert(NULL != (data = (char *)malloc(datasize))); + if (data == NULL) { + free(buff); + return; + } + memset(data, 0, datasize); + + /* + * Write a 100 files and read them all back. + */ + assert((a = archive_write_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a)); + r = archive_write_add_filter_zstd(a); + if (r != ARCHIVE_OK) { + skipping("zstd writing not supported on this platform"); + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); + free(buff); + free(data); + return; + } + assertEqualIntA(a, ARCHIVE_OK, + archive_write_set_bytes_per_block(a, 10)); + assertEqualInt(ARCHIVE_FILTER_ZSTD, archive_filter_code(a, 0)); + assertEqualString("zstd", archive_filter_name(a, 0)); + assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used1)); + assertEqualInt(ARCHIVE_FILTER_ZSTD, archive_filter_code(a, 0)); + assertEqualString("zstd", archive_filter_name(a, 0)); + assert((ae = archive_entry_new()) != NULL); + archive_entry_set_filetype(ae, AE_IFREG); + archive_entry_set_size(ae, datasize); + for (i = 0; i < 100; i++) { + sprintf(path, "file%03d", i); + archive_entry_copy_pathname(ae, path); + assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); + assertA(datasize + == (size_t)archive_write_data(a, data, datasize)); + } + archive_entry_free(ae); + assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a)); + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); + + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + r = archive_read_support_filter_zstd(a); + if (r == ARCHIVE_WARN) { + skipping("Can't verify zstd writing by reading back;" + " zstd reading not fully supported on this platform"); + } else { + assertEqualIntA(a, ARCHIVE_OK, + archive_read_support_filter_all(a)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_memory(a, buff, used1)); + for (i = 0; i < 100; i++) { + sprintf(path, "file%03d", i); + if (!assertEqualInt(ARCHIVE_OK, + archive_read_next_header(a, &ae))) + break; + assertEqualString(path, archive_entry_pathname(ae)); + assertEqualInt((int)datasize, archive_entry_size(ae)); + } + assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); + } + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); + + /* + * Repeat the cycle again, this time setting some compression + * options. + */ + assert((a = archive_write_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a)); + assertEqualIntA(a, ARCHIVE_OK, + archive_write_set_bytes_per_block(a, 10)); + assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_zstd(a)); + assertEqualIntA(a, ARCHIVE_FAILED, + archive_write_set_filter_option(a, NULL, "nonexistent-option", "0")); + assertEqualIntA(a, ARCHIVE_FAILED, + archive_write_set_filter_option(a, NULL, "compression-level", "abc")); + assertEqualIntA(a, ARCHIVE_FAILED, + archive_write_set_filter_option(a, NULL, "compression-level", "25")); /* too big */ + assertEqualIntA(a, ARCHIVE_OK, + archive_write_set_filter_option(a, NULL, "compression-level", "9")); + assertEqualIntA(a, ARCHIVE_OK, + archive_write_set_filter_option(a, NULL, "compression-level", "15")); + assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2)); + for (i = 0; i < 100; i++) { + sprintf(path, "file%03d", i); + assert((ae = archive_entry_new()) != NULL); + archive_entry_copy_pathname(ae, path); + archive_entry_set_size(ae, datasize); + archive_entry_set_filetype(ae, AE_IFREG); + assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); + assertA(datasize == (size_t)archive_write_data(a, data, datasize)); + archive_entry_free(ae); + } + assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a)); + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); + + failure("compression-level=15 wrote %d bytes, default wrote %d bytes", + (int)used2, (int)used1); + assert(used2 < used1); + + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + r = archive_read_support_filter_zstd(a); + if (r == ARCHIVE_WARN) { + skipping("zstd reading not fully supported on this platform"); + } else { + assertEqualIntA(a, ARCHIVE_OK, + archive_read_support_filter_all(a)); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_memory(a, buff, used2)); + for (i = 0; i < 100; i++) { + sprintf(path, "file%03d", i); + failure("Trying to read %s", path); + if (!assertEqualIntA(a, ARCHIVE_OK, + archive_read_next_header(a, &ae))) + break; + assertEqualString(path, archive_entry_pathname(ae)); + assertEqualInt((int)datasize, archive_entry_size(ae)); + } + assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); + } + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); + + /* + * Test various premature shutdown scenarios to make sure we + * don't crash or leak memory. + */ + assert((a = archive_write_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_zstd(a)); + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); + + assert((a = archive_write_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_zstd(a)); + assertEqualInt(ARCHIVE_OK, archive_write_close(a)); + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); + + assert((a = archive_write_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_zstd(a)); + assertEqualInt(ARCHIVE_OK, archive_write_close(a)); + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); + + assert((a = archive_write_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_zstd(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2)); + assertEqualInt(ARCHIVE_OK, archive_write_close(a)); + assertEqualInt(ARCHIVE_OK, archive_write_free(a)); + + /* + * Clean up. + */ + free(data); + free(buff); +} diff --git contrib/libarchive/tar/bsdtar.1 contrib/libarchive/tar/bsdtar.1 index cdc317b6cf4d..132e1145794c 100644 --- contrib/libarchive/tar/bsdtar.1 +++ contrib/libarchive/tar/bsdtar.1 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 25, 2017 +.Dd October 1, 2017 .Dt TAR 1 .Os .Sh NAME @@ -302,19 +302,18 @@ containing the string Compress the resulting archive with .Xr xz 1 . In extract or list modes, this option is ignored. -Note that, unlike other +Note that this .Nm tar -implementations, this implementation recognizes XZ compression -automatically when reading archives. +implementation recognizes XZ compression automatically when reading archives. .It Fl j , Fl Fl bzip , Fl Fl bzip2 , Fl Fl bunzip2 (c mode only) Compress the resulting archive with .Xr bzip2 1 . In extract or list modes, this option is ignored. -Note that, unlike other +Note that this .Nm tar -implementations, this implementation recognizes bzip2 compression -automatically when reading archives. +implementation recognizes bzip2 compression automatically when reading +archives. .It Fl k , Fl Fl keep-old-files (x mode only) Do not overwrite existing files. @@ -337,25 +336,41 @@ Issue a warning message unless all links to each file are archived. Compress the resulting archive with .Xr lrzip 1 . In extract or list modes, this option is ignored. +Note that this +.Nm tar +implementation recognizes lrzip compression automatically when reading +archives. .It Fl Fl lz4 (c mode only) Compress the archive with lz4-compatible compression before writing it. -In input mode, this option is ignored; lz4 compression is recognized -automatically on input. +In extract or list modes, this option is ignored. +Note that this +.Nm tar +implementation recognizes lz4 compression automatically when reading archives. +.It Fl Fl zstd +(c mode only) +Compress the archive with zstd-compatible compression before writing it. +In extract or list modes, this option is ignored. +Note that this +.Nm tar +implementation recognizes zstd compression automatically when reading archives. .It Fl Fl lzma (c mode only) Compress the resulting archive with the original LZMA algorithm. +In extract or list modes, this option is ignored. Use of this option is discouraged and new archives should be created with .Fl Fl xz instead. -Note that, unlike other +Note that this .Nm tar -implementations, this implementation recognizes LZMA compression -automatically when reading archives. +implementation recognizes LZMA compression automatically when reading archives. .It Fl Fl lzop (c mode only) Compress the resulting archive with .Xr lzop 1 . In extract or list modes, this option is ignored. +Note that this +.Nm tar +implementation recognizes LZO compression automatically when reading archives. .It Fl m , Fl Fl modification-time (x mode only) Do not extract modification time. @@ -577,6 +592,8 @@ A decimal integer from 4 to 7 specifying the lz4 compression block size .It Cm lz4:block-dependence Use the previous block of the block being compressed for a compression dictionary to improve compression ratio. +.It Cm zstd:compression-level +A decimal integer from 1 to 22 specifying the zstd compression level. .It Cm lzop:compression-level A decimal integer from 1 to 9 specifying the lzop compression level. .It Cm xz:compression-level @@ -826,28 +843,28 @@ is run in x mode as root. Compress the resulting archive with .Xr bzip2 1 . In extract or list modes, this option is ignored. -Note that, unlike other +Note that this .Nm tar -implementations, this implementation recognizes bzip2 compression -automatically when reading archives. +implementation recognizes bzip2 compression automatically when reading +archives. .It Fl Z , Fl Fl compress , Fl Fl uncompress (c mode only) Compress the resulting archive with .Xr compress 1 . In extract or list modes, this option is ignored. -Note that, unlike other +Note that this .Nm tar -implementations, this implementation recognizes compress compression -automatically when reading archives. +implementation recognizes compress compression automatically when reading +archives. .It Fl z , Fl Fl gunzip , Fl Fl gzip (c mode only) Compress the resulting archive with .Xr gzip 1 . In extract or list modes, this option is ignored. -Note that, unlike other +Note that this .Nm tar -implementations, this implementation recognizes gzip compression -automatically when reading archives. +implementation recognizes gzip compression automatically when reading +archives. .El .Sh ENVIRONMENT The following environment variables affect the execution of diff --git contrib/libarchive/tar/bsdtar.c contrib/libarchive/tar/bsdtar.c index d15214065472..e22e1d27285a 100644 --- contrib/libarchive/tar/bsdtar.c +++ contrib/libarchive/tar/bsdtar.c @@ -419,6 +419,7 @@ main(int argc, char **argv) case OPTION_LZIP: /* GNU tar beginning with 1.23 */ case OPTION_LZMA: /* GNU tar beginning with 1.20 */ case OPTION_LZOP: /* GNU tar beginning with 1.21 */ + case OPTION_ZSTD: if (compression != '\0') lafe_errc(1, 0, "Can't specify both -%c and -%c", opt, @@ -427,9 +428,10 @@ main(int argc, char **argv) switch (opt) { case OPTION_LRZIP: compression_name = "lrzip"; break; case OPTION_LZ4: compression_name = "lz4"; break; - case OPTION_LZIP: compression_name = "lzip"; break; - case OPTION_LZMA: compression_name = "lzma"; break; - case OPTION_LZOP: compression_name = "lzop"; break; + case OPTION_LZIP: compression_name = "lzip"; break; + case OPTION_LZMA: compression_name = "lzma"; break; + case OPTION_LZOP: compression_name = "lzop"; break; + case OPTION_ZSTD: compression_name = "zstd"; break; } break; case 'm': /* SUSv2 */ diff --git contrib/libarchive/tar/bsdtar.h contrib/libarchive/tar/bsdtar.h index 2bf42e8b28e7..612c2f67b273 100644 --- contrib/libarchive/tar/bsdtar.h +++ contrib/libarchive/tar/bsdtar.h @@ -181,7 +181,8 @@ enum { OPTION_USE_COMPRESS_PROGRAM, OPTION_UUENCODE, OPTION_VERSION, - OPTION_XATTRS + OPTION_XATTRS, + OPTION_ZSTD, }; int bsdtar_getopt(struct bsdtar *); diff --git contrib/libarchive/tar/cmdline.c contrib/libarchive/tar/cmdline.c index e36c545b3336..66cf4c2d196f 100644 --- contrib/libarchive/tar/cmdline.c +++ contrib/libarchive/tar/cmdline.c @@ -160,6 +160,7 @@ static const struct bsdtar_option { { "version", 0, OPTION_VERSION }, { "xattrs", 0, OPTION_XATTRS }, { "xz", 0, 'J' }, + { "zstd", 0, OPTION_ZSTD }, { NULL, 0, 0 } }; diff --git contrib/libarchive/tar/creation_set.c contrib/libarchive/tar/creation_set.c index 24cf3fcdd4ef..bdc607daeb20 100644 --- contrib/libarchive/tar/creation_set.c +++ contrib/libarchive/tar/creation_set.c @@ -80,9 +80,10 @@ get_filter_code(const char *suffix) { ".lzma", "lzma" }, { ".uu", "uuencode" }, { ".xz", "xz" }, + { ".zst", "zstd"}, { NULL, NULL } }; - + return get_suffix_code(filters, suffix); } @@ -121,6 +122,7 @@ decompose_alias(const char *suffix) { ".tzo", ".tar.lzo" }, { ".taZ", ".tar.Z" }, { ".tZ", ".tar.Z" }, + { ".tzst", ".tar.zst" }, { NULL, NULL } }; diff --git contrib/libarchive/tar/test/test_extract.tar.zst.uu contrib/libarchive/tar/test/test_extract.tar.zst.uu new file mode 100644 index 000000000000..3df0caf54758 --- /dev/null +++ contrib/libarchive/tar/test/test_extract.tar.zst.uu @@ -0,0 +1,6 @@ +begin 644 test_extract.tar.zst +M*+4O_010S0,`<L40$Z`5.(2U_RNV_[]L4V;Z_/R@1:7Y$3;9E`8$D$WI:W1) +M'58'D3->Y+>!0*5E/PM"$7^K^1VI3SS-AX&_W0KQWY!-Z1(`_4$%[$"]<T!A +L(*`#I!DXC4[J!6J8$!DJ$D"9$T*L]#G-$$/A`#`I`-(`UUKAU$Z@"`UXII`` +` +end diff --git sys/boot/arm/at91/libat91/memset.c contrib/libarchive/tar/test/test_extract_tar_zstd.c similarity index 57% rename from sys/boot/arm/at91/libat91/memset.c rename to contrib/libarchive/tar/test/test_extract_tar_zstd.c index 3432e640cd43..d67170ce3433 100644 --- sys/boot/arm/at91/libat91/memset.c +++ contrib/libarchive/tar/test/test_extract_tar_zstd.c @@ -1,5 +1,6 @@ /*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. + * Copyright (c) 2017 Sean Purcell + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,27 +11,38 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * */ - -#include <sys/cdefs.h> +#include "test.h" __FBSDID("$FreeBSD$"); -#include "lib.h" - -void -p_memset(char *buffer, char value, int size) +DEFINE_TEST(test_extract_tar_zstd) { - while (size--) - *buffer++ = value; + const char *reffile = "test_extract.tar.zst"; + int f; + + extract_reference_file(reffile); + f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canZstd()) { + assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err", + testprog, reffile)); + + assertFileExists("file1"); + assertTextFileContents("contents of file1.\n", "file1"); + assertFileExists("file2"); + assertTextFileContents("contents of file2.\n", "file2"); + assertEmptyFile("test.out"); + assertEmptyFile("test.err"); + } else { + skipping("It seems zstd is not supported on this platform"); + } } diff --git contrib/libarchive/tar/test/test_option_acls.c contrib/libarchive/tar/test/test_option_acls.c index f2d51d661abf..325f319537af 100644 --- contrib/libarchive/tar/test/test_option_acls.c +++ contrib/libarchive/tar/test/test_option_acls.c @@ -483,7 +483,7 @@ DEFINE_TEST(test_option_acls) r = compare_acls("f", "acls_acls/f"); assertEqualInt(r, 1); - /* Extractl acls without acls */ + /* Extract acls without acls */ assertMakeDir("acls_noacls", 0755); clear_inheritance_flags("acls_noacls", acltype); r = systemf("%s -x -C acls_noacls -p --no-acls -f acls.tar >acls_noacls.out 2>acls_noacls.err", testprog); diff --git contrib/libarchive/tar/test/test_option_zstd.c contrib/libarchive/tar/test/test_option_zstd.c new file mode 100644 index 000000000000..73965e33f3af --- /dev/null +++ contrib/libarchive/tar/test/test_option_zstd.c @@ -0,0 +1,85 @@ +/*- + * Copyright (c) 2017 Sean Purcell + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "test.h" +__FBSDID("$FreeBSD$"); + +DEFINE_TEST(test_option_zstd) +{ + char *p; + int r; + size_t s; + + /* Create a file. */ + assertMakeFile("f", 0644, "a"); + + /* Archive it with lz4 compression. */ + r = systemf("%s -cf - --zstd f >archive.out 2>archive.err", + testprog); + p = slurpfile(&s, "archive.err"); + p[s] = '\0'; + if (r != 0) { + if (strstr(p, "Unsupported compression") != NULL) { + skipping("This version of bsdtar was compiled " + "without zstd support"); + goto done; + } + /* POSIX permits different handling of the spawnp + * system call used to launch the subsidiary + * program: */ + /* Some systems fail immediately to spawn the new process. */ + if (strstr(p, "Can't launch") != NULL && !canZstd()) { + skipping("This version of bsdtar uses an external zstd program " + "but no such program is available on this system."); + goto done; + } + /* Some systems successfully spawn the new process, + * but fail to exec a program within that process. + * This results in failure at the first attempt to + * write. */ + if (strstr(p, "Can't write") != NULL && !canZstd()) { + skipping("This version of bsdtar uses an external zstd program " + "but no such program is available on this system."); + goto done; + } + /* On some systems the error won't be detected until closing + time, by a 127 exit error returned by waitpid. */ + if (strstr(p, "Error closing") != NULL && !canZstd()) { + skipping("This version of bsdcpio uses an external zstd program " + "but no such program is available on this system."); + return; + } + failure("--zstd option is broken: %s", p); + assertEqualInt(r, 0); + goto done; + } + free(p); + /* Check that the archive file has an lz4 signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "\x28\xb5\x2f\xfd", 4); + +done: + free(p); +} diff --git contrib/libarchive/test_utils/test_common.h contrib/libarchive/test_utils/test_common.h index 1425dd84b7df..dd7e41016d52 100644 --- contrib/libarchive/test_utils/test_common.h +++ contrib/libarchive/test_utils/test_common.h @@ -329,6 +329,9 @@ int canLrzip(void); /* Return true if this platform can run the "lz4" program. */ int canLz4(void); +/* Return true if this platform can run the "zstd" program. */ +int canZstd(void); + /* Return true if this platform can run the "lzip" program. */ int canLzip(void); diff --git contrib/libarchive/test_utils/test_main.c contrib/libarchive/test_utils/test_main.c index 0e1413693f4a..0e8cc9fc56a2 100644 --- contrib/libarchive/test_utils/test_main.c +++ contrib/libarchive/test_utils/test_main.c @@ -2318,6 +2318,21 @@ canLz4(void) return (value); } +/* + * Can this platform run the zstd program? + */ +int +canZstd(void) +{ + static int tested = 0, value = 0; + if (!tested) { + tested = 1; + if (systemf("zstd -V %s", redirectArgs) == 0) + value = 1; + } + return (value); +} + /* * Can this platform run the lzip program? */ diff --git contrib/llvm/include/llvm/CodeGen/SelectionDAGNodes.h contrib/llvm/include/llvm/CodeGen/SelectionDAGNodes.h index db42fb6c170c..5fb69ae232af 100644 --- contrib/llvm/include/llvm/CodeGen/SelectionDAGNodes.h +++ contrib/llvm/include/llvm/CodeGen/SelectionDAGNodes.h @@ -85,7 +85,10 @@ namespace ISD { /// If N is a BUILD_VECTOR node whose elements are all the same constant or /// undefined, return true and return the constant value in \p SplatValue. - bool isConstantSplatVector(const SDNode *N, APInt &SplatValue); + /// This sets \p SplatValue to the smallest possible splat unless AllowShrink + /// is set to false. + bool isConstantSplatVector(const SDNode *N, APInt &SplatValue, + bool AllowShrink = true); /// Return true if the specified node is a BUILD_VECTOR where all of the /// elements are ~0 or undef. @@ -798,7 +801,8 @@ public: /// if DAG changes. static bool hasPredecessorHelper(const SDNode *N, SmallPtrSetImpl<const SDNode *> &Visited, - SmallVectorImpl<const SDNode *> &Worklist) { + SmallVectorImpl<const SDNode *> &Worklist, + unsigned int MaxSteps = 0) { if (Visited.count(N)) return true; while (!Worklist.empty()) { @@ -813,6 +817,8 @@ public: } if (Found) return true; + if (MaxSteps != 0 && Visited.size() >= MaxSteps) + return false; } return false; } diff --git contrib/llvm/lib/Analysis/PostDominators.cpp contrib/llvm/lib/Analysis/PostDominators.cpp index 811373ac850b..1caf151546d9 100644 --- contrib/llvm/lib/Analysis/PostDominators.cpp +++ contrib/llvm/lib/Analysis/PostDominators.cpp @@ -23,8 +23,6 @@ using namespace llvm; #define DEBUG_TYPE "postdomtree" -template class llvm::DominatorTreeBase<BasicBlock, true>; // PostDomTreeBase - //===----------------------------------------------------------------------===// // PostDominatorTree Implementation //===----------------------------------------------------------------------===// diff --git contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index d5d3f7a61a9f..432c86dd6f1e 100644 --- contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1118,22 +1118,30 @@ SDValue DAGCombiner::PromoteIntBinOp(SDValue Op) { SDValue RV = DAG.getNode(ISD::TRUNCATE, DL, VT, DAG.getNode(Opc, DL, PVT, NN0, NN1)); - // New replace instances of N0 and N1 - if (Replace0 && N0 && N0.getOpcode() != ISD::DELETED_NODE && NN0 && - NN0.getOpcode() != ISD::DELETED_NODE) { + // We are always replacing N0/N1's use in N and only need + // additional replacements if there are additional uses. + Replace0 &= !N0->hasOneUse(); + Replace1 &= (N0 != N1) && !N1->hasOneUse(); + + // Combine Op here so it is presreved past replacements. + CombineTo(Op.getNode(), RV); + + // If operands have a use ordering, make sur we deal with + // predecessor first. + if (Replace0 && Replace1 && N0.getNode()->isPredecessorOf(N1.getNode())) { + std::swap(N0, N1); + std::swap(NN0, NN1); + } + + if (Replace0) { AddToWorklist(NN0.getNode()); ReplaceLoadWithPromotedLoad(N0.getNode(), NN0.getNode()); } - - if (Replace1 && N1 && N1.getOpcode() != ISD::DELETED_NODE && NN1 && - NN1.getOpcode() != ISD::DELETED_NODE) { + if (Replace1) { AddToWorklist(NN1.getNode()); ReplaceLoadWithPromotedLoad(N1.getNode(), NN1.getNode()); } - - // Deal with Op being deleted. - if (Op && Op.getOpcode() != ISD::DELETED_NODE) - return RV; + return Op; } return SDValue(); } @@ -12599,25 +12607,37 @@ void DAGCombiner::getStoreMergeCandidates( } } -// We need to check that merging these stores does not cause a loop -// in the DAG. Any store candidate may depend on another candidate +// We need to check that merging these stores does not cause a loop in +// the DAG. Any store candidate may depend on another candidate // indirectly through its operand (we already consider dependencies // through the chain). Check in parallel by searching up from // non-chain operands of candidates. + bool DAGCombiner::checkMergeStoreCandidatesForDependencies( SmallVectorImpl<MemOpLink> &StoreNodes, unsigned NumStores) { + + // FIXME: We should be able to truncate a full search of + // predecessors by doing a BFS and keeping tabs the originating + // stores from which worklist nodes come from in a similar way to + // TokenFactor simplfication. + SmallPtrSet<const SDNode *, 16> Visited; SmallVector<const SDNode *, 8> Worklist; - // search ops of store candidates + unsigned int Max = 8192; + // Search Ops of store candidates. for (unsigned i = 0; i < NumStores; ++i) { SDNode *n = StoreNodes[i].MemNode; // Potential loops may happen only through non-chain operands for (unsigned j = 1; j < n->getNumOperands(); ++j) Worklist.push_back(n->getOperand(j).getNode()); } - // search through DAG. We can stop early if we find a storenode + // Search through DAG. We can stop early if we find a store node. for (unsigned i = 0; i < NumStores; ++i) { - if (SDNode::hasPredecessorHelper(StoreNodes[i].MemNode, Visited, Worklist)) + if (SDNode::hasPredecessorHelper(StoreNodes[i].MemNode, Visited, Worklist, + Max)) + return false; + // Check if we ended early, failing conservatively if so. + if (Visited.size() >= Max) return false; } return true; diff --git contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h index e102df5e913d..c46d1b04804c 100644 --- contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h +++ contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h @@ -627,6 +627,7 @@ private: SDValue ScalarizeVecOp_CONCAT_VECTORS(SDNode *N); SDValue ScalarizeVecOp_EXTRACT_VECTOR_ELT(SDNode *N); SDValue ScalarizeVecOp_VSELECT(SDNode *N); + SDValue ScalarizeVecOp_VSETCC(SDNode *N); SDValue ScalarizeVecOp_STORE(StoreSDNode *N, unsigned OpNo); SDValue ScalarizeVecOp_FP_ROUND(SDNode *N, unsigned OpNo); diff --git contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp index ecb54e1e4b41..6aa3270883f0 100644 --- contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp +++ contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp @@ -484,6 +484,9 @@ bool DAGTypeLegalizer::ScalarizeVectorOperand(SDNode *N, unsigned OpNo) { case ISD::VSELECT: Res = ScalarizeVecOp_VSELECT(N); break; + case ISD::SETCC: + Res = ScalarizeVecOp_VSETCC(N); + break; case ISD::STORE: Res = ScalarizeVecOp_STORE(cast<StoreSDNode>(N), OpNo); break; @@ -560,6 +563,36 @@ SDValue DAGTypeLegalizer::ScalarizeVecOp_VSELECT(SDNode *N) { N->getOperand(2)); } +/// If the operand is a vector that needs to be scalarized then the +/// result must be v1i1, so just convert to a scalar SETCC and wrap +/// with a scalar_to_vector since the res type is legal if we got here +SDValue DAGTypeLegalizer::ScalarizeVecOp_VSETCC(SDNode *N) { + assert(N->getValueType(0).isVector() && + N->getOperand(0).getValueType().isVector() && + "Operand types must be vectors"); + assert(N->getValueType(0) == MVT::v1i1 && "Expected v1i1 type"); + + EVT VT = N->getValueType(0); + SDValue LHS = GetScalarizedVector(N->getOperand(0)); + SDValue RHS = GetScalarizedVector(N->getOperand(1)); + + EVT OpVT = N->getOperand(0).getValueType(); + EVT NVT = VT.getVectorElementType(); + SDLoc DL(N); + // Turn it into a scalar SETCC. + SDValue Res = DAG.getNode(ISD::SETCC, DL, MVT::i1, LHS, RHS, + N->getOperand(2)); + + // Vectors may have a different boolean contents to scalars. Promote the + // value appropriately. + ISD::NodeType ExtendCode = + TargetLowering::getExtendForContent(TLI.getBooleanContents(OpVT)); + + Res = DAG.getNode(ExtendCode, DL, NVT, Res); + + return DAG.getNode(ISD::SCALAR_TO_VECTOR, DL, VT, Res); +} + /// If the value to store is a vector that needs to be scalarized, it must be /// <1 x ty>. Just store the element. SDValue DAGTypeLegalizer::ScalarizeVecOp_STORE(StoreSDNode *N, unsigned OpNo){ diff --git contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 0ff154784f68..16f425dc7969 100644 --- contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -116,7 +116,8 @@ bool ConstantFPSDNode::isValueValidForType(EVT VT, // ISD Namespace //===----------------------------------------------------------------------===// -bool ISD::isConstantSplatVector(const SDNode *N, APInt &SplatVal) { +bool ISD::isConstantSplatVector(const SDNode *N, APInt &SplatVal, + bool AllowShrink) { auto *BV = dyn_cast<BuildVectorSDNode>(N); if (!BV) return false; @@ -124,9 +125,11 @@ bool ISD::isConstantSplatVector(const SDNode *N, APInt &SplatVal) { APInt SplatUndef; unsigned SplatBitSize; bool HasUndefs; - EVT EltVT = N->getValueType(0).getVectorElementType(); - return BV->isConstantSplat(SplatVal, SplatUndef, SplatBitSize, HasUndefs) && - EltVT.getSizeInBits() >= SplatBitSize; + unsigned EltSize = N->getValueType(0).getVectorElementType().getSizeInBits(); + unsigned MinSplatBits = AllowShrink ? 0 : EltSize; + return BV->isConstantSplat(SplatVal, SplatUndef, SplatBitSize, HasUndefs, + MinSplatBits) && + EltSize >= SplatBitSize; } // FIXME: AllOnes and AllZeros duplicate a lot of code. Could these be diff --git contrib/llvm/lib/IR/AutoUpgrade.cpp contrib/llvm/lib/IR/AutoUpgrade.cpp index 6a4b8032ffd5..a501799b4799 100644 --- contrib/llvm/lib/IR/AutoUpgrade.cpp +++ contrib/llvm/lib/IR/AutoUpgrade.cpp @@ -2239,14 +2239,14 @@ bool llvm::UpgradeDebugInfo(Module &M) { } bool llvm::UpgradeModuleFlags(Module &M) { - const NamedMDNode *ModFlags = M.getModuleFlagsMetadata(); + NamedMDNode *ModFlags = M.getModuleFlagsMetadata(); if (!ModFlags) return false; - bool HasObjCFlag = false, HasClassProperties = false; + bool HasObjCFlag = false, HasClassProperties = false, Changed = false; for (unsigned I = 0, E = ModFlags->getNumOperands(); I != E; ++I) { MDNode *Op = ModFlags->getOperand(I); - if (Op->getNumOperands() < 2) + if (Op->getNumOperands() != 3) continue; MDString *ID = dyn_cast_or_null<MDString>(Op->getOperand(1)); if (!ID) @@ -2255,7 +2255,24 @@ bool llvm::UpgradeModuleFlags(Module &M) { HasObjCFlag = true; if (ID->getString() == "Objective-C Class Properties") HasClassProperties = true; + // Upgrade PIC/PIE Module Flags. The module flag behavior for these two + // field was Error and now they are Max. + if (ID->getString() == "PIC Level" || ID->getString() == "PIE Level") { + if (auto *Behavior = + mdconst::dyn_extract_or_null<ConstantInt>(Op->getOperand(0))) { + if (Behavior->getLimitedValue() == Module::Error) { + Type *Int32Ty = Type::getInt32Ty(M.getContext()); + Metadata *Ops[3] = { + ConstantAsMetadata::get(ConstantInt::get(Int32Ty, Module::Max)), + MDString::get(M.getContext(), ID->getString()), + Op->getOperand(2)}; + ModFlags->setOperand(I, MDNode::get(M.getContext(), Ops)); + Changed = true; + } + } + } } + // "Objective-C Class Properties" is recently added for Objective-C. We // upgrade ObjC bitcodes to contain a "Objective-C Class Properties" module // flag of value 0, so we can correclty downgrade this flag when trying to @@ -2264,9 +2281,10 @@ bool llvm::UpgradeModuleFlags(Module &M) { if (HasObjCFlag && !HasClassProperties) { M.addModuleFlag(llvm::Module::Override, "Objective-C Class Properties", (uint32_t)0); - return true; + Changed = true; } - return false; + + return Changed; } static bool isOldLoopArgument(Metadata *MD) { diff --git contrib/llvm/lib/Object/COFFModuleDefinition.cpp contrib/llvm/lib/Object/COFFModuleDefinition.cpp index ed9140d1fe08..510eac8b239b 100644 --- contrib/llvm/lib/Object/COFFModuleDefinition.cpp +++ contrib/llvm/lib/Object/COFFModuleDefinition.cpp @@ -232,7 +232,13 @@ private: for (;;) { read(); if (Tok.K == Identifier && Tok.Value[0] == '@') { - Tok.Value.drop_front().getAsInteger(10, E.Ordinal); + if (Tok.Value.drop_front().getAsInteger(10, E.Ordinal)) { + // Not an ordinal modifier at all, but the next export (fastcall + // decorated) - complete the current one. + unget(); + Info.Exports.push_back(E); + return Error::success(); + } read(); if (Tok.K == KwNoname) { E.Noname = true; diff --git contrib/llvm/lib/Support/Unix/Path.inc contrib/llvm/lib/Support/Unix/Path.inc index 45097eb918b7..67edb46f0025 100644 --- contrib/llvm/lib/Support/Unix/Path.inc +++ contrib/llvm/lib/Support/Unix/Path.inc @@ -427,7 +427,7 @@ std::error_code resize_file(int FD, uint64_t Size) { // If we have posix_fallocate use it. Unlike ftruncate it always allocates // space, so we get an error if the disk is full. if (int Err = ::posix_fallocate(FD, 0, Size)) { - if (Err != EOPNOTSUPP) + if (Err != EINVAL && Err != EOPNOTSUPP) return std::error_code(Err, std::generic_category()); } #endif diff --git contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index c0c6055c358f..13c80a46e5b0 100644 --- contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -940,6 +940,12 @@ bool AArch64InstrInfo::areMemAccessesTriviallyDisjoint( bool AArch64InstrInfo::analyzeCompare(const MachineInstr &MI, unsigned &SrcReg, unsigned &SrcReg2, int &CmpMask, int &CmpValue) const { + // The first operand can be a frame index where we'd normally expect a + // register. + assert(MI.getNumOperands() >= 2 && "All AArch64 cmps should have 2 operands"); + if (!MI.getOperand(1).isReg()) + return false; + switch (MI.getOpcode()) { default: break; diff --git contrib/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp contrib/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp index 4e65c0ab6011..22c11c7276d2 100644 --- contrib/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp +++ contrib/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp @@ -167,6 +167,9 @@ AArch64RedundantCopyElimination::knownRegValInBlock( // CMP is an alias for SUBS with a dead destination register. case AArch64::SUBSWri: case AArch64::SUBSXri: { + // Sometimes the first operand is a FrameIndex. Bail if tht happens. + if (!PredI.getOperand(1).isReg()) + return None; MCPhysReg SrcReg = PredI.getOperand(1).getReg(); // Must not be a symbolic immediate. diff --git contrib/llvm/lib/Target/ARM/ARMISelLowering.cpp contrib/llvm/lib/Target/ARM/ARMISelLowering.cpp index 6ba7593543a9..27dda93387b6 100644 --- contrib/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ contrib/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -5901,7 +5901,10 @@ static bool isVUZPMask(ArrayRef<int> M, EVT VT, unsigned &WhichResult) { return false; for (unsigned i = 0; i < M.size(); i += NumElts) { - WhichResult = M[i] == 0 ? 0 : 1; + if (M.size() == NumElts * 2) + WhichResult = i / NumElts; + else + WhichResult = M[i] == 0 ? 0 : 1; for (unsigned j = 0; j < NumElts; ++j) { if (M[i+j] >= 0 && (unsigned) M[i+j] != 2 * j + WhichResult) return false; @@ -5932,7 +5935,10 @@ static bool isVUZP_v_undef_Mask(ArrayRef<int> M, EVT VT, unsigned &WhichResult){ unsigned Half = NumElts / 2; for (unsigned i = 0; i < M.size(); i += NumElts) { - WhichResult = M[i] == 0 ? 0 : 1; + if (M.size() == NumElts * 2) + WhichResult = i / NumElts; + else + WhichResult = M[i] == 0 ? 0 : 1; for (unsigned j = 0; j < NumElts; j += Half) { unsigned Idx = WhichResult; for (unsigned k = 0; k < Half; ++k) { @@ -5972,7 +5978,10 @@ static bool isVZIPMask(ArrayRef<int> M, EVT VT, unsigned &WhichResult) { return false; for (unsigned i = 0; i < M.size(); i += NumElts) { - WhichResult = M[i] == 0 ? 0 : 1; + if (M.size() == NumElts * 2) + WhichResult = i / NumElts; + else + WhichResult = M[i] == 0 ? 0 : 1; unsigned Idx = WhichResult * NumElts / 2; for (unsigned j = 0; j < NumElts; j += 2) { if ((M[i+j] >= 0 && (unsigned) M[i+j] != Idx) || @@ -6005,7 +6014,10 @@ static bool isVZIP_v_undef_Mask(ArrayRef<int> M, EVT VT, unsigned &WhichResult){ return false; for (unsigned i = 0; i < M.size(); i += NumElts) { - WhichResult = M[i] == 0 ? 0 : 1; + if (M.size() == NumElts * 2) + WhichResult = i / NumElts; + else + WhichResult = M[i] == 0 ? 0 : 1; unsigned Idx = WhichResult * NumElts / 2; for (unsigned j = 0; j < NumElts; j += 2) { if ((M[i+j] >= 0 && (unsigned) M[i+j] != Idx) || @@ -8793,6 +8805,8 @@ ARMTargetLowering::EmitLowered__chkstk(MachineInstr &MI, .addReg(ARM::R4, RegState::Implicit | RegState::Kill) .addReg(ARM::R4, RegState::Implicit | RegState::Define) .addReg(ARM::R12, + RegState::Implicit | RegState::Define | RegState::Dead) + .addReg(ARM::CPSR, RegState::Implicit | RegState::Define | RegState::Dead); break; case CodeModel::Large: @@ -8808,6 +8822,8 @@ ARMTargetLowering::EmitLowered__chkstk(MachineInstr &MI, .addReg(ARM::R4, RegState::Implicit | RegState::Kill) .addReg(ARM::R4, RegState::Implicit | RegState::Define) .addReg(ARM::R12, + RegState::Implicit | RegState::Define | RegState::Dead) + .addReg(ARM::CPSR, RegState::Implicit | RegState::Define | RegState::Dead); break; } diff --git contrib/llvm/lib/Target/X86/X86ISelLowering.cpp contrib/llvm/lib/Target/X86/X86ISelLowering.cpp index 1e73122cdc38..957b46c40a6e 100644 --- contrib/llvm/lib/Target/X86/X86ISelLowering.cpp +++ contrib/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -29540,8 +29540,9 @@ static bool detectZextAbsDiff(const SDValue &Select, SDValue &Op0, // In SetLT case, The second operand of the comparison can be either 1 or 0. APInt SplatVal; if ((CC == ISD::SETLT) && - !((ISD::isConstantSplatVector(SetCC.getOperand(1).getNode(), SplatVal) && - SplatVal == 1) || + !((ISD::isConstantSplatVector(SetCC.getOperand(1).getNode(), SplatVal, + /*AllowShrink*/false) && + SplatVal.isOneValue()) || (ISD::isBuildVectorAllZeros(SetCC.getOperand(1).getNode())))) return false; @@ -30628,6 +30629,9 @@ static SDValue combineSelect(SDNode *N, SelectionDAG &DAG, // Byte blends are only available in AVX2 if (VT == MVT::v32i8 && !Subtarget.hasAVX2()) return SDValue(); + // There are no 512-bit blend instructions that use sign bits. + if (VT.is512BitVector()) + return SDValue(); assert(BitWidth >= 8 && BitWidth <= 64 && "Invalid mask size"); APInt DemandedMask(APInt::getSignMask(BitWidth)); @@ -30938,11 +30942,40 @@ static bool checkBoolTestAndOrSetCCCombine(SDValue Cond, X86::CondCode &CC0, return true; } +// When legalizing carry, we create carries via add X, -1 +// If that comes from an actual carry, via setcc, we use the +// carry directly. +static SDValue combineCarryThroughADD(SDValue EFLAGS) { + if (EFLAGS.getOpcode() == X86ISD::ADD) { + if (isAllOnesConstant(EFLAGS.getOperand(1))) { + SDValue Carry = EFLAGS.getOperand(0); + while (Carry.getOpcode() == ISD::TRUNCATE || + Carry.getOpcode() == ISD::ZERO_EXTEND || + Carry.getOpcode() == ISD::SIGN_EXTEND || + Carry.getOpcode() == ISD::ANY_EXTEND || + (Carry.getOpcode() == ISD::AND && + isOneConstant(Carry.getOperand(1)))) + Carry = Carry.getOperand(0); + if (Carry.getOpcode() == X86ISD::SETCC || + Carry.getOpcode() == X86ISD::SETCC_CARRY) { + if (Carry.getConstantOperandVal(0) == X86::COND_B) + return Carry.getOperand(1); + } + } + } + + return SDValue(); +} + /// Optimize an EFLAGS definition used according to the condition code \p CC /// into a simpler EFLAGS value, potentially returning a new \p CC and replacing /// uses of chain values. static SDValue combineSetCCEFLAGS(SDValue EFLAGS, X86::CondCode &CC, SelectionDAG &DAG) { + if (CC == X86::COND_B) + if (SDValue Flags = combineCarryThroughADD(EFLAGS)) + return Flags; + if (SDValue R = checkBoolTestSetCCCombine(EFLAGS, CC)) return R; return combineSetCCAtomicArith(EFLAGS, CC, DAG); @@ -32058,7 +32091,8 @@ static SDValue combineAndMaskToShift(SDNode *N, SelectionDAG &DAG, return SDValue(); APInt SplatVal; - if (!ISD::isConstantSplatVector(Op1.getNode(), SplatVal) || + if (!ISD::isConstantSplatVector(Op1.getNode(), SplatVal, + /*AllowShrink*/false) || !SplatVal.isMask()) return SDValue(); @@ -32642,7 +32676,8 @@ static SDValue detectUSatPattern(SDValue In, EVT VT) { "Unexpected types for truncate operation"); APInt C; - if (ISD::isConstantSplatVector(In.getOperand(1).getNode(), C)) { + if (ISD::isConstantSplatVector(In.getOperand(1).getNode(), C, + /*AllowShrink*/false)) { // C should be equal to UINT32_MAX / UINT16_MAX / UINT8_MAX according // the element size of the destination type. return C.isMask(VT.getScalarSizeInBits()) ? In.getOperand(0) : @@ -34983,27 +35018,13 @@ static SDValue combineSIntToFP(SDNode *N, SelectionDAG &DAG, return SDValue(); } -// Optimize RES, EFLAGS = X86ISD::ADD LHS, RHS -static SDValue combineX86ADD(SDNode *N, SelectionDAG &DAG, - X86TargetLowering::DAGCombinerInfo &DCI) { - // When legalizing carry, we create carries via add X, -1 - // If that comes from an actual carry, via setcc, we use the - // carry directly. - if (isAllOnesConstant(N->getOperand(1)) && N->hasAnyUseOfValue(1)) { - SDValue Carry = N->getOperand(0); - while (Carry.getOpcode() == ISD::TRUNCATE || - Carry.getOpcode() == ISD::ZERO_EXTEND || - Carry.getOpcode() == ISD::SIGN_EXTEND || - Carry.getOpcode() == ISD::ANY_EXTEND || - (Carry.getOpcode() == ISD::AND && - isOneConstant(Carry.getOperand(1)))) - Carry = Carry.getOperand(0); - - if (Carry.getOpcode() == X86ISD::SETCC || - Carry.getOpcode() == X86ISD::SETCC_CARRY) { - if (Carry.getConstantOperandVal(0) == X86::COND_B) - return DCI.CombineTo(N, SDValue(N, 0), Carry.getOperand(1)); - } +static SDValue combineSBB(SDNode *N, SelectionDAG &DAG) { + if (SDValue Flags = combineCarryThroughADD(N->getOperand(2))) { + MVT VT = N->getSimpleValueType(0); + SDVTList VTs = DAG.getVTList(VT, MVT::i32); + return DAG.getNode(X86ISD::SBB, SDLoc(N), VTs, + N->getOperand(0), N->getOperand(1), + Flags); } return SDValue(); @@ -35032,6 +35053,14 @@ static SDValue combineADC(SDNode *N, SelectionDAG &DAG, return DCI.CombineTo(N, Res1, CarryOut); } + if (SDValue Flags = combineCarryThroughADD(N->getOperand(2))) { + MVT VT = N->getSimpleValueType(0); + SDVTList VTs = DAG.getVTList(VT, MVT::i32); + return DAG.getNode(X86ISD::ADC, SDLoc(N), VTs, + N->getOperand(0), N->getOperand(1), + Flags); + } + return SDValue(); } @@ -35346,7 +35375,8 @@ static SDValue combineIncDecVector(SDNode *N, SelectionDAG &DAG) { SDNode *N1 = N->getOperand(1).getNode(); APInt SplatVal; - if (!ISD::isConstantSplatVector(N1, SplatVal) || !SplatVal.isOneValue()) + if (!ISD::isConstantSplatVector(N1, SplatVal, /*AllowShrink*/false) || + !SplatVal.isOneValue()) return SDValue(); SDValue AllOnesVec = getOnesVector(VT, DAG, SDLoc(N)); @@ -35670,7 +35700,7 @@ SDValue X86TargetLowering::PerformDAGCombine(SDNode *N, case X86ISD::CMOV: return combineCMov(N, DAG, DCI, Subtarget); case ISD::ADD: return combineAdd(N, DAG, Subtarget); case ISD::SUB: return combineSub(N, DAG, Subtarget); - case X86ISD::ADD: return combineX86ADD(N, DAG, DCI); + case X86ISD::SBB: return combineSBB(N, DAG); case X86ISD::ADC: return combineADC(N, DAG, DCI); case ISD::MUL: return combineMul(N, DAG, DCI, Subtarget); case ISD::SHL: diff --git contrib/llvm/lib/Target/X86/X86InstrAVX512.td contrib/llvm/lib/Target/X86/X86InstrAVX512.td index 0e654a380e7c..0ae960e7d566 100644 --- contrib/llvm/lib/Target/X86/X86InstrAVX512.td +++ contrib/llvm/lib/Target/X86/X86InstrAVX512.td @@ -3619,8 +3619,8 @@ let Predicates = [HasVLX] in { def : Pat<(alignedstore256 (v4f64 (extract_subvector (v8f64 VR512:$src), (iPTR 0))), addr:$dst), (VMOVAPDZ256mr addr:$dst, (v4f64 (EXTRACT_SUBREG VR512:$src,sub_ymm)))>; - def : Pat<(alignedstore (v8f32 (extract_subvector - (v16f32 VR512:$src), (iPTR 0))), addr:$dst), + def : Pat<(alignedstore256 (v8f32 (extract_subvector + (v16f32 VR512:$src), (iPTR 0))), addr:$dst), (VMOVAPSZ256mr addr:$dst, (v8f32 (EXTRACT_SUBREG VR512:$src,sub_ymm)))>; def : Pat<(alignedstore256 (v4i64 (extract_subvector (v8i64 VR512:$src), (iPTR 0))), addr:$dst), diff --git contrib/llvm/lib/Target/X86/X86SchedSandyBridge.td contrib/llvm/lib/Target/X86/X86SchedSandyBridge.td index 6d85ca6cad64..b8ec5883152c 100644 --- contrib/llvm/lib/Target/X86/X86SchedSandyBridge.td +++ contrib/llvm/lib/Target/X86/X86SchedSandyBridge.td @@ -24,8 +24,8 @@ def SandyBridgeModel : SchedMachineModel { // Based on the LSD (loop-stream detector) queue size. let LoopMicroOpBufferSize = 28; - // This flag is set to allow the scheduler to assign - // a default model to unrecognized opcodes. + // FIXME: SSE4 and AVX are unimplemented. This flag is set to allow + // the scheduler to assign a default model to unrecognized opcodes. let CompleteModel = 0; } @@ -48,7 +48,6 @@ def SBPort23 : ProcResource<2>; def SBPort4 : ProcResource<1>; // Many micro-ops are capable of issuing on multiple ports. -def SBPort01 : ProcResGroup<[SBPort0, SBPort1]>; def SBPort05 : ProcResGroup<[SBPort0, SBPort5]>; def SBPort15 : ProcResGroup<[SBPort1, SBPort5]>; def SBPort015 : ProcResGroup<[SBPort0, SBPort1, SBPort5]>; @@ -116,10 +115,10 @@ def : WriteRes<WriteIDivLd, [SBPort23, SBPort0, SBDivider]> { // Scalar and vector floating point. defm : SBWriteResPair<WriteFAdd, SBPort1, 3>; defm : SBWriteResPair<WriteFMul, SBPort0, 5>; -defm : SBWriteResPair<WriteFDiv, SBPort0, 24>; +defm : SBWriteResPair<WriteFDiv, SBPort0, 12>; // 10-14 cycles. defm : SBWriteResPair<WriteFRcp, SBPort0, 5>; defm : SBWriteResPair<WriteFRsqrt, SBPort0, 5>; -defm : SBWriteResPair<WriteFSqrt, SBPort0, 14>; +defm : SBWriteResPair<WriteFSqrt, SBPort0, 15>; defm : SBWriteResPair<WriteCvtF2I, SBPort1, 3>; defm : SBWriteResPair<WriteCvtI2F, SBPort1, 4>; defm : SBWriteResPair<WriteCvtF2F, SBPort1, 3>; @@ -135,11 +134,11 @@ def : WriteRes<WriteFVarBlendLd, [SBPort0, SBPort5, SBPort23]> { } // Vector integer operations. -defm : SBWriteResPair<WriteVecShift, SBPort5, 1>; -defm : SBWriteResPair<WriteVecLogic, SBPort5, 1>; -defm : SBWriteResPair<WriteVecALU, SBPort1, 3>; +defm : SBWriteResPair<WriteVecShift, SBPort05, 1>; +defm : SBWriteResPair<WriteVecLogic, SBPort015, 1>; +defm : SBWriteResPair<WriteVecALU, SBPort15, 1>; defm : SBWriteResPair<WriteVecIMul, SBPort0, 5>; -defm : SBWriteResPair<WriteShuffle, SBPort5, 1>; +defm : SBWriteResPair<WriteShuffle, SBPort15, 1>; defm : SBWriteResPair<WriteBlend, SBPort15, 1>; def : WriteRes<WriteVarBlend, [SBPort1, SBPort5]> { let Latency = 2; @@ -149,15 +148,13 @@ def : WriteRes<WriteVarBlendLd, [SBPort1, SBPort5, SBPort23]> { let Latency = 6; let ResourceCycles = [1, 1, 1]; } -def : WriteRes<WriteMPSAD, [SBPort0,SBPort15]> { - let Latency = 5; - let NumMicroOps = 3; - let ResourceCycles = [1,2]; +def : WriteRes<WriteMPSAD, [SBPort0, SBPort1, SBPort5]> { + let Latency = 6; + let ResourceCycles = [1, 1, 1]; } -def : WriteRes<WriteMPSADLd, [SBPort0,SBPort23,SBPort15]> { - let Latency = 11; - let NumMicroOps = 4; - let ResourceCycles = [1,1,2]; +def : WriteRes<WriteMPSADLd, [SBPort0, SBPort1, SBPort5, SBPort23]> { + let Latency = 6; + let ResourceCycles = [1, 1, 1, 1]; } //////////////////////////////////////////////////////////////////////////////// @@ -207,15 +204,13 @@ def : WriteRes<WritePCmpEStrMLd, [SBPort015, SBPort23]> { } // Packed Compare Implicit Length Strings, Return Index -def : WriteRes<WritePCmpIStrI, [SBPort0]> { - let Latency = 11; - let NumMicroOps = 3; +def : WriteRes<WritePCmpIStrI, [SBPort015]> { + let Latency = 3; let ResourceCycles = [3]; } -def : WriteRes<WritePCmpIStrILd, [SBPort0,SBPort23]> { - let Latency = 17; - let NumMicroOps = 4; - let ResourceCycles = [3,1]; +def : WriteRes<WritePCmpIStrILd, [SBPort015, SBPort23]> { + let Latency = 3; + let ResourceCycles = [3, 1]; } // Packed Compare Explicit Length Strings, Return Index @@ -229,26 +224,22 @@ def : WriteRes<WritePCmpEStrILd, [SBPort015, SBPort23]> { } // AES Instructions. -def : WriteRes<WriteAESDecEnc, [SBPort5,SBPort015]> { - let Latency = 7; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; +def : WriteRes<WriteAESDecEnc, [SBPort015]> { + let Latency = 8; + let ResourceCycles = [2]; } -def : WriteRes<WriteAESDecEncLd, [SBPort5,SBPort23,SBPort015]> { - let Latency = 13; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; +def : WriteRes<WriteAESDecEncLd, [SBPort015, SBPort23]> { + let Latency = 8; + let ResourceCycles = [2, 1]; } -def : WriteRes<WriteAESIMC, [SBPort5]> { - let Latency = 12; - let NumMicroOps = 2; +def : WriteRes<WriteAESIMC, [SBPort015]> { + let Latency = 8; let ResourceCycles = [2]; } -def : WriteRes<WriteAESIMCLd, [SBPort5,SBPort23]> { - let Latency = 18; - let NumMicroOps = 3; - let ResourceCycles = [2,1]; +def : WriteRes<WriteAESIMCLd, [SBPort015, SBPort23]> { + let Latency = 8; + let ResourceCycles = [2, 1]; } def : WriteRes<WriteAESKeyGen, [SBPort015]> { @@ -281,2407 +272,4 @@ def : WriteRes<WriteNop, []>; defm : SBWriteResPair<WriteFShuffle256, SBPort0, 1>; defm : SBWriteResPair<WriteShuffle256, SBPort0, 1>; defm : SBWriteResPair<WriteVarVecShift, SBPort0, 1>; - -// Remaining SNB instrs. - -def SBWriteResGroup0 : SchedWriteRes<[SBPort0]> { - let Latency = 1; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup0], (instregex "CVTSS2SDrr")>; -def: InstRW<[SBWriteResGroup0], (instregex "PSLLDri")>; -def: InstRW<[SBWriteResGroup0], (instregex "PSLLQri")>; -def: InstRW<[SBWriteResGroup0], (instregex "PSLLWri")>; -def: InstRW<[SBWriteResGroup0], (instregex "PSRADri")>; -def: InstRW<[SBWriteResGroup0], (instregex "PSRAWri")>; -def: InstRW<[SBWriteResGroup0], (instregex "PSRLDri")>; -def: InstRW<[SBWriteResGroup0], (instregex "PSRLQri")>; -def: InstRW<[SBWriteResGroup0], (instregex "PSRLWri")>; -def: InstRW<[SBWriteResGroup0], (instregex "VCVTSS2SDrr")>; -def: InstRW<[SBWriteResGroup0], (instregex "VPMOVMSKBrr")>; -def: InstRW<[SBWriteResGroup0], (instregex "VPSLLDri")>; -def: InstRW<[SBWriteResGroup0], (instregex "VPSLLQri")>; -def: InstRW<[SBWriteResGroup0], (instregex "VPSLLWri")>; -def: InstRW<[SBWriteResGroup0], (instregex "VPSRADri")>; -def: InstRW<[SBWriteResGroup0], (instregex "VPSRAWri")>; -def: InstRW<[SBWriteResGroup0], (instregex "VPSRLDri")>; -def: InstRW<[SBWriteResGroup0], (instregex "VPSRLQri")>; -def: InstRW<[SBWriteResGroup0], (instregex "VPSRLWri")>; -def: InstRW<[SBWriteResGroup0], (instregex "VTESTPDYrr")>; -def: InstRW<[SBWriteResGroup0], (instregex "VTESTPDrr")>; -def: InstRW<[SBWriteResGroup0], (instregex "VTESTPSYrr")>; -def: InstRW<[SBWriteResGroup0], (instregex "VTESTPSrr")>; - -def SBWriteResGroup1 : SchedWriteRes<[SBPort1]> { - let Latency = 1; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup1], (instregex "COMP_FST0r")>; -def: InstRW<[SBWriteResGroup1], (instregex "COM_FST0r")>; -def: InstRW<[SBWriteResGroup1], (instregex "UCOM_FPr")>; -def: InstRW<[SBWriteResGroup1], (instregex "UCOM_Fr")>; - -def SBWriteResGroup2 : SchedWriteRes<[SBPort5]> { - let Latency = 1; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup2], (instregex "ANDNPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "ANDNPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "ANDPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "ANDPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "FDECSTP")>; -def: InstRW<[SBWriteResGroup2], (instregex "FFREE")>; -def: InstRW<[SBWriteResGroup2], (instregex "FINCSTP")>; -def: InstRW<[SBWriteResGroup2], (instregex "FNOP")>; -def: InstRW<[SBWriteResGroup2], (instregex "INSERTPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "JMP64r")>; -def: InstRW<[SBWriteResGroup2], (instregex "LD_Frr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOV64toPQIrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOVAPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOVAPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOVDDUPrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOVDI2PDIrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOVHLPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOVLHPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOVSDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOVSHDUPrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOVSLDUPrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOVSSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOVUPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "MOVUPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "ORPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "ORPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "RETQ")>; -def: InstRW<[SBWriteResGroup2], (instregex "SHUFPDrri")>; -def: InstRW<[SBWriteResGroup2], (instregex "SHUFPSrri")>; -def: InstRW<[SBWriteResGroup2], (instregex "ST_FPrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "ST_Frr")>; -def: InstRW<[SBWriteResGroup2], (instregex "UNPCKHPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "UNPCKHPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "UNPCKLPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "UNPCKLPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VANDNPDYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VANDNPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VANDNPSYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VANDNPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VANDPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VANDPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VANDPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VEXTRACTF128rr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VINSERTF128rr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VINSERTPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOV64toPQIrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOV64toPQIrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVAPDYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVAPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVAPSYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVAPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVDDUPYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVDDUPrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVHLPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVHLPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVSDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVSHDUPYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVSHDUPrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVSLDUPYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVSLDUPrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVSSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVUPDYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVUPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVUPSYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VMOVUPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VORPDYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VORPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VORPSYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VORPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VPERMILPDri")>; -def: InstRW<[SBWriteResGroup2], (instregex "VPERMILPDrm")>; -def: InstRW<[SBWriteResGroup2], (instregex "VPERMILPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VPERMILPSri")>; -def: InstRW<[SBWriteResGroup2], (instregex "VPERMILPSrm")>; -def: InstRW<[SBWriteResGroup2], (instregex "VPERMILPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VPERMILPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VSHUFPDYrri")>; -def: InstRW<[SBWriteResGroup2], (instregex "VSHUFPDrri")>; -def: InstRW<[SBWriteResGroup2], (instregex "VSHUFPSYrri")>; -def: InstRW<[SBWriteResGroup2], (instregex "VSHUFPSrri")>; -def: InstRW<[SBWriteResGroup2], (instregex "VUNPCKHPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VUNPCKHPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VUNPCKLPDYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VUNPCKLPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VUNPCKLPSYrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VUNPCKLPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VXORPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "VXORPSrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "XORPDrr")>; -def: InstRW<[SBWriteResGroup2], (instregex "XORPSrr")>; - -def SBWriteResGroup3 : SchedWriteRes<[SBPort01]> { - let Latency = 1; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup3], (instregex "LEA64_32r")>; - -def SBWriteResGroup4 : SchedWriteRes<[SBPort0]> { - let Latency = 1; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup4], (instregex "BLENDPDrri")>; -def: InstRW<[SBWriteResGroup4], (instregex "BLENDPSrri")>; -def: InstRW<[SBWriteResGroup4], (instregex "BT32ri8")>; -def: InstRW<[SBWriteResGroup4], (instregex "BT32rr")>; -def: InstRW<[SBWriteResGroup4], (instregex "BTC32ri8")>; -def: InstRW<[SBWriteResGroup4], (instregex "BTC32rr")>; -def: InstRW<[SBWriteResGroup4], (instregex "BTR32ri8")>; -def: InstRW<[SBWriteResGroup4], (instregex "BTR32rr")>; -def: InstRW<[SBWriteResGroup4], (instregex "BTS32ri8")>; -def: InstRW<[SBWriteResGroup4], (instregex "BTS32rr")>; -def: InstRW<[SBWriteResGroup4], (instregex "CDQ")>; -def: InstRW<[SBWriteResGroup4], (instregex "CQO")>; -def: InstRW<[SBWriteResGroup4], (instregex "LAHF")>; -def: InstRW<[SBWriteResGroup4], (instregex "SAHF")>; -def: InstRW<[SBWriteResGroup4], (instregex "SAR32ri")>; -def: InstRW<[SBWriteResGroup4], (instregex "SAR8ri")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETAEr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETBr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETEr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETGEr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETGr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETLEr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETLr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETNEr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETNOr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETNPr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETNSr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETOr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETPr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SETSr")>; -def: InstRW<[SBWriteResGroup4], (instregex "SHL32ri")>; -def: InstRW<[SBWriteResGroup4], (instregex "SHL64r1")>; -def: InstRW<[SBWriteResGroup4], (instregex "SHL8r1")>; -def: InstRW<[SBWriteResGroup4], (instregex "SHL8ri")>; -def: InstRW<[SBWriteResGroup4], (instregex "SHR32ri")>; -def: InstRW<[SBWriteResGroup4], (instregex "SHR8ri")>; -def: InstRW<[SBWriteResGroup4], (instregex "VBLENDPDYrri")>; -def: InstRW<[SBWriteResGroup4], (instregex "VBLENDPDrri")>; -def: InstRW<[SBWriteResGroup4], (instregex "VBLENDPSYrri")>; -def: InstRW<[SBWriteResGroup4], (instregex "VBLENDPSrri")>; -def: InstRW<[SBWriteResGroup4], (instregex "VMOVDQAYrr")>; -def: InstRW<[SBWriteResGroup4], (instregex "VMOVDQArr")>; -def: InstRW<[SBWriteResGroup4], (instregex "VMOVDQUYrr")>; -def: InstRW<[SBWriteResGroup4], (instregex "VMOVDQUrr")>; - -def SBWriteResGroup5 : SchedWriteRes<[SBPort15]> { - let Latency = 1; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup5], (instregex "KORTESTBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "MMX_PABSBrr64")>; -def: InstRW<[SBWriteResGroup5], (instregex "MMX_PABSDrr64")>; -def: InstRW<[SBWriteResGroup5], (instregex "MMX_PABSWrr64")>; -def: InstRW<[SBWriteResGroup5], (instregex "MMX_PADDQirr")>; -def: InstRW<[SBWriteResGroup5], (instregex "MMX_PALIGNR64irr")>; -def: InstRW<[SBWriteResGroup5], (instregex "MMX_PSHUFBrr64")>; -def: InstRW<[SBWriteResGroup5], (instregex "MMX_PSIGNBrr64")>; -def: InstRW<[SBWriteResGroup5], (instregex "MMX_PSIGNDrr64")>; -def: InstRW<[SBWriteResGroup5], (instregex "MMX_PSIGNWrr64")>; -def: InstRW<[SBWriteResGroup5], (instregex "PABSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PABSDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PABSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PACKSSDWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PACKSSWBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PACKUSDWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PACKUSWBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PADDBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PADDDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PADDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PADDSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PADDSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PADDUSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PADDUSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PADDWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PALIGNRrri")>; -def: InstRW<[SBWriteResGroup5], (instregex "PAVGBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PAVGWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PBLENDWrri")>; -def: InstRW<[SBWriteResGroup5], (instregex "PCMPEQBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PCMPEQDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PCMPEQQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PCMPEQWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PCMPGTBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PCMPGTDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PCMPGTWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMAXSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMAXSDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMAXSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMAXUBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMAXUDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMAXUWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMINSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMINSDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMINSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMINUBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMINUDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMINUWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMOVSXBDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMOVSXBQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMOVSXBWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMOVSXDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMOVSXWDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMOVSXWQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMOVZXBDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMOVZXBQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMOVZXBWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMOVZXDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMOVZXWDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PMOVZXWQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSHUFBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSHUFDri")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSHUFHWri")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSHUFLWri")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSIGNBrr128")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSIGNDrr128")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSIGNWrr128")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSLLDQri")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSRLDQri")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSUBBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSUBDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSUBQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSUBSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSUBSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSUBUSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSUBUSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PSUBWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PUNPCKHBWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PUNPCKHDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PUNPCKHQDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PUNPCKHWDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PUNPCKLBWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PUNPCKLDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PUNPCKLQDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "PUNPCKLWDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VMASKMOVPSYrm")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPABSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPABSDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPABSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPACKSSDWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPACKSSWBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPACKUSDWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPACKUSWBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPADDBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPADDDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPADDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPADDUSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPADDUSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPALIGNRrri")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPAVGBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPAVGWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPBLENDWrri")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPCMPEQBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPCMPEQDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPCMPEQWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPCMPGTBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPCMPGTDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPCMPGTWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMAXSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMAXSDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMAXSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMAXUBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMAXUDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMAXUWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMINSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMINSDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMINSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMINUBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMINUDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMINUWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMOVSXBDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMOVSXBQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMOVSXBWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMOVSXDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMOVSXWDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMOVSXWQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMOVZXBDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMOVZXBQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMOVZXBWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMOVZXDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMOVZXWDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPMOVZXWQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSHUFBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSHUFDri")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSHUFLWri")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSIGNBrr128")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSIGNDrr128")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSIGNWrr128")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSLLDQri")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSRLDQri")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSUBBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSUBDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSUBQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSUBSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSUBSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSUBUSBrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSUBUSWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPSUBWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPUNPCKHBWrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPUNPCKHDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPUNPCKHWDrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPUNPCKLDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPUNPCKLQDQrr")>; -def: InstRW<[SBWriteResGroup5], (instregex "VPUNPCKLWDrr")>; - -def SBWriteResGroup6 : SchedWriteRes<[SBPort015]> { - let Latency = 1; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup6], (instregex "ADD32ri8")>; -def: InstRW<[SBWriteResGroup6], (instregex "ADD32rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "ADD8ri")>; -def: InstRW<[SBWriteResGroup6], (instregex "ADD8rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "AND32ri")>; -def: InstRW<[SBWriteResGroup6], (instregex "AND64ri8")>; -def: InstRW<[SBWriteResGroup6], (instregex "AND64rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "AND8ri")>; -def: InstRW<[SBWriteResGroup6], (instregex "AND8rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "CBW")>; -def: InstRW<[SBWriteResGroup6], (instregex "CMC")>; -def: InstRW<[SBWriteResGroup6], (instregex "CMP16ri8")>; -def: InstRW<[SBWriteResGroup6], (instregex "CMP32i32")>; -def: InstRW<[SBWriteResGroup6], (instregex "CMP64rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "CMP8ri")>; -def: InstRW<[SBWriteResGroup6], (instregex "CMP8rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "CWDE")>; -def: InstRW<[SBWriteResGroup6], (instregex "DEC64r")>; -def: InstRW<[SBWriteResGroup6], (instregex "DEC8r")>; -def: InstRW<[SBWriteResGroup6], (instregex "INC64r")>; -def: InstRW<[SBWriteResGroup6], (instregex "INC8r")>; -def: InstRW<[SBWriteResGroup6], (instregex "MMX_MOVD64from64rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "MMX_MOVQ2DQrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "MOV32rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "MOV8ri")>; -def: InstRW<[SBWriteResGroup6], (instregex "MOV8rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "MOVDQArr")>; -def: InstRW<[SBWriteResGroup6], (instregex "MOVDQUrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "MOVPQI2QIrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "MOVSX32rr16")>; -def: InstRW<[SBWriteResGroup6], (instregex "MOVSX32rr8")>; -def: InstRW<[SBWriteResGroup6], (instregex "MOVZX32rr16")>; -def: InstRW<[SBWriteResGroup6], (instregex "MOVZX32rr8")>; -def: InstRW<[SBWriteResGroup6], (instregex "NEG64r")>; -def: InstRW<[SBWriteResGroup6], (instregex "NEG8r")>; -def: InstRW<[SBWriteResGroup6], (instregex "NOT64r")>; -def: InstRW<[SBWriteResGroup6], (instregex "NOT8r")>; -def: InstRW<[SBWriteResGroup6], (instregex "OR64ri8")>; -def: InstRW<[SBWriteResGroup6], (instregex "OR64rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "OR8ri")>; -def: InstRW<[SBWriteResGroup6], (instregex "OR8rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "PANDNrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "PANDrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "PORrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "PXORrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "STC")>; -def: InstRW<[SBWriteResGroup6], (instregex "SUB64ri8")>; -def: InstRW<[SBWriteResGroup6], (instregex "SUB64rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "SUB8ri")>; -def: InstRW<[SBWriteResGroup6], (instregex "SUB8rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "TEST64rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "TEST8ri")>; -def: InstRW<[SBWriteResGroup6], (instregex "TEST8rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "VMOVPQI2QIrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "VMOVZPQILo2PQIrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "VPANDNrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "VPANDrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "VPORrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "VPXORrr")>; -def: InstRW<[SBWriteResGroup6], (instregex "XOR32rr")>; -def: InstRW<[SBWriteResGroup6], (instregex "XOR64ri8")>; -def: InstRW<[SBWriteResGroup6], (instregex "XOR8ri")>; -def: InstRW<[SBWriteResGroup6], (instregex "XOR8rr")>; - -def SBWriteResGroup7 : SchedWriteRes<[SBPort0]> { - let Latency = 2; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup7], (instregex "MOVMSKPDrr")>; -def: InstRW<[SBWriteResGroup7], (instregex "MOVMSKPSrr")>; -def: InstRW<[SBWriteResGroup7], (instregex "MOVPDI2DIrr")>; -def: InstRW<[SBWriteResGroup7], (instregex "MOVPQIto64rr")>; -def: InstRW<[SBWriteResGroup7], (instregex "PMOVMSKBrr")>; -def: InstRW<[SBWriteResGroup7], (instregex "VMOVMSKPDYrr")>; -def: InstRW<[SBWriteResGroup7], (instregex "VMOVMSKPDrr")>; -def: InstRW<[SBWriteResGroup7], (instregex "VMOVMSKPSrr")>; -def: InstRW<[SBWriteResGroup7], (instregex "VMOVPDI2DIrr")>; -def: InstRW<[SBWriteResGroup7], (instregex "VMOVPQIto64rr")>; - -def SBWriteResGroup9 : SchedWriteRes<[SBPort0]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [2]; -} -def: InstRW<[SBWriteResGroup9], (instregex "BLENDVPDrr0")>; -def: InstRW<[SBWriteResGroup9], (instregex "BLENDVPSrr0")>; -def: InstRW<[SBWriteResGroup9], (instregex "ROL32ri")>; -def: InstRW<[SBWriteResGroup9], (instregex "ROL8ri")>; -def: InstRW<[SBWriteResGroup9], (instregex "ROR32ri")>; -def: InstRW<[SBWriteResGroup9], (instregex "ROR8ri")>; -def: InstRW<[SBWriteResGroup9], (instregex "SETAr")>; -def: InstRW<[SBWriteResGroup9], (instregex "SETBEr")>; -def: InstRW<[SBWriteResGroup9], (instregex "VBLENDVPDYrr")>; -def: InstRW<[SBWriteResGroup9], (instregex "VBLENDVPDrr")>; -def: InstRW<[SBWriteResGroup9], (instregex "VBLENDVPSYrr")>; -def: InstRW<[SBWriteResGroup9], (instregex "VBLENDVPSrr")>; - -def SBWriteResGroup10 : SchedWriteRes<[SBPort15]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [2]; -} -def: InstRW<[SBWriteResGroup10], (instregex "VPBLENDVBrr")>; - -def SBWriteResGroup11 : SchedWriteRes<[SBPort015]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [2]; -} -def: InstRW<[SBWriteResGroup11], (instregex "SCASB")>; -def: InstRW<[SBWriteResGroup11], (instregex "SCASL")>; -def: InstRW<[SBWriteResGroup11], (instregex "SCASQ")>; -def: InstRW<[SBWriteResGroup11], (instregex "SCASW")>; - -def SBWriteResGroup12 : SchedWriteRes<[SBPort0,SBPort1]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup12], (instregex "COMISDrr")>; -def: InstRW<[SBWriteResGroup12], (instregex "COMISSrr")>; -def: InstRW<[SBWriteResGroup12], (instregex "UCOMISDrr")>; -def: InstRW<[SBWriteResGroup12], (instregex "UCOMISSrr")>; -def: InstRW<[SBWriteResGroup12], (instregex "VCOMISDrr")>; -def: InstRW<[SBWriteResGroup12], (instregex "VCOMISSrr")>; -def: InstRW<[SBWriteResGroup12], (instregex "VUCOMISDrr")>; -def: InstRW<[SBWriteResGroup12], (instregex "VUCOMISSrr")>; - -def SBWriteResGroup13 : SchedWriteRes<[SBPort0,SBPort5]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup13], (instregex "CVTPS2PDrr")>; -def: InstRW<[SBWriteResGroup13], (instregex "PTESTrr")>; -def: InstRW<[SBWriteResGroup13], (instregex "VCVTPS2PDYrr")>; -def: InstRW<[SBWriteResGroup13], (instregex "VCVTPS2PDrr")>; -def: InstRW<[SBWriteResGroup13], (instregex "VPTESTYrr")>; -def: InstRW<[SBWriteResGroup13], (instregex "VPTESTrr")>; - -def SBWriteResGroup14 : SchedWriteRes<[SBPort0,SBPort15]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup14], (instregex "PSLLDrr")>; -def: InstRW<[SBWriteResGroup14], (instregex "PSLLQrr")>; -def: InstRW<[SBWriteResGroup14], (instregex "PSLLWrr")>; -def: InstRW<[SBWriteResGroup14], (instregex "PSRADrr")>; -def: InstRW<[SBWriteResGroup14], (instregex "PSRAWrr")>; -def: InstRW<[SBWriteResGroup14], (instregex "PSRLDrr")>; -def: InstRW<[SBWriteResGroup14], (instregex "PSRLQrr")>; -def: InstRW<[SBWriteResGroup14], (instregex "PSRLWrr")>; -def: InstRW<[SBWriteResGroup14], (instregex "VPSRADrr")>; -def: InstRW<[SBWriteResGroup14], (instregex "VPSRAWrr")>; -def: InstRW<[SBWriteResGroup14], (instregex "VPSRLDrr")>; -def: InstRW<[SBWriteResGroup14], (instregex "VPSRLQrr")>; -def: InstRW<[SBWriteResGroup14], (instregex "VPSRLWrr")>; - -def SBWriteResGroup15 : SchedWriteRes<[SBPort0,SBPort015]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup15], (instregex "FNSTSW16r")>; - -def SBWriteResGroup16 : SchedWriteRes<[SBPort1,SBPort0]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup16], (instregex "BSWAP32r")>; - -def SBWriteResGroup17 : SchedWriteRes<[SBPort5,SBPort15]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup17], (instregex "PINSRBrr")>; -def: InstRW<[SBWriteResGroup17], (instregex "PINSRDrr")>; -def: InstRW<[SBWriteResGroup17], (instregex "PINSRQrr")>; -def: InstRW<[SBWriteResGroup17], (instregex "PINSRWrri")>; -def: InstRW<[SBWriteResGroup17], (instregex "VPINSRBrr")>; -def: InstRW<[SBWriteResGroup17], (instregex "VPINSRDrr")>; -def: InstRW<[SBWriteResGroup17], (instregex "VPINSRQrr")>; -def: InstRW<[SBWriteResGroup17], (instregex "VPINSRWrri")>; - -def SBWriteResGroup18 : SchedWriteRes<[SBPort5,SBPort015]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup18], (instregex "MMX_MOVDQ2Qrr")>; - -def SBWriteResGroup19 : SchedWriteRes<[SBPort0,SBPort015]> { - let Latency = 2; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup19], (instregex "ADC64ri8")>; -def: InstRW<[SBWriteResGroup19], (instregex "ADC64rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "ADC8ri")>; -def: InstRW<[SBWriteResGroup19], (instregex "ADC8rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVAE32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVB32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVE32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVG32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVGE32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVL32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVLE32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVNE32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVNO32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVNP32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVNS32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVO32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVP32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "CMOVS32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "SBB32rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "SBB64ri8")>; -def: InstRW<[SBWriteResGroup19], (instregex "SBB8ri")>; -def: InstRW<[SBWriteResGroup19], (instregex "SBB8rr")>; -def: InstRW<[SBWriteResGroup19], (instregex "SHLD32rri8")>; -def: InstRW<[SBWriteResGroup19], (instregex "SHRD32rri8")>; - -def SBWriteResGroup20 : SchedWriteRes<[SBPort0]> { - let Latency = 3; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup20], (instregex "MMX_PMADDUBSWrr64")>; -def: InstRW<[SBWriteResGroup20], (instregex "MMX_PMULHRSWrr64")>; -def: InstRW<[SBWriteResGroup20], (instregex "MMX_PMULUDQirr")>; -def: InstRW<[SBWriteResGroup20], (instregex "PMADDUBSWrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "PMADDWDrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "PMULDQrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "PMULHRSWrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "PMULHUWrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "PMULHWrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "PMULLDrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "PMULLWrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "PMULUDQrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "PSADBWrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "VMOVMSKPSYrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "VPMADDUBSWrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "VPMADDWDrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "VPMULDQrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "VPMULHRSWrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "VPMULHWrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "VPMULLDrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "VPMULLWrr")>; -def: InstRW<[SBWriteResGroup20], (instregex "VPSADBWrr")>; - -def SBWriteResGroup21 : SchedWriteRes<[SBPort1]> { - let Latency = 3; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup21], (instregex "ADDPDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "ADDPSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "ADDSDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "ADDSSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "ADDSUBPDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "ADDSUBPSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "ADD_FPrST0")>; -def: InstRW<[SBWriteResGroup21], (instregex "ADD_FST0r")>; -def: InstRW<[SBWriteResGroup21], (instregex "ADD_FrST0")>; -def: InstRW<[SBWriteResGroup21], (instregex "BSF32rr")>; -def: InstRW<[SBWriteResGroup21], (instregex "BSR32rr")>; -def: InstRW<[SBWriteResGroup21], (instregex "CMPPDrri")>; -def: InstRW<[SBWriteResGroup21], (instregex "CMPPSrri")>; -def: InstRW<[SBWriteResGroup21], (instregex "CMPSDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "CMPSSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "CRC32r32r32")>; -def: InstRW<[SBWriteResGroup21], (instregex "CRC32r32r8")>; -def: InstRW<[SBWriteResGroup21], (instregex "CVTDQ2PSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "CVTPS2DQrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "CVTTPS2DQrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "MAXPDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "MAXPSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "MAXSDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "MAXSSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "MINPDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "MINPSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "MINSDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "MINSSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "MMX_CVTPI2PSirr")>; -def: InstRW<[SBWriteResGroup21], (instregex "MMX_CVTPS2PIirr")>; -def: InstRW<[SBWriteResGroup21], (instregex "MMX_CVTTPS2PIirr")>; -def: InstRW<[SBWriteResGroup21], (instregex "MUL8r")>; -def: InstRW<[SBWriteResGroup21], (instregex "POPCNT32rr")>; -def: InstRW<[SBWriteResGroup21], (instregex "ROUNDPDr")>; -def: InstRW<[SBWriteResGroup21], (instregex "ROUNDPSr")>; -def: InstRW<[SBWriteResGroup21], (instregex "ROUNDSDr")>; -def: InstRW<[SBWriteResGroup21], (instregex "ROUNDSSr")>; -def: InstRW<[SBWriteResGroup21], (instregex "SUBPDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "SUBPSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "SUBR_FPrST0")>; -def: InstRW<[SBWriteResGroup21], (instregex "SUBR_FST0r")>; -def: InstRW<[SBWriteResGroup21], (instregex "SUBR_FrST0")>; -def: InstRW<[SBWriteResGroup21], (instregex "SUBSDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "SUBSSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "SUB_FPrST0")>; -def: InstRW<[SBWriteResGroup21], (instregex "SUB_FST0r")>; -def: InstRW<[SBWriteResGroup21], (instregex "SUB_FrST0")>; -def: InstRW<[SBWriteResGroup21], (instregex "VADDPDYrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VADDPDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VADDPSYrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VADDPSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VADDSDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VADDSSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VADDSUBPDYrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VADDSUBPDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VADDSUBPSYrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VADDSUBPSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VBROADCASTF128")>; -def: InstRW<[SBWriteResGroup21], (instregex "VCMPPDYrri")>; -def: InstRW<[SBWriteResGroup21], (instregex "VCMPPDrri")>; -def: InstRW<[SBWriteResGroup21], (instregex "VCMPPSYrri")>; -def: InstRW<[SBWriteResGroup21], (instregex "VCMPPSrri")>; -def: InstRW<[SBWriteResGroup21], (instregex "VCMPSDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VCMPSSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VCVTDQ2PSYrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VCVTDQ2PSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VCVTPS2DQYrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VCVTPS2DQrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VCVTTPS2DQrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VMAXPDYrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VMAXPDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VMAXPSYrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VMAXPSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VMAXSDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VMAXSSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VMINPDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VMINPSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VMINSDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VMINSSrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VROUNDPDr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VROUNDPSr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VROUNDSDr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VSUBPDYrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VSUBPDrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VSUBPSYrr")>; -def: InstRW<[SBWriteResGroup21], (instregex "VSUBPSrr")>; - -def SBWriteResGroup22 : SchedWriteRes<[SBPort0,SBPort5]> { - let Latency = 3; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup22], (instregex "EXTRACTPSrr")>; -def: InstRW<[SBWriteResGroup22], (instregex "VEXTRACTPSrr")>; - -def SBWriteResGroup23 : SchedWriteRes<[SBPort0,SBPort15]> { - let Latency = 3; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup23], (instregex "PEXTRBrr")>; -def: InstRW<[SBWriteResGroup23], (instregex "PEXTRDrr")>; -def: InstRW<[SBWriteResGroup23], (instregex "PEXTRQrr")>; -def: InstRW<[SBWriteResGroup23], (instregex "PEXTRWri")>; -def: InstRW<[SBWriteResGroup23], (instregex "VPEXTRBrr")>; -def: InstRW<[SBWriteResGroup23], (instregex "VPEXTRDrr")>; -def: InstRW<[SBWriteResGroup23], (instregex "VPEXTRQrr")>; -def: InstRW<[SBWriteResGroup23], (instregex "VPEXTRWri")>; -def: InstRW<[SBWriteResGroup23], (instregex "SHL64rCL")>; -def: InstRW<[SBWriteResGroup23], (instregex "SHL8rCL")>; - -def SBWriteResGroup24 : SchedWriteRes<[SBPort15]> { - let Latency = 3; - let NumMicroOps = 3; - let ResourceCycles = [3]; -} -def: InstRW<[SBWriteResGroup24], (instregex "MMX_PHADDSWrr64")>; -def: InstRW<[SBWriteResGroup24], (instregex "MMX_PHADDWrr64")>; -def: InstRW<[SBWriteResGroup24], (instregex "MMX_PHADDrr64")>; -def: InstRW<[SBWriteResGroup24], (instregex "MMX_PHSUBDrr64")>; -def: InstRW<[SBWriteResGroup24], (instregex "MMX_PHSUBSWrr64")>; -def: InstRW<[SBWriteResGroup24], (instregex "MMX_PHSUBWrr64")>; -def: InstRW<[SBWriteResGroup24], (instregex "PHADDDrr")>; -def: InstRW<[SBWriteResGroup24], (instregex "PHADDSWrr128")>; -def: InstRW<[SBWriteResGroup24], (instregex "PHADDWrr")>; -def: InstRW<[SBWriteResGroup24], (instregex "PHSUBDrr")>; -def: InstRW<[SBWriteResGroup24], (instregex "PHSUBSWrr128")>; -def: InstRW<[SBWriteResGroup24], (instregex "PHSUBWrr")>; -def: InstRW<[SBWriteResGroup24], (instregex "VPHADDDrr")>; -def: InstRW<[SBWriteResGroup24], (instregex "VPHADDSWrr128")>; -def: InstRW<[SBWriteResGroup24], (instregex "VPHADDWrr")>; -def: InstRW<[SBWriteResGroup24], (instregex "VPHSUBDrr")>; -def: InstRW<[SBWriteResGroup24], (instregex "VPHSUBSWrr128")>; -def: InstRW<[SBWriteResGroup24], (instregex "VPHSUBWrr")>; - -def SBWriteResGroup25 : SchedWriteRes<[SBPort015]> { - let Latency = 3; - let NumMicroOps = 3; - let ResourceCycles = [3]; -} -def: InstRW<[SBWriteResGroup25], (instregex "LEAVE64")>; -def: InstRW<[SBWriteResGroup25], (instregex "XADD32rr")>; -def: InstRW<[SBWriteResGroup25], (instregex "XADD8rr")>; - -def SBWriteResGroup26 : SchedWriteRes<[SBPort0,SBPort015]> { - let Latency = 3; - let NumMicroOps = 3; - let ResourceCycles = [2,1]; -} -def: InstRW<[SBWriteResGroup26], (instregex "CMOVA32rr")>; -def: InstRW<[SBWriteResGroup26], (instregex "CMOVBE32rr")>; - -def SBWriteResGroup27 : SchedWriteRes<[SBPort0,SBPort1]> { - let Latency = 4; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup27], (instregex "MUL64r")>; - -def SBWriteResGroup28 : SchedWriteRes<[SBPort1,SBPort5]> { - let Latency = 4; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup28], (instregex "CVTDQ2PDrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "CVTPD2DQrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "CVTPD2PSrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "CVTSD2SSrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "CVTSI2SD64rr")>; -def: InstRW<[SBWriteResGroup28], (instregex "CVTSI2SDrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "CVTTPD2DQrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "MMX_CVTPD2PIirr")>; -def: InstRW<[SBWriteResGroup28], (instregex "MMX_CVTPI2PDirr")>; -def: InstRW<[SBWriteResGroup28], (instregex "MMX_CVTTPD2PIirr")>; -def: InstRW<[SBWriteResGroup28], (instregex "VCVTDQ2PDYrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "VCVTDQ2PDrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "VCVTPD2DQYrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "VCVTPD2DQrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "VCVTPD2PSYrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "VCVTPD2PSrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "VCVTSI2SD64rr")>; -def: InstRW<[SBWriteResGroup28], (instregex "VCVTSI2SDrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "VCVTTPD2DQYrr")>; -def: InstRW<[SBWriteResGroup28], (instregex "VCVTTPD2DQrr")>; - -def SBWriteResGroup29 : SchedWriteRes<[SBPort1,SBPort015]> { - let Latency = 4; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup29], (instregex "MOV64sr")>; -def: InstRW<[SBWriteResGroup29], (instregex "PAUSE")>; - -def SBWriteResGroup30 : SchedWriteRes<[SBPort0]> { - let Latency = 5; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup30], (instregex "MULPDrr")>; -def: InstRW<[SBWriteResGroup30], (instregex "MULPSrr")>; -def: InstRW<[SBWriteResGroup30], (instregex "MULSDrr")>; -def: InstRW<[SBWriteResGroup30], (instregex "MULSSrr")>; -def: InstRW<[SBWriteResGroup30], (instregex "MUL_FPrST0")>; -def: InstRW<[SBWriteResGroup30], (instregex "MUL_FST0r")>; -def: InstRW<[SBWriteResGroup30], (instregex "MUL_FrST0")>; -def: InstRW<[SBWriteResGroup30], (instregex "PCMPGTQrr")>; -def: InstRW<[SBWriteResGroup30], (instregex "PHMINPOSUWrr128")>; -def: InstRW<[SBWriteResGroup30], (instregex "RCPPSr")>; -def: InstRW<[SBWriteResGroup30], (instregex "RCPSSr")>; -def: InstRW<[SBWriteResGroup30], (instregex "RSQRTPSr")>; -def: InstRW<[SBWriteResGroup30], (instregex "RSQRTSSr")>; -def: InstRW<[SBWriteResGroup30], (instregex "VMULPDYrr")>; -def: InstRW<[SBWriteResGroup30], (instregex "VMULPDrr")>; -def: InstRW<[SBWriteResGroup30], (instregex "VMULPSYrr")>; -def: InstRW<[SBWriteResGroup30], (instregex "VMULPSrr")>; -def: InstRW<[SBWriteResGroup30], (instregex "VMULSDrr")>; -def: InstRW<[SBWriteResGroup30], (instregex "VMULSSrr")>; -def: InstRW<[SBWriteResGroup30], (instregex "VPCMPGTQrr")>; -def: InstRW<[SBWriteResGroup30], (instregex "VPHMINPOSUWrr128")>; -def: InstRW<[SBWriteResGroup30], (instregex "VRSQRTPSr")>; -def: InstRW<[SBWriteResGroup30], (instregex "VRSQRTSSr")>; - -def SBWriteResGroup31 : SchedWriteRes<[SBPort23]> { - let Latency = 5; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup31], (instregex "MOV32rm")>; -def: InstRW<[SBWriteResGroup31], (instregex "MOV8rm")>; -def: InstRW<[SBWriteResGroup31], (instregex "MOVSX32rm16")>; -def: InstRW<[SBWriteResGroup31], (instregex "MOVSX32rm8")>; -def: InstRW<[SBWriteResGroup31], (instregex "MOVZX32rm16")>; -def: InstRW<[SBWriteResGroup31], (instregex "MOVZX32rm8")>; -def: InstRW<[SBWriteResGroup31], (instregex "PREFETCH")>; - -def SBWriteResGroup32 : SchedWriteRes<[SBPort0,SBPort1]> { - let Latency = 5; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup32], (instregex "CVTSD2SI64rr")>; -def: InstRW<[SBWriteResGroup32], (instregex "CVTSD2SIrr")>; -def: InstRW<[SBWriteResGroup32], (instregex "CVTSS2SI64rr")>; -def: InstRW<[SBWriteResGroup32], (instregex "CVTSS2SIrr")>; -def: InstRW<[SBWriteResGroup32], (instregex "CVTTSD2SI64rr")>; -def: InstRW<[SBWriteResGroup32], (instregex "CVTTSD2SIrr")>; -def: InstRW<[SBWriteResGroup32], (instregex "CVTTSS2SI64rr")>; -def: InstRW<[SBWriteResGroup32], (instregex "CVTTSS2SIrr")>; -def: InstRW<[SBWriteResGroup32], (instregex "VCVTSD2SI64rr")>; -def: InstRW<[SBWriteResGroup32], (instregex "VCVTSS2SI64rr")>; -def: InstRW<[SBWriteResGroup32], (instregex "VCVTSS2SIrr")>; -def: InstRW<[SBWriteResGroup32], (instregex "VCVTTSD2SI64rr")>; -def: InstRW<[SBWriteResGroup32], (instregex "VCVTTSD2SIrr")>; -def: InstRW<[SBWriteResGroup32], (instregex "VCVTTSS2SI64rr")>; -def: InstRW<[SBWriteResGroup32], (instregex "VCVTTSS2SIrr")>; - -def SBWriteResGroup33 : SchedWriteRes<[SBPort4,SBPort23]> { - let Latency = 5; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup33], (instregex "MOV64mr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOV8mr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVAPDmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVAPSmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVDQAmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVDQUmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVHPDmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVHPSmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVLPDmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVLPSmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVNTDQmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVNTI_64mr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVNTImr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVNTPDmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVNTPSmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVPDI2DImr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVPQI2QImr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVPQIto64mr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVSSmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVUPDmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "MOVUPSmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "PUSH64i8")>; -def: InstRW<[SBWriteResGroup33], (instregex "PUSH64r")>; -def: InstRW<[SBWriteResGroup33], (instregex "VEXTRACTF128mr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVAPDYmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVAPDmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVAPSYmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVAPSmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVDQAYmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVDQAmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVDQUYmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVDQUmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVHPDmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVHPSmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVLPDmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVLPSmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVNTDQYmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVNTDQmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVNTPDYmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVNTPDmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVNTPSYmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVNTPSmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVPDI2DImr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVPQI2QImr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVPQIto64mr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVSDmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVSSmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVUPDYmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVUPDmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVUPSYmr")>; -def: InstRW<[SBWriteResGroup33], (instregex "VMOVUPSmr")>; - -def SBWriteResGroup34 : SchedWriteRes<[SBPort0,SBPort15]> { - let Latency = 5; - let NumMicroOps = 3; - let ResourceCycles = [1,2]; -} -def: InstRW<[SBWriteResGroup34], (instregex "MPSADBWrri")>; -def: InstRW<[SBWriteResGroup34], (instregex "VMPSADBWrri")>; - -def SBWriteResGroup35 : SchedWriteRes<[SBPort1,SBPort5]> { - let Latency = 5; - let NumMicroOps = 3; - let ResourceCycles = [1,2]; -} -def: InstRW<[SBWriteResGroup35], (instregex "CLI")>; -def: InstRW<[SBWriteResGroup35], (instregex "CVTSI2SS64rr")>; -def: InstRW<[SBWriteResGroup35], (instregex "CVTSI2SSrr")>; -def: InstRW<[SBWriteResGroup35], (instregex "HADDPDrr")>; -def: InstRW<[SBWriteResGroup35], (instregex "HADDPSrr")>; -def: InstRW<[SBWriteResGroup35], (instregex "HSUBPDrr")>; -def: InstRW<[SBWriteResGroup35], (instregex "HSUBPSrr")>; -def: InstRW<[SBWriteResGroup35], (instregex "VCVTSI2SS64rr")>; -def: InstRW<[SBWriteResGroup35], (instregex "VCVTSI2SSrr")>; -def: InstRW<[SBWriteResGroup35], (instregex "VHADDPDrr")>; -def: InstRW<[SBWriteResGroup35], (instregex "VHADDPSYrr")>; -def: InstRW<[SBWriteResGroup35], (instregex "VHADDPSrr")>; -def: InstRW<[SBWriteResGroup35], (instregex "VHSUBPDYrr")>; -def: InstRW<[SBWriteResGroup35], (instregex "VHSUBPDrr")>; -def: InstRW<[SBWriteResGroup35], (instregex "VHSUBPSYrr")>; -def: InstRW<[SBWriteResGroup35], (instregex "VHSUBPSrr")>; - -def SBWriteResGroup36 : SchedWriteRes<[SBPort4,SBPort5,SBPort23]> { - let Latency = 5; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup36], (instregex "CALL64r")>; -def: InstRW<[SBWriteResGroup36], (instregex "EXTRACTPSmr")>; -def: InstRW<[SBWriteResGroup36], (instregex "VEXTRACTPSmr")>; - -def SBWriteResGroup37 : SchedWriteRes<[SBPort4,SBPort01,SBPort23]> { - let Latency = 5; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup37], (instregex "VMASKMOVPDYrm")>; -def: InstRW<[SBWriteResGroup37], (instregex "VMASKMOVPDmr")>; -def: InstRW<[SBWriteResGroup37], (instregex "VMASKMOVPSmr")>; - -def SBWriteResGroup38 : SchedWriteRes<[SBPort4,SBPort23,SBPort0]> { - let Latency = 5; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup38], (instregex "SETAEm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETBm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETEm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETGEm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETGm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETLEm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETLm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETNEm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETNOm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETNPm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETNSm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETOm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETPm")>; -def: InstRW<[SBWriteResGroup38], (instregex "SETSm")>; - -def SBWriteResGroup39 : SchedWriteRes<[SBPort4,SBPort23,SBPort15]> { - let Latency = 5; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup39], (instregex "PEXTRBmr")>; -def: InstRW<[SBWriteResGroup39], (instregex "VPEXTRBmr")>; -def: InstRW<[SBWriteResGroup39], (instregex "VPEXTRDmr")>; -def: InstRW<[SBWriteResGroup39], (instregex "VPEXTRWmr")>; - -def SBWriteResGroup40 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> { - let Latency = 5; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup40], (instregex "MOV8mi")>; -def: InstRW<[SBWriteResGroup40], (instregex "STOSB")>; -def: InstRW<[SBWriteResGroup40], (instregex "STOSL")>; -def: InstRW<[SBWriteResGroup40], (instregex "STOSQ")>; -def: InstRW<[SBWriteResGroup40], (instregex "STOSW")>; - -def SBWriteResGroup41 : SchedWriteRes<[SBPort5,SBPort015]> { - let Latency = 5; - let NumMicroOps = 4; - let ResourceCycles = [1,3]; -} -def: InstRW<[SBWriteResGroup41], (instregex "FNINIT")>; - -def SBWriteResGroup42 : SchedWriteRes<[SBPort0,SBPort015]> { - let Latency = 5; - let NumMicroOps = 4; - let ResourceCycles = [1,3]; -} -def: InstRW<[SBWriteResGroup42], (instregex "CMPXCHG32rr")>; -def: InstRW<[SBWriteResGroup42], (instregex "CMPXCHG8rr")>; - -def SBWriteResGroup43 : SchedWriteRes<[SBPort4,SBPort23,SBPort0]> { - let Latency = 5; - let NumMicroOps = 4; - let ResourceCycles = [1,1,2]; -} -def: InstRW<[SBWriteResGroup43], (instregex "SETAm")>; -def: InstRW<[SBWriteResGroup43], (instregex "SETBEm")>; - -def SBWriteResGroup44 : SchedWriteRes<[SBPort0,SBPort4,SBPort5,SBPort23]> { - let Latency = 5; - let NumMicroOps = 4; - let ResourceCycles = [1,1,1,1]; -} -def: InstRW<[SBWriteResGroup44], (instregex "LDMXCSR")>; -def: InstRW<[SBWriteResGroup44], (instregex "STMXCSR")>; -def: InstRW<[SBWriteResGroup44], (instregex "VLDMXCSR")>; -def: InstRW<[SBWriteResGroup44], (instregex "VSTMXCSR")>; - -def SBWriteResGroup45 : SchedWriteRes<[SBPort0,SBPort4,SBPort23,SBPort15]> { - let Latency = 5; - let NumMicroOps = 4; - let ResourceCycles = [1,1,1,1]; -} -def: InstRW<[SBWriteResGroup45], (instregex "PEXTRDmr")>; -def: InstRW<[SBWriteResGroup45], (instregex "PEXTRQmr")>; -def: InstRW<[SBWriteResGroup45], (instregex "VPEXTRQmr")>; -def: InstRW<[SBWriteResGroup45], (instregex "PUSHF16")>; -def: InstRW<[SBWriteResGroup45], (instregex "PUSHF64")>; - -def SBWriteResGroup46 : SchedWriteRes<[SBPort4,SBPort5,SBPort01,SBPort23]> { - let Latency = 5; - let NumMicroOps = 4; - let ResourceCycles = [1,1,1,1]; -} -def: InstRW<[SBWriteResGroup46], (instregex "CLFLUSH")>; - -def SBWriteResGroup47 : SchedWriteRes<[SBPort4,SBPort5,SBPort01,SBPort23]> { - let Latency = 5; - let NumMicroOps = 5; - let ResourceCycles = [1,2,1,1]; -} -def: InstRW<[SBWriteResGroup47], (instregex "FXRSTOR")>; - -def SBWriteResGroup48 : SchedWriteRes<[SBPort23]> { - let Latency = 6; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup48], (instregex "LDDQUrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MMX_MOVD64from64rm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOV64toPQIrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOVAPDrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOVAPSrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOVDDUPrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOVDI2PDIrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOVDQArm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOVDQUrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOVNTDQArm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOVSHDUPrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOVSLDUPrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOVSSrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOVUPDrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "MOVUPSrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "POP64r")>; -def: InstRW<[SBWriteResGroup48], (instregex "VBROADCASTSSrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VLDDQUYrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VLDDQUrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOV64toPQIrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVAPDrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVAPSrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVDDUPrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVDI2PDIrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVDQArm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVDQUrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVNTDQArm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVQI2PQIrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVSDrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVSHDUPrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVSLDUPrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVSSrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVUPDrm")>; -def: InstRW<[SBWriteResGroup48], (instregex "VMOVUPSrm")>; - -def SBWriteResGroup49 : SchedWriteRes<[SBPort5,SBPort23]> { - let Latency = 6; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup49], (instregex "JMP64m")>; -def: InstRW<[SBWriteResGroup49], (instregex "MOV64sm")>; - -def SBWriteResGroup50 : SchedWriteRes<[SBPort23,SBPort0]> { - let Latency = 6; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup50], (instregex "BT64mi8")>; - -def SBWriteResGroup51 : SchedWriteRes<[SBPort23,SBPort15]> { - let Latency = 6; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup51], (instregex "MMX_PABSBrm64")>; -def: InstRW<[SBWriteResGroup51], (instregex "MMX_PABSDrm64")>; -def: InstRW<[SBWriteResGroup51], (instregex "MMX_PABSWrm64")>; -def: InstRW<[SBWriteResGroup51], (instregex "MMX_PALIGNR64irm")>; -def: InstRW<[SBWriteResGroup51], (instregex "MMX_PSHUFBrm64")>; -def: InstRW<[SBWriteResGroup51], (instregex "MMX_PSIGNBrm64")>; -def: InstRW<[SBWriteResGroup51], (instregex "MMX_PSIGNDrm64")>; -def: InstRW<[SBWriteResGroup51], (instregex "MMX_PSIGNWrm64")>; - -def SBWriteResGroup52 : SchedWriteRes<[SBPort23,SBPort015]> { - let Latency = 6; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup52], (instregex "ADD64rm")>; -def: InstRW<[SBWriteResGroup52], (instregex "ADD8rm")>; -def: InstRW<[SBWriteResGroup52], (instregex "AND64rm")>; -def: InstRW<[SBWriteResGroup52], (instregex "AND8rm")>; -def: InstRW<[SBWriteResGroup52], (instregex "CMP64mi8")>; -def: InstRW<[SBWriteResGroup52], (instregex "CMP64mr")>; -def: InstRW<[SBWriteResGroup52], (instregex "CMP64rm")>; -def: InstRW<[SBWriteResGroup52], (instregex "CMP8mi")>; -def: InstRW<[SBWriteResGroup52], (instregex "CMP8mr")>; -def: InstRW<[SBWriteResGroup52], (instregex "CMP8rm")>; -def: InstRW<[SBWriteResGroup52], (instregex "LODSL")>; -def: InstRW<[SBWriteResGroup52], (instregex "LODSQ")>; -def: InstRW<[SBWriteResGroup52], (instregex "OR64rm")>; -def: InstRW<[SBWriteResGroup52], (instregex "OR8rm")>; -def: InstRW<[SBWriteResGroup52], (instregex "SUB64rm")>; -def: InstRW<[SBWriteResGroup52], (instregex "SUB8rm")>; -def: InstRW<[SBWriteResGroup52], (instregex "XOR64rm")>; -def: InstRW<[SBWriteResGroup52], (instregex "XOR8rm")>; - -def SBWriteResGroup53 : SchedWriteRes<[SBPort4,SBPort23]> { - let Latency = 6; - let NumMicroOps = 3; - let ResourceCycles = [1,2]; -} -def: InstRW<[SBWriteResGroup53], (instregex "POP64rmm")>; -def: InstRW<[SBWriteResGroup53], (instregex "PUSH64rmm")>; -def: InstRW<[SBWriteResGroup53], (instregex "ST_F32m")>; -def: InstRW<[SBWriteResGroup53], (instregex "ST_F64m")>; -def: InstRW<[SBWriteResGroup53], (instregex "ST_FP32m")>; -def: InstRW<[SBWriteResGroup53], (instregex "ST_FP64m")>; -def: InstRW<[SBWriteResGroup53], (instregex "ST_FP80m")>; - -def SBWriteResGroup54 : SchedWriteRes<[SBPort23]> { - let Latency = 7; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup54], (instregex "VBROADCASTSDYrm")>; -def: InstRW<[SBWriteResGroup54], (instregex "VBROADCASTSSrm")>; -def: InstRW<[SBWriteResGroup54], (instregex "VMOVAPDYrm")>; -def: InstRW<[SBWriteResGroup54], (instregex "VMOVAPSYrm")>; -def: InstRW<[SBWriteResGroup54], (instregex "VMOVDDUPYrm")>; -def: InstRW<[SBWriteResGroup54], (instregex "VMOVDQAYrm")>; -def: InstRW<[SBWriteResGroup54], (instregex "VMOVDQUYrm")>; -def: InstRW<[SBWriteResGroup54], (instregex "VMOVSHDUPYrm")>; -def: InstRW<[SBWriteResGroup54], (instregex "VMOVSLDUPYrm")>; -def: InstRW<[SBWriteResGroup54], (instregex "VMOVUPDYrm")>; -def: InstRW<[SBWriteResGroup54], (instregex "VMOVUPSYrm")>; - -def SBWriteResGroup55 : SchedWriteRes<[SBPort0,SBPort23]> { - let Latency = 7; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup55], (instregex "CVTPS2PDrm")>; -def: InstRW<[SBWriteResGroup55], (instregex "CVTSS2SDrm")>; -def: InstRW<[SBWriteResGroup55], (instregex "VCVTPS2PDYrm")>; -def: InstRW<[SBWriteResGroup55], (instregex "VCVTPS2PDrm")>; -def: InstRW<[SBWriteResGroup55], (instregex "VCVTSS2SDrm")>; -def: InstRW<[SBWriteResGroup55], (instregex "VTESTPDrm")>; -def: InstRW<[SBWriteResGroup55], (instregex "VTESTPSrm")>; - -def SBWriteResGroup56 : SchedWriteRes<[SBPort5,SBPort23]> { - let Latency = 7; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup56], (instregex "ANDNPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "ANDNPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "ANDPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "ANDPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "INSERTPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "MOVHPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "MOVHPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "MOVLPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "MOVLPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "ORPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "ORPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "SHUFPDrmi")>; -def: InstRW<[SBWriteResGroup56], (instregex "SHUFPSrmi")>; -def: InstRW<[SBWriteResGroup56], (instregex "UNPCKHPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "UNPCKHPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "UNPCKLPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "UNPCKLPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VANDNPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VANDNPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VANDPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VANDPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VBROADCASTF128")>; -def: InstRW<[SBWriteResGroup56], (instregex "VINSERTPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VMOVHPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VMOVHPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VMOVLPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VMOVLPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VORPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VORPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VPERMILPDmi")>; -def: InstRW<[SBWriteResGroup56], (instregex "VPERMILPDri")>; -def: InstRW<[SBWriteResGroup56], (instregex "VPERMILPSmi")>; -def: InstRW<[SBWriteResGroup56], (instregex "VPERMILPSri")>; -def: InstRW<[SBWriteResGroup56], (instregex "VSHUFPDrmi")>; -def: InstRW<[SBWriteResGroup56], (instregex "VSHUFPSrmi")>; -def: InstRW<[SBWriteResGroup56], (instregex "VUNPCKHPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VUNPCKHPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VUNPCKLPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VUNPCKLPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VXORPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "VXORPSrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "XORPDrm")>; -def: InstRW<[SBWriteResGroup56], (instregex "XORPSrm")>; - -def SBWriteResGroup57 : SchedWriteRes<[SBPort5,SBPort015]> { - let Latency = 7; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup57], (instregex "AESDECLASTrr")>; -def: InstRW<[SBWriteResGroup57], (instregex "AESDECrr")>; -def: InstRW<[SBWriteResGroup57], (instregex "AESENCLASTrr")>; -def: InstRW<[SBWriteResGroup57], (instregex "AESENCrr")>; -def: InstRW<[SBWriteResGroup57], (instregex "KANDQrr")>; -def: InstRW<[SBWriteResGroup57], (instregex "VAESDECLASTrr")>; -def: InstRW<[SBWriteResGroup57], (instregex "VAESDECrr")>; -def: InstRW<[SBWriteResGroup57], (instregex "VAESENCrr")>; - -def SBWriteResGroup58 : SchedWriteRes<[SBPort23,SBPort0]> { - let Latency = 7; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup58], (instregex "BLENDPDrmi")>; -def: InstRW<[SBWriteResGroup58], (instregex "BLENDPSrmi")>; -def: InstRW<[SBWriteResGroup58], (instregex "VBLENDPDrmi")>; -def: InstRW<[SBWriteResGroup58], (instregex "VBLENDPSrmi")>; -def: InstRW<[SBWriteResGroup58], (instregex "VINSERTF128rm")>; - -def SBWriteResGroup59 : SchedWriteRes<[SBPort23,SBPort15]> { - let Latency = 7; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup59], (instregex "MMX_PADDQirm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PABSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PABSDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PABSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PACKSSDWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PACKSSWBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PACKUSDWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PACKUSWBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PADDBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PADDDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PADDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PADDSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PADDSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PADDUSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PADDUSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PADDWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PALIGNRrmi")>; -def: InstRW<[SBWriteResGroup59], (instregex "PAVGBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PAVGWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PBLENDWrmi")>; -def: InstRW<[SBWriteResGroup59], (instregex "PCMPEQBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PCMPEQDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PCMPEQQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PCMPEQWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PCMPGTBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PCMPGTDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PCMPGTWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PINSRBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PINSRDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PINSRQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PINSRWrmi")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMAXSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMAXSDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMAXSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMAXUBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMAXUDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMAXUWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMINSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMINSDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMINSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMINUBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMINUDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMINUWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMOVSXBDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMOVSXBQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMOVSXBWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMOVSXDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMOVSXWDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMOVSXWQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMOVZXBDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMOVZXBQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMOVZXBWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMOVZXDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMOVZXWDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PMOVZXWQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSHUFBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSHUFDmi")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSHUFHWmi")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSHUFLWmi")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSIGNBrm128")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSIGNDrm128")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSIGNWrm128")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSUBBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSUBDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSUBQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSUBSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSUBSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSUBUSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSUBUSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PSUBWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PUNPCKHBWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PUNPCKHDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PUNPCKHQDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PUNPCKHWDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PUNPCKLBWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PUNPCKLDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PUNPCKLQDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "PUNPCKLWDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPABSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPABSDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPABSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPACKSSDWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPACKSSWBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPACKUSDWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPACKUSWBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPADDBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPADDDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPADDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPADDSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPADDSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPADDUSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPADDUSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPADDWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPALIGNRrmi")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPAVGBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPAVGWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPBLENDWrmi")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPCMPEQBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPCMPEQDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPCMPEQQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPCMPEQWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPCMPGTBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPCMPGTDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPCMPGTWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPINSRBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPINSRDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPINSRQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPINSRWrmi")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMAXSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMAXSDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMAXSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMAXUBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMAXUDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMAXUWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMINSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMINSDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMINSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMINUBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMINUDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMINUWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMOVSXBDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMOVSXBQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMOVSXBWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMOVSXDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMOVSXWDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMOVSXWQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMOVZXBDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMOVZXBQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMOVZXBWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMOVZXDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMOVZXWDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPMOVZXWQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSHUFBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSHUFDmi")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSHUFHWmi")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSHUFLWmi")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSIGNBrm128")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSIGNDrm128")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSIGNWrm128")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSUBBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSUBDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSUBQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSUBSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSUBSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSUBUSBrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSUBUSWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPSUBWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPUNPCKHBWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPUNPCKHDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPUNPCKHQDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPUNPCKHWDrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPUNPCKLBWrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPUNPCKLDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPUNPCKLQDQrm")>; -def: InstRW<[SBWriteResGroup59], (instregex "VPUNPCKLWDrm")>; - -def SBWriteResGroup60 : SchedWriteRes<[SBPort23,SBPort015]> { - let Latency = 7; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup60], (instregex "PANDNrm")>; -def: InstRW<[SBWriteResGroup60], (instregex "PANDrm")>; -def: InstRW<[SBWriteResGroup60], (instregex "PORrm")>; -def: InstRW<[SBWriteResGroup60], (instregex "PXORrm")>; -def: InstRW<[SBWriteResGroup60], (instregex "VPANDNrm")>; -def: InstRW<[SBWriteResGroup60], (instregex "VPANDrm")>; -def: InstRW<[SBWriteResGroup60], (instregex "VPORrm")>; -def: InstRW<[SBWriteResGroup60], (instregex "VPXORrm")>; - -def SBWriteResGroup61 : SchedWriteRes<[SBPort0,SBPort0]> { - let Latency = 7; - let NumMicroOps = 3; - let ResourceCycles = [2,1]; -} -def: InstRW<[SBWriteResGroup61], (instregex "VRCPPSr")>; -def: InstRW<[SBWriteResGroup61], (instregex "VRSQRTPSYr")>; - -def SBWriteResGroup62 : SchedWriteRes<[SBPort5,SBPort23]> { - let Latency = 7; - let NumMicroOps = 3; - let ResourceCycles = [2,1]; -} -def: InstRW<[SBWriteResGroup62], (instregex "VERRm")>; -def: InstRW<[SBWriteResGroup62], (instregex "VERWm")>; - -def SBWriteResGroup63 : SchedWriteRes<[SBPort23,SBPort015]> { - let Latency = 7; - let NumMicroOps = 3; - let ResourceCycles = [1,2]; -} -def: InstRW<[SBWriteResGroup63], (instregex "LODSB")>; -def: InstRW<[SBWriteResGroup63], (instregex "LODSW")>; - -def SBWriteResGroup64 : SchedWriteRes<[SBPort5,SBPort01,SBPort23]> { - let Latency = 7; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup64], (instregex "FARJMP64")>; - -def SBWriteResGroup65 : SchedWriteRes<[SBPort23,SBPort0,SBPort015]> { - let Latency = 7; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup65], (instregex "ADC64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "ADC8rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVAE64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVB64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVE64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVG64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVGE64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVL64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVLE64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVNE64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVNO64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVNP64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVNS64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVO64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVP64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "CMOVS64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "SBB64rm")>; -def: InstRW<[SBWriteResGroup65], (instregex "SBB8rm")>; - -def SBWriteResGroup66 : SchedWriteRes<[SBPort0,SBPort4,SBPort23]> { - let Latency = 7; - let NumMicroOps = 4; - let ResourceCycles = [1,1,2]; -} -def: InstRW<[SBWriteResGroup66], (instregex "FNSTSWm")>; - -def SBWriteResGroup67 : SchedWriteRes<[SBPort1,SBPort5,SBPort015]> { - let Latency = 7; - let NumMicroOps = 4; - let ResourceCycles = [1,2,1]; -} -def: InstRW<[SBWriteResGroup67], (instregex "SLDT32r")>; -def: InstRW<[SBWriteResGroup67], (instregex "STR32r")>; - -def SBWriteResGroup68 : SchedWriteRes<[SBPort4,SBPort5,SBPort23]> { - let Latency = 7; - let NumMicroOps = 4; - let ResourceCycles = [1,1,2]; -} -def: InstRW<[SBWriteResGroup68], (instregex "CALL64m")>; -def: InstRW<[SBWriteResGroup68], (instregex "FNSTCW16m")>; - -def SBWriteResGroup69 : SchedWriteRes<[SBPort4,SBPort23,SBPort0]> { - let Latency = 7; - let NumMicroOps = 4; - let ResourceCycles = [1,2,1]; -} -def: InstRW<[SBWriteResGroup69], (instregex "BTC64mi8")>; -def: InstRW<[SBWriteResGroup69], (instregex "BTR64mi8")>; -def: InstRW<[SBWriteResGroup69], (instregex "BTS64mi8")>; -def: InstRW<[SBWriteResGroup69], (instregex "SAR64mi")>; -def: InstRW<[SBWriteResGroup69], (instregex "SAR8mi")>; -def: InstRW<[SBWriteResGroup69], (instregex "SHL64m1")>; -def: InstRW<[SBWriteResGroup69], (instregex "SHL64mi")>; -def: InstRW<[SBWriteResGroup69], (instregex "SHL8m1")>; -def: InstRW<[SBWriteResGroup69], (instregex "SHL8mi")>; -def: InstRW<[SBWriteResGroup69], (instregex "SHR64mi")>; -def: InstRW<[SBWriteResGroup69], (instregex "SHR8mi")>; - -def SBWriteResGroup70 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> { - let Latency = 7; - let NumMicroOps = 4; - let ResourceCycles = [1,2,1]; -} -def: InstRW<[SBWriteResGroup70], (instregex "ADD64mi8")>; -def: InstRW<[SBWriteResGroup70], (instregex "ADD64mr")>; -def: InstRW<[SBWriteResGroup70], (instregex "ADD8mi")>; -def: InstRW<[SBWriteResGroup70], (instregex "ADD8mr")>; -def: InstRW<[SBWriteResGroup70], (instregex "AND64mi8")>; -def: InstRW<[SBWriteResGroup70], (instregex "AND64mr")>; -def: InstRW<[SBWriteResGroup70], (instregex "AND8mi")>; -def: InstRW<[SBWriteResGroup70], (instregex "AND8mr")>; -def: InstRW<[SBWriteResGroup70], (instregex "DEC64m")>; -def: InstRW<[SBWriteResGroup70], (instregex "DEC8m")>; -def: InstRW<[SBWriteResGroup70], (instregex "INC64m")>; -def: InstRW<[SBWriteResGroup70], (instregex "INC8m")>; -def: InstRW<[SBWriteResGroup70], (instregex "NEG64m")>; -def: InstRW<[SBWriteResGroup70], (instregex "NEG8m")>; -def: InstRW<[SBWriteResGroup70], (instregex "NOT64m")>; -def: InstRW<[SBWriteResGroup70], (instregex "NOT8m")>; -def: InstRW<[SBWriteResGroup70], (instregex "OR64mi8")>; -def: InstRW<[SBWriteResGroup70], (instregex "OR64mr")>; -def: InstRW<[SBWriteResGroup70], (instregex "OR8mi")>; -def: InstRW<[SBWriteResGroup70], (instregex "OR8mr")>; -def: InstRW<[SBWriteResGroup70], (instregex "SUB64mi8")>; -def: InstRW<[SBWriteResGroup70], (instregex "SUB64mr")>; -def: InstRW<[SBWriteResGroup70], (instregex "SUB8mi")>; -def: InstRW<[SBWriteResGroup70], (instregex "SUB8mr")>; -def: InstRW<[SBWriteResGroup70], (instregex "TEST64rm")>; -def: InstRW<[SBWriteResGroup70], (instregex "TEST8mi")>; -def: InstRW<[SBWriteResGroup70], (instregex "TEST8rm")>; -def: InstRW<[SBWriteResGroup70], (instregex "XOR64mi8")>; -def: InstRW<[SBWriteResGroup70], (instregex "XOR64mr")>; -def: InstRW<[SBWriteResGroup70], (instregex "XOR8mi")>; -def: InstRW<[SBWriteResGroup70], (instregex "XOR8mr")>; - -def SBWriteResGroup71 : SchedWriteRes<[SBPort0,SBPort23]> { - let Latency = 8; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup71], (instregex "MMX_PMADDUBSWrm64")>; -def: InstRW<[SBWriteResGroup71], (instregex "MMX_PMULHRSWrm64")>; -def: InstRW<[SBWriteResGroup71], (instregex "VTESTPDYrm")>; -def: InstRW<[SBWriteResGroup71], (instregex "VTESTPSYrm")>; - -def SBWriteResGroup72 : SchedWriteRes<[SBPort1,SBPort23]> { - let Latency = 8; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup72], (instregex "BSF64rm")>; -def: InstRW<[SBWriteResGroup72], (instregex "BSR64rm")>; -def: InstRW<[SBWriteResGroup72], (instregex "CRC32r32m16")>; -def: InstRW<[SBWriteResGroup72], (instregex "CRC32r32m8")>; -def: InstRW<[SBWriteResGroup72], (instregex "FCOM32m")>; -def: InstRW<[SBWriteResGroup72], (instregex "FCOM64m")>; -def: InstRW<[SBWriteResGroup72], (instregex "FCOMP32m")>; -def: InstRW<[SBWriteResGroup72], (instregex "FCOMP64m")>; -def: InstRW<[SBWriteResGroup72], (instregex "MUL8m")>; - -def SBWriteResGroup73 : SchedWriteRes<[SBPort5,SBPort23]> { - let Latency = 8; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup73], (instregex "VANDNPDYrm")>; -def: InstRW<[SBWriteResGroup73], (instregex "VANDNPSYrm")>; -def: InstRW<[SBWriteResGroup73], (instregex "VANDPDrm")>; -def: InstRW<[SBWriteResGroup73], (instregex "VANDPSrm")>; -def: InstRW<[SBWriteResGroup73], (instregex "VORPDYrm")>; -def: InstRW<[SBWriteResGroup73], (instregex "VORPSYrm")>; -def: InstRW<[SBWriteResGroup73], (instregex "VPERM2F128rm")>; -def: InstRW<[SBWriteResGroup73], (instregex "VPERMILPDYri")>; -def: InstRW<[SBWriteResGroup73], (instregex "VPERMILPDmi")>; -def: InstRW<[SBWriteResGroup73], (instregex "VPERMILPSYri")>; -def: InstRW<[SBWriteResGroup73], (instregex "VPERMILPSmi")>; -def: InstRW<[SBWriteResGroup73], (instregex "VSHUFPDYrmi")>; -def: InstRW<[SBWriteResGroup73], (instregex "VSHUFPSYrmi")>; -def: InstRW<[SBWriteResGroup73], (instregex "VUNPCKHPDrm")>; -def: InstRW<[SBWriteResGroup73], (instregex "VUNPCKHPSrm")>; -def: InstRW<[SBWriteResGroup73], (instregex "VUNPCKLPDYrm")>; -def: InstRW<[SBWriteResGroup73], (instregex "VUNPCKLPSYrm")>; -def: InstRW<[SBWriteResGroup73], (instregex "VXORPDrm")>; -def: InstRW<[SBWriteResGroup73], (instregex "VXORPSrm")>; - -def SBWriteResGroup74 : SchedWriteRes<[SBPort23,SBPort0]> { - let Latency = 8; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup74], (instregex "VBLENDPDYrmi")>; -def: InstRW<[SBWriteResGroup74], (instregex "VBLENDPSYrmi")>; - -def SBWriteResGroup75 : SchedWriteRes<[SBPort23,SBPort0]> { - let Latency = 8; - let NumMicroOps = 3; - let ResourceCycles = [1,2]; -} -def: InstRW<[SBWriteResGroup75], (instregex "BLENDVPDrm0")>; -def: InstRW<[SBWriteResGroup75], (instregex "BLENDVPSrm0")>; -def: InstRW<[SBWriteResGroup75], (instregex "VBLENDVPDrm")>; -def: InstRW<[SBWriteResGroup75], (instregex "VBLENDVPSrm")>; -def: InstRW<[SBWriteResGroup75], (instregex "VMASKMOVPDrm")>; -def: InstRW<[SBWriteResGroup75], (instregex "VMASKMOVPSrm")>; - -def SBWriteResGroup76 : SchedWriteRes<[SBPort23,SBPort15]> { - let Latency = 8; - let NumMicroOps = 3; - let ResourceCycles = [1,2]; -} -def: InstRW<[SBWriteResGroup76], (instregex "PBLENDVBrr0")>; -def: InstRW<[SBWriteResGroup76], (instregex "VPBLENDVBrm")>; - -def SBWriteResGroup77 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> { - let Latency = 8; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup77], (instregex "COMISDrm")>; -def: InstRW<[SBWriteResGroup77], (instregex "COMISSrm")>; -def: InstRW<[SBWriteResGroup77], (instregex "UCOMISDrm")>; -def: InstRW<[SBWriteResGroup77], (instregex "UCOMISSrm")>; -def: InstRW<[SBWriteResGroup77], (instregex "VCOMISDrm")>; -def: InstRW<[SBWriteResGroup77], (instregex "VCOMISSrm")>; -def: InstRW<[SBWriteResGroup77], (instregex "VUCOMISDrm")>; -def: InstRW<[SBWriteResGroup77], (instregex "VUCOMISSrm")>; - -def SBWriteResGroup78 : SchedWriteRes<[SBPort0,SBPort5,SBPort23]> { - let Latency = 8; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup78], (instregex "PTESTrm")>; -def: InstRW<[SBWriteResGroup78], (instregex "VPTESTrm")>; - -def SBWriteResGroup79 : SchedWriteRes<[SBPort0,SBPort23,SBPort15]> { - let Latency = 8; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup79], (instregex "PSLLDrm")>; -def: InstRW<[SBWriteResGroup79], (instregex "PSLLQrm")>; -def: InstRW<[SBWriteResGroup79], (instregex "PSLLWrm")>; -def: InstRW<[SBWriteResGroup79], (instregex "PSRADrm")>; -def: InstRW<[SBWriteResGroup79], (instregex "PSRAWrm")>; -def: InstRW<[SBWriteResGroup79], (instregex "PSRLDrm")>; -def: InstRW<[SBWriteResGroup79], (instregex "PSRLQrm")>; -def: InstRW<[SBWriteResGroup79], (instregex "PSRLWrm")>; -def: InstRW<[SBWriteResGroup79], (instregex "VPSLLDri")>; -def: InstRW<[SBWriteResGroup79], (instregex "VPSLLQri")>; -def: InstRW<[SBWriteResGroup79], (instregex "VPSLLWri")>; -def: InstRW<[SBWriteResGroup79], (instregex "VPSRADrm")>; -def: InstRW<[SBWriteResGroup79], (instregex "VPSRAWrm")>; -def: InstRW<[SBWriteResGroup79], (instregex "VPSRLDrm")>; -def: InstRW<[SBWriteResGroup79], (instregex "VPSRLQrm")>; -def: InstRW<[SBWriteResGroup79], (instregex "VPSRLWrm")>; - -def SBWriteResGroup80 : SchedWriteRes<[SBPort23,SBPort15]> { - let Latency = 8; - let NumMicroOps = 4; - let ResourceCycles = [1,3]; -} -def: InstRW<[SBWriteResGroup80], (instregex "MMX_PHADDSWrm64")>; -def: InstRW<[SBWriteResGroup80], (instregex "MMX_PHADDWrm64")>; -def: InstRW<[SBWriteResGroup80], (instregex "MMX_PHADDrm64")>; -def: InstRW<[SBWriteResGroup80], (instregex "MMX_PHSUBDrm64")>; -def: InstRW<[SBWriteResGroup80], (instregex "MMX_PHSUBSWrm64")>; -def: InstRW<[SBWriteResGroup80], (instregex "MMX_PHSUBWrm64")>; - -def SBWriteResGroup81 : SchedWriteRes<[SBPort23,SBPort015]> { - let Latency = 8; - let NumMicroOps = 4; - let ResourceCycles = [1,3]; -} -def: InstRW<[SBWriteResGroup81], (instregex "CMPXCHG64rm")>; -def: InstRW<[SBWriteResGroup81], (instregex "CMPXCHG8rm")>; - -def SBWriteResGroup82 : SchedWriteRes<[SBPort23,SBPort0,SBPort015]> { - let Latency = 8; - let NumMicroOps = 4; - let ResourceCycles = [1,2,1]; -} -def: InstRW<[SBWriteResGroup82], (instregex "CMOVA64rm")>; -def: InstRW<[SBWriteResGroup82], (instregex "CMOVBE64rm")>; - -def SBWriteResGroup83 : SchedWriteRes<[SBPort23,SBPort015]> { - let Latency = 8; - let NumMicroOps = 5; - let ResourceCycles = [2,3]; -} -def: InstRW<[SBWriteResGroup83], (instregex "CMPSB")>; -def: InstRW<[SBWriteResGroup83], (instregex "CMPSL")>; -def: InstRW<[SBWriteResGroup83], (instregex "CMPSQ")>; -def: InstRW<[SBWriteResGroup83], (instregex "CMPSW")>; - -def SBWriteResGroup84 : SchedWriteRes<[SBPort4,SBPort5,SBPort23]> { - let Latency = 8; - let NumMicroOps = 5; - let ResourceCycles = [1,2,2]; -} -def: InstRW<[SBWriteResGroup84], (instregex "FLDCW16m")>; - -def SBWriteResGroup85 : SchedWriteRes<[SBPort4,SBPort23,SBPort0]> { - let Latency = 8; - let NumMicroOps = 5; - let ResourceCycles = [1,2,2]; -} -def: InstRW<[SBWriteResGroup85], (instregex "ROL64mi")>; -def: InstRW<[SBWriteResGroup85], (instregex "ROL8mi")>; -def: InstRW<[SBWriteResGroup85], (instregex "ROR64mi")>; -def: InstRW<[SBWriteResGroup85], (instregex "ROR8mi")>; - -def SBWriteResGroup86 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> { - let Latency = 8; - let NumMicroOps = 5; - let ResourceCycles = [1,2,2]; -} -def: InstRW<[SBWriteResGroup86], (instregex "MOVSB")>; -def: InstRW<[SBWriteResGroup86], (instregex "MOVSL")>; -def: InstRW<[SBWriteResGroup86], (instregex "MOVSQ")>; -def: InstRW<[SBWriteResGroup86], (instregex "MOVSW")>; -def: InstRW<[SBWriteResGroup86], (instregex "XADD64rm")>; -def: InstRW<[SBWriteResGroup86], (instregex "XADD8rm")>; - -def SBWriteResGroup87 : SchedWriteRes<[SBPort4,SBPort5,SBPort01,SBPort23]> { - let Latency = 8; - let NumMicroOps = 5; - let ResourceCycles = [1,1,1,2]; -} -def: InstRW<[SBWriteResGroup87], (instregex "FARCALL64")>; - -def SBWriteResGroup88 : SchedWriteRes<[SBPort4,SBPort23,SBPort0,SBPort015]> { - let Latency = 8; - let NumMicroOps = 5; - let ResourceCycles = [1,2,1,1]; -} -def: InstRW<[SBWriteResGroup88], (instregex "SHLD64mri8")>; -def: InstRW<[SBWriteResGroup88], (instregex "SHRD64mri8")>; - -def SBWriteResGroup89 : SchedWriteRes<[SBPort0,SBPort23]> { - let Latency = 9; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup89], (instregex "MMX_PMULUDQirm")>; -def: InstRW<[SBWriteResGroup89], (instregex "PMADDUBSWrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "PMADDWDrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "PMULDQrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "PMULHRSWrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "PMULHUWrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "PMULHWrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "PMULLDrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "PMULLWrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "PMULUDQrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "PSADBWrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "VPMADDUBSWrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "VPMADDWDrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "VPMULDQrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "VPMULHRSWrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "VPMULHUWrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "VPMULHWrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "VPMULLDrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "VPMULLWrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "VPMULUDQrm")>; -def: InstRW<[SBWriteResGroup89], (instregex "VPSADBWrm")>; - -def SBWriteResGroup90 : SchedWriteRes<[SBPort1,SBPort23]> { - let Latency = 9; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup90], (instregex "ADDPDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "ADDPSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "ADDSDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "ADDSSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "ADDSUBPDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "ADDSUBPSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "CMPPDrmi")>; -def: InstRW<[SBWriteResGroup90], (instregex "CMPPSrmi")>; -def: InstRW<[SBWriteResGroup90], (instregex "CMPSSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "CVTDQ2PSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "CVTPS2DQrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "CVTSI2SD64rm")>; -def: InstRW<[SBWriteResGroup90], (instregex "CVTSI2SDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "CVTTPS2DQrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "MAXPDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "MAXPSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "MAXSDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "MAXSSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "MINPDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "MINPSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "MINSDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "MINSSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "MMX_CVTPI2PSirm")>; -def: InstRW<[SBWriteResGroup90], (instregex "MMX_CVTPS2PIirm")>; -def: InstRW<[SBWriteResGroup90], (instregex "MMX_CVTTPS2PIirm")>; -def: InstRW<[SBWriteResGroup90], (instregex "POPCNT64rm")>; -def: InstRW<[SBWriteResGroup90], (instregex "ROUNDPDm")>; -def: InstRW<[SBWriteResGroup90], (instregex "ROUNDPSm")>; -def: InstRW<[SBWriteResGroup90], (instregex "ROUNDSDm")>; -def: InstRW<[SBWriteResGroup90], (instregex "ROUNDSSm")>; -def: InstRW<[SBWriteResGroup90], (instregex "SUBPDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "SUBPSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "SUBSDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "SUBSSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VADDPDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VADDPSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VADDSDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VADDSSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VADDSUBPDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VADDSUBPSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VCMPPDrmi")>; -def: InstRW<[SBWriteResGroup90], (instregex "VCMPPSrmi")>; -def: InstRW<[SBWriteResGroup90], (instregex "VCMPSDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VCMPSSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VCVTDQ2PSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VCVTPS2DQrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VCVTSI2SD64rm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VCVTSI2SDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VCVTTPS2DQrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VMAXPDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VMAXPSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VMAXSDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VMAXSSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VMINPDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VMINPSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VMINSDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VMINSSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VROUNDPDm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VROUNDPSm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VROUNDSDm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VROUNDSSm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VSUBPDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VSUBPSrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VSUBSDrm")>; -def: InstRW<[SBWriteResGroup90], (instregex "VSUBSSrm")>; - -def SBWriteResGroup91 : SchedWriteRes<[SBPort23,SBPort0]> { - let Latency = 9; - let NumMicroOps = 3; - let ResourceCycles = [1,2]; -} -def: InstRW<[SBWriteResGroup91], (instregex "VBLENDVPDYrm")>; -def: InstRW<[SBWriteResGroup91], (instregex "VBLENDVPSYrm")>; -def: InstRW<[SBWriteResGroup91], (instregex "VMASKMOVPDrm")>; -def: InstRW<[SBWriteResGroup91], (instregex "VMASKMOVPSrm")>; - -def SBWriteResGroup92 : SchedWriteRes<[SBPort0,SBPort1,SBPort5]> { - let Latency = 9; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup92], (instregex "DPPDrri")>; -def: InstRW<[SBWriteResGroup92], (instregex "VDPPDrri")>; - -def SBWriteResGroup93 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> { - let Latency = 9; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup93], (instregex "CVTSD2SI64rm")>; -def: InstRW<[SBWriteResGroup93], (instregex "CVTSD2SIrm")>; -def: InstRW<[SBWriteResGroup93], (instregex "CVTSS2SI64rm")>; -def: InstRW<[SBWriteResGroup93], (instregex "CVTSS2SIrm")>; -def: InstRW<[SBWriteResGroup93], (instregex "CVTTSD2SI64rm")>; -def: InstRW<[SBWriteResGroup93], (instregex "CVTTSD2SIrm")>; -def: InstRW<[SBWriteResGroup93], (instregex "CVTTSS2SI64rm")>; -def: InstRW<[SBWriteResGroup93], (instregex "CVTTSS2SIrm")>; -def: InstRW<[SBWriteResGroup93], (instregex "MUL64m")>; - -def SBWriteResGroup94 : SchedWriteRes<[SBPort0,SBPort5,SBPort23]> { - let Latency = 9; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup94], (instregex "VPTESTYrm")>; - -def SBWriteResGroup95 : SchedWriteRes<[SBPort5,SBPort01,SBPort23]> { - let Latency = 9; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup95], (instregex "LD_F32m")>; -def: InstRW<[SBWriteResGroup95], (instregex "LD_F64m")>; -def: InstRW<[SBWriteResGroup95], (instregex "LD_F80m")>; - -def SBWriteResGroup96 : SchedWriteRes<[SBPort23,SBPort15]> { - let Latency = 9; - let NumMicroOps = 4; - let ResourceCycles = [1,3]; -} -def: InstRW<[SBWriteResGroup96], (instregex "PHADDDrm")>; -def: InstRW<[SBWriteResGroup96], (instregex "PHADDSWrm128")>; -def: InstRW<[SBWriteResGroup96], (instregex "PHADDWrm")>; -def: InstRW<[SBWriteResGroup96], (instregex "PHSUBDrm")>; -def: InstRW<[SBWriteResGroup96], (instregex "PHSUBSWrm128")>; -def: InstRW<[SBWriteResGroup96], (instregex "PHSUBWrm")>; -def: InstRW<[SBWriteResGroup96], (instregex "VPHADDDrm")>; -def: InstRW<[SBWriteResGroup96], (instregex "VPHADDSWrm128")>; -def: InstRW<[SBWriteResGroup96], (instregex "VPHADDWrm")>; -def: InstRW<[SBWriteResGroup96], (instregex "VPHSUBDrm")>; -def: InstRW<[SBWriteResGroup96], (instregex "VPHSUBSWrm128")>; -def: InstRW<[SBWriteResGroup96], (instregex "VPHSUBWrm")>; - -def SBWriteResGroup97 : SchedWriteRes<[SBPort1,SBPort4,SBPort23]> { - let Latency = 9; - let NumMicroOps = 4; - let ResourceCycles = [1,1,2]; -} -def: InstRW<[SBWriteResGroup97], (instregex "IST_F16m")>; -def: InstRW<[SBWriteResGroup97], (instregex "IST_F32m")>; -def: InstRW<[SBWriteResGroup97], (instregex "IST_FP16m")>; -def: InstRW<[SBWriteResGroup97], (instregex "IST_FP32m")>; -def: InstRW<[SBWriteResGroup97], (instregex "IST_FP64m")>; -def: InstRW<[SBWriteResGroup97], (instregex "SHL64mCL")>; -def: InstRW<[SBWriteResGroup97], (instregex "SHL8mCL")>; - -def SBWriteResGroup98 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> { - let Latency = 9; - let NumMicroOps = 6; - let ResourceCycles = [1,2,3]; -} -def: InstRW<[SBWriteResGroup98], (instregex "ADC64mi8")>; -def: InstRW<[SBWriteResGroup98], (instregex "ADC8mi")>; -def: InstRW<[SBWriteResGroup98], (instregex "SBB64mi8")>; -def: InstRW<[SBWriteResGroup98], (instregex "SBB8mi")>; - -def SBWriteResGroup99 : SchedWriteRes<[SBPort4,SBPort23,SBPort0,SBPort015]> { - let Latency = 9; - let NumMicroOps = 6; - let ResourceCycles = [1,2,2,1]; -} -def: InstRW<[SBWriteResGroup99], (instregex "ADC64mr")>; -def: InstRW<[SBWriteResGroup99], (instregex "ADC8mr")>; -def: InstRW<[SBWriteResGroup99], (instregex "SBB64mr")>; -def: InstRW<[SBWriteResGroup99], (instregex "SBB8mr")>; - -def SBWriteResGroup100 : SchedWriteRes<[SBPort4,SBPort5,SBPort23,SBPort0,SBPort015]> { - let Latency = 9; - let NumMicroOps = 6; - let ResourceCycles = [1,1,2,1,1]; -} -def: InstRW<[SBWriteResGroup100], (instregex "BT64mr")>; -def: InstRW<[SBWriteResGroup100], (instregex "BTC64mr")>; -def: InstRW<[SBWriteResGroup100], (instregex "BTR64mr")>; -def: InstRW<[SBWriteResGroup100], (instregex "BTS64mr")>; - -def SBWriteResGroup101 : SchedWriteRes<[SBPort1,SBPort23]> { - let Latency = 10; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup101], (instregex "ADD_F32m")>; -def: InstRW<[SBWriteResGroup101], (instregex "ADD_F64m")>; -def: InstRW<[SBWriteResGroup101], (instregex "ILD_F16m")>; -def: InstRW<[SBWriteResGroup101], (instregex "ILD_F32m")>; -def: InstRW<[SBWriteResGroup101], (instregex "ILD_F64m")>; -def: InstRW<[SBWriteResGroup101], (instregex "SUBR_F32m")>; -def: InstRW<[SBWriteResGroup101], (instregex "SUBR_F64m")>; -def: InstRW<[SBWriteResGroup101], (instregex "SUB_F32m")>; -def: InstRW<[SBWriteResGroup101], (instregex "SUB_F64m")>; -def: InstRW<[SBWriteResGroup101], (instregex "VADDPDYrm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VADDPSYrm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VADDSUBPDYrm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VADDSUBPSYrm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VCMPPDYrmi")>; -def: InstRW<[SBWriteResGroup101], (instregex "VCMPPSYrmi")>; -def: InstRW<[SBWriteResGroup101], (instregex "VCVTDQ2PSYrm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VCVTPS2DQYrm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VCVTTPS2DQrm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VMAXPDYrm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VMAXPSYrm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VMINPDrm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VMINPSrm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VROUNDPDm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VROUNDPSm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VSUBPDYrm")>; -def: InstRW<[SBWriteResGroup101], (instregex "VSUBPSYrm")>; - -def SBWriteResGroup102 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> { - let Latency = 10; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup102], (instregex "VCVTSD2SI64rm")>; -def: InstRW<[SBWriteResGroup102], (instregex "VCVTSD2SI64rr")>; -def: InstRW<[SBWriteResGroup102], (instregex "VCVTSS2SI64rm")>; -def: InstRW<[SBWriteResGroup102], (instregex "VCVTSS2SIrm")>; -def: InstRW<[SBWriteResGroup102], (instregex "VCVTTSD2SI64rm")>; -def: InstRW<[SBWriteResGroup102], (instregex "VCVTTSD2SI64rr")>; -def: InstRW<[SBWriteResGroup102], (instregex "VCVTTSS2SI64rm")>; -def: InstRW<[SBWriteResGroup102], (instregex "VCVTTSS2SIrm")>; - -def SBWriteResGroup103 : SchedWriteRes<[SBPort1,SBPort5,SBPort23]> { - let Latency = 10; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup103], (instregex "CVTDQ2PDrm")>; -def: InstRW<[SBWriteResGroup103], (instregex "CVTPD2DQrm")>; -def: InstRW<[SBWriteResGroup103], (instregex "CVTPD2PSrm")>; -def: InstRW<[SBWriteResGroup103], (instregex "CVTSD2SSrm")>; -def: InstRW<[SBWriteResGroup103], (instregex "CVTSI2SS64rm")>; -def: InstRW<[SBWriteResGroup103], (instregex "CVTSI2SSrm")>; -def: InstRW<[SBWriteResGroup103], (instregex "CVTTPD2DQrm")>; -def: InstRW<[SBWriteResGroup103], (instregex "MMX_CVTPD2PIirm")>; -def: InstRW<[SBWriteResGroup103], (instregex "MMX_CVTPI2PDirm")>; -def: InstRW<[SBWriteResGroup103], (instregex "MMX_CVTTPD2PIirm")>; -def: InstRW<[SBWriteResGroup103], (instregex "VCVTDQ2PDYrm")>; -def: InstRW<[SBWriteResGroup103], (instregex "VCVTDQ2PDrm")>; -def: InstRW<[SBWriteResGroup103], (instregex "VCVTPD2DQrm")>; -def: InstRW<[SBWriteResGroup103], (instregex "VCVTPD2PSrm")>; -def: InstRW<[SBWriteResGroup103], (instregex "VCVTSD2SSrm")>; -def: InstRW<[SBWriteResGroup103], (instregex "VCVTSI2SS64rm")>; -def: InstRW<[SBWriteResGroup103], (instregex "VCVTSI2SSrm")>; -def: InstRW<[SBWriteResGroup103], (instregex "VCVTTPD2DQrm")>; - -def SBWriteResGroup104 : SchedWriteRes<[SBPort0,SBPort23]> { - let Latency = 11; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup104], (instregex "MULPDrm")>; -def: InstRW<[SBWriteResGroup104], (instregex "MULPSrm")>; -def: InstRW<[SBWriteResGroup104], (instregex "MULSDrm")>; -def: InstRW<[SBWriteResGroup104], (instregex "MULSSrm")>; -def: InstRW<[SBWriteResGroup104], (instregex "PCMPGTQrm")>; -def: InstRW<[SBWriteResGroup104], (instregex "PHMINPOSUWrm128")>; -def: InstRW<[SBWriteResGroup104], (instregex "RCPPSm")>; -def: InstRW<[SBWriteResGroup104], (instregex "RCPSSm")>; -def: InstRW<[SBWriteResGroup104], (instregex "RSQRTPSm")>; -def: InstRW<[SBWriteResGroup104], (instregex "RSQRTSSm")>; -def: InstRW<[SBWriteResGroup104], (instregex "VMULPDrm")>; -def: InstRW<[SBWriteResGroup104], (instregex "VMULPSrm")>; -def: InstRW<[SBWriteResGroup104], (instregex "VMULSDrm")>; -def: InstRW<[SBWriteResGroup104], (instregex "VMULSSrm")>; -def: InstRW<[SBWriteResGroup104], (instregex "VPCMPGTQrm")>; -def: InstRW<[SBWriteResGroup104], (instregex "VPHMINPOSUWrm128")>; -def: InstRW<[SBWriteResGroup104], (instregex "VRCPPSm")>; -def: InstRW<[SBWriteResGroup104], (instregex "VRCPSSm")>; -def: InstRW<[SBWriteResGroup104], (instregex "VRSQRTPSm")>; -def: InstRW<[SBWriteResGroup104], (instregex "VRSQRTSSm")>; - -def SBWriteResGroup105 : SchedWriteRes<[SBPort0]> { - let Latency = 11; - let NumMicroOps = 3; - let ResourceCycles = [3]; -} -def: InstRW<[SBWriteResGroup105], (instregex "PCMPISTRIrr")>; -def: InstRW<[SBWriteResGroup105], (instregex "PCMPISTRM128rr")>; -def: InstRW<[SBWriteResGroup105], (instregex "VPCMPISTRIrr")>; -def: InstRW<[SBWriteResGroup105], (instregex "VPCMPISTRM128rr")>; - -def SBWriteResGroup106 : SchedWriteRes<[SBPort1,SBPort23]> { - let Latency = 11; - let NumMicroOps = 3; - let ResourceCycles = [2,1]; -} -def: InstRW<[SBWriteResGroup106], (instregex "FICOM16m")>; -def: InstRW<[SBWriteResGroup106], (instregex "FICOM32m")>; -def: InstRW<[SBWriteResGroup106], (instregex "FICOMP16m")>; -def: InstRW<[SBWriteResGroup106], (instregex "FICOMP32m")>; - -def SBWriteResGroup107 : SchedWriteRes<[SBPort1,SBPort5,SBPort23]> { - let Latency = 11; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup107], (instregex "VCVTPD2DQYrm")>; -def: InstRW<[SBWriteResGroup107], (instregex "VCVTPD2PSYrm")>; -def: InstRW<[SBWriteResGroup107], (instregex "VCVTTPD2DQYrm")>; - -def SBWriteResGroup108 : SchedWriteRes<[SBPort0,SBPort23,SBPort15]> { - let Latency = 11; - let NumMicroOps = 4; - let ResourceCycles = [1,1,2]; -} -def: InstRW<[SBWriteResGroup108], (instregex "MPSADBWrmi")>; -def: InstRW<[SBWriteResGroup108], (instregex "VMPSADBWrmi")>; - -def SBWriteResGroup109 : SchedWriteRes<[SBPort1,SBPort5,SBPort23]> { - let Latency = 11; - let NumMicroOps = 4; - let ResourceCycles = [1,2,1]; -} -def: InstRW<[SBWriteResGroup109], (instregex "HADDPDrm")>; -def: InstRW<[SBWriteResGroup109], (instregex "HADDPSrm")>; -def: InstRW<[SBWriteResGroup109], (instregex "HSUBPDrm")>; -def: InstRW<[SBWriteResGroup109], (instregex "HSUBPSrm")>; -def: InstRW<[SBWriteResGroup109], (instregex "VHADDPDrm")>; -def: InstRW<[SBWriteResGroup109], (instregex "VHADDPSrm")>; -def: InstRW<[SBWriteResGroup109], (instregex "VHSUBPDrm")>; -def: InstRW<[SBWriteResGroup109], (instregex "VHSUBPSrm")>; - -def SBWriteResGroup110 : SchedWriteRes<[SBPort5]> { - let Latency = 12; - let NumMicroOps = 2; - let ResourceCycles = [2]; -} -def: InstRW<[SBWriteResGroup110], (instregex "AESIMCrr")>; -def: InstRW<[SBWriteResGroup110], (instregex "VAESIMCrr")>; - -def SBWriteResGroup111 : SchedWriteRes<[SBPort0,SBPort23]> { - let Latency = 12; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup111], (instregex "MUL_F32m")>; -def: InstRW<[SBWriteResGroup111], (instregex "MUL_F64m")>; -def: InstRW<[SBWriteResGroup111], (instregex "VMULPDYrm")>; -def: InstRW<[SBWriteResGroup111], (instregex "VMULPSYrm")>; - -def SBWriteResGroup112 : SchedWriteRes<[SBPort0,SBPort1,SBPort5]> { - let Latency = 12; - let NumMicroOps = 4; - let ResourceCycles = [1,2,1]; -} -def: InstRW<[SBWriteResGroup112], (instregex "DPPSrri")>; -def: InstRW<[SBWriteResGroup112], (instregex "VDPPSYrri")>; -def: InstRW<[SBWriteResGroup112], (instregex "VDPPSrri")>; - -def SBWriteResGroup113 : SchedWriteRes<[SBPort1,SBPort5,SBPort23]> { - let Latency = 12; - let NumMicroOps = 4; - let ResourceCycles = [1,2,1]; -} -def: InstRW<[SBWriteResGroup113], (instregex "VHADDPDrm")>; -def: InstRW<[SBWriteResGroup113], (instregex "VHADDPSYrm")>; -def: InstRW<[SBWriteResGroup113], (instregex "VHSUBPDYrm")>; -def: InstRW<[SBWriteResGroup113], (instregex "VHSUBPSYrm")>; - -def SBWriteResGroup114 : SchedWriteRes<[SBPort1,SBPort23]> { - let Latency = 13; - let NumMicroOps = 3; - let ResourceCycles = [2,1]; -} -def: InstRW<[SBWriteResGroup114], (instregex "ADD_FI16m")>; -def: InstRW<[SBWriteResGroup114], (instregex "ADD_FI32m")>; -def: InstRW<[SBWriteResGroup114], (instregex "SUBR_FI16m")>; -def: InstRW<[SBWriteResGroup114], (instregex "SUBR_FI32m")>; -def: InstRW<[SBWriteResGroup114], (instregex "SUB_FI16m")>; -def: InstRW<[SBWriteResGroup114], (instregex "SUB_FI32m")>; - -def SBWriteResGroup115 : SchedWriteRes<[SBPort5,SBPort23,SBPort015]> { - let Latency = 13; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup115], (instregex "AESDECLASTrm")>; -def: InstRW<[SBWriteResGroup115], (instregex "AESDECrm")>; -def: InstRW<[SBWriteResGroup115], (instregex "AESENCLASTrm")>; -def: InstRW<[SBWriteResGroup115], (instregex "AESENCrm")>; -def: InstRW<[SBWriteResGroup115], (instregex "VAESDECLASTrm")>; -def: InstRW<[SBWriteResGroup115], (instregex "VAESDECrm")>; -def: InstRW<[SBWriteResGroup115], (instregex "VAESENCLASTrm")>; -def: InstRW<[SBWriteResGroup115], (instregex "VAESENCrm")>; - -def SBWriteResGroup116 : SchedWriteRes<[SBPort0]> { - let Latency = 14; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup116], (instregex "DIVPSrr")>; -def: InstRW<[SBWriteResGroup116], (instregex "DIVSSrr")>; -def: InstRW<[SBWriteResGroup116], (instregex "SQRTPSr")>; -def: InstRW<[SBWriteResGroup116], (instregex "SQRTSSr")>; -def: InstRW<[SBWriteResGroup116], (instregex "VDIVPSrr")>; -def: InstRW<[SBWriteResGroup116], (instregex "VDIVSSrr")>; -def: InstRW<[SBWriteResGroup116], (instregex "VSQRTPSr")>; - -def SBWriteResGroup117 : SchedWriteRes<[SBPort0,SBPort23]> { - let Latency = 14; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup117], (instregex "VSQRTSSm")>; - -def SBWriteResGroup118 : SchedWriteRes<[SBPort0,SBPort23,SBPort0]> { - let Latency = 14; - let NumMicroOps = 4; - let ResourceCycles = [2,1,1]; -} -def: InstRW<[SBWriteResGroup118], (instregex "VRCPPSm")>; -def: InstRW<[SBWriteResGroup118], (instregex "VRSQRTPSYm")>; - -def SBWriteResGroup119 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> { - let Latency = 15; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup119], (instregex "MUL_FI16m")>; -def: InstRW<[SBWriteResGroup119], (instregex "MUL_FI32m")>; - -def SBWriteResGroup120 : SchedWriteRes<[SBPort0,SBPort1,SBPort5,SBPort23]> { - let Latency = 15; - let NumMicroOps = 4; - let ResourceCycles = [1,1,1,1]; -} -def: InstRW<[SBWriteResGroup120], (instregex "DPPDrmi")>; -def: InstRW<[SBWriteResGroup120], (instregex "VDPPDrmi")>; - -def SBWriteResGroup121 : SchedWriteRes<[SBPort0,SBPort23]> { - let Latency = 17; - let NumMicroOps = 4; - let ResourceCycles = [3,1]; -} -def: InstRW<[SBWriteResGroup121], (instregex "PCMPISTRIrm")>; -def: InstRW<[SBWriteResGroup121], (instregex "PCMPISTRM128rm")>; -def: InstRW<[SBWriteResGroup121], (instregex "VPCMPISTRIrm")>; -def: InstRW<[SBWriteResGroup121], (instregex "VPCMPISTRM128rm")>; - -def SBWriteResGroup122 : SchedWriteRes<[SBPort5,SBPort23]> { - let Latency = 18; - let NumMicroOps = 3; - let ResourceCycles = [2,1]; -} -def: InstRW<[SBWriteResGroup122], (instregex "AESIMCrm")>; -def: InstRW<[SBWriteResGroup122], (instregex "VAESIMCrm")>; - -def SBWriteResGroup123 : SchedWriteRes<[SBPort0,SBPort23]> { - let Latency = 20; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup123], (instregex "DIVPSrm")>; -def: InstRW<[SBWriteResGroup123], (instregex "DIVSSrm")>; -def: InstRW<[SBWriteResGroup123], (instregex "SQRTPSm")>; -def: InstRW<[SBWriteResGroup123], (instregex "SQRTSSm")>; -def: InstRW<[SBWriteResGroup123], (instregex "VDIVPSrm")>; -def: InstRW<[SBWriteResGroup123], (instregex "VDIVSSrm")>; -def: InstRW<[SBWriteResGroup123], (instregex "VSQRTPSm")>; - -def SBWriteResGroup124 : SchedWriteRes<[SBPort0]> { - let Latency = 21; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup124], (instregex "VSQRTSDr")>; - -def SBWriteResGroup125 : SchedWriteRes<[SBPort0,SBPort23]> { - let Latency = 21; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup125], (instregex "VSQRTSDm")>; - -def SBWriteResGroup126 : SchedWriteRes<[SBPort0]> { - let Latency = 22; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup126], (instregex "DIVPDrr")>; -def: InstRW<[SBWriteResGroup126], (instregex "DIVSDrr")>; -def: InstRW<[SBWriteResGroup126], (instregex "SQRTPDr")>; -def: InstRW<[SBWriteResGroup126], (instregex "SQRTSDr")>; -def: InstRW<[SBWriteResGroup126], (instregex "VDIVPDrr")>; -def: InstRW<[SBWriteResGroup126], (instregex "VDIVSDrr")>; -def: InstRW<[SBWriteResGroup126], (instregex "VSQRTPDr")>; - -def SBWriteResGroup127 : SchedWriteRes<[SBPort0]> { - let Latency = 24; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup127], (instregex "DIVR_FPrST0")>; -def: InstRW<[SBWriteResGroup127], (instregex "DIVR_FST0r")>; -def: InstRW<[SBWriteResGroup127], (instregex "DIVR_FrST0")>; -def: InstRW<[SBWriteResGroup127], (instregex "DIV_FPrST0")>; -def: InstRW<[SBWriteResGroup127], (instregex "DIV_FST0r")>; -def: InstRW<[SBWriteResGroup127], (instregex "DIV_FrST0")>; - -def SBWriteResGroup128 : SchedWriteRes<[SBPort0,SBPort23]> { - let Latency = 28; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup128], (instregex "DIVPDrm")>; -def: InstRW<[SBWriteResGroup128], (instregex "DIVSDrm")>; -def: InstRW<[SBWriteResGroup128], (instregex "SQRTPDm")>; -def: InstRW<[SBWriteResGroup128], (instregex "SQRTSDm")>; -def: InstRW<[SBWriteResGroup128], (instregex "VDIVPDrm")>; -def: InstRW<[SBWriteResGroup128], (instregex "VDIVSDrm")>; -def: InstRW<[SBWriteResGroup128], (instregex "VSQRTPDm")>; - -def SBWriteResGroup129 : SchedWriteRes<[SBPort0,SBPort0]> { - let Latency = 29; - let NumMicroOps = 3; - let ResourceCycles = [2,1]; -} -def: InstRW<[SBWriteResGroup129], (instregex "VDIVPSYrr")>; -def: InstRW<[SBWriteResGroup129], (instregex "VSQRTPSYr")>; - -def SBWriteResGroup130 : SchedWriteRes<[SBPort0,SBPort23]> { - let Latency = 31; - let NumMicroOps = 2; - let ResourceCycles = [1,1]; -} -def: InstRW<[SBWriteResGroup130], (instregex "DIVR_F32m")>; -def: InstRW<[SBWriteResGroup130], (instregex "DIVR_F64m")>; -def: InstRW<[SBWriteResGroup130], (instregex "DIV_F32m")>; -def: InstRW<[SBWriteResGroup130], (instregex "DIV_F64m")>; - -def SBWriteResGroup131 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> { - let Latency = 34; - let NumMicroOps = 3; - let ResourceCycles = [1,1,1]; -} -def: InstRW<[SBWriteResGroup131], (instregex "DIVR_FI16m")>; -def: InstRW<[SBWriteResGroup131], (instregex "DIVR_FI32m")>; -def: InstRW<[SBWriteResGroup131], (instregex "DIV_FI16m")>; -def: InstRW<[SBWriteResGroup131], (instregex "DIV_FI32m")>; - -def SBWriteResGroup132 : SchedWriteRes<[SBPort0,SBPort23,SBPort0]> { - let Latency = 36; - let NumMicroOps = 4; - let ResourceCycles = [2,1,1]; -} -def: InstRW<[SBWriteResGroup132], (instregex "VDIVPSYrm")>; -def: InstRW<[SBWriteResGroup132], (instregex "VSQRTPSYm")>; - -def SBWriteResGroup133 : SchedWriteRes<[SBPort0,SBPort0]> { - let Latency = 45; - let NumMicroOps = 3; - let ResourceCycles = [2,1]; -} -def: InstRW<[SBWriteResGroup133], (instregex "VDIVPDYrr")>; -def: InstRW<[SBWriteResGroup133], (instregex "VSQRTPDYr")>; - -def SBWriteResGroup134 : SchedWriteRes<[SBPort0,SBPort23,SBPort0]> { - let Latency = 52; - let NumMicroOps = 4; - let ResourceCycles = [2,1,1]; -} -def: InstRW<[SBWriteResGroup134], (instregex "VDIVPDYrm")>; -def: InstRW<[SBWriteResGroup134], (instregex "VSQRTPDYm")>; - -def SBWriteResGroup135 : SchedWriteRes<[SBPort0]> { - let Latency = 114; - let NumMicroOps = 1; - let ResourceCycles = [1]; -} -def: InstRW<[SBWriteResGroup135], (instregex "VSQRTSSr")>; - } // SchedModel diff --git contrib/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp contrib/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp index fc15dc1e6032..4820b9f7de58 100644 --- contrib/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp +++ contrib/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp @@ -161,6 +161,22 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef<const char *> ArgsArr) { if (Path.empty()) Path = getImplibPath(Def->OutputFile); + if (Machine == IMAGE_FILE_MACHINE_I386 && Args.getLastArg(OPT_k)) { + for (COFFShortExport& E : Def->Exports) { + if (E.isWeak() || (!E.Name.empty() && E.Name[0] == '?')) + continue; + E.SymbolName = E.Name; + // Trim off the trailing decoration. Symbols will always have a + // starting prefix here (either _ for cdecl/stdcall, @ for fastcall + // or ? for C++ functions). (Vectorcall functions also will end up having + // a prefix here, even if they shouldn't.) + E.Name = E.Name.substr(0, E.Name.find('@', 1)); + // By making sure E.SymbolName != E.Name for decorated symbols, + // writeImportLibrary writes these symbols with the type + // IMPORT_NAME_UNDECORATE. + } + } + if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine, true)) return 1; return 0; diff --git contrib/llvm/lib/ToolDrivers/llvm-dlltool/Options.td contrib/llvm/lib/ToolDrivers/llvm-dlltool/Options.td index 213c6a4d7674..e78182ab8130 100644 --- contrib/llvm/lib/ToolDrivers/llvm-dlltool/Options.td +++ contrib/llvm/lib/ToolDrivers/llvm-dlltool/Options.td @@ -12,13 +12,13 @@ def D_long : JoinedOrSeparate<["--"], "dllname">, Alias<D>; def d: JoinedOrSeparate<["-"], "d">, HelpText<"Input .def File">; def d_long : JoinedOrSeparate<["--"], "input-def">, Alias<d>; +def k: Flag<["-"], "k">, HelpText<"Kill @n Symbol from export">; +def k_alias: Flag<["--"], "kill-at">, Alias<k>; + //============================================================================== // The flags below do nothing. They are defined only for dlltool compatibility. //============================================================================== -def k: Flag<["-"], "k">, HelpText<"Kill @n Symbol from export">; -def k_alias: Flag<["--"], "kill-at">, Alias<k>; - def S: JoinedOrSeparate<["-"], "S">, HelpText<"Assembler">; def S_alias: JoinedOrSeparate<["--"], "as">, Alias<S>; diff --git contrib/llvm/lib/Transforms/Scalar/LowerAtomic.cpp contrib/llvm/lib/Transforms/Scalar/LowerAtomic.cpp index 08e60b16bedf..6f77c5bd0d07 100644 --- contrib/llvm/lib/Transforms/Scalar/LowerAtomic.cpp +++ contrib/llvm/lib/Transforms/Scalar/LowerAtomic.cpp @@ -155,8 +155,7 @@ public: } bool runOnFunction(Function &F) override { - if (skipFunction(F)) - return false; + // Don't skip optnone functions; atomics still need to be lowered. FunctionAnalysisManager DummyFAM; auto PA = Impl.run(F, DummyFAM); return !PA.areAllPreserved(); diff --git contrib/llvm/lib/Transforms/Scalar/Reassociate.cpp contrib/llvm/lib/Transforms/Scalar/Reassociate.cpp index 29d1ba406ae4..e235e5eb1a06 100644 --- contrib/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ contrib/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -1941,6 +1941,12 @@ Instruction *ReassociatePass::canonicalizeNegConstExpr(Instruction *I) { if (!User->isCommutative() && User->getOperand(1) != I) return nullptr; + // Don't canonicalize x + (-Constant * y) -> x - (Constant * y), if the + // resulting subtract will be broken up later. This can get us into an + // infinite loop during reassociation. + if (UserOpcode == Instruction::FAdd && ShouldBreakUpSubtract(User)) + return nullptr; + // Change the sign of the constant. APFloat Val = CF->getValueAPF(); Val.changeSign(); diff --git contrib/llvm/lib/Transforms/Utils/CloneFunction.cpp contrib/llvm/lib/Transforms/Utils/CloneFunction.cpp index 7e75e8847785..9c4e13903ed7 100644 --- contrib/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ contrib/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -341,8 +341,9 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB, SimplifyInstruction(NewInst, BB->getModule()->getDataLayout())) { // On the off-chance that this simplifies to an instruction in the old // function, map it back into the new function. - if (Value *MappedV = VMap.lookup(V)) - V = MappedV; + if (NewFunc != OldFunc) + if (Value *MappedV = VMap.lookup(V)) + V = MappedV; if (!NewInst->mayHaveSideEffects()) { VMap[&*II] = V; diff --git contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S index 923ddacbaea6..2330fc2adb5f 100644 --- contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S +++ contrib/llvm/projects/libunwind/src/UnwindRegistersRestore.S @@ -528,4 +528,5 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_riscv6jumptoEv) #endif - .section .note.GNU-stack,"",@progbits +NO_EXEC_STACK_DIRECTIVE + diff --git contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S index 0839c446f196..9b66a7657fe4 100644 --- contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S +++ contrib/llvm/projects/libunwind/src/UnwindRegistersSave.S @@ -470,4 +470,5 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext) #endif - .section .note.GNU-stack,"",@progbits +NO_EXEC_STACK_DIRECTIVE + diff --git contrib/llvm/projects/libunwind/src/assembly.h contrib/llvm/projects/libunwind/src/assembly.h index f46a24d0eed9..06b29b364fb5 100644 --- contrib/llvm/projects/libunwind/src/assembly.h +++ contrib/llvm/projects/libunwind/src/assembly.h @@ -35,19 +35,34 @@ #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name) #if defined(__APPLE__) + #define SYMBOL_IS_FUNC(name) +#define NO_EXEC_STACK_DIRECTIVE + #elif defined(__ELF__) + #if defined(__arm__) #define SYMBOL_IS_FUNC(name) .type name,%function #else #define SYMBOL_IS_FUNC(name) .type name,@function #endif + +#if defined(__GNU__) || defined(__ANDROID__) || defined(__FreeBSD__) +#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits +#else +#define NO_EXEC_STACK_DIRECTIVE +#endif + #else + #define SYMBOL_IS_FUNC(name) \ .def name SEPARATOR \ .scl 2 SEPARATOR \ .type 32 SEPARATOR \ .endef + +#define NO_EXEC_STACK_DIRECTIVE + #endif #define DEFINE_LIBUNWIND_FUNCTION(name) \ diff --git contrib/llvm/tools/clang/include/clang/AST/DeclCXX.h contrib/llvm/tools/clang/include/clang/AST/DeclCXX.h index 9d64f0244ec3..2f735c5506c4 100644 --- contrib/llvm/tools/clang/include/clang/AST/DeclCXX.h +++ contrib/llvm/tools/clang/include/clang/AST/DeclCXX.h @@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl { /// \brief These flags are \c true if a defaulted corresponding special /// member can't be fully analyzed without performing overload resolution. /// @{ + unsigned NeedOverloadResolutionForCopyConstructor : 1; unsigned NeedOverloadResolutionForMoveConstructor : 1; unsigned NeedOverloadResolutionForMoveAssignment : 1; unsigned NeedOverloadResolutionForDestructor : 1; @@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl { /// \brief These flags are \c true if an implicit defaulted corresponding /// special member would be defined as deleted. /// @{ + unsigned DefaultedCopyConstructorIsDeleted : 1; unsigned DefaultedMoveConstructorIsDeleted : 1; unsigned DefaultedMoveAssignmentIsDeleted : 1; unsigned DefaultedDestructorIsDeleted : 1; @@ -415,6 +417,12 @@ class CXXRecordDecl : public RecordDecl { /// constructor. unsigned HasDefaultedDefaultConstructor : 1; + /// \brief True if this class can be passed in a non-address-preserving + /// fashion (such as in registers) according to the C++ language rules. + /// This does not imply anything about how the ABI in use will actually + /// pass an object of this class. + unsigned CanPassInRegisters : 1; + /// \brief True if a defaulted default constructor for this class would /// be constexpr. unsigned DefaultedDefaultConstructorIsConstexpr : 1; @@ -811,18 +819,50 @@ public: return data().FirstFriend.isValid(); } + /// \brief \c true if a defaulted copy constructor for this class would be + /// deleted. + bool defaultedCopyConstructorIsDeleted() const { + assert((!needsOverloadResolutionForCopyConstructor() || + (data().DeclaredSpecialMembers & SMF_CopyConstructor)) && + "this property has not yet been computed by Sema"); + return data().DefaultedCopyConstructorIsDeleted; + } + + /// \brief \c true if a defaulted move constructor for this class would be + /// deleted. + bool defaultedMoveConstructorIsDeleted() const { + assert((!needsOverloadResolutionForMoveConstructor() || + (data().DeclaredSpecialMembers & SMF_MoveConstructor)) && + "this property has not yet been computed by Sema"); + return data().DefaultedMoveConstructorIsDeleted; + } + + /// \brief \c true if a defaulted destructor for this class would be deleted. + bool defaultedDestructorIsDeleted() const { + return !data().DefaultedDestructorIsDeleted; + } + + /// \brief \c true if we know for sure that this class has a single, + /// accessible, unambiguous copy constructor that is not deleted. + bool hasSimpleCopyConstructor() const { + return !hasUserDeclaredCopyConstructor() && + !data().DefaultedCopyConstructorIsDeleted; + } + /// \brief \c true if we know for sure that this class has a single, /// accessible, unambiguous move constructor that is not deleted. bool hasSimpleMoveConstructor() const { return !hasUserDeclaredMoveConstructor() && hasMoveConstructor() && !data().DefaultedMoveConstructorIsDeleted; } + /// \brief \c true if we know for sure that this class has a single, /// accessible, unambiguous move assignment operator that is not deleted. bool hasSimpleMoveAssignment() const { return !hasUserDeclaredMoveAssignment() && hasMoveAssignment() && !data().DefaultedMoveAssignmentIsDeleted; } + /// \brief \c true if we know for sure that this class has an accessible /// destructor that is not deleted. bool hasSimpleDestructor() const { @@ -878,7 +918,16 @@ public: /// \brief Determine whether we need to eagerly declare a defaulted copy /// constructor for this class. bool needsOverloadResolutionForCopyConstructor() const { - return data().HasMutableFields; + // C++17 [class.copy.ctor]p6: + // If the class definition declares a move constructor or move assignment + // operator, the implicitly declared copy constructor is defined as + // deleted. + // In MSVC mode, sometimes a declared move assignment does not delete an + // implicit copy constructor, so defer this choice to Sema. + if (data().UserDeclaredSpecialMembers & + (SMF_MoveConstructor | SMF_MoveAssignment)) + return true; + return data().NeedOverloadResolutionForCopyConstructor; } /// \brief Determine whether an implicit copy constructor for this type @@ -919,7 +968,16 @@ public: needsImplicitMoveConstructor(); } - /// \brief Set that we attempted to declare an implicitly move + /// \brief Set that we attempted to declare an implicit copy + /// constructor, but overload resolution failed so we deleted it. + void setImplicitCopyConstructorIsDeleted() { + assert((data().DefaultedCopyConstructorIsDeleted || + needsOverloadResolutionForCopyConstructor()) && + "Copy constructor should not be deleted"); + data().DefaultedCopyConstructorIsDeleted = true; + } + + /// \brief Set that we attempted to declare an implicit move /// constructor, but overload resolution failed so we deleted it. void setImplicitMoveConstructorIsDeleted() { assert((data().DefaultedMoveConstructorIsDeleted || @@ -1316,6 +1374,18 @@ public: return data().HasIrrelevantDestructor; } + /// \brief Determine whether this class has at least one trivial, non-deleted + /// copy or move constructor. + bool canPassInRegisters() const { + return data().CanPassInRegisters; + } + + /// \brief Set that we can pass this RecordDecl in registers. + // FIXME: This should be set as part of completeDefinition. + void setCanPassInRegisters(bool CanPass) { + data().CanPassInRegisters = CanPass; + } + /// \brief Determine whether this class has a non-literal or/ volatile type /// non-static data member or base class. bool hasNonLiteralTypeFieldsOrBases() const { @@ -1958,7 +2028,10 @@ public: /// \brief Returns the type of the \c this pointer. /// - /// Should only be called for instance (i.e., non-static) methods. + /// Should only be called for instance (i.e., non-static) methods. Note + /// that for the call operator of a lambda closure type, this returns the + /// desugared 'this' type (a pointer to the closure type), not the captured + /// 'this' type. QualType getThisType(ASTContext &C) const; unsigned getTypeQualifiers() const { diff --git contrib/llvm/tools/clang/include/clang/Driver/Options.td contrib/llvm/tools/clang/include/clang/Driver/Options.td index 753c178eec6a..05dc9d7eb3ad 100644 --- contrib/llvm/tools/clang/include/clang/Driver/Options.td +++ contrib/llvm/tools/clang/include/clang/Driver/Options.td @@ -694,6 +694,9 @@ def fbuiltin : Flag<["-"], "fbuiltin">, Group<f_Group>; def fbuiltin_module_map : Flag <["-"], "fbuiltin-module-map">, Group<f_Group>, Flags<[DriverOption]>, HelpText<"Load the clang builtins module map file.">; def fcaret_diagnostics : Flag<["-"], "fcaret-diagnostics">, Group<f_Group>; +def fclang_abi_compat_EQ : Joined<["-"], "fclang-abi-compat=">, Group<f_clang_Group>, + Flags<[CC1Option]>, MetaVarName<"<version>">, Values<"<major>.<minor>,latest">, + HelpText<"Attempt to match the ABI of Clang <version>">; def fclasspath_EQ : Joined<["-"], "fclasspath=">, Group<f_Group>; def fcolor_diagnostics : Flag<["-"], "fcolor-diagnostics">, Group<f_Group>, Flags<[CoreOption, CC1Option]>, HelpText<"Use colors in diagnostics">; diff --git contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.def contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.def index 238bb231bdf5..4002415adc45 100644 --- contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.def +++ contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.def @@ -120,6 +120,10 @@ CODEGENOPT(NoZeroInitializedInBSS , 1, 0) ///< -fno-zero-initialized-in-bss. ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy) CODEGENOPT(OmitLeafFramePointer , 1, 0) ///< Set when -momit-leaf-frame-pointer is ///< enabled. + +/// A version of Clang that we should attempt to be ABI-compatible with. +ENUM_CODEGENOPT(ClangABICompat, ClangABI, 4, ClangABI::Latest) + VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified. VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified. diff --git contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h index 22d5d3d16ee2..71730a21dbe2 100644 --- contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h +++ contrib/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h @@ -69,6 +69,23 @@ public: LocalExecTLSModel }; + /// Clang versions with different platform ABI conformance. + enum class ClangABI { + /// Attempt to be ABI-compatible with code generated by Clang 3.8.x + /// (SVN r257626). This causes <1 x long long> to be passed in an + /// integer register instead of an SSE register on x64_64. + Ver3_8, + + /// Attempt to be ABI-compatible with code generated by Clang 4.0.x + /// (SVN r291814). This causes move operations to be ignored when + /// determining whether a class type can be passed or returned directly. + Ver4, + + /// Conform to the underlying platform's C and C++ ABIs as closely + /// as we can. + Latest + }; + enum StructReturnConventionKind { SRCK_Default, // No special option was passed. SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return). diff --git contrib/llvm/tools/clang/include/clang/Lex/Preprocessor.h contrib/llvm/tools/clang/include/clang/Lex/Preprocessor.h index a058fbfbb4cf..dba4b80f6071 100644 --- contrib/llvm/tools/clang/include/clang/Lex/Preprocessor.h +++ contrib/llvm/tools/clang/include/clang/Lex/Preprocessor.h @@ -1048,10 +1048,6 @@ public: /// which implicitly adds the builtin defines etc. void EnterMainSourceFile(); - /// \brief After parser warm-up, initialize the conditional stack from - /// the preamble. - void replayPreambleConditionalStack(); - /// \brief Inform the preprocessor callbacks that processing is complete. void EndSourceFile(); @@ -2025,6 +2021,10 @@ public: } private: + /// \brief After processing predefined file, initialize the conditional stack from + /// the preamble. + void replayPreambleConditionalStack(); + // Macro handling. void HandleDefineDirective(Token &Tok, bool ImmediatelyAfterTopLevelIfndef); void HandleUndefDirective(); diff --git contrib/llvm/tools/clang/lib/AST/ASTImporter.cpp contrib/llvm/tools/clang/lib/AST/ASTImporter.cpp index 6e33b98d2f18..2c0bb11cc4bc 100644 --- contrib/llvm/tools/clang/lib/AST/ASTImporter.cpp +++ contrib/llvm/tools/clang/lib/AST/ASTImporter.cpp @@ -956,12 +956,16 @@ bool ASTNodeImporter::ImportDefinition(RecordDecl *From, RecordDecl *To, ToData.HasUninitializedFields = FromData.HasUninitializedFields; ToData.HasInheritedConstructor = FromData.HasInheritedConstructor; ToData.HasInheritedAssignment = FromData.HasInheritedAssignment; + ToData.NeedOverloadResolutionForCopyConstructor + = FromData.NeedOverloadResolutionForCopyConstructor; ToData.NeedOverloadResolutionForMoveConstructor = FromData.NeedOverloadResolutionForMoveConstructor; ToData.NeedOverloadResolutionForMoveAssignment = FromData.NeedOverloadResolutionForMoveAssignment; ToData.NeedOverloadResolutionForDestructor = FromData.NeedOverloadResolutionForDestructor; + ToData.DefaultedCopyConstructorIsDeleted + = FromData.DefaultedCopyConstructorIsDeleted; ToData.DefaultedMoveConstructorIsDeleted = FromData.DefaultedMoveConstructorIsDeleted; ToData.DefaultedMoveAssignmentIsDeleted @@ -973,6 +977,7 @@ bool ASTNodeImporter::ImportDefinition(RecordDecl *From, RecordDecl *To, = FromData.HasConstexprNonCopyMoveConstructor; ToData.HasDefaultedDefaultConstructor = FromData.HasDefaultedDefaultConstructor; + ToData.CanPassInRegisters = FromData.CanPassInRegisters; ToData.DefaultedDefaultConstructorIsConstexpr = FromData.DefaultedDefaultConstructorIsConstexpr; ToData.HasConstexprDefaultConstructor diff --git contrib/llvm/tools/clang/lib/AST/DeclCXX.cpp contrib/llvm/tools/clang/lib/AST/DeclCXX.cpp index 1caceab85eea..5782b7b56c96 100644 --- contrib/llvm/tools/clang/lib/AST/DeclCXX.cpp +++ contrib/llvm/tools/clang/lib/AST/DeclCXX.cpp @@ -55,15 +55,18 @@ CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl *D) HasOnlyCMembers(true), HasInClassInitializer(false), HasUninitializedReferenceMember(false), HasUninitializedFields(false), HasInheritedConstructor(false), HasInheritedAssignment(false), + NeedOverloadResolutionForCopyConstructor(false), NeedOverloadResolutionForMoveConstructor(false), NeedOverloadResolutionForMoveAssignment(false), NeedOverloadResolutionForDestructor(false), + DefaultedCopyConstructorIsDeleted(false), DefaultedMoveConstructorIsDeleted(false), DefaultedMoveAssignmentIsDeleted(false), DefaultedDestructorIsDeleted(false), HasTrivialSpecialMembers(SMF_All), DeclaredNonTrivialSpecialMembers(0), HasIrrelevantDestructor(true), HasConstexprNonCopyMoveConstructor(false), HasDefaultedDefaultConstructor(false), + CanPassInRegisters(true), DefaultedDefaultConstructorIsConstexpr(true), HasConstexprDefaultConstructor(false), HasNonLiteralTypeFieldsOrBases(false), ComputedVisibleConversions(false), @@ -352,8 +355,10 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases, setHasVolatileMember(true); // Keep track of the presence of mutable fields. - if (BaseClassDecl->hasMutableFields()) + if (BaseClassDecl->hasMutableFields()) { data().HasMutableFields = true; + data().NeedOverloadResolutionForCopyConstructor = true; + } if (BaseClassDecl->hasUninitializedReferenceMember()) data().HasUninitializedReferenceMember = true; @@ -406,6 +411,8 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl *Subobj) { // -- a direct or virtual base class B that cannot be copied/moved [...] // -- a non-static data member of class type M (or array thereof) // that cannot be copied or moved [...] + if (!Subobj->hasSimpleCopyConstructor()) + data().NeedOverloadResolutionForCopyConstructor = true; if (!Subobj->hasSimpleMoveConstructor()) data().NeedOverloadResolutionForMoveConstructor = true; @@ -426,6 +433,7 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl *Subobj) { // -- any non-static data member has a type with a destructor // that is deleted or inaccessible from the defaulted [ctor or dtor]. if (!Subobj->hasSimpleDestructor()) { + data().NeedOverloadResolutionForCopyConstructor = true; data().NeedOverloadResolutionForMoveConstructor = true; data().NeedOverloadResolutionForDestructor = true; } @@ -711,8 +719,10 @@ void CXXRecordDecl::addedMember(Decl *D) { data().IsStandardLayout = false; // Keep track of the presence of mutable fields. - if (Field->isMutable()) + if (Field->isMutable()) { data().HasMutableFields = true; + data().NeedOverloadResolutionForCopyConstructor = true; + } // C++11 [class.union]p8, DR1460: // If X is a union, a non-static data member of X that is not an anonymous @@ -756,6 +766,12 @@ void CXXRecordDecl::addedMember(Decl *D) { // A standard-layout class is a class that: // -- has no non-static data members of type [...] reference, data().IsStandardLayout = false; + + // C++1z [class.copy.ctor]p10: + // A defaulted copy constructor for a class X is defined as deleted if X has: + // -- a non-static data member of rvalue reference type + if (T->isRValueReferenceType()) + data().DefaultedCopyConstructorIsDeleted = true; } if (!Field->hasInClassInitializer() && !Field->isMutable()) { @@ -809,6 +825,10 @@ void CXXRecordDecl::addedMember(Decl *D) { // We may need to perform overload resolution to determine whether a // field can be moved if it's const or volatile qualified. if (T.getCVRQualifiers() & (Qualifiers::Const | Qualifiers::Volatile)) { + // We need to care about 'const' for the copy constructor because an + // implicit copy constructor might be declared with a non-const + // parameter. + data().NeedOverloadResolutionForCopyConstructor = true; data().NeedOverloadResolutionForMoveConstructor = true; data().NeedOverloadResolutionForMoveAssignment = true; } @@ -819,6 +839,8 @@ void CXXRecordDecl::addedMember(Decl *D) { // -- X is a union-like class that has a variant member with a // non-trivial [corresponding special member] if (isUnion()) { + if (FieldRec->hasNonTrivialCopyConstructor()) + data().DefaultedCopyConstructorIsDeleted = true; if (FieldRec->hasNonTrivialMoveConstructor()) data().DefaultedMoveConstructorIsDeleted = true; if (FieldRec->hasNonTrivialMoveAssignment()) @@ -830,6 +852,8 @@ void CXXRecordDecl::addedMember(Decl *D) { // For an anonymous union member, our overload resolution will perform // overload resolution for its members. if (Field->isAnonymousStructOrUnion()) { + data().NeedOverloadResolutionForCopyConstructor |= + FieldRec->data().NeedOverloadResolutionForCopyConstructor; data().NeedOverloadResolutionForMoveConstructor |= FieldRec->data().NeedOverloadResolutionForMoveConstructor; data().NeedOverloadResolutionForMoveAssignment |= @@ -915,8 +939,10 @@ void CXXRecordDecl::addedMember(Decl *D) { } // Keep track of the presence of mutable fields. - if (FieldRec->hasMutableFields()) + if (FieldRec->hasMutableFields()) { data().HasMutableFields = true; + data().NeedOverloadResolutionForCopyConstructor = true; + } // C++11 [class.copy]p13: // If the implicitly-defined constructor would satisfy the @@ -1450,7 +1476,7 @@ void CXXRecordDecl::completeDefinition() { void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) { RecordDecl::completeDefinition(); - + // If the class may be abstract (but hasn't been marked as such), check for // any pure final overriders. if (mayBeAbstract()) { diff --git contrib/llvm/tools/clang/lib/Basic/Version.cpp contrib/llvm/tools/clang/lib/Basic/Version.cpp index 3fd322483392..509c4a9ea052 100644 --- contrib/llvm/tools/clang/lib/Basic/Version.cpp +++ contrib/llvm/tools/clang/lib/Basic/Version.cpp @@ -36,7 +36,7 @@ std::string getClangRepositoryPath() { // If the SVN_REPOSITORY is empty, try to use the SVN keyword. This helps us // pick up a tag in an SVN export, for example. - StringRef SVNRepository("$URL: https://llvm.org/svn/llvm-project/cfe/branches/release_50/lib/Basic/Version.cpp $"); + StringRef SVNRepository("$URL: https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_500/final/lib/Basic/Version.cpp $"); if (URL.empty()) { URL = SVNRepository.slice(SVNRepository.find(':'), SVNRepository.find("/lib/Basic")); diff --git contrib/llvm/tools/clang/lib/CodeGen/ABIInfo.h contrib/llvm/tools/clang/lib/CodeGen/ABIInfo.h index e4dce2f2a004..575506da84d4 100644 --- contrib/llvm/tools/clang/lib/CodeGen/ABIInfo.h +++ contrib/llvm/tools/clang/lib/CodeGen/ABIInfo.h @@ -24,6 +24,7 @@ namespace llvm { namespace clang { class ASTContext; + class CodeGenOptions; class TargetInfo; namespace CodeGen { @@ -68,6 +69,7 @@ namespace swiftcall { llvm::LLVMContext &getVMContext() const; const llvm::DataLayout &getDataLayout() const; const TargetInfo &getTarget() const; + const CodeGenOptions &getCodeGenOpts() const; /// Return the calling convention to use for system runtime /// functions. diff --git contrib/llvm/tools/clang/lib/CodeGen/CGCXXABI.cpp contrib/llvm/tools/clang/lib/CodeGen/CGCXXABI.cpp index e29e525edd24..033258643ddf 100644 --- contrib/llvm/tools/clang/lib/CodeGen/CGCXXABI.cpp +++ contrib/llvm/tools/clang/lib/CodeGen/CGCXXABI.cpp @@ -30,38 +30,9 @@ void CGCXXABI::ErrorUnsupportedABI(CodeGenFunction &CGF, StringRef S) { } bool CGCXXABI::canCopyArgument(const CXXRecordDecl *RD) const { - // If RD has a non-trivial move or copy constructor, we cannot copy the - // argument. - if (RD->hasNonTrivialCopyConstructor() || RD->hasNonTrivialMoveConstructor()) - return false; - - // If RD has a non-trivial destructor, we cannot copy the argument. - if (RD->hasNonTrivialDestructor()) - return false; - // We can only copy the argument if there exists at least one trivial, // non-deleted copy or move constructor. - // FIXME: This assumes that all lazily declared copy and move constructors are - // not deleted. This assumption might not be true in some corner cases. - bool CopyDeleted = false; - bool MoveDeleted = false; - for (const CXXConstructorDecl *CD : RD->ctors()) { - if (CD->isCopyConstructor() || CD->isMoveConstructor()) { - assert(CD->isTrivial()); - // We had at least one undeleted trivial copy or move ctor. Return - // directly. - if (!CD->isDeleted()) - return true; - if (CD->isCopyConstructor()) - CopyDeleted = true; - else - MoveDeleted = true; - } - } - - // If all trivial copy and move constructors are deleted, we cannot copy the - // argument. - return !(CopyDeleted && MoveDeleted); + return RD->canPassInRegisters(); } llvm::Constant *CGCXXABI::GetBogusMemberPointer(QualType T) { diff --git contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp index c9c450c32e3b..18b1d10a921d 100644 --- contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp +++ contrib/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp @@ -3260,7 +3260,7 @@ void CGDebugInfo::EmitInlineFunctionStart(CGBuilderTy &Builder, GlobalDecl GD) { llvm::DISubprogram *SP = nullptr; if (FI != SPCache.end()) SP = dyn_cast_or_null<llvm::DISubprogram>(FI->second); - if (!SP) + if (!SP || !SP->isDefinition()) SP = getFunctionStub(GD); FnBeginRegionCount.push_back(LexicalBlockStack.size()); LexicalBlockStack.emplace_back(SP); diff --git contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp index 93a4a3866193..c23b25ea461f 100644 --- contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp +++ contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp @@ -22,6 +22,7 @@ #include "CodeGenPGO.h" #include "TargetInfo.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/ASTLambda.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/StmtCXX.h" @@ -983,11 +984,22 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, } // Check the 'this' pointer once per function, if it's available. - if (CXXThisValue) { + if (CXXABIThisValue) { SanitizerSet SkippedChecks; SkippedChecks.set(SanitizerKind::ObjectSize, true); QualType ThisTy = MD->getThisType(getContext()); - EmitTypeCheck(TCK_Load, Loc, CXXThisValue, ThisTy, + + // If this is the call operator of a lambda with no capture-default, it + // may have a static invoker function, which may call this operator with + // a null 'this' pointer. + if (isLambdaCallOperator(MD) && + cast<CXXRecordDecl>(MD->getParent())->getLambdaCaptureDefault() == + LCD_None) + SkippedChecks.set(SanitizerKind::Null, true); + + EmitTypeCheck(isa<CXXConstructorDecl>(MD) ? TCK_ConstructorCall + : TCK_MemberCall, + Loc, CXXABIThisValue, ThisTy, getContext().getTypeAlignInChars(ThisTy->getPointeeType()), SkippedChecks); } diff --git contrib/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp contrib/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp index 5ed929135880..9306c4fbaff8 100644 --- contrib/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp +++ contrib/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp @@ -44,6 +44,10 @@ CodeGenTypes::~CodeGenTypes() { delete &*I++; } +const CodeGenOptions &CodeGenTypes::getCodeGenOpts() const { + return CGM.getCodeGenOpts(); +} + void CodeGenTypes::addRecordTypeName(const RecordDecl *RD, llvm::StructType *Ty, StringRef suffix) { diff --git contrib/llvm/tools/clang/lib/CodeGen/CodeGenTypes.h contrib/llvm/tools/clang/lib/CodeGen/CodeGenTypes.h index f0b97ebde1c2..9d0e3ded23e4 100644 --- contrib/llvm/tools/clang/lib/CodeGen/CodeGenTypes.h +++ contrib/llvm/tools/clang/lib/CodeGen/CodeGenTypes.h @@ -178,6 +178,7 @@ public: const TargetInfo &getTarget() const { return Target; } CGCXXABI &getCXXABI() const { return TheCXXABI; } llvm::LLVMContext &getLLVMContext() { return TheModule.getContext(); } + const CodeGenOptions &getCodeGenOpts() const; /// ConvertType - Convert type T into a llvm::Type. llvm::Type *ConvertType(QualType T); diff --git contrib/llvm/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp contrib/llvm/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp index c82b9677eacf..bd4cb9a3667b 100644 --- contrib/llvm/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ contrib/llvm/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -62,12 +62,20 @@ public: bool classifyReturnType(CGFunctionInfo &FI) const override; + bool passClassIndirect(const CXXRecordDecl *RD) const { + // Clang <= 4 used the pre-C++11 rule, which ignores move operations. + // The PS4 platform ABI follows the behavior of Clang 3.2. + if (CGM.getCodeGenOpts().getClangABICompat() <= + CodeGenOptions::ClangABI::Ver4 || + CGM.getTriple().getOS() == llvm::Triple::PS4) + return RD->hasNonTrivialDestructor() || + RD->hasNonTrivialCopyConstructor(); + return !canCopyArgument(RD); + } + RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const override { - // Structures with either a non-trivial destructor or a non-trivial - // copy constructor are always indirect. - // FIXME: Use canCopyArgument() when it is fixed to handle lazily declared - // special members. - if (RD->hasNonTrivialDestructor() || RD->hasNonTrivialCopyConstructor()) + // If C++ prohibits us from making a copy, pass by address. + if (passClassIndirect(RD)) return RAA_Indirect; return RAA_Default; } @@ -998,10 +1006,8 @@ bool ItaniumCXXABI::classifyReturnType(CGFunctionInfo &FI) const { if (!RD) return false; - // Return indirectly if we have a non-trivial copy ctor or non-trivial dtor. - // FIXME: Use canCopyArgument() when it is fixed to handle lazily declared - // special members. - if (RD->hasNonTrivialDestructor() || RD->hasNonTrivialCopyConstructor()) { + // If C++ prohibits us from making a copy, return by address. + if (passClassIndirect(RD)) { auto Align = CGM.getContext().getTypeAlignInChars(FI.getReturnType()); FI.getReturnInfo() = ABIArgInfo::getIndirect(Align, /*ByVal=*/false); return true; diff --git contrib/llvm/tools/clang/lib/CodeGen/MicrosoftCXXABI.cpp contrib/llvm/tools/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 78b510bb4665..1bd2937e4747 100644 --- contrib/llvm/tools/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ contrib/llvm/tools/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -819,46 +819,44 @@ MicrosoftCXXABI::getRecordArgABI(const CXXRecordDecl *RD) const { return RAA_Default; case llvm::Triple::x86_64: - // Win64 passes objects with non-trivial copy ctors indirectly. - if (RD->hasNonTrivialCopyConstructor()) - return RAA_Indirect; - - // If an object has a destructor, we'd really like to pass it indirectly + // If a class has a destructor, we'd really like to pass it indirectly // because it allows us to elide copies. Unfortunately, MSVC makes that // impossible for small types, which it will pass in a single register or // stack slot. Most objects with dtors are large-ish, so handle that early. // We can't call out all large objects as being indirect because there are // multiple x64 calling conventions and the C++ ABI code shouldn't dictate // how we pass large POD types. + // + // Note: This permits small classes with nontrivial destructors to be + // passed in registers, which is non-conforming. if (RD->hasNonTrivialDestructor() && getContext().getTypeSize(RD->getTypeForDecl()) > 64) return RAA_Indirect; - // If this is true, the implicit copy constructor that Sema would have - // created would not be deleted. FIXME: We should provide a more direct way - // for CodeGen to ask whether the constructor was deleted. - if (!RD->hasUserDeclaredCopyConstructor() && - !RD->hasUserDeclaredMoveConstructor() && - !RD->needsOverloadResolutionForMoveConstructor() && - !RD->hasUserDeclaredMoveAssignment() && - !RD->needsOverloadResolutionForMoveAssignment()) - return RAA_Default; - - // Otherwise, Sema should have created an implicit copy constructor if - // needed. - assert(!RD->needsImplicitCopyConstructor()); - - // We have to make sure the trivial copy constructor isn't deleted. - for (const CXXConstructorDecl *CD : RD->ctors()) { - if (CD->isCopyConstructor()) { - assert(CD->isTrivial()); - // We had at least one undeleted trivial copy ctor. Return directly. - if (!CD->isDeleted()) - return RAA_Default; + // If a class has at least one non-deleted, trivial copy constructor, it + // is passed according to the C ABI. Otherwise, it is passed indirectly. + // + // Note: This permits classes with non-trivial copy or move ctors to be + // passed in registers, so long as they *also* have a trivial copy ctor, + // which is non-conforming. + if (RD->needsImplicitCopyConstructor()) { + // If the copy ctor has not yet been declared, we can read its triviality + // off the AST. + if (!RD->defaultedCopyConstructorIsDeleted() && + RD->hasTrivialCopyConstructor()) + return RAA_Default; + } else { + // Otherwise, we need to find the copy constructor(s) and ask. + for (const CXXConstructorDecl *CD : RD->ctors()) { + if (CD->isCopyConstructor()) { + // We had at least one nondeleted trivial copy ctor. Return directly. + if (!CD->isDeleted() && CD->isTrivial()) + return RAA_Default; + } } } - // The trivial copy constructor was deleted. Return indirectly. + // We have no trivial, non-deleted copy constructor. return RAA_Indirect; } diff --git contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp index eb230aad4d35..ece3a407eae3 100644 --- contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp +++ contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp @@ -183,7 +183,11 @@ const TargetInfo &ABIInfo::getTarget() const { return CGT.getTarget(); } -bool ABIInfo:: isAndroid() const { return getTarget().getTriple().isAndroid(); } +const CodeGenOptions &ABIInfo::getCodeGenOpts() const { + return CGT.getCodeGenOpts(); +} + +bool ABIInfo::isAndroid() const { return getTarget().getTriple().isAndroid(); } bool ABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const { return false; @@ -2095,9 +2099,14 @@ class X86_64ABIInfo : public SwiftABIInfo { return !getTarget().getTriple().isOSDarwin(); } - /// GCC classifies <1 x long long> as SSE but compatibility with older clang - // compilers require us to classify it as INTEGER. + /// GCC classifies <1 x long long> as SSE but some platform ABIs choose to + /// classify it as INTEGER (for compatibility with older clang compilers). bool classifyIntegerMMXAsSSE() const { + // Clang <= 3.8 did not do this. + if (getCodeGenOpts().getClangABICompat() <= + CodeGenOptions::ClangABI::Ver3_8) + return false; + const llvm::Triple &Triple = getTarget().getTriple(); if (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::PS4) return false; diff --git contrib/llvm/tools/clang/lib/Driver/ToolChains/Clang.cpp contrib/llvm/tools/clang/lib/Driver/ToolChains/Clang.cpp index baf7a93d2d92..6a6b90f86825 100644 --- contrib/llvm/tools/clang/lib/Driver/ToolChains/Clang.cpp +++ contrib/llvm/tools/clang/lib/Driver/ToolChains/Clang.cpp @@ -2855,6 +2855,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs); + if (auto *ABICompatArg = Args.getLastArg(options::OPT_fclang_abi_compat_EQ)) + ABICompatArg->render(Args, CmdArgs); + // Add runtime flag for PS4 when PGO or Coverage are enabled. if (getToolChain().getTriple().isPS4CPU()) PS4cpu::addProfileRTArgs(getToolChain(), Args, CmdArgs); diff --git contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.cpp contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.cpp index 6b7f0c71dfb7..32103a6120d4 100644 --- contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.cpp +++ contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1837,7 +1837,12 @@ Darwin::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch, } bool MachO::IsUnwindTablesDefault(const ArgList &Args) const { - return !UseSjLjExceptions(Args); + // Unwind tables are not emitted if -fno-exceptions is supplied (except when + // targeting x86_64). + return getArch() == llvm::Triple::x86_64 || + (!UseSjLjExceptions(Args) && + Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, + true)); } bool MachO::UseDwarfDebugFlags() const { diff --git contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.cpp contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.cpp index b871c856d2a0..7978a6941cb8 100644 --- contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.cpp +++ contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.cpp @@ -76,7 +76,7 @@ static bool getSystemRegistryString(const char *keyPath, const char *valueName, // Check various environment variables to try and find a toolchain. static bool findVCToolChainViaEnvironment(std::string &Path, - bool &IsVS2017OrNewer) { + MSVCToolChain::ToolsetLayout &VSLayout) { // These variables are typically set by vcvarsall.bat // when launching a developer command prompt. if (llvm::Optional<std::string> VCToolsInstallDir = @@ -84,7 +84,7 @@ static bool findVCToolChainViaEnvironment(std::string &Path, // This is only set by newer Visual Studios, and it leads straight to // the toolchain directory. Path = std::move(*VCToolsInstallDir); - IsVS2017OrNewer = true; + VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer; return true; } if (llvm::Optional<std::string> VCInstallDir = @@ -94,7 +94,7 @@ static bool findVCToolChainViaEnvironment(std::string &Path, // so this check has to appear second. // In older Visual Studios, the VC directory is the toolchain. Path = std::move(*VCInstallDir); - IsVS2017OrNewer = false; + VSLayout = MSVCToolChain::ToolsetLayout::OlderVS; return true; } @@ -134,9 +134,16 @@ static bool findVCToolChainViaEnvironment(std::string &Path, } if (IsBin) { llvm::StringRef ParentPath = llvm::sys::path::parent_path(TestPath); - if (llvm::sys::path::filename(ParentPath) == "VC") { + llvm::StringRef ParentFilename = llvm::sys::path::filename(ParentPath); + if (ParentFilename == "VC") { Path = ParentPath; - IsVS2017OrNewer = false; + VSLayout = MSVCToolChain::ToolsetLayout::OlderVS; + return true; + } + if (ParentFilename == "x86ret" || ParentFilename == "x86chk" + || ParentFilename == "amd64ret" || ParentFilename == "amd64chk") { + Path = ParentPath; + VSLayout = MSVCToolChain::ToolsetLayout::DevDivInternal; return true; } @@ -165,7 +172,7 @@ static bool findVCToolChainViaEnvironment(std::string &Path, ToolChainPath = llvm::sys::path::parent_path(ToolChainPath); Path = ToolChainPath; - IsVS2017OrNewer = true; + VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer; return true; } @@ -181,7 +188,7 @@ static bool findVCToolChainViaEnvironment(std::string &Path, // This is the preferred way to discover new Visual Studios, as they're no // longer listed in the registry. static bool findVCToolChainViaSetupConfig(std::string &Path, - bool &IsVS2017OrNewer) { + MSVCToolChain::ToolsetLayout &VSLayout) { #if !defined(USE_MSVC_SETUP_API) return false; #else @@ -263,7 +270,7 @@ static bool findVCToolChainViaSetupConfig(std::string &Path, return false; Path = ToolchainPath.str(); - IsVS2017OrNewer = true; + VSLayout = MSVCToolChain::ToolsetLayout::VS2017OrNewer; return true; #endif } @@ -272,7 +279,7 @@ static bool findVCToolChainViaSetupConfig(std::string &Path, // a toolchain path. VS2017 and newer don't get added to the registry. // So if we find something here, we know that it's an older version. static bool findVCToolChainViaRegistry(std::string &Path, - bool &IsVS2017OrNewer) { + MSVCToolChain::ToolsetLayout &VSLayout) { std::string VSInstallPath; if (getSystemRegistryString(R"(SOFTWARE\Microsoft\VisualStudio\$VERSION)", "InstallDir", VSInstallPath, nullptr) || @@ -284,7 +291,7 @@ static bool findVCToolChainViaRegistry(std::string &Path, llvm::sys::path::append(VCPath, "VC"); Path = VCPath.str(); - IsVS2017OrNewer = false; + VSLayout = MSVCToolChain::ToolsetLayout::OlderVS; return true; } } @@ -475,6 +482,7 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA, // native target bin directory. // e.g. when compiling for x86 on an x64 host, PATH should start with: // /bin/HostX64/x86;/bin/HostX64/x64 + // This doesn't attempt to handle ToolsetLayout::DevDivInternal. if (TC.getIsVS2017OrNewer() && llvm::Triple(llvm::sys::getProcessTriple()).getArch() != TC.getArch()) { auto HostArch = llvm::Triple(llvm::sys::getProcessTriple()).getArch(); @@ -677,9 +685,9 @@ MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple &Triple, // what they want to use. // Failing that, just try to find the newest Visual Studio version we can // and use its default VC toolchain. - findVCToolChainViaEnvironment(VCToolChainPath, IsVS2017OrNewer) || - findVCToolChainViaSetupConfig(VCToolChainPath, IsVS2017OrNewer) || - findVCToolChainViaRegistry(VCToolChainPath, IsVS2017OrNewer); + findVCToolChainViaEnvironment(VCToolChainPath, VSLayout) || + findVCToolChainViaSetupConfig(VCToolChainPath, VSLayout) || + findVCToolChainViaRegistry(VCToolChainPath, VSLayout); } Tool *MSVCToolChain::buildLinker() const { @@ -766,6 +774,21 @@ static const char *llvmArchToLegacyVCArch(llvm::Triple::ArchType Arch) { } } +// Similar to the above function, but for DevDiv internal builds. +static const char *llvmArchToDevDivInternalArch(llvm::Triple::ArchType Arch) { + using ArchType = llvm::Triple::ArchType; + switch (Arch) { + case ArchType::x86: + return "i386"; + case ArchType::x86_64: + return "amd64"; + case ArchType::arm: + return "arm"; + default: + return ""; + } +} + // Get the path to a specific subdirectory in the current toolchain for // a given target architecture. // VS2017 changed the VC toolchain layout, so this should be used instead @@ -773,26 +796,40 @@ static const char *llvmArchToLegacyVCArch(llvm::Triple::ArchType Arch) { std::string MSVCToolChain::getSubDirectoryPath(SubDirectoryType Type, llvm::Triple::ArchType TargetArch) const { + const char *SubdirName; + const char *IncludeName; + switch (VSLayout) { + case ToolsetLayout::OlderVS: + SubdirName = llvmArchToLegacyVCArch(TargetArch); + IncludeName = "include"; + break; + case ToolsetLayout::VS2017OrNewer: + SubdirName = llvmArchToWindowsSDKArch(TargetArch); + IncludeName = "include"; + break; + case ToolsetLayout::DevDivInternal: + SubdirName = llvmArchToDevDivInternalArch(TargetArch); + IncludeName = "inc"; + break; + } + llvm::SmallString<256> Path(VCToolChainPath); switch (Type) { case SubDirectoryType::Bin: - if (IsVS2017OrNewer) { - bool HostIsX64 = + if (VSLayout == ToolsetLayout::VS2017OrNewer) { + const bool HostIsX64 = llvm::Triple(llvm::sys::getProcessTriple()).isArch64Bit(); - llvm::sys::path::append(Path, "bin", (HostIsX64 ? "HostX64" : "HostX86"), - llvmArchToWindowsSDKArch(TargetArch)); - - } else { - llvm::sys::path::append(Path, "bin", llvmArchToLegacyVCArch(TargetArch)); + const char *const HostName = HostIsX64 ? "HostX64" : "HostX86"; + llvm::sys::path::append(Path, "bin", HostName, SubdirName); + } else { // OlderVS or DevDivInternal + llvm::sys::path::append(Path, "bin", SubdirName); } break; case SubDirectoryType::Include: - llvm::sys::path::append(Path, "include"); + llvm::sys::path::append(Path, IncludeName); break; case SubDirectoryType::Lib: - llvm::sys::path::append( - Path, "lib", IsVS2017OrNewer ? llvmArchToWindowsSDKArch(TargetArch) - : llvmArchToLegacyVCArch(TargetArch)); + llvm::sys::path::append(Path, "lib", SubdirName); break; } return Path.str(); diff --git contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.h contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.h index d153691a5c90..854f88a36fd2 100644 --- contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.h +++ contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.h @@ -92,7 +92,12 @@ public: return getSubDirectoryPath(Type, getArch()); } - bool getIsVS2017OrNewer() const { return IsVS2017OrNewer; } + enum class ToolsetLayout { + OlderVS, + VS2017OrNewer, + DevDivInternal, + }; + bool getIsVS2017OrNewer() const { return VSLayout == ToolsetLayout::VS2017OrNewer; } void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, @@ -130,7 +135,7 @@ protected: Tool *buildAssembler() const override; private: std::string VCToolChainPath; - bool IsVS2017OrNewer = false; + ToolsetLayout VSLayout = ToolsetLayout::OlderVS; CudaInstallationDetector CudaInstallation; }; diff --git contrib/llvm/tools/clang/lib/Format/WhitespaceManager.cpp contrib/llvm/tools/clang/lib/Format/WhitespaceManager.cpp index 4b4fd13145fb..377ec3a681b6 100644 --- contrib/llvm/tools/clang/lib/Format/WhitespaceManager.cpp +++ contrib/llvm/tools/clang/lib/Format/WhitespaceManager.cpp @@ -246,12 +246,12 @@ AlignTokenSequence(unsigned Start, unsigned End, unsigned Column, F &&Matches, for (unsigned i = Start; i != End; ++i) { if (ScopeStack.size() != 0 && - Changes[i].nestingAndIndentLevel() < - Changes[ScopeStack.back()].nestingAndIndentLevel()) + Changes[i].indentAndNestingLevel() < + Changes[ScopeStack.back()].indentAndNestingLevel()) ScopeStack.pop_back(); - if (i != Start && Changes[i].nestingAndIndentLevel() > - Changes[i - 1].nestingAndIndentLevel()) + if (i != Start && Changes[i].indentAndNestingLevel() > + Changes[i - 1].indentAndNestingLevel()) ScopeStack.push_back(i); bool InsideNestedScope = ScopeStack.size() != 0; @@ -327,8 +327,8 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches, // Measure the scope level (i.e. depth of (), [], {}) of the first token, and // abort when we hit any token in a higher scope than the starting one. - auto NestingAndIndentLevel = StartAt < Changes.size() - ? Changes[StartAt].nestingAndIndentLevel() + auto IndentAndNestingLevel = StartAt < Changes.size() + ? Changes[StartAt].indentAndNestingLevel() : std::pair<unsigned, unsigned>(0, 0); // Keep track of the number of commas before the matching tokens, we will only @@ -359,7 +359,7 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches, unsigned i = StartAt; for (unsigned e = Changes.size(); i != e; ++i) { - if (Changes[i].nestingAndIndentLevel() < NestingAndIndentLevel) + if (Changes[i].indentAndNestingLevel() < IndentAndNestingLevel) break; if (Changes[i].NewlinesBefore != 0) { @@ -375,7 +375,7 @@ static unsigned AlignTokens(const FormatStyle &Style, F &&Matches, if (Changes[i].Tok->is(tok::comma)) { ++CommasBeforeMatch; - } else if (Changes[i].nestingAndIndentLevel() > NestingAndIndentLevel) { + } else if (Changes[i].indentAndNestingLevel() > IndentAndNestingLevel) { // Call AlignTokens recursively, skipping over this scope block. unsigned StoppedAt = AlignTokens(Style, Matches, Changes, i); i = StoppedAt - 1; @@ -472,9 +472,14 @@ void WhitespaceManager::alignTrailingComments() { continue; unsigned ChangeMinColumn = Changes[i].StartOfTokenColumn; - unsigned ChangeMaxColumn = Style.ColumnLimit >= Changes[i].TokenLength - ? Style.ColumnLimit - Changes[i].TokenLength - : ChangeMinColumn; + unsigned ChangeMaxColumn; + + if (Style.ColumnLimit == 0) + ChangeMaxColumn = UINT_MAX; + else if (Style.ColumnLimit >= Changes[i].TokenLength) + ChangeMaxColumn = Style.ColumnLimit - Changes[i].TokenLength; + else + ChangeMaxColumn = ChangeMinColumn; // If we don't create a replacement for this change, we have to consider // it to be immovable. diff --git contrib/llvm/tools/clang/lib/Format/WhitespaceManager.h contrib/llvm/tools/clang/lib/Format/WhitespaceManager.h index 50df59d09641..4e78ab43abaf 100644 --- contrib/llvm/tools/clang/lib/Format/WhitespaceManager.h +++ contrib/llvm/tools/clang/lib/Format/WhitespaceManager.h @@ -154,12 +154,11 @@ public: const Change *StartOfBlockComment; int IndentationOffset; - // A combination of nesting level and indent level, which are used in + // A combination of indent level and nesting level, which are used in // tandem to compute lexical scope, for the purposes of deciding // when to stop consecutive alignment runs. - std::pair<unsigned, unsigned> - nestingAndIndentLevel() const { - return std::make_pair(Tok->NestingLevel, Tok->IndentLevel); + std::pair<unsigned, unsigned> indentAndNestingLevel() const { + return std::make_pair(Tok->IndentLevel, Tok->NestingLevel); } }; diff --git contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp index b2c14554a4b5..0d0869c815d3 100644 --- contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp +++ contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp @@ -573,6 +573,33 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, if (!Opts.ProfileInstrumentUsePath.empty()) setPGOUseInstrumentor(Opts, Opts.ProfileInstrumentUsePath); + if (Arg *A = Args.getLastArg(OPT_fclang_abi_compat_EQ)) { + Opts.setClangABICompat(CodeGenOptions::ClangABI::Latest); + + StringRef Ver = A->getValue(); + std::pair<StringRef, StringRef> VerParts = Ver.split('.'); + unsigned Major, Minor = 0; + + // Check the version number is valid: either 3.x (0 <= x <= 9) or + // y or y.0 (4 <= y <= current version). + if (!VerParts.first.startswith("0") && + !VerParts.first.getAsInteger(10, Major) && + 3 <= Major && Major <= CLANG_VERSION_MAJOR && + (Major == 3 ? VerParts.second.size() == 1 && + !VerParts.second.getAsInteger(10, Minor) + : VerParts.first.size() == Ver.size() || + VerParts.second == "0")) { + // Got a valid version number. + if (Major == 3 && Minor <= 8) + Opts.setClangABICompat(CodeGenOptions::ClangABI::Ver3_8); + else if (Major <= 4) + Opts.setClangABICompat(CodeGenOptions::ClangABI::Ver4); + } else if (Ver != "latest") { + Diags.Report(diag::err_drv_invalid_value) + << A->getAsString(Args) << A->getValue(); + } + } + Opts.CoverageMapping = Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false); Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping); diff --git contrib/llvm/tools/clang/lib/Headers/unwind.h contrib/llvm/tools/clang/lib/Headers/unwind.h index e94b00b57c26..4f74a3478740 100644 --- contrib/llvm/tools/clang/lib/Headers/unwind.h +++ contrib/llvm/tools/clang/lib/Headers/unwind.h @@ -76,13 +76,7 @@ typedef intptr_t _sleb128_t; typedef uintptr_t _uleb128_t; struct _Unwind_Context; -#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || defined(__ARM_DWARF_EH___)) -struct _Unwind_Control_Block; -typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */ -#else struct _Unwind_Exception; -typedef struct _Unwind_Exception _Unwind_Exception; -#endif typedef enum { _URC_NO_REASON = 0, #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \ @@ -115,42 +109,8 @@ typedef enum { } _Unwind_Action; typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code, - _Unwind_Exception *); - -#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || defined(__ARM_DWARF_EH___)) -typedef struct _Unwind_Control_Block _Unwind_Control_Block; -typedef uint32_t _Unwind_EHT_Header; - -struct _Unwind_Control_Block { - uint64_t exception_class; - void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *); - /* unwinder cache (private fields for the unwinder's use) */ - struct { - uint32_t reserved1; /* forced unwind stop function, 0 if not forced */ - uint32_t reserved2; /* personality routine */ - uint32_t reserved3; /* callsite */ - uint32_t reserved4; /* forced unwind stop argument */ - uint32_t reserved5; - } unwinder_cache; - /* propagation barrier cache (valid after phase 1) */ - struct { - uint32_t sp; - uint32_t bitpattern[5]; - } barrier_cache; - /* cleanup cache (preserved over cleanup) */ - struct { - uint32_t bitpattern[4]; - } cleanup_cache; - /* personality cache (for personality's benefit) */ - struct { - uint32_t fnstart; /* function start address */ - _Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */ - uint32_t additional; /* additional data */ - uint32_t reserved1; - } pr_cache; - long long int : 0; /* force alignment of next item to 8-byte boundary */ -}; -#else + struct _Unwind_Exception *); + struct _Unwind_Exception { _Unwind_Exception_Class exception_class; _Unwind_Exception_Cleanup_Fn exception_cleanup; @@ -160,24 +120,23 @@ struct _Unwind_Exception { * aligned". GCC has interpreted this to mean "use the maximum useful * alignment for the target"; so do we. */ } __attribute__((__aligned__)); -#endif typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)(int, _Unwind_Action, _Unwind_Exception_Class, - _Unwind_Exception *, + struct _Unwind_Exception *, struct _Unwind_Context *, void *); -typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(int, _Unwind_Action, - _Unwind_Exception_Class, - _Unwind_Exception *, - struct _Unwind_Context *); +typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)( + int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *, + struct _Unwind_Context *); typedef _Unwind_Personality_Fn __personality_routine; typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context *, void *); -#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || defined(__ARM_DWARF_EH___)) +#if defined(__arm__) && !defined(__APPLE__) + typedef enum { _UVRSC_CORE = 0, /* integer register */ _UVRSC_VFP = 1, /* vfp */ @@ -199,12 +158,14 @@ typedef enum { _UVRSR_FAILED = 2 } _Unwind_VRS_Result; +#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__ARM_DWARF_EH__) typedef uint32_t _Unwind_State; #define _US_VIRTUAL_UNWIND_FRAME ((_Unwind_State)0) #define _US_UNWIND_FRAME_STARTING ((_Unwind_State)1) #define _US_UNWIND_FRAME_RESUME ((_Unwind_State)2) #define _US_ACTION_MASK ((_Unwind_State)3) #define _US_FORCE_UNWIND ((_Unwind_State)8) +#endif _Unwind_VRS_Result _Unwind_VRS_Get(struct _Unwind_Context *__context, _Unwind_VRS_RegClass __regclass, @@ -263,12 +224,13 @@ _Unwind_Ptr _Unwind_GetRegionStart(struct _Unwind_Context *); /* DWARF EH functions; currently not available on Darwin/ARM */ #if !defined(__APPLE__) || !defined(__arm__) -_Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Exception *); -_Unwind_Reason_Code _Unwind_ForcedUnwind(_Unwind_Exception *, _Unwind_Stop_Fn, - void *); -void _Unwind_DeleteException(_Unwind_Exception *); -void _Unwind_Resume(_Unwind_Exception *); -_Unwind_Reason_Code _Unwind_Resume_or_Rethrow(_Unwind_Exception *); + +_Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *); +_Unwind_Reason_Code _Unwind_ForcedUnwind(struct _Unwind_Exception *, + _Unwind_Stop_Fn, void *); +void _Unwind_DeleteException(struct _Unwind_Exception *); +void _Unwind_Resume(struct _Unwind_Exception *); +_Unwind_Reason_Code _Unwind_Resume_or_Rethrow(struct _Unwind_Exception *); #endif @@ -279,11 +241,11 @@ typedef struct SjLj_Function_Context *_Unwind_FunctionContext_t; void _Unwind_SjLj_Register(_Unwind_FunctionContext_t); void _Unwind_SjLj_Unregister(_Unwind_FunctionContext_t); -_Unwind_Reason_Code _Unwind_SjLj_RaiseException(_Unwind_Exception *); -_Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind(_Unwind_Exception *, +_Unwind_Reason_Code _Unwind_SjLj_RaiseException(struct _Unwind_Exception *); +_Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind(struct _Unwind_Exception *, _Unwind_Stop_Fn, void *); -void _Unwind_SjLj_Resume(_Unwind_Exception *); -_Unwind_Reason_Code _Unwind_SjLj_Resume_or_Rethrow(_Unwind_Exception *); +void _Unwind_SjLj_Resume(struct _Unwind_Exception *); +_Unwind_Reason_Code _Unwind_SjLj_Resume_or_Rethrow(struct _Unwind_Exception *); void *_Unwind_FindEnclosingFunction(void *); diff --git contrib/llvm/tools/clang/lib/Lex/PPLexerChange.cpp contrib/llvm/tools/clang/lib/Lex/PPLexerChange.cpp index 5a589d6a17b3..36d7028da688 100644 --- contrib/llvm/tools/clang/lib/Lex/PPLexerChange.cpp +++ contrib/llvm/tools/clang/lib/Lex/PPLexerChange.cpp @@ -458,10 +458,16 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) { SourceMgr.setNumCreatedFIDsForFileID(CurPPLexer->getFileID(), NumFIDs); } + bool ExitedFromPredefinesFile = false; FileID ExitedFID; - if (Callbacks && !isEndOfMacro && CurPPLexer) + if (!isEndOfMacro && CurPPLexer) { ExitedFID = CurPPLexer->getFileID(); + assert(PredefinesFileID.isValid() && + "HandleEndOfFile is called before PredefinesFileId is set"); + ExitedFromPredefinesFile = (PredefinesFileID == ExitedFID); + } + if (LeavingSubmodule) { // We're done with this submodule. Module *M = LeaveSubmodule(/*ForPragma*/false); @@ -489,6 +495,11 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) { PPCallbacks::ExitFile, FileType, ExitedFID); } + // Restore conditional stack from the preamble right after exiting from the + // predefines file. + if (ExitedFromPredefinesFile) + replayPreambleConditionalStack(); + // Client should lex another token unless we generated an EOM. return LeavingSubmodule; } diff --git contrib/llvm/tools/clang/lib/Lex/Preprocessor.cpp contrib/llvm/tools/clang/lib/Lex/Preprocessor.cpp index d1dc8e1c0010..7979be773aa1 100644 --- contrib/llvm/tools/clang/lib/Lex/Preprocessor.cpp +++ contrib/llvm/tools/clang/lib/Lex/Preprocessor.cpp @@ -540,6 +540,8 @@ void Preprocessor::EnterMainSourceFile() { void Preprocessor::replayPreambleConditionalStack() { // Restore the conditional stack from the preamble, if there is one. if (PreambleConditionalStack.isReplaying()) { + assert(CurPPLexer && + "CurPPLexer is null when calling replayPreambleConditionalStack."); CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack()); PreambleConditionalStack.doneReplaying(); } diff --git contrib/llvm/tools/clang/lib/Parse/Parser.cpp contrib/llvm/tools/clang/lib/Parse/Parser.cpp index 4aa9a5971929..1ed7ef966358 100644 --- contrib/llvm/tools/clang/lib/Parse/Parser.cpp +++ contrib/llvm/tools/clang/lib/Parse/Parser.cpp @@ -516,8 +516,6 @@ void Parser::Initialize() { // Prime the lexer look-ahead. ConsumeToken(); - - PP.replayPreambleConditionalStack(); } void Parser::LateTemplateParserCleanupCallback(void *P) { diff --git contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp index e9070881afe4..c05e5f020708 100644 --- contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp +++ contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp @@ -5726,6 +5726,53 @@ static void DefineImplicitSpecialMember(Sema &S, CXXMethodDecl *MD, } } +/// Determine whether a type is permitted to be passed or returned in +/// registers, per C++ [class.temporary]p3. +static bool computeCanPassInRegisters(Sema &S, CXXRecordDecl *D) { + if (D->isDependentType() || D->isInvalidDecl()) + return false; + + // Per C++ [class.temporary]p3, the relevant condition is: + // each copy constructor, move constructor, and destructor of X is + // either trivial or deleted, and X has at least one non-deleted copy + // or move constructor + bool HasNonDeletedCopyOrMove = false; + + if (D->needsImplicitCopyConstructor() && + !D->defaultedCopyConstructorIsDeleted()) { + if (!D->hasTrivialCopyConstructor()) + return false; + HasNonDeletedCopyOrMove = true; + } + + if (S.getLangOpts().CPlusPlus11 && D->needsImplicitMoveConstructor() && + !D->defaultedMoveConstructorIsDeleted()) { + if (!D->hasTrivialMoveConstructor()) + return false; + HasNonDeletedCopyOrMove = true; + } + + if (D->needsImplicitDestructor() && !D->defaultedDestructorIsDeleted() && + !D->hasTrivialDestructor()) + return false; + + for (const CXXMethodDecl *MD : D->methods()) { + if (MD->isDeleted()) + continue; + + auto *CD = dyn_cast<CXXConstructorDecl>(MD); + if (CD && CD->isCopyOrMoveConstructor()) + HasNonDeletedCopyOrMove = true; + else if (!isa<CXXDestructorDecl>(MD)) + continue; + + if (!MD->isTrivial()) + return false; + } + + return HasNonDeletedCopyOrMove; +} + /// \brief Perform semantic checks on a class definition that has been /// completing, introducing implicitly-declared members, checking for /// abstract types, etc. @@ -5870,6 +5917,8 @@ void Sema::CheckCompletedCXXClass(CXXRecordDecl *Record) { } checkClassLevelDLLAttribute(Record); + + Record->setCanPassInRegisters(computeCanPassInRegisters(*this, Record)); } /// Look up the special member function that would be called by a special @@ -7496,8 +7545,7 @@ void Sema::ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc, reinterpret_cast<Decl**>(FieldCollector->getCurFields()), FieldCollector->getCurNumFields()), LBrac, RBrac, AttrList); - CheckCompletedCXXClass( - dyn_cast_or_null<CXXRecordDecl>(TagDecl)); + CheckCompletedCXXClass(dyn_cast_or_null<CXXRecordDecl>(TagDecl)); } /// AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared @@ -11929,8 +11977,10 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor( Scope *S = getScopeForContext(ClassDecl); CheckImplicitSpecialMemberDeclaration(S, CopyConstructor); - if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) + if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) { + ClassDecl->setImplicitCopyConstructorIsDeleted(); SetDeclDeleted(CopyConstructor, ClassLoc); + } if (S) PushOnScopeChains(CopyConstructor, S, false); diff --git contrib/llvm/tools/clang/lib/Sema/SemaObjCProperty.cpp contrib/llvm/tools/clang/lib/Sema/SemaObjCProperty.cpp index e1e85dfd5e55..bfb0071a54f9 100644 --- contrib/llvm/tools/clang/lib/Sema/SemaObjCProperty.cpp +++ contrib/llvm/tools/clang/lib/Sema/SemaObjCProperty.cpp @@ -872,7 +872,7 @@ SelectPropertyForSynthesisFromProtocols(Sema &S, SourceLocation AtLoc, } QualType RHSType = S.Context.getCanonicalType(Property->getType()); - unsigned OriginalAttributes = Property->getPropertyAttributes(); + unsigned OriginalAttributes = Property->getPropertyAttributesAsWritten(); enum MismatchKind { IncompatibleType = 0, HasNoExpectedAttribute, @@ -890,7 +890,7 @@ SelectPropertyForSynthesisFromProtocols(Sema &S, SourceLocation AtLoc, SmallVector<MismatchingProperty, 4> Mismatches; for (ObjCPropertyDecl *Prop : Properties) { // Verify the property attributes. - unsigned Attr = Prop->getPropertyAttributes(); + unsigned Attr = Prop->getPropertyAttributesAsWritten(); if (Attr != OriginalAttributes) { auto Diag = [&](bool OriginalHasAttribute, StringRef AttributeName) { MismatchKind Kind = OriginalHasAttribute ? HasNoExpectedAttribute diff --git contrib/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp contrib/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp index abed2586561a..085341571ced 100644 --- contrib/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp +++ contrib/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp @@ -1559,9 +1559,11 @@ void ASTDeclReader::ReadCXXDefinitionData( Data.HasUninitializedFields = Record.readInt(); Data.HasInheritedConstructor = Record.readInt(); Data.HasInheritedAssignment = Record.readInt(); + Data.NeedOverloadResolutionForCopyConstructor = Record.readInt(); Data.NeedOverloadResolutionForMoveConstructor = Record.readInt(); Data.NeedOverloadResolutionForMoveAssignment = Record.readInt(); Data.NeedOverloadResolutionForDestructor = Record.readInt(); + Data.DefaultedCopyConstructorIsDeleted = Record.readInt(); Data.DefaultedMoveConstructorIsDeleted = Record.readInt(); Data.DefaultedMoveAssignmentIsDeleted = Record.readInt(); Data.DefaultedDestructorIsDeleted = Record.readInt(); @@ -1570,6 +1572,7 @@ void ASTDeclReader::ReadCXXDefinitionData( Data.HasIrrelevantDestructor = Record.readInt(); Data.HasConstexprNonCopyMoveConstructor = Record.readInt(); Data.HasDefaultedDefaultConstructor = Record.readInt(); + Data.CanPassInRegisters = Record.readInt(); Data.DefaultedDefaultConstructorIsConstexpr = Record.readInt(); Data.HasConstexprDefaultConstructor = Record.readInt(); Data.HasNonLiteralTypeFieldsOrBases = Record.readInt(); @@ -1697,9 +1700,11 @@ void ASTDeclReader::MergeDefinitionData( MATCH_FIELD(HasUninitializedFields) MATCH_FIELD(HasInheritedConstructor) MATCH_FIELD(HasInheritedAssignment) + MATCH_FIELD(NeedOverloadResolutionForCopyConstructor) MATCH_FIELD(NeedOverloadResolutionForMoveConstructor) MATCH_FIELD(NeedOverloadResolutionForMoveAssignment) MATCH_FIELD(NeedOverloadResolutionForDestructor) + MATCH_FIELD(DefaultedCopyConstructorIsDeleted) MATCH_FIELD(DefaultedMoveConstructorIsDeleted) MATCH_FIELD(DefaultedMoveAssignmentIsDeleted) MATCH_FIELD(DefaultedDestructorIsDeleted) @@ -1708,6 +1713,7 @@ void ASTDeclReader::MergeDefinitionData( MATCH_FIELD(HasIrrelevantDestructor) OR_FIELD(HasConstexprNonCopyMoveConstructor) OR_FIELD(HasDefaultedDefaultConstructor) + MATCH_FIELD(CanPassInRegisters) MATCH_FIELD(DefaultedDefaultConstructorIsConstexpr) OR_FIELD(HasConstexprDefaultConstructor) MATCH_FIELD(HasNonLiteralTypeFieldsOrBases) diff --git contrib/llvm/tools/clang/lib/Serialization/ASTWriter.cpp contrib/llvm/tools/clang/lib/Serialization/ASTWriter.cpp index a875e627bdfb..128e53b91b1d 100644 --- contrib/llvm/tools/clang/lib/Serialization/ASTWriter.cpp +++ contrib/llvm/tools/clang/lib/Serialization/ASTWriter.cpp @@ -5874,9 +5874,11 @@ void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) { Record->push_back(Data.HasUninitializedFields); Record->push_back(Data.HasInheritedConstructor); Record->push_back(Data.HasInheritedAssignment); + Record->push_back(Data.NeedOverloadResolutionForCopyConstructor); Record->push_back(Data.NeedOverloadResolutionForMoveConstructor); Record->push_back(Data.NeedOverloadResolutionForMoveAssignment); Record->push_back(Data.NeedOverloadResolutionForDestructor); + Record->push_back(Data.DefaultedCopyConstructorIsDeleted); Record->push_back(Data.DefaultedMoveConstructorIsDeleted); Record->push_back(Data.DefaultedMoveAssignmentIsDeleted); Record->push_back(Data.DefaultedDestructorIsDeleted); @@ -5885,6 +5887,7 @@ void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) { Record->push_back(Data.HasIrrelevantDestructor); Record->push_back(Data.HasConstexprNonCopyMoveConstructor); Record->push_back(Data.HasDefaultedDefaultConstructor); + Record->push_back(Data.CanPassInRegisters); Record->push_back(Data.DefaultedDefaultConstructorIsConstexpr); Record->push_back(Data.HasConstexprDefaultConstructor); Record->push_back(Data.HasNonLiteralTypeFieldsOrBases); diff --git contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp index 28f78fa3ff5e..11902f66df91 100644 --- contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -409,6 +409,19 @@ public: // Part of public interface to class. // BindDefault is only used to initialize a region with a default value. StoreRef BindDefault(Store store, const MemRegion *R, SVal V) override { + // FIXME: The offsets of empty bases can be tricky because of + // of the so called "empty base class optimization". + // If a base class has been optimized out + // we should not try to create a binding, otherwise we should. + // Unfortunately, at the moment ASTRecordLayout doesn't expose + // the actual sizes of the empty bases + // and trying to infer them from offsets/alignments + // seems to be error-prone and non-trivial because of the trailing padding. + // As a temporary mitigation we don't create bindings for empty bases. + if (R->getKind() == MemRegion::CXXBaseObjectRegionKind && + cast<CXXBaseObjectRegion>(R)->getDecl()->isEmpty()) + return StoreRef(store, *this); + RegionBindingsRef B = getRegionBindings(store); assert(!B.lookup(R, BindingKey::Direct)); diff --git contrib/llvm/tools/lldb/source/Host/common/TCPSocket.cpp contrib/llvm/tools/lldb/source/Host/common/TCPSocket.cpp index a7af93f10a7f..f896944bb1b3 100644 --- contrib/llvm/tools/lldb/source/Host/common/TCPSocket.cpp +++ contrib/llvm/tools/lldb/source/Host/common/TCPSocket.cpp @@ -198,9 +198,14 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) { ::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p, sizeof(option_value)); - address.SetPort(port); - - int err = ::bind(fd, &address.sockaddr(), address.GetLength()); + SocketAddress listen_address = address; + if(!listen_address.IsLocalhost()) + listen_address.SetToAnyAddress(address.GetFamily(), port); + else + listen_address.SetPort(port); + + int err = + ::bind(fd, &listen_address.sockaddr(), listen_address.GetLength()); if (-1 != err) err = ::listen(fd, backlog); diff --git contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp index 6563796db12c..2cb17cb182e2 100644 --- contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp +++ contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp @@ -36,8 +36,7 @@ struct GPR { struct FPR_i386 { uint16_t fctrl; // FPU Control Word (fcw) uint16_t fstat; // FPU Status Word (fsw) - uint8_t ftag; // FPU Tag Word (ftw) - uint8_t reserved_1; // Reserved + uint16_t ftag; // FPU Tag Word (ftw) uint16_t fop; // Last Instruction Opcode (fop) union { struct { diff --git contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h index ab2ca2bb6c2c..5f6fc295a15c 100644 --- contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h +++ contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h @@ -257,8 +257,7 @@ struct XMMReg { struct FXSAVE { uint16_t fctrl; // FPU Control Word (fcw) uint16_t fstat; // FPU Status Word (fsw) - uint8_t ftag; // FPU Tag Word (ftw) - uint8_t reserved_1; // Reserved + uint16_t ftag; // FPU Tag Word (ftw) uint16_t fop; // Last Instruction Opcode (fop) union { struct { diff --git contrib/mdocml/Makefile contrib/mdocml/Makefile index 9507d9918a43..9855c9f8f1e8 100644 --- contrib/mdocml/Makefile +++ contrib/mdocml/Makefile @@ -15,7 +15,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -VERSION = 1.14.2 +VERSION = 1.14.3 # === LIST OF FILES ==================================================== diff --git contrib/mdocml/NEWS contrib/mdocml/NEWS index d62ac4b73dc4..3d35e2b7bdc5 100644 --- contrib/mdocml/NEWS +++ contrib/mdocml/NEWS @@ -2,6 +2,21 @@ $Id: NEWS,v 1.26 2017/07/28 14:57:56 schwarze Exp $ This file lists the most important changes in the mandoc.bsd.lv distribution. +Changes in version 1.14.3, released on August 5, 2017 + + --- BUG FIXES --- + * man(7): Do not crash with out-of-bounds read access to a constant + array if .sp or a blank line immediately precedes .SS or .SH. + * mdoc(7): Do not crash with out-of-bounds read access to a constant + array if .sp or a blank line precede the first .Sh macro. + * tbl(7): Ignore explicitly specified negative column widths rather than + wrapping around to huge numbers and risking memory exhaustion. + * man(1): No longer use names that only occur in the SYNOPSIS section. + Gets rid of some surprising behaviour and bogus warnings. + --- THANKS TO --- + Leah Neukirchen (Void Linux), Markus Waldeck (Debian), + Peter Bui (nd.edu), and Yuri Pankov (illumos) for bug reports. + Changes in version 1.14.2, released on July 28, 2017 --- MAJOR NEW FEATURES --- diff --git contrib/mdocml/man_term.c contrib/mdocml/man_term.c index fcdb45df8ddb..8946a05067a7 100644 --- contrib/mdocml/man_term.c +++ contrib/mdocml/man_term.c @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.208 2017/06/25 11:42:02 schwarze Exp $ */ +/* $Id: man_term.c,v 1.209 2017/07/31 15:19:06 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -673,7 +673,7 @@ pre_SS(DECL_ARGS) do { n = n->prev; - } while (n != NULL && n->tok != TOKEN_NONE && + } while (n != NULL && n->tok >= MAN_TH && termacts[n->tok].flags & MAN_NOTEXT); if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL)) break; @@ -735,7 +735,7 @@ pre_SH(DECL_ARGS) do { n = n->prev; - } while (n != NULL && n->tok != TOKEN_NONE && + } while (n != NULL && n->tok >= MAN_TH && termacts[n->tok].flags & MAN_NOTEXT); if (n == NULL || (n->tok == MAN_SH && n->body->child == NULL)) break; diff --git contrib/mdocml/mansearch.c contrib/mdocml/mansearch.c index c889aecf52f2..0d60c3bed731 100644 --- contrib/mdocml/mansearch.c +++ contrib/mdocml/mansearch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mansearch.c,v 1.50 2016/07/09 15:23:36 schwarze Exp $ */ +/* $Id: mansearch.c,v 1.76 2017/08/02 13:29:04 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -171,7 +171,9 @@ mansearch(const struct mansearch *search, page = dbm_page_get(rp->page); if (lstmatch(search->sec, page->sect) == 0 || - lstmatch(search->arch, page->arch) == 0) + lstmatch(search->arch, page->arch) == 0 || + (search->argmode == ARG_NAME && + rp->bits <= (int32_t)(NAME_SYN & NAME_MASK))) continue; if (res == NULL) { @@ -452,14 +454,28 @@ lstlen(const char *cp, size_t sep) { size_t sz; - for (sz = 0;; sz++) { - if (cp[0] == '\0') { - if (cp[1] == '\0') - break; - sz += sep - 1; - } else if (cp[0] < ' ') - sz--; - cp++; + for (sz = 0; *cp != '\0'; cp++) { + + /* Skip names appearing only in the SYNOPSIS. */ + if (*cp <= (char)(NAME_SYN & NAME_MASK)) { + while (*cp != '\0') + cp++; + continue; + } + + /* Skip name class markers. */ + if (*cp < ' ') + cp++; + + /* Print a separator before each but the first string. */ + if (sz) + sz += sep; + + /* Copy one string. */ + while (*cp != '\0') { + sz++; + cp++; + } } return sz; } @@ -471,19 +487,34 @@ lstlen(const char *cp, size_t sep) static void lstcat(char *buf, size_t *i, const char *cp, const char *sep) { - const char *s; + const char *s; + size_t i_start; - for (;;) { - if (cp[0] == '\0') { - if (cp[1] == '\0') - break; + for (i_start = *i; *cp != '\0'; cp++) { + + /* Skip names appearing only in the SYNOPSIS. */ + if (*cp <= (char)(NAME_SYN & NAME_MASK)) { + while (*cp != '\0') + cp++; + continue; + } + + /* Skip name class markers. */ + if (*cp < ' ') + cp++; + + /* Print a separator before each but the first string. */ + if (*i > i_start) { s = sep; while (*s != '\0') buf[(*i)++] = *s++; - } else if (cp[0] >= ' ') - buf[(*i)++] = cp[0]; - cp++; + } + + /* Copy one string. */ + while (*cp != '\0') + buf[(*i)++] = *cp++; } + } /* diff --git contrib/mdocml/mdoc_validate.c contrib/mdocml/mdoc_validate.c index de36bb843eb2..3a9b86f3fd2b 100644 --- contrib/mdocml/mdoc_validate.c +++ contrib/mdocml/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.350 2017/07/20 12:54:02 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.352 2017/08/02 13:29:04 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -1137,8 +1137,6 @@ post_fname(POST_ARGS) if ( ! (cp[0] == '\0' || (cp[0] == '(' && cp[1] == '*'))) mandoc_msg(MANDOCERR_FN_PAREN, mdoc->parse, n->line, n->pos + pos, n->string); - if (n->sec == SEC_SYNOPSIS && mdoc->meta.msec != NULL) - mandoc_xr_add(mdoc->meta.msec, n->string, -1, -1); } static void @@ -1205,9 +1203,8 @@ post_nm(POST_ARGS) n = mdoc->last; - if ((n->sec == SEC_NAME || n->sec == SEC_SYNOPSIS) && - n->child != NULL && n->child->type == ROFFT_TEXT && - mdoc->meta.msec != NULL) + if (n->sec == SEC_NAME && n->child != NULL && + n->child->type == ROFFT_TEXT && mdoc->meta.msec != NULL) mandoc_xr_add(mdoc->meta.msec, n->child->string, -1, -1); if (n->last != NULL && @@ -1931,7 +1928,7 @@ post_root(POST_ARGS) /* Check that we begin with a proper `Sh'. */ n = mdoc->first->child; - while (n != NULL && n->tok != TOKEN_NONE && + while (n != NULL && n->tok >= MDOC_Dd && mdoc_macros[n->tok].flags & MDOC_PROLOGUE) n = n->next; diff --git contrib/mdocml/tbl_html.c contrib/mdocml/tbl_html.c index 06fae5eba1a7..d59f1635d013 100644 --- contrib/mdocml/tbl_html.c +++ contrib/mdocml/tbl_html.c @@ -1,4 +1,4 @@ -/* $Id: tbl_html.c,v 1.22 2017/06/12 20:14:18 schwarze Exp $ */ +/* $Id: tbl_html.c,v 1.23 2017/07/31 16:14:10 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -49,6 +49,9 @@ html_tbl_strlen(const char *p, void *arg) static size_t html_tbl_sulen(const struct roffsu *su, void *arg) { + if (su->scale < 0.0) + return 0; + switch (su->unit) { case SCALE_FS: /* 2^16 basic units */ return su->scale * 65536.0 / 24.0; diff --git contrib/mdocml/tbl_term.c contrib/mdocml/tbl_term.c index fd03b81303f9..c154a0e9b967 100644 --- contrib/mdocml/tbl_term.c +++ contrib/mdocml/tbl_term.c @@ -1,4 +1,4 @@ -/* $Id: tbl_term.c,v 1.56 2017/07/08 13:43:15 schwarze Exp $ */ +/* $Id: tbl_term.c,v 1.57 2017/07/31 16:14:10 schwarze Exp $ */ /* * Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011,2012,2014,2015,2017 Ingo Schwarze <schwarze@openbsd.org> @@ -51,7 +51,10 @@ static void tbl_word(struct termp *, const struct tbl_dat *); static size_t term_tbl_sulen(const struct roffsu *su, void *arg) { - return term_hen((const struct termp *)arg, su); + int i; + + i = term_hen((const struct termp *)arg, su); + return i > 0 ? i : 0; } static size_t diff --git contrib/netbsd-tests/usr.bin/grep/t_grep.sh contrib/netbsd-tests/usr.bin/grep/t_grep.sh index 7acf1d58abd0..596b70f4d48a 100755 --- contrib/netbsd-tests/usr.bin/grep/t_grep.sh +++ contrib/netbsd-tests/usr.bin/grep/t_grep.sh @@ -687,6 +687,59 @@ matchall_body() atf_check -s exit:1 grep "" test1 } + +atf_test_case fgrep_multipattern +fgrep_multipattern_head() +{ + atf_set "descr" "Check proper behavior with multiple patterns supplied to fgrep" +} +fgrep_multipattern_body() +{ + printf "Foo\nBar\nBaz" > test1 + + atf_check -o inline:"Foo\nBaz\n" grep -F -e "Foo" -e "Baz" test1 + atf_check -o inline:"Foo\nBaz\n" grep -F -e "Baz" -e "Foo" test1 + atf_check -o inline:"Bar\nBaz\n" grep -F -e "Bar" -e "Baz" test1 +} + +atf_test_case fgrep_icase +fgrep_icase_head() +{ + atf_set "descr" "Check proper handling of -i supplied to fgrep" +} +fgrep_icase_body() +{ + printf "Foo\nBar\nBaz" > test1 + + atf_check -o inline:"Foo\nBaz\n" grep -Fi -e "foo" -e "baz" test1 + atf_check -o inline:"Foo\nBaz\n" grep -Fi -e "baz" -e "foo" test1 + atf_check -o inline:"Bar\nBaz\n" grep -Fi -e "bar" -e "baz" test1 + atf_check -o inline:"Bar\nBaz\n" grep -Fi -e "BAR" -e "bAz" test1 +} + +atf_test_case fgrep_oflag +fgrep_oflag_head() +{ + atf_set "descr" "Check proper handling of -o supplied to fgrep" +} +fgrep_oflag_body() +{ + printf "abcdefghi\n" > test1 + + atf_check -o inline:"a\n" grep -Fo "a" test1 + atf_check -o inline:"i\n" grep -Fo "i" test1 + atf_check -o inline:"abc\n" grep -Fo "abc" test1 + atf_check -o inline:"fgh\n" grep -Fo "fgh" test1 + atf_check -o inline:"cde\n" grep -Fo "cde" test1 + atf_check -o inline:"bcd\n" grep -Fo -e "bcd" -e "cde" test1 + atf_check -o inline:"bcd\nefg\n" grep -Fo -e "bcd" -e "efg" test1 + + atf_check -s exit:1 grep -Fo "xabc" test1 + atf_check -s exit:1 grep -Fo "abcx" test1 + atf_check -s exit:1 grep -Fo "xghi" test1 + atf_check -s exit:1 grep -Fo "ghix" test1 + atf_check -s exit:1 grep -Fo "abcdefghiklmnopqrstuvwxyz" test1 +} # End FreeBSD atf_init_test_cases() @@ -728,5 +781,8 @@ atf_init_test_cases() atf_add_test_case mmap atf_add_test_case mmap_eof_not_eol atf_add_test_case matchall + atf_add_test_case fgrep_multipattern + atf_add_test_case fgrep_icase + atf_add_test_case fgrep_oflag # End FreeBSD } diff --git contrib/ofed/usr.bin/ibaddr/Makefile.depend contrib/ofed/usr.bin/ibaddr/Makefile.depend index 97ff2c9f294d..c80b536c0c6b 100644 --- contrib/ofed/usr.bin/ibaddr/Makefile.depend +++ contrib/ofed/usr.bin/ibaddr/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibmad \ contrib/ofed/usr.lib/libibumad \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git contrib/ofed/usr.bin/ibnetdiscover/Makefile.depend contrib/ofed/usr.bin/ibnetdiscover/Makefile.depend index a4dafaf55e18..702b2df60733 100644 --- contrib/ofed/usr.bin/ibnetdiscover/Makefile.depend +++ contrib/ofed/usr.bin/ibnetdiscover/Makefile.depend @@ -7,7 +7,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibumad \ contrib/ofed/usr.lib/libosmcomp \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.bin/ibping/Makefile.depend contrib/ofed/usr.bin/ibping/Makefile.depend index b1cc1b024622..8d2f609a6059 100644 --- contrib/ofed/usr.bin/ibping/Makefile.depend +++ contrib/ofed/usr.bin/ibping/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibmad \ contrib/ofed/usr.lib/libibumad \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.bin/ibportstate/Makefile.depend contrib/ofed/usr.bin/ibportstate/Makefile.depend index b1cc1b024622..8d2f609a6059 100644 --- contrib/ofed/usr.bin/ibportstate/Makefile.depend +++ contrib/ofed/usr.bin/ibportstate/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibmad \ contrib/ofed/usr.lib/libibumad \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.bin/ibroute/Makefile.depend contrib/ofed/usr.bin/ibroute/Makefile.depend index a4dafaf55e18..702b2df60733 100644 --- contrib/ofed/usr.bin/ibroute/Makefile.depend +++ contrib/ofed/usr.bin/ibroute/Makefile.depend @@ -7,7 +7,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibumad \ contrib/ofed/usr.lib/libosmcomp \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.bin/ibsendtrap/Makefile.depend contrib/ofed/usr.bin/ibsendtrap/Makefile.depend index b1cc1b024622..8d2f609a6059 100644 --- contrib/ofed/usr.bin/ibsendtrap/Makefile.depend +++ contrib/ofed/usr.bin/ibsendtrap/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibmad \ contrib/ofed/usr.lib/libibumad \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.bin/ibstat/Makefile.depend contrib/ofed/usr.bin/ibstat/Makefile.depend index dfd90529cb4e..6e0e02c5d5f7 100644 --- contrib/ofed/usr.bin/ibstat/Makefile.depend +++ contrib/ofed/usr.bin/ibstat/Makefile.depend @@ -5,7 +5,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibcommon \ contrib/ofed/usr.lib/libibumad \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.bin/ibsysstat/Makefile.depend contrib/ofed/usr.bin/ibsysstat/Makefile.depend index b1cc1b024622..8d2f609a6059 100644 --- contrib/ofed/usr.bin/ibsysstat/Makefile.depend +++ contrib/ofed/usr.bin/ibsysstat/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibmad \ contrib/ofed/usr.lib/libibumad \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.bin/ibtracert/Makefile.depend contrib/ofed/usr.bin/ibtracert/Makefile.depend index a4dafaf55e18..702b2df60733 100644 --- contrib/ofed/usr.bin/ibtracert/Makefile.depend +++ contrib/ofed/usr.bin/ibtracert/Makefile.depend @@ -7,7 +7,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibumad \ contrib/ofed/usr.lib/libosmcomp \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.bin/opensm/Makefile.depend contrib/ofed/usr.bin/opensm/Makefile.depend index 797b43be1f1d..af9d29cf737a 100644 --- contrib/ofed/usr.bin/opensm/Makefile.depend +++ contrib/ofed/usr.bin/opensm/Makefile.depend @@ -8,7 +8,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libosmcomp \ contrib/ofed/usr.lib/libosmvendor \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git contrib/ofed/usr.bin/osmtest/Makefile.depend contrib/ofed/usr.bin/osmtest/Makefile.depend index 1f2ff139a26c..650f6502805c 100644 --- contrib/ofed/usr.bin/osmtest/Makefile.depend +++ contrib/ofed/usr.bin/osmtest/Makefile.depend @@ -9,7 +9,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libosmcomp \ contrib/ofed/usr.lib/libosmvendor \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git contrib/ofed/usr.bin/perfquery/Makefile.depend contrib/ofed/usr.bin/perfquery/Makefile.depend index b1cc1b024622..8d2f609a6059 100644 --- contrib/ofed/usr.bin/perfquery/Makefile.depend +++ contrib/ofed/usr.bin/perfquery/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibmad \ contrib/ofed/usr.lib/libibumad \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.bin/saquery/Makefile.depend contrib/ofed/usr.bin/saquery/Makefile.depend index 1f2ff139a26c..650f6502805c 100644 --- contrib/ofed/usr.bin/saquery/Makefile.depend +++ contrib/ofed/usr.bin/saquery/Makefile.depend @@ -9,7 +9,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libosmcomp \ contrib/ofed/usr.lib/libosmvendor \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git contrib/ofed/usr.bin/sminfo/Makefile.depend contrib/ofed/usr.bin/sminfo/Makefile.depend index b1cc1b024622..8d2f609a6059 100644 --- contrib/ofed/usr.bin/sminfo/Makefile.depend +++ contrib/ofed/usr.bin/sminfo/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibmad \ contrib/ofed/usr.lib/libibumad \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.bin/smpdump/Makefile.depend contrib/ofed/usr.bin/smpdump/Makefile.depend index b1cc1b024622..8d2f609a6059 100644 --- contrib/ofed/usr.bin/smpdump/Makefile.depend +++ contrib/ofed/usr.bin/smpdump/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibmad \ contrib/ofed/usr.lib/libibumad \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.bin/smpquery/Makefile.depend contrib/ofed/usr.bin/smpquery/Makefile.depend index a4dafaf55e18..702b2df60733 100644 --- contrib/ofed/usr.bin/smpquery/Makefile.depend +++ contrib/ofed/usr.bin/smpquery/Makefile.depend @@ -7,7 +7,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibumad \ contrib/ofed/usr.lib/libosmcomp \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.bin/vendstat/Makefile.depend contrib/ofed/usr.bin/vendstat/Makefile.depend index b1cc1b024622..8d2f609a6059 100644 --- contrib/ofed/usr.bin/vendstat/Makefile.depend +++ contrib/ofed/usr.bin/vendstat/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibmad \ contrib/ofed/usr.lib/libibumad \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.lib/libcxgb4/Makefile.depend contrib/ofed/usr.lib/libcxgb4/Makefile.depend index 7bb3c2d58eb9..04329077d03b 100644 --- contrib/ofed/usr.lib/libcxgb4/Makefile.depend +++ contrib/ofed/usr.lib/libcxgb4/Makefile.depend @@ -4,7 +4,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibverbs \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git contrib/ofed/usr.lib/libibcm/Makefile.depend contrib/ofed/usr.lib/libibcm/Makefile.depend index e8013ca72b20..c733ec63ade4 100644 --- contrib/ofed/usr.lib/libibcm/Makefile.depend +++ contrib/ofed/usr.lib/libibcm/Makefile.depend @@ -4,7 +4,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibverbs \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.lib/libibcommon/Makefile.depend contrib/ofed/usr.lib/libibcommon/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- contrib/ofed/usr.lib/libibcommon/Makefile.depend +++ contrib/ofed/usr.lib/libibcommon/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.lib/libibmad/Makefile.depend contrib/ofed/usr.lib/libibmad/Makefile.depend index a32fbc92151f..ac18714c2712 100644 --- contrib/ofed/usr.lib/libibmad/Makefile.depend +++ contrib/ofed/usr.lib/libibmad/Makefile.depend @@ -5,7 +5,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibcommon \ contrib/ofed/usr.lib/libibumad \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git contrib/ofed/usr.lib/libibumad/Makefile.depend contrib/ofed/usr.lib/libibumad/Makefile.depend index d8b158b60dab..ddc55dc9ecf5 100644 --- contrib/ofed/usr.lib/libibumad/Makefile.depend +++ contrib/ofed/usr.lib/libibumad/Makefile.depend @@ -4,7 +4,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibcommon \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.lib/libibverbs/Makefile.depend contrib/ofed/usr.lib/libibverbs/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- contrib/ofed/usr.lib/libibverbs/Makefile.depend +++ contrib/ofed/usr.lib/libibverbs/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.lib/libmlx4/Makefile.depend contrib/ofed/usr.lib/libmlx4/Makefile.depend index 9a8a2fe8cd66..da37c3296b3d 100644 --- contrib/ofed/usr.lib/libmlx4/Makefile.depend +++ contrib/ofed/usr.lib/libmlx4/Makefile.depend @@ -4,7 +4,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibverbs \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.lib/libmthca/Makefile.depend contrib/ofed/usr.lib/libmthca/Makefile.depend index 9a8a2fe8cd66..da37c3296b3d 100644 --- contrib/ofed/usr.lib/libmthca/Makefile.depend +++ contrib/ofed/usr.lib/libmthca/Makefile.depend @@ -4,7 +4,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibverbs \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.lib/libopensm/Makefile.depend contrib/ofed/usr.lib/libopensm/Makefile.depend index 233756861206..12bd88692fca 100644 --- contrib/ofed/usr.lib/libopensm/Makefile.depend +++ contrib/ofed/usr.lib/libopensm/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git contrib/ofed/usr.lib/libosmcomp/Makefile.depend contrib/ofed/usr.lib/libosmcomp/Makefile.depend index 8caf1871aa9c..0bfb4144fa82 100644 --- contrib/ofed/usr.lib/libosmcomp/Makefile.depend +++ contrib/ofed/usr.lib/libosmcomp/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.lib/libosmvendor/Makefile.depend contrib/ofed/usr.lib/libosmvendor/Makefile.depend index 20e0a6b5c645..e468aba5d23a 100644 --- contrib/ofed/usr.lib/libosmvendor/Makefile.depend +++ contrib/ofed/usr.lib/libosmvendor/Makefile.depend @@ -6,7 +6,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libopensm \ contrib/ofed/usr.lib/libosmcomp \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.lib/librdmacm/Makefile.depend contrib/ofed/usr.lib/librdmacm/Makefile.depend index e8013ca72b20..c733ec63ade4 100644 --- contrib/ofed/usr.lib/librdmacm/Makefile.depend +++ contrib/ofed/usr.lib/librdmacm/Makefile.depend @@ -4,7 +4,6 @@ DIRDEPS = \ contrib/ofed/usr.lib/libibverbs \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git contrib/ofed/usr.lib/libsdp/Makefile.depend contrib/ofed/usr.lib/libsdp/Makefile.depend index 54c1f6f1442e..d5ed563ecfc8 100644 --- contrib/ofed/usr.lib/libsdp/Makefile.depend +++ contrib/ofed/usr.lib/libsdp/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git contrib/one-true-awk/awk.h contrib/one-true-awk/awk.h index a36cdb151e75..5564af7619a4 100644 --- contrib/one-true-awk/awk.h +++ contrib/one-true-awk/awk.h @@ -126,6 +126,12 @@ extern Cell *rlengthloc; /* RLENGTH */ #define FTOUPPER 12 #define FTOLOWER 13 #define FFLUSH 14 +#define FAND 15 +#define FFOR 16 +#define FXOR 17 +#define FCOMPL 18 +#define FLSHIFT 19 +#define FRSHIFT 20 /* Node: parse tree is made of nodes, with Cell's at bottom */ diff --git contrib/one-true-awk/lex.c contrib/one-true-awk/lex.c index 0c65a9fe3292..3aeffb7f0539 100644 --- contrib/one-true-awk/lex.c +++ contrib/one-true-awk/lex.c @@ -47,9 +47,11 @@ Keyword keywords[] ={ /* keep sorted: binary searched */ { "BEGIN", XBEGIN, XBEGIN }, { "END", XEND, XEND }, { "NF", VARNF, VARNF }, + { "and", FAND, BLTIN }, { "atan2", FATAN, BLTIN }, { "break", BREAK, BREAK }, { "close", CLOSE, CLOSE }, + { "compl", FCOMPL, BLTIN }, { "continue", CONTINUE, CONTINUE }, { "cos", FCOS, BLTIN }, { "delete", DELETE, DELETE }, @@ -69,13 +71,16 @@ Keyword keywords[] ={ /* keep sorted: binary searched */ { "int", FINT, BLTIN }, { "length", FLENGTH, BLTIN }, { "log", FLOG, BLTIN }, + { "lshift", FLSHIFT, BLTIN }, { "match", MATCHFCN, MATCHFCN }, { "next", NEXT, NEXT }, { "nextfile", NEXTFILE, NEXTFILE }, + { "or", FFOR, BLTIN }, { "print", PRINT, PRINT }, { "printf", PRINTF, PRINTF }, { "rand", FRAND, BLTIN }, { "return", RETURN, RETURN }, + { "rshift", FRSHIFT, BLTIN }, { "sin", FSIN, BLTIN }, { "split", SPLIT, SPLIT }, { "sprintf", SPRINTF, SPRINTF }, @@ -87,6 +92,7 @@ Keyword keywords[] ={ /* keep sorted: binary searched */ { "tolower", FTOLOWER, BLTIN }, { "toupper", FTOUPPER, BLTIN }, { "while", WHILE, WHILE }, + { "xor", FXOR, BLTIN }, }; #define RET(x) { if(dbg)printf("lex %s\n", tokname(x)); return(x); } diff --git contrib/one-true-awk/lib.c contrib/one-true-awk/lib.c index 5eeb53d4679d..e2688a2debe4 100644 --- contrib/one-true-awk/lib.c +++ contrib/one-true-awk/lib.c @@ -62,6 +62,7 @@ void recinit(unsigned int n) || (fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *))) == NULL || (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL ) FATAL("out of space for $0 and fields"); + *record = '\0'; *fldtab[0] = dollar0; fldtab[0]->sval = record; fldtab[0]->nval = tostring("0"); @@ -616,7 +617,7 @@ void eprint(void) /* try to print context around error */ static int been_here = 0; extern char ebuf[], *ep; - if (compile_time == 2 || compile_time == 0 || been_here++ > 0) + if (compile_time == 2 || compile_time == 0 || been_here++ > 0 || ebuf == ep) return; p = ep - 1; if (p > ebuf && *p == '\n') diff --git contrib/one-true-awk/run.c contrib/one-true-awk/run.c index 1e5f1c25a69c..1b02a79fb46b 100644 --- contrib/one-true-awk/run.c +++ contrib/one-true-awk/run.c @@ -918,7 +918,7 @@ int format(char **pbuf, int *pbufsize, const char *s, Node *a) /* printf-like co break; case 'c': if (isnum(x)) { - if (getfval(x)) + if ((int)getfval(x)) sprintf(p, fmt, (int) getfval(x)); else { *p++ = '\0'; /* explicit null byte */ @@ -1476,7 +1476,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis { Cell *x, *y; Awkfloat u; - int t; + int t, i; Awkfloat tmp; char *p, *buf; Node *nextarg; @@ -1516,6 +1516,76 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis nextarg = nextarg->nnext; } break; + case FCOMPL: + u = ~((int)getfval(x)); + break; + case FAND: + if (nextarg == NULL) { + WARNING("and requires two arguments; returning 0"); + u = 0; + break; + } + i = ((int)getfval(x)); + while (nextarg != NULL) { + y = execute(nextarg); + i &= (int)getfval(y); + tempfree(y); + nextarg = nextarg->nnext; + } + u = i; + break; + case FFOR: + if (nextarg == NULL) { + WARNING("or requires two arguments; returning 0"); + u = 0; + break; + } + i = ((int)getfval(x)); + while (nextarg != NULL) { + y = execute(nextarg); + i |= (int)getfval(y); + tempfree(y); + nextarg = nextarg->nnext; + } + u = i; + break; + case FXOR: + if (nextarg == NULL) { + WARNING("xor requires two arguments; returning 0"); + u = 0; + break; + } + i = ((int)getfval(x)); + while (nextarg != NULL) { + y = execute(nextarg); + i ^= (int)getfval(y); + tempfree(y); + nextarg = nextarg->nnext; + } + u = i; + break; + case FLSHIFT: + if (nextarg == NULL) { + WARNING("lshift requires two arguments; returning 0"); + u = 0; + break; + } + y = execute(a[1]->nnext); + u = ((int)getfval(x)) << ((int)getfval(y)); + tempfree(y); + nextarg = nextarg->nnext; + break; + case FRSHIFT: + if (nextarg == NULL) { + WARNING("rshift requires two arguments; returning 0"); + u = 0; + break; + } + y = execute(a[1]->nnext); + u = ((int)getfval(x)) >> ((int)getfval(y)); + tempfree(y); + nextarg = nextarg->nnext; + break; case FSYSTEM: fflush(stdout); /* in case something is buffered already */ u = (Awkfloat) system(getsval(x)) / 256; /* 256 is unix-dep */ diff --git contrib/top/loadavg.h contrib/top/loadavg.h index 02bc81b236ad..d7db65ad5ca8 100644 --- contrib/top/loadavg.h +++ contrib/top/loadavg.h @@ -19,7 +19,7 @@ * * Defined types: load_avg for load averages, pctcpu for cpu percentages. */ -#if defined(mips) && !(defined(NetBSD) || defined(__FreeBSD__)) +#if defined(__mips__) && !(defined(__NetBSD__) || defined(__FreeBSD__)) # include <sys/fixpoint.h> # if defined(FBITS) && !defined(FSCALE) # define FSCALE (1 << FBITS) /* RISC/os on mips */ diff --git contrib/traceroute/traceroute.c contrib/traceroute/traceroute.c index a007d48d9dde..c74065a08836 100644 --- contrib/traceroute/traceroute.c +++ contrib/traceroute/traceroute.c @@ -227,7 +227,7 @@ static const char rcsid[] = #include <arpa/inet.h> -#ifdef HAVE_LIBCASPER +#ifdef WITH_CASPER #include <libcasper.h> #include <casper/cap_dns.h> #endif @@ -369,7 +369,7 @@ extern int optind; extern int opterr; extern char *optarg; -#ifdef HAVE_LIBCASPER +#ifdef WITH_CASPER static cap_channel_t *capdns; #endif @@ -521,7 +521,7 @@ main(int argc, char **argv) int requestPort = -1; int sump = 0; int sockerrno; -#ifdef HAVE_LIBCASPER +#ifdef WITH_CASPER const char *types[] = { "NAME", "ADDR" }; int families[1]; cap_channel_t *casper; @@ -556,7 +556,7 @@ main(int argc, char **argv) exit(1); } -#ifdef HAVE_LIBCASPER +#ifdef WITH_CASPER casper = cap_init(); if (casper == NULL) errx(1, "unable to create casper process"); @@ -568,7 +568,7 @@ main(int argc, char **argv) families[0] = AF_INET; if (cap_dns_family_limit(capdns, families, 1) < 0) errx(1, "unable to limit access to system.dns service"); -#endif /* HAVE_LIBCASPER */ +#endif /* WITH_CASPER */ #ifdef IPCTL_DEFTTL { @@ -584,7 +584,7 @@ main(int argc, char **argv) max_ttl = 30; #endif -#ifdef HAVE_LIBCASPER +#ifdef WITH_CASPER cap_close(casper); #endif @@ -1006,7 +1006,7 @@ main(int argc, char **argv) exit(1); } -#ifdef HAVE_LIBCASPER +#ifdef WITH_CASPER cansandbox = true; #else if (nflag) @@ -1851,7 +1851,7 @@ inetname(struct in_addr in) else { cp = strchr(domain, '.'); if (cp == NULL) { -#ifdef HAVE_LIBCASPER +#ifdef WITH_CASPER if (capdns != NULL) hp = cap_gethostbyname(capdns, domain); else @@ -1870,7 +1870,7 @@ inetname(struct in_addr in) } } if (!nflag && in.s_addr != INADDR_ANY) { -#ifdef HAVE_LIBCASPER +#ifdef WITH_CASPER if (capdns != NULL) hp = cap_gethostbyaddr(capdns, (char *)&in, sizeof(in), AF_INET); @@ -1922,7 +1922,7 @@ gethostinfo(register char *hostname) return (hi); } -#ifdef HAVE_LIBCASPER +#ifdef WITH_CASPER if (capdns != NULL) hp = cap_gethostbyname(capdns, hostname); else diff --git contrib/tzdata/CONTRIBUTING contrib/tzdata/CONTRIBUTING index 22addd2b546f..716f32b3a39a 100644 --- contrib/tzdata/CONTRIBUTING +++ contrib/tzdata/CONTRIBUTING @@ -5,20 +5,26 @@ change timekeeping rules erratically and sometimes with little warning, the data entries do not cover all of civil time before 1970, and undoubtedly errors remain in the code and data. Feel free to fill gaps or fix mistakes, and please email improvements -to tz@iana.org for use in the future. +to tz@iana.org for use in the future. In your email, please give +reliable sources that reviewers can check. + +----- + +Developers can contribute technical changes to the source code and +data as follows. To email small changes, please run a POSIX shell command like 'diff -u old/europe new/europe >myfix.patch', and attach myfix.patch to the email. -For more-elaborate changes, please read the Theory file and browse -the mailing list archives <http://mm.icann.org/pipermail/tz/> for -examples of patches that tend to work well. Ideally, additions to +For more-elaborate changes, please read the theory.html file and browse +the mailing list archives <https://mm.icann.org/pipermail/tz/> for +examples of patches that tend to work well. Additions to data should contain commentary citing reliable sources as -justification. +justification. Citations should use https: URLs if available. Please submit changes against either the latest release in -<ftp://ftp.iana.org/tz/> or the master branch of the development +<https://www.iana.org/time-zones> or the master branch of the development repository. If you use Git the following workflow may be helpful: * Copy the development repository. diff --git contrib/tzdata/LICENSE contrib/tzdata/LICENSE index 148eb232b673..8ba4399c622d 100644 --- contrib/tzdata/LICENSE +++ contrib/tzdata/LICENSE @@ -1,4 +1,5 @@ -With a few exceptions, all files in the tz code and data (including -this one) are in the public domain. The exceptions are date.c, -newstrftime.3, and strftime.c, which contain material derived from BSD -and which use the BSD 3-clause license. +Unless specified below, all files in the tz code and data (including +this LICENSE file) are in the public domain. + +If the files date.c, newstrftime.3, and strftime.c are present, they +contain material derived from BSD and use the BSD 3-clause license. diff --git contrib/tzdata/Makefile contrib/tzdata/Makefile index 8067ba087b43..c92edc064084 100644 --- contrib/tzdata/Makefile +++ contrib/tzdata/Makefile @@ -49,6 +49,7 @@ TOPDIR= /usr/local # "Compiled" time zone information is placed in the "TZDIR" directory # (and subdirectories). # Use an absolute path name for TZDIR unless you're just testing the software. +# TZDIR_BASENAME should not contain "/" and should not be ".", ".." or empty. TZDIR_BASENAME= zoneinfo TZDIR= $(TOPDIR)/etc/$(TZDIR_BASENAME) @@ -75,7 +76,7 @@ LIBDIR= $(TOPDIR)/lib # If you want only POSIX time, with time values interpreted as # seconds since the epoch (not counting leap seconds), use # REDO= posix_only -# below. If you want want only "right" time, with values interpreted +# below. If you want only "right" time, with values interpreted # as seconds since the epoch (counting leap seconds), use # REDO= right_only # below. If you want both sets of data available, with leap seconds not @@ -92,6 +93,24 @@ LIBDIR= $(TOPDIR)/lib REDO= posix_right +# To install data in text form that has all the information of the binary data, +# (optionally incorporating leap second information), use +# TZDATA_TEXT= tzdata.zi leapseconds +# To install text data without leap second information (e.g., because +# REDO='posix_only'), use +# TZDATA_TEXT= tzdata.zi +# To avoid installing text data, use +# TZDATA_TEXT= + +TZDATA_TEXT= leapseconds tzdata.zi + +# For backward-compatibility links for old zone names, use +# BACKWARD= backward pacificnew +# To omit these links, use +# BACKWARD= + +BACKWARD= backward pacificnew + # If you want out-of-scope and often-wrong data from the file 'backzone', use # PACKRATDATA= backzone # To omit this data, use @@ -99,6 +118,11 @@ REDO= posix_right PACKRATDATA= +# The name of a locale using the UTF-8 encoding, used during self-tests. +# The tests are skipped if the name does not appear to work on this system. + +UTF8_LOCALE= en_US.utf8 + # Since "." may not be in PATH... YEARISTYPE= ./yearistype @@ -106,50 +130,53 @@ YEARISTYPE= ./yearistype # Non-default libraries needed to link. LDLIBS= -# Add the following to the end of the "CFLAGS=" line as needed. +# Add the following to the end of the "CFLAGS=" line as needed to override +# defaults specified in the source code. "-DFOO" is equivalent to "-DFOO=1". # -DBIG_BANG=-9999999LL if the Big Bang occurred at time -9999999 (see zic.c) +# -DDEPRECATE_TWO_DIGIT_YEARS for optional runtime warnings about strftime +# formats that generate only the last two digits of year numbers +# -DEPOCH_LOCAL if the 'time' function returns local time not UT +# -DEPOCH_OFFSET=N if the 'time' function returns a value N greater +# than what POSIX specifies, assuming local time is UT. +# For example, N is 252460800 on AmigaOS. # -DHAVE_DECL_ASCTIME_R=0 if <time.h> does not declare asctime_r +# -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ' # -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows) -# -DHAVE_DOS_FILE_NAMES if file names have drive specifiers etc. (MS-DOS) -# -DHAVE_GETTEXT=1 if 'gettext' works (e.g., GNU/Linux, FreeBSD, Solaris) -# -DHAVE_INCOMPATIBLE_CTIME_R=1 if your system's time.h declares +# -DHAVE_GENERIC=0 if _Generic does not work +# -DHAVE_GETTEXT if 'gettext' works (e.g., GNU/Linux, FreeBSD, Solaris) +# -DHAVE_INCOMPATIBLE_CTIME_R if your system's time.h declares # ctime_r and asctime_r incompatibly with the POSIX standard # (Solaris when _POSIX_PTHREAD_SEMANTICS is not defined). -# -DHAVE_INTTYPES_H=1 if you have a pre-C99 compiler with "inttypes.h" +# -DHAVE_INTTYPES_H if you have a non-C99 compiler with <inttypes.h> # -DHAVE_LINK=0 if your system lacks a link function # -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function # -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz -# This defaults to 1 if a working localtime_rz seems to be available. # localtime_rz can make zdump significantly faster, but is nonstandard. # -DHAVE_POSIX_DECLS=0 if your system's include files do not declare # functions like 'link' or variables like 'tzname' required by POSIX -# -DHAVE_STDINT_H=1 if you have a pre-C99 compiler with "stdint.h" -# -DHAVE_STRFTIME_L=1 if <time.h> declares locale_t and strftime_l -# This defaults to 0 if _POSIX_VERSION < 200809, 1 otherwise. +# -DHAVE_SNPRINTF=0 if your system lacks the snprintf function +# -DHAVE_STDBOOL_H if you have a non-C99 compiler with <stdbool.h> +# -DHAVE_STDINT_H if you have a non-C99 compiler with <stdint.h> +# -DHAVE_STRFTIME_L if <time.h> declares locale_t and strftime_l # -DHAVE_STRDUP=0 if your system lacks the strdup function # -DHAVE_SYMLINK=0 if your system lacks the symlink function -# -DHAVE_SYS_STAT_H=0 if your compiler lacks a "sys/stat.h" -# -DHAVE_SYS_WAIT_H=0 if your compiler lacks a "sys/wait.h" +# -DHAVE_SYS_STAT_H=0 if your compiler lacks a <sys/stat.h> +# -DHAVE_SYS_WAIT_H=0 if your compiler lacks a <sys/wait.h> # -DHAVE_TZSET=0 if your system lacks a tzset function -# -DHAVE_UNISTD_H=0 if your compiler lacks a "unistd.h" (Microsoft C++ 7?) -# -DEPOCH_LOCAL=1 if the 'time' function returns local time not UT -# -DEPOCH_OFFSET=N if the 'time' function returns a value N greater -# than what POSIX specifies, assuming local time is UT. -# For example, N is 252460800 on AmigaOS. -# -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1 -# if you do not want run time warnings about formats that may cause -# year 2000 grief -# -Dssize_t=long on ancient hosts that lack ssize_t -# -DTHREAD_SAFE=1 to make localtime.c thread-safe, as POSIX requires; +# -DHAVE_UNISTD_H=0 if your compiler lacks a <unistd.h> +# -Dlocale_t=XXX if your system uses XXX instead of locale_t +# -Dssize_t=long on hosts like MS-Windows that lack ssize_t +# -DTHREAD_SAFE to make localtime.c thread-safe, as POSIX requires; # not needed by the main-program tz code, which is single-threaded. # Append other compiler flags as needed, e.g., -pthread on GNU/Linux. # -Dtime_tz=\"T\" to use T as the time_t type, rather than the system time_t +# This is intended for internal use only; it mangles external names. # -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz" # -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory; # the default is system-supplied, typically "/usr/lib/locale" # -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified # DST transitions if the time zone files cannot be accessed -# -DUNINIT_TRAP=1 if reading uninitialized storage can cause problems +# -DUNINIT_TRAP if reading uninitialized storage can cause problems # other than simply getting garbage data # -DUSE_LTZ=0 to build zdump with the system time zone library # Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below. @@ -157,26 +184,27 @@ LDLIBS= # (or some other number) to set the maximum time zone abbreviation length # that zic will accept without a warning (the default is 6) # $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking -GCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \ - -Wall -Wextra \ - -Wbad-function-cast -Wcast-align -Wdate-time \ - -Wdeclaration-after-statement \ - -Wdouble-promotion \ - -Wformat=2 -Winit-self -Wjump-misses-init \ - -Wlogical-op -Wmissing-prototypes -Wnested-externs \ - -Wold-style-definition -Woverlength-strings -Wpointer-arith \ - -Wshadow -Wstrict-prototypes -Wsuggest-attribute=const \ - -Wsuggest-attribute=format -Wsuggest-attribute=noreturn \ - -Wsuggest-attribute=pure -Wtrampolines \ - -Wundef -Wunused -Wwrite-strings \ - -Wno-address -Wno-format-nonliteral -Wno-sign-compare \ - -Wno-type-limits -Wno-unused-parameter -# -# If you want to use System V compatibility code, add -# -DUSG_COMPAT -# to the end of the "CFLAGS=" line. This arrange for "timezone" and "daylight" -# variables to be kept up-to-date by the time conversion functions. Neither -# "timezone" nor "daylight" is described in X3J11's work. +# Select instrumentation via "make GCC_INSTRUMENT='whatever'". +GCC_INSTRUMENT = \ + -fsanitize=undefined -fsanitize-address-use-after-scope \ + -fsanitize-undefined-trap-on-error -fstack-protector +GCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \ + $(GCC_INSTRUMENT) \ + -Wall -Wextra \ + -Walloc-size-larger-than=100000 -Warray-bounds=2 \ + -Wbad-function-cast -Wcast-align -Wdate-time \ + -Wdeclaration-after-statement -Wdouble-promotion \ + -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation \ + -Winit-self -Wjump-misses-init -Wlogical-op \ + -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ + -Wold-style-definition -Woverlength-strings -Wpointer-arith \ + -Wshadow -Wshift-overflow=2 -Wstrict-prototypes -Wstringop-overflow=5 \ + -Wsuggest-attribute=const -Wsuggest-attribute=format \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure \ + -Wtrampolines -Wundef -Wuninitialized -Wunused \ + -Wvariadic-macros -Wvla -Wwrite-strings \ + -Wno-address -Wno-format-nonliteral -Wno-sign-compare \ + -Wno-type-limits -Wno-unused-parameter # # If your system has a "GMT offset" field in its "struct tm"s # (or if you decide to add such a field in your system's "time.h" file), @@ -189,6 +217,31 @@ GCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \ # and define NO_TM_ZONE to suppress any guessing. These two fields are not # required by POSIX, but are widely available on GNU/Linux and BSD systems. # +# The next batch of options control support for external variables +# exported by tzcode. In practice these variables are less useful +# than TM_GMTOFF and TM_ZONE. However, most of them are standardized. +# # +# # To omit or support the external variable "tzname", add one of: +# # -DHAVE_TZNAME=0 +# # -DHAVE_TZNAME=1 +# # to the "CFLAGS=" line. "tzname" is required by POSIX 1988 and later. +# # If not defined, the code attempts to guess HAVE_TZNAME from other macros. +# # Warning: unless time_tz is also defined, HAVE_TZNAME=1 can cause +# # crashes when combined with some platforms' standard libraries, +# # presumably due to memory allocation issues. +# # +# # To omit or support the external variables "timezone" and "daylight", add +# # -DUSG_COMPAT=0 +# # -DUSG_COMPAT=1 +# # to the "CFLAGS=" line; "timezone" and "daylight" are inspired by +# # Unix Systems Group code and are required by POSIX 2008 (with XSI) and later. +# # If not defined, the code attempts to guess USG_COMPAT from other macros. +# # +# # To support the external variable "altzone", add +# # -DALTZONE +# # to the end of the "CFLAGS=" line; although "altzone" appeared in +# # System V Release 3.1 it has not been standardized. +# # If you want functions that were inspired by early versions of X3J11's work, # add # -DSTD_INSPIRED @@ -226,11 +279,6 @@ GCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \ # -DALL_STATE # to the end of the "CFLAGS=" line. Storage is obtained by calling malloc. # -# If you want an "altzone" variable (a la System V Release 3.1), add -# -DALTZONE -# to the end of the "CFLAGS=" line. -# This variable is not described in X3J11's work. -# # NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put # out by the National Institute of Standards and Technology # which claims to test C and Posix conformance. If you want to pass PCTS, add @@ -240,8 +288,8 @@ GCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \ # If you want strict compliance with XPG4 as of 1994-04-09, add # -DXPG4_1994_04_09 # to the end of the "CFLAGS=" line. This causes "strftime" to always return -# 53 as a week number (rather than 52 or 53) for those days in January that -# before the first Monday in January when a "%V" format is used and January 1 +# 53 as a week number (rather than 52 or 53) for January days before +# January's first Monday when a "%V" format is used and January 1 # falls on a Friday, Saturday, or Sunday. CFLAGS= @@ -265,7 +313,7 @@ ZFLAGS= # How to use zic to install tz binary files. -ZIC_INSTALL= $(ZIC) -y $(YEARISTYPE) -d $(DESTDIR)$(TZDIR) $(LEAPSECONDS) +ZIC_INSTALL= $(ZIC) -d $(DESTDIR)$(TZDIR) $(LEAPSECONDS) # The name of a Posix-compliant 'awk' on your system. AWK= awk @@ -289,6 +337,7 @@ SGML_CATALOG_FILES= \ # The name, arguments and environment of a program to validate your web pages. # See <http://openjade.sourceforge.net/doc/> for a validator, and # <https://validator.w3.org/source/> for a validation library. +# Set VALIDATE=':' if you do not have such a program. VALIDATE = nsgmls VALIDATE_FLAGS = -s -B -wall -wno-unused-param VALIDATE_ENV = \ @@ -355,7 +404,7 @@ AR= ar RANLIB= : TZCOBJS= zic.o -TZDOBJS= zdump.o localtime.o asctime.o +TZDOBJS= zdump.o localtime.o asctime.o strftime.o DATEOBJS= date.o localtime.o strftime.o asctime.o LIBSRCS= localtime.c asctime.c difftime.c LIBOBJS= localtime.o asctime.o difftime.o @@ -370,33 +419,35 @@ MANTXTS= newctime.3.txt newstrftime.3.txt newtzset.3.txt \ time2posix.3.txt \ tzfile.5.txt tzselect.8.txt zic.8.txt zdump.8.txt \ date.1.txt -COMMON= CONTRIBUTING LICENSE Makefile NEWS README Theory version +COMMON= calendars CONTRIBUTING LICENSE Makefile \ + NEWS README theory.html version WEB_PAGES= tz-art.htm tz-how-to.html tz-link.htm DOCS= $(MANS) date.1 $(MANTXTS) $(WEB_PAGES) PRIMARY_YDATA= africa antarctica asia australasia \ europe northamerica southamerica -YDATA= $(PRIMARY_YDATA) pacificnew etcetera backward +YDATA= $(PRIMARY_YDATA) etcetera $(BACKWARD) NDATA= systemv factory TDATA= $(YDATA) $(NDATA) ZONETABLES= zone1970.tab zone.tab -TABDATA= iso3166.tab leapseconds $(ZONETABLES) +TABDATA= iso3166.tab $(TZDATA_TEXT) $(ZONETABLES) LEAP_DEPS= leapseconds.awk leap-seconds.list -DATA= $(YDATA) $(NDATA) backzone $(TABDATA) \ - leap-seconds.list yearistype.sh -AWK_SCRIPTS= checklinks.awk checktab.awk leapseconds.awk +TZDATA_ZI_DEPS= zishrink.awk $(TDATA) $(PACKRATDATA) +DATA= $(YDATA) $(NDATA) backzone iso3166.tab leap-seconds.list \ + leapseconds yearistype.sh $(ZONETABLES) +AWK_SCRIPTS= checklinks.awk checktab.awk leapseconds.awk zishrink.awk MISC= $(AWK_SCRIPTS) zoneinfo2tdf.pl TZS_YEAR= 2050 TZS= to$(TZS_YEAR).tzs TZS_NEW= to$(TZS_YEAR)new.tzs TZS_DEPS= $(PRIMARY_YDATA) asctime.c localtime.c \ private.h tzfile.h zdump.c zic.c -ENCHILADA= $(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC) $(TZS) +ENCHILADA= $(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC) $(TZS) tzdata.zi # Consult these files when deciding whether to rebuild the 'version' file. # This list is not the same as the output of 'git ls-files', since # .gitignore is not distributed. VERSION_DEPS= \ - CONTRIBUTING LICENSE Makefile NEWS README Theory \ + calendars CONTRIBUTING LICENSE Makefile NEWS README \ africa antarctica asctime.c asia australasia \ backward backzone \ checklinks.awk checktab.awk \ @@ -405,7 +456,7 @@ VERSION_DEPS= \ leap-seconds.list leapseconds.awk localtime.c \ newctime.3 newstrftime.3 newtzset.3 northamerica \ pacificnew private.h \ - southamerica strftime.c systemv \ + southamerica strftime.c systemv theory.html \ time2posix.3 tz-art.htm tz-how-to.html tz-link.htm \ tzfile.5 tzfile.h tzselect.8 tzselect.ksh \ workman.sh yearistype.sh \ @@ -427,7 +478,7 @@ install: all $(DATA) $(REDO) $(MANS) $(DESTDIR)$(MANDIR)/man3 $(DESTDIR)$(MANDIR)/man5 \ $(DESTDIR)$(MANDIR)/man8 $(ZIC_INSTALL) -l $(LOCALTIME) -p $(POSIXRULES) - cp -f iso3166.tab $(ZONETABLES) $(DESTDIR)$(TZDIR)/. + cp -f $(TABDATA) $(DESTDIR)$(TZDIR)/. cp tzselect zic zdump $(DESTDIR)$(ETCDIR)/. cp libtz.a $(DESTDIR)$(LIBDIR)/. $(RANLIB) $(DESTDIR)$(LIBDIR)/libtz.a @@ -448,6 +499,11 @@ version: $(VERSION_DEPS) printf '%s\n' "$$V" >$@.out mv $@.out $@ +# This file can be tailored by setting BACKWARD, PACKRATDATA, etc. +tzdata.zi: $(TZDATA_ZI_DEPS) + LC_ALL=C $(AWK) -f zishrink.awk $(TDATA) $(PACKRATDATA) >$@.out + mv $@.out $@ + version.h: version VERSION=`cat version` && printf '%s\n' \ 'static char const PKGVERSION[]="($(PACKAGE)) ";' \ @@ -473,6 +529,7 @@ leapseconds: $(LEAP_DEPS) # Arguments to pass to submakes of install_data. # They can be overridden by later submake arguments. INSTALLARGS = \ + BACKWARD=$(BACKWARD) \ DESTDIR=$(DESTDIR) \ LEAPSECONDS='$(LEAPSECONDS)' \ PACKRATDATA='$(PACKRATDATA)' \ @@ -481,10 +538,8 @@ INSTALLARGS = \ ZIC='$(ZIC)' # 'make install_data' installs one set of tz binary files. -# It can be tailored by setting LEAPSECONDS, PACKRATDATA, etc. -install_data: zic leapseconds yearistype $(PACKRATDATA) $(TDATA) - $(ZIC_INSTALL) $(TDATA) - $(AWK) '/^Rule/' $(TDATA) | $(ZIC_INSTALL) - $(PACKRATDATA) +install_data: zic leapseconds yearistype tzdata.zi + $(ZIC_INSTALL) tzdata.zi posix_only: $(MAKE) $(INSTALLARGS) LEAPSECONDS= install_data @@ -521,14 +576,14 @@ posix_packrat: zones: $(REDO) -$(TZS_NEW): $(TDATA) zdump zic +$(TZS_NEW): tzdata.zi zdump zic mkdir -p tzs.dir - $(zic) -d tzs.dir $(TDATA) - $(AWK) '/^Link/{print $$1 "\t" $$2 "\t" $$3}' \ - $(TDATA) | LC_ALL=C sort >$@.out + $(zic) -d tzs.dir tzdata.zi + $(AWK) '/^L/{print "Link\t" $$2 "\t" $$3}' \ + tzdata.zi | LC_ALL=C sort >$@.out wd=`pwd` && \ zones=`$(AWK) -v wd="$$wd" \ - '/^Zone/{print wd "/tzs.dir/" $$2}' $(TDATA) \ + '/^Z/{print wd "/tzs.dir/" $$2}' tzdata.zi \ | LC_ALL=C sort` && \ ./zdump -i -c $(TZS_YEAR) $$zones >>$@.out sed 's,^TZ=".*tzs\.dir/,TZ=",' $@.out >$@.sed.out @@ -564,24 +619,37 @@ tzselect: tzselect.ksh version chmod +x $@.out mv $@.out $@ -check: check_character_set check_white_space check_links check_sorted \ - check_tables check_tzs check_web +check: check_character_set check_white_space check_links \ + check_name_lengths check_sorted \ + check_tables check_web check_zishrink check_tzs check_character_set: $(ENCHILADA) - LC_ALL=en_US.utf8 && export LC_ALL && \ + test ! '$(UTF8_LOCALE)' || \ + ! printf 'A\304\200B\n' | \ + LC_ALL='$(UTF8_LOCALE)' grep -q '^A.B$$' >/dev/null 2>&1 || { \ + LC_ALL='$(UTF8_LOCALE)' && export LC_ALL && \ sharp='#' && \ ! grep -Env $(SAFE_LINE) $(MANS) date.1 $(MANTXTS) \ $(MISC) $(SOURCES) $(WEB_PAGES) \ - CONTRIBUTING LICENSE Makefile README version && \ + CONTRIBUTING LICENSE Makefile README \ + version tzdata.zi && \ ! grep -Env $(SAFE_SHARP_LINE) $(TDATA) backzone \ leapseconds yearistype.sh zone.tab && \ - ! grep -Env $(OK_LINE) $(ENCHILADA) + ! grep -Env $(OK_LINE) $(ENCHILADA); \ + } check_white_space: $(ENCHILADA) patfmt=' \t|[\f\r\v]' && pat=`printf "$$patfmt\\n"` && \ ! grep -En "$$pat" $(ENCHILADA) ! grep -n '[[:space:]]$$' $(ENCHILADA) +PRECEDES_FILE_NAME = ^(Zone|Link[[:space:]]+[^[:space:]]+)[[:space:]]+ +FILE_NAME_COMPONENT_TOO_LONG = \ + $(PRECEDES_FILE_NAME)[^[:space:]]*[^/[:space:]]{15} + +check_name_lengths: $(TDATA) backzone + ! grep -En '$(FILE_NAME_COMPONENT_TOO_LONG)' $(TDATA) backzone + CHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; } check_sorted: backward backzone iso3166.tab zone.tab zone1970.tab @@ -596,6 +664,7 @@ check_sorted: backward backzone iso3166.tab zone.tab zone1970.tab check_links: checklinks.awk $(TDATA) $(AWK) -f checklinks.awk $(TDATA) + $(AWK) -f checklinks.awk tzdata.zi check_tables: checktab.awk $(PRIMARY_YDATA) $(ZONETABLES) for tab in $(ZONETABLES); do \ @@ -606,14 +675,32 @@ check_tables: checktab.awk $(PRIMARY_YDATA) $(ZONETABLES) check_tzs: $(TZS) $(TZS_NEW) diff -u $(TZS) $(TZS_NEW) -check_web: $(WEB_PAGES) - $(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) $(WEB_PAGES) +# This checks only the HTML 4.01 strict page. +# To check the the other pages, use <https://validator.w3.org/>. +check_web: tz-how-to.html + $(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) tz-how-to.html + +# Check that tzdata.zi generates the same binary data that its sources do. +check_zishrink: tzdata.zi zic leapseconds $(PACKRATDATA) $(TDATA) + for type in posix right; do \ + mkdir -p time_t.dir/$$type time_t.dir/$$type-shrunk && \ + case $$type in \ + right) leap='-L leapseconds';; \ + *) leap=;; \ + esac && \ + $(ZIC) $$leap -d time_t.dir/$$type $(TDATA) && \ + $(AWK) '/^Rule/' $(TDATA) | \ + $(ZIC) $$leap -d time_t.dir/$$type - $(PACKRATDATA) && \ + $(ZIC) $$leap -d time_t.dir/$$type-shrunk tzdata.zi && \ + diff -r time_t.dir/$$type time_t.dir/$$type-shrunk || exit; \ + done + rm -fr time_t.dir clean_misc: rm -f core *.o *.out \ date tzselect version.h zdump zic yearistype libtz.a clean: clean_misc - rm -fr *.dir tzdb-*/ $(TZS_NEW) + rm -fr *.dir tzdata.zi tzdb-*/ $(TZS_NEW) maintainer-clean: clean @echo 'This command is intended for maintainers to use; it' @@ -667,6 +754,7 @@ set-timestamps.out: $(ENCHILADA) touch -cmr `ls -t $$file workman.sh | sed 1q` $$file.txt || \ exit; \ done + touch -cmr `ls -t $(TZDATA_ZI_DEPS) | sed 1q` tzdata.zi touch -cmr `ls -t $(TZS_DEPS) | sed 1q` $(TZS) touch -cmr `ls -t $(VERSION_DEPS) | sed 1q` version touch $@ @@ -678,7 +766,7 @@ check_public: $(MAKE) maintainer-clean $(MAKE) "CFLAGS=$(GCC_DEBUG_FLAGS)" ALL mkdir -p public.dir - for i in $(TDATA) ; do \ + for i in $(TDATA) tzdata.zi; do \ $(zic) -v -d public.dir $$i 2>&1 || exit; \ done $(zic) -v -d public.dir $(TDATA) @@ -772,8 +860,8 @@ typecheck: $(MAKE) clean ; \ done -zonenames: $(TDATA) - @$(AWK) '/^Zone/ { print $$2 } /^Link/ { print $$3 }' $(TDATA) +zonenames: tzdata.zi + @$(AWK) '/^Z/ { print $$2 } /^L/ { print $$3 }' tzdata.zi asctime.o: private.h tzfile.h date.o: private.h @@ -789,6 +877,7 @@ zic.o: private.h tzfile.h version.h .PHONY: check check_character_set check_links .PHONY: check_public check_sorted check_tables .PHONY: check_time_t_alternatives check_tzs check_web check_white_space +.PHONY: check_zishrink .PHONY: clean clean_misc force_tzs .PHONY: install install_data maintainer-clean names .PHONY: posix_only posix_packrat posix_right diff --git contrib/tzdata/NEWS contrib/tzdata/NEWS index f986cf6f0f67..bd2bec223a0b 100644 --- contrib/tzdata/NEWS +++ contrib/tzdata/NEWS @@ -1,5 +1,169 @@ News for the tz database +Release 2017c - 2017-10-20 14:49:34 -0700 + + Briefly: + Northern Cyprus switches from +03 to +02/+03 on 2017-10-29. + Fiji ends DST 2018-01-14, not 2018-01-21. + Namibia switches from +01/+02 to +02 on 2018-04-01. + Sudan switches from +03 to +02 on 2017-11-01. + Tonga likely switches from +13/+14 to +13 on 2017-11-05. + Turks & Caicos switches from -04 to -05/-04 on 2018-11-04. + A new file tzdata.zi now holds a small text copy of all data. + The zic input format has been regularized slightly. + + Changes to future time stamps + + Northern Cyprus has decided to resume EU rules starting + 2017-10-29, thus reinstituting winter time. + + Fiji ends DST 2018-01-14 instead of the 2018-01-21 previously + predicted. (Thanks to Dominic Fok.) Adjust future predictions + accordingly. + + Namibia will switch from +01 with DST to +02 all year on + 2017-09-03 at 02:00. This affects UT offsets starting 2018-04-01 + at 02:00. (Thanks to Steffen Thorsen.) + + Sudan will switch from +03 to +02 on 2017-11-01. (Thanks to Ahmed + Atyya and Yahia Abdalla.) South Sudan is not switching, so + Africa/Juba is no longer a link to Africa/Khartoum. + + Tonga has likely ended its experiment with DST, and will not + adjust its clocks on 2017-11-05. Although Tonga has not announced + whether it will continue to observe DST, the IATA is assuming that + it will not. (Thanks to David Wade.) + + Turks & Caicos will switch from -04 all year to -05 with US DST on + 2018-03-11 at 03:00. This affects UT offsets starting 2018-11-04 + at 02:00. (Thanks to Steffen Thorsen.) + + Changes to past time stamps + + Namibia switched from +02 to +01 on 1994-03-21, not 1994-04-03. + (Thanks to Arthur David Olson.) + + Detroit did not observe DST in 1967. + + Use railway time for Asia/Kolkata before 1941, by switching to + Madras local time (UT +052110) in 1870, then to IST (UT +0530) in + 1906. Also, treat 1941-2's +0630 as DST, like 1942-5. + + Europe/Dublin's 1946 and 1947 fallback transitions occurred at + 02:00 standard time, not 02:00 DST. (Thanks to Michael Deckers.) + + Pacific/Apia and Pacific/Pago_Pago switched from Antipodean to + American time in 1892, not 1879. (Thanks to Michael Deckers.) + + Adjust the 1867 transition in Alaska to better reflect the + historical record, by changing it to occur on 1867-10-18 at 15:30 + Sitka time rather than at the start of 1867-10-17 local time. + Although strictly speaking this is accurate only for Sitka, + the rest of Alaska's blanks need to be filled in somehow. + + Fix off-by-one errors in UT offsets for Adak and Nome before 1867. + (Thanks to Michael Deckers.) + + Add 7 s to the UT offset in Asia/Yangon before 1920. + + Changes to zone names + + Remove Canada/East-Saskatchewan from the 'backward' file, as it + exceeded the 14-character limit and was an unused misnomer anyway. + + Changes to build procedure + + To support applications that prefer to read time zone data in text + form, two zic input files tzdata.zi and leapseconds are now + installed by default. The commands 'zic tzdata.zi' and 'zic -L + leapseconds tzdata.zi' can reproduce the tzdata binary files + without and with leap seconds, respectively. To prevent these two + new files from being installed, use 'make TZDATA_TEXT=', and to + suppress leap seconds from the tzdata text installation, use 'make + TZDATA_TEXT=tzdata.zi'. + + 'make BACKWARD=' now suppresses backward-compatibility names + like 'US/Pacific' that are defined in the 'backward' and + 'pacificnew' files. + + 'make check' now works on systems that lack a UTF-8 locale, + or that lack the nsgmls program. Set UTF8_LOCALE to configure + the name of a UTF-8 locale, if you have one. + + Y2K runtime checks are no longer enabled by default. Add + -DDEPRECATE_TWO_DIGIT_YEARS to CFLAGS to enable them, instead of + adding -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU + to disable them. (New name suggested by Brian Inglis.) + + The build procedure for zdump now works on AIX 7.1. + (Problem reported by Kees Dekker.) + + Changes to code + + zic and the reference runtime now reject multiple leap seconds + within 28 days of each other, or leap seconds before the Epoch. + As a result, support for double leap seconds, which was + obsolescent and undocumented, has been removed. Double leap + seconds were an error in the C89 standard; they have never existed + in civil timekeeping. (Thanks to Robert Elz and Bradley White for + noticing glitches in the code that uncovered this problem.) + + zic now warns about use of the obsolescent and undocumented -y + option, and about use of the obsolescent TYPE field of Rule lines. + + zic now allows unambiguous abbreviations like "Sa" and "Su" for + weekdays; formerly it rejected them due to a bug. Conversely, zic + no longer considers non-prefixes to be abbreviations; for example, + it no longer accepts "lF" as an abbreviation for "lastFriday". + Also, zic warns about the undocumented usage with a "last-" + prefix, e.g., "last-Fri". + + Similarly, zic now accepts the unambiguous abbreviation "L" for + "Link" in ordinary context and for "Leap" in leap-second context. + Conversely, zic no longer accepts non-prefixes such as "La" as + abbreviations for words like "Leap". + + zic no longer accepts leap second lines in ordinary input, or + ordinary lines in leap second input. Formerly, zic sometimes + warned about this undocumented usage and handled it incorrectly. + + The new macro HAVE_TZNAME governs whether the tzname external + variable is exported, instead of USG_COMPAT. USG_COMPAT now + governs only the external variables "timezone" and "daylight". + This change is needed because the three variables are not in the + same category: although POSIX requires tzname, it specifies the + other two variables as optional. Also, USG_COMPAT is now 1 or 0: + if not defined, the code attempts to guess it from other macros. + + localtime.c and difftime.c no longer require stdio.h, and .c files + other than zic.c no longer require sys/wait.h. + + zdump.c no longer assumes snprintf. (Reported by Jonathan Leffler.) + + Calculation of time_t extrema works around a bug in GCC 4.8.4 + (Reported by Stan Shebs and Joseph Myers.) + + zic.c no longer mistranslates formats of line numbers in non-English + locales. (Problem reported by Benno Schulenberg.) + + Several minor changes have been made to the code to make it a + bit easier to port to MS-Windows and Solaris. (Thanks to Kees + Dekker for reporting the problems.) + + Changes to documentation and commentary + + The two new files 'theory.html' and 'calendars' contain the + contents of the removed file 'Theory'. The goal is to document + tzdb theory more accessibly. + + The zic man page now documents abbreviation rules. + + tz-link.htm now covers how to apply tzdata changes to clients. + (Thanks to Jorge Fábregas for the AIX link.) It also mentions MySQL. + + The leap-seconds.list URL has been updated to something that is + more reliable for tzdb. (Thanks to Tim Parenti and Brian Inglis.) + Release 2017b - 2017-03-17 07:30:38 -0700 Briefly: Haiti has resumed DST. @@ -15,6 +179,16 @@ Release 2017b - 2017-03-17 07:30:38 -0700 Use "MMT" to abbreviate Liberia's time zone before 1972, as "-004430" is one byte over the POSIX limit. (Problem reported by Derick Rethans.) + Changes to code + + The reference localtime implementation now falls back on the + current US daylight-saving transition rules rather than the + 1987-2006 rules. This fallback occurs only when (1) the TZ + environment variable's value has a name like "AST4ADT" that asks + for daylight saving time but does not specify the rules, (2) there + is no file by that name, and (3) the TZDEFRULES file cannot be + loaded. (Thanks to Tom Lane.) + Release 2017a - 2017-02-28 00:05:36 -0800 @@ -1981,7 +2155,7 @@ Release 2013e - 2013-09-19 23:50:04 -0700 The 'leapseconds' file is now generated automatically from a new file 'leap-seconds.list', which is a copy of - <ftp://time.nist.gov/pub/leap-seconds.list>. + <ftp://ftp.nist.gov/pub/time/leap-seconds.list> A new source file 'leapseconds.awk' implements this. The goal is simplification of the future maintenance of 'leapseconds'. @@ -2187,7 +2361,7 @@ Release 2013a - 2013-02-27 09:20:35 -0800 Many changes affect historical timestamps before 1940. These were deduced from: Milne J. Civil time. Geogr J. 1899 - Feb;13(2):173-94 <http://www.jstor.org/stable/1774359>. + Feb;13(2):173-94 <https://www.jstor.org/stable/1774359>. Changes affecting the code: diff --git contrib/tzdata/Theory contrib/tzdata/Theory deleted file mode 100644 index 33e46069ba23..000000000000 --- contrib/tzdata/Theory +++ /dev/null @@ -1,870 +0,0 @@ -Theory and pragmatics of the tz code and data - - ------ Outline ----- - - Scope of the tz database - Names of time zone rules - Time zone abbreviations - Accuracy of the tz database - Time and date functions - Interface stability - Calendrical issues - Time and time zones on Mars - - ------ Scope of the tz database ----- - -The tz database attempts to record the history and predicted future of -all computer-based clocks that track civil time. To represent this -data, the world is partitioned into regions whose clocks all agree -about time stamps that occur after the somewhat-arbitrary cutoff point -of the POSIX Epoch (1970-01-01 00:00:00 UTC). For each such region, -the database records all known clock transitions, and labels the region -with a notable location. Although 1970 is a somewhat-arbitrary -cutoff, there are significant challenges to moving the cutoff earlier -even by a decade or two, due to the wide variety of local practices -before computer timekeeping became prevalent. - -Clock transitions before 1970 are recorded for each such location, -because most systems support time stamps before 1970 and could -misbehave if data entries were omitted for pre-1970 transitions. -However, the database is not designed for and does not suffice for -applications requiring accurate handling of all past times everywhere, -as it would take far too much effort and guesswork to record all -details of pre-1970 civil timekeeping. - -As described below, reference source code for using the tz database is -also available. The tz code is upwards compatible with POSIX, an -international standard for UNIX-like systems. As of this writing, the -current edition of POSIX is: - - The Open Group Base Specifications Issue 7 - IEEE Std 1003.1-2008, 2016 Edition - <http://pubs.opengroup.org/onlinepubs/9699919799/> - - - ------ Names of time zone rules ----- - -Each of the database's time zone rules has a unique name. -Inexperienced users are not expected to select these names unaided. -Distributors should provide documentation and/or a simple selection -interface that explains the names; for one example, see the 'tzselect' -program in the tz code. The Unicode Common Locale Data Repository -<http://cldr.unicode.org/> contains data that may be useful for other -selection interfaces. - -The time zone rule naming conventions attempt to strike a balance -among the following goals: - - * Uniquely identify every region where clocks have agreed since 1970. - This is essential for the intended use: static clocks keeping local - civil time. - - * Indicate to experts where that region is. - - * Be robust in the presence of political changes. For example, names - of countries are ordinarily not used, to avoid incompatibilities - when countries change their name (e.g. Zaire->Congo) or when - locations change countries (e.g. Hong Kong from UK colony to - China). - - * Be portable to a wide variety of implementations. - - * Use a consistent naming conventions over the entire world. - -Names normally have the form AREA/LOCATION, where AREA is the name -of a continent or ocean, and LOCATION is the name of a specific -location within that region. North and South America share the same -area, 'America'. Typical names are 'Africa/Cairo', 'America/New_York', -and 'Pacific/Honolulu'. - -Here are the general rules used for choosing location names, -in decreasing order of importance: - - Use only valid POSIX file name components (i.e., the parts of - names other than '/'). Do not use the file name - components '.' and '..'. Within a file name component, - use only ASCII letters, '.', '-' and '_'. Do not use - digits, as that might create an ambiguity with POSIX - TZ strings. A file name component must not exceed 14 - characters or start with '-'. E.g., prefer 'Brunei' - to 'Bandar_Seri_Begawan'. Exceptions: see the discussion - of legacy names below. - A name must not be empty, or contain '//', or start or end with '/'. - Do not use names that differ only in case. Although the reference - implementation is case-sensitive, some other implementations - are not, and they would mishandle names differing only in case. - If one name A is an initial prefix of another name AB (ignoring case), - then B must not start with '/', as a regular file cannot have - the same name as a directory in POSIX. For example, - 'America/New_York' precludes 'America/New_York/Bronx'. - Uninhabited regions like the North Pole and Bouvet Island - do not need locations, since local time is not defined there. - There should typically be at least one name for each ISO 3166-1 - officially assigned two-letter code for an inhabited country - or territory. - If all the clocks in a region have agreed since 1970, - don't bother to include more than one location - even if subregions' clocks disagreed before 1970. - Otherwise these tables would become annoyingly large. - If a name is ambiguous, use a less ambiguous alternative; - e.g. many cities are named San José and Georgetown, so - prefer 'Costa_Rica' to 'San_Jose' and 'Guyana' to 'Georgetown'. - Keep locations compact. Use cities or small islands, not countries - or regions, so that any future time zone changes do not split - locations into different time zones. E.g. prefer 'Paris' - to 'France', since France has had multiple time zones. - Use mainstream English spelling, e.g. prefer 'Rome' to 'Roma', and - prefer 'Athens' to the Greek 'Αθήνα' or the Romanized 'AthÃna'. - The POSIX file name restrictions encourage this rule. - Use the most populous among locations in a zone, - e.g. prefer 'Shanghai' to 'Beijing'. Among locations with - similar populations, pick the best-known location, - e.g. prefer 'Rome' to 'Milan'. - Use the singular form, e.g. prefer 'Canary' to 'Canaries'. - Omit common suffixes like '_Islands' and '_City', unless that - would lead to ambiguity. E.g. prefer 'Cayman' to - 'Cayman_Islands' and 'Guatemala' to 'Guatemala_City', - but prefer 'Mexico_City' to 'Mexico' because the country - of Mexico has several time zones. - Use '_' to represent a space. - Omit '.' from abbreviations in names, e.g. prefer 'St_Helena' - to 'St._Helena'. - Do not change established names if they only marginally - violate the above rules. For example, don't change - the existing name 'Rome' to 'Milan' merely because - Milan's population has grown to be somewhat greater - than Rome's. - If a name is changed, put its old spelling in the 'backward' file. - This means old spellings will continue to work. - -The file 'zone1970.tab' lists geographical locations used to name time -zone rules. It is intended to be an exhaustive list of names for -geographic regions as described above; this is a subset of the names -in the data. Although a 'zone1970.tab' location's longitude -corresponds to its LMT offset with one hour for every 15 degrees east -longitude, this relationship is not exact. - -Older versions of this package used a different naming scheme, -and these older names are still supported. -See the file 'backward' for most of these older names -(e.g., 'US/Eastern' instead of 'America/New_York'). -The other old-fashioned names still supported are -'WET', 'CET', 'MET', and 'EET' (see the file 'europe'). - -Older versions of this package defined legacy names that are -incompatible with the first rule of location names, but which are -still supported. These legacy names are mostly defined in the file -'etcetera'. Also, the file 'backward' defines the legacy names -'GMT0', 'GMT-0', 'GMT+0' and 'Canada/East-Saskatchewan', and the file -'northamerica' defines the legacy names 'EST5EDT', 'CST6CDT', -'MST7MDT', and 'PST8PDT'. - -Excluding 'backward' should not affect the other data. If -'backward' is excluded, excluding 'etcetera' should not affect the -remaining data. - - ------ Time zone abbreviations ----- - -When this package is installed, it generates time zone abbreviations -like 'EST' to be compatible with human tradition and POSIX. -Here are the general rules used for choosing time zone abbreviations, -in decreasing order of importance: - - Use three or more characters that are ASCII alphanumerics or '+' or '-'. - Previous editions of this database also used characters like - ' ' and '?', but these characters have a special meaning to - the shell and cause commands like - set `date` - to have unexpected effects. - Previous editions of this rule required upper-case letters, - but the Congressman who introduced Chamorro Standard Time - preferred "ChST", so lower-case letters are now allowed. - Also, POSIX from 2001 on relaxed the rule to allow '-', '+', - and alphanumeric characters from the portable character set - in the current locale. In practice ASCII alphanumerics and - '+' and '-' are safe in all locales. - - In other words, in the C locale the POSIX extended regular - expression [-+[:alnum:]]{3,} should match the abbreviation. - This guarantees that all abbreviations could have been - specified by a POSIX TZ string. - - Use abbreviations that are in common use among English-speakers, - e.g. 'EST' for Eastern Standard Time in North America. - We assume that applications translate them to other languages - as part of the normal localization process; for example, - a French application might translate 'EST' to 'HNE'. - - For zones whose times are taken from a city's longitude, use the - traditional xMT notation, e.g. 'PMT' for Paris Mean Time. - The only name like this in current use is 'GMT'. - - Use 'LMT' for local mean time of locations before the introduction - of standard time; see "Scope of the tz database". - - If there is no common English abbreviation, use numeric offsets like - -05 and +0830 that are generated by zic's %z notation. - - Use current abbreviations for older timestamps to avoid confusion. - For example, in 1910 a common English abbreviation for UT +01 - in central Europe was 'MEZ' (short for both "Middle European - Zone" and for "Mitteleuropäische Zeit" in German). Nowadays - 'CET' ("Central European Time") is more common in English, and - the database uses 'CET' even for circa-1910 timestamps as this - is less confusing for modern users and avoids the need for - determining when 'CET' supplanted 'MEZ' in common usage. - - Use a consistent style in a zone's history. For example, if a zone's - history tends to use numeric abbreviations and a particular - entry could go either way, use a numeric abbreviation. - - [The remaining guidelines predate the introduction of %z. - They are problematic as they mean tz data entries invent - notation rather than record it. These guidelines are now - deprecated and the plan is to gradually move to %z for - inhabited locations and to "-00" for uninhabited locations.] - - If there is no common English abbreviation, abbreviate the English - translation of the usual phrase used by native speakers. - If this is not available or is a phrase mentioning the country - (e.g. "Cape Verde Time"), then: - - When a country is identified with a single or principal zone, - append 'T' to the country's ISO code, e.g. 'CVT' for - Cape Verde Time. For summer time append 'ST'; - for double summer time append 'DST'; etc. - Otherwise, take the first three letters of an English place - name identifying each zone and append 'T', 'ST', etc. - as before; e.g. 'CHAST' for CHAtham Summer Time. - - Use UT (with time zone abbreviation '-00') for locations while - uninhabited. The leading '-' is a flag that the time - zone is in some sense undefined; this notation is - derived from Internet RFC 3339. - -Application writers should note that these abbreviations are ambiguous -in practice: e.g. 'CST' has a different meaning in China than -it does in the United States. In new applications, it's often better -to use numeric UT offsets like '-0600' instead of time zone -abbreviations like 'CST'; this avoids the ambiguity. - - ------ Accuracy of the tz database ----- - -The tz database is not authoritative, and it surely has errors. -Corrections are welcome and encouraged; see the file CONTRIBUTING. -Users requiring authoritative data should consult national standards -bodies and the references cited in the database's comments. - -Errors in the tz database arise from many sources: - - * The tz database predicts future time stamps, and current predictions - will be incorrect after future governments change the rules. - For example, if today someone schedules a meeting for 13:00 next - October 1, Casablanca time, and tomorrow Morocco changes its - daylight saving rules, software can mess up after the rule change - if it blithely relies on conversions made before the change. - - * The pre-1970 entries in this database cover only a tiny sliver of how - clocks actually behaved; the vast majority of the necessary - information was lost or never recorded. Thousands more zones would - be needed if the tz database's scope were extended to cover even - just the known or guessed history of standard time; for example, - the current single entry for France would need to split into dozens - of entries, perhaps hundreds. And in most of the world even this - approach would be misleading due to widespread disagreement or - indifference about what times should be observed. In her 2015 book - "The Global Transformation of Time, 1870-1950", Vanessa Ogle writes - "Outside of Europe and North America there was no system of time - zones at all, often not even a stable landscape of mean times, - prior to the middle decades of the twentieth century". See: - Timothy Shenk, Booked: A Global History of Time. Dissent 2015-12-17 - https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanessa-ogle - - * Most of the pre-1970 data entries come from unreliable sources, often - astrology books that lack citations and whose compilers evidently - invented entries when the true facts were unknown, without - reporting which entries were known and which were invented. - These books often contradict each other or give implausible entries, - and on the rare occasions when they are checked they are - typically found to be incorrect. - - * For the UK the tz database relies on years of first-class work done by - Joseph Myers and others; see <http://www.polyomino.org.uk/british-time/>. - Other countries are not done nearly as well. - - * Sometimes, different people in the same city would maintain clocks - that differed significantly. Railway time was used by railroad - companies (which did not always agree with each other), - church-clock time was used for birth certificates, etc. - Often this was merely common practice, but sometimes it was set by law. - For example, from 1891 to 1911 the UT offset in France was legally - 0:09:21 outside train stations and 0:04:21 inside. - - * Although a named location in the tz database stands for the - containing region, its pre-1970 data entries are often accurate for - only a small subset of that region. For example, Europe/London - stands for the United Kingdom, but its pre-1847 times are valid - only for locations that have London's exact meridian, and its 1847 - transition to GMT is known to be valid only for the L&NW and the - Caledonian railways. - - * The tz database does not record the earliest time for which a zone's - data entries are thereafter valid for every location in the region. - For example, Europe/London is valid for all locations in its - region after GMT was made the standard time, but the date of - standardization (1880-08-02) is not in the tz database, other than - in commentary. For many zones the earliest time of validity is - unknown. - - * The tz database does not record a region's boundaries, and in many - cases the boundaries are not known. For example, the zone - America/Kentucky/Louisville represents a region around the city of - Louisville, the boundaries of which are unclear. - - * Changes that are modeled as instantaneous transitions in the tz - database were often spread out over hours, days, or even decades. - - * Even if the time is specified by law, locations sometimes - deliberately flout the law. - - * Early timekeeping practices, even assuming perfect clocks, were - often not specified to the accuracy that the tz database requires. - - * Sometimes historical timekeeping was specified more precisely - than what the tz database can handle. For example, from 1909 to - 1937 Netherlands clocks were legally UT +00:19:32.13, but the tz - database cannot represent the fractional second. - - * Even when all the timestamp transitions recorded by the tz database - are correct, the tz rules that generate them may not faithfully - reflect the historical rules. For example, from 1922 until World - War II the UK moved clocks forward the day following the third - Saturday in April unless that was Easter, in which case it moved - clocks forward the previous Sunday. Because the tz database has no - way to specify Easter, these exceptional years are entered as - separate tz Rule lines, even though the legal rules did not change. - - * The tz database models pre-standard time using the proleptic Gregorian - calendar and local mean time (LMT), but many people used other - calendars and other timescales. For example, the Roman Empire used - the Julian calendar, and had 12 varying-length daytime hours with a - non-hour-based system at night. - - * Early clocks were less reliable, and data entries do not represent - clock error. - - * The tz database assumes Universal Time (UT) as an origin, even - though UT is not standardized for older time stamps. In the tz - database commentary, UT denotes a family of time standards that - includes Coordinated Universal Time (UTC) along with other variants - such as UT1 and GMT, with days starting at midnight. Although UT - equals UTC for modern time stamps, UTC was not defined until 1960, - so commentary uses the more-general abbreviation UT for time stamps - that might predate 1960. Since UT, UT1, etc. disagree slightly, - and since pre-1972 UTC seconds varied in length, interpretation of - older time stamps can be problematic when subsecond accuracy is - needed. - - * Civil time was not based on atomic time before 1972, and we don't - know the history of earth's rotation accurately enough to map SI - seconds to historical solar time to more than about one-hour - accuracy. See: Stephenson FR, Morrison LV, Hohenkerk CY. - Measurement of the Earth's rotation: 720 BC to AD 2015. - Proc Royal Soc A. 2016 Dec 7;472:20160404. - http://dx.doi.org/10.1098/rspa.2016.0404 - Also see: Espenak F. Uncertainty in Delta T (ΔT). - http://eclipse.gsfc.nasa.gov/SEhelp/uncertainty2004.html - - * The relationship between POSIX time (that is, UTC but ignoring leap - seconds) and UTC is not agreed upon after 1972. Although the POSIX - clock officially stops during an inserted leap second, at least one - proposed standard has it jumping back a second instead; and in - practice POSIX clocks more typically either progress glacially during - a leap second, or are slightly slowed while near a leap second. - - * The tz database does not represent how uncertain its information is. - Ideally it would contain information about when data entries are - incomplete or dicey. Partial temporal knowledge is a field of - active research, though, and it's not clear how to apply it here. - -In short, many, perhaps most, of the tz database's pre-1970 and future -time stamps are either wrong or misleading. Any attempt to pass the -tz database off as the definition of time should be unacceptable to -anybody who cares about the facts. In particular, the tz database's -LMT offsets should not be considered meaningful, and should not prompt -creation of zones merely because two locations differ in LMT or -transitioned to standard time at different dates. - - ------ Time and date functions ----- - -The tz code contains time and date functions that are upwards -compatible with those of POSIX. - -POSIX has the following properties and limitations. - -* In POSIX, time display in a process is controlled by the - environment variable TZ. Unfortunately, the POSIX TZ string takes - a form that is hard to describe and is error-prone in practice. - Also, POSIX TZ strings can't deal with other (for example, Israeli) - daylight saving time rules, or situations where more than two - time zone abbreviations are used in an area. - - The POSIX TZ string takes the following form: - - stdoffset[dst[offset][,date[/time],date[/time]]] - - where: - - std and dst - are 3 or more characters specifying the standard - and daylight saving time (DST) zone names. - Starting with POSIX.1-2001, std and dst may also be - in a quoted form like "<UTC+10>"; this allows - "+" and "-" in the names. - offset - is of the form '[+-]hh:[mm[:ss]]' and specifies the - offset west of UT. 'hh' may be a single digit; 0<=hh<=24. - The default DST offset is one hour ahead of standard time. - date[/time],date[/time] - specifies the beginning and end of DST. If this is absent, - the system supplies its own rules for DST, and these can - differ from year to year; typically US DST rules are used. - time - takes the form 'hh:[mm[:ss]]' and defaults to 02:00. - This is the same format as the offset, except that a - leading '+' or '-' is not allowed. - date - takes one of the following forms: - Jn (1<=n<=365) - origin-1 day number not counting February 29 - n (0<=n<=365) - origin-0 day number counting February 29 if present - Mm.n.d (0[Sunday]<=d<=6[Saturday], 1<=n<=5, 1<=m<=12) - for the dth day of week n of month m of the year, - where week 1 is the first week in which day d appears, - and '5' stands for the last week in which day d appears - (which may be either the 4th or 5th week). - Typically, this is the only useful form; - the n and Jn forms are rarely used. - - Here is an example POSIX TZ string, for US Pacific time using rules - appropriate from 1987 through 2006: - - TZ='PST8PDT,M4.1.0/02:00,M10.5.0/02:00' - - This POSIX TZ string is hard to remember, and mishandles time stamps - before 1987 and after 2006. With this package you can use this - instead: - - TZ='America/Los_Angeles' - -* POSIX does not define the exact meaning of TZ values like "EST5EDT". - Typically the current US DST rules are used to interpret such values, - but this means that the US DST rules are compiled into each program - that does time conversion. This means that when US time conversion - rules change (as in the United States in 1987), all programs that - do time conversion must be recompiled to ensure proper results. - -* The TZ environment variable is process-global, which makes it hard - to write efficient, thread-safe applications that need access - to multiple time zones. - -* In POSIX, there's no tamper-proof way for a process to learn the - system's best idea of local wall clock. (This is important for - applications that an administrator wants used only at certain times - - without regard to whether the user has fiddled the "TZ" environment - variable. While an administrator can "do everything in UTC" to get - around the problem, doing so is inconvenient and precludes handling - daylight saving time shifts - as might be required to limit phone - calls to off-peak hours.) - -* POSIX provides no convenient and efficient way to determine the UT - offset and time zone abbreviation of arbitrary time stamps, - particularly for time zone settings that do not fit into the - POSIX model. - -* POSIX requires that systems ignore leap seconds. - -* The tz code attempts to support all the time_t implementations - allowed by POSIX. The time_t type represents a nonnegative count of - seconds since 1970-01-01 00:00:00 UTC, ignoring leap seconds. - In practice, time_t is usually a signed 64- or 32-bit integer; 32-bit - signed time_t values stop working after 2038-01-19 03:14:07 UTC, so - new implementations these days typically use a signed 64-bit integer. - Unsigned 32-bit integers are used on one or two platforms, - and 36-bit and 40-bit integers are also used occasionally. - Although earlier POSIX versions allowed time_t to be a - floating-point type, this was not supported by any practical - systems, and POSIX.1-2013 and the tz code both require time_t - to be an integer type. - -These are the extensions that have been made to the POSIX functions: - -* The "TZ" environment variable is used in generating the name of a file - from which time zone information is read (or is interpreted a la - POSIX); "TZ" is no longer constrained to be a three-letter time zone - name followed by a number of hours and an optional three-letter - daylight time zone name. The daylight saving time rules to be used - for a particular time zone are encoded in the time zone file; - the format of the file allows U.S., Australian, and other rules to be - encoded, and allows for situations where more than two time zone - abbreviations are used. - - It was recognized that allowing the "TZ" environment variable to - take on values such as "America/New_York" might cause "old" programs - (that expect "TZ" to have a certain form) to operate incorrectly; - consideration was given to using some other environment variable - (for example, "TIMEZONE") to hold the string used to generate the - time zone information file name. In the end, however, it was decided - to continue using "TZ": it is widely used for time zone purposes; - separately maintaining both "TZ" and "TIMEZONE" seemed a nuisance; - and systems where "new" forms of "TZ" might cause problems can simply - use TZ values such as "EST5EDT" which can be used both by - "new" programs (a la POSIX) and "old" programs (as zone names and - offsets). - -* The code supports platforms with a UT offset member in struct tm, - e.g., tm_gmtoff. - -* The code supports platforms with a time zone abbreviation member in - struct tm, e.g., tm_zone. - -* Since the "TZ" environment variable can now be used to control time - conversion, the "daylight" and "timezone" variables are no longer - needed. (These variables are defined and set by "tzset"; however, their - values will not be used by "localtime.") - -* Functions tzalloc, tzfree, localtime_rz, and mktime_z for - more-efficient thread-safe applications that need to use - multiple time zones. The tzalloc and tzfree functions - allocate and free objects of type timezone_t, and localtime_rz - and mktime_z are like localtime_r and mktime with an extra - timezone_t argument. The functions were inspired by NetBSD. - -* A function "tzsetwall" has been added to arrange for the system's - best approximation to local wall clock time to be delivered by - subsequent calls to "localtime." Source code for portable - applications that "must" run on local wall clock time should call - "tzsetwall();" if such code is moved to "old" systems that don't - provide tzsetwall, you won't be able to generate an executable program. - (These time zone functions also arrange for local wall clock time to be - used if tzset is called - directly or indirectly - and there's no "TZ" - environment variable; portable applications should not, however, rely - on this behavior since it's not the way SVR2 systems behave.) - -* Negative time_t values are supported, on systems where time_t is signed. - -* These functions can account for leap seconds, thanks to Bradley White. - -Points of interest to folks with other systems: - -* Code compatible with this package is already part of many platforms, - including GNU/Linux, Android, the BSDs, Chromium OS, Cygwin, AIX, iOS, - BlackBery 10, macOS, Microsoft Windows, OpenVMS, and Solaris. - On such hosts, the primary use of this package - is to update obsolete time zone rule tables. - To do this, you may need to compile the time zone compiler - 'zic' supplied with this package instead of using the system 'zic', - since the format of zic's input is occasionally extended, - and a platform may still be shipping an older zic. - -* The UNIX Version 7 "timezone" function is not present in this package; - it's impossible to reliably map timezone's arguments (a "minutes west - of GMT" value and a "daylight saving time in effect" flag) to a - time zone abbreviation, and we refuse to guess. - Programs that in the past used the timezone function may now examine - tzname[localtime(&clock)->tm_isdst] to learn the correct time - zone abbreviation to use. Alternatively, use - localtime(&clock)->tm_zone if this has been enabled. - -* The 4.2BSD gettimeofday function is not used in this package. - This formerly let users obtain the current UTC offset and DST flag, - but this functionality was removed in later versions of BSD. - -* In SVR2, time conversion fails for near-minimum or near-maximum - time_t values when doing conversions for places that don't use UT. - This package takes care to do these conversions correctly. - A comment in the source code tells how to get compatibly wrong - results. - -The functions that are conditionally compiled if STD_INSPIRED is defined -should, at this point, be looked on primarily as food for thought. They are -not in any sense "standard compatible" - some are not, in fact, specified in -*any* standard. They do, however, represent responses of various authors to -standardization proposals. - -Other time conversion proposals, in particular the one developed by folks at -Hewlett Packard, offer a wider selection of functions that provide capabilities -beyond those provided here. The absence of such functions from this package -is not meant to discourage the development, standardization, or use of such -functions. Rather, their absence reflects the decision to make this package -contain valid extensions to POSIX, to ensure its broad acceptability. If -more powerful time conversion functions can be standardized, so much the -better. - - ------ Interface stability ----- - -The tz code and data supply the following interfaces: - - * A set of zone names as per "Names of time zone rules" above. - - * Library functions described in "Time and date functions" above. - - * The programs tzselect, zdump, and zic, documented in their man pages. - - * The format of zic input files, documented in the zic man page. - - * The format of zic output files, documented in the tzfile man page. - - * The format of zone table files, documented in zone1970.tab. - - * The format of the country code file, documented in iso3166.tab. - - * The version number of the code and data, as the first line of - the text file 'version' in each release. - -Interface changes in a release attempt to preserve compatibility with -recent releases. For example, tz data files typically do not rely on -recently-added zic features, so that users can run older zic versions -to process newer data files. The tz-link.htm file describes how -releases are tagged and distributed. - -Interfaces not listed above are less stable. For example, users -should not rely on particular UT offsets or abbreviations for time -stamps, as data entries are often based on guesswork and these guesses -may be corrected or improved. - - ------ Calendrical issues ----- - -Calendrical issues are a bit out of scope for a time zone database, -but they indicate the sort of problems that we would run into if we -extended the time zone database further into the past. An excellent -resource in this area is Nachum Dershowitz and Edward M. Reingold, -Calendrical Calculations: Third Edition, Cambridge University Press (2008) -<http://emr.cs.iit.edu/home/reingold/calendar-book/third-edition/>. -Other information and sources are given below. They sometimes disagree. - - -France - -Gregorian calendar adopted 1582-12-20. -French Revolutionary calendar used 1793-11-24 through 1805-12-31, -and (in Paris only) 1871-05-06 through 1871-05-23. - - -Russia - -From Chris Carrier (1996-12-02): -On 1929-10-01 the Soviet Union instituted an "Eternal Calendar" -with 30-day months plus 5 holidays, with a 5-day week. -On 1931-12-01 it changed to a 6-day week; in 1934 it reverted to the -Gregorian calendar while retaining the 6-day week; on 1940-06-27 it -reverted to the 7-day week. With the 6-day week the usual days -off were the 6th, 12th, 18th, 24th and 30th of the month. -(Source: Evitiar Zerubavel, _The Seven Day Circle_) - - -Mark Brader reported a similar story in "The Book of Calendars", edited -by Frank Parise (1982, Facts on File, ISBN 0-8719-6467-8), page 377. But: - -From: Petteri Sulonen (via Usenet) -Date: 14 Jan 1999 00:00:00 GMT -... - -If your source is correct, how come documents between 1929 and 1940 were -still dated using the conventional, Gregorian calendar? - -I can post a scan of a document dated December 1, 1934, signed by -Yenukidze, the secretary, on behalf of Kalinin, the President of the -Executive Committee of the Supreme Soviet, if you like. - - - -Sweden (and Finland) - -From: Mark Brader -Subject: Re: Gregorian reform - a part of locale? -<news:1996Jul6.012937.29190@sq.com> -Date: 1996-07-06 - -In 1700, Denmark made the transition from Julian to Gregorian. Sweden -decided to *start* a transition in 1700 as well, but rather than have one of -those unsightly calendar gaps :-), they simply decreed that the next leap -year after 1696 would be in 1744 - putting the whole country on a calendar -different from both Julian and Gregorian for a period of 40 years. - -However, in 1704 something went wrong and the plan was not carried through; -they did, after all, have a leap year that year. And one in 1708. In 1712 -they gave it up and went back to Julian, putting 30 days in February that -year!... - -Then in 1753, Sweden made the transition to Gregorian in the usual manner, -getting there only 13 years behind the original schedule. - -(A previous posting of this story was challenged, and Swedish readers -produced the following references to support it: "Tideräkning och historia" -by Natanael Beckman (1924) and "Tid, en bok om tideräkning och -kalenderväsen" by Lars-Olof Lodén (1968). - - -Grotefend's data - -From: "Michael Palmer" [with one obvious typo fixed] -Subject: Re: Gregorian Calendar (was Re: Another FHC related question -Newsgroups: soc.genealogy.german -Date: Tue, 9 Feb 1999 02:32:48 -800 -... - -The following is a(n incomplete) listing, arranged chronologically, of -European states, with the date they converted from the Julian to the -Gregorian calendar: - -04/15 Oct 1582 - Italy (with exceptions), Spain, Portugal, Poland (Roman - Catholics and Danzig only) -09/20 Dec 1582 - France, Lorraine - -21 Dec 1582/ - 01 Jan 1583 - Holland, Brabant, Flanders, Hennegau -10/21 Feb 1583 - bishopric of Liege (Lüttich) -13/24 Feb 1583 - bishopric of Augsburg -04/15 Oct 1583 - electorate of Trier -05/16 Oct 1583 - Bavaria, bishoprics of Freising, Eichstedt, Regensburg, - Salzburg, Brixen -13/24 Oct 1583 - Austrian Oberelsaß and Breisgau -20/31 Oct 1583 - bishopric of Basel -02/13 Nov 1583 - duchy of Jülich-Berg -02/13 Nov 1583 - electorate and city of Köln -04/15 Nov 1583 - bishopric of Würzburg -11/22 Nov 1583 - electorate of Mainz -16/27 Nov 1583 - bishopric of Strassburg and the margraviate of Baden -17/28 Nov 1583 - bishopric of Münster and duchy of Cleve -14/25 Dec 1583 - Steiermark - -06/17 Jan 1584 - Austria and Bohemia -11/22 Jan 1584 - Lucerne, Uri, Schwyz, Zug, Freiburg, Solothurn -12/23 Jan 1584 - Silesia and the Lausitz -22 Jan/ - 02 Feb 1584 - Hungary (legally on 21 Oct 1587) - Jun 1584 - Unterwalden -01/12 Jul 1584 - duchy of Westfalen - -16/27 Jun 1585 - bishopric of Paderborn - -14/25 Dec 1590 - Transylvania - -22 Aug/ - 02 Sep 1612 - duchy of Prussia - -13/24 Dec 1614 - Pfalz-Neuburg - - 1617 - duchy of Kurland (reverted to the Julian calendar in - 1796) - - 1624 - bishopric of Osnabrück - - 1630 - bishopric of Minden - -15/26 Mar 1631 - bishopric of Hildesheim - - 1655 - Kanton Wallis - -05/16 Feb 1682 - city of Strassburg - -18 Feb/ - 01 Mar 1700 - Protestant Germany (including Swedish possessions in - Germany), Denmark, Norway -30 Jun/ - 12 Jul 1700 - Gelderland, Zutphen -10 Nov/ - 12 Dec 1700 - Utrecht, Overijssel - -31 Dec 1700/ - 12 Jan 1701 - Friesland, Groningen, Zürich, Bern, Basel, Geneva, - Turgau, and Schaffhausen - - 1724 - Glarus, Appenzell, and the city of St. Gallen - -01 Jan 1750 - Pisa and Florence - -02/14 Sep 1752 - Great Britain - -17 Feb/ - 01 Mar 1753 - Sweden - -1760-1812 - Graubünden - -The Russian empire (including Finland and the Baltic states) did not -convert to the Gregorian calendar until the Soviet revolution of 1917. - -Source: H. Grotefend, _Taschenbuch der Zeitrechnung des deutschen -Mittelalters und der Neuzeit_, herausgegeben von Dr. O. Grotefend -(Hannover: Hahnsche Buchhandlung, 1941), pp. 26-28. - - ------ Time and time zones on Mars ----- - -Some people's work schedules use Mars time. Jet Propulsion Laboratory -(JPL) coordinators have kept Mars time on and off at least since 1997 -for the Mars Pathfinder mission. Some of their family members have -also adapted to Mars time. Dozens of special Mars watches were built -for JPL workers who kept Mars time during the Mars Exploration -Rovers mission (2004). These timepieces look like normal Seikos and -Citizens but use Mars seconds rather than terrestrial seconds. - -A Mars solar day is called a "sol" and has a mean period equal to -about 24 hours 39 minutes 35.244 seconds in terrestrial time. It is -divided into a conventional 24-hour clock, so each Mars second equals -about 1.02749125 terrestrial seconds. - -The prime meridian of Mars goes through the center of the crater -Airy-0, named in honor of the British astronomer who built the -Greenwich telescope that defines Earth's prime meridian. Mean solar -time on the Mars prime meridian is called Mars Coordinated Time (MTC). - -Each landed mission on Mars has adopted a different reference for -solar time keeping, so there is no real standard for Mars time zones. -For example, the Mars Exploration Rover project (2004) defined two -time zones "Local Solar Time A" and "Local Solar Time B" for its two -missions, each zone designed so that its time equals local true solar -time at approximately the middle of the nominal mission. Such a "time -zone" is not particularly suited for any application other than the -mission itself. - -Many calendars have been proposed for Mars, but none have achieved -wide acceptance. Astronomers often use Mars Sol Date (MSD) which is a -sequential count of Mars solar days elapsed since about 1873-12-29 -12:00 GMT. - -The tz database does not currently support Mars time, but it is -documented here in the hopes that support will be added eventually. - -Sources: - -Michael Allison and Robert Schmunk, -"Technical Notes on Mars Solar Time as Adopted by the Mars24 Sunclock" -<http://www.giss.nasa.gov/tools/mars24/help/notes.html> (2012-08-08). - -Jia-Rui Chong, "Workdays Fit for a Martian", Los Angeles Times -<http://articles.latimes.com/2004/jan/14/science/sci-marstime14> -(2004-01-14), pp A1, A20-A21. - -Tom Chmielewski, "Jet Lag Is Worse on Mars", The Atlantic (2015-02-26) -<http://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/> - ------ - -This file is in the public domain, so clarified as of 2009-05-17 by -Arthur David Olson. - ------ -Local Variables: -coding: utf-8 -End: diff --git contrib/tzdata/africa contrib/tzdata/africa index dcc20b9b1c33..3a60bc27d02c 100644 --- contrib/tzdata/africa +++ contrib/tzdata/africa @@ -26,7 +26,7 @@ # # For data circa 1899, a common source is: # Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94. -# http://www.jstor.org/stable/1774359 +# https://www.jstor.org/stable/1774359 # # A reliable and entertaining source about time zones is # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). @@ -218,7 +218,7 @@ Rule Egypt 2006 only - Sep 21 24:00 0 - # saving time in Egypt will end in the night of 2007-09-06 to 2007-09-07. # From Jesper Nørgaard Welen (2007-08-15): [The following agree:] # http://www.nentjes.info/Bill/bill5.htm -# http://www.timeanddate.com/worldclock/city.html?n=53 +# https://www.timeanddate.com/worldclock/city.html?n=53 # From Steffen Thorsen (2007-09-04): The official information...: # http://www.sis.gov.eg/En/EgyptOnline/Miscellaneous/000002/0207000000000000001580.htm Rule Egypt 2007 only - Sep Thu>=1 24:00 0 - @@ -256,8 +256,8 @@ Rule Egypt 2007 only - Sep Thu>=1 24:00 0 - # timeanddate[2] and another site I've found[3] also support that. # # [1] https://bugzilla.redhat.com/show_bug.cgi?id=492263 -# [2] http://www.timeanddate.com/worldclock/clockchange.html?n=53 -# [3] http://wwp.greenwichmeantime.com/time-zone/africa/egypt/ +# [2] https://www.timeanddate.com/worldclock/clockchange.html?n=53 +# [3] https://wwp.greenwichmeantime.com/time-zone/africa/egypt/ # From Arthur David Olson (2009-04-20): # In 2009 (and for the next several years), Ramadan ends before the fourth @@ -267,10 +267,10 @@ Rule Egypt 2007 only - Sep Thu>=1 24:00 0 - # From Steffen Thorsen (2009-08-11): # We have been able to confirm the August change with the Egyptian Cabinet # Information and Decision Support Center: -# http://www.timeanddate.com/news/time/egypt-dst-ends-2009.html +# https://www.timeanddate.com/news/time/egypt-dst-ends-2009.html # # The Middle East News Agency -# http://www.mena.org.eg/index.aspx +# https://www.mena.org.eg/index.aspx # also reports "Egypt starts winter time on August 21" # today in article numbered "71, 11/08/2009 12:25 GMT." # Only the title above is available without a subscription to their service, @@ -320,7 +320,7 @@ Rule Egypt 2007 only - Sep Thu>=1 24:00 0 - # Thursday of April.... Clocks will still be turned back for Ramadan, but # dates not yet announced.... # http://almogaz.com/news/weird-news/2015/04/05/1947105 ... -# http://www.timeanddate.com/news/time/egypt-starts-dst-2015.html +# https://www.timeanddate.com/news/time/egypt-starts-dst-2015.html # From Ahmed Nazmy (2015-04-20): # Egypt's ministers cabinet just announced ... that it will cancel DST at @@ -447,11 +447,11 @@ Zone Africa/Monrovia -0:43:08 - LMT 1882 # From Even Scharning (2012-11-10): # Libya set their time one hour back at 02:00 on Saturday November 10. -# http://www.libyaherald.com/2012/11/04/clocks-to-go-back-an-hour-on-saturday/ +# https://www.libyaherald.com/2012/11/04/clocks-to-go-back-an-hour-on-saturday/ # Here is an official source [in Arabic]: http://ls.ly/fb6Yc # # Steffen Thorsen forwarded a translation (2012-11-10) in -# http://mm.icann.org/pipermail/tz/2012-November/018451.html +# https://mm.icann.org/pipermail/tz/2012-November/018451.html # # From Tim Parenti (2012-11-11): # Treat the 2012-11-10 change as a zone change from UTC+2 to UTC+1. @@ -462,7 +462,7 @@ Zone Africa/Monrovia -0:43:08 - LMT 1882 # From Even Scharning (2013-10-25): # The scheduled end of DST in Libya on Friday, October 25, 2013 was # cancelled yesterday.... -# http://www.libyaherald.com/2013/10/24/correction-no-time-change-tomorrow/ +# https://www.libyaherald.com/2013/10/24/correction-no-time-change-tomorrow/ # # From Paul Eggert (2013-10-25): # For now, assume they're reverting to the pre-2012 rules of permanent UT +02. @@ -515,7 +515,7 @@ Zone Africa/Tripoli 0:52:44 - LMT 1920 # basis.... # It seems that Mauritius observed daylight saving time from 1982-10-10 to # 1983-03-20 as well, but that was not successful.... -# http://www.timeanddate.com/news/time/mauritius-daylight-saving-time.html +# https://www.timeanddate.com/news/time/mauritius-daylight-saving-time.html # From Alex Krivenyshev (2008-06-25): # http://economicdevelopment.gov.mu/portal/site/Mainhomepage/menuitem.a42b24128104d9845dabddd154508a0c/?content_id=0a7cee8b5d69a110VgnVCM1000000a04a8c0RCRD @@ -583,7 +583,7 @@ Zone Africa/Tripoli 0:52:44 - LMT 1920 # http://lexpress.mu/Story/3398~Beebeejaun---Les-objectifs-d-%C3%A9conomie-d-%C3%A9nergie-de-l-heure-d-%C3%A9t%C3%A9-ont-%C3%A9t%C3%A9-atteints- # # Our wrap-up: -# http://www.timeanddate.com/news/time/mauritius-dst-will-not-repeat.html +# https://www.timeanddate.com/news/time/mauritius-dst-will-not-repeat.html # From Arthur David Olson (2009-07-11): # The "mauritius-dst-will-not-repeat" wrapup includes this: @@ -615,7 +615,7 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # be one hour ahead of GMT between 1 June and 27 September, according to # Communication Minister and Government Spokesman, Khalid Naciri...." # -# http://www.worldtimezone.net/dst_news/dst_news_morocco01.html +# http://www.worldtimezone.com/dst_news/dst_news_morocco01.html # http://en.afrik.com/news11892.html # From Alex Krivenyshev (2008-05-09): @@ -628,7 +628,7 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # From Patrice Scattolin (2008-05-09): # According to this article: -# http://www.avmaroc.com/actualite/heure-dete-comment-a127896.html +# https://www.avmaroc.com/actualite/heure-dete-comment-a127896.html # (and republished here: <http://www.actu.ma/heure-dete-comment_i127896_0.html>) # the changes occur at midnight: # @@ -650,7 +650,7 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # posted in English). # # The following Google query will generate many relevant hits: -# http://www.google.com/search?hl=en&q=Conseil+de+gouvernement+maroc+heure+avance&btnG=Search +# https://www.google.com/search?hl=en&q=Conseil+de+gouvernement+maroc+heure+avance&btnG=Search # From Steffen Thorsen (2008-08-27): # Morocco will change the clocks back on the midnight between August 31 @@ -661,7 +661,7 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # http://www.menara.ma/fr/Actualites/Maroc/Societe/ci.retour_a_l_heure_gmt_a_partir_du_dimanche_31_aout_a_minuit_officiel_.default # # We have some further details posted here: -# http://www.timeanddate.com/news/time/morocco-ends-dst-early-2008.html +# https://www.timeanddate.com/news/time/morocco-ends-dst-early-2008.html # From Steffen Thorsen (2009-03-17): # Morocco will observe DST from 2009-06-01 00:00 to 2009-08-21 00:00 according @@ -671,7 +671,7 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # (French) # # Our summary: -# http://www.timeanddate.com/news/time/morocco-starts-dst-2009.html +# https://www.timeanddate.com/news/time/morocco-starts-dst-2009.html # From Alexander Krivenyshev (2009-03-17): # Here is a link to official document from Royaume du Maroc Premier Ministre, @@ -694,7 +694,7 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # http://www.lavieeco.com/actualites/4099-le-maroc-passera-a-l-heure-d-ete-gmt1-le-2-mai.html # (French) # Our page: -# http://www.timeanddate.com/news/time/morocco-starts-dst-2010.html +# https://www.timeanddate.com/news/time/morocco-starts-dst-2010.html # From Dan Abitol (2011-03-30): # ...Rules for Africa/Casablanca are the following (24h format) @@ -711,7 +711,7 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # They said that the decision was already taken. # # More articles in the press -# http://www.yabiladi.com/articles/details/5058/secret-l-heure-d-ete-maroc-leve.html +# https://www.yabiladi.com/articles/details/5058/secret-l-heure-d-ete-maroc-leve.html # http://www.lematin.ma/Actualite/Express/Article.asp?id=148923 # http://www.lavieeco.com/actualite/Le-Maroc-passe-sur-GMT%2B1-a-partir-de-dim @@ -803,7 +803,7 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # 1433 (18 April 2012) and the decision of the Head of Government of # 16 N. 3-29-15 Chaaban 1435 (4 June 2015). # Source (french): -# http://lnt.ma/le-maroc-reculera-dune-heure-le-dimanche-14-juin/ +# https://lnt.ma/le-maroc-reculera-dune-heure-le-dimanche-14-juin/ # # From Milamber (2015-06-09): # http://www.mmsp.gov.ma/fr/actualites.aspx?id=863 @@ -812,7 +812,7 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # [The gov.ma announcement] would (probably) make the switch on 2015-07-19 go # from 03:00 to 04:00 rather than from 02:00 to 03:00, as in the patch.... # I think the patch is correct and the quoted text is wrong; the text in -# <http://lnt.ma/le-maroc-reculera-dune-heure-le-dimanche-14-juin/> agrees +# <https://lnt.ma/le-maroc-reculera-dune-heure-le-dimanche-14-juin/> agrees # with the patch. # From Paul Eggert (2015-06-08): @@ -937,9 +937,17 @@ Link Africa/Maputo Africa/Kigali # Rwanda Link Africa/Maputo Africa/Lubumbashi # E Dem. Rep. of Congo Link Africa/Maputo Africa/Lusaka # Zambia + # Namibia -# The 1994-04-03 transition is from Shanks & Pottenger. -# Shanks & Pottenger report no DST after 1998-04; go with IATA. + +# From Arthur David Olson (2017-08-09): +# The text of the "Namibia Time Act, 1994" is available online at +# www.lac.org.na/laws/1994/811.pdf +# and includes this nugget: +# Notwithstanding the provisions of subsection (2) of section 1, the +# first winter period after the commencement of this Act shall +# commence at OOhOO on Monday 21 March 1994 and shall end at 02h00 on +# Sunday 4 September 1994. # From Petronella Sibeene (2007-03-30): # http://allafrica.com/stories/200703300178.html @@ -955,19 +963,30 @@ Link Africa/Maputo Africa/Lusaka # Zambia # observes Botswana time, we have no details about historical practice. # In the meantime people there can use Africa/Gaborone. # See: Immanuel S. The Namibian. 2017-02-23. -# http://www.namibian.com.na/51480/read/Time-change-divides-lawmakers +# https://www.namibian.com.na/51480/read/Time-change-divides-lawmakers + +# From Steffen Thorsen (2017-08-09): +# Namibia is going to change their time zone to what is now their DST: +# https://www.newera.com.na/2017/02/23/namibias-winter-time-might-be-repealed/ +# This video is from the government decision: +# https://www.nbc.na/news/na-passes-namibia-time-bill-repealing-1994-namibia-time-act.8665 +# We have made the assumption so far that they will change their time zone at +# the same time they would normally start DST, the first Sunday in September: +# https://www.timeanddate.com/news/time/namibia-new-time-zone.html # RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Namibia 1994 max - Sep Sun>=1 2:00 1:00 S -Rule Namibia 1995 max - Apr Sun>=1 2:00 0 - +Rule Namibia 1994 only - Mar 21 0:00 0 - +Rule Namibia 1994 2016 - Sep Sun>=1 2:00 1:00 S +Rule Namibia 1995 2017 - Apr Sun>=1 2:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Africa/Windhoek 1:08:24 - LMT 1892 Feb 8 1:30 - +0130 1903 Mar 2:00 - SAST 1942 Sep 20 2:00 2:00 1:00 SAST 1943 Mar 21 2:00 2:00 - SAST 1990 Mar 21 # independence - 2:00 - CAT 1994 Apr 3 - 1:00 Namibia WA%sT + 2:00 - CAT 1994 Mar 21 0:00 + 1:00 Namibia WA%sT 2017 Sep 3 2:00 + 2:00 - CAT # Niger # See Africa/Lagos. @@ -1054,14 +1073,24 @@ Link Africa/Johannesburg Africa/Mbabane # Swaziland # no information # Sudan -# + # From <http://www.sunanews.net/sn13jane.html> # Sudan News Agency (2000-01-13), # also reported by Michaël De Beukelaer-Dossche via Steffen Thorsen: # Clocks will be moved ahead for 60 minutes all over the Sudan as of noon # Saturday.... This was announced Thursday by Caretaker State Minister for # Manpower Abdul-Rahman Nur-Eddin. + +# From Ahmed Atyya, National Telecommunications Corp. (NTC), Sudan (2017-10-17): +# ... the Republic of Sudan is going to change the time zone from (GMT+3:00) +# to (GMT+ 2:00) starting from Wednesday 1 November 2017. # +# From Paul Eggert (2017-10-18): +# A scanned copy (in Arabic) of Cabinet Resolution No. 352 for the +# year 2017 can be found as an attachment in email today from Yahia +# Abdalla of NTC, archived at: +# https://mm.icann.org/pipermail/tz/2017-October/025333.html + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Sudan 1970 only - May 1 0:00 1:00 S Rule Sudan 1970 1985 - Oct 15 0:00 0 - @@ -1070,10 +1099,14 @@ Rule Sudan 1972 1985 - Apr lastSun 0:00 1:00 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Africa/Khartoum 2:10:08 - LMT 1931 2:00 Sudan CA%sT 2000 Jan 15 12:00 - 3:00 - EAT + 3:00 - EAT 2017 Nov 1 + 2:00 - CAT # South Sudan -Link Africa/Khartoum Africa/Juba +# Zone NAME GMTOFF RULES FORMAT [UNTIL] +Zone Africa/Juba 2:06:28 - LMT 1931 + 2:00 Sudan CA%sT 2000 Jan 15 12:00 + 3:00 - EAT # Swaziland # See Africa/Johannesburg. @@ -1111,11 +1144,11 @@ Link Africa/Khartoum Africa/Juba # According to several news sources, Tunisia will not observe DST this year. # (Arabic) # http://www.elbashayer.com/?page=viewn&nid=42546 -# http://www.babnet.net/kiwidetail-15295.asp +# https://www.babnet.net/kiwidetail-15295.asp # # We have also confirmed this with the US embassy in Tunisia. # We have a wrap-up about this on the following page: -# http://www.timeanddate.com/news/time/tunisia-cancels-dst-2009.html +# https://www.timeanddate.com/news/time/tunisia-cancels-dst-2009.html # From Alexander Krivenyshev (2009-03-17): # Here is a link to Tunis Afrique Presse News Agency diff --git contrib/tzdata/antarctica contrib/tzdata/antarctica index 3332d6684252..d9c132a30f45 100644 --- contrib/tzdata/antarctica +++ contrib/tzdata/antarctica @@ -26,7 +26,7 @@ # Heard Island, McDonald Islands (uninhabited) # previously sealers and scientific personnel wintered # Margaret Turner reports -# http://web.archive.org/web/20021204222245/http://www.dstc.qut.edu.au/DST/marg/daylight.html +# https://web.archive.org/web/20021204222245/http://www.dstc.qut.edu.au/DST/marg/daylight.html # (1999-09-30) that they're UT +05, with no DST; # presumably this is when they have visitors. # @@ -47,7 +47,7 @@ # http://www.aad.gov.au/default.asp?casid=37079 # # We have more background information here: -# http://www.timeanddate.com/news/time/antarctica-new-times.html +# https://www.timeanddate.com/news/time/antarctica-new-times.html # From Steffen Thorsen (2010-03-10): # We got these changes from the Australian Antarctic Division: ... @@ -62,7 +62,7 @@ # - Mawson station stays on UTC+5. # # Background: -# http://www.timeanddate.com/news/time/antartica-time-changes-2010.html +# https://www.timeanddate.com/news/time/antartica-time-changes-2010.html # From Steffen Thorsen (2016-10-28): # Australian Antarctica Division informed us that Casey changed time @@ -145,7 +145,7 @@ Zone Indian/Kerguelen 0 - -00 1950 # Port-aux-Français # # year-round base in the main continent # Dumont d'Urville, ÃŽle des Pétrels, -6640+14001, since 1956-11 -# <http://en.wikipedia.org/wiki/Dumont_d'Urville_Station> (2005-12-05) +# <https://en.wikipedia.org/wiki/Dumont_d'Urville_Station> (2005-12-05) # # Another base at Port-Martin, 50km east, began operation in 1947. # It was destroyed by fire on 1952-01-14. diff --git contrib/tzdata/asia contrib/tzdata/asia index 35774c6d7edd..ac39af351ecd 100644 --- contrib/tzdata/asia +++ contrib/tzdata/asia @@ -26,7 +26,7 @@ # # For data circa 1899, a common source is: # Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94. -# http://www.jstor.org/stable/1774359 +# https://www.jstor.org/stable/1774359 # # For Russian data circa 1919, a source is: # Byalokoz EL. New Counting of Time in Russia since July 1, 1919. @@ -75,8 +75,8 @@ Rule E-EurAsia 1996 max - Oct lastSun 0:00 0 - Rule RussiaAsia 1981 1984 - Apr 1 0:00 1:00 S Rule RussiaAsia 1981 1983 - Oct 1 0:00 0 - Rule RussiaAsia 1984 1995 - Sep lastSun 2:00s 0 - -Rule RussiaAsia 1985 2011 - Mar lastSun 2:00s 1:00 S -Rule RussiaAsia 1996 2011 - Oct lastSun 2:00s 0 - +Rule RussiaAsia 1985 2010 - Mar lastSun 2:00s 1:00 S +Rule RussiaAsia 1996 2010 - Oct lastSun 2:00s 0 - # Afghanistan # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -109,13 +109,17 @@ Zone Asia/Kabul 4:36:48 - LMT 1890 # or # (brief) # http://www.worldtimezone.com/dst_news/dst_news_armenia03.html +# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +Rule Armenia 2011 only - Mar lastSun 2:00s 1:00 S +Rule Armenia 2011 only - Oct lastSun 2:00s 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Yerevan 2:58:00 - LMT 1924 May 2 3:00 - +03 1957 Mar 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s 3:00 RussiaAsia +03/+04 1995 Sep 24 2:00s 4:00 - +04 1997 - 4:00 RussiaAsia +04/+05 + 4:00 RussiaAsia +04/+05 2011 + 4:00 Armenia +04/+05 # Azerbaijan @@ -127,7 +131,7 @@ Zone Asia/Yerevan 2:58:00 - LMT 1924 May 2 # From Steffen Thorsen (2016-03-17): # ... the Azerbaijani Cabinet of Ministers has cancelled switching to # daylight saving time.... -# http://www.azernews.az/azerbaijan/94137.html +# https://www.azernews.az/azerbaijan/94137.html # http://vestnikkavkaza.net/news/Azerbaijani-Cabinet-of-Ministers-cancels-daylight-saving-time.html # http://en.apa.az/xeber_azerbaijan_abolishes_daylight_savings_ti_240862.html @@ -168,11 +172,11 @@ Zone Asia/Baku 3:19:24 - LMT 1924 May 2 # the 19th and 20th, and they have not set the end date yet. # # Some sources: -# http://in.reuters.com/article/southAsiaNews/idINIndia-40017620090601 +# https://in.reuters.com/article/southAsiaNews/idINIndia-40017620090601 # http://bdnews24.com/details.php?id=85889&cid=2 # # Our wrap-up: -# http://www.timeanddate.com/news/time/bangladesh-daylight-saving-2009.html +# https://www.timeanddate.com/news/time/bangladesh-daylight-saving-2009.html # From A. N. M. Kamrus Saadat (2009-06-15): # Finally we've got the official mail regarding DST start time where DST start @@ -258,9 +262,15 @@ Zone Asia/Brunei 7:39:40 - LMT 1926 Mar # Bandar Seri Begawan # Milne says 6:24:40 was the meridian of the time ball observatory at Rangoon. +# From Paul Eggert (2017-04-20): +# Page 27 of Reed & Low (cited for Asia/Kolkata) says "Rangoon local time is +# used upon the railways and telegraphs of Burma, and is 6h. 24m. 47s. ahead +# of Greenwich." This refers to the period before Burma's transition to +0630, +# a transition for which Shanks is the only source. + # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Yangon 6:24:40 - LMT 1880 # or Rangoon - 6:24:40 - RMT 1920 # Rangoon Mean Time? +Zone Asia/Yangon 6:24:47 - LMT 1880 # or Rangoon + 6:24:47 - RMT 1920 # Rangoon local time 6:30 - +0630 1942 May 9:00 - +09 1945 May 3 6:30 - +0630 @@ -317,7 +327,7 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1:00 D # # From Jesper Nørgaard Welen (2006-07-14): # I have investigated the timezones around 1970 on the -# http://www.astro.com/atlas site [with provinces and county +# https://www.astro.com/atlas site [with provinces and county # boundaries summarized below].... A few other exceptions were two # counties on the Sichuan side of the Xizang-Sichuan border, # counties Dege and Baiyu which lies on the Sichuan side and are @@ -469,7 +479,7 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1:00 D # From David Cochrane (2014-03-26): # Just a confirmation that Ãœrümqi time was implemented in Ãœrümqi on 1 Feb 1986: -# http://content.time.com/time/magazine/article/0,9171,960684,00.html +# https://content.time.com/time/magazine/article/0,9171,960684,00.html # From Luther Ma (2014-04-22): # I have interviewed numerous people of various nationalities and from @@ -626,7 +636,7 @@ Zone Asia/Hong_Kong 7:36:42 - LMT 1904 Oct 30 # (both in Okinawa) adopt the Western Standard Time which is based on # 120E. The adoption began from Jan 1, 1896. The original text can be # found on Wikisource: -# http://ja.wikisource.org/wiki/標準時ニ關スル件_(公布時) +# https://ja.wikisource.org/wiki/標準時ニ關スル件_(公布時) # ... This could be the first adoption of time zone in Taiwan, because # during the Qing Dynasty, it seems that there was no time zone # declared officially. @@ -639,7 +649,7 @@ Zone Asia/Hong_Kong 7:36:42 - LMT 1904 Oct 30 # territory, including later occupations, adopt Japan Central Time # (UTC+9). The adoption began on Oct 1, 1937. The original text can # be found on Wikisource: -# http://ja.wikisource.org/wiki/明治二å八年勅令第百å…å七號標準時ニ關スル件ä¸æ”¹æ£ãƒŽä»¶ +# https://ja.wikisource.org/wiki/明治二å八年勅令第百å…å七號標準時ニ關スル件ä¸æ”¹æ£ãƒŽä»¶ # # That is, the time zone of Taipei switched to UTC+9 on Oct 1, 1937. @@ -775,6 +785,12 @@ Zone Asia/Macau 7:34:20 - LMT 1912 Jan 1 # Looks like the time zone split in Cyprus went through last night. # http://cyprus-mail.com/2016/10/30/cyprus-new-division-two-time-zones-now-reality/ +# From Paul Eggert (2017-10-18): +# Northern Cyprus will reinstate winter time on October 29, thus +# staying in sync with the rest of Cyprus. See: Anastasiou A. +# Cyprus to remain united in time. Cyprus Mail 2017-10-17. +# https://cyprus-mail.com/2017/10/17/cyprus-remain-united-time/ + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Cyprus 1975 only - Apr 13 0:00 1:00 S Rule Cyprus 1975 only - Oct 12 0:00 0 - @@ -792,7 +808,8 @@ Zone Asia/Nicosia 2:13:28 - LMT 1921 Nov 14 Zone Asia/Famagusta 2:15:48 - LMT 1921 Nov 14 2:00 Cyprus EE%sT 1998 Sep 2:00 EUAsia EE%sT 2016 Sep 8 - 3:00 - +03 + 3:00 - +03 2017 Oct 29 1:00u + 2:00 EUAsia EE%sT # Classically, Cyprus belongs to Asia; e.g. see Herodotus, Histories, I.72. # However, for various reasons many users expect to find it under Europe. @@ -852,7 +869,7 @@ Zone Asia/Tbilisi 2:59:11 - LMT 1880 # From João Carrascalão, brother of the former governor of East Timor, in # East Timor may be late for its millennium -# <http://etan.org/et99c/december/26-31/30ETMAY.htm> (1999-12-26/31): +# <https://etan.org/et99c/december/26-31/30ETMAY.htm> (1999-12-26/31): # Portugal tried to change the time forward in 1974 because the sun # rises too early but the suggestion raised a lot of problems with the # Timorese and I still don't think it would work today because it @@ -880,21 +897,62 @@ Zone Asia/Dili 8:22:20 - LMT 1912 Jan 1 # India # From Ian P. Beacock, in "A brief history of (modern) time", The Atlantic -# http://www.theatlantic.com/technology/archive/2015/12/the-creation-of-modern-time/421419/ +# https://www.theatlantic.com/technology/archive/2015/12/the-creation-of-modern-time/421419/ # (2015-12-22): # In January 1906, several thousand cotton-mill workers rioted on the # outskirts of Bombay.... They were protesting the proposed abolition of # local time in favor of Indian Standard Time.... Journalists called this # dispute the "Battle of the Clocks." It lasted nearly half a century. +# From Paul Eggert (2017-04-20): +# Good luck trying to nail down old timekeeping records in India. +# "... in the nineteenth century ... Madras Observatory took its magnetic +# measurements on Göttingen time, its meteorological measurements on Madras +# (local) time, dropped its time ball on Greenwich (ocean navigator's) time, +# and distributed civil (local time)." -- Bartky IR. Selling the true time: +# 19th-century timekeeping in america. Stanford U Press (2000), 247 note 19. +# "A more potent cause of resistance to the general adoption of the present +# standard time lies in the fact that it is Madras time. The citizen of +# Bombay, proud of being 'primus in Indis' and of Calcutta, equally proud of +# his city being the Capital of India, and - for a part of the year - the Seat +# of the Supreme Government, alike look down on Madras, and refuse to change +# the time they are using, for that of what they regard as a benighted +# Presidency; while Madras, having for long given the standard time to the +# rest of India, would resist the adoption of any other Indian standard in its +# place." -- Oldham RD. On Time in India: a suggestion for its improvement. +# Proceedings of the Asiatic Society of Bengal (April 1899), 49-55. +# +# "In 1870 ... Madras time - 'now used by the telegraph and regulated from the +# only government observatory' - was suggested as a standard railway time, +# first to be adopted on the Great Indian Peninsular Railway (GIPR).... +# Calcutta, Bombay, and Karachi, were to be allowed to continue with their +# local time for civil purposes." - Prasad R. Tracks of Change: Railways and +# Everyday Life in Colonial India. Cambridge University Press (2016), 145. +# +# Reed S, Low F. The Indian Year Book 1936-37. Bennett, Coleman, pp 27-8. +# https://archive.org/details/in.ernet.dli.2015.282212 +# This lists +052110 as Madras local time used in railways, and says that on +# 1906-01-01 railways and telegraphs in India switched to +0530. Some +# municipalities retained their former time, and the time in Calcutta +# continued to depend on whether you were at the railway station or at +# government offices. Government time was at +055320 (according to Shanks) or +# at +0554 (according to the Indian Year Book). Railway time is more +# appropriate for our purposes, as it was better documented, it is what we do +# elsewhere (e.g., Europe/London before 1880), and after 1906 it was +# consistent in the region now identified by Asia/Kolkata. So, use railway +# time for 1870-1941. Shanks is our only (and dubious) source for the +# 1941-1945 data. + # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Kolkata 5:53:28 - LMT 1880 # Kolkata - 5:53:20 - HMT 1941 Oct # Howrah Mean Time? - 6:30 - +0630 1942 May 15 +Zone Asia/Kolkata 5:53:28 - LMT 1854 Jun 28 # Kolkata + 5:53:20 - HMT 1870 # Howrah Mean Time? + 5:21:10 - MMT 1906 Jan 1 # Madras local time + 5:30 - IST 1941 Oct + 5:30 1:00 +0630 1942 May 15 5:30 - IST 1942 Sep 5:30 1:00 +0630 1945 Oct 15 5:30 - IST -# The following are like Asia/Kolkata: +# Since 1970 the following are like Asia/Kolkata: # Andaman Is # Lakshadweep (Laccadive, Minicoy and Amindivi Is) # Nicobar Is @@ -1036,7 +1094,7 @@ Zone Asia/Jayapura 9:22:48 - LMT 1932 Nov # From Reuters (2007-09-16), with a heads-up from Jesper Nørgaard Welen: # ... the Guardian Council ... approved a law on Sunday to re-introduce # daylight saving time ... -# http://uk.reuters.com/article/oilRpt/idUKBLA65048420070916 +# https://uk.reuters.com/article/oilRpt/idUKBLA65048420070916 # # From Roozbeh Pournader (2007-11-05): # This is quoted from Official Gazette of the Islamic Republic of @@ -1135,7 +1193,7 @@ Zone Asia/Tehran 3:25:44 - LMT 1916 # http://www.aswataliraq.info/look/article.tpl?id=2047&IdLanguage=17&IdPublication=4&NrArticle=71743&NrIssue=1&NrSection=10 # # We have published a short article in English about the change: -# http://www.timeanddate.com/news/time/iraq-dumps-daylight-saving.html +# https://www.timeanddate.com/news/time/iraq-dumps-daylight-saving.html # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Iraq 1982 only - May 1 0:00 1:00 D @@ -1443,12 +1501,12 @@ Rule Japan 1950 1951 - May Sun>=1 2:00 1:00 D # From Yu-Cheng Chuang (2013-07-12): # ...the Meiji Emperor announced Ordinance No. 167 of Meiji Year 28 "The clause # about standard time" ... The adoption began from Jan 1, 1896. -# http://ja.wikisource.org/wiki/標準時ニ關スル件_(公布時) +# https://ja.wikisource.org/wiki/標準時ニ關スル件_(公布時) # # ...the Showa Emperor announced Ordinance No. 529 of Showa Year 12 ... which # means the whole Japan territory, including later occupations, adopt Japan # Central Time (UTC+9). The adoption began on Oct 1, 1937. -# http://ja.wikisource.org/wiki/明治二å八年勅令第百å…å七號標準時ニ關スル件ä¸æ”¹æ£ãƒŽä»¶ +# https://ja.wikisource.org/wiki/明治二å八年勅令第百å…å七號標準時ニ關スル件ä¸æ”¹æ£ãƒŽä»¶ # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Tokyo 9:18:59 - LMT 1887 Dec 31 15:00u @@ -1510,7 +1568,7 @@ Zone Asia/Tokyo 9:18:59 - LMT 1887 Dec 31 15:00u # Official, in Arabic: # http://www.petra.gov.jo/public_news/Nws_NewsDetails.aspx?Menu_ID=&Site_Id=2&lang=1&NewsID=133230&CatID=14 # ... Our background/permalink about it -# http://www.timeanddate.com/news/time/jordan-reverses-dst-decision.html +# https://www.timeanddate.com/news/time/jordan-reverses-dst-decision.html # ... # http://www.petra.gov.jo/Public_News/Nws_NewsDetails.aspx?lang=2&site_id=1&NewsID=133313&Type=P # ... says midnight for the coming one and 1:00 for the ones in the future @@ -1868,9 +1926,9 @@ Zone Asia/Bishkek 4:58:24 - LMT 1924 May 2 # between 1987 and 1988 ... # From Sanghyuk Jung (2014-10-29): -# http://mm.icann.org/pipermail/tz/2014-October/021830.html +# https://mm.icann.org/pipermail/tz/2014-October/021830.html # According to the Korean Wikipedia -# http://ko.wikipedia.org/wiki/í•œêµ_표준시 +# https://ko.wikipedia.org/wiki/í•œêµ_표준시 # [oldid=12896437 2014-09-04 08:03 UTC] # DST in Republic of Korea was as follows.... And I checked old # newspapers in Korean, all articles correspond with data in Wikipedia. @@ -2092,7 +2150,7 @@ Zone Indian/Maldives 4:54:00 - LMT 1880 # Male # +08:00 instead. Different sources appear to disagree with the tz # database on this, e.g.: # -# http://www.timeanddate.com/worldclock/city.html?n=1026 +# https://www.timeanddate.com/worldclock/city.html?n=1026 # http://www.worldtimeserver.com/current_time_in_MN.aspx # # both say GMT+08:00. @@ -2222,7 +2280,7 @@ Zone Asia/Kathmandu 5:41:16 - LMT 1920 # help reduce load shedding by approving the closure of commercial centres at # 9pm and moving clocks forward by one hour for the next three months. ...." # -# http://www.worldtimezone.net/dst_news/dst_news_pakistan01.html +# http://www.worldtimezone.com/dst_news/dst_news_pakistan01.html # http://www.dailytimes.com.pk/default.asp?page=2008%5C05%5C15%5Cstory_15-5-2008_pg1_4 # From Arthur David Olson (2008-05-19): @@ -2288,7 +2346,7 @@ Zone Asia/Kathmandu 5:41:16 - LMT 1920 # # We have confirmed this year's end date with both with the Ministry of # Water and Power and the Pakistan Electric Power Company: -# http://www.timeanddate.com/news/time/pakistan-ends-dst09.html +# https://www.timeanddate.com/news/time/pakistan-ends-dst09.html # From Christoph Göhre (2009-10-01): # [T]he German Consulate General in Karachi reported me today that Pakistan @@ -2470,7 +2528,7 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # # We are not sure if Gaza will do the same, last year they had a different # end date, we will keep this page updated: -# http://www.timeanddate.com/news/time/westbank-gaza-dst-2009.html +# https://www.timeanddate.com/news/time/westbank-gaza-dst-2009.html # From Alexander Krivenyshev (2009-09-02): # Seems that Gaza Strip will go back to Winter Time same date as West Bank. @@ -2508,7 +2566,7 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # the clocks were set back one hour at 2010-08-11 00:00:00 local time in # Gaza and the West Bank. # Some more background info: -# http://www.timeanddate.com/news/time/westbank-gaza-end-dst-2010.html +# https://www.timeanddate.com/news/time/westbank-gaza-end-dst-2010.html # From Steffen Thorsen (2011-08-26): # Gaza and the West Bank did go back to standard time in the beginning of @@ -2518,7 +2576,7 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # # http://www.maannews.net/eng/ViewDetails.aspx?ID=416217 # Additional info: -# http://www.timeanddate.com/news/time/palestine-dst-2011.html +# https://www.timeanddate.com/news/time/palestine-dst-2011.html # From Alexander Krivenyshev (2011-08-27): # According to the article in The Jerusalem Post: @@ -2528,7 +2586,7 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # The Hamas government said on Saturday that it won't observe summertime after # the Muslim feast of Id al-Fitr, which begins on Tuesday..." # ... -# http://www.jpost.com/MiddleEast/Article.aspx?id=235650 +# https://www.jpost.com/MiddleEast/Article.aspx?id=235650 # http://www.worldtimezone.com/dst_news/dst_news_gazastrip05.html # The rules for Egypt are stolen from the 'africa' file. @@ -2549,7 +2607,7 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # http://safa.ps/details/news/74352/%D8%A8%D8%AF%D8%A1-%D8%A7%D9%84%D8%AA%D9%88%D9%82%D9%8A%D8%AA-%D8%A7%D9%84%D8%B5%D9%8A%D9%81%D9%8A-%D8%A8%D8%A7%D9%84%D8%B6%D9%81%D8%A9-%D9%88%D8%BA%D8%B2%D8%A9-%D9%84%D9%8A%D9%84%D8%A9-%D8%A7%D9%84%D8%AC%D9%85%D8%B9%D8%A9.html # # Our brief summary: -# http://www.timeanddate.com/news/time/gaza-west-bank-dst-2012.html +# https://www.timeanddate.com/news/time/gaza-west-bank-dst-2012.html # From Steffen Thorsen (2013-03-26): # The following news sources tells that Palestine will "start daylight saving @@ -2569,11 +2627,11 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # From Steffen Thorsen (2015-03-03): # Sources such as http://www.alquds.com/news/article/view/id/548257 -# and http://www.raya.ps/ar/news/890705.html say Palestine areas will +# and https://www.raya.ps/ar/news/890705.html say Palestine areas will # start DST on 2015-03-28 00:00 which is one day later than expected. # # From Paul Eggert (2015-03-03): -# http://www.timeanddate.com/time/change/west-bank/ramallah?year=2014 +# https://www.timeanddate.com/time/change/west-bank/ramallah?year=2014 # says that the fall 2014 transition was Oct 23 at 24:00. # From Hannah Kreitem (2016-03-09): @@ -2597,8 +2655,8 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # # From Paul Eggert (2016-10-19): # It's also consistent with predictions in the following URLs today: -# http://www.timeanddate.com/time/change/gaza-strip/gaza -# http://www.timeanddate.com/time/change/west-bank/hebron +# https://www.timeanddate.com/time/change/gaza-strip/gaza +# https://www.timeanddate.com/time/change/west-bank/hebron # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule EgyptAsia 1957 only - May 10 0:00 1:00 S @@ -2661,7 +2719,7 @@ Zone Asia/Hebron 2:20:23 - LMT 1900 Oct # Philippines, issued a proclamation announcing that 1844-12-30 was to # be immediately followed by 1845-01-01; see R.H. van Gent's # History of the International Date Line -# http://www.staff.science.uu.nl/~gent0113/idl/idl_philippines.htm +# https://www.staff.science.uu.nl/~gent0113/idl/idl_philippines.htm # The rest of the data entries are from Shanks & Pottenger. # From Jesper Nørgaard Welen (2006-04-26): @@ -2925,7 +2983,7 @@ Rule Syria 2007 only - Nov Fri>=1 0:00 0 - # We have not found any sources saying anything about when DST ends this year. # # Our summary -# http://www.timeanddate.com/news/time/syria-dst-starts-march-27-2009.html +# https://www.timeanddate.com/news/time/syria-dst-starts-march-27-2009.html # From Steffen Thorsen (2009-10-27): # The Syrian Arab News Network on 2009-09-29 reported that Syria will @@ -2952,7 +3010,7 @@ Rule Syria 2007 only - Nov Fri>=1 0:00 0 - # http://www.sana.sy/ara/2/2012/03/26/408215.htm # # Our brief summary: -# http://www.timeanddate.com/news/time/syria-dst-2012.html +# https://www.timeanddate.com/news/time/syria-dst-2012.html # From Arthur David Olson (2012-03-27): # Assume last Friday in March going forward XXX. @@ -3035,7 +3093,7 @@ Zone Asia/Tashkent 4:37:11 - LMT 1924 May 2 # is quoted verbatim in: # http://www.thoigian.com.vn/?mPage=P80D01 # is translated by Brian Inglis in: -# http://mm.icann.org/pipermail/tz/2014-October/021654.html +# https://mm.icann.org/pipermail/tz/2014-October/021654.html # and is the basis for the information below. # # The 1906 transition was effective July 1 and standardized Indochina to diff --git contrib/tzdata/australasia contrib/tzdata/australasia index d389ae134ab7..5f7c86dda660 100644 --- contrib/tzdata/australasia +++ contrib/tzdata/australasia @@ -293,7 +293,7 @@ Zone Indian/Cocos 6:27:40 - LMT 1900 # http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=1096:3310-cabinet-approves-change-in-daylight-savings-dates&catid=49:cabinet-releases&Itemid=166 # # A bit more background info here: -# http://www.timeanddate.com/news/time/fiji-dst-ends-march-2010.html +# https://www.timeanddate.com/news/time/fiji-dst-ends-march-2010.html # From Alexander Krivenyshev (2010-10-24): # According to Radio Fiji and Fiji Times online, Fiji will end DST 3 @@ -357,9 +357,12 @@ Zone Indian/Cocos 6:27:40 - LMT 1900 # clocks go forward an hour at 2am to 3am.... Daylight Saving will # end at 3.00am on Sunday 15th January 2017." -# From Paul Eggert (2016-10-03): -# For now, guess DST from 02:00 the first Sunday in November to -# 03:00 the third Sunday in January. Although ad hoc, it matches +# From Paul Eggert (2017-08-21): +# Dominic Fok writes (2017-08-20) that DST ends 2018-01-14, citing +# Extraordinary Government of Fiji Gazette Supplement No. 21 (2017-08-27), +# [Legal Notice No. 41] of an order of the previous day by J Usamate. +# For now, guess DST from 02:00 the first Sunday in November to 03:00 +# the first Sunday on or after January 14. Although ad hoc, it matches # transitions since late 2014 and seems more likely to match future # practice than guessing no DST. @@ -373,7 +376,7 @@ Rule Fiji 2011 only - Mar Sun>=1 3:00 0 - Rule Fiji 2012 2013 - Jan Sun>=18 3:00 0 - Rule Fiji 2014 only - Jan Sun>=18 2:00 0 - Rule Fiji 2014 max - Nov Sun>=1 2:00 1:00 S -Rule Fiji 2015 max - Jan Sun>=15 3:00 0 - +Rule Fiji 2015 max - Jan Sun>=14 3:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva 12:00 Fiji +12/+13 @@ -557,7 +560,7 @@ Zone Pacific/Port_Moresby 9:48:40 - LMT 1880 # The World War II entries below are instead based on Arawa-Kieta. # The Japanese occupied Kieta in July 1942, # according to the Pacific War Online Encyclopedia -# http://pwencycl.kgbudge.com/B/o/Bougainville.htm +# https://pwencycl.kgbudge.com/B/o/Bougainville.htm # and seem to have controlled it until their 1945-08-21 surrender. # # The Autonomous Region of Bougainville switched from UT +10 to +11 @@ -579,7 +582,7 @@ Zone Pacific/Pitcairn -8:40:20 - LMT 1901 # Adamstown -8:00 - -08 # American Samoa -Zone Pacific/Pago_Pago 12:37:12 - LMT 1879 Jul 5 +Zone Pacific/Pago_Pago 12:37:12 - LMT 1892 Jul 5 -11:22:48 - LMT 1911 -11:00 - SST # S=Samoa Link Pacific/Pago_Pago Pacific/Midway # in US minor outlying islands @@ -595,7 +598,7 @@ Link Pacific/Pago_Pago Pacific/Midway # in US minor outlying islands # Sunday of April 2011." # # Background info: -# http://www.timeanddate.com/news/time/samoa-dst-plan-2009.html +# https://www.timeanddate.com/news/time/samoa-dst-plan-2009.html # # Samoa's Daylight Saving Time Act 2009 is available here, but does not # contain any dates: @@ -659,7 +662,7 @@ Rule WS 2011 only - Sep lastSat 3:00 1 D Rule WS 2012 max - Apr Sun>=1 4:00 0 S Rule WS 2012 max - Sep lastSun 3:00 1 D # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Apia 12:33:04 - LMT 1879 Jul 5 +Zone Pacific/Apia 12:33:04 - LMT 1892 Jul 5 -11:26:56 - LMT 1911 -11:30 - -1130 1950 -11:00 WS -11/-10 2011 Dec 29 24:00 @@ -686,7 +689,7 @@ Zone Pacific/Guadalcanal 10:39:48 - LMT 1912 Oct # Honiara # From Paul Eggert (2012-07-25) # A Google Books snippet of Appendix to the Journals of the House of # Representatives of New Zealand, Session 1948, -# <http://books.google.com/books?id=ZaVCAQAAIAAJ>, page 65, says Tokelau +# <https://books.google.com/books?id=ZaVCAQAAIAAJ>, page 65, says Tokelau # was "11 hours slow on G.M.T." Go with Thorsen and assume Shanks & Pottenger # are off by an hour starting in 1901. @@ -701,8 +704,8 @@ Rule Tonga 1999 only - Oct 7 2:00s 1:00 S Rule Tonga 2000 only - Mar 19 2:00s 0 - Rule Tonga 2000 2001 - Nov Sun>=1 2:00 1:00 S Rule Tonga 2001 2002 - Jan lastSun 2:00 0 - -Rule Tonga 2016 max - Nov Sun>=1 2:00 1:00 S -Rule Tonga 2017 max - Jan Sun>=15 3:00 0 - +Rule Tonga 2016 only - Nov Sun>=1 2:00 1:00 S +Rule Tonga 2017 only - Jan Sun>=15 3:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Pacific/Tongatapu 12:19:20 - LMT 1901 12:20 - +1220 1941 @@ -756,7 +759,7 @@ Zone Pacific/Funafuti 11:56:52 - LMT 1901 # Operation Fishbowl shot (Tightrope, 1962-11-04).... [See] Herman Hoerlin, # "The United States High-Altitude Test Experience: A Review Emphasizing the # Impact on the Environment", Los Alamos LA-6405, Oct 1976. -# http://www.fas.org/sgp/othergov/doe/lanl/docs1/00322994.pdf +# https://www.fas.org/sgp/othergov/doe/lanl/docs1/00322994.pdf # See the table on page 4 where he lists GMT and local times for the tests; a # footnote for the JI tests reads that local time is "JI time = Hawaii Time # Minus One Hour". @@ -822,7 +825,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # # For data circa 1899, a common source is: # Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94. -# http://www.jstor.org/stable/1774359 +# https://www.jstor.org/stable/1774359 # # A reliable and entertaining source about time zones is # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). @@ -969,7 +972,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # AEST ACST AWST AEDT ACDT # # Parliamentary Library (2008-11-10) -# http://www.aph.gov.au/binaries/library/pubs/rp/2008-09/09rp14.pdf +# https://www.aph.gov.au/binaries/library/pubs/rp/2008-09/09rp14.pdf # EST CST WST preferred for standard time; AEST AEDT ACST ACDT also used # # The Transport Safety Bureau has an extensive series of accident reports, @@ -1005,13 +1008,13 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # # NSW (including LHI and Broken Hill): # Standard Time Act 1987 (updated 1995-04-04) -# http://www.austlii.edu.au/au/legis/nsw/consol_act/sta1987137/index.html +# https://www.austlii.edu.au/au/legis/nsw/consol_act/sta1987137/index.html # ACT # Standard Time and Summer Time Act 1972 -# http://www.austlii.edu.au/au/legis/act/consol_act/stasta1972279/index.html +# https://www.austlii.edu.au/au/legis/act/consol_act/stasta1972279/index.html # SA # Standard Time Act, 1898 -# http://www.austlii.edu.au/au/legis/sa/consol_act/sta1898137/index.html +# https://www.austlii.edu.au/au/legis/sa/consol_act/sta1898137/index.html # From David Grosz (2005-06-13): # It was announced last week that Daylight Saving would be extended by @@ -1306,7 +1309,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # http://abc.net.au/news/regionals/neweng/monthly/regeng-22jul1999-1.htm # (1999-07-22). For now, we'll wait to see if this really happens. # -# Victoria will following NSW. See: +# Victoria will follow NSW. See: # Vic to extend daylight saving (1999-07-28) # http://abc.net.au/local/news/olympics/1999/07/item19990728112314_1.htm # @@ -1409,7 +1412,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # the ACT for all 52 weeks of the year... # # We have a wrap-up here: -# http://www.timeanddate.com/news/time/south-australia-extends-dst.html +# https://www.timeanddate.com/news/time/south-australia-extends-dst.html ############################################################################### # New Zealand @@ -1463,7 +1466,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # From Paul Eggert (2014-07-14): # Chatham Island time was formally standardized on 1957-01-01 by # New Zealand's Standard Time Amendment Act 1956 (1956-10-26). -# http://www.austlii.edu.au/nz/legis/hist_act/staa19561956n100244.pdf +# https://www.austlii.edu.au/nz/legis/hist_act/staa19561956n100244.pdf # According to Google Books snippet view, a speaker in the New Zealand # parliamentary debates in 1956 said "Clause 78 makes provision for standard # time in the Chatham Islands. The time there is 45 minutes in advance of New @@ -1578,7 +1581,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # the Norfolk Island Museum and the Australian Bureau of Meteorology's # Norfolk Island station, and found no record of Norfolk observing DST # other than in 1974/5. See: -# http://www.timeanddate.com/time/australia/norfolk-island.html +# https://www.timeanddate.com/time/australia/norfolk-island.html # Pitcairn @@ -1606,11 +1609,13 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # (Western) Samoa and American Samoa -# Howse writes (p 153, citing p 10 of the 1883-11-18 New York Herald) -# that in 1879 the King of Samoa decided to change +# Howse writes (p 153) that after the 1879 standardization on Antipodean +# time by the British governor of Fiji, the King of Samoa decided to change # "the date in his kingdom from the Antipodean to the American system, # ordaining - by a masterpiece of diplomatic flattery - that # the Fourth of July should be celebrated twice in that year." +# This happened in 1892, according to the Evening News (Sydney) of 1892-07-20. +# https://www.staff.science.uu.nl/~gent0113/idl/idl.htm # Although Shanks & Pottenger says they both switched to UT -11:30 # in 1911, and to -11 in 1950. many earlier sources give -11 @@ -1621,6 +1626,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # day in 2011. Assume also that the Samoas follow the US and New # Zealand's "ST"/"DT" style of daylight-saving abbreviations. + # Tonga # From Paul Eggert (1996-01-22): @@ -1715,6 +1721,15 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # Assume Tonga will observe DST from the first Sunday in November at 02:00 # through the third Sunday in January at 03:00, like Fiji, for now. +# From David Wade (2017-10-18): +# In August government was disolved by the King. The current prime minister +# continued in office in care taker mode. It is easy to see that few +# decisions will be made until elections 16th November. +# +# From Paul Eggert (2017-10-18): +# For now, guess that DST is discontinued. That's what the IATA is guessing. + + # Wake # From Vernice Anderson, Personal Secretary to Philip Jessup, @@ -1727,7 +1742,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # making calculation of time in Washington difficult if not almost # impossible. # -# http://www.trumanlibrary.org/wake/meeting.htm +# https://www.trumanlibrary.org/oralhist/andrsonv.htm # From Paul Eggert (2003-03-23): # We have no other report of DST in Wake Island, so omit this info for now. @@ -1755,7 +1770,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901 # an international standard, there are some places on the high seas where the # correct date is ambiguous. -# From Wikipedia <http://en.wikipedia.org/wiki/Time_zone> (2005-08-31): +# From Wikipedia <https://en.wikipedia.org/wiki/Time_zone> (2005-08-31): # Before 1920, all ships kept local apparent time on the high seas by setting # their clocks at night or at the morning sight so that, given the ship's # speed and direction, it would be 12 o'clock when the Sun crossed the ship's diff --git contrib/tzdata/backward contrib/tzdata/backward index 09f2a31b685d..2141f0d5798f 100644 --- contrib/tzdata/backward +++ contrib/tzdata/backward @@ -61,7 +61,9 @@ Link America/Sao_Paulo Brazil/East Link America/Manaus Brazil/West Link America/Halifax Canada/Atlantic Link America/Winnipeg Canada/Central -Link America/Regina Canada/East-Saskatchewan +# This line is commented out, as the name exceeded the 14-character limit +# and was an unused misnomer. +#Link America/Regina Canada/East-Saskatchewan Link America/Toronto Canada/Eastern Link America/Edmonton Canada/Mountain Link America/St_Johns Canada/Newfoundland diff --git contrib/tzdata/backzone contrib/tzdata/backzone index 9ce78316c2b3..32bd0f106155 100644 --- contrib/tzdata/backzone +++ contrib/tzdata/backzone @@ -181,7 +181,7 @@ Zone Africa/Lome 0:04:52 - LMT 1893 # with the date that it took effect, namely 1912-01-01. # Zone Africa/Luanda 0:52:56 - LMT 1892 - 0:52:04 - +005204 1912 Jan 1 + 0:52:04 - LMT 1912 Jan 1 # Luanda Mean Time? 1:00 - WAT # Democratic Republic of the Congo (east) @@ -540,10 +540,10 @@ Zone Europe/Belfast -0:23:40 - LMT 1880 Aug 2 # Guernsey # Data from Joseph S. Myers -# http://mm.icann.org/pipermail/tz/2013-September/019883.html +# https://mm.icann.org/pipermail/tz/2013-September/019883.html # References to be added -# LMT Location - 49.27N -2.33E - St.Peter Port -Zone Europe/Guernsey -0:09:19 - LMT 1913 Jun 18 +# LMT is for Town Church, St. Peter Port, 49 degrees 27'17"N 2 degrees 32'10"W +Zone Europe/Guernsey -0:10:09 - LMT 1913 Jun 18 0:00 GB-Eire %s 1940 Jul 2 1:00 C-Eur CE%sT 1945 May 8 0:00 GB-Eire %s 1968 Oct 27 @@ -555,11 +555,11 @@ Zone Europe/Guernsey -0:09:19 - LMT 1913 Jun 18 # # From Lester Caine (2013-09-04): # The Isle of Man legislation is now on-line at -# <http://www.legislation.gov.im>, starting with the original Statutory +# <https://www.legislation.gov.im>, starting with the original Statutory # Time Act in 1883 and including additional confirmation of some of # the dates of the 'Summer Time' orders originating at # Westminster. There is a little uncertainty as to the starting date -# of the first summer time in 1916 which may have be announced a +# of the first summer time in 1916 which may have been announced a # couple of days late. There is still a substantial number of # documents to work through, but it is thought that every GB change # was also implemented on the island. @@ -574,10 +574,10 @@ Zone Europe/Isle_of_Man -0:17:55 - LMT 1883 Mar 30 0:00s # Jersey # Data from Joseph S. Myers -# http://mm.icann.org/pipermail/tz/2013-September/019883.html +# https://mm.icann.org/pipermail/tz/2013-September/019883.html # References to be added -# LMT Location - 49.187N -2.107E - St. Helier -Zone Europe/Jersey -0:08:25 - LMT 1898 Jun 11 16:00u +# LMT is for Parish Church, St. Helier, 49 degrees 11'0.57"N 2 degrees 6'24.33"W +Zone Europe/Jersey -0:08:26 - LMT 1898 Jun 11 16:00u 0:00 GB-Eire %s 1940 Jul 2 1:00 C-Eur CE%sT 1945 May 8 0:00 GB-Eire %s 1968 Oct 27 diff --git contrib/tzdata/calendars contrib/tzdata/calendars new file mode 100644 index 000000000000..8bc70626eb5a --- /dev/null +++ contrib/tzdata/calendars @@ -0,0 +1,173 @@ +----- Calendrical issues ----- + +As mentioned in Theory.html, although calendrical issues are out of +scope for tzdb, they indicate the sort of problems that we would run +into if we extended tzdb further into the past. The following +information and sources go beyond Theory.html's brief discussion. +They sometimes disagree. + + +France + +Gregorian calendar adopted 1582-12-20. +French Revolutionary calendar used 1793-11-24 through 1805-12-31, +and (in Paris only) 1871-05-06 through 1871-05-23. + + +Russia + +From Chris Carrier (1996-12-02): +On 1929-10-01 the Soviet Union instituted an "Eternal Calendar" +with 30-day months plus 5 holidays, with a 5-day week. +On 1931-12-01 it changed to a 6-day week; in 1934 it reverted to the +Gregorian calendar while retaining the 6-day week; on 1940-06-27 it +reverted to the 7-day week. With the 6-day week the usual days +off were the 6th, 12th, 18th, 24th and 30th of the month. +(Source: Evitiar Zerubavel, _The Seven Day Circle_) + + +Mark Brader reported a similar story in "The Book of Calendars", edited +by Frank Parise (1982, Facts on File, ISBN 0-8719-6467-8), page 377. But: + +From: Petteri Sulonen (via Usenet) +Date: 14 Jan 1999 00:00:00 GMT +... + +If your source is correct, how come documents between 1929 and 1940 were +still dated using the conventional, Gregorian calendar? + +I can post a scan of a document dated December 1, 1934, signed by +Yenukidze, the secretary, on behalf of Kalinin, the President of the +Executive Committee of the Supreme Soviet, if you like. + + + +Sweden (and Finland) + +From: Mark Brader +Subject: Re: Gregorian reform - a part of locale? +<news:1996Jul6.012937.29190@sq.com> +Date: 1996-07-06 + +In 1700, Denmark made the transition from Julian to Gregorian. Sweden +decided to *start* a transition in 1700 as well, but rather than have one of +those unsightly calendar gaps :-), they simply decreed that the next leap +year after 1696 would be in 1744 - putting the whole country on a calendar +different from both Julian and Gregorian for a period of 40 years. + +However, in 1704 something went wrong and the plan was not carried through; +they did, after all, have a leap year that year. And one in 1708. In 1712 +they gave it up and went back to Julian, putting 30 days in February that +year!... + +Then in 1753, Sweden made the transition to Gregorian in the usual manner, +getting there only 13 years behind the original schedule. + +(A previous posting of this story was challenged, and Swedish readers +produced the following references to support it: "Tideräkning och historia" +by Natanael Beckman (1924) and "Tid, en bok om tideräkning och +kalenderväsen" by Lars-Olof Lodén (1968). + + +Grotefend's data + +From: "Michael Palmer" [with one obvious typo fixed] +Subject: Re: Gregorian Calendar (was Re: Another FHC related question +Newsgroups: soc.genealogy.german +Date: Tue, 9 Feb 1999 02:32:48 -800 +... + +The following is a(n incomplete) listing, arranged chronologically, of +European states, with the date they converted from the Julian to the +Gregorian calendar: + +04/15 Oct 1582 - Italy (with exceptions), Spain, Portugal, Poland (Roman + Catholics and Danzig only) +09/20 Dec 1582 - France, Lorraine + +21 Dec 1582/ + 01 Jan 1583 - Holland, Brabant, Flanders, Hennegau +10/21 Feb 1583 - bishopric of Liege (Lüttich) +13/24 Feb 1583 - bishopric of Augsburg +04/15 Oct 1583 - electorate of Trier +05/16 Oct 1583 - Bavaria, bishoprics of Freising, Eichstedt, Regensburg, + Salzburg, Brixen +13/24 Oct 1583 - Austrian Oberelsaß and Breisgau +20/31 Oct 1583 - bishopric of Basel +02/13 Nov 1583 - duchy of Jülich-Berg +02/13 Nov 1583 - electorate and city of Köln +04/15 Nov 1583 - bishopric of Würzburg +11/22 Nov 1583 - electorate of Mainz +16/27 Nov 1583 - bishopric of Strassburg and the margraviate of Baden +17/28 Nov 1583 - bishopric of Münster and duchy of Cleve +14/25 Dec 1583 - Steiermark + +06/17 Jan 1584 - Austria and Bohemia +11/22 Jan 1584 - Lucerne, Uri, Schwyz, Zug, Freiburg, Solothurn +12/23 Jan 1584 - Silesia and the Lausitz +22 Jan/ + 02 Feb 1584 - Hungary (legally on 21 Oct 1587) + Jun 1584 - Unterwalden +01/12 Jul 1584 - duchy of Westfalen + +16/27 Jun 1585 - bishopric of Paderborn + +14/25 Dec 1590 - Transylvania + +22 Aug/ + 02 Sep 1612 - duchy of Prussia + +13/24 Dec 1614 - Pfalz-Neuburg + + 1617 - duchy of Kurland (reverted to the Julian calendar in + 1796) + + 1624 - bishopric of Osnabrück + + 1630 - bishopric of Minden + +15/26 Mar 1631 - bishopric of Hildesheim + + 1655 - Kanton Wallis + +05/16 Feb 1682 - city of Strassburg + +18 Feb/ + 01 Mar 1700 - Protestant Germany (including Swedish possessions in + Germany), Denmark, Norway +30 Jun/ + 12 Jul 1700 - Gelderland, Zutphen +10 Nov/ + 12 Dec 1700 - Utrecht, Overijssel + +31 Dec 1700/ + 12 Jan 1701 - Friesland, Groningen, Zürich, Bern, Basel, Geneva, + Turgau, and Schaffhausen + + 1724 - Glarus, Appenzell, and the city of St. Gallen + +01 Jan 1750 - Pisa and Florence + +02/14 Sep 1752 - Great Britain + +17 Feb/ + 01 Mar 1753 - Sweden + +1760-1812 - Graubünden + +The Russian empire (including Finland and the Baltic states) did not +convert to the Gregorian calendar until the Soviet revolution of 1917. + +Source: H. Grotefend, _Taschenbuch der Zeitrechnung des deutschen +Mittelalters und der Neuzeit_, herausgegeben von Dr. O. Grotefend +(Hannover: Hahnsche Buchhandlung, 1941), pp. 26-28. + +----- + +This file is in the public domain, so clarified as of 2009-05-17 by +Arthur David Olson. + +----- +Local Variables: +coding: utf-8 +End: diff --git contrib/tzdata/checklinks.awk contrib/tzdata/checklinks.awk index 5b3e1571d9f4..f30901086536 100644 --- contrib/tzdata/checklinks.awk +++ contrib/tzdata/checklinks.awk @@ -9,7 +9,7 @@ BEGIN { Zone = "\n" } -/^Zone/ { +/^Z/ { if (defined[$2]) { if (defined[$2] == Zone) { printf "%s: Zone has duplicate definition\n", $2 @@ -21,7 +21,7 @@ BEGIN { defined[$2] = Zone } -/^Link/ { +/^L/ { if (defined[$3]) { if (defined[$3] == Zone) { printf "%s: Link with same name as Zone\n", $3 diff --git contrib/tzdata/europe contrib/tzdata/europe index 558b9f168f36..5b3b4e52fa44 100644 --- contrib/tzdata/europe +++ contrib/tzdata/europe @@ -37,14 +37,14 @@ # [PDF] (1914-03) # # Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94 -# <http://www.jstor.org/stable/1774359>. He writes: +# <https://www.jstor.org/stable/1774359>. He writes: # "It is requested that corrections and additions to these tables # may be sent to Mr. John Milne, Royal Geographical Society, # Savile Row, London." Nowadays please email them to tz@iana.org. # # Byalokoz EL. New Counting of Time in Russia since July 1, 1919. # This Russian-language source was consulted by Vladimir Karpinsky; see -# http://mm.icann.org/pipermail/tz/2014-August/021320.html +# https://mm.icann.org/pipermail/tz/2014-August/021320.html # The full Russian citation is: # БÑлокоз, Евгений Людвигович. Ðовый Ñчет времени в течении Ñуток # введенный декретом Совета народных комиÑÑаров Ð´Ð»Ñ Ð²Ñей РоÑÑии Ñ 1-го @@ -187,7 +187,7 @@ # foundations of civilization throughout the world. # -- "A Silent Toast to William Willett", Pictorial Weekly; # republished in Finest Hour (Spring 2002) 1(114):26 -# http://www.winstonchurchill.org/images/finesthour/Vol.01%20No.114.pdf +# https://www.winstonchurchill.org/publications/finest-hour/finest-hour-114/a-silent-toast-to-william-willett-by-winston-s-churchill # From Paul Eggert (2015-08-08): # The OED Supplement says that the English originally said "Daylight Saving" @@ -225,8 +225,8 @@ # official designation; the reply of the 21st was that there wasn't # but he couldn't think of anything better than the "Double British # Summer Time" that the BBC had been using informally. -# http://www.polyomino.org.uk/british-time/bbc-19410418.png -# http://www.polyomino.org.uk/british-time/ho-19410421.png +# https://www.polyomino.org.uk/british-time/bbc-19410418.png +# https://www.polyomino.org.uk/british-time/ho-19410421.png # From Sir Alexander Maxwell in the above-mentioned letter (1941-04-21): # [N]o official designation has as far as I know been adopted for the time @@ -243,13 +243,13 @@ # the history of summer time legislation in the United Kingdom. # Since 1998 Joseph S. Myers has been updating # and extending this list, which can be found in -# http://www.polyomino.org.uk/british-time/ +# https://www.polyomino.org.uk/british-time/ # From Joseph S. Myers (1998-01-06): # # The legal time in the UK outside of summer time is definitely GMT, not UTC; # see Lord Tanlaw's speech -# http://www.publications.parliament.uk/pa/ld199798/ldhansrd/vo970611/text/70611-10.htm#70611-10_head0 +# https://www.publications.parliament.uk/pa/ld199798/ldhansrd/vo970611/text/70611-10.htm#70611-10_head0 # (Lords Hansard 11 June 1997 columns 964 to 976). # From Paul Eggert (2006-03-22): @@ -295,7 +295,7 @@ # Irish 'public feeling (was) outraged by forcing of English time on us'." # -- Parsons M. Dublin lost its time zone - and 25 minutes - after 1916 Rising. # Irish Times 2014-10-27. -# http://www.irishtimes.com/news/politics/dublin-lost-its-time-zone-and-25-minutes-after-1916-rising-1.1977411 +# https://www.irishtimes.com/news/politics/dublin-lost-its-time-zone-and-25-minutes-after-1916-rising-1.1977411 # From Joseph S. Myers (2005-01-26): # Irish laws are available online at <http://www.irishstatutebook.ie>. @@ -348,6 +348,12 @@ # Justice (tel +353 1 678 9711) who confirmed to me that the correct name is # "Irish Summer Time", abbreviated to "IST". +# Michael Deckers (2017-06-01) gave the following URLs for Ireland's +# Summer Time Act, 1925 and Summer Time Orders, 1926 and 1947: +# http://www.irishstatutebook.ie/eli/1925/act/8/enacted/en/print.html +# http://www.irishstatutebook.ie/eli/1926/sro/919/made/en/print.html +# http://www.irishstatutebook.ie/eli/1947/sro/71/made/en/print.html + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S # Summer Time Act, 1916 Rule GB-Eire 1916 only - May 21 2:00s 1:00 BST @@ -472,14 +478,14 @@ Link Europe/London Europe/Isle_of_Man # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Europe/Dublin -0:25:00 - LMT 1880 Aug 2 - -0:25:21 - DMT 1916 May 21 2:00 # Dublin MT + -0:25:21 - DMT 1916 May 21 2:00s # Dublin MT -0:25:21 1:00 IST 1916 Oct 1 2:00s 0:00 GB-Eire %s 1921 Dec 6 # independence - 0:00 GB-Eire GMT/IST 1940 Feb 25 2:00 - 0:00 1:00 IST 1946 Oct 6 2:00 - 0:00 - GMT 1947 Mar 16 2:00 - 0:00 1:00 IST 1947 Nov 2 2:00 - 0:00 - GMT 1948 Apr 18 2:00 + 0:00 GB-Eire GMT/IST 1940 Feb 25 2:00s + 0:00 1:00 IST 1946 Oct 6 2:00s + 0:00 - GMT 1947 Mar 16 2:00s + 0:00 1:00 IST 1947 Nov 2 2:00s + 0:00 - GMT 1948 Apr 18 2:00s 0:00 GB-Eire GMT/IST 1968 Oct 27 1:00 - IST 1971 Oct 31 2:00u 0:00 GB-Eire GMT/IST 1996 @@ -625,7 +631,7 @@ Rule Russia 1996 2010 - Oct lastSun 2:00s 0 - # Council of Ministers of the USSR from 1989-03-14 No. 227. # # I did not find full texts of these acts. For the 1989 one we have -# title at http://base.garant.ru/70754136/ : +# title at https://base.garant.ru/70754136/ : # "About change in calculation of time on the territories of # Lithuanian SSR, Latvian SSR and Estonian SSR, Astrakhan, # Kaliningrad, Kirov, Kuybyshev, Ulyanovsk and Uralsk oblasts". @@ -656,7 +662,7 @@ Rule Russia 1996 2010 - Oct lastSun 2:00s 0 - # http://bmockbe.ru/events/?ID=7583 # # Medvedev signed a law on the calculation of the time (in russian): -# http://www.regnum.ru/news/polit/1413906.html +# https://www.regnum.ru/news/polit/1413906.html # From Arthur David Olson (2011-06-15): # Take "abolishing daylight saving time" to mean that time is now considered @@ -783,7 +789,7 @@ Zone Europe/Vienna 1:05:21 - LMT 1893 Apr # Sources (Russian language): # http://www.belta.by/ru/all_news/society/V-Belarusi-otmenjaetsja-perexod-na-sezonnoe-vremja_i_572952.html # http://naviny.by/rubrics/society/2011/09/16/ic_articles_116_175144/ -# http://news.tut.by/society/250578.html +# https://news.tut.by/society/250578.html # # From Alexander Bokovoy (2014-10-09): # Belarussian government decided against changing to winter time.... @@ -1104,7 +1110,7 @@ Zone America/Thule -4:35:08 - LMT 1916 Jul 28 # Pituffik air base # for their standard and summer times. He says no, they use "suveaeg" # (summer time) and "talveaeg" (winter time). -# From The Baltic Times <http://www.baltictimes.com/> (1999-09-09) +# From The Baltic Times <https://www.baltictimes.com/> (1999-09-09) # via Steffen Thorsen: # This year will mark the last time Estonia shifts to summer time, # a council of the ruling coalition announced Sept. 6.... @@ -1156,7 +1162,7 @@ Zone Europe/Tallinn 1:39:00 - LMT 1880 # This is documented in Heikki Oja: Aikakirja 2007, published by The Almanac # Office of University of Helsinki, ISBN 952-10-3221-9, available online (in # Finnish) at -# http://almanakka.helsinki.fi/aikakirja/Aikakirja2007kokonaan.pdf +# https://almanakka.helsinki.fi/aikakirja/Aikakirja2007kokonaan.pdf # # Page 105 (56 in PDF version) has a handy table of all past daylight savings # transitions. It is easy enough to interpret without Finnish skills. @@ -1169,7 +1175,7 @@ Zone Europe/Tallinn 1:39:00 - LMT 1880 # From Konstantin Hyppönen (2014-06-13): # [Heikki Oja's book Aikakirja 2013] -# http://almanakka.helsinki.fi/images/aikakirja/Aikakirja2013kokonaan.pdf +# https://almanakka.helsinki.fi/images/aikakirja/Aikakirja2013kokonaan.pdf # pages 104-105, including a scan from a newspaper published on Apr 2 1942 # say that ... [o]n Apr 2 1942, 24 o'clock (which means Apr 3 1942, # 00:00), clocks were moved one hour forward. The newspaper @@ -1299,7 +1305,7 @@ Zone Europe/Paris 0:09:21 - LMT 1891 Mar 15 0:01 # From Jörg Schilling (2002-10-23): # In 1945, Berlin was switched to Moscow Summer time (GMT+4) by -# http://www.dhm.de/lemo/html/biografien/BersarinNikolai/ +# https://www.dhm.de/lemo/html/biografien/BersarinNikolai/ # General [Nikolai] Bersarin. # From Paul Eggert (2003-03-08): @@ -1524,7 +1530,7 @@ Zone Atlantic/Reykjavik -1:28 - LMT 1908 # From Paul Eggert (2016-10-27): # Go with INRiM for DST rules, except as corrected by Inglis for 1944 # for the Kingdom of Italy. This is consistent with Renzo Baldini. -# Model Rome's occupation by using using C-Eur rules from 1943-09-10 +# Model Rome's occupation by using C-Eur rules from 1943-09-10 # to 1944-06-04; although Rome was an open city during this period, it # was effectively controlled by Germany. # @@ -1839,14 +1845,14 @@ Zone Europe/Malta 0:58:04 - LMT 1893 Nov 2 0:00s # Valletta # Following Moldova and neighboring Ukraine- Transnistria (Pridnestrovie)- # Tiraspol will go back to winter time on October 30, 2011. # News from Moldova (in russian): -# http://ru.publika.md/link_317061.html +# https://ru.publika.md/link_317061.html # From Roman Tudos (2015-07-02): # http://lex.justice.md/index.php?action=view&view=doc&lang=1&id=355077 # From Paul Eggert (2015-07-01): # The abovementioned official link to IGO1445-868/2014 states that # 2014-10-26's fallback transition occurred at 03:00 local time. Also, -# http://www.trm.md/en/social/la-30-martie-vom-trece-la-ora-de-vara +# https://www.trm.md/en/social/la-30-martie-vom-trece-la-ora-de-vara # says the 2014-03-30 spring-forward transition was at 02:00 local time. # Guess that since 1997 Moldova has switched one hour before the EU. @@ -1918,7 +1924,7 @@ Zone Europe/Monaco 0:29:32 - LMT 1891 Mar 15 # Amsterdam mean time. # The data entries before 1945 are taken from -# http://www.staff.science.uu.nl/~gent0113/wettijd/wettijd.htm +# https://www.staff.science.uu.nl/~gent0113/wettijd/wettijd.htm # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Neth 1916 only - May 1 0:00 1:00 NST # Netherlands Summer Time @@ -1999,7 +2005,7 @@ Zone Europe/Oslo 0:43:00 - LMT 1895 Jan 1 # so it must have diverged from Oslo time during the war, as Oslo was # keeping Berlin time. # -# <http://home.no.net/janmayen/history.htm> says that the meteorologists +# <https://www.jan-mayen.no/history.htm> says that the meteorologists # burned down their station in 1940 and left the island, but returned in # 1941 with a small Norwegian garrison and continued operations despite # frequent air attacks from Germans. In 1943 the Americans established a @@ -2037,7 +2043,7 @@ Rule Poland 1945 only - Apr 29 0:00 1:00 S Rule Poland 1945 only - Nov 1 0:00 0 - # For 1946 on the source is Kazimierz Borkowski, # ToruÅ„ Center for Astronomy, Dept. of Radio Astronomy, Nicolaus Copernicus U., -# http://www.astro.uni.torun.pl/~kb/Artykuly/U-PA/Czas2.htm#tth_tAb1 +# https://www.astro.uni.torun.pl/~kb/Artykuly/U-PA/Czas2.htm#tth_tAb1 # Thanks to PrzemysÅ‚aw Augustyniak (2005-05-28) for this reference. # He also gives these further references: # Mon Pol nr 13, poz 162 (1995) <http://www.abc.com.pl/serwis/mp/1995/0162.htm> @@ -2071,7 +2077,7 @@ Zone Europe/Warsaw 1:24:00 - LMT 1880 # # From Paul Eggert (2014-08-11), after a heads-up from Stephen Colebourne: # According to a Portuguese decree (1911-05-26) -# http://dre.pt/pdf1sdip/1911/05/12500/23132313.pdf +# https://dre.pt/application/dir/pdf1sdip/1911/05/12500/23132313.pdf # Lisbon was at -0:36:44.68, but switched to GMT on 1912-01-01 at 00:00. # Round the old offset to -0:36:45. This agrees with Willett but disagrees # with Shanks, who says the transition occurred on 1911-05-24 at 00:00 for @@ -2253,7 +2259,7 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct # 2011 No. 725" and contains no other dates or "effective date" information. # # Another source is -# http://www.rg.ru/2011/09/06/chas-zona-dok.html +# https://rg.ru/2011/09/06/chas-zona-dok.html # which, according to translate.google.com, begins "Resolution of the # Government of the Russian Federation on August 31, 2011 N 725" and also # contains "Date first official publication: September 6, 2011 Posted on: @@ -2261,7 +2267,7 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct # does not contain any "effective date" information. # # Another source is -# http://en.wikipedia.org/wiki/Oymyakonsky_District#cite_note-RuTime-7 +# https://en.wikipedia.org/wiki/Oymyakonsky_District#cite_note-RuTime-7 # which, in note 8, contains "Resolution No. 725 of August 31, 2011... # Effective as of after 7 days following the day of the official publication" # but which does not contain any reference to September 6, 2011. @@ -2297,7 +2303,7 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct # http://itar-tass.com/obschestvo/1333711 # http://www.pravo.gov.ru:8080/page.aspx?111660 # http://www.kremlin.ru/acts/46279 -# From October 26, 2014 the new Russian time zone map will looks like this: +# From October 26, 2014 the new Russian time zone map will look like this: # http://www.worldtimezone.com/dst_news/dst_news_russia-map-2014-07.html # From Paul Eggert (2006-03-22): @@ -2344,7 +2350,7 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct # with maintenance only and represent our best guesses as to which regions # are covered by each zone. They are not meant to be taken as an authoritative # listing. The region codes listed come from -# http://en.wikipedia.org/w/?title=Federal_subjects_of_Russia&oldid=611810498 +# https://en.wikipedia.org/w/?title=Federal_subjects_of_Russia&oldid=611810498 # and are used for convenience only; no guarantees are made regarding their # future stability. ISO 3166-2:RU codes are also listed for first-level # divisions where available. @@ -2509,7 +2515,7 @@ Zone Europe/Kaliningrad 1:22:00 - LMT 1893 Apr # http://www.kaliningradka.ru/site_pc/cherez/index.php?ELEMENT_ID=40091 # says that Kaliningrad decided not to be an exception 2 days before the # 1991-03-31 switch and one person at -# http://izhevsk.ru/forum_light_message/50/682597-m8369040.html +# https://izhevsk.ru/forum_light_message/50/682597-m8369040.html # says he remembers that Samara opted out of the 1992-01-19 exception # 2 days before the switch. # @@ -2581,7 +2587,7 @@ Zone Europe/Simferopol 2:16:24 - LMT 1880 3:00 - MSK 1997 Mar lastSun 1:00u # From Alexander Krivenyshev (2014-03-17): # time change at 2:00 (2am) on March 30, 2014 -# http://vz.ru/news/2014/3/17/677464.html +# https://vz.ru/news/2014/3/17/677464.html # From Paul Eggert (2014-03-30): # Simferopol and Sevastopol reportedly changed their central town clocks # late the previous day, but this appears to have been ceremonial @@ -2764,7 +2770,7 @@ Zone Asia/Omsk 4:53:30 - LMT 1919 Nov 14 # suggests that Altai Republic transitioned to Moscow+3 on # 1995-05-28. # -# http://regnum.ru/news/society/1957270.html +# https://regnum.ru/news/society/1957270.html # has some historical data for Altai Krai: # before 1957: west part on UTC+6, east on UTC+7 # after 1957: UTC+7 @@ -3138,8 +3144,8 @@ Zone Asia/Magadan 10:03:12 - LMT 1924 May 2 # districts, but have very similar populations. In fact, Wikipedia currently # lists them both as having 3528 people, exactly 1668 males and 1860 females # each! (Yikes!) -# http://en.wikipedia.org/w/?title=Srednekolymsky_District&oldid=603435276 -# http://en.wikipedia.org/w/?title=Verkhnekolymsky_District&oldid=594378493 +# https://en.wikipedia.org/w/?title=Srednekolymsky_District&oldid=603435276 +# https://en.wikipedia.org/w/?title=Verkhnekolymsky_District&oldid=594378493 # Assume this is a mistake, albeit an amusing one. # # Looking at censuses, the populations of the two municipalities seem to have @@ -3460,7 +3466,7 @@ Zone Europe/Stockholm 1:12:12 - LMT 1879 Jan 1 # # From Alois Treindl (2013-09-11): # The Federal regulations say -# http://www.admin.ch/opc/de/classified-compilation/20071096/index.html +# https://www.admin.ch/opc/de/classified-compilation/20071096/index.html # ... the meridian for Bern mean time ... is 7 degrees 26' 22.50". # Expressed in time, it is 0h29m45.5s. @@ -3537,9 +3543,9 @@ Zone Europe/Zurich 0:34:08 - LMT 1853 Jul 16 # See above comment. # According to the articles linked below, Turkey will change into summer # time zone (GMT+3) on March 28, 2011 at 3:00 a.m. instead of March 27. # This change is due to a nationwide exam on 27th. -# http://www.worldbulletin.net/?aType=haber&ArticleID=70872 +# https://www.worldbulletin.net/?aType=haber&ArticleID=70872 # Turkish: -# http://www.hurriyet.com.tr/ekonomi/17230464.asp?gid=373 +# https://www.hurriyet.com.tr/yaz-saati-uygulamasi-bir-gun-ileri-alindi-17230464 # From Faruk Pasin (2014-02-14): # The DST for Turkey has been changed for this year because of the @@ -3675,7 +3681,7 @@ Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents. # http://www.segodnya.ua/news/14290482.html # # Deputies cancelled the winter time (in Russian) -# http://www.pravda.com.ua/rus/news/2011/09/20/6600616/ +# https://www.pravda.com.ua/rus/news/2011/09/20/6600616/ # # From Philip Pizzey (2011-10-18): # Today my Ukrainian colleagues have informed me that the diff --git contrib/tzdata/leap-seconds.list contrib/tzdata/leap-seconds.list index d0903e7e0ebd..5d5001029667 100644 --- contrib/tzdata/leap-seconds.list +++ contrib/tzdata/leap-seconds.list @@ -199,10 +199,10 @@ # current -- the update time stamp, the data and the name of the file # will not change. # -# Updated through IERS Bulletin C53 -# File expires on: 28 December 2017 +# Updated through IERS Bulletin C54 +# File expires on: 28 June 2018 # -#@ 3723408000 +#@ 3739132800 # 2272060800 10 # 1 Jan 1972 2287785600 11 # 1 Jul 1972 @@ -247,4 +247,4 @@ # the hash line is also ignored in the # computation. # -#h 62cf8c5d 8bbb6dcc c61e3b56 c308343 869bb80d +#h 5101445a 69948b51 9153e2b 2086e3d8 d54561a3 diff --git contrib/tzdata/leapseconds contrib/tzdata/leapseconds index 1ebf70fcf61e..a191d5f535a5 100644 --- contrib/tzdata/leapseconds +++ contrib/tzdata/leapseconds @@ -3,19 +3,18 @@ # This file is in the public domain. # This file is generated automatically from the data in the public-domain -# leap-seconds.list file available from most NIST time servers. -# If the URL <ftp://time.nist.gov/pub/leap-seconds.list> does not work, -# you should be able to pick up leap-seconds.list from a secondary NIST server. -# See <http://tf.nist.gov/tf-cgi/servers.cgi> for a list of secondary servers. +# leap-seconds.list file, which is copied from: +# ftp://ftp.nist.gov/pub/time/leap-seconds.list # For more about leap-seconds.list, please see # The NTP Timescale and Leap Seconds -# http://www.eecis.udel.edu/~mills/leap.html +# https://www.eecis.udel.edu/~mills/leap.html # The International Earth Rotation and Reference Systems Service # periodically uses leap seconds to keep UTC to within 0.9 s of UT1 # (which measures the true angular orientation of the earth in space); see -# Terry J Quinn, The BIPM and the accurate measure of time, -# Proc IEEE 79, 7 (July 1991), 894-905 <http://dx.doi.org/10.1109/5.84965>. +# Levine J. Coordinated Universal Time and the leap second. +# URSI Radio Sci Bull. 2016;89(4):30-6. doi:10.23919/URSIRSB.2016.7909995 +# http://ieeexplore.ieee.org/document/7909995/ # There were no leap seconds before 1972, because the official mechanism # accounting for the discrepancy between atomic time and the earth's rotation # did not exist until the early 1970s. @@ -58,5 +57,5 @@ Leap 2012 Jun 30 23:59:60 + S Leap 2015 Jun 30 23:59:60 + S Leap 2016 Dec 31 23:59:60 + S -# Updated through IERS Bulletin C53 -# File expires on: 28 December 2017 +# Updated through IERS Bulletin C54 +# File expires on: 28 June 2018 diff --git contrib/tzdata/leapseconds.awk contrib/tzdata/leapseconds.awk index 21fe540791b5..66eb64d3dcab 100644 --- contrib/tzdata/leapseconds.awk +++ contrib/tzdata/leapseconds.awk @@ -8,19 +8,18 @@ BEGIN { print "# This file is in the public domain." print "" print "# This file is generated automatically from the data in the public-domain" - print "# leap-seconds.list file available from most NIST time servers." - print "# If the URL <ftp://time.nist.gov/pub/leap-seconds.list> does not work," - print "# you should be able to pick up leap-seconds.list from a secondary NIST server." - print "# See <http://tf.nist.gov/tf-cgi/servers.cgi> for a list of secondary servers." + print "# leap-seconds.list file, which is copied from:" + print "# ftp://ftp.nist.gov/pub/time/leap-seconds.list" print "# For more about leap-seconds.list, please see" print "# The NTP Timescale and Leap Seconds" - print "# http://www.eecis.udel.edu/~mills/leap.html" + print "# https://www.eecis.udel.edu/~mills/leap.html" print "" print "# The International Earth Rotation and Reference Systems Service" print "# periodically uses leap seconds to keep UTC to within 0.9 s of UT1" print "# (which measures the true angular orientation of the earth in space); see" - print "# Terry J Quinn, The BIPM and the accurate measure of time," - print "# Proc IEEE 79, 7 (July 1991), 894-905 <http://dx.doi.org/10.1109/5.84965>." + print "# Levine J. Coordinated Universal Time and the leap second." + print "# URSI Radio Sci Bull. 2016;89(4):30-6. doi:10.23919/URSIRSB.2016.7909995" + print "# http://ieeexplore.ieee.org/document/7909995/" print "# There were no leap seconds before 1972, because the official mechanism" print "# accounting for the discrepancy between atomic time and the earth's rotation" print "# did not exist until the early 1970s." diff --git contrib/tzdata/northamerica contrib/tzdata/northamerica index 6ede9dcd96be..e5d3eca41c25 100644 --- contrib/tzdata/northamerica +++ contrib/tzdata/northamerica @@ -105,10 +105,13 @@ # Last night I heard part of a rebroadcast of a 1945 Arch Oboler radio drama. # In the introduction, Oboler spoke of "Eastern Peace Time." # An AltaVista search turned up: -# http://rowayton.org/rhs/hstaug45.html +# https://web.archive.org/web/20000926032210/http://rowayton.org/rhs/hstaug45.html # "When the time is announced over the radio now, it is 'Eastern Peace # Time' instead of the old familiar 'Eastern War Time.' Peace is wonderful." # (August 1945) by way of confirmation. +# +# From Paul Eggert (2017-09-23): +# This was the V-J Day issue of the Clamdigger, a Rowayton, CT newsletter. # From Joseph Gallant citing # George H. Douglas, _The Early Days of Radio Broadcasting_ (1987): @@ -257,7 +260,7 @@ Zone PST8PDT -8:00 US P%sT # HST and HDT are standardized abbreviations for Hawaii-Aleutian # standard and daylight times. See section 9.47 (p 234) of the # U.S. Government Printing Office Style Manual (2008) -# http://www.gpo.gov/fdsys/pkg/GPO-STYLEMANUAL-2008/pdf/GPO-STYLEMANUAL-2008.pdf +# https://www.gpo.gov/fdsys/pkg/GPO-STYLEMANUAL-2008/pdf/GPO-STYLEMANUAL-2008.pdf # From Arthur David Olson, 2005-08-09 # The following was signed into law on 2005-08-08. @@ -346,7 +349,7 @@ Zone America/New_York -4:56:02 - LMT 1883 Nov 18 12:03:58 # western Tennessee, most of Texas, Wisconsin # From Larry M. Smith (2006-04-26) re Wisconsin: -# http://www.legis.state.wi.us/statutes/Stat0175.pdf ... +# https://docs.legis.wisconsin.gov/statutes/statutes/175.pdf # is currently enforced at the 01:00 time of change. Because the local # "bar time" in the state corresponds to 02:00, a number of citations # are issued for the "sale of class 'B' alcohol after prohibited @@ -355,7 +358,7 @@ Zone America/New_York -4:56:02 - LMT 1883 Nov 18 12:03:58 # From Douglas R. Bomberg (2007-03-12): # Wisconsin has enacted (nearly eleventh-hour) legislation to get WI # Statue 175 closer in synch with the US Congress' intent.... -# http://www.legis.state.wi.us/2007/data/acts/07Act3.pdf +# https://docs.legis.wisconsin.gov/2007/related/acts/3 # From an email administrator of the City of Fort Pierre, SD (2015-12-21): # Fort Pierre is technically located in the Mountain time zone as is @@ -402,7 +405,7 @@ Zone America/North_Dakota/New_Salem -6:45:39 - LMT 1883 Nov 18 12:14:21 # ...it appears that Mercer County, North Dakota, changed from the # mountain time zone to the central time zone at the last transition from # daylight-saving to standard time (on Nov. 7, 2010): -# http://www.gpo.gov/fdsys/pkg/FR-2010-09-29/html/2010-24376.htm +# https://www.gpo.gov/fdsys/pkg/FR-2010-09-29/html/2010-24376.htm # http://www.bismarcktribune.com/news/local/article_1eb1b588-c758-11df-b472-001cc4c03286.html # From Andy Lipscomb (2011-01-24): @@ -453,7 +456,7 @@ Zone America/Denver -6:59:56 - LMT 1883 Nov 18 12:00:04 # legal time, and is not part of the data here.) See: # Ross SA. An energy crisis from the past: Northern California in 1948. # Working Paper No. 8, Institute of Governmental Studies, UC Berkeley, -# 1973-11. http://escholarship.org/uc/item/8x22k30c +# 1973-11. https://escholarship.org/uc/item/8x22k30c # # In another measure to save electricity, DST was instituted from 1948-03-14 # at 02:01 to 1949-01-16 at 02:00, with the governor having the option to move @@ -474,8 +477,8 @@ Zone America/Denver -6:59:56 - LMT 1883 Nov 18 12:00:04 # which established DST from April's last Sunday at 01:00 until September's # last Sunday at 02:00. This was amended by 1962's Proposition 6, which changed # the fall-back date to October's last Sunday. See: -# http://repository.uchastings.edu/cgi/viewcontent.cgi?article=1501&context=ca_ballot_props -# http://repository.uchastings.edu/cgi/viewcontent.cgi?article=1636&context=ca_ballot_props +# https://repository.uchastings.edu/cgi/viewcontent.cgi?article=1501&context=ca_ballot_props +# https://repository.uchastings.edu/cgi/viewcontent.cgi?article=1636&context=ca_ballot_props # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER Rule CA 1948 only - Mar 14 2:01 1:00 D @@ -492,20 +495,31 @@ Zone America/Los_Angeles -7:52:58 - LMT 1883 Nov 18 12:07:02 # Alaska # AK%sT is the modern abbreviation for -09 per USNO. # -# From Paul Eggert (2001-05-30): +# From Paul Eggert (2017-06-15): # Howse writes that Alaska switched from the Julian to the Gregorian calendar, # and from east-of-GMT to west-of-GMT days, when the US bought it from Russia. -# This was on 1867-10-18, a Friday; the previous day was 1867-10-06 Julian, -# also a Friday. Include only the time zone part of this transition, -# ignoring the switch from Julian to Gregorian, since we can't represent -# the Julian calendar. -# -# As far as we know, none of the exact locations mentioned below were +# On Friday, 1867-10-18 (Gregorian), at precisely 15:30 local time, the +# Russian forts and fleet at Sitka fired salutes to mark the ceremony of +# formal transfer. See the Sacramento Daily Union (1867-11-14), p 3, col 2. +# https://cdnc.ucr.edu/cgi-bin/cdnc?a=d&d=SDU18671114.2.12.1 +# Sitka workers did not change their calendars until Sunday, 1867-10-20, +# and so celebrated two Sundays that week. See: Ahllund T (tr Hallamaa P). +# From the memoirs of a Finnish workman. Alaska History. 2006 Fall;21(2):1-25. +# http://alaskahistoricalsociety.org/wp-content/uploads/2016/12/Ahllund-2006-Memoirs-of-a-Finnish-Workman.pdf +# Include only the time zone part of this transition, ignoring the switch +# from Julian to Gregorian, since we can't represent the Julian calendar. +# +# As far as we know, of the locations mentioned below only Sitka was # permanently inhabited in 1867 by anyone using either calendar. -# (Yakutat was colonized by the Russians in 1799, but the settlement -# was destroyed in 1805 by a Yakutat-kon war party.) However, there -# were nearby inhabitants in some cases and for our purposes perhaps -# it's best to simply use the official transition. +# (Yakutat was colonized by the Russians in 1799, but the settlement was +# destroyed in 1805 by a Yakutat-kon war party.) Many of Alaska's inhabitants +# were unaware of the US acquisition of Alaska, much less of any calendar or +# time change. However, the Russian-influenced part of Alaska did observe +# Russian time, and it is more accurate to model this than to ignore it. +# The database format requires an exact transition time; use the Russian +# salute as a somewhat-arbitrary time for the formal transfer of control for +# all of Alaska. Sitka's UTC offset is -9:01:13; adjust its 15:30 to the +# local times of other Alaskan locations so that they change simultaneously. # From Paul Eggert (2014-07-18): # One opinion of the early-1980s turmoil in Alaska over time zones and @@ -558,10 +572,10 @@ Zone America/Los_Angeles -7:52:58 - LMT 1883 Nov 18 12:07:02 # It seems Metlakatla did go off PST on Sunday, November 1, changing # their time to AKST and are going to follow Alaska's DST, switching # between AKST and AKDT from now on.... -# http://www.krbd.org/2015/10/30/annette-island-times-they-are-a-changing/ +# https://www.krbd.org/2015/10/30/annette-island-times-they-are-a-changing/ # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone America/Juneau 15:02:19 - LMT 1867 Oct 18 +Zone America/Juneau 15:02:19 - LMT 1867 Oct 19 15:33:32 -8:57:41 - LMT 1900 Aug 20 12:00 -8:00 - PST 1942 -8:00 US P%sT 1946 @@ -571,7 +585,7 @@ Zone America/Juneau 15:02:19 - LMT 1867 Oct 18 -8:00 US P%sT 1983 Oct 30 2:00 -9:00 US Y%sT 1983 Nov 30 -9:00 US AK%sT -Zone America/Sitka 14:58:47 - LMT 1867 Oct 18 +Zone America/Sitka 14:58:47 - LMT 1867 Oct 19 15:30 -9:01:13 - LMT 1900 Aug 20 12:00 -8:00 - PST 1942 -8:00 US P%sT 1946 @@ -579,7 +593,7 @@ Zone America/Sitka 14:58:47 - LMT 1867 Oct 18 -8:00 US P%sT 1983 Oct 30 2:00 -9:00 US Y%sT 1983 Nov 30 -9:00 US AK%sT -Zone America/Metlakatla 15:13:42 - LMT 1867 Oct 18 +Zone America/Metlakatla 15:13:42 - LMT 1867 Oct 19 15:44:55 -8:46:18 - LMT 1900 Aug 20 12:00 -8:00 - PST 1942 -8:00 US P%sT 1946 @@ -587,14 +601,14 @@ Zone America/Metlakatla 15:13:42 - LMT 1867 Oct 18 -8:00 US P%sT 1983 Oct 30 2:00 -8:00 - PST 2015 Nov 1 2:00 -9:00 US AK%sT -Zone America/Yakutat 14:41:05 - LMT 1867 Oct 18 +Zone America/Yakutat 14:41:05 - LMT 1867 Oct 19 15:12:18 -9:18:55 - LMT 1900 Aug 20 12:00 -9:00 - YST 1942 -9:00 US Y%sT 1946 -9:00 - YST 1969 -9:00 US Y%sT 1983 Nov 30 -9:00 US AK%sT -Zone America/Anchorage 14:00:24 - LMT 1867 Oct 18 +Zone America/Anchorage 14:00:24 - LMT 1867 Oct 19 14:31:37 -9:59:36 - LMT 1900 Aug 20 12:00 -10:00 - AST 1942 -10:00 US A%sT 1967 Apr @@ -602,7 +616,7 @@ Zone America/Anchorage 14:00:24 - LMT 1867 Oct 18 -10:00 US AH%sT 1983 Oct 30 2:00 -9:00 US Y%sT 1983 Nov 30 -9:00 US AK%sT -Zone America/Nome 12:58:21 - LMT 1867 Oct 18 +Zone America/Nome 12:58:22 - LMT 1867 Oct 19 13:29:35 -11:01:38 - LMT 1900 Aug 20 12:00 -11:00 - NST 1942 -11:00 US N%sT 1946 @@ -611,7 +625,7 @@ Zone America/Nome 12:58:21 - LMT 1867 Oct 18 -11:00 US B%sT 1983 Oct 30 2:00 -9:00 US Y%sT 1983 Nov 30 -9:00 US AK%sT -Zone America/Adak 12:13:21 - LMT 1867 Oct 18 +Zone America/Adak 12:13:22 - LMT 1867 Oct 19 12:44:35 -11:46:38 - LMT 1900 Aug 20 12:00 -11:00 - NST 1942 -11:00 US N%sT 1946 @@ -647,7 +661,7 @@ Zone America/Adak 12:13:21 - LMT 1867 Oct 18 # "Hawaiian Time" by Robert C. Schmitt and Doak C. Cox appears on pages 207-225 # of volume 26 of The Hawaiian Journal of History (1992). As of 2010-12-09, # the article is available at -# http://evols.library.manoa.hawaii.edu/bitstream/10524/239/2/JL26215.pdf +# https://evols.library.manoa.hawaii.edu/bitstream/10524/239/2/JL26215.pdf # and indicates that standard time was adopted effective noon, January # 13, 1896 (page 218), that in "1933, the Legislature decreed daylight # saving for the period between the last Sunday of each April and the @@ -746,7 +760,7 @@ Zone America/Boise -7:44:49 - LMT 1883 Nov 18 12:15:11 # Indiana # # For a map of Indiana's time zone regions, see: -# http://en.wikipedia.org/wiki/Time_in_Indiana +# https://en.wikipedia.org/wiki/Time_in_Indiana # # From Paul Eggert (2007-08-17): # Since 1970, most of Indiana has been like America/Indiana/Indianapolis, @@ -973,7 +987,7 @@ Zone America/Kentucky/Louisville -5:43:02 - LMT 1883 Nov 18 12:16:58 # From Paul Eggert (2001-07-16): # The final rule was published in the # Federal Register 65, 160 (2000-08-17), pp 50154-50158. -# http://frwebgate.access.gpo.gov/cgi-bin/getdoc.cgi?dbname=2000_register&docid=fr17au00-22 +# https://www.gpo.gov/fdsys/pkg/FR-2000-08-17/html/00-20854.htm # Zone America/Kentucky/Monticello -5:39:24 - LMT 1883 Nov 18 12:20:36 -6:00 US C%sT 1946 @@ -999,7 +1013,7 @@ Zone America/Kentucky/Monticello -5:39:24 - LMT 1883 Nov 18 12:20:36 # West Wendover, NV officially switched from Pacific to mountain time on # 1999-10-31. See the # Federal Register 64, 203 (1999-10-21), pp 56705-56707. -# http://frwebgate.access.gpo.gov/cgi-bin/getdoc.cgi?dbname=1999_register&docid=fr21oc99-15 +# https://www.gpo.gov/fdsys/pkg/FR-1999-10-21/html/99-27240.htm # However, the Federal Register says that West Wendover already operated # on mountain time, and the rule merely made this official; # hence a separate tz entry is not needed. @@ -1029,12 +1043,23 @@ Zone America/Kentucky/Monticello -5:39:24 - LMT 1883 Nov 18 12:20:36 # one hour in 1914." This change is not in Shanks. We have no more # info, so omit this for now. # +# From Paul Eggert (2017-07-26): +# Although Shanks says Detroit observed DST in 1967 from 06-14 00:01 +# until 10-29 00:01, I now see multiple reports that this is incorrect. +# For example, according to a 50-year anniversary report about the 1967 +# Detroit riots and a major-league doubleheader on 1967-07-23, "By the time +# the last fly ball of the doubleheader settled into the glove of leftfielder +# Lenny Green, it was after 7 p.m. Detroit did not observe daylight saving +# time, so light was already starting to fail. Twilight was made even deeper +# by billowing columns of smoke that ascended in an unbroken wall north of the +# ballpark." See: Dow B. Detroit '67: As violence unfolded, Tigers played two +# at home vs. Yankees. Detroit Free Press 2017-07-23. +# https://www.freep.com/story/sports/mlb/tigers/2017/07/23/detroit-tigers-1967-riot-new-york-yankees/499951001/ +# # Most of Michigan observed DST from 1973 on, but was a bit late in 1975. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER Rule Detroit 1948 only - Apr lastSun 2:00 1:00 D Rule Detroit 1948 only - Sep lastSun 2:00 0 S -Rule Detroit 1967 only - Jun 14 2:00 1:00 D -Rule Detroit 1967 only - Oct lastSun 2:00 0 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Detroit -5:32:11 - LMT 1905 -6:00 - CST 1915 May 15 2:00 @@ -1098,7 +1123,7 @@ Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00 # [PDF] (1914-03) # # Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94 -# <http://www.jstor.org/stable/1774359>. +# <https://www.jstor.org/stable/1774359>. # # See the 'europe' file for Greenland. @@ -1144,19 +1169,19 @@ Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00 # The British Columbia government announced yesterday that it will # adjust daylight savings next year to align with changes in the # U.S. and the rest of Canada.... -# http://www2.news.gov.bc.ca/news_releases_2005-2009/2006AG0014-000330.htm +# https://archive.news.gov.bc.ca/releases/news_releases_2005-2009/2006AG0014-000330.htm # ... # Nova Scotia # Daylight saving time will be extended by four weeks starting in 2007.... -# http://www.gov.ns.ca/just/regulations/rg2/2006/ma1206.pdf +# https://www.novascotia.ca/just/regulations/rg2/2006/ma1206.pdf # # [For New Brunswick] the new legislation dictates that the time change is to # be done at 02:00 instead of 00:01. -# http://www.gnb.ca/0062/acts/BBA-2006/Chap-19.pdf +# https://www.gnb.ca/0062/acts/BBA-2006/Chap-19.pdf # ... # Manitoba has traditionally changed the clock every fall at 03:00. # As of 2006, the transition is to take place one hour earlier at 02:00. -# http://web2.gov.mb.ca/laws/statutes/ccsm/o030e.php +# https://web2.gov.mb.ca/laws/statutes/ccsm/o030e.php # ... # [Alberta, Ontario, Quebec] will follow US rules. # http://www.qp.gov.ab.ca/documents/spring/CH03_06.CFM @@ -1170,7 +1195,7 @@ Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00 # http://www.hoa.gov.nl.ca/hoa/bills/Bill0634.htm # ... # Yukon -# http://www.gov.yk.ca/legislation/regs/oic2006_127.pdf +# https://www.gov.yk.ca/legislation/regs/oic2006_127.pdf # ... # N.W.T. will follow US rules. Whoever maintains the government web site # does not seem to believe in bookmarks. To see the news release, click the @@ -1191,8 +1216,8 @@ Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00 # time and daylight saving time arrangements in Canada circa 1998. # # National Research Council Canada maintains info about time zones and DST. -# http://www.nrc-cnrc.gc.ca/eng/services/time/time_zones.html -# http://www.nrc-cnrc.gc.ca/eng/services/time/faq/index.html#Q5 +# https://www.nrc-cnrc.gc.ca/eng/services/time/time_zones.html +# https://www.nrc-cnrc.gc.ca/eng/services/time/faq/index.html#Q5 # Its unofficial information is often taken from Matthews and Vincent. # From Paul Eggert (2006-06-27): @@ -1229,11 +1254,13 @@ Rule Canada 2007 max - Nov Sun>=1 2:00 0 S # Newfoundland and Labrador -# From Paul Eggert (2000-10-02): -# Matthews and Vincent (1998) write that Labrador should use NST/NDT, -# but the only part of Labrador that follows the rules is the -# southeast corner, including Port Hope Simpson and Mary's Harbour, -# but excluding, say, Black Tickle. +# From Paul Eggert (2017-10-14): +# Legally Labrador should observe Newfoundland time; see: +# McLeod J. Labrador time - legal or not? St. John's Telegram, 2017-10-07 +# http://www.thetelegram.com/news/local/labrador-time--legal-or-not-154860/ +# Matthews and Vincent (1998) write that the only part of Labrador +# that follows the rules is the southeast corner, including Port Hope +# Simpson and Mary's Harbour, but excluding, say, Black Tickle. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule StJohns 1917 only - Apr 8 2:00 1:00 D @@ -1433,7 +1460,7 @@ Zone America/Moncton -4:19:08 - LMT 1883 Dec 9 # http://www.justice.gouv.qc.ca/english/publications/generale/temps-minganie-a.htm # that the coastal strip from just east of Natashquan to Blanc-Sablon # observes Atlantic standard time all year round. -# http://www.assnat.qc.ca/Media/Process.aspx?MediaId=ANQ.Vigie.Bll.DocumentGenerique_8845en +# https://www.assnat.qc.ca/Media/Process.aspx?MediaId=ANQ.Vigie.Bll.DocumentGenerique_8845en # says this common practice was codified into law as of 2007. # For lack of better info, guess this practice began around 1970, contra to # Shanks & Pottenger who have this region observing AST/ADT. @@ -1465,6 +1492,11 @@ Zone America/Blanc-Sablon -3:48:28 - LMT 1884 # earlier in June). # # Kenora, Ontario, was to abandon DST on 1914-06-01 (-05-21). +# +# From Paul Eggert (2017-07-08): +# For more on Orillia, see: Daubs K. Bold attempt at daylight saving +# time became a comic failure in Orillia. Toronto Star 2017-07-08. +# https://www.thestar.com/news/insight/2017/07/08/bold-attempt-at-daylight-saving-time-became-a-comic-failure-in-orillia.html # From Paul Eggert (1997-10-17): # Mark Brader writes that an article in the 1997-10-14 Toronto Star @@ -1956,7 +1988,7 @@ Zone America/Creston -7:46:04 - LMT 1884 # * 1967. Paragraph 28(34)(g) of the Interpretation Act, S.C. 1967-68, # c. 7 defines Yukon standard time as UTC-9.... # see Interpretation Act, R.S.C. 1985, c. I-21, s. 35(1). -# [http://canlii.ca/t/7vhg] +# [https://www.canlii.org/en/ca/laws/stat/rsc-1985-c-i-21/latest/rsc-1985-c-i-21.html] # * C.O. 1973/214 switched Yukon to PST on 1973-10-28 00:00. # * O.I.C. 1980/02 established DST. # * O.I.C. 1987/056 changed DST to Apr firstSun 2:00 to Oct lastSun 2:00. @@ -2021,7 +2053,7 @@ Zone America/Creston -7:46:04 - LMT 1884 # hours behind Greenwich Time. # # * Yukon Standard Time defined as Pacific Standard Time, YCO 1973/214 -# http://www.canlii.org/en/yk/laws/regu/yco-1973-214/latest/yco-1973-214.html +# https://www.canlii.org/en/yk/laws/regu/yco-1973-214/latest/yco-1973-214.html # C.O. 1973/214 INTERPRETATION ACT ... # # 1. Effective October 28, 1973 Commissioner's Order 1967/59 is hereby @@ -2036,7 +2068,7 @@ Zone America/Creston -7:46:04 - LMT 1884 # http://? - no online source found # # * Yukon Daylight Saving Time, YOIC 1987/56 -# http://www.canlii.org/en/yk/laws/regu/yoic-1987-56/latest/yoic-1987-56.html +# https://www.canlii.org/en/yk/laws/regu/yoic-1987-56/latest/yoic-1987-56.html # O.I.C. 1987/056 INTERPRETATION ACT ... # # In every year between @@ -2048,7 +2080,7 @@ Zone America/Creston -7:46:04 - LMT 1884 # Dated ... 9th day of March, A.D., 1987. # # * Yukon Daylight Saving Time 2006, YOIC 2006/127 -# http://www.canlii.org/en/yk/laws/regu/yoic-2006-127/latest/yoic-2006-127.html +# https://www.canlii.org/en/yk/laws/regu/yoic-2006-127/latest/yoic-2006-127.html # O.I.C. 2006/127 INTERPRETATION ACT ... # # 1. In Yukon each year the time for general purposes shall be 7 hours @@ -2062,7 +2094,7 @@ Zone America/Creston -7:46:04 - LMT 1884 # 3. This order comes into force January 1, 2007. # # * Interpretation Act, RSY 2002, c 125 -# http://www.canlii.org/en/yk/laws/stat/rsy-2002-c-125/latest/rsy-2002-c-125.html +# https://www.canlii.org/en/yk/laws/stat/rsy-2002-c-125/latest/rsy-2002-c-125.html # From Rives McDow (1999-09-04): # Nunavut ... moved ... to incorporate the whole territory into one time zone. @@ -2105,7 +2137,7 @@ Zone America/Creston -7:46:04 - LMT 1884 # From Michaela Rodrigue, writing in the # Nunatsiaq News (1999-11-19): -# http://www.nunatsiaq.com/archives/nunavut991130/nvt91119_17.html +# http://www.nunatsiaqonline.ca/archives/nunavut991130/nvt91119_17.html # Clyde River, Pangnirtung and Sanikiluaq now operate with two time zones, # central - or Nunavut time - for government offices, and eastern time # for municipal offices and schools.... Igloolik [was similar but then] @@ -2123,7 +2155,7 @@ Zone America/Creston -7:46:04 - LMT 1884 # Central Time and Southampton Island [in the Central zone] is not # required to use daylight savings. -# From <http://www.nunatsiaq.com/archives/nunavut001130/nvt21110_02.html> +# From <http://www.nunatsiaqonline.ca/archives/nunavut001130/nvt21110_02.html> # Nunavut now has two time zones (2000-11-10): # The Nunavut government would allow its employees in Kugluktuk and # Cambridge Bay to operate on central time year-round, putting them @@ -2454,7 +2486,7 @@ Zone America/Dawson -9:17:40 - LMT 1900 Aug 20 # http://gaceta.diputados.gob.mx/Gaceta/61/2009/dic/V2-101209.html # # Our page: -# http://www.timeanddate.com/news/time/north-mexico-dst-change.html +# https://www.timeanddate.com/news/time/north-mexico-dst-change.html # From Arthur David Olson (2010-01-20): # The page @@ -2873,7 +2905,7 @@ Zone America/Costa_Rica -5:36:13 - LMT 1890 # San José # http://www.nnc.cubaweb.cu/marzo-2008/cien-1-11-3-08.htm # # Some more background information is posted here: -# http://www.timeanddate.com/news/time/cuba-starts-dst-march-16.html +# https://www.timeanddate.com/news/time/cuba-starts-dst-march-16.html # # The article also says that Cuba has been observing DST since 1963, # while Shanks (and tzdata) has 1965 as the first date (except in the @@ -2920,7 +2952,7 @@ Zone America/Costa_Rica -5:36:13 - LMT 1890 # San José # http://granma.co.cu/2011/03/08/nacional/artic01.html # # Our info: -# http://www.timeanddate.com/news/time/cuba-starts-dst-2011.html +# https://www.timeanddate.com/news/time/cuba-starts-dst-2011.html # # From Steffen Thorsen (2011-10-30) # Cuba will end DST two weeks later this year. Instead of going back @@ -2930,7 +2962,7 @@ Zone America/Costa_Rica -5:36:13 - LMT 1890 # San José # http://www.radioangulo.cu/noticias/cuba/17105-cuba-restablecera-el-horario-del-meridiano-de-greenwich.html # # Our page: -# http://www.timeanddate.com/news/time/cuba-time-changes-2011.html +# https://www.timeanddate.com/news/time/cuba-time-changes-2011.html # # From Steffen Thorsen (2012-03-01) # According to Radio Reloj, Cuba will start DST on Midnight between March @@ -2940,7 +2972,7 @@ Zone America/Costa_Rica -5:36:13 - LMT 1890 # San José # http://www.radioreloj.cu/index.php/noticias-radio-reloj/71-miscelaneas/7529-cuba-aplicara-el-horario-de-verano-desde-el-1-de-abril # # Our info on it: -# http://www.timeanddate.com/news/time/cuba-starts-dst-2012.html +# https://www.timeanddate.com/news/time/cuba-starts-dst-2012.html # From Steffen Thorsen (2012-11-03): # Radio Reloj and many other sources report that Cuba is changing back @@ -3135,8 +3167,8 @@ Zone America/Guatemala -6:02:04 - LMT 1918 Oct 5 # From Steffen Thorsen (2016-03-12): # Jean Antoine, editor of www.haiti-reference.com informed us that Haiti # are not going on DST this year. Several other resources confirm this: ... -# http://www.radiotelevisioncaraibes.com/presse/heure_d_t_pas_de_changement_d_heure_pr_vu_pour_cet_ann_e.html -# http://www.vantbefinfo.com/changement-dheure-pas-pour-haiti/ +# https://www.radiotelevisioncaraibes.com/presse/heure_d_t_pas_de_changement_d_heure_pr_vu_pour_cet_ann_e.html +# https://www.vantbefinfo.com/changement-dheure-pas-pour-haiti/ # http://news.anmwe.com/haiti-lheure-nationale-ne-sera-ni-avancee-ni-reculee-cette-annee/ # From Steffen Thorsen (2017-03-12): @@ -3335,7 +3367,7 @@ Zone America/Miquelon -3:44:40 - LMT 1911 May 15 # St Pierre # Turks and Caicos # # From Chris Dunn in -# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=415007 +# https://bugs.debian.org/415007 # (2007-03-15): In the Turks & Caicos Islands (America/Grand_Turk) the # daylight saving dates for time changes have been adjusted to match # the recent U.S. change of dates. @@ -3357,12 +3389,25 @@ Zone America/Miquelon -3:44:40 - LMT 1911 May 15 # St Pierre # "permanent daylight saving time" by one year.... # http://tcweeklynews.com/time-change-to-go-ahead-this-november-p5437-127.htm # +# From the Turks & Caicos Cabinet (2017-07-20), heads-up from Steffen Thorsen: +# ... agreed to the reintroduction in TCI of Daylight Saving Time (DST) +# during the summer months and Standard Time, also known as Local +# Time, during the winter months with effect from April 2018 ... +# https://www.gov.uk/government/news/turks-and-caicos-post-cabinet-meeting-statement--3 +# +# From Paul Eggert (2017-08-26): +# The date of effect of the spring 2018 change appears to be March 11, +# which makes more sense. See: Hamilton D. Time change back +# by March 2018 for TCI. Magnetic Media. 2017-08-25. +# http://magneticmediatv.com/2017/08/time-change-back-by-march-2018-for-tci/ +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone America/Grand_Turk -4:44:32 - LMT 1890 -5:07:11 - KMT 1912 Feb # Kingston Mean Time -5:00 - EST 1979 -5:00 US E%sT 2015 Nov Sun>=1 2:00 - -4:00 - AST + -4:00 - AST 2018 Mar 11 3:00 + -5:00 US E%sT # British Virgin Is # Virgin Is diff --git contrib/tzdata/southamerica contrib/tzdata/southamerica index 6038c3b65c26..bbae2261560b 100644 --- contrib/tzdata/southamerica +++ contrib/tzdata/southamerica @@ -22,7 +22,7 @@ # # For data circa 1899, a common source is: # Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94. -# http://www.jstor.org/stable/1774359 +# https://www.jstor.org/stable/1774359 # # These tables use numeric abbreviations like -03 and -0330 for # integer hour and minute UTC offsets. Although earlier editions used @@ -265,8 +265,8 @@ Rule Arg 2008 only - Oct Sun>=15 0:00 1:00 S # # Es inminente que en San Luis atrasen una hora los relojes # (It is imminent in San Luis clocks one hour delay) -# http://www.lagaceta.com.ar/nota/253414/Economia/Es-inminente-que-en-San-Luis-atrasen-una-hora-los-relojes.html -# http://www.worldtimezone.net/dst_news/dst_news_argentina02.html +# https://www.lagaceta.com.ar/nota/253414/Economia/Es-inminente-que-en-San-Luis-atrasen-una-hora-los-relojes.html +# http://www.worldtimezone.com/dst_news/dst_news_argentina02.html # From Jesper Nørgaard Welen (2008-01-18): # The page of the San Luis provincial government @@ -385,7 +385,7 @@ Rule Arg 2008 only - Oct Sun>=15 0:00 1:00 S # Perhaps San Luis operates on the legal fiction that it is at -04 # with perpetual summer time, but ordinary usage typically seems to # just say it's at -03; see, for example, -# http://es.wikipedia.org/wiki/Hora_oficial_argentina +# https://es.wikipedia.org/wiki/Hora_oficial_argentina # We've documented similar situations as being plain changes to # standard time, so let's do that here too. This does not change UTC # offsets, only tm_isdst and the time zone abbreviations. One minor @@ -716,7 +716,7 @@ Zone America/La_Paz -4:32:36 - LMT 1890 # (Portuguese) # # We have a written a short article about it as well: -# http://www.timeanddate.com/news/time/brazil-dst-2008-2009.html +# https://www.timeanddate.com/news/time/brazil-dst-2008-2009.html # # From Alexander Krivenyshev (2011-10-04): # State Bahia will return to Daylight savings time this year after 8 years off. @@ -725,7 +725,7 @@ Zone America/La_Paz -4:32:36 - LMT 1890 # In Portuguese: # http://g1.globo.com/bahia/noticia/2011/10/governador-jaques-wagner-confirma-horario-de-verao-na-bahia.html -# http://noticias.terra.com.br/brasil/noticias/0,,OI5390887-EI8139,00-Bahia+volta+a+ter+horario+de+verao+apos+oito+anos.html +# https://noticias.terra.com.br/brasil/noticias/0,,OI5390887-EI8139,00-Bahia+volta+a+ter+horario+de+verao+apos+oito+anos.html # From Guilherme Bernardes Rodrigues (2011-10-07): # There is news in the media, however there is still no decree about it. @@ -751,16 +751,16 @@ Zone America/La_Paz -4:32:36 - LMT 1890 # From Rodrigo Severo (2012-10-16): # Tocantins state will have DST. -# http://noticias.terra.com.br/brasil/noticias/0,,OI6232536-EI306.html +# https://noticias.terra.com.br/brasil/noticias/0,,OI6232536-EI306.html # From Steffen Thorsen (2013-09-20): # Tocantins in Brazil is very likely not to observe DST from October.... # http://conexaoto.com.br/2013/09/18/ministerio-confirma-que-tocantins-esta-fora-do-horario-de-verao-em-2013-mas-falta-publicacao-de-decreto # We will keep this article updated when this is confirmed: -# http://www.timeanddate.com/news/time/brazil-starts-dst-2013.html +# https://www.timeanddate.com/news/time/brazil-starts-dst-2013.html # From Steffen Thorsen (2013-10-17): -# http://www.timeanddate.com/news/time/acre-amazonas-change-time-zone.html +# https://www.timeanddate.com/news/time/acre-amazonas-change-time-zone.html # Senator Jorge Viana announced that Acre will change time zone on November 10. # He did not specify the time of the change, nor if western parts of Amazonas # will change as well. @@ -1076,18 +1076,18 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914 # the following source, cited by Oscar van Vlijmen (2006-10-08): # [1] Chile Law # http://www.webexhibits.org/daylightsaving/chile.html -# This contains a copy of a this official table: +# This contains a copy of this official table: # Cambios en la hora oficial de Chile desde 1900 (retrieved 2008-03-30) -# http://web.archive.org/web/20080330200901/http://www.horaoficial.cl/cambio.htm +# https://web.archive.org/web/20080330200901/http://www.horaoficial.cl/cambio.htm # [1] needs several corrections, though. # # The first set of corrections is from: # [2] History of the Official Time of Chile # http://www.horaoficial.cl/ing/horaof_ing.html (retrieved 2012-03-06). See: -# http://web.archive.org/web/20120306042032/http://www.horaoficial.cl/ing/horaof_ing.html +# https://web.archive.org/web/20120306042032/http://www.horaoficial.cl/ing/horaof_ing.html # This is an English translation of: # Historia de la hora oficial de Chile (retrieved 2012-10-24). See: -# http://web.archive.org/web/20121024234627/http://www.horaoficial.cl/horaof.htm +# https://web.archive.org/web/20121024234627/http://www.horaoficial.cl/horaof.htm # A fancier Spanish version (requiring mouse-clicking) is at: # http://www.horaoficial.cl/historia_hora.html # Conflicts between [1] and [2] were resolved as follows: @@ -1363,10 +1363,10 @@ Link America/Curacao America/Kralendijk # Caribbean Netherlands # Milne says the Central and South American Telegraph Company used -5:24:15. # # From Alois Treindl (2016-12-15): -# http://www.elcomercio.com/actualidad/hora-sixto-1993.html +# https://www.elcomercio.com/actualidad/hora-sixto-1993.html # ... Whether the law applied also to Galápagos, I do not know. # From Paul Eggert (2016-12-15): -# http://www.elcomercio.com/afull/modificacion-husohorario-ecuador-presidentes-decreto.html +# https://www.elcomercio.com/afull/modificacion-husohorario-ecuador-presidentes-decreto.html # This says President Sixto Durán Ballén signed decree No. 285, which # established DST from 1992-11-28 to 1993-02-05; it does not give transition # times. The people called it "hora de Sixto" ("Sixto hour"). The change did @@ -1778,7 +1778,7 @@ Zone America/Montevideo -3:44:44 - LMT 1898 Jun 28 # hours of presidential broadcasts, hours of lines,' quipped comedian # Jean Mary Curró ...". See: Cawthorne A, Kai D. Venezuela scraps # half-hour time difference set by Chavez. Reuters 2016-04-15 14:50 -0400 -# http://www.reuters.com/article/us-venezuela-timezone-idUSKCN0XC2BE +# https://www.reuters.com/article/us-venezuela-timezone-idUSKCN0XC2BE # # From Matt Johnson (2016-04-20): # ... published in the official Gazette [2016-04-18], here: diff --git contrib/tzdata/theory.html contrib/tzdata/theory.html new file mode 100644 index 000000000000..965135d7e541 --- /dev/null +++ contrib/tzdata/theory.html @@ -0,0 +1,1034 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <title>Theory and pragmatics of the tz code and data</title> + <meta charset="UTF-8"> +</head> + +<!-- The somewhat-unusal indenting style in this file is intended to + shrink the output of the shell command 'diff Theory Theory.html', + where 'Theory' was the plain text file that this file is derived + from. The 'Theory' file used leading white space to indent, and + when possible that indentation is preserved here. Eventually we + may stop doing this and remove this comment. --> + +<body> + <h1>Theory and pragmatics of the tz code and data</h1> + <h3>Outline</h3> + <nav> + <ul> + <li><a href="#scope">Scope of the tz database</a></li> + <li><a href="#naming">Names of time zone rules</a></li> + <li><a href="#abbreviations">Time zone abbreviations</a></li> + <li><a href="#accuracy">Accuracy of the tz database</a></li> + <li><a href="#functions">Time and date functions</a></li> + <li><a href="#stability">Interface stability</a></li> + <li><a href="#calendar">Calendrical issues</a></li> + <li><a href="#planets">Time and time zones on other planets</a></li> + </ul> + </nav> + + + <section> + <h2 id="scope">Scope of the tz database</h2> +<p> +The tz database attempts to record the history and predicted future of +all computer-based clocks that track civil time. To represent this +data, the world is partitioned into regions whose clocks all agree +about timestamps that occur after the somewhat-arbitrary cutoff point +of the POSIX Epoch (1970-01-01 00:00:00 UTC). For each such region, +the database records all known clock transitions, and labels the region +with a notable location. Although 1970 is a somewhat-arbitrary +cutoff, there are significant challenges to moving the cutoff earlier +even by a decade or two, due to the wide variety of local practices +before computer timekeeping became prevalent. +</p> + +<p> +Clock transitions before 1970 are recorded for each such location, +because most systems support timestamps before 1970 and could +misbehave if data entries were omitted for pre-1970 transitions. +However, the database is not designed for and does not suffice for +applications requiring accurate handling of all past times everywhere, +as it would take far too much effort and guesswork to record all +details of pre-1970 civil timekeeping. +</p> + +<p> +As described below, reference source code for using the tz database is +also available. The tz code is upwards compatible with POSIX, an +international standard for UNIX-like systems. As of this writing, the +current edition of POSIX is: + <a href="http://pubs.opengroup.org/onlinepubs/9699919799/"> + The Open Group Base Specifications Issue 7</a>, + IEEE Std 1003.1-2008, 2016 Edition. +</p> + </section> + + + + <section> + <h2 id="naming">Names of time zone rules</h2> +<p> +Each of the database's time zone rules has a unique name. +Inexperienced users are not expected to select these names unaided. +Distributors should provide documentation and/or a simple selection +interface that explains the names; for one example, see the 'tzselect' +program in the tz code. The +<a href="http://cldr.unicode.org/">Unicode Common Locale Data +Repository</a> contains data that may be useful for other +selection interfaces. +</p> + +<p> +The time zone rule naming conventions attempt to strike a balance +among the following goals: +</p> +<ul> + <li> + Uniquely identify every region where clocks have agreed since 1970. + This is essential for the intended use: static clocks keeping local + civil time. + </li> + <li> + Indicate to experts where that region is. + </li> + <li> + Be robust in the presence of political changes. For example, names + of countries are ordinarily not used, to avoid incompatibilities + when countries change their name (e.g. Zaire→Congo) or when + locations change countries (e.g. Hong Kong from UK colony to + China). + </li> + <li> + Be portable to a wide variety of implementations. + </li> + <li> + Use a consistent naming conventions over the entire world. + </li> +</ul> +<p> +Names normally have the +form <var>AREA</var><code>/</code><var>LOCATION</var>, +where <var>AREA</var> is the name of a continent or ocean, +and <var>LOCATION</var> is the name of a specific +location within that region. North and South America share the same +area, '<code>America</code>'. Typical names are +'<code>Africa/Cairo</code>', '<code>America/New_York</code>', and +'<code>Pacific/Honolulu</code>'. +</p> + +<p> +Here are the general rules used for choosing location names, +in decreasing order of importance: +</p> +<ul> + <li> + Use only valid POSIX file name components (i.e., the parts of + names other than '<code>/</code>'). Do not use the file name + components '<code>.</code>' and '<code>..</code>'. + Within a file name component, + use only ASCII letters, '<code>.</code>', + '<code>-</code>' and '<code>_</code>'. Do not use + digits, as that might create an ambiguity with POSIX + TZ strings. A file name component must not exceed 14 + characters or start with '<code>-</code>'. E.g., + prefer '<code>Brunei</code>' to + '<code>Bandar_Seri_Begawan</code>'. Exceptions: see + the discussion + of legacy names below. + </li> + <li> + A name must not be empty, or contain '<code>//</code>', or + start or end with '<code>/</code>'. + </li> + <li> + Do not use names that differ only in case. Although the reference + implementation is case-sensitive, some other implementations + are not, and they would mishandle names differing only in case. + </li> + <li> + If one name <var>A</var> is an initial prefix of another + name <var>AB</var> (ignoring case), then <var>B</var> + must not start with '<code>/</code>', as a + regular file cannot have + the same name as a directory in POSIX. For example, + '<code>America/New_York</code>' precludes + '<code>America/New_York/Bronx</code>'. + </li> + <li> + Uninhabited regions like the North Pole and Bouvet Island + do not need locations, since local time is not defined there. + </li> + <li> + There should typically be at least one name for each ISO 3166-1 + officially assigned two-letter code for an inhabited country + or territory. + </li> + <li> + If all the clocks in a region have agreed since 1970, + don't bother to include more than one location + even if subregions' clocks disagreed before 1970. + Otherwise these tables would become annoyingly large. + </li> + <li> + If a name is ambiguous, use a less ambiguous alternative; + e.g. many cities are named San José and Georgetown, so + prefer '<code>Costa_Rica</code>' to '<code>San_Jose</code>' and '<code>Guyana</code>' to '<code>Georgetown</code>'. + </li> + <li> + Keep locations compact. Use cities or small islands, not countries + or regions, so that any future time zone changes do not split + locations into different time zones. E.g. prefer + '<code>Paris</code>' to '<code>France</code>', since + France has had multiple time zones. + </li> + <li> + Use mainstream English spelling, e.g. prefer + '<code>Rome</code>' to '<code>Roma</code>', and prefer + '<code>Athens</code>' to the Greek + '<code>Αθήνα</code>' or the Romanized + '<code>AthÃna</code>'. + The POSIX file name restrictions encourage this rule. + </li> + <li> + Use the most populous among locations in a zone, + e.g. prefer '<code>Shanghai</code>' to + '<code>Beijing</code>'. Among locations with + similar populations, pick the best-known location, + e.g. prefer '<code>Rome</code>' to '<code>Milan</code>'. + </li> + <li> + Use the singular form, e.g. prefer '<code>Canary</code>' to '<code>Canaries</code>'. + </li> + <li> + Omit common suffixes like '<code>_Islands</code>' and + '<code>_City</code>', unless that would lead to + ambiguity. E.g. prefer '<code>Cayman</code>' to + '<code>Cayman_Islands</code>' and + '<code>Guatemala</code>' to + '<code>Guatemala_City</code>', but prefer + '<code>Mexico_City</code>' to '<code>Mexico</code>' + because the country + of Mexico has several time zones. + </li> + <li> + Use '<code>_</code>' to represent a space. + </li> + <li> + Omit '<code>.</code>' from abbreviations in names, e.g. prefer + '<code>St_Helena</code>' to '<code>St._Helena</code>'. + </li> + <li> + Do not change established names if they only marginally + violate the above rules. For example, don't change + the existing name '<code>Rome</code>' to + '<code>Milan</code>' merely because + Milan's population has grown to be somewhat greater + than Rome's. + </li> + <li> + If a name is changed, put its old spelling in the + '<code>backward</code>' file. + This means old spellings will continue to work. + </li> +</ul> + +<p> +The file '<code>zone1970.tab</code>' lists geographical locations used +to name time +zone rules. It is intended to be an exhaustive list of names for +geographic regions as described above; this is a subset of the names +in the data. Although a '<code>zone1970.tab</code>' location's longitude +corresponds to its LMT offset with one hour for every 15 degrees east +longitude, this relationship is not exact. +</p> + +<p> +Older versions of this package used a different naming scheme, +and these older names are still supported. +See the file '<code>backward</code>' for most of these older names +(e.g., '<code>US/Eastern</code>' instead of '<code>America/New_York</code>'). +The other old-fashioned names still supported are +'<code>WET</code>', '<code>CET</code>', '<code>MET</code>', and '<code>EET</code>' (see the file '<code>europe</code>'). +</p> + +<p> +Older versions of this package defined legacy names that are +incompatible with the first rule of location names, but which are +still supported. These legacy names are mostly defined in the file +'<code>etcetera</code>'. Also, the file '<code>backward</code>' defines the legacy names +'<code>GMT0</code>', '<code>GMT-0</code>' and '<code>GMT+0</code>', and the file '<code>northamerica</code>' defines the +legacy names '<code>EST5EDT</code>', '<code>CST6CDT</code>', '<code>MST7MDT</code>', and '<code>PST8PDT</code>'. +</p> + +<p> +Excluding '<code>backward</code>' should not affect the other data. If +'<code>backward</code>' is excluded, excluding '<code>etcetera</code>' should not affect the +remaining data. +</p> + + + </section> + <section> + <h2 id="abbreviations">Time zone abbreviations</h2> +<p> +When this package is installed, it generates time zone abbreviations +like '<code>EST</code>' to be compatible with human tradition and POSIX. +Here are the general rules used for choosing time zone abbreviations, +in decreasing order of importance: +<ul> + <li> + Use three or more characters that are ASCII alphanumerics or + '<code>+</code>' or '<code>-</code>'. + Previous editions of this database also used characters like + '<code> </code>' and '<code>?</code>', but these + characters have a special meaning to + the shell and cause commands like + '<code>set `date`</code>' + to have unexpected effects. + Previous editions of this rule required upper-case letters, + but the Congressman who introduced Chamorro Standard Time + preferred "ChST", so lower-case letters are now allowed. + Also, POSIX from 2001 on relaxed the rule to allow + '<code>-</code>', '<code>+</code>', + and alphanumeric characters from the portable character set + in the current locale. In practice ASCII alphanumerics and + '<code>+</code>' and '<code>-</code>' are safe in all locales. + + In other words, in the C locale the POSIX extended regular + expression <code>[-+[:alnum:]]{3,}</code> should match + the abbreviation. + This guarantees that all abbreviations could have been + specified by a POSIX TZ string. + </li> + <li> + Use abbreviations that are in common use among English-speakers, + e.g. 'EST' for Eastern Standard Time in North America. + We assume that applications translate them to other languages + as part of the normal localization process; for example, + a French application might translate 'EST' to 'HNE'. + </li> + <li> + For zones whose times are taken from a city's longitude, use the + traditional <var>x</var>MT notation, e.g. 'PMT' for + Paris Mean Time. + The only name like this in current use is 'GMT'. + </li> + <li> + Use 'LMT' for local mean time of locations before the introduction + of standard time; see "<a href="#scope">Scope of the + tz database</a>". + </li> + <li> + If there is no common English abbreviation, use numeric offsets like + <code>-</code>05 and <code>+</code>0830 that are + generated by zic's <code>%z</code> notation. + </li> + <li> + Use current abbreviations for older timestamps to avoid confusion. + For example, in 1910 a common English abbreviation for UT +01 + in central Europe was 'MEZ' (short for both "Middle European + Zone" and for "Mitteleuropäische Zeit" in German). Nowadays + 'CET' ("Central European Time") is more common in English, and + the database uses 'CET' even for circa-1910 timestamps as this + is less confusing for modern users and avoids the need for + determining when 'CET' supplanted 'MEZ' in common usage. + </li> + <li> + Use a consistent style in a zone's history. For example, if a zone's + history tends to use numeric abbreviations and a particular + entry could go either way, use a numeric abbreviation. + </li> +</ul> + [The remaining guidelines predate the introduction of <code>%z</code>. + They are problematic as they mean tz data entries invent + notation rather than record it. These guidelines are now + deprecated and the plan is to gradually move to <code>%z</code> for + inhabited locations and to "<code>-</code>00" for uninhabited locations.] +<ul> + <li> + If there is no common English abbreviation, abbreviate the English + translation of the usual phrase used by native speakers. + If this is not available or is a phrase mentioning the country + (e.g. "Cape Verde Time"), then: + <ul> + <li> + When a country is identified with a single or principal zone, + append 'T' to the country's ISO code, e.g. 'CVT' for + Cape Verde Time. For summer time append 'ST'; + for double summer time append 'DST'; etc. + </li> + <li> + Otherwise, take the first three letters of an English place + name identifying each zone and append 'T', 'ST', etc. + as before; e.g. 'CHAST' for CHAtham Summer Time. + </li> + </ul> + </li> + <li> + Use UT (with time zone abbreviation '<code>-</code>00') for + locations while uninhabited. The leading + '<code>-</code>' is a flag that the time + zone is in some sense undefined; this notation is + derived from Internet RFC 3339. + </li> +</ul> +<p> +Application writers should note that these abbreviations are ambiguous +in practice: e.g. 'CST' has a different meaning in China than +it does in the United States. In new applications, it's often better +to use numeric UT offsets like '<code>-</code>0600' instead of time zone +abbreviations like 'CST'; this avoids the ambiguity. +</p> + </section> + + + <section> + <h2 id="accuracy">Accuracy of the tz database</h2> +<p> +The tz database is not authoritative, and it surely has errors. +Corrections are welcome and encouraged; see the file CONTRIBUTING. +Users requiring authoritative data should consult national standards +bodies and the references cited in the database's comments. +</p> + +<p> +Errors in the tz database arise from many sources: +</p> +<ul> + <li> + The tz database predicts future timestamps, and current predictions + will be incorrect after future governments change the rules. + For example, if today someone schedules a meeting for 13:00 next + October 1, Casablanca time, and tomorrow Morocco changes its + daylight saving rules, software can mess up after the rule change + if it blithely relies on conversions made before the change. + </li> + <li> + The pre-1970 entries in this database cover only a tiny sliver of how + clocks actually behaved; the vast majority of the necessary + information was lost or never recorded. Thousands more zones would + be needed if the tz database's scope were extended to cover even + just the known or guessed history of standard time; for example, + the current single entry for France would need to split into dozens + of entries, perhaps hundreds. And in most of the world even this + approach would be misleading due to widespread disagreement or + indifference about what times should be observed. In her 2015 book + <cite>The Global Transformation of Time, 1870-1950</cite>, Vanessa Ogle writes + "Outside of Europe and North America there was no system of time + zones at all, often not even a stable landscape of mean times, + prior to the middle decades of the twentieth century". See: + Timothy Shenk, <a + href="https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanessa-ogle">Booked: + A Global History of Time</a>. <cite>Dissent</cite> 2015-12-17. + </li> + <li> + Most of the pre-1970 data entries come from unreliable sources, often + astrology books that lack citations and whose compilers evidently + invented entries when the true facts were unknown, without + reporting which entries were known and which were invented. + These books often contradict each other or give implausible entries, + and on the rare occasions when they are checked they are + typically found to be incorrect. + </li> + <li> + For the UK the tz database relies on years of first-class work done by + Joseph Myers and others; see + "<a href="https://www.polyomino.org.uk/british-time/">History of + legal time in Britain</a>". + Other countries are not done nearly as well. + </li> + <li> + Sometimes, different people in the same city would maintain clocks + that differed significantly. Railway time was used by railroad + companies (which did not always agree with each other), + church-clock time was used for birth certificates, etc. + Often this was merely common practice, but sometimes it was set by law. + For example, from 1891 to 1911 the UT offset in France was legally + 0:09:21 outside train stations and 0:04:21 inside. + </li> + <li> + Although a named location in the tz database stands for the + containing region, its pre-1970 data entries are often accurate for + only a small subset of that region. For example, <code>Europe/London</code> + stands for the United Kingdom, but its pre-1847 times are valid + only for locations that have London's exact meridian, and its 1847 + transition to GMT is known to be valid only for the L&NW and the + Caledonian railways. + </li> + <li> + The tz database does not record the earliest time for which a zone's + data entries are thereafter valid for every location in the region. + For example, <code>Europe/London</code> is valid for all locations in its + region after GMT was made the standard time, but the date of + standardization (1880-08-02) is not in the tz database, other than + in commentary. For many zones the earliest time of validity is + unknown. + </li> + <li> + The tz database does not record a region's boundaries, and in many + cases the boundaries are not known. For example, the zone + <code>America/Kentucky/Louisville</code> represents a region around + the city of + Louisville, the boundaries of which are unclear. + </li> + <li> + Changes that are modeled as instantaneous transitions in the tz + database were often spread out over hours, days, or even decades. + </li> + <li> + Even if the time is specified by law, locations sometimes + deliberately flout the law. + </li> + <li> + Early timekeeping practices, even assuming perfect clocks, were + often not specified to the accuracy that the tz database requires. + </li> + <li> + Sometimes historical timekeeping was specified more precisely + than what the tz database can handle. For example, from 1909 to + 1937 Netherlands clocks were legally UT +00:19:32.13, but the tz + database cannot represent the fractional second. + </li> + <li> + Even when all the timestamp transitions recorded by the tz database + are correct, the tz rules that generate them may not faithfully + reflect the historical rules. For example, from 1922 until World + War II the UK moved clocks forward the day following the third + Saturday in April unless that was Easter, in which case it moved + clocks forward the previous Sunday. Because the tz database has no + way to specify Easter, these exceptional years are entered as + separate tz Rule lines, even though the legal rules did not change. + </li> + <li> + The tz database models pre-standard time using the proleptic Gregorian + calendar and local mean time (LMT), but many people used other + calendars and other timescales. For example, the Roman Empire used + the Julian calendar, and had 12 varying-length daytime hours with a + non-hour-based system at night. + </li> + <li> + Early clocks were less reliable, and data entries do not represent + clock error. + </li> + <li> + The tz database assumes Universal Time (UT) as an origin, even + though UT is not standardized for older timestamps. In the tz + database commentary, UT denotes a family of time standards that + includes Coordinated Universal Time (UTC) along with other variants + such as UT1 and GMT, with days starting at midnight. Although UT + equals UTC for modern timestamps, UTC was not defined until 1960, + so commentary uses the more-general abbreviation UT for timestamps + that might predate 1960. Since UT, UT1, etc. disagree slightly, + and since pre-1972 UTC seconds varied in length, interpretation of + older timestamps can be problematic when subsecond accuracy is + needed. + </li> + <li> + Civil time was not based on atomic time before 1972, and we don't + know the history of earth's rotation accurately enough to map SI + seconds to historical solar time to more than about one-hour + accuracy. See: Stephenson FR, Morrison LV, Hohenkerk CY. + <a href="http://dx.doi.org/10.1098/rspa.2016.0404">Measurement + of the Earth's rotation: 720 BC to AD 2015</a>. + <cite>Proc Royal Soc A</cite>. 2016 Dec 7;472:20160404. + Also see: Espenak F. <a + href="https://eclipse.gsfc.nasa.gov/SEhelp/uncertainty2004.html">Uncertainty + in Delta T (ΔT)</a>. + </li> + <li> + The relationship between POSIX time (that is, UTC but ignoring leap + seconds) and UTC is not agreed upon after 1972. Although the POSIX + clock officially stops during an inserted leap second, at least one + proposed standard has it jumping back a second instead; and in + practice POSIX clocks more typically either progress glacially during + a leap second, or are slightly slowed while near a leap second. + </li> + <li> + The tz database does not represent how uncertain its information is. + Ideally it would contain information about when data entries are + incomplete or dicey. Partial temporal knowledge is a field of + active research, though, and it's not clear how to apply it here. + </li> +</ul> +<p> +In short, many, perhaps most, of the tz database's pre-1970 and future +timestamps are either wrong or misleading. Any attempt to pass the +tz database off as the definition of time should be unacceptable to +anybody who cares about the facts. In particular, the tz database's +LMT offsets should not be considered meaningful, and should not prompt +creation of zones merely because two locations differ in LMT or +transitioned to standard time at different dates. +</p> + </section> + + + <section> + <h2 id="functions">Time and date functions</h2> +<p> +The tz code contains time and date functions that are upwards +compatible with those of POSIX. +</p> + +<p> +POSIX has the following properties and limitations. +</p> +<ul> + <li> + <p> + In POSIX, time display in a process is controlled by the + environment variable TZ. Unfortunately, the POSIX TZ string takes + a form that is hard to describe and is error-prone in practice. + Also, POSIX TZ strings can't deal with other (for example, Israeli) + daylight saving time rules, or situations where more than two + time zone abbreviations are used in an area. + </p> + <p> + The POSIX TZ string takes the following form: + </p> + <p> + <var>stdoffset</var>[<var>dst</var>[<var>offset</var>][<code>,</code><var>date</var>[<code>/</code><var>time</var>]<code>,</code><var>date</var>[<code>/</code><var>time</var>]]] + </p> + <p> + where: + <dl> + <dt><var>std</var> and <var>dst</var></dt><dd> + are 3 or more characters specifying the standard + and daylight saving time (DST) zone names. + Starting with POSIX.1-2001, <var>std</var> + and <var>dst</var> may also be + in a quoted form like '<code><UTC+10></code>'; this allows + "<code>+</code>" and "<code>-</code>" in the names. + </dd> + <dt><var>offset</var></dt><dd> + is of the form + '<code>[±]<var>hh</var>:[<var>mm</var>[:<var>ss</var>]]</code>' + and specifies the offset west of UT. '<var>hh</var>' + may be a single digit; 0≤<var>hh</var>≤24. + The default DST offset is one hour ahead of standard time. + </dd> + <dt><var>date</var>[<code>/</code><var>time</var>]<code>,</code><var>date</var>[<code>/</code><var>time</var>]</dt><dd> + specifies the beginning and end of DST. If this is absent, + the system supplies its own rules for DST, and these can + differ from year to year; typically US DST rules are used. + </dd> + <dt><var>time</var></dt><dd> + takes the form + '<var>hh</var><code>:</code>[<var>mm</var>[<code>:</code><var>ss</var>]]' + and defaults to 02:00. + This is the same format as the offset, except that a + leading '<code>+</code>' or '<code>-</code>' is not allowed. + </dd> + <dt><var>date</var></dt><dd> + takes one of the following forms: + <dl> + <dt>J<var>n</var> (1≤<var>n</var>≤365)</dt><dd> + origin-1 day number not counting February 29 + </dd> + <dt><var>n</var> (0≤<var>n</var>≤365)</dt><dd> + origin-0 day number counting February 29 if present + </dd> + <dt><code>M</code><var>m</var><code>.</code><var>n</var><code>.</code><var>d</var> (0[Sunday]≤<var>d</var>≤6[Saturday], 1≤<var>n</var>≤5, 1≤<var>m</var>≤12)</dt><dd> + for the <var>d</var>th day of + week <var>n</var> of month <var>m</var> of the + year, where week 1 is the first week in which + day <var>d</var> appears, and '<code>5</code>' + stands for the last week in which + day <var>d</var> appears + (which may be either the 4th or 5th week). + Typically, this is the only useful form; + the <var>n</var> + and <code>J</code><var>n</var> forms are + rarely used. + </dd> +</dl> +</dd> +</dl> + Here is an example POSIX TZ string for New Zealand after 2007. + It says that standard time (NZST) is 12 hours ahead of UTC, + and that daylight saving time (NZDT) is observed from September's + last Sunday at 02:00 until April's first Sunday at 03:00: + + <pre><code>TZ='NZST-12NZDT,M9.5.0,M4.1.0/3'</code></pre> + + This POSIX TZ string is hard to remember, and mishandles some + timestamps before 2008. With this package you can use this + instead: + + <pre><code>TZ='Pacific/Auckland'</code></pre> + </li> + <li> + POSIX does not define the exact meaning of TZ values like + "<code>EST5EDT</code>". + Typically the current US DST rules are used to interpret such values, + but this means that the US DST rules are compiled into each program + that does time conversion. This means that when US time conversion + rules change (as in the United States in 1987), all programs that + do time conversion must be recompiled to ensure proper results. + </li> + <li> + The TZ environment variable is process-global, which makes it hard + to write efficient, thread-safe applications that need access + to multiple time zones. + </li> + <li> + In POSIX, there's no tamper-proof way for a process to learn the + system's best idea of local wall clock. (This is important for + applications that an administrator wants used only at certain + times – + without regard to whether the user has fiddled the TZ environment + variable. While an administrator can "do everything in UTC" to get + around the problem, doing so is inconvenient and precludes handling + daylight saving time shifts - as might be required to limit phone + calls to off-peak hours.) + </li> + <li> + POSIX provides no convenient and efficient way to determine the UT + offset and time zone abbreviation of arbitrary timestamps, + particularly for time zone settings that do not fit into the + POSIX model. + </li> + <li> + POSIX requires that systems ignore leap seconds. + </li> + <li> + The tz code attempts to support all the <code>time_t</code> + implementations allowed by POSIX. The <code>time_t</code> + type represents a nonnegative count of + seconds since 1970-01-01 00:00:00 UTC, ignoring leap seconds. + In practice, <code>time_t</code> is usually a signed 64- or + 32-bit integer; 32-bit signed <code>time_t</code> values stop + working after 2038-01-19 03:14:07 UTC, so + new implementations these days typically use a signed 64-bit integer. + Unsigned 32-bit integers are used on one or two platforms, + and 36-bit and 40-bit integers are also used occasionally. + Although earlier POSIX versions allowed <code>time_t</code> to be a + floating-point type, this was not supported by any practical + systems, and POSIX.1-2013 and the tz code both + require <code>time_t</code> + to be an integer type. + </li> +</ul> +<p> +These are the extensions that have been made to the POSIX functions: +</p> +<ul> + <li> + <p> + The TZ environment variable is used in generating the name of a file + from which time zone information is read (or is interpreted a la + POSIX); TZ is no longer constrained to be a three-letter time zone + name followed by a number of hours and an optional three-letter + daylight time zone name. The daylight saving time rules to be used + for a particular time zone are encoded in the time zone file; + the format of the file allows U.S., Australian, and other rules to be + encoded, and allows for situations where more than two time zone + abbreviations are used. + </p> + <p> + It was recognized that allowing the TZ environment variable to + take on values such as '<code>America/New_York</code>' might + cause "old" programs + (that expect TZ to have a certain form) to operate incorrectly; + consideration was given to using some other environment variable + (for example, TIMEZONE) to hold the string used to generate the + time zone information file name. In the end, however, it was decided + to continue using TZ: it is widely used for time zone purposes; + separately maintaining both TZ and TIMEZONE seemed a nuisance; + and systems where "new" forms of TZ might cause problems can simply + use TZ values such as "<code>EST5EDT</code>" which can be used both by + "new" programs (a la POSIX) and "old" programs (as zone names and + offsets). + </p> +</li> +<li> + The code supports platforms with a UT offset member + in <code>struct tm</code>, + e.g., <code>tm_gmtoff</code>. +</li> +<li> + The code supports platforms with a time zone abbreviation member in + <code>struct tm</code>, e.g., <code>tm_zone</code>. +</li> +<li> + Since the TZ environment variable can now be used to control time + conversion, the <code>daylight</code> + and <code>timezone</code> variables are no longer needed. + (These variables are defined and set by <code>tzset</code>; + however, their values will not be used + by <code>localtime</code>.) +</li> +<li> + Functions <code>tzalloc</code>, <code>tzfree</code>, + <code>localtime_rz</code>, and <code>mktime_z</code> for + more-efficient thread-safe applications that need to use + multiple time zones. The <code>tzalloc</code> + and <code>tzfree</code> functions allocate and free objects of + type <code>timezone_t</code>, and <code>localtime_rz</code> + and <code>mktime_z</code> are like <code>localtime_r</code> + and <code>mktime</code> with an extra + <code>timezone_t</code> argument. The functions were inspired + by NetBSD. +</li> +<li> + A function <code>tzsetwall</code> has been added to arrange + for the system's + best approximation to local wall clock time to be delivered by + subsequent calls to <code>localtime</code>. Source code for portable + applications that "must" run on local wall clock time should call + <code>tzsetwall</code>; if such code is moved to "old" systems that don't + provide tzsetwall, you won't be able to generate an executable program. + (These time zone functions also arrange for local wall clock time to be + used if tzset is called – directly or indirectly – + and there's no TZ + environment variable; portable applications should not, however, rely + on this behavior since it's not the way SVR2 systems behave.) +</li> +<li> + Negative <code>time_t</code> values are supported, on systems + where <code>time_t</code> is signed. +</li> +<li> + These functions can account for leap seconds, thanks to Bradley White. +</li> +</ul> +<p> +Points of interest to folks with other systems: +</p> +<ul> + <li> + Code compatible with this package is already part of many platforms, + including GNU/Linux, Android, the BSDs, Chromium OS, Cygwin, AIX, iOS, + BlackBery 10, macOS, Microsoft Windows, OpenVMS, and Solaris. + On such hosts, the primary use of this package + is to update obsolete time zone rule tables. + To do this, you may need to compile the time zone compiler + '<code>zic</code>' supplied with this package instead of using + the system '<code>zic</code>', since the format + of <code>zic</code>'s input is occasionally extended, and a + platform may still be shipping an older <code>zic</code>. + </li> + <li> + The UNIX Version 7 <code>timezone</code> function is not + present in this package; + it's impossible to reliably map timezone's arguments (a "minutes west + of GMT" value and a "daylight saving time in effect" flag) to a + time zone abbreviation, and we refuse to guess. + Programs that in the past used the timezone function may now examine + <code>localtime(&clock)->tm_zone</code> + (if <code>TM_ZONE</code> is defined) or + <code>tzname[localtime(&clock)->tm_isdst]</code> + (if <code>HAVE_TZNAME</code> is defined) + to learn the correct time zone abbreviation to use. + </li> + <li> + The 4.2BSD <code>gettimeofday</code> function is not used in + this package. + This formerly let users obtain the current UTC offset and DST flag, + but this functionality was removed in later versions of BSD. + </li> + <li> + In SVR2, time conversion fails for near-minimum or near-maximum + <code>time_t</code> values when doing conversions for places + that don't use UT. + This package takes care to do these conversions correctly. + A comment in the source code tells how to get compatibly wrong + results. + </li> +</ul> +<p> +The functions that are conditionally compiled +if <code>STD_INSPIRED</code> is defined +should, at this point, be looked on primarily as food for thought. They are +not in any sense "standard compatible" – some are not, in fact, +specified in <em>any</em> standard. They do, however, represent responses of +various authors to +standardization proposals. +</p> + +<p> +Other time conversion proposals, in particular the one developed by folks at +Hewlett Packard, offer a wider selection of functions that provide capabilities +beyond those provided here. The absence of such functions from this package +is not meant to discourage the development, standardization, or use of such +functions. Rather, their absence reflects the decision to make this package +contain valid extensions to POSIX, to ensure its broad acceptability. If +more powerful time conversion functions can be standardized, so much the +better. +</p> + </section> + + + <section> + <h2 id="stability">Interface stability</h2> +<p> +The tz code and data supply the following interfaces: +</p> +<ul> + <li> + A set of zone names as per "<a href="#naming">Names of time zone + rules</a>" above. + </li> + <li> + Library functions described in "<a href="#functions">Time and date + functions</a>" above. + </li> + <li> + The programs <code>tzselect</code>, <code>zdump</code>, + and <code>zic</code>, documented in their man pages. + </li> + <li> + The format of <code>zic</code> input files, documented in + the <code>zic</code> man page. + </li> + <li> + The format of <code>zic</code> output files, documented in + the <code>tzfile</code> man page. + </li> + <li> + The format of zone table files, documented in <code>zone1970.tab</code>. + </li> + <li> + The format of the country code file, documented in <code>iso3166.tab</code>. + </li> + <li> + The version number of the code and data, as the first line of + the text file '<code>version</code>' in each release. + </li> +</ul> +<p> +Interface changes in a release attempt to preserve compatibility with +recent releases. For example, tz data files typically do not rely on +recently-added <code>zic</code> features, so that users can run +older <code>zic</code> versions to process newer data +files. <a href="tz-link.htm">Sources for time zone and daylight +saving time data</a> describes how +releases are tagged and distributed. +</p> + +<p> +Interfaces not listed above are less stable. For example, users +should not rely on particular UT offsets or abbreviations for +timestamps, as data entries are often based on guesswork and these +guesses may be corrected or improved. +</p> + </section> + + + <section> + <h2 id="calendar">Calendrical issues</h2> +<p> +Calendrical issues are a bit out of scope for a time zone database, +but they indicate the sort of problems that we would run into if we +extended the time zone database further into the past. An excellent +resource in this area is Nachum Dershowitz and Edward M. Reingold, +<cite><a href="https://www.cs.tau.ac.il/~nachum/calendar-book/third-edition/">Calendrical +Calculations: Third Edition</a></cite>, Cambridge University Press (2008). +Other information and sources are given in the file '<samp>calendars</samp>' +in the tz distribution. They sometimes disagree. +</p> + </section> + + + <section> + <h2 id="planets">Time and time zones on other planets</h2> +<p> +Some people's work schedules use Mars time. Jet Propulsion Laboratory +(JPL) coordinators have kept Mars time on and off at least since 1997 +for the Mars Pathfinder mission. Some of their family members have +also adapted to Mars time. Dozens of special Mars watches were built +for JPL workers who kept Mars time during the Mars Exploration +Rovers mission (2004). These timepieces look like normal Seikos and +Citizens but use Mars seconds rather than terrestrial seconds. +</p> + +<p> +A Mars solar day is called a "sol" and has a mean period equal to +about 24 hours 39 minutes 35.244 seconds in terrestrial time. It is +divided into a conventional 24-hour clock, so each Mars second equals +about 1.02749125 terrestrial seconds. +</p> + +<p> +The prime meridian of Mars goes through the center of the crater +Airy-0, named in honor of the British astronomer who built the +Greenwich telescope that defines Earth's prime meridian. Mean solar +time on the Mars prime meridian is called Mars Coordinated Time (MTC). +</p> + +<p> +Each landed mission on Mars has adopted a different reference for +solar time keeping, so there is no real standard for Mars time zones. +For example, the Mars Exploration Rover project (2004) defined two +time zones "Local Solar Time A" and "Local Solar Time B" for its two +missions, each zone designed so that its time equals local true solar +time at approximately the middle of the nominal mission. Such a "time +zone" is not particularly suited for any application other than the +mission itself. +</p> + +<p> +Many calendars have been proposed for Mars, but none have achieved +wide acceptance. Astronomers often use Mars Sol Date (MSD) which is a +sequential count of Mars solar days elapsed since about 1873-12-29 +12:00 GMT. +</p> + +<p> +In our solar system, Mars is the planet with time and calendar most +like Earth's. On other planets, Sun-based time and calendars would +work quite differently. For example, although Mercury's sidereal +rotation period is 58.646 Earth days, Mercury revolves around the Sun +so rapidly that an observer on Mercury's equator would see a sunrise +only every 175.97 Earth days, i.e., a Mercury year is 0.5 of a Mercury +day. Venus is more complicated, partly because its rotation is +slightly retrograde: its year is 1.92 of its days. Gas giants like +Jupiter are trickier still, as their polar and equatorial regions +rotate at different rates, so that the length of a day depends on +latitude. This effect is most pronounced on Neptune, where the day is +about 12 hours at the poles and 18 hours at the equator. +</p> + +<p> +Although the tz database does not support time on other planets, it is +documented here in the hopes that support will be added eventually. +</p> + +<p> +Sources: +</p> +<ul> + <li> +Michael Allison and Robert Schmunk, +"<a href="https://www.giss.nasa.gov/tools/mars24/help/notes.html">Technical +Notes on Mars Solar Time as Adopted by the Mars24 Sunclock</a>" +(2012-08-08). + </li> + <li> +Jia-Rui Chong, +"<a href="http://articles.latimes.com/2004/jan/14/science/sci-marstime14">Workdays +Fit for a Martian</a>", Los Angeles Times +(2004-01-14), pp A1, A20-A21. + </li> + <li> +Tom Chmielewski, +"<a href="https://www.theatlantic.com/technology/archive/2015/02/jet-lag-is-worse-on-mars/386033/">Jet +Lag Is Worse on Mars</a>", The Atlantic (2015-02-26) + </li> + <li> +Matt Williams, +"<a href="https://www.universetoday.com/37481/days-of-the-planets/">How +long is a day on the other planets of the solar system?</a>" +(2017-04-27). + </li> +</ul> + </section> + + <footer> + <hr> +This file is in the public domain, so clarified as of 2009-05-17 by +Arthur David Olson. + </footer> +</body> +</html> diff --git contrib/tzdata/version contrib/tzdata/version index c5bbdc4ead5d..198e36de73e0 100644 --- contrib/tzdata/version +++ contrib/tzdata/version @@ -1 +1 @@ -2017b +2017c diff --git contrib/tzdata/zishrink.awk contrib/tzdata/zishrink.awk new file mode 100644 index 000000000000..02c883a62620 --- /dev/null +++ contrib/tzdata/zishrink.awk @@ -0,0 +1,156 @@ +# Convert tzdata source into a smaller version of itself. + +# Contributed by Paul Eggert. This file is in the public domain. + +# This is not a general-purpose converter; it is designed for current tzdata. +# 'zic' should treat this script's output as if it were identical to +# this script's input. + + +# Return a new rule name. +# N_RULE_NAMES keeps track of how many rule names have been generated. + +function gen_rule_name(alphabet, base, rule_name, n, digit) +{ + alphabet = "" + alphabet = alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + alphabet = alphabet "abcdefghijklmnopqrstuvwxyz" + alphabet = alphabet "!$%&'()*+,./:;<=>?@[\\]^_`{|}~" + base = length(alphabet) + rule_name = "" + n = n_rule_names++ + + do { + n -= rule_name && n <= base + digit = n % base + rule_name = substr(alphabet, digit + 1, 1) rule_name + n = (n - digit) / base + } while (n); + + return rule_name +} + +# Process an input line and save it for later output. + +function process_input_line(line, field, end, i, n, startdef) +{ + # Remove comments, normalize spaces, and append a space to each line. + sub(/#.*/, "", line) + line = line " " + gsub(/[[:space:]]+/, " ", line) + + # Abbreviate keywords. Do not abbreviate "Link" to just "L", + # as pre-2017c zic erroneously diagnoses "Li" as ambiguous. + sub(/^Link /, "Li ", line) + sub(/^Rule /, "R ", line) + sub(/^Zone /, "Z ", line) + + # SystemV rules are not needed. + if (line ~ /^R SystemV /) return + + # Replace FooAsia rules with the same rules without "Asia", as they + # are duplicates. + if (match(line, /[^ ]Asia /)) { + if (line ~ /^R /) return + line = substr(line, 1, RSTART) substr(line, RSTART + 5) + } + + # Abbreviate times. + while (match(line, /[: ]0+[0-9]/)) + line = substr(line, 1, RSTART) substr(line, RSTART + RLENGTH - 1) + while (match(line, /:0[^:]/)) + line = substr(line, 1, RSTART - 1) substr(line, RSTART + 2) + + # Abbreviate weekday names. Do not abbreviate "Sun" and "Sat", as + # pre-2017c zic erroneously diagnoses "Su" and "Sa" as ambiguous. + while (match(line, / (last)?(Mon|Wed|Fri)[ <>]/)) { + end = RSTART + RLENGTH + line = substr(line, 1, end - 4) substr(line, end - 1) + } + while (match(line, / (last)?(Tue|Thu)[ <>]/)) { + end = RSTART + RLENGTH + line = substr(line, 1, end - 3) substr(line, end - 1) + } + + # Abbreviate "max", "only" and month names. + # Do not abbreviate "min", as pre-2017c zic erroneously diagnoses "mi" + # as ambiguous. + gsub(/ max /, " ma ", line) + gsub(/ only /, " o ", line) + gsub(/ Jan /, " Ja ", line) + gsub(/ Feb /, " F ", line) + gsub(/ Apr /, " Ap ", line) + gsub(/ Aug /, " Au ", line) + gsub(/ Sep /, " S ", line) + gsub(/ Oct /, " O ", line) + gsub(/ Nov /, " N ", line) + gsub(/ Dec /, " D ", line) + + # Strip leading and trailing space. + sub(/^ /, "", line) + sub(/ $/, "", line) + + # Remove unnecessary trailing zero fields. + sub(/ 0+$/, "", line) + + # Remove unnecessary trailing days-of-month "1". + if (match(line, /[[:alpha:]] 1$/)) + line = substr(line, 1, RSTART) + + # Remove unnecessary trailing " Ja" (for January). + sub(/ Ja$/, "", line) + + n = split(line, field) + + # Abbreviate rule names. + i = field[1] == "Z" ? 4 : field[1] == "Li" ? 0 : 2 + if (i && field[i] ~ /^[^-+0-9]/) { + if (!rule[field[i]]) + rule[field[i]] = gen_rule_name() + field[i] = rule[field[i]] + } + + # If this zone supersedes an earlier one, delete the earlier one + # from the saved output lines. + startdef = "" + if (field[1] == "Z") + zonename = startdef = field[2] + else if (field[1] == "Li") + zonename = startdef = field[3] + else if (field[1] == "R") + zonename = "" + if (startdef) { + i = zonedef[startdef] + if (i) { + do + output_line[i - 1] = "" + while (output_line[i++] ~ /^[-+0-9]/); + } + } + zonedef[zonename] = nout + 1 + + # Save the line for later output. + line = field[1] + for (i = 2; i <= n; i++) + line = line " " field[i] + output_line[nout++] = line +} + +function output_saved_lines(i) +{ + for (i = 0; i < nout; i++) + if (output_line[i]) + print output_line[i] +} + +BEGIN { + print "# This zic input file is in the public domain." +} + +/^[[:space:]]*[^#[:space:]]/ { + process_input_line($0) +} + +END { + output_saved_lines() +} diff --git contrib/tzdata/zone.tab contrib/tzdata/zone.tab index 204048cc5a63..2d0b26b7d658 100644 --- contrib/tzdata/zone.tab +++ contrib/tzdata/zone.tab @@ -186,7 +186,7 @@ GB +513030-0000731 Europe/London GD +1203-06145 America/Grenada GE +4143+04449 Asia/Tbilisi GF +0456-05220 America/Cayenne -GG +4927-00232 Europe/Guernsey +GG +492717-0023210 Europe/Guernsey GH +0533-00013 Africa/Accra GI +3608-00521 Europe/Gibraltar GL +6411-05144 America/Godthab Greenland (most areas) @@ -221,7 +221,7 @@ IQ +3321+04425 Asia/Baghdad IR +3540+05126 Asia/Tehran IS +6409-02151 Atlantic/Reykjavik IT +4154+01229 Europe/Rome -JE +4912-00207 Europe/Jersey +JE +491101-0020624 Europe/Jersey JM +175805-0764736 America/Jamaica JO +3157+03556 Asia/Amman JP +353916+1394441 Asia/Tokyo diff --git contrib/tzdata/zone1970.tab contrib/tzdata/zone1970.tab index b5fd7fc7d31f..bb0357631562 100644 --- contrib/tzdata/zone1970.tab +++ contrib/tzdata/zone1970.tab @@ -2,7 +2,7 @@ # # This file is in the public domain. # -# From Paul Eggert (2014-07-31): +# From Paul Eggert (2017-10-01): # This file contains a table where each row stands for a zone where # civil time stamps have agreed since 1970. Columns are separated by # a single tab. Lines beginning with '#' are comments. All text uses @@ -16,7 +16,7 @@ # either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS, # first latitude (+ is north), then longitude (+ is east). # 3. Zone name used in value of TZ environment variable. -# Please see the 'Theory' file for how zone names are chosen. +# Please see the theory.html file for how zone names are chosen. # If multiple zones overlap a country, each has a row in the # table, with each column 1 containing the country code. # 4. Comments; present if and only if a country has multiple zones. @@ -317,10 +317,11 @@ RU +6445+17729 Asia/Anadyr MSK+09 - Bering Sea SA,KW,YE +2438+04643 Asia/Riyadh SB -0932+16012 Pacific/Guadalcanal SC -0440+05528 Indian/Mahe -SD,SS +1536+03232 Africa/Khartoum +SD +1536+03232 Africa/Khartoum SE +5920+01803 Europe/Stockholm SG +0117+10351 Asia/Singapore SR +0550-05510 America/Paramaribo +SS +0451+03137 Africa/Juba SV +1342-08912 America/El_Salvador SY +3330+03618 Asia/Damascus TC +2128-07108 America/Grand_Turk diff --git contrib/unbound/validator/autotrust.c contrib/unbound/validator/autotrust.c index da8829cebf25..73d08f0f008c 100644 --- contrib/unbound/validator/autotrust.c +++ contrib/unbound/validator/autotrust.c @@ -1571,6 +1571,11 @@ key_matches_a_ds(struct module_env* env, struct val_env* ve, verbose(VERB_ALGO, "DS match attempt failed"); continue; } + /* match of hash is sufficient for bootstrap of trust point */ + (void)reason; + (void)ve; + return 1; + /* no need to check RRSIG, DS hash already matched with source if(dnskey_verify_rrset(env, ve, dnskey_rrset, dnskey_rrset, key_idx, &reason) == sec_status_secure) { return 1; @@ -1578,6 +1583,7 @@ key_matches_a_ds(struct module_env* env, struct val_env* ve, verbose(VERB_ALGO, "DS match failed because the key " "does not verify the keyset: %s", reason); } + */ } return 0; } diff --git contrib/wpa/src/ap/wpa_auth.c contrib/wpa/src/ap/wpa_auth.c index 2760a3f3a00e..63f252fb55b0 100644 --- contrib/wpa/src/ap/wpa_auth.c +++ contrib/wpa/src/ap/wpa_auth.c @@ -1893,6 +1893,21 @@ SM_STATE(WPA_PTK, AUTHENTICATION2) } +static int wpa_auth_sm_ptk_update(struct wpa_state_machine *sm) +{ + if (random_get_bytes(sm->ANonce, WPA_NONCE_LEN)) { + wpa_printf(MSG_ERROR, + "WPA: Failed to get random data for ANonce"); + sm->Disconnect = TRUE; + return -1; + } + wpa_hexdump(MSG_DEBUG, "WPA: Assign new ANonce", sm->ANonce, + WPA_NONCE_LEN); + sm->TimeoutCtr = 0; + return 0; +} + + SM_STATE(WPA_PTK, INITPMK) { u8 msk[2 * PMK_LEN]; @@ -2414,9 +2429,12 @@ SM_STEP(WPA_PTK) SM_ENTER(WPA_PTK, AUTHENTICATION); else if (sm->ReAuthenticationRequest) SM_ENTER(WPA_PTK, AUTHENTICATION2); - else if (sm->PTKRequest) - SM_ENTER(WPA_PTK, PTKSTART); - else switch (sm->wpa_ptk_state) { + else if (sm->PTKRequest) { + if (wpa_auth_sm_ptk_update(sm) < 0) + SM_ENTER(WPA_PTK, DISCONNECTED); + else + SM_ENTER(WPA_PTK, PTKSTART); + } else switch (sm->wpa_ptk_state) { case WPA_PTK_INITIALIZE: break; case WPA_PTK_DISCONNECT: @@ -3209,6 +3227,14 @@ int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm) } +int wpa_auth_sta_ft_tk_already_set(struct wpa_state_machine *sm) +{ + if (!sm || !wpa_key_mgmt_ft(sm->wpa_key_mgmt)) + return 0; + return sm->tk_already_set; +} + + int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm, struct rsn_pmksa_cache_entry *entry) { diff --git contrib/wpa/src/ap/wpa_auth.h contrib/wpa/src/ap/wpa_auth.h index fd04f169433a..1b1442f414fa 100644 --- contrib/wpa/src/ap/wpa_auth.h +++ contrib/wpa/src/ap/wpa_auth.h @@ -271,6 +271,7 @@ int wpa_auth_pairwise_set(struct wpa_state_machine *sm); int wpa_auth_get_pairwise(struct wpa_state_machine *sm); int wpa_auth_sta_key_mgmt(struct wpa_state_machine *sm); int wpa_auth_sta_wpa_version(struct wpa_state_machine *sm); +int wpa_auth_sta_ft_tk_already_set(struct wpa_state_machine *sm); int wpa_auth_sta_clear_pmksa(struct wpa_state_machine *sm, struct rsn_pmksa_cache_entry *entry); struct rsn_pmksa_cache_entry * diff --git contrib/wpa/src/ap/wpa_auth_ft.c contrib/wpa/src/ap/wpa_auth_ft.c index eeaffbf63516..f8f5dbe3e7da 100644 --- contrib/wpa/src/ap/wpa_auth_ft.c +++ contrib/wpa/src/ap/wpa_auth_ft.c @@ -780,6 +780,14 @@ void wpa_ft_install_ptk(struct wpa_state_machine *sm) return; } + if (sm->tk_already_set) { + /* Must avoid TK reconfiguration to prevent clearing of TX/RX + * PN in the driver */ + wpa_printf(MSG_DEBUG, + "FT: Do not re-install same PTK to the driver"); + return; + } + /* FIX: add STA entry to kernel/driver here? The set_key will fail * most likely without this.. At the moment, STA entry is added only * after association has been completed. This function will be called @@ -792,6 +800,7 @@ void wpa_ft_install_ptk(struct wpa_state_machine *sm) /* FIX: MLME-SetProtection.Request(TA, Tx_Rx) */ sm->pairwise_set = TRUE; + sm->tk_already_set = TRUE; } @@ -898,6 +907,7 @@ static int wpa_ft_process_auth_req(struct wpa_state_machine *sm, sm->pairwise = pairwise; sm->PTK_valid = TRUE; + sm->tk_already_set = FALSE; wpa_ft_install_ptk(sm); buflen = 2 + sizeof(struct rsn_mdie) + 2 + sizeof(struct rsn_ftie) + diff --git contrib/wpa/src/ap/wpa_auth_i.h contrib/wpa/src/ap/wpa_auth_i.h index 57b098f2ed72..234d84c84689 100644 --- contrib/wpa/src/ap/wpa_auth_i.h +++ contrib/wpa/src/ap/wpa_auth_i.h @@ -64,6 +64,7 @@ struct wpa_state_machine { struct wpa_ptk PTK; Boolean PTK_valid; Boolean pairwise_set; + Boolean tk_already_set; int keycount; Boolean Pair; struct wpa_key_replay_counter { diff --git contrib/wpa/src/common/wpa_common.h contrib/wpa/src/common/wpa_common.h index c08f6514ab57..a04e759373b9 100644 --- contrib/wpa/src/common/wpa_common.h +++ contrib/wpa/src/common/wpa_common.h @@ -213,8 +213,20 @@ struct wpa_ptk { size_t kck_len; size_t kek_len; size_t tk_len; + int installed; /* 1 if key has already been installed to driver */ }; +struct wpa_gtk { + u8 gtk[WPA_GTK_MAX_LEN]; + size_t gtk_len; +}; + +#ifdef CONFIG_IEEE80211W +struct wpa_igtk { + u8 igtk[WPA_IGTK_MAX_LEN]; + size_t igtk_len; +}; +#endif /* CONFIG_IEEE80211W */ /* WPA IE version 1 * 00-50-f2:1 (OUI:OUI type) diff --git contrib/wpa/src/rsn_supp/tdls.c contrib/wpa/src/rsn_supp/tdls.c index 722c20a706f9..cce59d7df5b9 100644 --- contrib/wpa/src/rsn_supp/tdls.c +++ contrib/wpa/src/rsn_supp/tdls.c @@ -112,6 +112,7 @@ struct wpa_tdls_peer { u8 tk[16]; /* TPK-TK; assuming only CCMP will be used */ } tpk; int tpk_set; + int tk_set; /* TPK-TK configured to the driver */ int tpk_success; int tpk_in_progress; @@ -192,6 +193,20 @@ static int wpa_tdls_set_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer) u8 rsc[6]; enum wpa_alg alg; + if (peer->tk_set) { + /* + * This same TPK-TK has already been configured to the driver + * and this new configuration attempt (likely due to an + * unexpected retransmitted frame) would result in clearing + * the TX/RX sequence number which can break security, so must + * not allow that to happen. + */ + wpa_printf(MSG_INFO, "TDLS: TPK-TK for the peer " MACSTR + " has already been configured to the driver - do not reconfigure", + MAC2STR(peer->addr)); + return -1; + } + os_memset(rsc, 0, 6); switch (peer->cipher) { @@ -209,12 +224,15 @@ static int wpa_tdls_set_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer) return -1; } + wpa_printf(MSG_DEBUG, "TDLS: Configure pairwise key for peer " MACSTR, + MAC2STR(peer->addr)); if (wpa_sm_set_key(sm, alg, peer->addr, -1, 1, rsc, sizeof(rsc), peer->tpk.tk, key_len) < 0) { wpa_printf(MSG_WARNING, "TDLS: Failed to set TPK to the " "driver"); return -1; } + peer->tk_set = 1; return 0; } @@ -690,7 +708,7 @@ static void wpa_tdls_peer_clear(struct wpa_sm *sm, struct wpa_tdls_peer *peer) peer->cipher = 0; peer->qos_info = 0; peer->wmm_capable = 0; - peer->tpk_set = peer->tpk_success = 0; + peer->tk_set = peer->tpk_set = peer->tpk_success = 0; peer->chan_switch_enabled = 0; os_memset(&peer->tpk, 0, sizeof(peer->tpk)); os_memset(peer->inonce, 0, WPA_NONCE_LEN); @@ -1153,6 +1171,7 @@ skip_rsnie: wpa_tdls_peer_free(sm, peer); return -1; } + peer->tk_set = 0; /* A new nonce results in a new TK */ wpa_hexdump(MSG_DEBUG, "TDLS: Initiator Nonce for TPK handshake", peer->inonce, WPA_NONCE_LEN); os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); @@ -1745,6 +1764,19 @@ static int wpa_tdls_addset_peer(struct wpa_sm *sm, struct wpa_tdls_peer *peer, } +static int tdls_nonce_set(const u8 *nonce) +{ + int i; + + for (i = 0; i < WPA_NONCE_LEN; i++) { + if (nonce[i]) + return 1; + } + + return 0; +} + + static int wpa_tdls_process_tpk_m1(struct wpa_sm *sm, const u8 *src_addr, const u8 *buf, size_t len) { @@ -1998,7 +2030,8 @@ skip_rsn: peer->rsnie_i_len = kde.rsn_ie_len; peer->cipher = cipher; - if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) { + if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0 || + !tdls_nonce_set(peer->inonce)) { /* * There is no point in updating the RNonce for every obtained * TPK M1 frame (e.g., retransmission due to timeout) with the @@ -2014,6 +2047,7 @@ skip_rsn: "TDLS: Failed to get random data for responder nonce"); goto error; } + peer->tk_set = 0; /* A new nonce results in a new TK */ } #if 0 @@ -2170,6 +2204,14 @@ static int wpa_tdls_process_tpk_m2(struct wpa_sm *sm, const u8 *src_addr, "ignore TPK M2 from " MACSTR, MAC2STR(src_addr)); return -1; } + + if (peer->tpk_success) { + wpa_printf(MSG_INFO, "TDLS: Ignore incoming TPK M2 retry, from " + MACSTR " as TPK M3 was already sent", + MAC2STR(src_addr)); + return 0; + } + wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_REQUEST); if (len < 3 + 2 + 1) { diff --git contrib/wpa/src/rsn_supp/wpa.c contrib/wpa/src/rsn_supp/wpa.c index d397ff1605c2..bc50c97141b6 100644 --- contrib/wpa/src/rsn_supp/wpa.c +++ contrib/wpa/src/rsn_supp/wpa.c @@ -605,6 +605,12 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm, const u8 *key_rsc; u8 null_rsc[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + if (sm->ptk.installed) { + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: Do not re-install same PTK to the driver"); + return 0; + } + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Installing PTK to the driver"); @@ -643,6 +649,7 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm, /* TK is not needed anymore in supplicant */ os_memset(sm->ptk.tk, 0, WPA_TK_MAX_LEN); + sm->ptk.installed = 1; if (sm->wpa_ptk_rekey) { eloop_cancel_timeout(wpa_sm_rekey_ptk, sm, NULL); @@ -692,11 +699,23 @@ struct wpa_gtk_data { static int wpa_supplicant_install_gtk(struct wpa_sm *sm, const struct wpa_gtk_data *gd, - const u8 *key_rsc) + const u8 *key_rsc, int wnm_sleep) { const u8 *_gtk = gd->gtk; u8 gtk_buf[32]; + /* Detect possible key reinstallation */ + if ((sm->gtk.gtk_len == (size_t) gd->gtk_len && + os_memcmp(sm->gtk.gtk, gd->gtk, sm->gtk.gtk_len) == 0) || + (sm->gtk_wnm_sleep.gtk_len == (size_t) gd->gtk_len && + os_memcmp(sm->gtk_wnm_sleep.gtk, gd->gtk, + sm->gtk_wnm_sleep.gtk_len) == 0)) { + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: Not reinstalling already in-use GTK to the driver (keyidx=%d tx=%d len=%d)", + gd->keyidx, gd->tx, gd->gtk_len); + return 0; + } + wpa_hexdump_key(MSG_DEBUG, "WPA: Group Key", gd->gtk, gd->gtk_len); wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Installing GTK to the driver (keyidx=%d tx=%d len=%d)", @@ -731,6 +750,15 @@ static int wpa_supplicant_install_gtk(struct wpa_sm *sm, } os_memset(gtk_buf, 0, sizeof(gtk_buf)); + if (wnm_sleep) { + sm->gtk_wnm_sleep.gtk_len = gd->gtk_len; + os_memcpy(sm->gtk_wnm_sleep.gtk, gd->gtk, + sm->gtk_wnm_sleep.gtk_len); + } else { + sm->gtk.gtk_len = gd->gtk_len; + os_memcpy(sm->gtk.gtk, gd->gtk, sm->gtk.gtk_len); + } + return 0; } @@ -788,7 +816,7 @@ static int wpa_supplicant_pairwise_gtk(struct wpa_sm *sm, (wpa_supplicant_check_group_cipher(sm, sm->group_cipher, gtk_len, gtk_len, &gd.key_rsc_len, &gd.alg) || - wpa_supplicant_install_gtk(sm, &gd, key->key_rsc))) { + wpa_supplicant_install_gtk(sm, &gd, key->key_rsc, 0))) { wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "RSN: Failed to install GTK"); os_memset(&gd, 0, sizeof(gd)); @@ -802,6 +830,58 @@ static int wpa_supplicant_pairwise_gtk(struct wpa_sm *sm, } +#ifdef CONFIG_IEEE80211W +static int wpa_supplicant_install_igtk(struct wpa_sm *sm, + const struct wpa_igtk_kde *igtk, + int wnm_sleep) +{ + size_t len = wpa_cipher_key_len(sm->mgmt_group_cipher); + u16 keyidx = WPA_GET_LE16(igtk->keyid); + + /* Detect possible key reinstallation */ + if ((sm->igtk.igtk_len == len && + os_memcmp(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len) == 0) || + (sm->igtk_wnm_sleep.igtk_len == len && + os_memcmp(sm->igtk_wnm_sleep.igtk, igtk->igtk, + sm->igtk_wnm_sleep.igtk_len) == 0)) { + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: Not reinstalling already in-use IGTK to the driver (keyidx=%d)", + keyidx); + return 0; + } + + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: IGTK keyid %d pn %02x%02x%02x%02x%02x%02x", + keyidx, MAC2STR(igtk->pn)); + wpa_hexdump_key(MSG_DEBUG, "WPA: IGTK", igtk->igtk, len); + if (keyidx > 4095) { + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Invalid IGTK KeyID %d", keyidx); + return -1; + } + if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher), + broadcast_ether_addr, + keyidx, 0, igtk->pn, sizeof(igtk->pn), + igtk->igtk, len) < 0) { + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Failed to configure IGTK to the driver"); + return -1; + } + + if (wnm_sleep) { + sm->igtk_wnm_sleep.igtk_len = len; + os_memcpy(sm->igtk_wnm_sleep.igtk, igtk->igtk, + sm->igtk_wnm_sleep.igtk_len); + } else { + sm->igtk.igtk_len = len; + os_memcpy(sm->igtk.igtk, igtk->igtk, sm->igtk.igtk_len); + } + + return 0; +} +#endif /* CONFIG_IEEE80211W */ + + static int ieee80211w_set_keys(struct wpa_sm *sm, struct wpa_eapol_ie_parse *ie) { @@ -812,30 +892,14 @@ static int ieee80211w_set_keys(struct wpa_sm *sm, if (ie->igtk) { size_t len; const struct wpa_igtk_kde *igtk; - u16 keyidx; + len = wpa_cipher_key_len(sm->mgmt_group_cipher); if (ie->igtk_len != WPA_IGTK_KDE_PREFIX_LEN + len) return -1; + igtk = (const struct wpa_igtk_kde *) ie->igtk; - keyidx = WPA_GET_LE16(igtk->keyid); - wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: IGTK keyid %d " - "pn %02x%02x%02x%02x%02x%02x", - keyidx, MAC2STR(igtk->pn)); - wpa_hexdump_key(MSG_DEBUG, "WPA: IGTK", - igtk->igtk, len); - if (keyidx > 4095) { - wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, - "WPA: Invalid IGTK KeyID %d", keyidx); - return -1; - } - if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher), - broadcast_ether_addr, - keyidx, 0, igtk->pn, sizeof(igtk->pn), - igtk->igtk, len) < 0) { - wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, - "WPA: Failed to configure IGTK to the driver"); + if (wpa_supplicant_install_igtk(sm, igtk, 0) < 0) return -1; - } } return 0; @@ -1483,7 +1547,7 @@ static void wpa_supplicant_process_1_of_2(struct wpa_sm *sm, if (ret) goto failed; - if (wpa_supplicant_install_gtk(sm, &gd, key->key_rsc) || + if (wpa_supplicant_install_gtk(sm, &gd, key->key_rsc, 0) || wpa_supplicant_send_2_of_2(sm, key, ver, key_info)) goto failed; os_memset(&gd, 0, sizeof(gd)); @@ -2251,7 +2315,7 @@ void wpa_sm_deinit(struct wpa_sm *sm) */ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid) { - int clear_ptk = 1; + int clear_keys = 1; if (sm == NULL) return; @@ -2277,11 +2341,11 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid) /* Prepare for the next transition */ wpa_ft_prepare_auth_request(sm, NULL); - clear_ptk = 0; + clear_keys = 0; } #endif /* CONFIG_IEEE80211R */ - if (clear_ptk) { + if (clear_keys) { /* * IEEE 802.11, 8.4.10: Delete PTK SA on (re)association if * this is not part of a Fast BSS Transition. @@ -2291,6 +2355,12 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid) os_memset(&sm->ptk, 0, sizeof(sm->ptk)); sm->tptk_set = 0; os_memset(&sm->tptk, 0, sizeof(sm->tptk)); + os_memset(&sm->gtk, 0, sizeof(sm->gtk)); + os_memset(&sm->gtk_wnm_sleep, 0, sizeof(sm->gtk_wnm_sleep)); +#ifdef CONFIG_IEEE80211W + os_memset(&sm->igtk, 0, sizeof(sm->igtk)); + os_memset(&sm->igtk_wnm_sleep, 0, sizeof(sm->igtk_wnm_sleep)); +#endif /* CONFIG_IEEE80211W */ } #ifdef CONFIG_TDLS @@ -2322,6 +2392,9 @@ void wpa_sm_notify_disassoc(struct wpa_sm *sm) #ifdef CONFIG_TDLS wpa_tdls_disassoc(sm); #endif /* CONFIG_TDLS */ +#ifdef CONFIG_IEEE80211R + sm->ft_reassoc_completed = 0; +#endif /* CONFIG_IEEE80211R */ /* Keys are not needed in the WPA state machine anymore */ wpa_sm_drop_sa(sm); @@ -2807,6 +2880,12 @@ void wpa_sm_drop_sa(struct wpa_sm *sm) os_memset(sm->pmk, 0, sizeof(sm->pmk)); os_memset(&sm->ptk, 0, sizeof(sm->ptk)); os_memset(&sm->tptk, 0, sizeof(sm->tptk)); + os_memset(&sm->gtk, 0, sizeof(sm->gtk)); + os_memset(&sm->gtk_wnm_sleep, 0, sizeof(sm->gtk_wnm_sleep)); +#ifdef CONFIG_IEEE80211W + os_memset(&sm->igtk, 0, sizeof(sm->igtk)); + os_memset(&sm->igtk_wnm_sleep, 0, sizeof(sm->igtk_wnm_sleep)); +#endif /* CONFIG_IEEE80211W */ #ifdef CONFIG_IEEE80211R os_memset(sm->xxkey, 0, sizeof(sm->xxkey)); os_memset(sm->pmk_r0, 0, sizeof(sm->pmk_r0)); @@ -2870,7 +2949,7 @@ int wpa_wnmsleep_install_key(struct wpa_sm *sm, u8 subelem_id, u8 *buf) wpa_hexdump_key(MSG_DEBUG, "Install GTK (WNM SLEEP)", gd.gtk, gd.gtk_len); - if (wpa_supplicant_install_gtk(sm, &gd, key_rsc)) { + if (wpa_supplicant_install_gtk(sm, &gd, key_rsc, 1)) { os_memset(&gd, 0, sizeof(gd)); wpa_printf(MSG_DEBUG, "Failed to install the GTK in " "WNM mode"); @@ -2879,29 +2958,11 @@ int wpa_wnmsleep_install_key(struct wpa_sm *sm, u8 subelem_id, u8 *buf) os_memset(&gd, 0, sizeof(gd)); #ifdef CONFIG_IEEE80211W } else if (subelem_id == WNM_SLEEP_SUBELEM_IGTK) { - struct wpa_igtk_kde igd; - u16 keyidx; - - os_memset(&igd, 0, sizeof(igd)); - keylen = wpa_cipher_key_len(sm->mgmt_group_cipher); - os_memcpy(igd.keyid, buf + 2, 2); - os_memcpy(igd.pn, buf + 4, 6); - - keyidx = WPA_GET_LE16(igd.keyid); - os_memcpy(igd.igtk, buf + 10, keylen); - - wpa_hexdump_key(MSG_DEBUG, "Install IGTK (WNM SLEEP)", - igd.igtk, keylen); - if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher), - broadcast_ether_addr, - keyidx, 0, igd.pn, sizeof(igd.pn), - igd.igtk, keylen) < 0) { - wpa_printf(MSG_DEBUG, "Failed to install the IGTK in " - "WNM mode"); - os_memset(&igd, 0, sizeof(igd)); + const struct wpa_igtk_kde *igtk; + + igtk = (const struct wpa_igtk_kde *) (buf + 2); + if (wpa_supplicant_install_igtk(sm, igtk, 1) < 0) return -1; - } - os_memset(&igd, 0, sizeof(igd)); #endif /* CONFIG_IEEE80211W */ } else { wpa_printf(MSG_DEBUG, "Unknown element id"); diff --git contrib/wpa/src/rsn_supp/wpa_ft.c contrib/wpa/src/rsn_supp/wpa_ft.c index 205793e7f43a..d45bb4585e50 100644 --- contrib/wpa/src/rsn_supp/wpa_ft.c +++ contrib/wpa/src/rsn_supp/wpa_ft.c @@ -153,6 +153,7 @@ static u8 * wpa_ft_gen_req_ies(struct wpa_sm *sm, size_t *len, u16 capab; sm->ft_completed = 0; + sm->ft_reassoc_completed = 0; buf_len = 2 + sizeof(struct rsn_mdie) + 2 + sizeof(struct rsn_ftie) + 2 + sm->r0kh_id_len + ric_ies_len + 100; @@ -681,6 +682,11 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies, return -1; } + if (sm->ft_reassoc_completed) { + wpa_printf(MSG_DEBUG, "FT: Reassociation has already been completed for this FT protocol instance - ignore unexpected retransmission"); + return 0; + } + if (wpa_ft_parse_ies(ies, ies_len, &parse) < 0) { wpa_printf(MSG_DEBUG, "FT: Failed to parse IEs"); return -1; @@ -781,6 +787,8 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies, return -1; } + sm->ft_reassoc_completed = 1; + if (wpa_ft_process_gtk_subelem(sm, parse.gtk, parse.gtk_len) < 0) return -1; diff --git contrib/wpa/src/rsn_supp/wpa_i.h contrib/wpa/src/rsn_supp/wpa_i.h index 965a9c1d577c..85cc86282640 100644 --- contrib/wpa/src/rsn_supp/wpa_i.h +++ contrib/wpa/src/rsn_supp/wpa_i.h @@ -30,6 +30,12 @@ struct wpa_sm { u8 rx_replay_counter[WPA_REPLAY_COUNTER_LEN]; int rx_replay_counter_set; u8 request_counter[WPA_REPLAY_COUNTER_LEN]; + struct wpa_gtk gtk; + struct wpa_gtk gtk_wnm_sleep; +#ifdef CONFIG_IEEE80211W + struct wpa_igtk igtk; + struct wpa_igtk igtk_wnm_sleep; +#endif /* CONFIG_IEEE80211W */ struct eapol_sm *eapol; /* EAPOL state machine from upper level code */ @@ -121,6 +127,7 @@ struct wpa_sm { size_t r0kh_id_len; u8 r1kh_id[FT_R1KH_ID_LEN]; int ft_completed; + int ft_reassoc_completed; int over_the_ds_in_progress; u8 target_ap[ETH_ALEN]; /* over-the-DS target AP */ int set_ptk_after_assoc; diff --git contrib/wpa/wpa_supplicant/ctrl_iface.c contrib/wpa/wpa_supplicant/ctrl_iface.c index 3b97806d871d..25dcdf7ee321 100644 --- contrib/wpa/wpa_supplicant/ctrl_iface.c +++ contrib/wpa/wpa_supplicant/ctrl_iface.c @@ -6891,6 +6891,7 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s) } eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL); + wpa_s->wnmsleep_used = 0; } diff --git contrib/wpa/wpa_supplicant/events.c contrib/wpa/wpa_supplicant/events.c index 3af1c7d89c64..e2105ec505f5 100644 --- contrib/wpa/wpa_supplicant/events.c +++ contrib/wpa/wpa_supplicant/events.c @@ -303,6 +303,7 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s) wpa_s->key_mgmt = 0; wpas_rrm_reset(wpa_s); + wpa_s->wnmsleep_used = 0; } diff --git contrib/wpa/wpa_supplicant/wnm_sta.c contrib/wpa/wpa_supplicant/wnm_sta.c index 954de67c2aa3..d88c863ac25e 100644 --- contrib/wpa/wpa_supplicant/wnm_sta.c +++ contrib/wpa/wpa_supplicant/wnm_sta.c @@ -137,6 +137,8 @@ int ieee802_11_send_wnmsleep_req(struct wpa_supplicant *wpa_s, if (res < 0) wpa_printf(MSG_DEBUG, "Failed to send WNM-Sleep Request " "(action=%d, intval=%d)", action, intval); + else + wpa_s->wnmsleep_used = 1; os_free(wnmsleep_ie); os_free(wnmtfs_ie); @@ -187,6 +189,12 @@ static void wnm_sleep_mode_exit_success(struct wpa_supplicant *wpa_s, end = ptr + key_len_total; wpa_hexdump_key(MSG_DEBUG, "WNM: Key Data", ptr, key_len_total); + if (key_len_total && !wpa_sm_pmf_enabled(wpa_s->wpa)) { + wpa_msg(wpa_s, MSG_INFO, + "WNM: Ignore Key Data in WNM-Sleep Mode Response - PMF not enabled"); + return; + } + while (ptr + 1 < end) { if (ptr + 2 + ptr[1] > end) { wpa_printf(MSG_DEBUG, "WNM: Invalid Key Data element " @@ -247,6 +255,12 @@ static void ieee802_11_rx_wnmsleep_resp(struct wpa_supplicant *wpa_s, u8 *tfsresp_ie_end = NULL; size_t left; + if (!wpa_s->wnmsleep_used) { + wpa_printf(MSG_DEBUG, + "WNM: Ignore WNM-Sleep Mode Response frame since WNM-Sleep Mode operation has not been requested"); + return; + } + if (len < 3) return; key_len_total = WPA_GET_LE16(frm + 1); @@ -282,6 +296,8 @@ static void ieee802_11_rx_wnmsleep_resp(struct wpa_supplicant *wpa_s, return; } + wpa_s->wnmsleep_used = 0; + if (wnmsleep_ie->status == WNM_STATUS_SLEEP_ACCEPT || wnmsleep_ie->status == WNM_STATUS_SLEEP_EXIT_ACCEPT_GTK_UPDATE) { wpa_printf(MSG_DEBUG, "Successfully recv WNM-Sleep Response " diff --git contrib/wpa/wpa_supplicant/wpa_supplicant_i.h contrib/wpa/wpa_supplicant/wpa_supplicant_i.h index 58df48c548ea..318768bc2776 100644 --- contrib/wpa/wpa_supplicant/wpa_supplicant_i.h +++ contrib/wpa/wpa_supplicant/wpa_supplicant_i.h @@ -658,6 +658,7 @@ struct wpa_supplicant { unsigned int reattach:1; /* reassociation to the same BSS requested */ unsigned int mac_addr_changed:1; unsigned int added_vif:1; + unsigned int wnmsleep_used:1; struct os_reltime last_mac_addr_change; int last_mac_addr_style; diff --git contrib/zlib/deflate.c contrib/zlib/deflate.c index 1ec761448de9..7f2c8a2a2a64 100644 --- contrib/zlib/deflate.c +++ contrib/zlib/deflate.c @@ -494,7 +494,7 @@ int ZEXPORT deflateResetKeep (strm) s->wrap == 2 ? crc32(0L, Z_NULL, 0) : #endif adler32(0L, Z_NULL, 0); - s->last_flush = Z_NO_FLUSH; + s->last_flush = -2; _tr_init(s); @@ -587,12 +587,12 @@ int ZEXPORT deflateParams(strm, level, strategy) func = configuration_table[s->level].func; if ((strategy != s->strategy || func != configuration_table[level].func) && - s->high_water) { + s->last_flush != -2) { /* Flush the last buffer: */ int err = deflate(strm, Z_BLOCK); if (err == Z_STREAM_ERROR) return err; - if (strm->avail_out == 0) + if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead) return Z_BUF_ERROR; } if (s->level != level) { diff --git contrib/zlib/zlib.h contrib/zlib/zlib.h index f09cdaf1e054..001624e5ed85 100644 --- contrib/zlib/zlib.h +++ contrib/zlib/zlib.h @@ -712,11 +712,12 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression approach (which is a function of the level) or the - strategy is changed, and if any input has been consumed in a previous - deflate() call, then the input available so far is compressed with the old - level and strategy using deflate(strm, Z_BLOCK). There are three approaches - for the compression levels 0, 1..3, and 4..9 respectively. The new level - and strategy will take effect at the next call of deflate(). + strategy is changed, and if there have been any deflate() calls since the + state was initialized or reset, then the input available so far is + compressed with the old level and strategy using deflate(strm, Z_BLOCK). + There are three approaches for the compression levels 0, 1..3, and 4..9 + respectively. The new level and strategy will take effect at the next call + of deflate(). If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does not have enough output space to complete, then the parameter change will not diff --git crypto/openssl/CHANGES crypto/openssl/CHANGES index 307b2ed5e312..e3d57b328c58 100644 --- crypto/openssl/CHANGES +++ crypto/openssl/CHANGES @@ -2,6 +2,44 @@ OpenSSL CHANGES _______________ + This is a high-level summary of the most important changes. + For a full list of changes, see the git commit log; for example, + https://github.com/openssl/openssl/commits/ and pick the appropriate + release branch. + + Changes between 1.0.2l and 1.0.2m [2 Nov 2017] + + *) bn_sqrx8x_internal carry bug on x86_64 + + There is a carry propagating bug in the x86_64 Montgomery squaring + procedure. No EC algorithms are affected. Analysis suggests that attacks + against RSA and DSA as a result of this defect would be very difficult to + perform and are not believed likely. Attacks against DH are considered just + feasible (although very difficult) because most of the work necessary to + deduce information about a private key may be performed offline. The amount + of resources required for such an attack would be very significant and + likely only accessible to a limited number of attackers. An attacker would + additionally need online access to an unpatched system using the target + private key in a scenario with persistent DH parameters and a private + key that is shared between multiple clients. + + This only affects processors that support the BMI1, BMI2 and ADX extensions + like Intel Broadwell (5th generation) and later or AMD Ryzen. + + This issue was reported to OpenSSL by the OSS-Fuzz project. + (CVE-2017-3736) + [Andy Polyakov] + + *) Malformed X.509 IPAddressFamily could cause OOB read + + If an X.509 certificate has a malformed IPAddressFamily extension, + OpenSSL could do a one-byte buffer overread. The most likely result + would be an erroneous display of the certificate in text format. + + This issue was reported to OpenSSL by the OSS-Fuzz project. + (CVE-2017-3735) + [Rich Salz] + Changes between 1.0.2k and 1.0.2l [25 May 2017] *) Have 'config' recognise 64-bit mingw and choose 'mingw64' as the target diff --git crypto/openssl/INSTALL crypto/openssl/INSTALL index aa7e35fa79fe..fcdbfc0a6ee0 100644 --- crypto/openssl/INSTALL +++ crypto/openssl/INSTALL @@ -190,10 +190,8 @@ the failure that isn't a problem in OpenSSL itself (like a missing or malfunctioning bc). If it is a problem with OpenSSL itself, try removing any compiler optimization flags from the CFLAG line - in Makefile.ssl and run "make clean; make". Please send a bug - report to <openssl-bugs@openssl.org>, including the output of - "make report" in order to be added to the request tracker at - http://www.openssl.org/support/rt.html. + in Makefile.ssl and run "make clean; make". To report a bug please open an + issue on GitHub, at https://github.com/openssl/openssl/issues. 4. If everything tests ok, install OpenSSL with diff --git crypto/openssl/Makefile crypto/openssl/Makefile index a3d30318f917..484f2f45f776 100644 --- crypto/openssl/Makefile +++ crypto/openssl/Makefile @@ -4,7 +4,7 @@ ## Makefile for OpenSSL ## -VERSION=1.0.2l +VERSION=1.0.2m MAJOR=1 MINOR=0.2 SHLIB_VERSION_NUMBER=1.0.0 diff --git crypto/openssl/NEWS crypto/openssl/NEWS index fd49cedeba4c..1b72013ad186 100644 --- crypto/openssl/NEWS +++ crypto/openssl/NEWS @@ -5,6 +5,11 @@ This file gives a brief overview of the major changes between each OpenSSL release. For more details please read the CHANGES file. + Major changes between OpenSSL 1.0.2l and OpenSSL 1.0.2m [2 Nov 2017] + + o bn_sqrx8x_internal carry bug on x86_64 (CVE-2017-3736) + o Malformed X.509 IPAddressFamily could cause OOB read (CVE-2017-3735) + Major changes between OpenSSL 1.0.2k and OpenSSL 1.0.2l [25 May 2017] o config now recognises 64-bit mingw and chooses mingw64 instead of mingw diff --git crypto/openssl/README crypto/openssl/README index 4c357d9a836d..b5aae6260ce8 100644 --- crypto/openssl/README +++ crypto/openssl/README @@ -1,5 +1,5 @@ - OpenSSL 1.0.2l 25 May 2017 + OpenSSL 1.0.2m 2 Nov 2017 Copyright (c) 1998-2015 The OpenSSL Project Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson diff --git crypto/openssl/apps/ca.c crypto/openssl/apps/ca.c index f90f033baed3..9a839969a204 100644 --- crypto/openssl/apps/ca.c +++ crypto/openssl/apps/ca.c @@ -1985,10 +1985,6 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, /* Lets add the extensions, if there are any */ if (ext_sect) { X509V3_CTX ctx; - if (ci->version == NULL) - if ((ci->version = ASN1_INTEGER_new()) == NULL) - goto err; - ASN1_INTEGER_set(ci->version, 2); /* version 3 certificate */ /* * Free the current entries if any, there should not be any I believe @@ -2051,6 +2047,15 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, goto err; } + { + STACK_OF(X509_EXTENSION) *exts = ci->extensions; + + if (exts != NULL && sk_X509_EXTENSION_num(exts) > 0) + /* Make it an X509 v3 certificate. */ + if (!X509_set_version(ret, 2)) + goto err; + } + /* Set the right value for the noemailDN option */ if (email_dn == 0) { if (!X509_set_subject_name(ret, dn_subject)) diff --git crypto/openssl/apps/s_client.c crypto/openssl/apps/s_client.c index 85c1b6b57944..dc467994f8e2 100644 --- crypto/openssl/apps/s_client.c +++ crypto/openssl/apps/s_client.c @@ -1667,6 +1667,8 @@ int MAIN(int argc, char **argv) if (strstr(mbuf, "/stream:features>")) goto shut; seen = BIO_read(sbio, mbuf, BUFSIZZ); + if (seen <= 0) + goto shut; mbuf[seen] = 0; } BIO_printf(sbio, diff --git crypto/openssl/apps/s_server.c crypto/openssl/apps/s_server.c index d75871386928..98ffc09314a3 100644 --- crypto/openssl/apps/s_server.c +++ crypto/openssl/apps/s_server.c @@ -3017,7 +3017,7 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context) PEM_write_bio_X509(io, peer); } else BIO_puts(io, "no client certificate available\n"); - BIO_puts(io, "</BODY></HTML>\r\n\r\n"); + BIO_puts(io, "</pre></BODY></HTML>\r\n\r\n"); break; } else if ((www == 2 || www == 3) && (strncmp("GET /", buf, 5) == 0)) { diff --git crypto/openssl/apps/speed.c crypto/openssl/apps/speed.c index 6cd102152504..5259c16f1218 100644 --- crypto/openssl/apps/speed.c +++ crypto/openssl/apps/speed.c @@ -307,7 +307,8 @@ static SIGRETTYPE sig_done(int sig) # if !defined(SIGALRM) # define SIGALRM # endif -static unsigned int lapse, schlock; +static volatile unsigned int lapse; +static volatile unsigned int schlock; static void alarm_win32(unsigned int secs) { lapse = secs * 1000; @@ -725,6 +726,7 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err, "no EVP given\n"); goto end; } + evp_md = NULL; evp_cipher = EVP_get_cipherbyname(*argv); if (!evp_cipher) { evp_md = EVP_get_digestbyname(*argv); diff --git crypto/openssl/apps/spkac.c crypto/openssl/apps/spkac.c index 7f5333fe832e..4b4106d03b99 100644 --- crypto/openssl/apps/spkac.c +++ crypto/openssl/apps/spkac.c @@ -5,7 +5,7 @@ * 1999. Based on an original idea by Massimiliano Pala (madwolf@openca.org). */ /* ==================================================================== - * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * Copyright (c) 1999-2017 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -185,20 +185,23 @@ int MAIN(int argc, char **argv) } e = setup_engine(bio_err, engine, 0); - if (keyfile) { + if (keyfile != NULL) { pkey = load_key(bio_err, strcmp(keyfile, "-") ? keyfile : NULL, FORMAT_PEM, 1, passin, e, "private key"); - if (!pkey) { + if (pkey == NULL) goto end; - } spki = NETSCAPE_SPKI_new(); - if (challenge) + if (spki == NULL) + goto end; + if (challenge != NULL) ASN1_STRING_set(spki->spkac->challenge, challenge, (int)strlen(challenge)); NETSCAPE_SPKI_set_pubkey(spki, pkey); NETSCAPE_SPKI_sign(spki, pkey, EVP_md5()); spkstr = NETSCAPE_SPKI_b64_encode(spki); + if (spkstr == NULL) + goto end; if (outfile) out = BIO_new_file(outfile, "w"); @@ -253,7 +256,7 @@ int MAIN(int argc, char **argv) spki = NETSCAPE_SPKI_b64_decode(spkstr, -1); - if (!spki) { + if (spki == NULL) { BIO_printf(bio_err, "Error loading SPKAC\n"); ERR_print_errors(bio_err); goto end; @@ -282,9 +285,9 @@ int MAIN(int argc, char **argv) pkey = NETSCAPE_SPKI_get_pubkey(spki); if (verify) { i = NETSCAPE_SPKI_verify(spki, pkey); - if (i > 0) + if (i > 0) { BIO_printf(bio_err, "Signature OK\n"); - else { + } else { BIO_printf(bio_err, "Signature Failure\n"); ERR_print_errors(bio_err); goto end; diff --git crypto/openssl/apps/srp.c crypto/openssl/apps/srp.c index ce01a24f2a78..491445df60b0 100644 --- crypto/openssl/apps/srp.c +++ crypto/openssl/apps/srp.c @@ -123,13 +123,14 @@ static int get_index(CA_DB *db, char *id, char type) int i; if (id == NULL) return -1; - if (type == DB_SRP_INDEX) + if (type == DB_SRP_INDEX) { for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) { pp = sk_OPENSSL_PSTRING_value(db->db->data, i); if (pp[DB_srptype][0] == DB_SRP_INDEX && !strcmp(id, pp[DB_srpid])) return i; - } else + } + } else { for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) { pp = sk_OPENSSL_PSTRING_value(db->db->data, i); @@ -137,6 +138,7 @@ static int get_index(CA_DB *db, char *id, char type) && !strcmp(id, pp[DB_srpid])) return i; } + } return -1; } @@ -177,8 +179,8 @@ static int update_index(CA_DB *db, BIO *bio, char **row) char **irow; int i; - if ((irow = - (char **)OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) { + irow = (char **)OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1)); + if (irow == NULL) { BIO_printf(bio_err, "Memory allocation failure\n"); return 0; } @@ -205,30 +207,32 @@ static char *srp_verify_user(const char *user, const char *srp_verifier, char *srp_usersalt, const char *g, const char *N, const char *passin, BIO *bio, int verbose) { - char password[1024]; + char password[1025]; PW_CB_DATA cb_tmp; char *verifier = NULL; char *gNid = NULL; + int len; cb_tmp.prompt_info = user; cb_tmp.password = passin; - if (password_callback(password, 1024, 0, &cb_tmp) > 0) { + len = password_callback(password, sizeof(password)-1, 0, &cb_tmp); + if (len > 0) { + password[len] = 0; VERBOSE BIO_printf(bio, "Validating\n user=\"%s\"\n srp_verifier=\"%s\"\n srp_usersalt=\"%s\"\n g=\"%s\"\n N=\"%s\"\n", user, srp_verifier, srp_usersalt, g, N); - BIO_printf(bio, "Pass %s\n", password); + VVERBOSE BIO_printf(bio, "Pass %s\n", password); - if (! - (gNid = - SRP_create_verifier(user, password, &srp_usersalt, &verifier, N, - g))) { + if (!(gNid = SRP_create_verifier(user, password, &srp_usersalt, + &verifier, N, g))) { BIO_printf(bio, "Internal error validating SRP verifier\n"); } else { if (strcmp(verifier, srp_verifier)) gNid = NULL; OPENSSL_free(verifier); } + OPENSSL_cleanse(password, len); } return gNid; } @@ -237,24 +241,27 @@ static char *srp_create_user(char *user, char **srp_verifier, char **srp_usersalt, char *g, char *N, char *passout, BIO *bio, int verbose) { - char password[1024]; + char password[1025]; PW_CB_DATA cb_tmp; char *gNid = NULL; char *salt = NULL; + int len; cb_tmp.prompt_info = user; cb_tmp.password = passout; - if (password_callback(password, 1024, 1, &cb_tmp) > 0) { + len = password_callback(password, sizeof(password)-1, 1, &cb_tmp); + if (len > 0) { + password[len] = 0; VERBOSE BIO_printf(bio, "Creating\n user=\"%s\"\n g=\"%s\"\n N=\"%s\"\n", user, g, N); - if (! - (gNid = - SRP_create_verifier(user, password, &salt, srp_verifier, N, - g))) { + if (!(gNid = SRP_create_verifier(user, password, &salt, + srp_verifier, N, g))) { BIO_printf(bio, "Internal error creating SRP verifier\n"); - } else + } else { *srp_usersalt = salt; + } + OPENSSL_cleanse(password, len); VVERBOSE BIO_printf(bio, "gNid=%s salt =\"%s\"\n verifier =\"%s\"\n", gNid, salt, *srp_verifier); @@ -314,9 +321,9 @@ int MAIN(int argc, char **argv) argc--; argv++; while (argc >= 1 && badops == 0) { - if (strcmp(*argv, "-verbose") == 0) + if (strcmp(*argv, "-verbose") == 0) { verbose++; - else if (strcmp(*argv, "-config") == 0) { + } else if (strcmp(*argv, "-config") == 0) { if (--argc < 1) goto bad; configfile = *(++argv); @@ -328,15 +335,15 @@ int MAIN(int argc, char **argv) if (--argc < 1) goto bad; dbfile = *(++argv); - } else if (strcmp(*argv, "-add") == 0) + } else if (strcmp(*argv, "-add") == 0) { add_user = 1; - else if (strcmp(*argv, "-delete") == 0) + } else if (strcmp(*argv, "-delete") == 0) { delete_user = 1; - else if (strcmp(*argv, "-modify") == 0) + } else if (strcmp(*argv, "-modify") == 0) { modify_user = 1; - else if (strcmp(*argv, "-list") == 0) + } else if (strcmp(*argv, "-list") == 0) { list_user = 1; - else if (strcmp(*argv, "-gn") == 0) { + } else if (strcmp(*argv, "-gn") == 0) { if (--argc < 1) goto bad; gN = *(++argv); @@ -366,8 +373,9 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err, "unknown option %s\n", *argv); badops = 1; break; - } else + } else { break; + } argc--; argv++; @@ -388,7 +396,7 @@ int MAIN(int argc, char **argv) "Need at least one user for options -add, -delete, -modify. \n"); badops = 1; } - if ((passin || passout) && argc != 1) { + if ((passargin || passargout) && argc != 1) { BIO_printf(bio_err, "-passin, -passout arguments only valid with one user.\n"); badops = 1; @@ -706,9 +714,9 @@ int MAIN(int argc, char **argv) doupdatedb = 1; } } - if (--argc > 0) + if (--argc > 0) { user = *(argv++); - else { + } else { user = NULL; list_user = 0; } diff --git crypto/openssl/apps/tsget crypto/openssl/apps/tsget index 0d54e9fc9a76..0fca99f4385a 100644 --- crypto/openssl/apps/tsget +++ crypto/openssl/apps/tsget @@ -193,4 +193,3 @@ REQUEST: foreach (@ARGV) { STDERR->printflush(", $output written.\n") if $options{v}; } $curl->cleanup(); -WWW::Curl::Easy::global_cleanup(); diff --git crypto/openssl/crypto/asn1/Makefile crypto/openssl/crypto/asn1/Makefile index 330fe81b740c..fb3140c1d302 100644 --- crypto/openssl/crypto/asn1/Makefile +++ crypto/openssl/crypto/asn1/Makefile @@ -680,7 +680,7 @@ tasn_fre.o: ../../include/openssl/e_os2.h ../../include/openssl/obj_mac.h tasn_fre.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h tasn_fre.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h tasn_fre.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -tasn_fre.o: ../../include/openssl/symhacks.h tasn_fre.c +tasn_fre.o: ../../include/openssl/symhacks.h asn1_int.h tasn_fre.c tasn_new.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h tasn_new.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h tasn_new.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h @@ -688,7 +688,7 @@ tasn_new.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h tasn_new.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h tasn_new.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h tasn_new.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -tasn_new.o: ../../include/openssl/symhacks.h tasn_new.c +tasn_new.o: ../../include/openssl/symhacks.h asn1_int.h tasn_new.c tasn_prn.o: ../../e_os.h ../../include/openssl/asn1.h tasn_prn.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h tasn_prn.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h diff --git crypto/openssl/crypto/asn1/a_bitstr.c crypto/openssl/crypto/asn1/a_bitstr.c index c429342e03d4..0c8bb144a099 100644 --- crypto/openssl/crypto/asn1/a_bitstr.c +++ crypto/openssl/crypto/asn1/a_bitstr.c @@ -56,6 +56,7 @@ * [including the GNU Public Licence.] */ +#include <limits.h> #include <stdio.h> #include "cryptlib.h" #include <openssl/asn1.h> @@ -136,6 +137,11 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, goto err; } + if (len > INT_MAX) { + i = ASN1_R_STRING_TOO_LONG; + goto err; + } + if ((a == NULL) || ((*a) == NULL)) { if ((ret = M_ASN1_BIT_STRING_new()) == NULL) return (NULL); diff --git crypto/openssl/crypto/asn1/asn1_int.h crypto/openssl/crypto/asn1/asn1_int.h new file mode 100644 index 000000000000..c9fd8b12ae17 --- /dev/null +++ crypto/openssl/crypto/asn1/asn1_int.h @@ -0,0 +1,63 @@ +/* asn1t.h */ +/* + * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project + * 2006. + */ +/* ==================================================================== + * Copyright (c) 2006 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED 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 OpenSSL PROJECT OR + * ITS 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. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* Internal ASN1 template structures and functions: not for application use */ + +void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, + int combine); diff --git crypto/openssl/crypto/asn1/tasn_fre.c crypto/openssl/crypto/asn1/tasn_fre.c index aeea4eff7ab8..0cf7510ff038 100644 --- crypto/openssl/crypto/asn1/tasn_fre.c +++ crypto/openssl/crypto/asn1/tasn_fre.c @@ -61,9 +61,7 @@ #include <openssl/asn1.h> #include <openssl/asn1t.h> #include <openssl/objects.h> - -static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, - int combine); +#include "asn1_int.h" /* Free up an ASN1 structure */ @@ -77,8 +75,7 @@ void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) asn1_item_combine_free(pval, it, 0); } -static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, - int combine) +void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) { const ASN1_TEMPLATE *tt = NULL, *seqtt; const ASN1_EXTERN_FUNCS *ef; diff --git crypto/openssl/crypto/asn1/tasn_new.c crypto/openssl/crypto/asn1/tasn_new.c index 54f459d1ed9c..6ba90260dab3 100644 --- crypto/openssl/crypto/asn1/tasn_new.c +++ crypto/openssl/crypto/asn1/tasn_new.c @@ -63,6 +63,7 @@ #include <openssl/err.h> #include <openssl/asn1t.h> #include <string.h> +#include "asn1_int.h" static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine); @@ -199,7 +200,7 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, return 1; memerr2: - ASN1_item_ex_free(pval, it); + asn1_item_combine_free(pval, it, combine); memerr: ASN1err(ASN1_F_ASN1_ITEM_EX_COMBINE_NEW, ERR_R_MALLOC_FAILURE); #ifdef CRYPTO_MDEBUG @@ -209,7 +210,7 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, return 0; auxerr2: - ASN1_item_ex_free(pval, it); + asn1_item_combine_free(pval, it, combine); auxerr: ASN1err(ASN1_F_ASN1_ITEM_EX_COMBINE_NEW, ASN1_R_AUX_ERROR); #ifdef CRYPTO_MDEBUG diff --git crypto/openssl/crypto/asn1/x_name.c crypto/openssl/crypto/asn1/x_name.c index 1fb7ad1cbf88..aea0c2763c28 100644 --- crypto/openssl/crypto/asn1/x_name.c +++ crypto/openssl/crypto/asn1/x_name.c @@ -523,19 +523,11 @@ static int i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) * _intname, int X509_NAME_set(X509_NAME **xn, X509_NAME *name) { - X509_NAME *in; - - if (!xn || !name) - return (0); - - if (*xn != name) { - in = X509_NAME_dup(name); - if (in != NULL) { - X509_NAME_free(*xn); - *xn = in; - } - } - return (*xn != NULL); + if ((name = X509_NAME_dup(name)) == NULL) + return 0; + X509_NAME_free(*xn); + *xn = name; + return 1; } IMPLEMENT_STACK_OF(X509_NAME_ENTRY) diff --git crypto/openssl/crypto/asn1/x_pkey.c crypto/openssl/crypto/asn1/x_pkey.c index 2da23e4756b4..59f855392840 100644 --- crypto/openssl/crypto/asn1/x_pkey.c +++ crypto/openssl/crypto/asn1/x_pkey.c @@ -106,10 +106,14 @@ X509_PKEY *X509_PKEY_new(void) X509_PKEY *ret = NULL; ASN1_CTX c; - M_ASN1_New_Malloc(ret, X509_PKEY); + ret = OPENSSL_malloc(sizeof(X509_PKEY)); + if (ret == NULL) { + c.line = __LINE__; + goto err; + } ret->version = 0; - M_ASN1_New(ret->enc_algor, X509_ALGOR_new); - M_ASN1_New(ret->enc_pkey, M_ASN1_OCTET_STRING_new); + ret->enc_algor = X509_ALGOR_new(); + ret->enc_pkey = M_ASN1_OCTET_STRING_new(); ret->dec_pkey = NULL; ret->key_length = 0; ret->key_data = NULL; @@ -117,8 +121,15 @@ X509_PKEY *X509_PKEY_new(void) ret->cipher.cipher = NULL; memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH); ret->references = 1; - return (ret); - M_ASN1_New_Error(ASN1_F_X509_PKEY_NEW); + if (ret->enc_algor == NULL || ret->enc_pkey == NULL) { + c.line = __LINE__; + goto err; + } + return ret; +err: + X509_PKEY_free(ret); + ASN1_MAC_H_err(ASN1_F_X509_PKEY_NEW, ERR_R_MALLOC_FAILURE, c.line); + return NULL; } void X509_PKEY_free(X509_PKEY *x) diff --git crypto/openssl/crypto/bn/asm/x86_64-mont5.pl crypto/openssl/crypto/bn/asm/x86_64-mont5.pl index 3bb0cdf5bd39..42178e455a98 100755 --- crypto/openssl/crypto/bn/asm/x86_64-mont5.pl +++ crypto/openssl/crypto/bn/asm/x86_64-mont5.pl @@ -3090,11 +3090,19 @@ $code.=<<___; .align 32 .Lsqrx8x_break: - sub 16+8(%rsp),%r8 # consume last carry + xor $zero,$zero + sub 16+8(%rsp),%rbx # mov 16(%rsp),%cf + adcx $zero,%r8 mov 24+8(%rsp),$carry # initial $tptr, borrow $carry + adcx $zero,%r9 mov 0*8($aptr),%rdx # a[8], modulo-scheduled - xor %ebp,%ebp # xor $zero,$zero + adc \$0,%r10 mov %r8,0*8($tptr) + adc \$0,%r11 + adc \$0,%r12 + adc \$0,%r13 + adc \$0,%r14 + adc \$0,%r15 cmp $carry,$tptr # cf=0, of=0 je .Lsqrx8x_outer_loop diff --git crypto/openssl/crypto/bn/bn_exp.c crypto/openssl/crypto/bn/bn_exp.c index 195a7867a46b..35facd213a25 100644 --- crypto/openssl/crypto/bn/bn_exp.c +++ crypto/openssl/crypto/bn/bn_exp.c @@ -145,7 +145,8 @@ int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) int i, bits, ret = 0; BIGNUM *v, *rr; - if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) { + if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0 + || BN_get_flags(a, BN_FLG_CONSTTIME) != 0) { /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */ BNerr(BN_F_BN_EXP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return -1; @@ -245,7 +246,9 @@ int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, if (BN_is_odd(m)) { # ifdef MONT_EXP_WORD if (a->top == 1 && !a->neg - && (BN_get_flags(p, BN_FLG_CONSTTIME) == 0)) { + && (BN_get_flags(p, BN_FLG_CONSTTIME) == 0) + && (BN_get_flags(a, BN_FLG_CONSTTIME) == 0) + && (BN_get_flags(m, BN_FLG_CONSTTIME) == 0)) { BN_ULONG A = a->d[0]; ret = BN_mod_exp_mont_word(r, A, p, m, ctx, NULL); } else @@ -277,7 +280,9 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BIGNUM *val[TABLE_SIZE]; BN_RECP_CTX recp; - if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) { + if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0 + || BN_get_flags(a, BN_FLG_CONSTTIME) != 0 + || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) { /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */ BNerr(BN_F_BN_MOD_EXP_RECP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return -1; @@ -411,7 +416,9 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, BIGNUM *val[TABLE_SIZE]; BN_MONT_CTX *mont = NULL; - if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) { + if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0 + || BN_get_flags(a, BN_FLG_CONSTTIME) != 0 + || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) { return BN_mod_exp_mont_consttime(rr, a, p, m, ctx, in_mont); } @@ -1217,7 +1224,8 @@ int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, #define BN_TO_MONTGOMERY_WORD(r, w, mont) \ (BN_set_word(r, (w)) && BN_to_montgomery(r, r, (mont), ctx)) - if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) { + if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0 + || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) { /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */ BNerr(BN_F_BN_MOD_EXP_MONT_WORD, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return -1; @@ -1348,7 +1356,9 @@ int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, /* Table of variables obtained from 'ctx' */ BIGNUM *val[TABLE_SIZE]; - if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) { + if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0 + || BN_get_flags(a, BN_FLG_CONSTTIME) != 0 + || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) { /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */ BNerr(BN_F_BN_MOD_EXP_SIMPLE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return -1; diff --git crypto/openssl/crypto/bn/bn_lib.c crypto/openssl/crypto/bn/bn_lib.c index 10b78f512607..f9c65f9f948a 100644 --- crypto/openssl/crypto/bn/bn_lib.c +++ crypto/openssl/crypto/bn/bn_lib.c @@ -524,6 +524,9 @@ BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b) memcpy(a->d, b->d, sizeof(b->d[0]) * b->top); #endif + if (BN_get_flags(b, BN_FLG_CONSTTIME) != 0) + BN_set_flags(a, BN_FLG_CONSTTIME); + a->top = b->top; a->neg = b->neg; bn_check_top(a); diff --git crypto/openssl/crypto/bn/bn_mont.c crypto/openssl/crypto/bn/bn_mont.c index be95bd55d020..3af9db870bcb 100644 --- crypto/openssl/crypto/bn/bn_mont.c +++ crypto/openssl/crypto/bn/bn_mont.c @@ -394,6 +394,9 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx) tmod.dmax = 2; tmod.neg = 0; + if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0) + BN_set_flags(&tmod, BN_FLG_CONSTTIME); + mont->ri = (BN_num_bits(mod) + (BN_BITS2 - 1)) / BN_BITS2 * BN_BITS2; # if defined(OPENSSL_BN_ASM_MONT) && (BN_BITS2<=32) diff --git crypto/openssl/crypto/bn/bn_mul.c crypto/openssl/crypto/bn/bn_mul.c index 3c618dc30708..6b455a755f71 100644 --- crypto/openssl/crypto/bn/bn_mul.c +++ crypto/openssl/crypto/bn/bn_mul.c @@ -1032,46 +1032,6 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) rr->top = top; goto end; } -# if 0 - if (i == 1 && !BN_get_flags(b, BN_FLG_STATIC_DATA)) { - BIGNUM *tmp_bn = (BIGNUM *)b; - if (bn_wexpand(tmp_bn, al) == NULL) - goto err; - tmp_bn->d[bl] = 0; - bl++; - i--; - } else if (i == -1 && !BN_get_flags(a, BN_FLG_STATIC_DATA)) { - BIGNUM *tmp_bn = (BIGNUM *)a; - if (bn_wexpand(tmp_bn, bl) == NULL) - goto err; - tmp_bn->d[al] = 0; - al++; - i++; - } - if (i == 0) { - /* symmetric and > 4 */ - /* 16 or larger */ - j = BN_num_bits_word((BN_ULONG)al); - j = 1 << (j - 1); - k = j + j; - t = BN_CTX_get(ctx); - if (al == j) { /* exact multiple */ - if (bn_wexpand(t, k * 2) == NULL) - goto err; - if (bn_wexpand(rr, k * 2) == NULL) - goto err; - bn_mul_recursive(rr->d, a->d, b->d, al, t->d); - } else { - if (bn_wexpand(t, k * 4) == NULL) - goto err; - if (bn_wexpand(rr, k * 4) == NULL) - goto err; - bn_mul_part_recursive(rr->d, a->d, b->d, al - j, j, t->d); - } - rr->top = top; - goto end; - } -# endif } #endif /* BN_RECURSION */ if (bn_wexpand(rr, top) == NULL) diff --git crypto/openssl/crypto/bn/bn_x931p.c crypto/openssl/crypto/bn/bn_x931p.c index efa48bdf8772..f444af3feabd 100644 --- crypto/openssl/crypto/bn/bn_x931p.c +++ crypto/openssl/crypto/bn/bn_x931p.c @@ -217,6 +217,8 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx) BN_CTX_start(ctx); t = BN_CTX_get(ctx); + if (t == NULL) + goto err; for (i = 0; i < 1000; i++) { if (!BN_rand(Xq, nbits, 1, 0)) @@ -255,10 +257,12 @@ int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, int ret = 0; BN_CTX_start(ctx); - if (!Xp1) + if (Xp1 == NULL) Xp1 = BN_CTX_get(ctx); - if (!Xp2) + if (Xp2 == NULL) Xp2 = BN_CTX_get(ctx); + if (Xp1 == NULL || Xp2 == NULL) + goto error; if (!BN_rand(Xp1, 101, 0, 0)) goto error; diff --git crypto/openssl/crypto/cryptlib.c crypto/openssl/crypto/cryptlib.c index 1925428f5ec5..5fab45b2ec85 100644 --- crypto/openssl/crypto/cryptlib.c +++ crypto/openssl/crypto/cryptlib.c @@ -469,11 +469,18 @@ void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr) } } +#ifdef OPENSSL_FIPS +extern int FIPS_crypto_threadid_set_callback(void (*func) (CRYPTO_THREADID *)); +#endif + int CRYPTO_THREADID_set_callback(void (*func) (CRYPTO_THREADID *)) { if (threadid_callback) return 0; threadid_callback = func; +#ifdef OPENSSL_FIPS + FIPS_crypto_threadid_set_callback(func); +#endif return 1; } diff --git crypto/openssl/crypto/dh/Makefile crypto/openssl/crypto/dh/Makefile index 46fa5ac57b47..cc366ec6fa38 100644 --- crypto/openssl/crypto/dh/Makefile +++ crypto/openssl/crypto/dh/Makefile @@ -134,7 +134,7 @@ dh_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h dh_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h dh_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h dh_gen.o: ../cryptlib.h dh_gen.c -dh_kdf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +dh_kdf.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h dh_kdf.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h dh_kdf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h dh_kdf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h diff --git crypto/openssl/crypto/dh/dh.h crypto/openssl/crypto/dh/dh.h index a228c7a7a4c3..80b28fb39dc8 100644 --- crypto/openssl/crypto/dh/dh.h +++ crypto/openssl/crypto/dh/dh.h @@ -257,11 +257,13 @@ DH *DH_get_1024_160(void); DH *DH_get_2048_224(void); DH *DH_get_2048_256(void); +# ifndef OPENSSL_NO_CMS /* RFC2631 KDF */ int DH_KDF_X9_42(unsigned char *out, size_t outlen, const unsigned char *Z, size_t Zlen, ASN1_OBJECT *key_oid, const unsigned char *ukm, size_t ukmlen, const EVP_MD *md); +# endif # define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ diff --git crypto/openssl/crypto/dh/dh_kdf.c crypto/openssl/crypto/dh/dh_kdf.c index a882cb286e0e..8947a0873152 100644 --- crypto/openssl/crypto/dh/dh_kdf.c +++ crypto/openssl/crypto/dh/dh_kdf.c @@ -51,6 +51,9 @@ * ==================================================================== */ +#include <e_os.h> + +#ifndef OPENSSL_NO_CMS #include <string.h> #include <openssl/dh.h> #include <openssl/evp.h> @@ -185,3 +188,4 @@ int DH_KDF_X9_42(unsigned char *out, size_t outlen, EVP_MD_CTX_cleanup(&mctx); return rv; } +#endif diff --git crypto/openssl/crypto/dh/dh_pmeth.c crypto/openssl/crypto/dh/dh_pmeth.c index b58e3fa86fad..6452482c87d2 100644 --- crypto/openssl/crypto/dh/dh_pmeth.c +++ crypto/openssl/crypto/dh/dh_pmeth.c @@ -207,7 +207,11 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) case EVP_PKEY_CTRL_DH_KDF_TYPE: if (p1 == -2) return dctx->kdf_type; +#ifdef OPENSSL_NO_CMS + if (p1 != EVP_PKEY_DH_KDF_NONE) +#else if (p1 != EVP_PKEY_DH_KDF_NONE && p1 != EVP_PKEY_DH_KDF_X9_42) +#endif return -2; dctx->kdf_type = p1; return 1; @@ -448,7 +452,9 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key, return ret; *keylen = ret; return 1; - } else if (dctx->kdf_type == EVP_PKEY_DH_KDF_X9_42) { + } +#ifndef OPENSSL_NO_CMS + else if (dctx->kdf_type == EVP_PKEY_DH_KDF_X9_42) { unsigned char *Z = NULL; size_t Zlen = 0; if (!dctx->kdf_outlen || !dctx->kdf_oid) @@ -479,6 +485,7 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key, } return ret; } +#endif return 1; } diff --git crypto/openssl/crypto/dsa/dsa_ameth.c crypto/openssl/crypto/dsa/dsa_ameth.c index c4fa105747fe..aac253095141 100644 --- crypto/openssl/crypto/dsa/dsa_ameth.c +++ crypto/openssl/crypto/dsa/dsa_ameth.c @@ -258,6 +258,7 @@ static int dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) goto dsaerr; } + BN_set_flags(dsa->priv_key, BN_FLG_CONSTTIME); if (!BN_mod_exp(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) { DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_BN_ERROR); goto dsaerr; diff --git crypto/openssl/crypto/dsa/dsa_gen.c crypto/openssl/crypto/dsa/dsa_gen.c index 1fce0f81c242..21af2e159fb2 100644 --- crypto/openssl/crypto/dsa/dsa_gen.c +++ crypto/openssl/crypto/dsa/dsa_gen.c @@ -482,6 +482,8 @@ int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N, } else { p = BN_CTX_get(ctx); q = BN_CTX_get(ctx); + if (q == NULL) + goto err; } if (!BN_lshift(test, BN_value_one(), L - 1)) diff --git crypto/openssl/crypto/dsa/dsa_ossl.c crypto/openssl/crypto/dsa/dsa_ossl.c index 58013a4a13b5..aa10dd12f6f8 100644 --- crypto/openssl/crypto/dsa/dsa_ossl.c +++ crypto/openssl/crypto/dsa/dsa_ossl.c @@ -224,7 +224,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, { BN_CTX *ctx; BIGNUM k, kq, *K, *kinv = NULL, *r = NULL; + BIGNUM l, m; int ret = 0; + int q_bits; if (!dsa->p || !dsa->q || !dsa->g) { DSAerr(DSA_F_DSA_SIGN_SETUP, DSA_R_MISSING_PARAMETERS); @@ -233,6 +235,8 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BN_init(&k); BN_init(&kq); + BN_init(&l); + BN_init(&m); if (ctx_in == NULL) { if ((ctx = BN_CTX_new()) == NULL) @@ -243,6 +247,13 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, if ((r = BN_new()) == NULL) goto err; + /* Preallocate space */ + q_bits = BN_num_bits(dsa->q); + if (!BN_set_bit(&k, q_bits) + || !BN_set_bit(&l, q_bits) + || !BN_set_bit(&m, q_bits)) + goto err; + /* Get random k */ do if (!BN_rand_range(&k, dsa->q)) @@ -263,24 +274,23 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, /* Compute r = (g^k mod p) mod q */ if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) { - if (!BN_copy(&kq, &k)) - goto err; - - BN_set_flags(&kq, BN_FLG_CONSTTIME); - /* * We do not want timing information to leak the length of k, so we - * compute g^k using an equivalent exponent of fixed length. (This - * is a kludge that we need because the BN_mod_exp_mont() does not - * let us specify the desired timing behaviour.) + * compute G^k using an equivalent scalar of fixed bit-length. + * + * We unconditionally perform both of these additions to prevent a + * small timing information leakage. We then choose the sum that is + * one bit longer than the modulus. + * + * TODO: revisit the BN_copy aiming for a memory access agnostic + * conditional copy. */ - - if (!BN_add(&kq, &kq, dsa->q)) + if (!BN_add(&l, &k, dsa->q) + || !BN_add(&m, &l, dsa->q) + || !BN_copy(&kq, BN_num_bits(&l) > q_bits ? &l : &m)) goto err; - if (BN_num_bits(&kq) <= BN_num_bits(dsa->q)) { - if (!BN_add(&kq, &kq, dsa->q)) - goto err; - } + + BN_set_flags(&kq, BN_FLG_CONSTTIME); K = &kq; } else { @@ -314,7 +324,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BN_CTX_free(ctx); BN_clear_free(&k); BN_clear_free(&kq); - return (ret); + BN_clear_free(&l); + BN_clear_free(&m); + return ret; } static int dsa_do_verify(const unsigned char *dgst, int dgst_len, diff --git crypto/openssl/crypto/ec/asm/ecp_nistz256-x86_64.pl crypto/openssl/crypto/ec/asm/ecp_nistz256-x86_64.pl index 7948bf71b51e..35d2b6d146c1 100755 --- crypto/openssl/crypto/ec/asm/ecp_nistz256-x86_64.pl +++ crypto/openssl/crypto/ec/asm/ecp_nistz256-x86_64.pl @@ -1178,19 +1178,18 @@ __ecp_nistz256_sqr_montx: adox $t1, $acc5 .byte 0x67,0x67 mulx %rdx, $t0, $t4 - mov $acc0, %rdx + mov .Lpoly+8*3(%rip), %rdx adox $t0, $acc6 shlx $a_ptr, $acc0, $t0 adox $t4, $acc7 shrx $a_ptr, $acc0, $t4 - mov .Lpoly+8*3(%rip), $t1 + mov %rdx,$t1 # reduction step 1 add $t0, $acc1 adc $t4, $acc2 - mulx $t1, $t0, $acc0 - mov $acc1, %rdx + mulx $acc0, $t0, $acc0 adc $t0, $acc3 shlx $a_ptr, $acc1, $t0 adc \$0, $acc0 @@ -1200,8 +1199,7 @@ __ecp_nistz256_sqr_montx: add $t0, $acc2 adc $t4, $acc3 - mulx $t1, $t0, $acc1 - mov $acc2, %rdx + mulx $acc1, $t0, $acc1 adc $t0, $acc0 shlx $a_ptr, $acc2, $t0 adc \$0, $acc1 @@ -1211,8 +1209,7 @@ __ecp_nistz256_sqr_montx: add $t0, $acc3 adc $t4, $acc0 - mulx $t1, $t0, $acc2 - mov $acc3, %rdx + mulx $acc2, $t0, $acc2 adc $t0, $acc1 shlx $a_ptr, $acc3, $t0 adc \$0, $acc2 @@ -1222,12 +1219,12 @@ __ecp_nistz256_sqr_montx: add $t0, $acc0 adc $t4, $acc1 - mulx $t1, $t0, $acc3 + mulx $acc3, $t0, $acc3 adc $t0, $acc2 adc \$0, $acc3 - xor $t3, $t3 # cf=0 - adc $acc0, $acc4 # accumulate upper half + xor $t3, $t3 + add $acc0, $acc4 # accumulate upper half mov .Lpoly+8*1(%rip), $a_ptr adc $acc1, $acc5 mov $acc4, $acc0 @@ -1236,8 +1233,7 @@ __ecp_nistz256_sqr_montx: mov $acc5, $acc1 adc \$0, $t3 - xor %eax, %eax # cf=0 - sbb \$-1, $acc4 # .Lpoly[0] + sub \$-1, $acc4 # .Lpoly[0] mov $acc6, $acc2 sbb $a_ptr, $acc5 # .Lpoly[1] sbb \$0, $acc6 # .Lpoly[2] diff --git crypto/openssl/crypto/ec/ecp_mont.c crypto/openssl/crypto/ec/ecp_mont.c index b2de7faea75e..43c4330cb0b7 100644 --- crypto/openssl/crypto/ec/ecp_mont.c +++ crypto/openssl/crypto/ec/ecp_mont.c @@ -247,6 +247,8 @@ int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, BN_CTX_free(new_ctx); if (mont != NULL) BN_MONT_CTX_free(mont); + if (one != NULL) + BN_free(one); return ret; } diff --git crypto/openssl/crypto/ec/ecp_nistp224.c crypto/openssl/crypto/ec/ecp_nistp224.c index d81cc9ce6b1a..fcd754e44881 100644 --- crypto/openssl/crypto/ec/ecp_nistp224.c +++ crypto/openssl/crypto/ec/ecp_nistp224.c @@ -716,7 +716,7 @@ static limb felem_is_zero(const felem in) return (zero | two224m96p1 | two225m97p2); } -static limb felem_is_zero_int(const felem in) +static int felem_is_zero_int(const void *in) { return (int)(felem_is_zero(in) & ((limb) 1)); } @@ -1391,7 +1391,6 @@ static void make_points_affine(size_t num, felem points[ /* num */ ][3], sizeof(felem), tmp_felems, (void (*)(void *))felem_one, - (int (*)(const void *)) felem_is_zero_int, (void (*)(void *, const void *)) felem_assign, diff --git crypto/openssl/crypto/ec/ecp_nistp256.c crypto/openssl/crypto/ec/ecp_nistp256.c index 78d191aac7af..1272966fff84 100644 --- crypto/openssl/crypto/ec/ecp_nistp256.c +++ crypto/openssl/crypto/ec/ecp_nistp256.c @@ -977,7 +977,7 @@ static limb smallfelem_is_zero(const smallfelem small) return result; } -static int smallfelem_is_zero_int(const smallfelem small) +static int smallfelem_is_zero_int(const void *small) { return (int)(smallfelem_is_zero(small) & ((limb) 1)); } @@ -1979,7 +1979,6 @@ static void make_points_affine(size_t num, smallfelem points[][3], sizeof(smallfelem), tmp_smallfelems, (void (*)(void *))smallfelem_one, - (int (*)(const void *)) smallfelem_is_zero_int, (void (*)(void *, const void *)) smallfelem_assign, diff --git crypto/openssl/crypto/ec/ecp_nistp521.c crypto/openssl/crypto/ec/ecp_nistp521.c index c53a61bbfb69..a1dc9946fd17 100644 --- crypto/openssl/crypto/ec/ecp_nistp521.c +++ crypto/openssl/crypto/ec/ecp_nistp521.c @@ -871,7 +871,7 @@ static limb felem_is_zero(const felem in) return is_zero; } -static int felem_is_zero_int(const felem in) +static int felem_is_zero_int(const void *in) { return (int)(felem_is_zero(in) & ((limb) 1)); } @@ -1787,7 +1787,6 @@ static void make_points_affine(size_t num, felem points[][3], sizeof(felem), tmp_felems, (void (*)(void *))felem_one, - (int (*)(const void *)) felem_is_zero_int, (void (*)(void *, const void *)) felem_assign, diff --git crypto/openssl/crypto/ecdh/ech_lib.c crypto/openssl/crypto/ecdh/ech_lib.c index cbc21d1a276e..9cc22582e4ad 100644 --- crypto/openssl/crypto/ecdh/ech_lib.c +++ crypto/openssl/crypto/ecdh/ech_lib.c @@ -225,9 +225,16 @@ ECDH_DATA *ecdh_check(EC_KEY *key) */ ecdh_data_free(ecdh_data); ecdh_data = (ECDH_DATA *)data; + } else if (EC_KEY_get_key_method_data(key, ecdh_data_dup, + ecdh_data_free, + ecdh_data_free) != ecdh_data) { + /* Or an out of memory error in EC_KEY_insert_key_method_data. */ + ecdh_data_free(ecdh_data); + return NULL; } - } else + } else { ecdh_data = (ECDH_DATA *)data; + } #ifdef OPENSSL_FIPS if (FIPS_mode() && !(ecdh_data->flags & ECDH_FLAG_FIPS_METHOD) && !(EC_KEY_get_flags(key) & EC_FLAG_NON_FIPS_ALLOW)) { diff --git crypto/openssl/crypto/ecdsa/ecs_lib.c crypto/openssl/crypto/ecdsa/ecs_lib.c index 8dc1dda46259..f1dd47231793 100644 --- crypto/openssl/crypto/ecdsa/ecs_lib.c +++ crypto/openssl/crypto/ecdsa/ecs_lib.c @@ -203,9 +203,16 @@ ECDSA_DATA *ecdsa_check(EC_KEY *key) */ ecdsa_data_free(ecdsa_data); ecdsa_data = (ECDSA_DATA *)data; + } else if (EC_KEY_get_key_method_data(key, ecdsa_data_dup, + ecdsa_data_free, + ecdsa_data_free) != ecdsa_data) { + /* Or an out of memory error in EC_KEY_insert_key_method_data. */ + ecdsa_data_free(ecdsa_data); + return NULL; } - } else + } else { ecdsa_data = (ECDSA_DATA *)data; + } #ifdef OPENSSL_FIPS if (FIPS_mode() && !(ecdsa_data->flags & ECDSA_FLAG_FIPS_METHOD) && !(EC_KEY_get_flags(key) & EC_FLAG_NON_FIPS_ALLOW)) { diff --git crypto/openssl/crypto/ecdsa/ecs_ossl.c crypto/openssl/crypto/ecdsa/ecs_ossl.c index dd769609be4c..16d4f59b9ba9 100644 --- crypto/openssl/crypto/ecdsa/ecs_ossl.c +++ crypto/openssl/crypto/ecdsa/ecs_ossl.c @@ -95,6 +95,7 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, EC_POINT *tmp_point = NULL; const EC_GROUP *group; int ret = 0; + int order_bits; if (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL) { ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_PASSED_NULL_PARAMETER); @@ -126,6 +127,13 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, goto err; } + /* Preallocate space */ + order_bits = BN_num_bits(order); + if (!BN_set_bit(k, order_bits) + || !BN_set_bit(r, order_bits) + || !BN_set_bit(X, order_bits)) + goto err; + do { /* get random k */ do @@ -139,13 +147,19 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, /* * We do not want timing information to leak the length of k, so we * compute G*k using an equivalent scalar of fixed bit-length. + * + * We unconditionally perform both of these additions to prevent a + * small timing information leakage. We then choose the sum that is + * one bit longer than the order. This guarantees the code + * path used in the constant time implementations elsewhere. + * + * TODO: revisit the BN_copy aiming for a memory access agnostic + * conditional copy. */ - - if (!BN_add(k, k, order)) + if (!BN_add(r, k, order) + || !BN_add(X, r, order) + || !BN_copy(k, BN_num_bits(r) > order_bits ? r : X)) goto err; - if (BN_num_bits(k) <= BN_num_bits(order)) - if (!BN_add(k, k, order)) - goto err; /* compute r the x-coordinate of generator * k */ if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx)) { diff --git crypto/openssl/crypto/err/err.c crypto/openssl/crypto/err/err.c index 0b1fcfc1f1a5..cfe0e8083f39 100644 --- crypto/openssl/crypto/err/err.c +++ crypto/openssl/crypto/err/err.c @@ -725,6 +725,8 @@ void ERR_put_error(int lib, int func, int reason, const char *file, int line) } #endif es = ERR_get_state(); + if (es == NULL) + return; es->top = (es->top + 1) % ERR_NUM_ERRORS; if (es->top == es->bottom) @@ -742,6 +744,8 @@ void ERR_clear_error(void) ERR_STATE *es; es = ERR_get_state(); + if (es == NULL) + return; for (i = 0; i < ERR_NUM_ERRORS; i++) { err_clear(es, i); @@ -806,6 +810,8 @@ static unsigned long get_error_values(int inc, int top, const char **file, unsigned long ret; es = ERR_get_state(); + if (es == NULL) + return 0; if (inc && top) { if (file) @@ -1016,7 +1022,6 @@ void ERR_remove_state(unsigned long pid) ERR_STATE *ERR_get_state(void) { - static ERR_STATE fallback; ERR_STATE *ret, tmp, *tmpp = NULL; int i; CRYPTO_THREADID tid; @@ -1030,7 +1035,7 @@ ERR_STATE *ERR_get_state(void) if (ret == NULL) { ret = (ERR_STATE *)OPENSSL_malloc(sizeof(ERR_STATE)); if (ret == NULL) - return (&fallback); + return NULL; CRYPTO_THREADID_cpy(&ret->tid, &tid); ret->top = 0; ret->bottom = 0; @@ -1042,7 +1047,7 @@ ERR_STATE *ERR_get_state(void) /* To check if insertion failed, do a get. */ if (ERRFN(thread_get_item) (ret) != ret) { ERR_STATE_free(ret); /* could not insert it */ - return (&fallback); + return NULL; } /* * If a race occured in this function and we came second, tmpp is the @@ -1066,10 +1071,10 @@ void ERR_set_error_data(char *data, int flags) int i; es = ERR_get_state(); + if (es == NULL) + return; i = es->top; - if (i == 0) - i = ERR_NUM_ERRORS - 1; err_clear_data(es, i); es->err_data[i] = data; @@ -1121,6 +1126,8 @@ int ERR_set_mark(void) ERR_STATE *es; es = ERR_get_state(); + if (es == NULL) + return 0; if (es->bottom == es->top) return 0; @@ -1133,6 +1140,8 @@ int ERR_pop_to_mark(void) ERR_STATE *es; es = ERR_get_state(); + if (es == NULL) + return 0; while (es->bottom != es->top && (es->err_flags[es->top] & ERR_FLAG_MARK) == 0) { diff --git crypto/openssl/crypto/evp/e_aes_cbc_hmac_sha1.c crypto/openssl/crypto/evp/e_aes_cbc_hmac_sha1.c index d114710e98ec..b25fc6d541d4 100644 --- crypto/openssl/crypto/evp/e_aes_cbc_hmac_sha1.c +++ crypto/openssl/crypto/evp/e_aes_cbc_hmac_sha1.c @@ -579,12 +579,17 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, maxpad |= (255 - maxpad) >> (sizeof(maxpad) * 8 - 8); maxpad &= 255; - ret &= constant_time_ge(maxpad, pad); + mask = constant_time_ge(maxpad, pad); + ret &= mask; + /* + * If pad is invalid then we will fail the above test but we must + * continue anyway because we are in constant time code. However, + * we'll use the maxpad value instead of the supplied pad to make + * sure we perform well defined pointer arithmetic. + */ + pad = constant_time_select(mask, pad, maxpad); inp_len = len - (SHA_DIGEST_LENGTH + pad + 1); - mask = (0 - ((inp_len - len) >> (sizeof(inp_len) * 8 - 1))); - inp_len &= mask; - ret &= (int)mask; key->aux.tls_aad[plen - 2] = inp_len >> 8; key->aux.tls_aad[plen - 1] = inp_len; diff --git crypto/openssl/crypto/evp/e_aes_cbc_hmac_sha256.c crypto/openssl/crypto/evp/e_aes_cbc_hmac_sha256.c index 917ae0751dee..9a8a2ad7787c 100644 --- crypto/openssl/crypto/evp/e_aes_cbc_hmac_sha256.c +++ crypto/openssl/crypto/evp/e_aes_cbc_hmac_sha256.c @@ -507,10 +507,12 @@ static int aesni_cbc_hmac_sha256_cipher(EVP_CIPHER_CTX *ctx, * to identify it and avoid stitch invocation. So that after we * establish that current CPU supports AVX, we even see if it's * either even XOP-capable Bulldozer-based or GenuineIntel one. + * But SHAEXT-capable go ahead... */ - if (OPENSSL_ia32cap_P[1] & (1 << (60 - 32)) && /* AVX? */ - ((OPENSSL_ia32cap_P[1] & (1 << (43 - 32))) /* XOP? */ - | (OPENSSL_ia32cap_P[0] & (1<<30))) && /* "Intel CPU"? */ + if (((OPENSSL_ia32cap_P[2] & (1 << 29)) || /* SHAEXT? */ + ((OPENSSL_ia32cap_P[1] & (1 << (60 - 32))) && /* AVX? */ + ((OPENSSL_ia32cap_P[1] & (1 << (43 - 32))) /* XOP? */ + | (OPENSSL_ia32cap_P[0] & (1 << 30))))) && /* "Intel CPU"? */ plen > (sha_off + iv) && (blocks = (plen - (sha_off + iv)) / SHA256_CBLOCK)) { SHA256_Update(&key->md, in + iv, sha_off); @@ -590,12 +592,17 @@ static int aesni_cbc_hmac_sha256_cipher(EVP_CIPHER_CTX *ctx, maxpad |= (255 - maxpad) >> (sizeof(maxpad) * 8 - 8); maxpad &= 255; - ret &= constant_time_ge(maxpad, pad); + mask = constant_time_ge(maxpad, pad); + ret &= mask; + /* + * If pad is invalid then we will fail the above test but we must + * continue anyway because we are in constant time code. However, + * we'll use the maxpad value instead of the supplied pad to make + * sure we perform well defined pointer arithmetic. + */ + pad = constant_time_select(mask, pad, maxpad); inp_len = len - (SHA256_DIGEST_LENGTH + pad + 1); - mask = (0 - ((inp_len - len) >> (sizeof(inp_len) * 8 - 1))); - inp_len &= mask; - ret &= (int)mask; key->aux.tls_aad[plen - 2] = inp_len >> 8; key->aux.tls_aad[plen - 1] = inp_len; diff --git crypto/openssl/crypto/evp/evp.h crypto/openssl/crypto/evp/evp.h index d258ef870a36..cf1de15e6d03 100644 --- crypto/openssl/crypto/evp/evp.h +++ crypto/openssl/crypto/evp/evp.h @@ -1363,6 +1363,98 @@ void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth, const char *type, const char *value)); +void EVP_PKEY_meth_get_init(EVP_PKEY_METHOD *pmeth, + int (**pinit) (EVP_PKEY_CTX *ctx)); + +void EVP_PKEY_meth_get_copy(EVP_PKEY_METHOD *pmeth, + int (**pcopy) (EVP_PKEY_CTX *dst, + EVP_PKEY_CTX *src)); + +void EVP_PKEY_meth_get_cleanup(EVP_PKEY_METHOD *pmeth, + void (**pcleanup) (EVP_PKEY_CTX *ctx)); + +void EVP_PKEY_meth_get_paramgen(EVP_PKEY_METHOD *pmeth, + int (**pparamgen_init) (EVP_PKEY_CTX *ctx), + int (**pparamgen) (EVP_PKEY_CTX *ctx, + EVP_PKEY *pkey)); + +void EVP_PKEY_meth_get_keygen(EVP_PKEY_METHOD *pmeth, + int (**pkeygen_init) (EVP_PKEY_CTX *ctx), + int (**pkeygen) (EVP_PKEY_CTX *ctx, + EVP_PKEY *pkey)); + +void EVP_PKEY_meth_get_sign(EVP_PKEY_METHOD *pmeth, + int (**psign_init) (EVP_PKEY_CTX *ctx), + int (**psign) (EVP_PKEY_CTX *ctx, + unsigned char *sig, size_t *siglen, + const unsigned char *tbs, + size_t tbslen)); + +void EVP_PKEY_meth_get_verify(EVP_PKEY_METHOD *pmeth, + int (**pverify_init) (EVP_PKEY_CTX *ctx), + int (**pverify) (EVP_PKEY_CTX *ctx, + const unsigned char *sig, + size_t siglen, + const unsigned char *tbs, + size_t tbslen)); + +void EVP_PKEY_meth_get_verify_recover(EVP_PKEY_METHOD *pmeth, + int (**pverify_recover_init) (EVP_PKEY_CTX + *ctx), + int (**pverify_recover) (EVP_PKEY_CTX + *ctx, + unsigned char + *sig, + size_t *siglen, + const unsigned + char *tbs, + size_t tbslen)); + +void EVP_PKEY_meth_get_signctx(EVP_PKEY_METHOD *pmeth, + int (**psignctx_init) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx), + int (**psignctx) (EVP_PKEY_CTX *ctx, + unsigned char *sig, + size_t *siglen, + EVP_MD_CTX *mctx)); + +void EVP_PKEY_meth_get_verifyctx(EVP_PKEY_METHOD *pmeth, + int (**pverifyctx_init) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx), + int (**pverifyctx) (EVP_PKEY_CTX *ctx, + const unsigned char *sig, + int siglen, + EVP_MD_CTX *mctx)); + +void EVP_PKEY_meth_get_encrypt(EVP_PKEY_METHOD *pmeth, + int (**pencrypt_init) (EVP_PKEY_CTX *ctx), + int (**pencryptfn) (EVP_PKEY_CTX *ctx, + unsigned char *out, + size_t *outlen, + const unsigned char *in, + size_t inlen)); + +void EVP_PKEY_meth_get_decrypt(EVP_PKEY_METHOD *pmeth, + int (**pdecrypt_init) (EVP_PKEY_CTX *ctx), + int (**pdecrypt) (EVP_PKEY_CTX *ctx, + unsigned char *out, + size_t *outlen, + const unsigned char *in, + size_t inlen)); + +void EVP_PKEY_meth_get_derive(EVP_PKEY_METHOD *pmeth, + int (**pderive_init) (EVP_PKEY_CTX *ctx), + int (**pderive) (EVP_PKEY_CTX *ctx, + unsigned char *key, + size_t *keylen)); + +void EVP_PKEY_meth_get_ctrl(EVP_PKEY_METHOD *pmeth, + int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1, + void *p2), + int (**pctrl_str) (EVP_PKEY_CTX *ctx, + const char *type, + const char *value)); + void EVP_add_alg_module(void); /* BEGIN ERROR CODES */ diff --git crypto/openssl/crypto/evp/evp_key.c crypto/openssl/crypto/evp/evp_key.c index 5be9e336f9e7..cdffe1c8c428 100644 --- crypto/openssl/crypto/evp/evp_key.c +++ crypto/openssl/crypto/evp/evp_key.c @@ -97,7 +97,7 @@ int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify) int EVP_read_pw_string_min(char *buf, int min, int len, const char *prompt, int verify) { - int ret; + int ret = -1; char buff[BUFSIZ]; UI *ui; @@ -105,16 +105,18 @@ int EVP_read_pw_string_min(char *buf, int min, int len, const char *prompt, prompt = prompt_string; ui = UI_new(); if (ui == NULL) - return -1; - UI_add_input_string(ui, prompt, 0, buf, min, - (len >= BUFSIZ) ? BUFSIZ - 1 : len); - if (verify) - UI_add_verify_string(ui, prompt, 0, - buff, min, (len >= BUFSIZ) ? BUFSIZ - 1 : len, - buf); + return ret; + if (UI_add_input_string(ui, prompt, 0, buf, min, + (len >= BUFSIZ) ? BUFSIZ - 1 : len) < 0 + || (verify + && UI_add_verify_string(ui, prompt, 0, buff, min, + (len >= BUFSIZ) ? BUFSIZ - 1 : len, + buf) < 0)) + goto end; ret = UI_process(ui); - UI_free(ui); OPENSSL_cleanse(buff, BUFSIZ); + end: + UI_free(ui); return ret; } diff --git crypto/openssl/crypto/evp/pmeth_lib.c crypto/openssl/crypto/evp/pmeth_lib.c index b7b7bdcd0290..e50826b568d8 100644 --- crypto/openssl/crypto/evp/pmeth_lib.c +++ crypto/openssl/crypto/evp/pmeth_lib.c @@ -589,3 +589,170 @@ void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth, pmeth->ctrl = ctrl; pmeth->ctrl_str = ctrl_str; } + +void EVP_PKEY_meth_get_init(EVP_PKEY_METHOD *pmeth, + int (**pinit) (EVP_PKEY_CTX *ctx)) +{ + *pinit = pmeth->init; +} + +void EVP_PKEY_meth_get_copy(EVP_PKEY_METHOD *pmeth, + int (**pcopy) (EVP_PKEY_CTX *dst, + EVP_PKEY_CTX *src)) +{ + *pcopy = pmeth->copy; +} + +void EVP_PKEY_meth_get_cleanup(EVP_PKEY_METHOD *pmeth, + void (**pcleanup) (EVP_PKEY_CTX *ctx)) +{ + *pcleanup = pmeth->cleanup; +} + +void EVP_PKEY_meth_get_paramgen(EVP_PKEY_METHOD *pmeth, + int (**pparamgen_init) (EVP_PKEY_CTX *ctx), + int (**pparamgen) (EVP_PKEY_CTX *ctx, + EVP_PKEY *pkey)) +{ + if (pparamgen_init) + *pparamgen_init = pmeth->paramgen_init; + if (pparamgen) + *pparamgen = pmeth->paramgen; +} + +void EVP_PKEY_meth_get_keygen(EVP_PKEY_METHOD *pmeth, + int (**pkeygen_init) (EVP_PKEY_CTX *ctx), + int (**pkeygen) (EVP_PKEY_CTX *ctx, + EVP_PKEY *pkey)) +{ + if (pkeygen_init) + *pkeygen_init = pmeth->keygen_init; + if (pkeygen) + *pkeygen = pmeth->keygen; +} + +void EVP_PKEY_meth_get_sign(EVP_PKEY_METHOD *pmeth, + int (**psign_init) (EVP_PKEY_CTX *ctx), + int (**psign) (EVP_PKEY_CTX *ctx, + unsigned char *sig, size_t *siglen, + const unsigned char *tbs, + size_t tbslen)) +{ + if (psign_init) + *psign_init = pmeth->sign_init; + if (psign) + *psign = pmeth->sign; +} + +void EVP_PKEY_meth_get_verify(EVP_PKEY_METHOD *pmeth, + int (**pverify_init) (EVP_PKEY_CTX *ctx), + int (**pverify) (EVP_PKEY_CTX *ctx, + const unsigned char *sig, + size_t siglen, + const unsigned char *tbs, + size_t tbslen)) +{ + if (pverify_init) + *pverify_init = pmeth->verify_init; + if (pverify) + *pverify = pmeth->verify; +} + +void EVP_PKEY_meth_get_verify_recover(EVP_PKEY_METHOD *pmeth, + int (**pverify_recover_init) (EVP_PKEY_CTX + *ctx), + int (**pverify_recover) (EVP_PKEY_CTX + *ctx, + unsigned char + *sig, + size_t *siglen, + const unsigned + char *tbs, + size_t tbslen)) +{ + if (pverify_recover_init) + *pverify_recover_init = pmeth->verify_recover_init; + if (pverify_recover) + *pverify_recover = pmeth->verify_recover; +} + +void EVP_PKEY_meth_get_signctx(EVP_PKEY_METHOD *pmeth, + int (**psignctx_init) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx), + int (**psignctx) (EVP_PKEY_CTX *ctx, + unsigned char *sig, + size_t *siglen, + EVP_MD_CTX *mctx)) +{ + if (psignctx_init) + *psignctx_init = pmeth->signctx_init; + if (psignctx) + *psignctx = pmeth->signctx; +} + +void EVP_PKEY_meth_get_verifyctx(EVP_PKEY_METHOD *pmeth, + int (**pverifyctx_init) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx), + int (**pverifyctx) (EVP_PKEY_CTX *ctx, + const unsigned char *sig, + int siglen, + EVP_MD_CTX *mctx)) +{ + if (pverifyctx_init) + *pverifyctx_init = pmeth->verifyctx_init; + if (pverifyctx) + *pverifyctx = pmeth->verifyctx; +} + +void EVP_PKEY_meth_get_encrypt(EVP_PKEY_METHOD *pmeth, + int (**pencrypt_init) (EVP_PKEY_CTX *ctx), + int (**pencryptfn) (EVP_PKEY_CTX *ctx, + unsigned char *out, + size_t *outlen, + const unsigned char *in, + size_t inlen)) +{ + if (pencrypt_init) + *pencrypt_init = pmeth->encrypt_init; + if (pencryptfn) + *pencryptfn = pmeth->encrypt; +} + +void EVP_PKEY_meth_get_decrypt(EVP_PKEY_METHOD *pmeth, + int (**pdecrypt_init) (EVP_PKEY_CTX *ctx), + int (**pdecrypt) (EVP_PKEY_CTX *ctx, + unsigned char *out, + size_t *outlen, + const unsigned char *in, + size_t inlen)) +{ + if (pdecrypt_init) + *pdecrypt_init = pmeth->decrypt_init; + if (pdecrypt) + *pdecrypt = pmeth->decrypt; +} + +void EVP_PKEY_meth_get_derive(EVP_PKEY_METHOD *pmeth, + int (**pderive_init) (EVP_PKEY_CTX *ctx), + int (**pderive) (EVP_PKEY_CTX *ctx, + unsigned char *key, + size_t *keylen)) +{ + if (pderive_init) + *pderive_init = pmeth->derive_init; + if (pderive) + *pderive = pmeth->derive; +} + +void EVP_PKEY_meth_get_ctrl(EVP_PKEY_METHOD *pmeth, + int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1, + void *p2), + int (**pctrl_str) (EVP_PKEY_CTX *ctx, + const char *type, + const char *value)) +{ + if (pctrl) + *pctrl = pmeth->ctrl; + if (pctrl_str) + *pctrl_str = pmeth->ctrl_str; +} diff --git crypto/openssl/crypto/ex_data.c crypto/openssl/crypto/ex_data.c index 108a1959eacf..723b21b3d281 100644 --- crypto/openssl/crypto/ex_data.c +++ crypto/openssl/crypto/ex_data.c @@ -473,7 +473,14 @@ static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, if (j < mx) mx = j; if (mx > 0) { - if (!CRYPTO_set_ex_data(to, mx - 1, NULL)) + /* + * Make sure the ex_data stack is at least |mx| elements long to avoid + * issues in the for loop that follows; so go get the |mx|'th element + * (if it does not exist CRYPTO_get_ex_data() returns NULL), and assign + * to itself. This is normally a no-op; but ensures the stack is the + * proper size + */ + if (!CRYPTO_set_ex_data(to, mx - 1, CRYPTO_get_ex_data(to, mx - 1))) goto skip; storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS *)); if (!storage) diff --git crypto/openssl/crypto/lhash/lhash.c crypto/openssl/crypto/lhash/lhash.c index f20353aea33f..f3798872598a 100644 --- crypto/openssl/crypto/lhash/lhash.c +++ crypto/openssl/crypto/lhash/lhash.c @@ -101,6 +101,24 @@ #include <openssl/crypto.h> #include <openssl/lhash.h> +/* + * A hashing implementation that appears to be based on the linear hashing + * alogrithm: + * https://en.wikipedia.org/wiki/Linear_hashing + * + * Litwin, Witold (1980), "Linear hashing: A new tool for file and table + * addressing", Proc. 6th Conference on Very Large Databases: 212–223 + * http://hackthology.com/pdfs/Litwin-1980-Linear_Hashing.pdf + * + * From the wikipedia article "Linear hashing is used in the BDB Berkeley + * database system, which in turn is used by many software systems such as + * OpenLDAP, using a C implementation derived from the CACM article and first + * published on the Usenet in 1988 by Esmond Pitt." + * + * The CACM paper is available here: + * https://pdfs.semanticscholar.org/ff4d/1c5deca6269cc316bfd952172284dbf610ee.pdf + */ + const char lh_version[] = "lhash" OPENSSL_VERSION_PTEXT; #undef MIN_NODES @@ -108,7 +126,7 @@ const char lh_version[] = "lhash" OPENSSL_VERSION_PTEXT; #define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */ #define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */ -static void expand(_LHASH *lh); +static int expand(_LHASH *lh); static void contract(_LHASH *lh); static LHASH_NODE **getrn(_LHASH *lh, const void *data, unsigned long *rhash); @@ -182,8 +200,9 @@ void *lh_insert(_LHASH *lh, void *data) void *ret; lh->error = 0; - if (lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) - expand(lh); + if (lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes) + && !expand(lh)) + return NULL; rn = getrn(lh, data, &hash); @@ -300,19 +319,37 @@ void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg) doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg); } -static void expand(_LHASH *lh) +static int expand(_LHASH *lh) { LHASH_NODE **n, **n1, **n2, *np; - unsigned int p, i, j; - unsigned long hash, nni; + unsigned int p, pmax, nni, j; + unsigned long hash; + + nni = lh->num_alloc_nodes; + p = lh->p; + pmax = lh->pmax; + if (p + 1 >= pmax) { + j = nni * 2; + n = OPENSSL_realloc(lh->b, (int)(sizeof(LHASH_NODE *) * j)); + if (n == NULL) { + lh->error++; + return 0; + } + lh->b = n; + memset(n + nni, 0, sizeof(*n) * (j - nni)); + lh->pmax = nni; + lh->num_alloc_nodes = j; + lh->num_expand_reallocs++; + lh->p = 0; + } else { + lh->p++; + } lh->num_nodes++; lh->num_expands++; - p = (int)lh->p++; n1 = &(lh->b[p]); - n2 = &(lh->b[p + (int)lh->pmax]); - *n2 = NULL; /* 27/07/92 - eay - undefined pointer bug */ - nni = lh->num_alloc_nodes; + n2 = &(lh->b[p + pmax]); + *n2 = NULL; for (np = *n1; np != NULL;) { #ifndef OPENSSL_NO_HASH_COMP @@ -330,25 +367,7 @@ static void expand(_LHASH *lh) np = *n1; } - if ((lh->p) >= lh->pmax) { - j = (int)lh->num_alloc_nodes * 2; - n = (LHASH_NODE **)OPENSSL_realloc(lh->b, - (int)(sizeof(LHASH_NODE *) * j)); - if (n == NULL) { - lh->error++; - lh->num_nodes--; - lh->p = 0; - return; - } - /* else */ - for (i = (int)lh->num_alloc_nodes; i < j; i++) /* 26/02/92 eay */ - n[i] = NULL; /* 02/03/92 eay */ - lh->pmax = lh->num_alloc_nodes; - lh->num_alloc_nodes = j; - lh->num_expand_reallocs++; - lh->p = 0; - lh->b = n; - } + return 1; } static void contract(_LHASH *lh) diff --git crypto/openssl/crypto/ocsp/ocsp_vfy.c crypto/openssl/crypto/ocsp/ocsp_vfy.c index d4a257c33bb5..7a7d06094edf 100644 --- crypto/openssl/crypto/ocsp/ocsp_vfy.c +++ crypto/openssl/crypto/ocsp/ocsp_vfy.c @@ -118,6 +118,8 @@ int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs, goto end; } } + } else if (certs != NULL) { + untrusted = certs; } else { untrusted = bs->certs; } diff --git crypto/openssl/crypto/opensslv.h crypto/openssl/crypto/opensslv.h index 9eae57ca8ae5..83867763cab3 100644 --- crypto/openssl/crypto/opensslv.h +++ crypto/openssl/crypto/opensslv.h @@ -30,11 +30,11 @@ extern "C" { * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for * major minor fix final patch/beta) */ -# define OPENSSL_VERSION_NUMBER 0x100020cfL +# define OPENSSL_VERSION_NUMBER 0x100020dfL # ifdef OPENSSL_FIPS -# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2l-fips 25 May 2017" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2m-fips 2 Nov 2017" # else -# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2l-freebsd 25 May 2017" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2m-freebsd 2 Nov 2017" # endif # define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT diff --git crypto/openssl/crypto/pem/pem_lib.c crypto/openssl/crypto/pem/pem_lib.c index c82b3c0ae263..865976bf8cce 100644 --- crypto/openssl/crypto/pem/pem_lib.c +++ crypto/openssl/crypto/pem/pem_lib.c @@ -536,7 +536,8 @@ int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher) ((c >= '0') && (c <= '9')))) break; #else - if (!(isupper(c) || (c == '-') || isdigit(c))) + if (!(isupper((unsigned char)c) || (c == '-') + || isdigit((unsigned char)c))) break; #endif header++; diff --git crypto/openssl/crypto/pem/pem_pk8.c crypto/openssl/crypto/pem/pem_pk8.c index 5747c7366e3d..daf210fde0f9 100644 --- crypto/openssl/crypto/pem/pem_pk8.c +++ crypto/openssl/crypto/pem/pem_pk8.c @@ -178,6 +178,7 @@ EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, } p8inf = PKCS8_decrypt(p8, psbuf, klen); X509_SIG_free(p8); + OPENSSL_cleanse(psbuf, klen); if (!p8inf) return NULL; ret = EVP_PKCS82PKEY(p8inf); diff --git crypto/openssl/crypto/pem/pem_pkey.c crypto/openssl/crypto/pem/pem_pkey.c index 04d6319a225b..e8b3a1b92c8d 100644 --- crypto/openssl/crypto/pem/pem_pkey.c +++ crypto/openssl/crypto/pem/pem_pkey.c @@ -120,6 +120,7 @@ EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, } p8inf = PKCS8_decrypt(p8, psbuf, klen); X509_SIG_free(p8); + OPENSSL_cleanse(psbuf, klen); if (!p8inf) goto p8err; ret = EVP_PKCS82PKEY(p8inf); diff --git crypto/openssl/crypto/pkcs12/p12_kiss.c crypto/openssl/crypto/pkcs12/p12_kiss.c index 9aa3c90c4e57..1841f78f6915 100644 --- crypto/openssl/crypto/pkcs12/p12_kiss.c +++ crypto/openssl/crypto/pkcs12/p12_kiss.c @@ -84,6 +84,12 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, { STACK_OF(X509) *ocerts = NULL; X509 *x = NULL; + + if (pkey) + *pkey = NULL; + if (cert) + *cert = NULL; + /* Check for NULL PKCS12 structure */ if (!p12) { @@ -92,11 +98,6 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, return 0; } - if (pkey) - *pkey = NULL; - if (cert) - *cert = NULL; - /* Check the mac */ /* @@ -125,7 +126,7 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, if (!ocerts) { PKCS12err(PKCS12_F_PKCS12_PARSE, ERR_R_MALLOC_FAILURE); - return 0; + goto err; } if (!parse_pk12(p12, pass, -1, pkey, ocerts)) { @@ -163,10 +164,14 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, err: - if (pkey && *pkey) + if (pkey) { EVP_PKEY_free(*pkey); - if (cert && *cert) + *pkey = NULL; + } + if (cert) { X509_free(*cert); + *cert = NULL; + } if (x) X509_free(x); if (ocerts) diff --git crypto/openssl/crypto/rsa/rsa_ameth.c crypto/openssl/crypto/rsa/rsa_ameth.c index 951e1d5ca32b..ddead3d74455 100644 --- crypto/openssl/crypto/rsa/rsa_ameth.c +++ crypto/openssl/crypto/rsa/rsa_ameth.c @@ -768,6 +768,7 @@ static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, return 2; } +#ifndef OPENSSL_NO_CMS static RSA_OAEP_PARAMS *rsa_oaep_decode(const X509_ALGOR *alg, X509_ALGOR **pmaskHash) { @@ -791,7 +792,6 @@ static RSA_OAEP_PARAMS *rsa_oaep_decode(const X509_ALGOR *alg, return pss; } -#ifndef OPENSSL_NO_CMS static int rsa_cms_decrypt(CMS_RecipientInfo *ri) { EVP_PKEY_CTX *pkctx; diff --git crypto/openssl/crypto/rsa/rsa_oaep.c crypto/openssl/crypto/rsa/rsa_oaep.c index 19d28c6f0e60..9a01b4afc11f 100644 --- crypto/openssl/crypto/rsa/rsa_oaep.c +++ crypto/openssl/crypto/rsa/rsa_oaep.c @@ -237,10 +237,14 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1, RSA_R_OAEP_DECODING_ERROR); cleanup: - if (db != NULL) + if (db != NULL) { + OPENSSL_cleanse(db, dblen); OPENSSL_free(db); - if (em != NULL) + } + if (em != NULL) { + OPENSSL_cleanse(em, num); OPENSSL_free(em); + } return mlen; } diff --git crypto/openssl/crypto/rsa/rsa_pk1.c crypto/openssl/crypto/rsa/rsa_pk1.c index efa1fd3e993f..50397c335a5a 100644 --- crypto/openssl/crypto/rsa/rsa_pk1.c +++ crypto/openssl/crypto/rsa/rsa_pk1.c @@ -255,8 +255,6 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, * We can't continue in constant-time because we need to copy the result * and we cannot fake its length. This unavoidably leaks timing * information at the API boundary. - * TODO(emilia): this could be addressed at the call site, - * see BoringSSL commit 0aa0767340baf925bda4804882aab0cb974b2d26. */ if (!good) { mlen = -1; @@ -266,8 +264,10 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, memcpy(to, em + msg_index, mlen); err: - if (em != NULL) + if (em != NULL) { + OPENSSL_cleanse(em, num); OPENSSL_free(em); + } if (mlen == -1) RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, RSA_R_PKCS_DECODING_ERROR); diff --git crypto/openssl/crypto/rsa/rsa_pmeth.c crypto/openssl/crypto/rsa/rsa_pmeth.c index 8896e2e97714..00e730ffa958 100644 --- crypto/openssl/crypto/rsa/rsa_pmeth.c +++ crypto/openssl/crypto/rsa/rsa_pmeth.c @@ -180,27 +180,25 @@ static void pkey_rsa_cleanup(EVP_PKEY_CTX *ctx) * FIPS mode. */ -static int pkey_fips_check_ctx(EVP_PKEY_CTX *ctx) +static int pkey_fips_check_rsa(const RSA *rsa, const EVP_MD **pmd, + const EVP_MD **pmgf1md) { - RSA_PKEY_CTX *rctx = ctx->data; - RSA *rsa = ctx->pkey->pkey.rsa; int rv = -1; + if (!FIPS_mode()) return 0; if (rsa->flags & RSA_FLAG_NON_FIPS_ALLOW) rv = 0; if (!(rsa->meth->flags & RSA_FLAG_FIPS_METHOD) && rv) return -1; - if (rctx->md) { - const EVP_MD *fmd; - fmd = FIPS_get_digestbynid(EVP_MD_type(rctx->md)); - if (!fmd || !(fmd->flags & EVP_MD_FLAG_FIPS)) + if (*pmd != NULL) { + *pmd = FIPS_get_digestbynid(EVP_MD_type(*pmd)); + if (*pmd == NULL || !((*pmd)->flags & EVP_MD_FLAG_FIPS)) return rv; } - if (rctx->mgf1md && !(rctx->mgf1md->flags & EVP_MD_FLAG_FIPS)) { - const EVP_MD *fmd; - fmd = FIPS_get_digestbynid(EVP_MD_type(rctx->mgf1md)); - if (!fmd || !(fmd->flags & EVP_MD_FLAG_FIPS)) + if (*pmgf1md != NULL) { + *pmgf1md = FIPS_get_digestbynid(EVP_MD_type(*pmgf1md)); + if (*pmgf1md == NULL || !((*pmgf1md)->flags & EVP_MD_FLAG_FIPS)) return rv; } return 1; @@ -214,27 +212,27 @@ static int pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, int ret; RSA_PKEY_CTX *rctx = ctx->data; RSA *rsa = ctx->pkey->pkey.rsa; + const EVP_MD *md = rctx->md; + const EVP_MD *mgf1md = rctx->mgf1md; #ifdef OPENSSL_FIPS - ret = pkey_fips_check_ctx(ctx); + ret = pkey_fips_check_rsa(rsa, &md, &mgf1md); if (ret < 0) { RSAerr(RSA_F_PKEY_RSA_SIGN, RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE); return -1; } #endif - if (rctx->md) { - if (tbslen != (size_t)EVP_MD_size(rctx->md)) { + if (md != NULL) { + if (tbslen != (size_t)EVP_MD_size(md)) { RSAerr(RSA_F_PKEY_RSA_SIGN, RSA_R_INVALID_DIGEST_LENGTH); return -1; } #ifdef OPENSSL_FIPS if (ret > 0) { unsigned int slen; - ret = FIPS_rsa_sign_digest(rsa, tbs, tbslen, rctx->md, - rctx->pad_mode, - rctx->saltlen, - rctx->mgf1md, sig, &slen); + ret = FIPS_rsa_sign_digest(rsa, tbs, tbslen, md, rctx->pad_mode, + rctx->saltlen, mgf1md, sig, &slen); if (ret > 0) *siglen = slen; else @@ -243,12 +241,12 @@ static int pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, } #endif - if (EVP_MD_type(rctx->md) == NID_mdc2) { + if (EVP_MD_type(md) == NID_mdc2) { unsigned int sltmp; if (rctx->pad_mode != RSA_PKCS1_PADDING) return -1; - ret = RSA_sign_ASN1_OCTET_STRING(NID_mdc2, - tbs, tbslen, sig, &sltmp, rsa); + ret = RSA_sign_ASN1_OCTET_STRING(NID_mdc2, tbs, tbslen, sig, &sltmp, + rsa); if (ret <= 0) return ret; @@ -263,23 +261,20 @@ static int pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, return -1; } memcpy(rctx->tbuf, tbs, tbslen); - rctx->tbuf[tbslen] = RSA_X931_hash_id(EVP_MD_type(rctx->md)); + rctx->tbuf[tbslen] = RSA_X931_hash_id(EVP_MD_type(md)); ret = RSA_private_encrypt(tbslen + 1, rctx->tbuf, sig, rsa, RSA_X931_PADDING); } else if (rctx->pad_mode == RSA_PKCS1_PADDING) { unsigned int sltmp; - ret = RSA_sign(EVP_MD_type(rctx->md), - tbs, tbslen, sig, &sltmp, rsa); + ret = RSA_sign(EVP_MD_type(md), tbs, tbslen, sig, &sltmp, rsa); if (ret <= 0) return ret; ret = sltmp; } else if (rctx->pad_mode == RSA_PKCS1_PSS_PADDING) { if (!setup_tbuf(rctx, ctx)) return -1; - if (!RSA_padding_add_PKCS1_PSS_mgf1(rsa, - rctx->tbuf, tbs, - rctx->md, rctx->mgf1md, - rctx->saltlen)) + if (!RSA_padding_add_PKCS1_PSS_mgf1(rsa, rctx->tbuf, tbs, + md, mgf1md, rctx->saltlen)) return -1; ret = RSA_private_encrypt(RSA_size(rsa), rctx->tbuf, sig, rsa, RSA_NO_PADDING); @@ -348,32 +343,31 @@ static int pkey_rsa_verify(EVP_PKEY_CTX *ctx, { RSA_PKEY_CTX *rctx = ctx->data; RSA *rsa = ctx->pkey->pkey.rsa; + const EVP_MD *md = rctx->md; + const EVP_MD *mgf1md = rctx->mgf1md; size_t rslen; + #ifdef OPENSSL_FIPS - int rv; - rv = pkey_fips_check_ctx(ctx); + int rv = pkey_fips_check_rsa(rsa, &md, &mgf1md); + if (rv < 0) { RSAerr(RSA_F_PKEY_RSA_VERIFY, RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE); return -1; } #endif - if (rctx->md) { + if (md != NULL) { #ifdef OPENSSL_FIPS if (rv > 0) { - return FIPS_rsa_verify_digest(rsa, - tbs, tbslen, - rctx->md, - rctx->pad_mode, - rctx->saltlen, - rctx->mgf1md, sig, siglen); + return FIPS_rsa_verify_digest(rsa, tbs, tbslen, md, rctx->pad_mode, + rctx->saltlen, mgf1md, sig, siglen); } #endif if (rctx->pad_mode == RSA_PKCS1_PADDING) - return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen, + return RSA_verify(EVP_MD_type(md), tbs, tbslen, sig, siglen, rsa); - if (tbslen != (size_t)EVP_MD_size(rctx->md)) { + if (tbslen != (size_t)EVP_MD_size(md)) { RSAerr(RSA_F_PKEY_RSA_VERIFY, RSA_R_INVALID_DIGEST_LENGTH); return -1; } @@ -388,8 +382,7 @@ static int pkey_rsa_verify(EVP_PKEY_CTX *ctx, rsa, RSA_NO_PADDING); if (ret <= 0) return 0; - ret = RSA_verify_PKCS1_PSS_mgf1(rsa, tbs, - rctx->md, rctx->mgf1md, + ret = RSA_verify_PKCS1_PSS_mgf1(rsa, tbs, md, mgf1md, rctx->tbuf, rctx->saltlen); if (ret <= 0) return 0; diff --git crypto/openssl/crypto/ui/ui_lib.c crypto/openssl/crypto/ui/ui_lib.c index 643ae593439a..03ef981cf912 100644 --- crypto/openssl/crypto/ui/ui_lib.c +++ crypto/openssl/crypto/ui/ui_lib.c @@ -520,6 +520,7 @@ int UI_process(UI *ui) } } } + err: if (ui->meth->ui_close_session != NULL && ui->meth->ui_close_session(ui) <= 0) diff --git crypto/openssl/crypto/whrlpool/wp_dgst.c crypto/openssl/crypto/whrlpool/wp_dgst.c index 807d1c49b2d3..96d042f5859e 100644 --- crypto/openssl/crypto/whrlpool/wp_dgst.c +++ crypto/openssl/crypto/whrlpool/wp_dgst.c @@ -166,7 +166,7 @@ void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *_inp, size_t bits) goto reconsider; } else #endif - if (bits >= 8) { + if (bits > 8) { b = ((inp[0] << inpgap) | (inp[1] >> (8 - inpgap))); b &= 0xff; if (bitrem) @@ -183,7 +183,7 @@ void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *_inp, size_t bits) } if (bitrem) c->data[byteoff] = b << (8 - bitrem); - } else { /* remaining less than 8 bits */ + } else { /* remaining less than or equal to 8 bits */ b = (inp[0] << inpgap) & 0xff; if (bitrem) diff --git crypto/openssl/crypto/x509/by_dir.c crypto/openssl/crypto/x509/by_dir.c index bbc3189381e5..6f0209a275ef 100644 --- crypto/openssl/crypto/x509/by_dir.c +++ crypto/openssl/crypto/x509/by_dir.c @@ -402,6 +402,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, if (!hent) { hent = OPENSSL_malloc(sizeof(BY_DIR_HASH)); if (hent == NULL) { + CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_MALLOC_FAILURE); goto finish; } diff --git crypto/openssl/crypto/x509/by_file.c crypto/openssl/crypto/x509/by_file.c index 43a073003d8b..82ce4e8d87c3 100644 --- crypto/openssl/crypto/x509/by_file.c +++ crypto/openssl/crypto/x509/by_file.c @@ -92,12 +92,12 @@ static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, char **ret) { int ok = 0; - char *file; + const char *file; switch (cmd) { case X509_L_FILE_LOAD: if (argl == X509_FILETYPE_DEFAULT) { - file = (char *)getenv(X509_get_default_cert_file_env()); + file = getenv(X509_get_default_cert_file_env()); if (file) ok = (X509_load_cert_crl_file(ctx, file, X509_FILETYPE_PEM) != 0); @@ -140,7 +140,7 @@ int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type) if (type == X509_FILETYPE_PEM) { for (;;) { - x = PEM_read_bio_X509_AUX(in, NULL, NULL, NULL); + x = PEM_read_bio_X509_AUX(in, NULL, NULL, ""); if (x == NULL) { if ((ERR_GET_REASON(ERR_peek_last_error()) == PEM_R_NO_START_LINE) && (count > 0)) { @@ -199,7 +199,7 @@ int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type) if (type == X509_FILETYPE_PEM) { for (;;) { - x = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL); + x = PEM_read_bio_X509_CRL(in, NULL, NULL, ""); if (x == NULL) { if ((ERR_GET_REASON(ERR_peek_last_error()) == PEM_R_NO_START_LINE) && (count > 0)) { @@ -253,7 +253,7 @@ int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type) X509err(X509_F_X509_LOAD_CERT_CRL_FILE, ERR_R_SYS_LIB); return 0; } - inf = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL); + inf = PEM_X509_INFO_read_bio(in, NULL, NULL, ""); BIO_free(in); if (!inf) { X509err(X509_F_X509_LOAD_CERT_CRL_FILE, ERR_R_PEM_LIB); diff --git crypto/openssl/crypto/x509v3/pcy_tree.c crypto/openssl/crypto/x509v3/pcy_tree.c index 09b8691c8694..03c9533bcca9 100644 --- crypto/openssl/crypto/x509v3/pcy_tree.c +++ crypto/openssl/crypto/x509v3/pcy_tree.c @@ -732,6 +732,7 @@ int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags) { int ret; + int calc_ret; X509_POLICY_TREE *tree = NULL; STACK_OF(X509_POLICY_NODE) *nodes, *auth_nodes = NULL; *ptree = NULL; @@ -800,17 +801,20 @@ int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, /* Tree is not empty: continue */ - ret = tree_calculate_authority_set(tree, &auth_nodes); + calc_ret = tree_calculate_authority_set(tree, &auth_nodes); - if (!ret) + if (!calc_ret) goto error; - if (!tree_calculate_user_set(tree, policy_oids, auth_nodes)) - goto error; + ret = tree_calculate_user_set(tree, policy_oids, auth_nodes); - if (ret == 2) + if (calc_ret == 2) sk_X509_POLICY_NODE_free(auth_nodes); + if (!ret) + goto error; + + if (tree) *ptree = tree; diff --git crypto/openssl/crypto/x509v3/v3_addr.c crypto/openssl/crypto/x509v3/v3_addr.c index 1290dec9bb8c..af080a04f2ba 100644 --- crypto/openssl/crypto/x509v3/v3_addr.c +++ crypto/openssl/crypto/x509v3/v3_addr.c @@ -130,10 +130,12 @@ static int length_from_afi(const unsigned afi) */ unsigned int v3_addr_get_afi(const IPAddressFamily *f) { - return ((f != NULL && - f->addressFamily != NULL && f->addressFamily->data != NULL) - ? ((f->addressFamily->data[0] << 8) | (f->addressFamily->data[1])) - : 0); + if (f == NULL + || f->addressFamily == NULL + || f->addressFamily->data == NULL + || f->addressFamily->length < 2) + return 0; + return (f->addressFamily->data[0] << 8) | f->addressFamily->data[1]; } /* diff --git crypto/openssl/crypto/x509v3/v3_genn.c crypto/openssl/crypto/x509v3/v3_genn.c index 7f40bfabe050..9bb01ee38e63 100644 --- crypto/openssl/crypto/x509v3/v3_genn.c +++ crypto/openssl/crypto/x509v3/v3_genn.c @@ -231,6 +231,7 @@ int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, oth = OTHERNAME_new(); if (!oth) return 0; + ASN1_TYPE_free(oth->value); oth->type_id = oid; oth->value = value; GENERAL_NAME_set0_value(gen, GEN_OTHERNAME, oth); diff --git crypto/openssl/crypto/x509v3/v3_ncons.c crypto/openssl/crypto/x509v3/v3_ncons.c index 2855269668be..1184091ccf30 100644 --- crypto/openssl/crypto/x509v3/v3_ncons.c +++ crypto/openssl/crypto/x509v3/v3_ncons.c @@ -107,6 +107,47 @@ ASN1_SEQUENCE(NAME_CONSTRAINTS) = { IMPLEMENT_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) IMPLEMENT_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) +/* + * We cannot use strncasecmp here because that applies locale specific rules. + * For example in Turkish 'I' is not the uppercase character for 'i'. We need to + * do a simple ASCII case comparison ignoring the locale (that is why we use + * numeric constants below). + */ +static int ia5ncasecmp(const char *s1, const char *s2, size_t n) +{ + for (; n > 0; n--, s1++, s2++) { + if (*s1 != *s2) { + unsigned char c1 = (unsigned char)*s1, c2 = (unsigned char)*s2; + + /* Convert to lower case */ + if (c1 >= 0x41 /* A */ && c1 <= 0x5A /* Z */) + c1 += 0x20; + if (c2 >= 0x41 /* A */ && c2 <= 0x5A /* Z */) + c2 += 0x20; + + if (c1 == c2) + continue; + + if (c1 < c2) + return -1; + + /* c1 > c2 */ + return 1; + } else if (*s1 == 0) { + /* If we get here we know that *s2 == 0 too */ + return 0; + } + } + + return 0; +} + +static int ia5casecmp(const char *s1, const char *s2) +{ + /* No portable definition of SIZE_MAX, so we use (size_t)(-1) instead */ + return ia5ncasecmp(s1, s2, (size_t)(-1)); +} + static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) { @@ -384,7 +425,7 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) return X509_V_ERR_PERMITTED_VIOLATION; } - if (strcasecmp(baseptr, dnsptr)) + if (ia5casecmp(baseptr, dnsptr)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -404,7 +445,7 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) if (!baseat && (*baseptr == '.')) { if (eml->length > base->length) { emlptr += eml->length - base->length; - if (!strcasecmp(baseptr, emlptr)) + if (ia5casecmp(baseptr, emlptr) == 0) return X509_V_OK; } return X509_V_ERR_PERMITTED_VIOLATION; @@ -425,7 +466,7 @@ static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) } emlptr = emlat + 1; /* Just have hostname left to match: case insensitive */ - if (strcasecmp(baseptr, emlptr)) + if (ia5casecmp(baseptr, emlptr)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; @@ -464,14 +505,14 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) if (*baseptr == '.') { if (hostlen > base->length) { p = hostptr + hostlen - base->length; - if (!strncasecmp(p, baseptr, base->length)) + if (ia5ncasecmp(p, baseptr, base->length) == 0) return X509_V_OK; } return X509_V_ERR_PERMITTED_VIOLATION; } if ((base->length != (int)hostlen) - || strncasecmp(hostptr, baseptr, hostlen)) + || ia5ncasecmp(hostptr, baseptr, hostlen)) return X509_V_ERR_PERMITTED_VIOLATION; return X509_V_OK; diff --git crypto/openssl/crypto/x86_64cpuid.pl crypto/openssl/crypto/x86_64cpuid.pl index a3d6f438f91e..ef3608b13495 100644 --- crypto/openssl/crypto/x86_64cpuid.pl +++ crypto/openssl/crypto/x86_64cpuid.pl @@ -136,8 +136,19 @@ OPENSSL_ia32_cpuid: or \$0x40000000,%edx # set reserved bit#30 on Intel CPUs and \$15,%ah cmp \$15,%ah # examine Family ID - jne .Lnotintel + jne .LnotP4 or \$0x00100000,%edx # set reserved bit#20 to engage RC4_CHAR +.LnotP4: + cmp \$6,%ah + jne .Lnotintel + and \$0x0fff0ff0,%eax + cmp \$0x00050670,%eax # Knights Landing + je .Lknights + cmp \$0x00080650,%eax # Knights Mill (according to sde) + jne .Lnotintel +.Lknights: + and \$0xfbffffff,%ecx # clear XSAVE flag to mimic Silvermont + .Lnotintel: bt \$28,%edx # test hyper-threading bit jnc .Lgeneric @@ -162,6 +173,10 @@ OPENSSL_ia32_cpuid: mov \$7,%eax xor %ecx,%ecx cpuid + bt \$26,%r9d # check XSAVE bit, cleared on Knights + jc .Lnotknights + and \$0xfff7ffff,%ebx # clear ADCX/ADOX flag +.Lnotknights: mov %ebx,8(%rdi) # save extended feature flags .Lno_extended_info: @@ -175,7 +190,7 @@ OPENSSL_ia32_cpuid: .Lclear_avx: mov \$0xefffe7ff,%eax # ~(1<<28|1<<12|1<<11) and %eax,%r9d # clear AVX, FMA and AMD XOP bits - andl \$0xffffffdf,8(%rdi) # cleax AVX2, ~(1<<5) + andl \$0xffffffdf,8(%rdi) # clear AVX2, ~(1<<5) .Ldone: shl \$32,%r9 mov %r10d,%eax diff --git crypto/openssl/doc/apps/asn1parse.pod crypto/openssl/doc/apps/asn1parse.pod index 76a765daf95b..a84dbc37dc89 100644 --- crypto/openssl/doc/apps/asn1parse.pod +++ crypto/openssl/doc/apps/asn1parse.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-asn1parse, asn1parse - ASN.1 parsing tool =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/ca.pod crypto/openssl/doc/apps/ca.pod index f600f553b1a7..bd1acc88f35c 100644 --- crypto/openssl/doc/apps/ca.pod +++ crypto/openssl/doc/apps/ca.pod @@ -3,6 +3,7 @@ =head1 NAME +openssl-ca, ca - sample minimal CA application =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/ciphers.pod crypto/openssl/doc/apps/ciphers.pod index 35d40bbf27ae..fa16124d08b8 100644 --- crypto/openssl/doc/apps/ciphers.pod +++ crypto/openssl/doc/apps/ciphers.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-ciphers, ciphers - SSL cipher display and cipher list tool. =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/cms.pod crypto/openssl/doc/apps/cms.pod index ac69804228cc..4a7783d47a4e 100644 --- crypto/openssl/doc/apps/cms.pod +++ crypto/openssl/doc/apps/cms.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-cms, cms - CMS utility =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/crl.pod crypto/openssl/doc/apps/crl.pod index 044a9da91545..cdced1c742c0 100644 --- crypto/openssl/doc/apps/crl.pod +++ crypto/openssl/doc/apps/crl.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-crl, crl - CRL utility =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/crl2pkcs7.pod crypto/openssl/doc/apps/crl2pkcs7.pod index 3797bc0df4ef..18654c5afa0e 100644 --- crypto/openssl/doc/apps/crl2pkcs7.pod +++ crypto/openssl/doc/apps/crl2pkcs7.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-crl2pkcs7, crl2pkcs7 - Create a PKCS#7 structure from a CRL and certificates. =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/dgst.pod crypto/openssl/doc/apps/dgst.pod index 9d2bf2173715..1c0c51333a18 100644 --- crypto/openssl/doc/apps/dgst.pod +++ crypto/openssl/doc/apps/dgst.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-dgst, dgst, sha, sha1, mdc2, ripemd160, sha224, sha256, sha384, sha512, md2, md4, md5, dss1 - message digests =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/dhparam.pod crypto/openssl/doc/apps/dhparam.pod index 1cd4c76663c5..018d9935085a 100644 --- crypto/openssl/doc/apps/dhparam.pod +++ crypto/openssl/doc/apps/dhparam.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-dhparam, dhparam - DH parameter manipulation and generation =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/dsa.pod crypto/openssl/doc/apps/dsa.pod index 8bf6cc9dcad6..77d66089beac 100644 --- crypto/openssl/doc/apps/dsa.pod +++ crypto/openssl/doc/apps/dsa.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-dsa, dsa - DSA key processing =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/dsaparam.pod crypto/openssl/doc/apps/dsaparam.pod index ba5ec4d72cdf..446903491357 100644 --- crypto/openssl/doc/apps/dsaparam.pod +++ crypto/openssl/doc/apps/dsaparam.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-dsaparam, dsaparam - DSA parameter manipulation and generation =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/ec.pod crypto/openssl/doc/apps/ec.pod index 5c7b45d4e75e..658eac5d509f 100644 --- crypto/openssl/doc/apps/ec.pod +++ crypto/openssl/doc/apps/ec.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-ec, ec - EC key processing =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/ecparam.pod crypto/openssl/doc/apps/ecparam.pod index 88e9d1e83d02..ba2f3b9ae274 100644 --- crypto/openssl/doc/apps/ecparam.pod +++ crypto/openssl/doc/apps/ecparam.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-ecparam, ecparam - EC parameter manipulation and generation =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/enc.pod crypto/openssl/doc/apps/enc.pod index 41791ad6713c..aceafcd4d557 100644 --- crypto/openssl/doc/apps/enc.pod +++ crypto/openssl/doc/apps/enc.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-enc, enc - symmetric cipher routines =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/errstr.pod crypto/openssl/doc/apps/errstr.pod index b3c6ccfc9cbd..0dee51c844ef 100644 --- crypto/openssl/doc/apps/errstr.pod +++ crypto/openssl/doc/apps/errstr.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-errstr, errstr - lookup error codes =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/gendsa.pod crypto/openssl/doc/apps/gendsa.pod index d9f56be890f8..2c8e5c86f208 100644 --- crypto/openssl/doc/apps/gendsa.pod +++ crypto/openssl/doc/apps/gendsa.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-gendsa, gendsa - generate a DSA private key from a set of parameters =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/genpkey.pod crypto/openssl/doc/apps/genpkey.pod index 929edcd26ff0..4d09fc0937c5 100644 --- crypto/openssl/doc/apps/genpkey.pod +++ crypto/openssl/doc/apps/genpkey.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-genpkey, genpkey - generate a private key =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/genrsa.pod crypto/openssl/doc/apps/genrsa.pod index f4ed9593ae26..8be06834f507 100644 --- crypto/openssl/doc/apps/genrsa.pod +++ crypto/openssl/doc/apps/genrsa.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-genrsa, genrsa - generate an RSA private key =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/nseq.pod crypto/openssl/doc/apps/nseq.pod index 989c3108fb83..de441fa87a4d 100644 --- crypto/openssl/doc/apps/nseq.pod +++ crypto/openssl/doc/apps/nseq.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-nseq, nseq - create or examine a netscape certificate sequence =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/ocsp.pod crypto/openssl/doc/apps/ocsp.pod index 1bb7958d20e5..9e2716f00820 100644 --- crypto/openssl/doc/apps/ocsp.pod +++ crypto/openssl/doc/apps/ocsp.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-ocsp, ocsp - Online Certificate Status Protocol utility =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/passwd.pod crypto/openssl/doc/apps/passwd.pod index f44982549bf1..7f74ce016d92 100644 --- crypto/openssl/doc/apps/passwd.pod +++ crypto/openssl/doc/apps/passwd.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-passwd, passwd - compute password hashes =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/pkcs12.pod crypto/openssl/doc/apps/pkcs12.pod index 744984838dc7..debc9ea27a27 100644 --- crypto/openssl/doc/apps/pkcs12.pod +++ crypto/openssl/doc/apps/pkcs12.pod @@ -3,6 +3,7 @@ =head1 NAME +openssl-pkcs12, pkcs12 - PKCS#12 file utility =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/pkcs7.pod crypto/openssl/doc/apps/pkcs7.pod index acfb8100f078..651e9371c105 100644 --- crypto/openssl/doc/apps/pkcs7.pod +++ crypto/openssl/doc/apps/pkcs7.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-pkcs7, pkcs7 - PKCS#7 utility =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/pkcs8.pod crypto/openssl/doc/apps/pkcs8.pod index 6901f1f3f211..f741741e5ad2 100644 --- crypto/openssl/doc/apps/pkcs8.pod +++ crypto/openssl/doc/apps/pkcs8.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-pkcs8, pkcs8 - PKCS#8 format private key conversion tool =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/pkey.pod crypto/openssl/doc/apps/pkey.pod index 4851223f3fcd..6db8a6238393 100644 --- crypto/openssl/doc/apps/pkey.pod +++ crypto/openssl/doc/apps/pkey.pod @@ -3,6 +3,7 @@ =head1 NAME +openssl-pkey, pkey - public or private key processing tool =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/pkeyparam.pod crypto/openssl/doc/apps/pkeyparam.pod index 154f6721af4a..27c10a6a745c 100644 --- crypto/openssl/doc/apps/pkeyparam.pod +++ crypto/openssl/doc/apps/pkeyparam.pod @@ -3,6 +3,7 @@ =head1 NAME +openssl-pkeyparam, pkeyparam - public key algorithm parameter processing tool =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/pkeyutl.pod crypto/openssl/doc/apps/pkeyutl.pod index 5da347c97d32..78b3b02a7d96 100644 --- crypto/openssl/doc/apps/pkeyutl.pod +++ crypto/openssl/doc/apps/pkeyutl.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-pkeyutl, pkeyutl - public key algorithm utility =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/rand.pod crypto/openssl/doc/apps/rand.pod index d1d213ef43cb..94df10d939e0 100644 --- crypto/openssl/doc/apps/rand.pod +++ crypto/openssl/doc/apps/rand.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-rand, rand - generate pseudo-random bytes =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/req.pod crypto/openssl/doc/apps/req.pod index 1682ba5143dd..20b2f39e90f2 100644 --- crypto/openssl/doc/apps/req.pod +++ crypto/openssl/doc/apps/req.pod @@ -3,6 +3,7 @@ =head1 NAME +openssl-req, req - PKCS#10 certificate request and certificate generating utility. =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/rsa.pod crypto/openssl/doc/apps/rsa.pod index 21cbf8ee009b..7e43e0f3d062 100644 --- crypto/openssl/doc/apps/rsa.pod +++ crypto/openssl/doc/apps/rsa.pod @@ -3,6 +3,7 @@ =head1 NAME +openssl-rsa, rsa - RSA key processing tool =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/rsautl.pod crypto/openssl/doc/apps/rsautl.pod index 1a498c2f62e0..e16ce29cf609 100644 --- crypto/openssl/doc/apps/rsautl.pod +++ crypto/openssl/doc/apps/rsautl.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-rsautl, rsautl - RSA utility =head1 SYNOPSIS @@ -105,7 +106,7 @@ Recover the signed data Examine the raw signed data: - openssl rsautl -verify -in file -inkey key.pem -raw -hexdump + openssl rsautl -verify -in sig -inkey key.pem -raw -hexdump 0000 - 00 01 ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ 0010 - ff ff ff ff ff ff ff ff-ff ff ff ff ff ff ff ff ................ diff --git crypto/openssl/doc/apps/s_client.pod crypto/openssl/doc/apps/s_client.pod index b45acbc5e3e4..d9413a0cf211 100644 --- crypto/openssl/doc/apps/s_client.pod +++ crypto/openssl/doc/apps/s_client.pod @@ -3,6 +3,7 @@ =head1 NAME +openssl-s_client, s_client - SSL/TLS client program =head1 SYNOPSIS @@ -197,12 +198,14 @@ Can be used to override the implicit B<-ign_eof> after B<-quiet>. =item B<-psk_identity identity> Use the PSK identity B<identity> when using a PSK cipher suite. +The default value is "Client_identity" (without the quotes). =item B<-psk key> Use the PSK key B<key> when using a PSK cipher suite. The key is given as a hexadecimal number without leading 0x, for example -psk 1a2b3c4d. +This option must be provided in order to use a PSK cipher. =item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-tls1_1>, B<-tls1_2>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>, B<-no_tls1_1>, B<-no_tls1_2> diff --git crypto/openssl/doc/apps/s_server.pod crypto/openssl/doc/apps/s_server.pod index 1fe93ddfbebb..9916fc3ef6a3 100644 --- crypto/openssl/doc/apps/s_server.pod +++ crypto/openssl/doc/apps/s_server.pod @@ -3,6 +3,7 @@ =head1 NAME +openssl-s_server, s_server - SSL/TLS server program =head1 SYNOPSIS @@ -219,6 +220,7 @@ Use the PSK identity hint B<hint> when using a PSK cipher suite. Use the PSK key B<key> when using a PSK cipher suite. The key is given as a hexadecimal number without leading 0x, for example -psk 1a2b3c4d. +This option must be provided in order to use a PSK cipher. =item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-tls1_1>, B<-tls1_2>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>, B<-no_tls1_1>, B<-no_tls1_2> @@ -403,10 +405,6 @@ a web browser the command: can be used for example. -Most web browsers (in particular Netscape and MSIE) only support RSA cipher -suites, so they cannot connect to servers which don't use a certificate -carrying an RSA key or a version of OpenSSL with RSA disabled. - Although specifying an empty list of CAs when requesting a client certificate is strictly speaking a protocol violation, some SSL clients interpret this to mean any CA is acceptable. This is useful for debugging purposes. diff --git crypto/openssl/doc/apps/s_time.pod crypto/openssl/doc/apps/s_time.pod index 9082d876feeb..1fa02800a419 100644 --- crypto/openssl/doc/apps/s_time.pod +++ crypto/openssl/doc/apps/s_time.pod @@ -3,6 +3,7 @@ =head1 NAME +openssl-s_time, s_time - SSL/TLS performance timing program =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/sess_id.pod crypto/openssl/doc/apps/sess_id.pod index 9988d2cd3d5d..0771baef1173 100644 --- crypto/openssl/doc/apps/sess_id.pod +++ crypto/openssl/doc/apps/sess_id.pod @@ -3,6 +3,7 @@ =head1 NAME +openssl-sess_id, sess_id - SSL/TLS session handling utility =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/smime.pod crypto/openssl/doc/apps/smime.pod index 04a83ca8e427..fbf60da27faf 100644 --- crypto/openssl/doc/apps/smime.pod +++ crypto/openssl/doc/apps/smime.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-smime, smime - S/MIME utility =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/speed.pod crypto/openssl/doc/apps/speed.pod index 1cd1998d1675..2bfe91e371cb 100644 --- crypto/openssl/doc/apps/speed.pod +++ crypto/openssl/doc/apps/speed.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-speed, speed - test library performance =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/spkac.pod crypto/openssl/doc/apps/spkac.pod index 97fb80e4016b..b8a5477a063e 100644 --- crypto/openssl/doc/apps/spkac.pod +++ crypto/openssl/doc/apps/spkac.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-spkac, spkac - SPKAC printing and generating utility =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/ts.pod crypto/openssl/doc/apps/ts.pod index d6aa47d3144d..5da019b2eb2f 100644 --- crypto/openssl/doc/apps/ts.pod +++ crypto/openssl/doc/apps/ts.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-ts, ts - Time Stamping Authority tool (client/server) =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/tsget.pod crypto/openssl/doc/apps/tsget.pod index 56db985c4bb1..4856c850d8e1 100644 --- crypto/openssl/doc/apps/tsget.pod +++ crypto/openssl/doc/apps/tsget.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-tsget, tsget - Time Stamping HTTP/HTTPS client =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/verify.pod crypto/openssl/doc/apps/verify.pod index b3767325ae07..321d5ac7e126 100644 --- crypto/openssl/doc/apps/verify.pod +++ crypto/openssl/doc/apps/verify.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-verify, verify - Utility to verify certificates. =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/version.pod crypto/openssl/doc/apps/version.pod index 58f543bc3e64..675b0f84d6a7 100644 --- crypto/openssl/doc/apps/version.pod +++ crypto/openssl/doc/apps/version.pod @@ -2,6 +2,7 @@ =head1 NAME +openssl-version, version - print OpenSSL version information =head1 SYNOPSIS diff --git crypto/openssl/doc/apps/x509.pod crypto/openssl/doc/apps/x509.pod index 10e49e5b88b2..aed22259f045 100644 --- crypto/openssl/doc/apps/x509.pod +++ crypto/openssl/doc/apps/x509.pod @@ -3,6 +3,7 @@ =head1 NAME +openssl-x509, x509 - Certificate display and signing utility =head1 SYNOPSIS diff --git crypto/openssl/doc/crypto/BN_bn2bin.pod crypto/openssl/doc/crypto/BN_bn2bin.pod index 3bed47f8f1d5..f6bb484f902f 100644 --- crypto/openssl/doc/crypto/BN_bn2bin.pod +++ crypto/openssl/doc/crypto/BN_bn2bin.pod @@ -70,8 +70,9 @@ BN_bn2bin() returns the length of the big-endian number placed at B<to>. BN_bin2bn() returns the B<BIGNUM>, NULL on error. BN_bn2hex() and BN_bn2dec() return a null-terminated string, or NULL -on error. BN_hex2bn() and BN_dec2bn() return the number's length in -hexadecimal or decimal digits, and 0 on error. +on error. BN_hex2bn() and BN_dec2bn() return the number of characters +used in parsing, or 0 on error, in which +case no new B<BIGNUM> will be created. BN_print_fp() and BN_print() return 1 on success, 0 on write errors. diff --git crypto/openssl/doc/crypto/BN_new.pod crypto/openssl/doc/crypto/BN_new.pod index ab7a105e3ad7..d446603191af 100644 --- crypto/openssl/doc/crypto/BN_new.pod +++ crypto/openssl/doc/crypto/BN_new.pod @@ -30,10 +30,12 @@ to the value 0. BN_free() frees the components of the B<BIGNUM>, and if it was created by BN_new(), also the structure itself. BN_clear_free() additionally overwrites the data before the memory is returned to the system. +If B<a> is NULL, nothing is done. =head1 RETURN VALUES -BN_new() returns a pointer to the B<BIGNUM>. If the allocation fails, +BN_new() returns a pointer to the B<BIGNUM> initialised to the value 0. +If the allocation fails, it returns B<NULL> and sets an error code that can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. diff --git crypto/openssl/doc/crypto/EVP_EncryptInit.pod crypto/openssl/doc/crypto/EVP_EncryptInit.pod index 28ab53507d2d..b19d7887345f 100644 --- crypto/openssl/doc/crypto/EVP_EncryptInit.pod +++ crypto/openssl/doc/crypto/EVP_EncryptInit.pod @@ -395,8 +395,7 @@ processed (e.g. after an EVP_EncryptFinal() call). EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, taglen, tag); Sets the expected tag to B<taglen> bytes from B<tag>. This call is only legal -when decrypting data and must be made B<before> any data is processed (e.g. -before any EVP_DecryptUpdate() call). +when decrypting data. =head1 CCM Mode diff --git crypto/openssl/doc/crypto/EVP_PKEY_meth_new.pod crypto/openssl/doc/crypto/EVP_PKEY_meth_new.pod new file mode 100644 index 000000000000..041492a8f0fb --- /dev/null +++ crypto/openssl/doc/crypto/EVP_PKEY_meth_new.pod @@ -0,0 +1,376 @@ +=pod + +=head1 NAME + +EVP_PKEY_meth_new, EVP_PKEY_meth_free, EVP_PKEY_meth_copy, EVP_PKEY_meth_find, +EVP_PKEY_meth_add0, EVP_PKEY_METHOD, +EVP_PKEY_meth_set_init, EVP_PKEY_meth_set_copy, EVP_PKEY_meth_set_cleanup, +EVP_PKEY_meth_set_paramgen, EVP_PKEY_meth_set_keygen, EVP_PKEY_meth_set_sign, +EVP_PKEY_meth_set_verify, EVP_PKEY_meth_set_verify_recover, EVP_PKEY_meth_set_signctx, +EVP_PKEY_meth_set_verifyctx, EVP_PKEY_meth_set_encrypt, EVP_PKEY_meth_set_decrypt, +EVP_PKEY_meth_set_derive, EVP_PKEY_meth_set_ctrl, +EVP_PKEY_meth_get_init, EVP_PKEY_meth_get_copy, EVP_PKEY_meth_get_cleanup, +EVP_PKEY_meth_get_paramgen, EVP_PKEY_meth_get_keygen, EVP_PKEY_meth_get_sign, +EVP_PKEY_meth_get_verify, EVP_PKEY_meth_get_verify_recover, EVP_PKEY_meth_get_signctx, +EVP_PKEY_meth_get_verifyctx, EVP_PKEY_meth_get_encrypt, EVP_PKEY_meth_get_decrypt, +EVP_PKEY_meth_get_derive, EVP_PKEY_meth_get_ctrl +- manipulating EVP_PKEY_METHOD structure + +=head1 SYNOPSIS + + #include <openssl/evp.h> + + typedef struct evp_pkey_method_st EVP_PKEY_METHOD; + + EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags); + void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth); + void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src); + const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type); + int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth); + + void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth, + int (*init) (EVP_PKEY_CTX *ctx)); + void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth, + int (*copy) (EVP_PKEY_CTX *dst, + EVP_PKEY_CTX *src)); + void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth, + void (*cleanup) (EVP_PKEY_CTX *ctx)); + void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth, + int (*paramgen_init) (EVP_PKEY_CTX *ctx), + int (*paramgen) (EVP_PKEY_CTX *ctx, + EVP_PKEY *pkey)); + void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth, + int (*keygen_init) (EVP_PKEY_CTX *ctx), + int (*keygen) (EVP_PKEY_CTX *ctx, + EVP_PKEY *pkey)); + void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth, + int (*sign_init) (EVP_PKEY_CTX *ctx), + int (*sign) (EVP_PKEY_CTX *ctx, + unsigned char *sig, size_t *siglen, + const unsigned char *tbs, + size_t tbslen)); + void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth, + int (*verify_init) (EVP_PKEY_CTX *ctx), + int (*verify) (EVP_PKEY_CTX *ctx, + const unsigned char *sig, + size_t siglen, + const unsigned char *tbs, + size_t tbslen)); + void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth, + int (*verify_recover_init) (EVP_PKEY_CTX + *ctx), + int (*verify_recover) (EVP_PKEY_CTX + *ctx, + unsigned char + *sig, + size_t *siglen, + const unsigned + char *tbs, + size_t tbslen)); + void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth, + int (*signctx_init) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx), + int (*signctx) (EVP_PKEY_CTX *ctx, + unsigned char *sig, + size_t *siglen, + EVP_MD_CTX *mctx)); + void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth, + int (*verifyctx_init) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx), + int (*verifyctx) (EVP_PKEY_CTX *ctx, + const unsigned char *sig, + int siglen, + EVP_MD_CTX *mctx)); + void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth, + int (*encrypt_init) (EVP_PKEY_CTX *ctx), + int (*encryptfn) (EVP_PKEY_CTX *ctx, + unsigned char *out, + size_t *outlen, + const unsigned char *in, + size_t inlen)); + void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth, + int (*decrypt_init) (EVP_PKEY_CTX *ctx), + int (*decrypt) (EVP_PKEY_CTX *ctx, + unsigned char *out, + size_t *outlen, + const unsigned char *in, + size_t inlen)); + void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth, + int (*derive_init) (EVP_PKEY_CTX *ctx), + int (*derive) (EVP_PKEY_CTX *ctx, + unsigned char *key, + size_t *keylen)); + void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth, + int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, + void *p2), + int (*ctrl_str) (EVP_PKEY_CTX *ctx, + const char *type, + const char *value)); + + void EVP_PKEY_meth_get_init(EVP_PKEY_METHOD *pmeth, + int (**pinit) (EVP_PKEY_CTX *ctx)); + void EVP_PKEY_meth_get_copy(EVP_PKEY_METHOD *pmeth, + int (**pcopy) (EVP_PKEY_CTX *dst, + EVP_PKEY_CTX *src)); + void EVP_PKEY_meth_get_cleanup(EVP_PKEY_METHOD *pmeth, + void (**pcleanup) (EVP_PKEY_CTX *ctx)); + void EVP_PKEY_meth_get_paramgen(EVP_PKEY_METHOD *pmeth, + int (**pparamgen_init) (EVP_PKEY_CTX *ctx), + int (**pparamgen) (EVP_PKEY_CTX *ctx, + EVP_PKEY *pkey)); + void EVP_PKEY_meth_get_keygen(EVP_PKEY_METHOD *pmeth, + int (**pkeygen_init) (EVP_PKEY_CTX *ctx), + int (**pkeygen) (EVP_PKEY_CTX *ctx, + EVP_PKEY *pkey)); + void EVP_PKEY_meth_get_sign(EVP_PKEY_METHOD *pmeth, + int (**psign_init) (EVP_PKEY_CTX *ctx), + int (**psign) (EVP_PKEY_CTX *ctx, + unsigned char *sig, size_t *siglen, + const unsigned char *tbs, + size_t tbslen)); + void EVP_PKEY_meth_get_verify(EVP_PKEY_METHOD *pmeth, + int (**pverify_init) (EVP_PKEY_CTX *ctx), + int (**pverify) (EVP_PKEY_CTX *ctx, + const unsigned char *sig, + size_t siglen, + const unsigned char *tbs, + size_t tbslen)); + void EVP_PKEY_meth_get_verify_recover(EVP_PKEY_METHOD *pmeth, + int (**pverify_recover_init) (EVP_PKEY_CTX + *ctx), + int (**pverify_recover) (EVP_PKEY_CTX + *ctx, + unsigned char + *sig, + size_t *siglen, + const unsigned + char *tbs, + size_t tbslen)); + void EVP_PKEY_meth_get_signctx(EVP_PKEY_METHOD *pmeth, + int (**psignctx_init) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx), + int (**psignctx) (EVP_PKEY_CTX *ctx, + unsigned char *sig, + size_t *siglen, + EVP_MD_CTX *mctx)); + void EVP_PKEY_meth_get_verifyctx(EVP_PKEY_METHOD *pmeth, + int (**pverifyctx_init) (EVP_PKEY_CTX *ctx, + EVP_MD_CTX *mctx), + int (**pverifyctx) (EVP_PKEY_CTX *ctx, + const unsigned char *sig, + int siglen, + EVP_MD_CTX *mctx)); + void EVP_PKEY_meth_get_encrypt(EVP_PKEY_METHOD *pmeth, + int (**pencrypt_init) (EVP_PKEY_CTX *ctx), + int (**pencryptfn) (EVP_PKEY_CTX *ctx, + unsigned char *out, + size_t *outlen, + const unsigned char *in, + size_t inlen)); + void EVP_PKEY_meth_get_decrypt(EVP_PKEY_METHOD *pmeth, + int (**pdecrypt_init) (EVP_PKEY_CTX *ctx), + int (**pdecrypt) (EVP_PKEY_CTX *ctx, + unsigned char *out, + size_t *outlen, + const unsigned char *in, + size_t inlen)); + void EVP_PKEY_meth_get_derive(EVP_PKEY_METHOD *pmeth, + int (**pderive_init) (EVP_PKEY_CTX *ctx), + int (**pderive) (EVP_PKEY_CTX *ctx, + unsigned char *key, + size_t *keylen)); + void EVP_PKEY_meth_get_ctrl(EVP_PKEY_METHOD *pmeth, + int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1, + void *p2), + int (**pctrl_str) (EVP_PKEY_CTX *ctx, + const char *type, + const char *value)); + +=head1 DESCRIPTION + +B<EVP_PKEY_METHOD> is a structure which holds a set of methods for a +specific public key cryptographic algorithm. Those methods are usually +used to perform different jobs, such as generating a key, signing or +verifying, encrypting or decrypting, etc. + +There are two places where the B<EVP_PKEY_METHOD> objects are stored: one +is a built-in static array representing the standard methods for different +algorithms, and the other one is a stack of user-defined application-specific +methods, which can be manipulated by using L<EVP_PKEY_meth_add0(3)>. + +The B<EVP_PKEY_METHOD> objects are usually referenced by B<EVP_PKEY_CTX> +objects. + +=head2 Methods + +The methods are the underlying implementations of a particular public key +algorithm present by the B<EVP_PKEY_CTX> object. + + int (*init) (EVP_PKEY_CTX *ctx); + int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src); + void (*cleanup) (EVP_PKEY_CTX *ctx); + +The init() method is called to initialize algorithm-specific data when a new +B<EVP_PKEY_CTX> is created. As opposed to init(), the cleanup() method is called +when an B<EVP_PKEY_CTX> is freed. The copy() method is called when an B<EVP_PKEY_CTX> +is being duplicated. Refer to L<EVP_PKEY_CTX_new(3)>, L<EVP_PKEY_CTX_new_id(3)>, +L<EVP_PKEY_CTX_free(3)> and L<EVP_PKEY_CTX_dup(3)>. + + int (*paramgen_init) (EVP_PKEY_CTX *ctx); + int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); + +The paramgen_init() and paramgen() methods deal with key parameter generation. +They are called by L<EVP_PKEY_paramgen_init(3)> and L<EVP_PKEY_paramgen(3)> to +handle the parameter generation process. + + int (*keygen_init) (EVP_PKEY_CTX *ctx); + int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); + +The keygen_init() and keygen() methods are used to generate the actual key for +the specified algorithm. They are called by L<EVP_PKEY_keygen_init(3)> and +L<EVP_PKEY_keygen(3)>. + + int (*sign_init) (EVP_PKEY_CTX *ctx); + int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen); + +The sign_init() and sign() methods are used to generate the signature of a +piece of data using a private key. They are called by L<EVP_PKEY_sign_init(3)> +and L<EVP_PKEY_sign(3)>. + + int (*verify_init) (EVP_PKEY_CTX *ctx); + int (*verify) (EVP_PKEY_CTX *ctx, + const unsigned char *sig, size_t siglen, + const unsigned char *tbs, size_t tbslen); + +The verify_init() and verify() methods are used to verify whether a signature is +valid. They are called by L<EVP_PKEY_verify_init(3)> and L<EVP_PKEY_verify(3)>. + + int (*verify_recover_init) (EVP_PKEY_CTX *ctx); + int (*verify_recover) (EVP_PKEY_CTX *ctx, + unsigned char *rout, size_t *routlen, + const unsigned char *sig, size_t siglen); + +The verify_recover_init() and verify_recover() methods are used to verify a +signature and then recover the digest from the signature (for instance, a +signature that was generated by RSA signing algorithm). They are called by +L<EVP_PKEY_verify_recover_init(3)> and L<EVP_PKEY_verify_recover(3)>. + + int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); + int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + EVP_MD_CTX *mctx); + +The signctx_init() and signctx() methods are used to sign a digest present by +a B<EVP_MD_CTX> object. They are called by the EVP_DigestSign functions. See +L<EVP_DigestSignInit(3)> for detail. + + int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); + int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, + EVP_MD_CTX *mctx); + +The verifyctx_init() and verifyctx() methods are used to verify a signature +against the data in a B<EVP_MD_CTX> object. They are called by the various +EVP_DigestVerify functions. See L<EVP_DigestVerifyInit(3)> for detail. + + int (*encrypt_init) (EVP_PKEY_CTX *ctx); + int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen); + +The encrypt_init() and encrypt() methods are used to encrypt a piece of data. +They are called by L<EVP_PKEY_encrypt_init(3)> and L<EVP_PKEY_encrypt(3)>. + + int (*decrypt_init) (EVP_PKEY_CTX *ctx); + int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen); + +The decrypt_init() and decrypt() methods are used to decrypt a piece of data. +They are called by L<EVP_PKEY_decrypt_init(3)> and L<EVP_PKEY_decrypt(3)>. + + int (*derive_init) (EVP_PKEY_CTX *ctx); + int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); + +The derive_init() and derive() methods are used to derive the shared secret +from a public key algorithm (for instance, the DH algorithm). They are called by +L<EVP_PKEY_derive_init(3)> and L<EVP_PKEY_derive(3)>. + + int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2); + int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value); + +The ctrl() and ctrl_str() methods are used to adjust algorithm-specific +settings. See L<EVP_PKEY_CTX_ctrl(3)> and related functions for detail. + + int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen); + int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig, + size_t siglen, const unsigned char *tbs, + size_t tbslen); + +The digestsign() and digestverify() methods are used to generate or verify +a signature in a one-shot mode. They could be called by L<EVP_DigetSign(3)> +and L<EVP_DigestVerify(3)>. + +=head2 Functions + +EVP_PKEY_meth_new() creates and returns a new B<EVP_PKEY_METHOD> object, +and associates the given B<id> and B<flags>. The following flags are +supported: + + EVP_PKEY_FLAG_AUTOARGLEN + EVP_PKEY_FLAG_SIGCTX_CUSTOM + +If an B<EVP_PKEY_METHOD> is set with the B<EVP_PKEY_FLAG_AUTOARGLEN> flag, the +maximum size of the output buffer will be automatically calculated or checked +in corresponding EVP methods by the EVP framework. Thus the implementations of +these methods don't need to care about handling the case of returning output +buffer size by themselves. For details on the output buffer size, refer to +L<EVP_PKEY_sign(3)>. + +The B<EVP_PKEY_FLAG_SIGCTX_CUSTOM> is used to indicate the signctx() method +of an B<EVP_PKEY_METHOD> is always called by the EVP framework while doing a +digest signing operation by calling L<EVP_DigestSignFinal(3)>. + +EVP_PKEY_meth_free() frees an existing B<EVP_PKEY_METHOD> pointed by +B<pmeth>. + +EVP_PKEY_meth_copy() copies an B<EVP_PKEY_METHOD> object from B<src> +to B<dst>. + +EVP_PKEY_meth_find() finds an B<EVP_PKEY_METHOD> object with the B<id>. +This function first searches through the user-defined method objects and +then the built-in objects. + +EVP_PKEY_meth_add0() adds B<pmeth> to the user defined stack of methods. + +The EVP_PKEY_meth_set functions set the corresponding fields of +B<EVP_PKEY_METHOD> structure with the arguments passed. + +The EVP_PKEY_meth_get functions get the corresponding fields of +B<EVP_PKEY_METHOD> structure to the arguments provided. + +=head1 RETURN VALUES + +EVP_PKEY_meth_new() returns a pointer to a new B<EVP_PKEY_METHOD> +object or returns NULL on error. + +EVP_PKEY_meth_free() and EVP_PKEY_meth_copy() do not return values. + +EVP_PKEY_meth_find() returns a pointer to the found B<EVP_PKEY_METHOD> +object or returns NULL if not found. + +EVP_PKEY_meth_add0() returns 1 if method is added successfully or 0 +if an error occurred. + +All EVP_PKEY_meth_set and EVP_PKEY_meth_get functions have no return +values. For the 'get' functions, function pointers are returned by +arguments. + +=head1 COPYRIGHT + +Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the OpenSSL license (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L<https://www.openssl.org/source/license.html>. + +=cut diff --git crypto/openssl/doc/crypto/RSA_padding_add_PKCS1_type_1.pod crypto/openssl/doc/crypto/RSA_padding_add_PKCS1_type_1.pod index b8f678fe729d..f20f815d4786 100644 --- crypto/openssl/doc/crypto/RSA_padding_add_PKCS1_type_1.pod +++ crypto/openssl/doc/crypto/RSA_padding_add_PKCS1_type_1.pod @@ -104,6 +104,13 @@ The RSA_padding_check_xxx() functions return the length of the recovered data, -1 on error. Error codes can be obtained by calling L<ERR_get_error(3)|ERR_get_error(3)>. +=head1 WARNING + +The RSA_padding_check_PKCS1_type_2() padding check leaks timing +information which can potentially be used to mount a Bleichenbacher +padding oracle attack. This is an inherent weakness in the PKCS #1 +v1.5 padding design. Prefer PKCS1_OAEP padding. + =head1 SEE ALSO L<RSA_public_encrypt(3)|RSA_public_encrypt(3)>, diff --git crypto/openssl/doc/crypto/RSA_public_encrypt.pod crypto/openssl/doc/crypto/RSA_public_encrypt.pod index 0541f348b3e2..4d7c1f2cac7a 100644 --- crypto/openssl/doc/crypto/RSA_public_encrypt.pod +++ crypto/openssl/doc/crypto/RSA_public_encrypt.pod @@ -67,6 +67,13 @@ recovered plaintext. On error, -1 is returned; the error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>. +=head1 WARNING + +Decryption failures in the RSA_PKCS1_PADDING mode leak information +which can potentially be used to mount a Bleichenbacher padding oracle +attack. This is an inherent weakness in the PKCS #1 v1.5 padding +design. Prefer RSA_PKCS1_OAEP_PADDING. + =head1 CONFORMING TO SSL, PKCS #1 v2.0 diff --git crypto/openssl/doc/crypto/X509_check_private_key.pod crypto/openssl/doc/crypto/X509_check_private_key.pod new file mode 100644 index 000000000000..a1fb07b1097e --- /dev/null +++ crypto/openssl/doc/crypto/X509_check_private_key.pod @@ -0,0 +1,54 @@ +=pod + +=head1 NAME + +X509_check_private_key, X509_REQ_check_private_key - check the consistency +of a private key with the public key in an X509 certificate or certificate +request + +=head1 SYNOPSIS + + #include <openssl/x509.h> + + int X509_check_private_key(X509 *x, EVP_PKEY *k); + + int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k); + +=head1 DESCRIPTION + +X509_check_private_key() function checks the consistency of private +key B<k> with the public key in B<x>. + +X509_REQ_check_private_key() is equivalent to X509_check_private_key() +except that B<x> represents a certificate request of structure B<X509_REQ>. + +=head1 RETURN VALUE + +X509_check_private_key() and X509_REQ_check_private_key() return 1 if +the keys match each other, and 0 if not. + +If the key is invalid or an error occurred, the reason code can be +obtained using L<ERR_get_error(3)>. + +=head1 BUGS + +The B<check_private_key> functions don't check if B<k> itself is indeed +a private key or not. It merely compares the public materials (e.g. exponent +and modulus of an RSA key) and/or key parameters (e.g. EC params of an EC key) +of a key pair. So if you pass a public key to these functions in B<k>, it will +return success. + +=head1 SEE ALSO + +L<ERR_get_error(3)> + +=head1 COPYRIGHT + +Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the OpenSSL license (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L<https://www.openssl.org/source/license.html>. + +=cut diff --git crypto/openssl/doc/crypto/hmac.pod crypto/openssl/doc/crypto/hmac.pod index 2c8f20a20188..ca9798af62c3 100644 --- crypto/openssl/doc/crypto/hmac.pod +++ crypto/openssl/doc/crypto/hmac.pod @@ -38,7 +38,8 @@ B<key_len> bytes long. It places the result in B<md> (which must have space for the output of the hash function, which is no more than B<EVP_MAX_MD_SIZE> bytes). If B<md> is NULL, the digest is placed in a static array. The size of -the output is placed in B<md_len>, unless it is B<NULL>. +the output is placed in B<md_len>, unless it is B<NULL>. Note: passing a NULL +value for B<md> to use the static array is not thread safe. B<evp_md> can be EVP_sha1(), EVP_ripemd160() etc. diff --git crypto/openssl/doc/man3/SSL_CTX_set_tlsext_servername_callback.pod crypto/openssl/doc/ssl/SSL_CTX_set_tlsext_servername_callback.pod similarity index 100% rename from crypto/openssl/doc/man3/SSL_CTX_set_tlsext_servername_callback.pod rename to crypto/openssl/doc/ssl/SSL_CTX_set_tlsext_servername_callback.pod diff --git crypto/openssl/doc/ssl/SSL_export_keying_material.pod crypto/openssl/doc/ssl/SSL_export_keying_material.pod new file mode 100644 index 000000000000..ccb99ec9a8e0 --- /dev/null +++ crypto/openssl/doc/ssl/SSL_export_keying_material.pod @@ -0,0 +1,61 @@ +=pod + +=head1 NAME + +SSL_export_keying_material - obtain keying material for application use + +=head1 SYNOPSIS + + #include <openssl/ssl.h> + + int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, + const char *label, size_t llen, + const unsigned char *context, + size_t contextlen, int use_context); + +=head1 DESCRIPTION + +During the creation of a TLS or DTLS connection shared keying material is +established between the two endpoints. The function SSL_export_keying_material() +enables an application to use some of this keying material for its own purposes +in accordance with RFC5705. + +An application may need to securely establish the context within which this +keying material will be used. For example this may include identifiers for the +application session, application algorithms or parameters, or the lifetime of +the context. The context value is left to the application but must be the same +on both sides of the communication. + +For a given SSL connection B<s>, B<olen> bytes of data will be written to +B<out>. The application specific context should be supplied in the location +pointed to by B<context> and should be B<contextlen> bytes long. Provision of +a context is optional. If the context should be omitted entirely then +B<use_context> should be set to 0. Otherwise it should be any other value. If +B<use_context> is 0 then the values of B<context> and B<contextlen> are ignored. +Note that a zero length context is treated differently to no context at all, and +will result in different keying material being returned. + +An application specific label should be provided in the location pointed to by +B<label> and should be B<llen> bytes long. Typically this will be a value from +the IANA Exporter Label Registry +(L<https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#exporter-labels>). +Alternatively labels beginning with "EXPERIMENTAL" are permitted by the standard +to be used without registration. + +Note that this function is only defined for TLSv1.0 and above, and DTLSv1.0 and +above. Attempting to use it in SSLv3 will result in an error. + +=head1 RETURN VALUES + +SSL_export_keying_material() returns 0 or -1 on failure or 1 on success. + +=head1 COPYRIGHT + +Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the OpenSSL license (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L<https://www.openssl.org/source/license.html>. + +=cut diff --git crypto/openssl/doc/ssl/SSL_set_connect_state.pod crypto/openssl/doc/ssl/SSL_set_connect_state.pod index d88a057deffa..14facc6a57c9 100644 --- crypto/openssl/doc/ssl/SSL_set_connect_state.pod +++ crypto/openssl/doc/ssl/SSL_set_connect_state.pod @@ -25,7 +25,7 @@ it was either assigned a dedicated client method, a dedicated server method, or a generic method, that can be used for both client and server connections. (The method might have been changed with L<SSL_CTX_set_ssl_version(3)|SSL_CTX_set_ssl_version(3)> or -SSL_set_ssl_method().) +SSL_set_ssl_method(3).) When beginning a new handshake, the SSL engine must know whether it must call the connect (client) or accept (server) routines. Even though it may diff --git crypto/openssl/ssl/s23_clnt.c crypto/openssl/ssl/s23_clnt.c index b80d1fd8ce6e..92f41dd549ad 100644 --- crypto/openssl/ssl/s23_clnt.c +++ crypto/openssl/ssl/s23_clnt.c @@ -735,7 +735,35 @@ static int ssl23_get_server_hello(SSL *s) s->version = TLS1_2_VERSION; s->method = TLSv1_2_client_method(); } else { + /* + * Unrecognised version, we'll send a protocol version alert using + * our preferred version. + */ + switch(s->client_version) { + default: + /* + * Shouldn't happen + * Fall through + */ + case TLS1_2_VERSION: + s->version = TLS1_2_VERSION; + s->method = TLSv1_2_client_method(); + break; + case TLS1_1_VERSION: + s->version = TLS1_1_VERSION; + s->method = TLSv1_1_client_method(); + break; + case TLS1_VERSION: + s->version = TLS1_VERSION; + s->method = TLSv1_client_method(); + break; + case SSL3_VERSION: + s->version = SSL3_VERSION; + s->method = SSLv3_client_method(); + break; + } SSLerr(SSL_F_SSL23_GET_SERVER_HELLO, SSL_R_UNSUPPORTED_PROTOCOL); + ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_PROTOCOL_VERSION); goto err; } diff --git crypto/openssl/ssl/s3_pkt.c crypto/openssl/ssl/s3_pkt.c index 0290c991d810..04212c51e726 100644 --- crypto/openssl/ssl/s3_pkt.c +++ crypto/openssl/ssl/s3_pkt.c @@ -1427,7 +1427,7 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) (s->s3->handshake_fragment_len >= 4) && (s->s3->handshake_fragment[0] == SSL3_MT_CLIENT_HELLO) && (s->session != NULL) && (s->session->cipher != NULL) && - !(s->ctx->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { + !(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { /* * s->s3->handshake_fragment_len = 0; */ diff --git crypto/openssl/ssl/s3_srvr.c crypto/openssl/ssl/s3_srvr.c index ba17f1b56281..0fb4845d44fa 100644 --- crypto/openssl/ssl/s3_srvr.c +++ crypto/openssl/ssl/s3_srvr.c @@ -2202,7 +2202,7 @@ int ssl3_get_client_key_exchange(SSL *s) unsigned char rand_premaster_secret[SSL_MAX_MASTER_KEY_LENGTH]; int decrypt_len; unsigned char decrypt_good, version_good; - size_t j; + size_t j, padding_len; /* FIX THIS UP EAY EAY EAY EAY */ if (s->s3->tmp.use_rsa_tmp) { @@ -2270,16 +2270,38 @@ int ssl3_get_client_key_exchange(SSL *s) if (RAND_bytes(rand_premaster_secret, sizeof(rand_premaster_secret)) <= 0) goto err; + + /* + * Decrypt with no padding. PKCS#1 padding will be removed as part of + * the timing-sensitive code below. + */ decrypt_len = - RSA_private_decrypt((int)n, p, p, rsa, RSA_PKCS1_PADDING); - ERR_clear_error(); + RSA_private_decrypt((int)n, p, p, rsa, RSA_NO_PADDING); + if (decrypt_len < 0) + goto err; + + /* Check the padding. See RFC 3447, section 7.2.2. */ /* - * decrypt_len should be SSL_MAX_MASTER_KEY_LENGTH. decrypt_good will - * be 0xff if so and zero otherwise. + * The smallest padded premaster is 11 bytes of overhead. Small keys + * are publicly invalid, so this may return immediately. This ensures + * PS is at least 8 bytes. */ - decrypt_good = - constant_time_eq_int_8(decrypt_len, SSL_MAX_MASTER_KEY_LENGTH); + if (decrypt_len < 11 + SSL_MAX_MASTER_KEY_LENGTH) { + al = SSL_AD_DECRYPT_ERROR; + SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, + SSL_R_DECRYPTION_FAILED); + goto f_err; + } + + padding_len = decrypt_len - SSL_MAX_MASTER_KEY_LENGTH; + decrypt_good = constant_time_eq_int_8(p[0], 0) & + constant_time_eq_int_8(p[1], 2); + for (j = 2; j < padding_len - 1; j++) { + decrypt_good &= ~constant_time_is_zero_8(p[j]); + } + decrypt_good &= constant_time_is_zero_8(p[padding_len - 1]); + p += padding_len; /* * If the version in the decrypted pre-master secret is correct then diff --git crypto/openssl/ssl/ssl_ciph.c crypto/openssl/ssl/ssl_ciph.c index 40021329a936..ccdf00fa1b3f 100644 --- crypto/openssl/ssl/ssl_ciph.c +++ crypto/openssl/ssl/ssl_ciph.c @@ -1205,7 +1205,7 @@ static int ssl_cipher_process_rulestr(const char *rule_str, ((ch >= '0') && (ch <= '9')) || ((ch >= 'a') && (ch <= 'z')) || (ch == '-') || (ch == '.')) #else - while (isalnum(ch) || (ch == '-') || (ch == '.')) + while (isalnum((unsigned char)ch) || (ch == '-') || (ch == '.')) #endif { ch = *(++l); diff --git crypto/openssl/ssl/ssl_lib.c crypto/openssl/ssl/ssl_lib.c index 24be376c9fdf..3539f4b8d20a 100644 --- crypto/openssl/ssl/ssl_lib.c +++ crypto/openssl/ssl/ssl_lib.c @@ -1825,15 +1825,15 @@ void SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data, int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, const char *label, size_t llen, - const unsigned char *p, size_t plen, + const unsigned char *context, size_t contextlen, int use_context) { if (s->version < TLS1_VERSION && s->version != DTLS1_BAD_VER) return -1; return s->method->ssl3_enc->export_keying_material(s, out, olen, label, - llen, p, plen, - use_context); + llen, context, + contextlen, use_context); } static unsigned long ssl_session_hash(const SSL_SESSION *a) @@ -3180,6 +3180,7 @@ SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx) #endif ssl->cert = ssl_cert_dup(ctx->cert); if (ocert) { + int i; /* Preserve any already negotiated parameters */ if (ssl->server) { ssl->cert->peer_sigalgs = ocert->peer_sigalgs; @@ -3189,6 +3190,9 @@ SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx) ssl->cert->ciphers_rawlen = ocert->ciphers_rawlen; ocert->ciphers_raw = NULL; } + for (i = 0; i < SSL_PKEY_NUM; i++) { + ssl->cert->pkeys[i].digest = ocert->pkeys[i].digest; + } #ifndef OPENSSL_NO_TLSEXT ssl->cert->alpn_proposed = ocert->alpn_proposed; ssl->cert->alpn_proposed_len = ocert->alpn_proposed_len; diff --git crypto/openssl/ssl/ssl_sess.c crypto/openssl/ssl/ssl_sess.c index f50f5142126f..23dd3e7a01c3 100644 --- crypto/openssl/ssl/ssl_sess.c +++ crypto/openssl/ssl/ssl_sess.c @@ -261,7 +261,6 @@ SSL_SESSION *ssl_session_dup(SSL_SESSION *src, int ticket) #ifndef OPENSSL_NO_SRP dest->srp_username = NULL; #endif - memset(&dest->ex_data, 0, sizeof(dest->ex_data)); /* We deliberately don't copy the prev and next pointers */ dest->prev = NULL; @@ -275,6 +274,9 @@ SSL_SESSION *ssl_session_dup(SSL_SESSION *src, int ticket) if (src->peer != NULL) CRYPTO_add(&src->peer->references, 1, CRYPTO_LOCK_X509); + if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, dest, &dest->ex_data)) + goto err; + #ifndef OPENSSL_NO_PSK if (src->psk_identity_hint) { dest->psk_identity_hint = BUF_strdup(src->psk_identity_hint); @@ -325,7 +327,7 @@ SSL_SESSION *ssl_session_dup(SSL_SESSION *src, int ticket) } # endif - if (ticket != 0) { + if (ticket != 0 && src->tlsext_tick != NULL) { dest->tlsext_tick = BUF_memdup(src->tlsext_tick, src->tlsext_ticklen); if(dest->tlsext_tick == NULL) goto err; diff --git crypto/openssl/ssl/ssltest.c crypto/openssl/ssl/ssltest.c index b75cac61fbdc..2d6141cd954e 100644 --- crypto/openssl/ssl/ssltest.c +++ crypto/openssl/ssl/ssltest.c @@ -315,6 +315,9 @@ static int s_ticket1 = 0; static int s_ticket2 = 0; static int c_ticket = 0; static int ticket_expect = -1; +static int sni_in_cert_cb = 0; +static const char *client_sigalgs = NULL; +static const char *server_digest_expect = NULL; static int servername_cb(SSL *s, int *ad, void *arg) { @@ -355,6 +358,11 @@ static int verify_servername(SSL *client, SSL *server) BIO_printf(bio_stdout, "Servername: context is unknown\n"); return -1; } +static int cert_cb(SSL *ssl, void *arg) +{ + int unused; + return servername_cb(ssl, &unused, NULL) != SSL_TLSEXT_ERR_ALERT_FATAL; +} static int verify_ticket(SSL* ssl) { @@ -371,6 +379,20 @@ static int verify_ticket(SSL* ssl) return -1; } +static int verify_server_digest(SSL* ssl) +{ + int nid = NID_undef; + + if (server_digest_expect == NULL) + return 0; + SSL_get_peer_signature_nid(ssl, &nid); + if (strcmp(server_digest_expect, OBJ_nid2sn(nid)) == 0) + return 1; + BIO_printf(bio_stdout, "Expected server digest %s, got %s.\n", + server_digest_expect, OBJ_nid2sn(nid)); + return -1; +} + /*- * next_protos_parse parses a comma separated list of strings into a string * in a format suitable for passing to SSL_CTX_set_next_protos_advertised. @@ -831,6 +853,7 @@ static void sv_usage(void) #endif #ifndef OPENSSL_NO_TLS1 fprintf(stderr, " -tls1 - use TLSv1\n"); + fprintf(stderr, " -tls12 - use TLSv1.2\n"); #endif #ifndef OPENSSL_NO_DTLS fprintf(stderr, " -dtls1 - use DTLSv1\n"); @@ -884,6 +907,9 @@ static void sv_usage(void) fprintf(stderr, " -c_ticket <yes|no> - enable/disable session tickets on the client\n"); fprintf(stderr, " -ticket_expect <yes|no> - indicate that the client should (or should not) have a ticket\n"); #endif + fprintf(stderr, " -sni_in_cert_cb - have the server handle SNI in the certificate callback\n"); + fprintf(stderr, " -client_sigalgs arg - the signature algorithms to configure on the client\n"); + fprintf(stderr, " -server_digest_expect arg - the expected server signing digest\n"); } static void print_details(SSL *c_ssl, const char *prefix) @@ -1010,7 +1036,7 @@ int main(int argc, char *argv[]) int badop = 0; int bio_pair = 0; int force = 0; - int dtls1 = 0, dtls12 = 0, tls1 = 0, ssl2 = 0, ssl3 = 0, ret = 1; + int dtls1 = 0, dtls12 = 0, tls1 = 0, tls12 = 0, ssl2 = 0, ssl3 = 0, ret = 1; int client_auth = 0; int server_auth = 0, i; struct app_verify_arg app_verify_arg = @@ -1164,6 +1190,11 @@ int main(int argc, char *argv[]) no_protocol = 1; #endif tls1 = 1; + } else if (strcmp(*argv, "-tls12") == 0) { +#ifdef OPENSSL_NO_TLS1 + no_protocol = 1; +#endif + tls12 = 1; } else if (strcmp(*argv, "-ssl3") == 0) { #ifdef OPENSSL_NO_SSL3_METHOD no_protocol = 1; @@ -1343,6 +1374,16 @@ int main(int argc, char *argv[]) else if (strcmp(*argv, "no") == 0) ticket_expect = 0; #endif + } else if (strcmp(*argv, "-sni_in_cert_cb") == 0) { + sni_in_cert_cb = 1; + } else if (strcmp(*argv, "-client_sigalgs") == 0) { + if (--argc < 1) + goto bad; + client_sigalgs = *(++argv); + } else if (strcmp(*argv, "-server_digest_expect") == 0) { + if (--argc < 1) + goto bad; + server_digest_expect = *(++argv); } else { fprintf(stderr, "unknown option %s\n", *argv); badop = 1; @@ -1373,9 +1414,9 @@ int main(int argc, char *argv[]) goto end; } - if (ssl2 + ssl3 + tls1 + dtls1 + dtls12 > 1) { - fprintf(stderr, "At most one of -ssl2, -ssl3, -tls1, -dtls1 or -dtls12 should " - "be requested.\n"); + if (ssl2 + ssl3 + tls1 + tls12 + dtls1 + dtls12 > 1) { + fprintf(stderr, "At most one of -ssl2, -ssl3, -tls1, -tls12, -dtls1 or " + "-dtls12 should be requested.\n"); EXIT(1); } @@ -1391,10 +1432,11 @@ int main(int argc, char *argv[]) goto end; } - if (!ssl2 && !ssl3 && !tls1 && !dtls1 && !dtls12 && number > 1 && !reuse && !force) { + if (!ssl2 && !ssl3 && !tls1 && !tls12 && !dtls1 && !dtls12 && number > 1 + && !reuse && !force) { fprintf(stderr, "This case cannot work. Use -f to perform " "the test anyway (and\n-d to see what happens), " - "or add one of ssl2, -ssl3, -tls1, -dtls1, -dtls12, -reuse\n" + "or add one of ssl2, -ssl3, -tls1, -tls12, -dtls1, -dtls12, -reuse\n" "to avoid protocol mismatch.\n"); EXIT(1); } @@ -1458,7 +1500,7 @@ int main(int argc, char *argv[]) #endif /* - * At this point, ssl2/ssl3/tls1 is only set if the protocol is + * At this point, ssl2/ssl3/tls1/tls12 is only set if the protocol is * available. (Otherwise we exit early.) However the compiler doesn't * know this, so we ifdef. */ @@ -1482,6 +1524,8 @@ int main(int argc, char *argv[]) #ifndef OPENSSL_NO_TLS1 if (tls1) meth = TLSv1_method(); + else if (tls12) + meth = TLSv1_2_method(); else #endif meth = SSLv23_method(); @@ -1778,8 +1822,12 @@ int main(int argc, char *argv[]) OPENSSL_free(alpn); } - if (sn_server1 || sn_server2) - SSL_CTX_set_tlsext_servername_callback(s_ctx, servername_cb); + if (sn_server1 || sn_server2) { + if (sni_in_cert_cb) + SSL_CTX_set_cert_cb(s_ctx, cert_cb, NULL); + else + SSL_CTX_set_tlsext_servername_callback(s_ctx, servername_cb); + } #ifndef OPENSSL_NO_TLSEXT if (s_ticket1 == 0) @@ -1799,6 +1847,9 @@ int main(int argc, char *argv[]) SSL_CTX_set_options(c_ctx, SSL_OP_NO_TICKET); #endif + if (client_sigalgs != NULL) + SSL_CTX_set1_sigalgs_list(c_ctx, client_sigalgs); + c_ssl = SSL_new(c_ctx); s_ssl = SSL_new(s_ctx); @@ -1864,6 +1915,8 @@ int main(int argc, char *argv[]) ret = 1; if (verify_ticket(c_ssl) < 0) ret = 1; + if (verify_server_digest(c_ssl) < 0) + ret = 1; SSL_free(s_ssl); SSL_free(c_ssl); diff --git crypto/openssl/ssl/tls1.h crypto/openssl/ssl/tls1.h index 7e237d0631a3..dd1d8c109ee5 100644 --- crypto/openssl/ssl/tls1.h +++ crypto/openssl/ssl/tls1.h @@ -317,7 +317,7 @@ int SSL_get_servername_type(const SSL *s); */ int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, const char *label, size_t llen, - const unsigned char *p, size_t plen, + const unsigned char *context, size_t contextlen, int use_context); int SSL_get_sigalgs(SSL *s, int idx, diff --git crypto/openssl/util/copy-if-different.pl crypto/openssl/util/copy-if-different.pl index ec99e084b56a..e1245f54aff1 100755 --- crypto/openssl/util/copy-if-different.pl +++ crypto/openssl/util/copy-if-different.pl @@ -12,7 +12,7 @@ my @filelist; foreach my $arg (@ARGV) { $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob... - foreach (glob $arg) + foreach (glob qq("$arg")) { push @filelist, $_; } diff --git crypto/openssl/util/copy.pl crypto/openssl/util/copy.pl index eba6d5815e9c..a6b2a54ec6f0 100644 --- crypto/openssl/util/copy.pl +++ crypto/openssl/util/copy.pl @@ -19,7 +19,7 @@ foreach $arg (@ARGV) { next; } $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob... - foreach (glob $arg) + foreach (glob qq("$arg")) { push @filelist, $_; } diff --git crypto/openssl/util/libeay.num crypto/openssl/util/libeay.num index 2094ab364c8e..fddfe1cbb202 100644 --- crypto/openssl/util/libeay.num +++ crypto/openssl/util/libeay.num @@ -4370,7 +4370,7 @@ DH_compute_key_padded 4732 EXIST::FUNCTION:DH ECDSA_METHOD_set_sign 4733 EXIST::FUNCTION:ECDSA CMS_RecipientEncryptedKey_cert_cmp 4734 EXIST:!VMS:FUNCTION:CMS CMS_RecipEncryptedKey_cert_cmp 4734 EXIST:VMS:FUNCTION:CMS -DH_KDF_X9_42 4735 EXIST::FUNCTION:DH +DH_KDF_X9_42 4735 EXIST::FUNCTION:CMS,DH RSA_OAEP_PARAMS_free 4736 EXIST::FUNCTION:RSA EVP_des_ede3_wrap 4737 EXIST::FUNCTION:DES RSA_OAEP_PARAMS_it 4738 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RSA @@ -4416,3 +4416,17 @@ X509_VERIFY_PARAM_add1_host 4771 EXIST::FUNCTION: EC_GROUP_get_mont_data 4772 EXIST::FUNCTION:EC i2d_re_X509_tbs 4773 EXIST::FUNCTION: EVP_PKEY_asn1_set_item 4774 EXIST::FUNCTION: +EVP_PKEY_meth_get_init 4775 EXIST::FUNCTION: +EVP_PKEY_meth_get_verify_recover 4776 EXIST::FUNCTION: +EVP_PKEY_meth_get_keygen 4777 EXIST::FUNCTION: +EVP_PKEY_meth_get_derive 4778 EXIST::FUNCTION: +EVP_PKEY_meth_get_verifyctx 4779 EXIST::FUNCTION: +EVP_PKEY_meth_get_paramgen 4780 EXIST::FUNCTION: +EVP_PKEY_meth_get_verify 4781 EXIST::FUNCTION: +EVP_PKEY_meth_get_sign 4782 EXIST::FUNCTION: +EVP_PKEY_meth_get_signctx 4783 EXIST::FUNCTION: +EVP_PKEY_meth_get_ctrl 4784 EXIST::FUNCTION: +EVP_PKEY_meth_get_decrypt 4785 EXIST::FUNCTION: +EVP_PKEY_meth_get_cleanup 4786 EXIST::FUNCTION: +EVP_PKEY_meth_get_encrypt 4787 EXIST::FUNCTION: +EVP_PKEY_meth_get_copy 4788 EXIST::FUNCTION: diff --git crypto/openssl/util/mk1mf.pl crypto/openssl/util/mk1mf.pl index 490a034e4037..6b31496ed1e6 100755 --- crypto/openssl/util/mk1mf.pl +++ crypto/openssl/util/mk1mf.pl @@ -428,7 +428,7 @@ EOF { $extra_install .= <<"EOF" \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\" - \$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\" + \$(CP) \$(E_SHLIB) \"\$(INSTALLTOP)${o}lib${o}engines\" EOF } } @@ -608,7 +608,7 @@ install: all \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\" \$(MKDIR) \"\$(INSTALLTOP)${o}lib\" \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\" - \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\" + \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep\" \"\$(INSTALLTOP)${o}bin\" \$(MKDIR) \"\$(OPENSSLDIR)\" \$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\" $extra_install diff --git etc/Makefile etc/Makefile index a2ad96bd3269..93351222a239 100644 --- etc/Makefile +++ etc/Makefile @@ -220,9 +220,6 @@ distribution: ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 600 \ snmpd.config ${DESTDIR}/etc; .endif -.if ${MK_AT} == "no" - sed -i "" -e 's;.*/usr/libexec/atrun;#&;' ${DESTDIR}/etc/crontab -.endif .if ${MK_TCSH} == "no" sed -i "" -e 's;/bin/csh;/bin/sh;' ${DESTDIR}/etc/master.passwd .endif @@ -403,31 +400,6 @@ distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY done; true .endif ${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/sys -.if ${MK_MAN} != "no" - cd ${DESTDIR}${SHAREDIR}/man; \ - for mandir in man*; do \ - ${INSTALL_SYMLINK} ../$$mandir \ - ${DESTDIR}${SHAREDIR}/man/en.ISO8859-1/; \ - ${INSTALL_SYMLINK} ../$$mandir \ - ${DESTDIR}${SHAREDIR}/man/en.UTF-8/; \ - done -.if ${MK_OPENSSL} != "no" - cd ${DESTDIR}${SHAREDIR}/openssl/man; \ - for mandir in man*; do \ - ${INSTALL_SYMLINK} ../$$mandir \ - ${DESTDIR}${SHAREDIR}/openssl/man/en.ISO8859-1/; \ - done -.endif - set - `grep "^[a-zA-Z]" ${.CURDIR}/man.alias`; \ - while [ $$# -gt 0 ] ; do \ - ${INSTALL_SYMLINK} "$$2" "${DESTDIR}${SHAREDIR}/man/$$1"; \ - if [ "${MK_OPENSSL}" != "no" ]; then \ - ${INSTALL_SYMLINK} "$$2" \ - "${DESTDIR}${SHAREDIR}/openssl/man/$$1"; \ - fi; \ - shift; shift; \ - done -.endif .if ${MK_NLS} != "no" set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \ while [ $$# -gt 0 ] ; do \ diff --git etc/autofs/Makefile etc/autofs/Makefile index 6d1c9e85d30b..f2f8c4f3dd6c 100644 --- etc/autofs/Makefile +++ etc/autofs/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -FILES= include_ldap special_hosts special_media special_noauto special_null +FILES= include_ldap include_nis special_hosts special_media special_noauto special_null NO_OBJ= FILESDIR= /etc/autofs diff --git etc/autofs/include_nis etc/autofs/include_nis new file mode 100644 index 000000000000..e671c42288dd --- /dev/null +++ etc/autofs/include_nis @@ -0,0 +1,180 @@ +#!/usr/bin/awk -f +#- +# Copyright (c) 2017 G. Paul Ziemba +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# +# /etc/autofs/include_nis +# +# automountd Directory Services script for NIS +# +# SYNOPSIS +# include_nis <mapname> +# +# include_nis <mapname> <key> +# +# DESCRIPTION +# +# This script provides a Directory Services map for automountd +# based on NIS. Please see auto_master(5) for general information. +# +# The first form, with one argument, emits the entire named NIS map. +# The second form, with two arguments, emits the map entry for the +# key given in the second argument. +# +# This script attempts to determine the names and IP addresses +# of the local host. Map entries matching the local host are +# rewritten to specify nullfs mounts (instead of the default +# NFS) to reduce access overhead in the kernel. +# +# If a map entry contains multiple location fields, it is not changed. +# + + +# Populate list of names and IP addrs thet mean "this host" +# into myhostnames array +BEGIN { + # + # Set self hostnames + # + + "hostname -s" | getline; + myhostnames[$0] = 1; + + "hostname -f" | getline; + myhostnames[$0] = 1; + + myhostnames["localhost"] = 1 + + "hostname -f" | getline; + localdomain=$0 + myhostnames["localhost."localdomain] = 1 + + while ("ifconfig" | getline) { + if ($1 == "inet") { + myhostnames[$2] = 1; + } + } + + # debug +# print "--- hostname list start ----" +# for (i in myhostnames) { +# print i +# } +# print "--- hostname list end ----" + + if (ARGC == 2) { + # mapname only + while ("ypcat -k " ARGV[1] | getline) { + proc_mapline(1) + } + } + if (ARGC == 3) { + # mapname and keyname + while ("ypmatch " ARGV[2] " " ARGV[1] | getline) { + proc_mapline(0) + } + } + exit 0 +} + +function is_self(hostname) +{ + if (myhostnames[hostname]) { + return 1 + } + return 0 +} + +# +# Lines are of the form [key] [-opts] location1 [... locationN] +# +# indicate index of key field with first positional parameter +# 1 means keyfield is the first field +# 0 means keyfield is not present +# +function proc_mapline(keyfield) +{ + optionsfield = 0 + locationfield = 0 + locationcount = 0 + + for (i=keyfield+1; i <= NF; ++i) { + if (!optionsfield) { + if ($i ~ /^-/) { + # the first options field found on the line + optionsfield = i; + continue + } + } + # Assumption: location contains colon (":") + if (optionsfield && ($i ~ /:/) && ($i !~ /^-/)) { + ++locationcount + if (!locationfield) { + # the first location field found on the line + locationfield = i + } + } + } + + # + # If location not found, do not modify. + # + # If there is more than one location, do not modify. Rationale: + # Options are applied to all locations. We ca not have "nullfs" + # for only some locations and "nfs" for others for a given + # map key (i.e., a line). The usual reason for multiple + # locations is for redundancy using replicated volumes on + # multiple hosts, so multiple hosts imply fstype=nfs (the + # FreeBSD default for automounter maps). + # + # Hypothetically there could be a map entry with multiple + # locations all with host parts matching "me". In that case, + # it would be safe to rewrite the locations and specify + # nullfs, but the code does not handle this case. + # + if (locationcount == 1) { + # + # We have a line with exactly one location field + # + # Assumption: location has no more than one colon (":") + # + n=split($locationfield,location,":") + if (is_self(location[1])) { + $locationfield = ":" location[2] + if (optionsfield) { + # append to existing options + $optionsfield = $optionsfield ",fstype=nullfs" + } else { + # sneak in ahead of location + $locationfield = "-fstype=nullfs " $locationfield + } + } + } + + print +} diff --git etc/defaults/bluetooth.device.conf etc/defaults/bluetooth.device.conf index 6e6a9811bccf..330548f97bb5 100644 --- etc/defaults/bluetooth.device.conf +++ etc/defaults/bluetooth.device.conf @@ -65,7 +65,7 @@ # NO or 0 do not scan for inquiry requests; # YES or 1 scan for inquiry requests (default). -# discoverable="YES" +# discoverable="NO" # The encryption_mode parameter controls if the device requires encryption # to the remote device at connection setup. At connection setup, only the diff --git etc/defaults/periodic.conf etc/defaults/periodic.conf index 789921d27bba..801733301318 100644 --- etc/defaults/periodic.conf +++ etc/defaults/periodic.conf @@ -181,9 +181,6 @@ weekly_locate_enable="YES" # Update locate weekly # 320.whatis weekly_whatis_enable="YES" # Update whatis weekly -# 330.catman -weekly_catman_enable="NO" # Preformat man pages - # 340.noid weekly_noid_enable="NO" # Find unowned files weekly_noid_dirs="/" # Look here diff --git etc/defaults/rc.conf etc/defaults/rc.conf index 06a9e6a6fd9a..d85bdacb5db9 100644 --- etc/defaults/rc.conf +++ etc/defaults/rc.conf @@ -53,6 +53,7 @@ tmpmfs_flags="-S" # Extra mdmfs options for the mfs /tmp varmfs="AUTO" # Set to YES to always create an mfs /var, NO to never varsize="32m" # Size of mfs /var if created varmfs_flags="-S" # Extra mount options for the mfs /var +mfs_type="auto" # "md", "tmpfs", "auto" to prefer tmpfs with md as fallback populate_var="AUTO" # Set to YES to always (re)populate /var, NO to never cleanvar_enable="YES" # Clean the /var directory local_startup="/usr/local/etc/rc.d" # startup script dirs. @@ -599,9 +600,8 @@ nscd_enable="NO" # Run the nsswitch caching daemon. chkprintcap_enable="NO" # Run chkprintcap(8) before running lpd. chkprintcap_flags="-d" # Create missing directories by default. dumpdev="AUTO" # Device to crashdump to (device name, AUTO, or NO). +dumpon_flags="" # Options to pass to dumpon(8), followed by dumpdev. dumpdir="/var/crash" # Directory where crash dumps are to be stored -dumppubkey="" # Public key for encrypted kernel crash dumps. - # See dumpon(8) for more details. savecore_enable="YES" # Extract core from dump devices if any savecore_flags="-m 10" # Used if dumpdev is enabled above, and present. # By default, only the 10 most recent kernel dumps diff --git etc/devd/usb.conf etc/devd/usb.conf index c9a072d104c5..528adaa592f9 100644 --- etc/devd/usb.conf +++ etc/devd/usb.conf @@ -805,6 +805,14 @@ nomatch 32 { action "kldload -n if_rtwn_usb"; }; +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x050d"; + match "product" "0x258a"; + action "kldload -n udbp"; +}; + nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; @@ -1389,6 +1397,14 @@ nomatch 32 { action "kldload -n if_cdce"; }; +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x067b"; + match "product" "0x27a1"; + action "kldload -n udbp"; +}; + nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; @@ -2769,7 +2785,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x0bda"; - match "product" "(0x8712|0x8712)"; + match "product" "(0x8712|0x8713)"; action "kldload -n if_rsu"; }; @@ -3889,7 +3905,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x12d1"; - match "product" "(0x1001|0x1003|0x1004|0x1401|0x1402|0x1403|0x1404|0x1405|0x1406|0x1407|0x1408|0x1409|0x140a|0x140b|0x140c|0x140d|0x140e|0x140f|0x1410|0x1411|0x1412|0x1413|0x1414|0x1415|0x1416|0x1417|0x1418|0x1419|0x141a|0x141b|0x141c|0x141d|0x141e|0x141f|0x1420|0x1421|0x1422|0x1423|0x1424|0x1425|0x1426|0x1427|0x1428|0x1429|0x142a|0x142b|0x142c|0x142d|0x142e|0x142f|0x1430|0x1431|0x1432|0x1433|0x1434|0x1435|0x1436|0x1437|0x1438|0x1439|0x143a|0x143b|0x143c|0x143d|0x143e|0x143f|0x1446|0x1464|0x1465|0x14ac|0x14c9|0x14cf|0x14d1|0x14fe|0x1505|0x1506|0x1520|0x1521|0x1526)"; + match "product" "(0x1001|0x1003|0x1004|0x1401|0x1402|0x1403|0x1404|0x1405|0x1406|0x1407|0x1408|0x1409|0x140a|0x140b|0x140c|0x140d|0x140e|0x140f|0x1410|0x1411|0x1412|0x1413|0x1414|0x1415|0x1416|0x1417|0x1418|0x1419|0x141a|0x141b|0x141c|0x141d|0x141e|0x141f|0x1420|0x1421|0x1422|0x1423|0x1424|0x1425|0x1426|0x1427|0x1428|0x1429|0x142a|0x142b|0x142c|0x142d|0x142e|0x142f|0x1430|0x1431|0x1432|0x1433|0x1434|0x1435|0x1436|0x1437|0x1438|0x1439|0x143a|0x143b|0x143c|0x143d|0x143e|0x143f|0x1446|0x1464|0x1465|0x14ac|0x14c4|0x14c9|0x14ca|0x14cf|0x14d1|0x14fe|0x1505|0x1506|0x1520|0x1521|0x1526)"; action "kldload -n u3g"; }; @@ -4733,6 +4749,14 @@ nomatch 32 { action "kldload -n if_axe"; }; +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x17ef"; + match "product" "0x7205"; + action "kldload -n if_ure"; +}; + nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; @@ -5089,7 +5113,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x2001"; - match "product" "(0x7d02|0x7e12|0xa707|0xa805)"; + match "product" "(0x7d02|0x7e12|0x7e35|0xa707|0xa805|0xab00)"; action "kldload -n u3g"; }; @@ -5297,7 +5321,7 @@ nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; match "vendor" "0x2357"; - match "product" "(0x0101|0x0108|0x0109)"; + match "product" "(0x0101|0x0108|0x0109|0x010d|0x010e)"; action "kldload -n if_rtwn_usb"; }; @@ -5317,6 +5341,14 @@ nomatch 32 { action "kldload -n uplcom"; }; +nomatch 32 { + match "bus" "uhub[0-9]+"; + match "mode" "host"; + match "vendor" "0x27b8"; + match "product" "0x01ed"; + action "kldload -n uled"; +}; + nomatch 32 { match "bus" "uhub[0-9]+"; match "mode" "host"; @@ -5889,5 +5921,5 @@ nomatch 32 { action "kldload -n umass"; }; -# 2751 USB entries processed +# 2760 USB entries processed diff --git etc/devd/zfs.conf etc/devd/zfs.conf index a9061ccdacd4..8a719f89e6ec 100644 --- etc/devd/zfs.conf +++ etc/devd/zfs.conf @@ -5,73 +5,73 @@ notify 10 { match "system" "ZFS"; match "type" "fs.zfs.checksum"; - action "logger -p kern.warn -t ZFS 'checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'"; + action "logger -p local7.warn -t ZFS 'checksum mismatch, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.io"; - action "logger -p kern.warn -t ZFS 'vdev I/O failure, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size error=$zio_err'"; + action "logger -p local7.warn -t ZFS 'vdev I/O failure, zpool=$pool path=$vdev_path offset=$zio_offset size=$zio_size error=$zio_err'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.data"; - action "logger -p kern.warn -t ZFS 'pool I/O failure, zpool=$pool error=$zio_err'"; + action "logger -p local7.warn -t ZFS 'pool I/O failure, zpool=$pool error=$zio_err'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.zpool"; - action "logger -p kern.err -t ZFS 'failed to load zpool $pool'"; + action "logger -p local7.err -t ZFS 'failed to load zpool $pool'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.vdev\..*"; - action "logger -p kern.err -t ZFS 'vdev problem, zpool=$pool path=$vdev_path type=$type'"; + action "logger -p local7.err -t ZFS 'vdev problem, zpool=$pool path=$vdev_path type=$type'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.io_failure"; - action "logger -p kern.alert -t ZFS 'catastrophic pool I/O failure, zpool=$pool'"; + action "logger -p local7.alert -t ZFS 'catastrophic pool I/O failure, zpool=$pool'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.probe_failure"; - action "logger -p kern.err -t ZFS 'vdev probe failure, zpool=$pool path=$vdev_path'"; + action "logger -p local7.err -t ZFS 'vdev probe failure, zpool=$pool path=$vdev_path'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.log_replay"; - action "logger -p kern.err -t ZFS 'pool log replay failure, zpool=$pool'"; + action "logger -p local7.err -t ZFS 'pool log replay failure, zpool=$pool'"; }; notify 10 { match "system" "ZFS"; match "type" "fs.zfs.config_cache_write"; - action "logger -p kern.warn -t ZFS 'failed to write zpool.cache, zpool=$pool'"; + action "logger -p local7.warn -t ZFS 'failed to write zpool.cache, zpool=$pool'"; }; notify 10 { match "system" "ZFS"; match "type" "resource.fs.zfs.removed"; - action "logger -p kern.notice -t ZFS 'vdev is removed, pool_guid=$pool_guid vdev_guid=$vdev_guid'"; + action "logger -p local7.notice -t ZFS 'vdev is removed, pool_guid=$pool_guid vdev_guid=$vdev_guid'"; }; notify 10 { match "system" "ZFS"; match "type" "resource.fs.zfs.autoreplace"; - action "logger -p kern.info -t ZFS 'autoreplace is configured for vdev, pool_guid=$pool_guid vdev_guid=$vdev_guid'"; + action "logger -p local7.info -t ZFS 'autoreplace is configured for vdev, pool_guid=$pool_guid vdev_guid=$vdev_guid'"; }; notify 10 { match "system" "ZFS"; match "type" "resource.fs.zfs.statechange"; - action "logger -p kern.notice -t ZFS 'vdev state changed, pool_guid=$pool_guid vdev_guid=$vdev_guid'"; + action "logger -p local7.notice -t ZFS 'vdev state changed, pool_guid=$pool_guid vdev_guid=$vdev_guid'"; }; diff --git etc/inetd.conf etc/inetd.conf index 7f70662593b0..65a3507a6dc2 100644 --- etc/inetd.conf +++ etc/inetd.conf @@ -12,10 +12,10 @@ #ssh stream tcp6 nowait root /usr/sbin/sshd sshd -i -6 #telnet stream tcp nowait root /usr/libexec/telnetd telnetd #telnet stream tcp6 nowait root /usr/libexec/telnetd telnetd -#shell stream tcp nowait root /usr/libexec/rshd rshd -#shell stream tcp6 nowait root /usr/libexec/rshd rshd -#login stream tcp nowait root /usr/libexec/rlogind rlogind -#login stream tcp6 nowait root /usr/libexec/rlogind rlogind +#shell stream tcp nowait root /usr/local/sbin/rshd rshd +#shell stream tcp6 nowait root /usr/local/sbin/rshd rshd +#login stream tcp nowait root /usr/local/sbin/rlogind rlogind +#login stream tcp6 nowait root /usr/local/sbin/rlogind rlogind #finger stream tcp nowait/3/10 nobody /usr/libexec/fingerd fingerd -k -s #finger stream tcp6 nowait/3/10 nobody /usr/libexec/fingerd fingerd -k -s # diff --git etc/man.alias etc/man.alias deleted file mode 100644 index 0268403efffc..000000000000 --- etc/man.alias +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ - -en.ISO8859-15 en.ISO8859-1 - diff --git etc/mtree/BSD.tests.dist etc/mtree/BSD.tests.dist index 632e4d70e909..2b7d9ce10e1d 100644 --- etc/mtree/BSD.tests.dist +++ etc/mtree/BSD.tests.dist @@ -8,6 +8,8 @@ bin cat .. + chflags + .. chmod .. date @@ -22,6 +24,8 @@ .. ls .. + mkdir + .. mv .. pax @@ -30,6 +34,8 @@ .. pwait .. + rmdir + .. sh builtins .. @@ -470,6 +476,10 @@ .. netinet .. + netpfil + pf + .. + .. opencrypto .. pjdfstest diff --git etc/mtree/BSD.usr.dist etc/mtree/BSD.usr.dist index 714fa1cb02f2..3f1485edf53c 100644 --- etc/mtree/BSD.usr.dist +++ etc/mtree/BSD.usr.dist @@ -239,6 +239,8 @@ .. find_interface .. + hardenedbsd + .. hast .. hostapd @@ -805,158 +807,6 @@ .. .. man -/set uname=man - cat1 - .. - cat2 - .. - cat3 - .. - cat4 - amd64 - .. - arm - .. - i386 - .. - powerpc - .. - sparc64 - .. - .. - cat5 - .. - cat6 - .. - cat7 - .. - cat8 - amd64 - .. - i386 - .. - powerpc - .. - sparc64 - .. - .. - cat9 - .. - en.ISO8859-1 uname=root - cat1 - .. - cat2 - .. - cat3 - .. - cat4 - amd64 - .. - arm - .. - i386 - .. - powerpc - .. - sparc64 - .. - .. - cat5 - .. - cat6 - .. - cat7 - .. - cat8 - amd64 - .. - i386 - .. - powerpc - .. - sparc64 - .. - .. - cat9 - .. - .. - en.UTF-8 uname=root - cat1 - .. - cat2 - .. - cat3 - .. - cat4 - amd64 - .. - arm - .. - i386 - .. - powerpc - .. - sparc64 - .. - .. - cat5 - .. - cat6 - .. - cat7 - .. - cat8 - amd64 - .. - i386 - .. - powerpc - .. - sparc64 - .. - .. - cat9 - .. - .. - ja uname=root - cat1 - .. - cat2 - .. - cat3 - .. - cat4 - .. - cat5 - .. - cat6 - .. - cat7 - .. - cat8 - .. - cat9 - .. -/set uname=root - man1 - .. - man2 - .. - man3 - .. - man4 - .. - man5 - .. - man6 - .. - man7 - .. - man8 - .. - man9 - .. - .. man1 .. man2 @@ -1296,18 +1146,6 @@ .. openssl man -/set uname=man - cat1 - .. - cat3 - .. - en.ISO8859-1 uname=root - cat1 - .. - cat3 - .. - .. -/set uname=root man1 .. man3 diff --git etc/network.subr etc/network.subr index 3ae66c667cd5..daa7442088aa 100644 --- etc/network.subr +++ etc/network.subr @@ -122,7 +122,7 @@ ifn_vnet0() # ifconfig_up() { - local _cfg _ipv6_opts ifconfig_args + local _cfg _ifconfig_descr _ipv6_opts ifconfig_args _cfg=1 # Make sure lo0 always comes up. @@ -214,6 +214,11 @@ ifconfig_up() ifalias $1 link alias ifalias $1 ether alias + _ifconfig_descr=`get_if_var $1 ifconfig_IF_descr` + if [ -n "${_ifconfig_descr}" ]; then + ${IFCONFIG_CMD} $1 description "${_ifconfig_descr}" + fi + if wpaif $1; then /etc/rc.d/wpa_supplicant start $1 _cfg=0 # XXX: not sure this should count diff --git etc/pam.d/Makefile etc/pam.d/Makefile index 51a2195fe59d..195274fae541 100644 --- etc/pam.d/Makefile +++ etc/pam.d/Makefile @@ -35,14 +35,6 @@ FTPMODE= ${FILESMODE} LINKS= ${FILESDIR}/ftpd ${FILESDIR}/ftp .endif -.if ${MK_RCMDS} != "no" -FILESGROUPS+= RCMDS -RCMDS+= rsh -RCMDSPACKAGE+= rcmds -RCMDSDIR= ${FILESDIR} -RCMDSMODE= ${FILESMODE} -.endif - .if ${MK_TELNET} != "no" FILESGROUPS+= TELNET TELNET+= telnetd diff --git etc/pam.d/rsh etc/pam.d/rsh deleted file mode 100644 index 9e562e0786d4..000000000000 --- etc/pam.d/rsh +++ /dev/null @@ -1,18 +0,0 @@ -# -# $FreeBSD$ -# -# PAM configuration for the "rsh" service -# - -# auth -auth required pam_rhosts.so no_warn - -# account -account required pam_nologin.so -account required pam_unix.so - -# session -session required pam_permit.so - -# password -password required pam_deny.so diff --git etc/periodic/daily/480.leapfile-ntpd etc/periodic/daily/480.leapfile-ntpd index 6b2a1f33f1b7..a693986e0dd1 100755 --- etc/periodic/daily/480.leapfile-ntpd +++ etc/periodic/daily/480.leapfile-ntpd @@ -13,9 +13,11 @@ fi case "$daily_ntpd_leapfile_enable" in [Yy][Ee][Ss]) - anticongestion - service ntpd onefetch - ;; + if service ntpd oneneedfetch; then + anticongestion + service ntpd onefetch + fi + ;; esac exit $rc diff --git etc/periodic/security/100.chksetuid etc/periodic/security/100.chksetuid index da8d29d985ea..670ae9792021 100755 --- etc/periodic/security/100.chksetuid +++ etc/periodic/security/100.chksetuid @@ -45,7 +45,13 @@ if check_yesno_period security_status_chksetuid_enable then echo "" echo 'Checking setuid files and devices:' - MP=`mount -t ufs,zfs | awk '$0 !~ /no(suid|exec)/ { print $3 }'` + IFS=$'\n' # Don't split mount points with spaces or tabs + MP=`mount -t ufs,zfs | awk ' + $0 !~ /no(suid|exec)/ { + sub(/^.* on \//, "/"); + sub(/ \(.*\)/, ""); + print $0 + }'` find -sx $MP /dev/null \( ! -fstype local \) -prune -o -type f \ \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \ \( -perm -u+s -or -perm -g+s \) -exec ls -liTd \{\} \+ | diff --git etc/periodic/security/110.neggrpperm etc/periodic/security/110.neggrpperm index bd94015951bd..55974eae6345 100755 --- etc/periodic/security/110.neggrpperm +++ etc/periodic/security/110.neggrpperm @@ -43,7 +43,13 @@ if check_yesno_period security_status_neggrpperm_enable then echo "" echo 'Checking negative group permissions:' - MP=`mount -t ufs,zfs | awk '$0 !~ /no(suid|exec)/ { print $3 }'` + IFS=$'\n' # Don't split mount points with spaces or tabs + MP=`mount -t ufs,zfs | awk ' + $0 !~ /no(suid|exec)/ { + sub(/^.* on \//, "/"); + sub(/ \(.*\)/, ""); + print $0 + }'` n=$(find -sx $MP /dev/null \( ! -fstype local \) -prune -o -type f \ \( \( ! -perm +010 -and -perm +001 \) -or \ \( ! -perm +020 -and -perm +002 \) -or \ diff --git etc/periodic/security/security.functions etc/periodic/security/security.functions index c2c757a3789d..00a89075dbfd 100644 --- etc/periodic/security/security.functions +++ etc/periodic/security/security.functions @@ -48,6 +48,7 @@ rc=0 # LABEL is the base name of the ${LOG}/${label}.{today,yesterday} files. check_diff() { + unset IFS rc=0 if [ "$1" = "new_only" ]; then shift diff --git etc/periodic/weekly/330.catman etc/periodic/weekly/330.catman deleted file mode 100755 index 1ba2f7e9a973..000000000000 --- etc/periodic/weekly/330.catman +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh - -# -# $FreeBSD$ -# - -# If there is a global system configuration file, suck it in. -# -if [ -r /etc/defaults/periodic.conf ] -then - . /etc/defaults/periodic.conf - source_periodic_confs -fi - -case "$weekly_catman_enable" in - [Yy][Ee][Ss]) - if [ ! -d /usr/share/man/cat1 ] - then - echo '$weekly_catman_enable is set but /usr/share/man/cat1' \ - "doesn't exist" - rc=2 - else - echo "" - echo "Reformatting manual pages:" - - MANPATH=`/usr/bin/manpath -q` - if [ $? = 0 ] - then - if [ -z "${MANPATH}" ] - then - echo "manpath failed to find any manpath directories" - rc=3 - else - man_locales=`/usr/bin/manpath -qL` - rc=0 - - # Preformat original, non-localized manpages - echo /usr/libexec/catman.local -r "$MANPATH" | - su -fm man || rc=3 - - # Preformat localized manpages. - if [ -n "$man_locales" ] - then - for i in $man_locales - do - echo /usr/libexec/catman.local -Lr \ - "$MANPATH" | LC_ALL=$i su -fm man || rc=3 - done - fi - fi - else - rc=3 - fi - fi;; - - *) rc=0;; -esac - -exit $rc diff --git etc/periodic/weekly/Makefile etc/periodic/weekly/Makefile index 865ef5340def..c32420a2be65 100644 --- etc/periodic/weekly/Makefile +++ etc/periodic/weekly/Makefile @@ -13,7 +13,7 @@ FILES+= 310.locate .endif .if ${MK_MAN_UTILS} != "no" -FILES+= 320.whatis 330.catman +FILES+= 320.whatis .endif .include <bsd.prog.mk> diff --git etc/printcap etc/printcap index 5319a0ec2b93..b1f83b344c8f 100644 --- etc/printcap +++ etc/printcap @@ -22,7 +22,7 @@ # # Do also refer to the "printing" section of the handbook. # -# http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/printing.html +# https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/printing.html # # A local copy can be found under # diff --git etc/rc.d/automount etc/rc.d/automount index 7f43b4531125..e0789cb8d050 100644 --- etc/rc.d/automount +++ etc/rc.d/automount @@ -5,6 +5,7 @@ # PROVIDE: automount # REQUIRE: nfsclient automountd +# BEFORE: DAEMON # KEYWORD: nojail shutdown . /etc/rc.subr diff --git etc/rc.d/automountd etc/rc.d/automountd index c772494633f1..f9d8db8b2f37 100644 --- etc/rc.d/automountd +++ etc/rc.d/automountd @@ -4,7 +4,8 @@ # # PROVIDE: automountd -# REQUIRE: DAEMON +# REQUIRE: rpcbind ypset nfsclient FILESYSTEMS ldconfig +# BEFORE: DAEMON # KEYWORD: nojail . /etc/rc.subr diff --git etc/rc.d/autounmountd etc/rc.d/autounmountd index aa24d516ffff..2acbe09139ca 100644 --- etc/rc.d/autounmountd +++ etc/rc.d/autounmountd @@ -4,7 +4,8 @@ # # PROVIDE: autounmountd -# REQUIRE: DAEMON +# REQUIRE: FILESYSTEMS +# BEFORE: DAEMON # KEYWORD: nojail . /etc/rc.subr diff --git etc/rc.d/bluetooth etc/rc.d/bluetooth index 5f5a8343408c..ac10719861ae 100755 --- etc/rc.d/bluetooth +++ etc/rc.d/bluetooth @@ -287,7 +287,7 @@ bluetooth_start() bluetooth_device_authentication_enable="0" bluetooth_device_class="ff:01:0c" bluetooth_device_connectable="1" - bluetooth_device_discoverable="1" + bluetooth_device_discoverable="0" bluetooth_device_encryption_mode="0" bluetooth_device_hci_debug_level="3" bluetooth_device_l2cap_debug_level="3" diff --git etc/rc.d/dumpon etc/rc.d/dumpon index 87bdd3eb0b39..dddbf2af01cc 100755 --- etc/rc.d/dumpon +++ etc/rc.d/dumpon @@ -16,11 +16,14 @@ stop_cmd="dumpon_stop" dumpon_try() { + local flags + + flags=${dumpon_flags} if [ -n "${dumppubkey}" ]; then - /sbin/dumpon -k "${dumppubkey}" "${1}" - else - /sbin/dumpon "${1}" + warn "The dumppubkey variable is deprecated. Use dumpon_flags." + flags="${flags} -k ${dumppubkey}" fi + /sbin/dumpon ${flags} "${1}" if [ $? -eq 0 ]; then # Make a symlink in devfs for savecore ln -fs "${1}" /dev/dumpdev diff --git etc/rc.d/ntpd etc/rc.d/ntpd index a0cb54362541..6021f89b0c2d 100755 --- etc/rc.d/ntpd +++ etc/rc.d/ntpd @@ -15,8 +15,9 @@ desc="Network Time Protocol daemon" rcvar="ntpd_enable" command="/usr/sbin/${name}" pidfile="/var/run/${name}.pid" -extra_commands="fetch" +extra_commands="fetch needfetch" fetch_cmd="ntpd_fetch_leapfile" +needfetch_cmd="ntpd_needfetch_leapfile" start_precmd="ntpd_precmd" load_rc_config $name @@ -90,7 +91,7 @@ ntpd_init_leapfile() { fi } -ntpd_fetch_leapfile() { +ntpd_needfetch_leapfile() { local ntp_tmp_leapfile rc verbose if checkyesno ntp_leapfile_fetch_verbose; then @@ -122,6 +123,21 @@ ntpd_fetch_leapfile() { ntp_leap_fetch_date=$((ntp_leap_expiry-ntp_leapfile_expiry_seconds)) if [ $(current_ntp_ts) -ge $ntp_leap_fetch_date ]; then $verbose Within ntp leapfile expiry limit, initiating fetch + # Return code 0: ntp leapfile fetch needed + return 0 + fi + # Return code 1: ntp leapfile fetch not needed + return 1 +} + +ntpd_fetch_leapfile() { + if checkyesno ntp_leapfile_fetch_verbose; then + verbose=echo + else + verbose=: + fi + + if ntpd_needfetch_leapfile ; then for url in $ntp_leapfile_sources ; do $verbose fetching $url fetch $ntp_leapfile_fetch_opts -o $ntp_tmp_leapfile $url && break diff --git etc/rc.initdiskless etc/rc.initdiskless index ed6e2d217577..3e9c2c700990 100644 --- etc/rc.initdiskless +++ etc/rc.initdiskless @@ -195,10 +195,11 @@ handle_remount() { # $1 = mount point to_umount="$b ${to_umount}" } -# Create a generic memory disk (using tmpfs) -# +# Create a generic memory disk. +# The 'auto' parameter will attempt to use tmpfs(5), falls back to md(4). +# $1 is size in 512-byte sectors, $2 is the mount point. mount_md() { - mount -t tmpfs -o size=$(($1 * 512)) tmpfs $2 + /sbin/mdmfs -s $1 auto $2 } # Create the memory filesystem if it has not already been created diff --git etc/rc.subr etc/rc.subr index 3c66ee9deedb..caafd88b3f0b 100644 --- etc/rc.subr +++ etc/rc.subr @@ -930,9 +930,7 @@ run_rc_command() else _pidcmd='rc_pid=$(check_process '"$_procname $command_interpreter"')' fi - if [ -n "$_pidcmd" ]; then - _keywords="${_keywords} status poll" - fi + _keywords="${_keywords} status poll" fi if [ -z "$rc_arg" ]; then @@ -1790,7 +1788,7 @@ mount_md() if [ -n "$3" ]; then flags="$3" fi - /sbin/mdmfs $flags -s $1 md $2 + /sbin/mdmfs $flags -s $1 ${mfs_type} $2 } # Code common to scripts that need to load a kernel module diff --git gnu/lib/libdialog/Makefile.depend gnu/lib/libdialog/Makefile.depend index 8b0f9a72f3a9..a66ab8d1b411 100644 --- gnu/lib/libdialog/Makefile.depend +++ gnu/lib/libdialog/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git gnu/lib/libgomp/Makefile.depend gnu/lib/libgomp/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- gnu/lib/libgomp/Makefile.depend +++ gnu/lib/libgomp/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git gnu/lib/libregex/Makefile.depend gnu/lib/libregex/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- gnu/lib/libregex/Makefile.depend +++ gnu/lib/libregex/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git gnu/lib/libssp/Makefile.depend gnu/lib/libssp/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- gnu/lib/libssp/Makefile.depend +++ gnu/lib/libssp/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git gnu/lib/libstdc++/Makefile.depend gnu/lib/libstdc++/Makefile.depend index c9f9d52f6e26..905e67cc66c9 100644 --- gnu/lib/libstdc++/Makefile.depend +++ gnu/lib/libstdc++/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git gnu/lib/libsupc++/Makefile.depend gnu/lib/libsupc++/Makefile.depend index 7ad7a324ba1a..f0b281683f29 100644 --- gnu/lib/libsupc++/Makefile.depend +++ gnu/lib/libsupc++/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/lib/libstdc++ \ include \ include/xlocale \ diff --git gnu/usr.bin/binutils/Makefile.inc0 gnu/usr.bin/binutils/Makefile.inc0 index cf15467fe98f..c2c96e7bb09c 100644 --- gnu/usr.bin/binutils/Makefile.inc0 +++ gnu/usr.bin/binutils/Makefile.inc0 @@ -23,12 +23,12 @@ TARGET_TUPLE?= ${BINUTILS_ARCH}-${TARGET_VENDOR}-${TARGET_OS} TARGET_BIG_ENDIAN=t .endif -# RELTOP is the relative path to this point in the source or object +# GNURELTOP is the relative path to this point in the source or object # tree, from any subdirectory of same. It gets extra "../" prefixes # added to it as we descend into subdirectories. -RELTOP:= .. +GNURELTOP:= .. -RELSRC= ${RELTOP}/../../../contrib/binutils +RELSRC= ${GNURELTOP}/../../../contrib/binutils SRCDIR= ${.CURDIR}/${RELSRC} .if ${TARGET_CPUARCH} == "arm" || ${TARGET_CPUARCH} == "i386" || \ @@ -41,8 +41,8 @@ CFLAGS+= -DBFD_DEFAULT_TARGET_SIZE=64 CFLAGS+= -I. CFLAGS+= -I${.CURDIR} -CFLAGS+= -I${.CURDIR}/${RELTOP}/libbfd -CFLAGS+= -I${.OBJDIR}/${RELTOP}/libbfd +CFLAGS+= -I${.CURDIR}/${GNURELTOP}/libbfd +CFLAGS+= -I${.OBJDIR}/${GNURELTOP}/libbfd CFLAGS+= -I${SRCDIR}/include ARCHS= ${TARGET_CPUARCH} diff --git gnu/usr.bin/binutils/as/Makefile gnu/usr.bin/binutils/as/Makefile index f20b56a38121..509069994e69 100644 --- gnu/usr.bin/binutils/as/Makefile +++ gnu/usr.bin/binutils/as/Makefile @@ -46,9 +46,12 @@ SRCS+= app.c \ # DEO: why not used? #SRCS+= itbl-ops.c -.if ${TARGET_ARCH} == "armv6" || ${TARGET_ARCH} == "armv6eb" +.if ${TARGET_ARCH:Marmv6*} != "" CFLAGS+= -DCPU_DEFAULT=ARM_ARCH_V6K .endif +.if ${TARGET_ARCH:Marmv7*} != "" +CFLAGS+= -DCPU_DEFAULT=ARM_ARCH_V7A +.endif .if ${TARGET_CPUARCH} == "mips" SRCS+= itbl-ops.c itbl-parse.y itbl-lex.l @@ -92,9 +95,9 @@ CFLAGS+= -I${.CURDIR} -I${.CURDIR}/${TARGET_CPUARCH}-freebsd NO_SHARED?= yes .endif -DPADD= ${RELTOP}/libbfd/libbfd.a -DPADD+= ${RELTOP}/libiberty/libiberty.a -DPADD+= ${RELTOP}/libopcodes/libopcodes.a +DPADD= ${GNURELTOP}/libbfd/libbfd.a +DPADD+= ${GNURELTOP}/libiberty/libiberty.a +DPADD+= ${GNURELTOP}/libopcodes/libopcodes.a LDADD= ${DPADD} NOCFI= yes diff --git gnu/usr.bin/binutils/as/Makefile.depend gnu/usr.bin/binutils/as/Makefile.depend index e48f45099eb3..1480a25f260e 100644 --- gnu/usr.bin/binutils/as/Makefile.depend +++ gnu/usr.bin/binutils/as/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/usr.bin/binutils/libbfd \ gnu/usr.bin/binutils/libiberty \ gnu/usr.bin/binutils/libopcodes \ diff --git gnu/usr.bin/binutils/ld/Makefile gnu/usr.bin/binutils/ld/Makefile index c5b5d313485c..fb8097ac3427 100644 --- gnu/usr.bin/binutils/ld/Makefile +++ gnu/usr.bin/binutils/ld/Makefile @@ -41,8 +41,8 @@ CFLAGS+= -I${SRCDIR}/ld -I${SRCDIR}/bfd .if ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= yes .endif -DPADD= ${RELTOP}/libbfd/libbfd.a -DPADD+= ${RELTOP}/libiberty/libiberty.a +DPADD= ${GNURELTOP}/libbfd/libbfd.a +DPADD+= ${GNURELTOP}/libiberty/libiberty.a LDADD= ${DPADD} CLEANDIRS+= ldscripts CLEANFILES+= ldemul-list.h stringify.sed diff --git gnu/usr.bin/binutils/ld/Makefile.depend gnu/usr.bin/binutils/ld/Makefile.depend index 995eda769c92..ace486b47b12 100644 --- gnu/usr.bin/binutils/ld/Makefile.depend +++ gnu/usr.bin/binutils/ld/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/usr.bin/binutils/libbfd \ gnu/usr.bin/binutils/libiberty \ include \ diff --git gnu/usr.bin/binutils/libbfd/Makefile.amd64 gnu/usr.bin/binutils/libbfd/Makefile.amd64 index 31e6e3e8bbda..31ad0d9302be 100644 --- gnu/usr.bin/binutils/libbfd/Makefile.amd64 +++ gnu/usr.bin/binutils/libbfd/Makefile.amd64 @@ -9,7 +9,6 @@ DEFAULT_VECTOR= bfd_elf64_x86_64_freebsd_vec SRCS+= elf64-x86-64.c \ efi-app-x86_64.c \ - efi-app-ia32.c \ elf64.c \ elf64-gen.c \ elf64-target.h \ diff --git gnu/usr.bin/binutils/objcopy/Makefile gnu/usr.bin/binutils/objcopy/Makefile index 66d99f4e7538..992649bc2864 100644 --- gnu/usr.bin/binutils/objcopy/Makefile +++ gnu/usr.bin/binutils/objcopy/Makefile @@ -7,11 +7,11 @@ PROG= objcopy SRCS= objcopy.c not-strip.c CFLAGS+= -D_GNU_SOURCE -CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils +CFLAGS+= -I${.CURDIR}/${GNURELTOP}/libbinutils CFLAGS+= -I${SRCDIR}/binutils -I${SRCDIR}/bfd -DPADD= ${RELTOP}/libbinutils/libbinutils.a -DPADD+= ${RELTOP}/libbfd/libbfd.a -DPADD+= ${RELTOP}/libiberty/libiberty.a +DPADD= ${GNURELTOP}/libbinutils/libbinutils.a +DPADD+= ${GNURELTOP}/libbfd/libbfd.a +DPADD+= ${GNURELTOP}/libiberty/libiberty.a LDADD= ${DPADD} .include <bsd.prog.mk> diff --git gnu/usr.bin/binutils/objcopy/Makefile.depend gnu/usr.bin/binutils/objcopy/Makefile.depend index b58c9bda263a..c27a80a48005 100644 --- gnu/usr.bin/binutils/objcopy/Makefile.depend +++ gnu/usr.bin/binutils/objcopy/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/usr.bin/binutils/libbfd \ gnu/usr.bin/binutils/libbinutils \ gnu/usr.bin/binutils/libiberty \ diff --git gnu/usr.bin/binutils/objdump/Makefile gnu/usr.bin/binutils/objdump/Makefile index 1a0d04625d1a..4663ccc44181 100644 --- gnu/usr.bin/binutils/objdump/Makefile +++ gnu/usr.bin/binutils/objdump/Makefile @@ -1,19 +1,25 @@ # $FreeBSD$ .include "../Makefile.inc0" +.include <src.opts.mk> .PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc -PROG= objdump +PROG= gnu-objdump SRCS= objdump.c prdbg.c CFLAGS+= -D_GNU_SOURCE -CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils +CFLAGS+= -I${.CURDIR}/${GNURELTOP}/libbinutils CFLAGS+= -I${SRCDIR}/binutils CFLAGS+= -DBFD_VERSION_STRING=\"${VERSION}\" -DPADD= ${RELTOP}/libbinutils/libbinutils.a -DPADD+= ${RELTOP}/libopcodes/libopcodes.a -DPADD+= ${RELTOP}/libbfd/libbfd.a -DPADD+= ${RELTOP}/libiberty/libiberty.a +DPADD= ${GNURELTOP}/libbinutils/libbinutils.a +DPADD+= ${GNURELTOP}/libopcodes/libopcodes.a +DPADD+= ${GNURELTOP}/libbfd/libbfd.a +DPADD+= ${GNURELTOP}/libiberty/libiberty.a LDADD= ${DPADD} +MAN= objdump.1 + +.if ${MK_LLVM_OBJDUMP_IS_OBJDUMP} != "yes" +SYMLINKS+= ${BINDIR}/gnu-objdump ${BINDIR}/objdump +.endif .include <bsd.prog.mk> diff --git gnu/usr.bin/binutils/objdump/Makefile.depend gnu/usr.bin/binutils/objdump/Makefile.depend index f4eee5f3ab0f..38831ab06c3e 100644 --- gnu/usr.bin/binutils/objdump/Makefile.depend +++ gnu/usr.bin/binutils/objdump/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/usr.bin/binutils/libbfd \ gnu/usr.bin/binutils/libbinutils \ gnu/usr.bin/binutils/libiberty \ diff --git gnu/usr.bin/cc/Makefile.inc gnu/usr.bin/cc/Makefile.inc index b3044df7f68c..7e196965ddbf 100644 --- gnu/usr.bin/cc/Makefile.inc +++ gnu/usr.bin/cc/Makefile.inc @@ -34,9 +34,12 @@ CFLAGS+= -DTARGET_ARM_EABI .if ${TARGET_ARCH:Marm*eb} != "" CFLAGS += -DTARGET_ENDIAN_DEFAULT=MASK_BIG_END .endif -.if ${TARGET_ARCH} == "armv6" || ${TARGET_ARCH} == "armv6eb" +.if ${TARGET_ARCH:Marmv6*} != "" CFLAGS += -DFREEBSD_ARCH_armv6 .endif +.if ${TARGET_ARCH:Marmv7*} != "" +CFLAGS += -DFREEBSD_ARCH_armv7 +.endif .if ${TARGET_CPUARCH} == "mips" .if ${TARGET_ARCH:Mmips*el*} != "" diff --git gnu/usr.bin/cc/c++/Makefile.depend gnu/usr.bin/cc/c++/Makefile.depend index 012ac3a73424..2bea3c0fa889 100644 --- gnu/usr.bin/cc/c++/Makefile.depend +++ gnu/usr.bin/cc/c++/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/usr.bin/cc/cc_tools \ gnu/usr.bin/cc/libcpp \ gnu/usr.bin/cc/libiberty \ diff --git gnu/usr.bin/cc/cc/Makefile.depend gnu/usr.bin/cc/cc/Makefile.depend index 012ac3a73424..2bea3c0fa889 100644 --- gnu/usr.bin/cc/cc/Makefile.depend +++ gnu/usr.bin/cc/cc/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/usr.bin/cc/cc_tools \ gnu/usr.bin/cc/libcpp \ gnu/usr.bin/cc/libiberty \ diff --git gnu/usr.bin/cc/cc1/Makefile.depend gnu/usr.bin/cc/cc1/Makefile.depend index 05af396011e7..54acaaf4b5b0 100644 --- gnu/usr.bin/cc/cc1/Makefile.depend +++ gnu/usr.bin/cc/cc1/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/usr.bin/cc/cc_int \ gnu/usr.bin/cc/cc_tools \ gnu/usr.bin/cc/libcpp \ diff --git gnu/usr.bin/cc/cc1plus/Makefile.depend gnu/usr.bin/cc/cc1plus/Makefile.depend index ab413839c195..7615829e9d1c 100644 --- gnu/usr.bin/cc/cc1plus/Makefile.depend +++ gnu/usr.bin/cc/cc1plus/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/usr.bin/cc/cc_int \ gnu/usr.bin/cc/cc_tools \ gnu/usr.bin/cc/libcpp \ diff --git gnu/usr.bin/cc/cc_tools/Makefile gnu/usr.bin/cc/cc_tools/Makefile index 47870357f269..adc101b299f3 100644 --- gnu/usr.bin/cc/cc_tools/Makefile +++ gnu/usr.bin/cc/cc_tools/Makefile @@ -391,6 +391,7 @@ GNTOOLS+= genattr genattrtab genautomata gencodes gencheck genchecksum \ ${GNTOOLS:C,$,.o,} ${GNTOOLS}: ${BUILD_TOOLS_META} all: ${GNTOOLS} ${GENSRCS} ${GENONLY} +build-tools: all beforedepend: ${GENONLY} # diff --git gnu/usr.bin/cc/cc_tools/Makefile.depend gnu/usr.bin/cc/cc_tools/Makefile.depend index cb804542add1..7e06312d1eb7 100644 --- gnu/usr.bin/cc/cc_tools/Makefile.depend +++ gnu/usr.bin/cc/cc_tools/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git gnu/usr.bin/cc/cpp/Makefile.depend gnu/usr.bin/cc/cpp/Makefile.depend index 012ac3a73424..2bea3c0fa889 100644 --- gnu/usr.bin/cc/cpp/Makefile.depend +++ gnu/usr.bin/cc/cpp/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/usr.bin/cc/cc_tools \ gnu/usr.bin/cc/libcpp \ gnu/usr.bin/cc/libiberty \ diff --git gnu/usr.bin/cc/gcov/Makefile.depend gnu/usr.bin/cc/gcov/Makefile.depend index 1260907b2d68..de48a531065e 100644 --- gnu/usr.bin/cc/gcov/Makefile.depend +++ gnu/usr.bin/cc/gcov/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/usr.bin/cc/cc_tools \ gnu/usr.bin/cc/libiberty \ include \ diff --git gnu/usr.bin/dialog/Makefile.depend gnu/usr.bin/dialog/Makefile.depend index 5e97e258b259..87a30b89d0f0 100644 --- gnu/usr.bin/dialog/Makefile.depend +++ gnu/usr.bin/dialog/Makefile.depend @@ -4,7 +4,6 @@ DIRDEPS = \ gnu/lib/csu \ gnu/lib/libdialog \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git gnu/usr.bin/diff3/Makefile.depend gnu/usr.bin/diff3/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- gnu/usr.bin/diff3/Makefile.depend +++ gnu/usr.bin/diff3/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git gnu/usr.bin/dtc/Makefile.depend gnu/usr.bin/dtc/Makefile.depend index ca0b2f9610f7..d084433f911c 100644 --- gnu/usr.bin/dtc/Makefile.depend +++ gnu/usr.bin/dtc/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git gnu/usr.bin/gdb/gdb/Makefile.depend gnu/usr.bin/gdb/gdb/Makefile.depend index 10de637399a2..ee6269e741a7 100644 --- gnu/usr.bin/gdb/gdb/Makefile.depend +++ gnu/usr.bin/gdb/gdb/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/lib/libreadline/readline \ gnu/lib/libregex \ gnu/usr.bin/binutils/libbfd \ diff --git gnu/usr.bin/gdb/gdbserver/Makefile.depend gnu/usr.bin/gdb/gdbserver/Makefile.depend index 54c1f6f1442e..d5ed563ecfc8 100644 --- gnu/usr.bin/gdb/gdbserver/Makefile.depend +++ gnu/usr.bin/gdb/gdbserver/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git gnu/usr.bin/gdb/gdbtui/Makefile.depend gnu/usr.bin/gdb/gdbtui/Makefile.depend index 10de637399a2..ee6269e741a7 100644 --- gnu/usr.bin/gdb/gdbtui/Makefile.depend +++ gnu/usr.bin/gdb/gdbtui/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/lib/libreadline/readline \ gnu/lib/libregex \ gnu/usr.bin/binutils/libbfd \ diff --git gnu/usr.bin/gdb/kgdb/Makefile.depend gnu/usr.bin/gdb/kgdb/Makefile.depend index c39552f83509..ed1b03ca732f 100644 --- gnu/usr.bin/gdb/kgdb/Makefile.depend +++ gnu/usr.bin/gdb/kgdb/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/lib/libreadline/readline \ gnu/lib/libregex \ gnu/usr.bin/binutils/libbfd \ diff --git gnu/usr.bin/gperf/Makefile.depend gnu/usr.bin/gperf/Makefile.depend index b6027086c86c..ea8bba31ec06 100644 --- gnu/usr.bin/gperf/Makefile.depend +++ gnu/usr.bin/gperf/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git gnu/usr.bin/grep/Makefile.depend gnu/usr.bin/grep/Makefile.depend index 676126dad180..bdea82e9f7cd 100644 --- gnu/usr.bin/grep/Makefile.depend +++ gnu/usr.bin/grep/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ gnu/lib/libregex \ include \ include/xlocale \ diff --git include/runetype.h include/runetype.h index 6aad915b5604..dcbb226bb2d8 100644 --- include/runetype.h +++ include/runetype.h @@ -95,9 +95,7 @@ static __inline const _RuneLocale *__getCurrentRuneLocale(void) if (_ThreadRuneLocale) return _ThreadRuneLocale; - if (_CurrentRuneLocale) - return _CurrentRuneLocale; - return &_DefaultRuneLocale; + return _CurrentRuneLocale; } #endif /* __NO_TLS || __RUNETYPE_INTERNAL */ #define _CurrentRuneLocale (__getCurrentRuneLocale()) diff --git include/stddef.h include/stddef.h index 88fbb93040a9..4916e80756f5 100644 --- include/stddef.h +++ include/stddef.h @@ -70,7 +70,7 @@ typedef __max_align_t max_align_t; #endif #endif -#define offsetof(type, member) __offsetof(type, member) +#define offsetof(type, field) __offsetof(type, field) #if __EXT1_VISIBLE /* ISO/IEC 9899:2011 K.3.3.2 */ diff --git kerberos5/lib/libasn1/Makefile.depend kerberos5/lib/libasn1/Makefile.depend index 72f4875e32a8..eb953e7eb57c 100644 --- kerberos5/lib/libasn1/Makefile.depend +++ kerberos5/lib/libasn1/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libgssapi_krb5/Makefile.depend kerberos5/lib/libgssapi_krb5/Makefile.depend index 2f0effb51781..13ef23bb9d08 100644 --- kerberos5/lib/libgssapi_krb5/Makefile.depend +++ kerberos5/lib/libgssapi_krb5/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libgssapi_ntlm/Makefile.depend kerberos5/lib/libgssapi_ntlm/Makefile.depend index fe01ea61b8c5..b860dd2f7b73 100644 --- kerberos5/lib/libgssapi_ntlm/Makefile.depend +++ kerberos5/lib/libgssapi_ntlm/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libgssapi_spnego/Makefile.depend kerberos5/lib/libgssapi_spnego/Makefile.depend index a1aecc5e6ca1..ec85bb9e1e38 100644 --- kerberos5/lib/libgssapi_spnego/Makefile.depend +++ kerberos5/lib/libgssapi_spnego/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libhdb/Makefile.depend kerberos5/lib/libhdb/Makefile.depend index 1a071a80c47d..4f0e34f96b31 100644 --- kerberos5/lib/libhdb/Makefile.depend +++ kerberos5/lib/libhdb/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libheimbase/Makefile.depend kerberos5/lib/libheimbase/Makefile.depend index 7b92dbd89f4a..8bb1973e0ff5 100644 --- kerberos5/lib/libheimbase/Makefile.depend +++ kerberos5/lib/libheimbase/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git kerberos5/lib/libheimipcc/Makefile.depend kerberos5/lib/libheimipcc/Makefile.depend index 78a2d56cabd2..979fd8bac5cf 100644 --- kerberos5/lib/libheimipcc/Makefile.depend +++ kerberos5/lib/libheimipcc/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libheimipcs/Makefile.depend kerberos5/lib/libheimipcs/Makefile.depend index 38b9ffdbfca7..248469a4ba59 100644 --- kerberos5/lib/libheimipcs/Makefile.depend +++ kerberos5/lib/libheimipcs/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libheimntlm/Makefile.depend kerberos5/lib/libheimntlm/Makefile.depend index d337cb8f4e77..43cdedb26b11 100644 --- kerberos5/lib/libheimntlm/Makefile.depend +++ kerberos5/lib/libheimntlm/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libhx509/Makefile.depend kerberos5/lib/libhx509/Makefile.depend index ad38cc419322..39a0537cd8a1 100644 --- kerberos5/lib/libhx509/Makefile.depend +++ kerberos5/lib/libhx509/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libkadm5clnt/Makefile.depend kerberos5/lib/libkadm5clnt/Makefile.depend index b345b5dfb454..3a500695511e 100644 --- kerberos5/lib/libkadm5clnt/Makefile.depend +++ kerberos5/lib/libkadm5clnt/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libkadm5srv/Makefile.depend kerberos5/lib/libkadm5srv/Makefile.depend index b345b5dfb454..3a500695511e 100644 --- kerberos5/lib/libkadm5srv/Makefile.depend +++ kerberos5/lib/libkadm5srv/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libkafs5/Makefile.depend kerberos5/lib/libkafs5/Makefile.depend index 4f22e41e0d32..fd6922a3ffa7 100644 --- kerberos5/lib/libkafs5/Makefile.depend +++ kerberos5/lib/libkafs5/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ @@ -14,7 +13,6 @@ DIRDEPS = \ lib/libc \ lib/libcompiler_rt \ secure/lib/libcrypto \ - usr.bin/compile_et.host \ .include <dirdeps.mk> diff --git kerberos5/lib/libkdc/Makefile.depend kerberos5/lib/libkdc/Makefile.depend index 384382ba4bce..4974b160c9d8 100644 --- kerberos5/lib/libkdc/Makefile.depend +++ kerberos5/lib/libkdc/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libkrb5/Makefile.depend kerberos5/lib/libkrb5/Makefile.depend index 5ccf59583c27..316ba47f32c1 100644 --- kerberos5/lib/libkrb5/Makefile.depend +++ kerberos5/lib/libkrb5/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libroken/Makefile.depend kerberos5/lib/libroken/Makefile.depend index 35cdb76975c2..9a1911dbf3d2 100644 --- kerberos5/lib/libroken/Makefile.depend +++ kerberos5/lib/libroken/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/lib/libwind/Makefile.depend kerberos5/lib/libwind/Makefile.depend index 94dff02ffb79..f4235f6847ca 100644 --- kerberos5/lib/libwind/Makefile.depend +++ kerberos5/lib/libwind/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/libexec/digest-service/Makefile.depend kerberos5/libexec/digest-service/Makefile.depend index 65f84a9a321c..791f5db44fe4 100644 --- kerberos5/libexec/digest-service/Makefile.depend +++ kerberos5/libexec/digest-service/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/libexec/hprop/Makefile.depend kerberos5/libexec/hprop/Makefile.depend index df6a5f75c80b..10fc46724ede 100644 --- kerberos5/libexec/hprop/Makefile.depend +++ kerberos5/libexec/hprop/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/libexec/hpropd/Makefile.depend kerberos5/libexec/hpropd/Makefile.depend index fc78d6cc6eb0..96378f6083d8 100644 --- kerberos5/libexec/hpropd/Makefile.depend +++ kerberos5/libexec/hpropd/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/libexec/ipropd-master/Makefile.depend kerberos5/libexec/ipropd-master/Makefile.depend index 309e11490921..20251e94ba97 100644 --- kerberos5/libexec/ipropd-master/Makefile.depend +++ kerberos5/libexec/ipropd-master/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/libexec/ipropd-slave/Makefile.depend kerberos5/libexec/ipropd-slave/Makefile.depend index 309e11490921..20251e94ba97 100644 --- kerberos5/libexec/ipropd-slave/Makefile.depend +++ kerberos5/libexec/ipropd-slave/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/libexec/kadmind/Makefile.depend kerberos5/libexec/kadmind/Makefile.depend index 0fd8ac816721..67d2d5518d4a 100644 --- kerberos5/libexec/kadmind/Makefile.depend +++ kerberos5/libexec/kadmind/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/gssapi \ diff --git kerberos5/libexec/kcm/Makefile.depend kerberos5/libexec/kcm/Makefile.depend index aa443c34b4c5..7f7343269e7f 100644 --- kerberos5/libexec/kcm/Makefile.depend +++ kerberos5/libexec/kcm/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/libexec/kdc/Makefile.depend kerberos5/libexec/kdc/Makefile.depend index eb56231b4cd5..6a08c2b63ee8 100644 --- kerberos5/libexec/kdc/Makefile.depend +++ kerberos5/libexec/kdc/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/libexec/kdigest/Makefile.depend kerberos5/libexec/kdigest/Makefile.depend index 325d4ed94145..e71b2214c1a8 100644 --- kerberos5/libexec/kdigest/Makefile.depend +++ kerberos5/libexec/kdigest/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/libexec/kfd/Makefile.depend kerberos5/libexec/kfd/Makefile.depend index b434af8f54c0..b7626cdd7360 100644 --- kerberos5/libexec/kfd/Makefile.depend +++ kerberos5/libexec/kfd/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/libexec/kimpersonate/Makefile.depend kerberos5/libexec/kimpersonate/Makefile.depend index 9e85d37b7423..a8187f718255 100644 --- kerberos5/libexec/kimpersonate/Makefile.depend +++ kerberos5/libexec/kimpersonate/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/libexec/kpasswdd/Makefile.depend kerberos5/libexec/kpasswdd/Makefile.depend index 1c794c43265e..8178becab2f3 100644 --- kerberos5/libexec/kpasswdd/Makefile.depend +++ kerberos5/libexec/kpasswdd/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/tools/asn1_compile/Makefile.depend kerberos5/tools/asn1_compile/Makefile.depend index 947a8edfebc3..7f8f93b61067 100644 --- kerberos5/tools/asn1_compile/Makefile.depend +++ kerberos5/tools/asn1_compile/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/tools/make-roken/Makefile.depend kerberos5/tools/make-roken/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- kerberos5/tools/make-roken/Makefile.depend +++ kerberos5/tools/make-roken/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git kerberos5/tools/slc/Makefile.depend kerberos5/tools/slc/Makefile.depend index 947a8edfebc3..7f8f93b61067 100644 --- kerberos5/tools/slc/Makefile.depend +++ kerberos5/tools/slc/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.bin/hxtool/Makefile.depend kerberos5/usr.bin/hxtool/Makefile.depend index e673899ff8ca..637ecdc71538 100644 --- kerberos5/usr.bin/hxtool/Makefile.depend +++ kerberos5/usr.bin/hxtool/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.bin/kadmin/Makefile.depend kerberos5/usr.bin/kadmin/Makefile.depend index bd5025406de0..fca25156e4c7 100644 --- kerberos5/usr.bin/kadmin/Makefile.depend +++ kerberos5/usr.bin/kadmin/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.bin/kcc/Makefile.depend kerberos5/usr.bin/kcc/Makefile.depend index c7d0db696dfc..3c69ae3e4423 100644 --- kerberos5/usr.bin/kcc/Makefile.depend +++ kerberos5/usr.bin/kcc/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.bin/kdestroy/Makefile.depend kerberos5/usr.bin/kdestroy/Makefile.depend index 9e85d37b7423..a8187f718255 100644 --- kerberos5/usr.bin/kdestroy/Makefile.depend +++ kerberos5/usr.bin/kdestroy/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.bin/kf/Makefile.depend kerberos5/usr.bin/kf/Makefile.depend index b434af8f54c0..b7626cdd7360 100644 --- kerberos5/usr.bin/kf/Makefile.depend +++ kerberos5/usr.bin/kf/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.bin/kgetcred/Makefile.depend kerberos5/usr.bin/kgetcred/Makefile.depend index 9e85d37b7423..a8187f718255 100644 --- kerberos5/usr.bin/kgetcred/Makefile.depend +++ kerberos5/usr.bin/kgetcred/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.bin/kinit/Makefile.depend kerberos5/usr.bin/kinit/Makefile.depend index dcd0d641625d..951e30014510 100644 --- kerberos5/usr.bin/kinit/Makefile.depend +++ kerberos5/usr.bin/kinit/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.bin/kpasswd/Makefile.depend kerberos5/usr.bin/kpasswd/Makefile.depend index 1f4d460300cd..5c48dc0bead0 100644 --- kerberos5/usr.bin/kpasswd/Makefile.depend +++ kerberos5/usr.bin/kpasswd/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.bin/ksu/Makefile.depend kerberos5/usr.bin/ksu/Makefile.depend index 9e85d37b7423..a8187f718255 100644 --- kerberos5/usr.bin/ksu/Makefile.depend +++ kerberos5/usr.bin/ksu/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.bin/string2key/Makefile.depend kerberos5/usr.bin/string2key/Makefile.depend index 517300f0080b..b0b8237d6091 100644 --- kerberos5/usr.bin/string2key/Makefile.depend +++ kerberos5/usr.bin/string2key/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.bin/verify_krb5_conf/Makefile.depend kerberos5/usr.bin/verify_krb5_conf/Makefile.depend index b434af8f54c0..b7626cdd7360 100644 --- kerberos5/usr.bin/verify_krb5_conf/Makefile.depend +++ kerberos5/usr.bin/verify_krb5_conf/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.sbin/iprop-log/Makefile.depend kerberos5/usr.sbin/iprop-log/Makefile.depend index d8cb0d5706eb..d94b32b91ee0 100644 --- kerberos5/usr.sbin/iprop-log/Makefile.depend +++ kerberos5/usr.sbin/iprop-log/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.sbin/kstash/Makefile.depend kerberos5/usr.sbin/kstash/Makefile.depend index fc78d6cc6eb0..96378f6083d8 100644 --- kerberos5/usr.sbin/kstash/Makefile.depend +++ kerberos5/usr.sbin/kstash/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git kerberos5/usr.sbin/ktutil/Makefile.depend kerberos5/usr.sbin/ktutil/Makefile.depend index ce4c832f8473..3529856e8ce2 100644 --- kerberos5/usr.sbin/ktutil/Makefile.depend +++ kerberos5/usr.sbin/ktutil/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/Makefile lib/Makefile index dcf81007d0aa..33911ac90c4b 100644 --- lib/Makefile +++ lib/Makefile @@ -35,6 +35,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \ libcalendar \ libcam \ libcapsicum \ + libcasper \ libcompat \ libcrypt \ libdevctl \ @@ -64,6 +65,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \ libopenbsd \ libopie \ libpam \ + libpathconv \ libpcap \ libpjdlog \ ${_libproc} \ @@ -75,7 +77,6 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \ libsbuf \ libsmb \ libsqlite3 \ - libstand \ libstdbuf \ libstdthreads \ libsysdecode \ @@ -128,7 +129,6 @@ SUBDIR.${MK_ATM}+= libngatm SUBDIR.${MK_BLACKLIST}+=libblacklist SUBDIR.${MK_BLUETOOTH}+=libbluetooth libsdp SUBDIR.${MK_BSNMP}+= libbsnmp -SUBDIR.${MK_CASPER}+= libcasper .if !defined(COMPAT_32BIT) && !defined(COMPAT_SOFTFP) SUBDIR.${MK_CLANG}+= clang @@ -158,10 +158,8 @@ _libclang_rt= libclang_rt .if ${MK_LIBCPLUSPLUS} != "no" _libcxxrt= libcxxrt _libcplusplus= libc++ -.if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" _libcplusplus+= libc++experimental .endif -.endif SUBDIR.${MK_EFI}+= libefivar SUBDIR.${MK_LIBTHR}+= libthr @@ -189,7 +187,7 @@ _libdl= libdl .endif SUBDIR.${MK_OPENSSL}+= libmp -SUBDIR.${MK_PMC}+= libpmc +SUBDIR.${MK_PMC}+= libpmc libpmcstat SUBDIR.${MK_RADIUS_SUPPORT}+= libradius SUBDIR.${MK_SENDMAIL}+= libmilter libsm libsmdb libsmutil SUBDIR.${MK_TELNET}+= libtelnet diff --git lib/atf/libatf-c++/Makefile.depend lib/atf/libatf-c++/Makefile.depend index 4cca715bf897..b0b52c8a3f36 100644 --- lib/atf/libatf-c++/Makefile.depend +++ lib/atf/libatf-c++/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/atf/libatf-c++/tests/Makefile.depend lib/atf/libatf-c++/tests/Makefile.depend index 494810e117f6..5eb060af3bca 100644 --- lib/atf/libatf-c++/tests/Makefile.depend +++ lib/atf/libatf-c++/tests/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/atf/libatf-c++/tests/detail/Makefile.depend lib/atf/libatf-c++/tests/detail/Makefile.depend index 494810e117f6..5eb060af3bca 100644 --- lib/atf/libatf-c++/tests/detail/Makefile.depend +++ lib/atf/libatf-c++/tests/detail/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/atf/libatf-c/Makefile.depend lib/atf/libatf-c/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/atf/libatf-c/Makefile.depend +++ lib/atf/libatf-c/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/atf/libatf-c/tests/Makefile.depend lib/atf/libatf-c/tests/Makefile.depend index 74074b9588ec..c062f6026d94 100644 --- lib/atf/libatf-c/tests/Makefile.depend +++ lib/atf/libatf-c/tests/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/atf/libatf-c/tests/detail/Makefile.depend lib/atf/libatf-c/tests/detail/Makefile.depend index 74074b9588ec..c062f6026d94 100644 --- lib/atf/libatf-c/tests/detail/Makefile.depend +++ lib/atf/libatf-c/tests/detail/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/atf/tests/test-programs/Makefile.depend lib/atf/tests/test-programs/Makefile.depend index 494810e117f6..5eb060af3bca 100644 --- lib/atf/tests/test-programs/Makefile.depend +++ lib/atf/tests/test-programs/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/clang/Makefile.inc lib/clang/Makefile.inc new file mode 100644 index 000000000000..a0b4eea76882 --- /dev/null +++ lib/clang/Makefile.inc @@ -0,0 +1,9 @@ +# $FreeBSD$ + +.include <bsd.compiler.mk> + +.if ${COMPILER_TYPE} == "clang" +DEBUG_FILES_CFLAGS= -gline-tables-only +.else +DEBUG_FILES_CFLAGS= -g1 +.endif diff --git lib/clang/include/clang/Basic/Version.inc lib/clang/include/clang/Basic/Version.inc index 7a9a4f7cc287..51e63ee37ccd 100644 --- lib/clang/include/clang/Basic/Version.inc +++ lib/clang/include/clang/Basic/Version.inc @@ -8,4 +8,4 @@ #define CLANG_VENDOR "FreeBSD " -#define SVN_REVISION "311219" +#define SVN_REVISION "312559" diff --git lib/clang/include/lld/Config/Version.inc lib/clang/include/lld/Config/Version.inc index c506bdf0fc83..4dad50070d43 100644 --- lib/clang/include/lld/Config/Version.inc +++ lib/clang/include/lld/Config/Version.inc @@ -4,5 +4,5 @@ #define LLD_VERSION_STRING "5.0.0" #define LLD_VERSION_MAJOR 5 #define LLD_VERSION_MINOR 0 -#define LLD_REVISION_STRING "311219" +#define LLD_REVISION_STRING "312559" #define LLD_REPOSITORY_STRING "FreeBSD" diff --git lib/clang/include/llvm/Support/VCSRevision.h lib/clang/include/llvm/Support/VCSRevision.h index 8060bd4818f8..a1682db4a641 100644 --- lib/clang/include/llvm/Support/VCSRevision.h +++ lib/clang/include/llvm/Support/VCSRevision.h @@ -1,2 +1,2 @@ /* $FreeBSD$ */ -#define LLVM_REVISION "svn-r311219" +#define LLVM_REVISION "svn-r312559" diff --git lib/clang/libclang/Makefile lib/clang/libclang/Makefile index 544f7d4596ce..6a0d1dfc049d 100644 --- lib/clang/libclang/Makefile +++ lib/clang/libclang/Makefile @@ -790,16 +790,7 @@ clang/StaticAnalyzer/Checkers/Checkers.inc: \ ${CLANG_SRCS}/include/clang/StaticAnalyzer/Checkers/Checkers.td TGHDRS+= clang/StaticAnalyzer/Checkers/Checkers.inc -.for dep in ${TGHDRS:C/$/.d/} -. if ${MAKE_VERSION} < 20160220 -. if !make(depend) -. sinclude "${dep}" -. endif -. else -. dinclude "${dep}" -. endif -.endfor - +DEPENDFILES+= ${TGHDRS:C/$/.d/} DPSRCS+= ${TGHDRS} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} diff --git lib/clang/libllvm/Makefile lib/clang/libllvm/Makefile index aa1a3f313b43..e7d9541c60bf 100644 --- lib/clang/libllvm/Makefile +++ lib/clang/libllvm/Makefile @@ -1412,16 +1412,7 @@ TGHDRS+= X86GenRegisterBank.inc TGHDRS+= X86GenRegisterInfo.inc TGHDRS+= X86GenSubtargetInfo.inc -.for dep in ${TGHDRS:C/$/.d/} -. if ${MAKE_VERSION} < 20160220 -. if !make(depend) -. sinclude "${dep}" -. endif -. else -. dinclude "${dep}" -. endif -.endfor - +DEPENDFILES+= ${TGHDRS:C/$/.d/} DPSRCS+= ${TGHDRS} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} diff --git lib/clang/llvm.build.mk lib/clang/llvm.build.mk index cac4662efd30..d5e39d14d84e 100644 --- lib/clang/llvm.build.mk +++ lib/clang/llvm.build.mk @@ -20,10 +20,10 @@ CFLAGS+= -D__STDC_CONSTANT_MACROS TARGET_ARCH?= ${MACHINE_ARCH} BUILD_ARCH?= ${MACHINE_ARCH} -# Armv6 uses hard float abi, unless the CPUTYPE has soft in it. +# Armv6 and armv7 uses hard float abi, unless the CPUTYPE has soft in it. # arm (for armv4 and armv5 CPUs) always uses the soft float ABI. # For all other targets, we stick with 'unknown'. -.if ${TARGET_ARCH:Marmv6*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") +.if ${TARGET_ARCH:Marmv[67]*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") TARGET_ABI= -gnueabihf .elif ${TARGET_ARCH:Marm*} TARGET_ABI= -gnueabi @@ -33,11 +33,11 @@ TARGET_ABI= VENDOR= unknown OS_VERSION= freebsd12.0 -TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION}${TARGET_ABI} -BUILD_TRIPLE?= ${BUILD_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION} +LLVM_TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION}${TARGET_ABI} +LLVM_BUILD_TRIPLE?= ${BUILD_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION} -CFLAGS+= -DLLVM_DEFAULT_TARGET_TRIPLE=\"${TARGET_TRIPLE}\" -CFLAGS+= -DLLVM_HOST_TRIPLE=\"${BUILD_TRIPLE}\" +CFLAGS+= -DLLVM_DEFAULT_TARGET_TRIPLE=\"${LLVM_TARGET_TRIPLE}\" +CFLAGS+= -DLLVM_HOST_TRIPLE=\"${LLVM_BUILD_TRIPLE}\" CFLAGS+= -DDEFAULT_SYSROOT=\"${TOOLS_PREFIX}\" CFLAGS+= -ffunction-sections diff --git lib/csu/arm/crt1.c lib/csu/arm/crt1.c index 5dec5e5f1da1..46a301ca2acc 100644 --- lib/csu/arm/crt1.c +++ lib/csu/arm/crt1.c @@ -19,7 +19,7 @@ * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed for the - * FreeBSD Project. See http://www.freebsd.org/ for + * FreeBSD Project. See https://www.freebsd.org/ for * information about FreeBSD. * This product includes software developed for the * NetBSD Project. See http://www.netbsd.org/ for diff --git lib/csu/mips/crti.S lib/csu/mips/crti.S index 1553f9e13b91..7289f0a91f47 100644 --- lib/csu/mips/crti.S +++ lib/csu/mips/crti.S @@ -1,7 +1,9 @@ #include <machine/asm.h> __FBSDID("$FreeBSD$"); +#ifndef __clang__ .gnu_attribute 4, 0 +#endif .section .init,"ax",%progbits .align 4 .globl _init diff --git lib/csu/mips/crtn.S lib/csu/mips/crtn.S index 8cef67ffec08..ad81a7b5f3c6 100644 --- lib/csu/mips/crtn.S +++ lib/csu/mips/crtn.S @@ -1,7 +1,9 @@ #include <machine/asm.h> __FBSDID("$FreeBSD$"); +#ifndef __clang__ .gnu_attribute 4, 0 +#endif .section .init,"ax",%progbits .align 4 .set noreorder diff --git lib/csu/powerpc/crt1.c lib/csu/powerpc/crt1.c index 4e41bf7472aa..3a24fd108506 100644 --- lib/csu/powerpc/crt1.c +++ lib/csu/powerpc/crt1.c @@ -19,7 +19,7 @@ * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed for the - * FreeBSD Project. See http://www.freebsd.org/ for + * FreeBSD Project. See https://www.freebsd.org/ for * information about FreeBSD. * This product includes software developed for the * NetBSD Project. See http://www.netbsd.org/ for diff --git lib/csu/powerpc64/crt1.c lib/csu/powerpc64/crt1.c index 3ae52501c496..f3b58fbc9115 100644 --- lib/csu/powerpc64/crt1.c +++ lib/csu/powerpc64/crt1.c @@ -19,7 +19,7 @@ * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed for the - * FreeBSD Project. See http://www.freebsd.org/ for + * FreeBSD Project. See https://www.freebsd.org/ for * information about FreeBSD. * This product includes software developed for the * NetBSD Project. See http://www.netbsd.org/ for diff --git lib/lib80211/Makefile.depend lib/lib80211/Makefile.depend index 7f43259d6ba3..a04957c6b683 100644 --- lib/lib80211/Makefile.depend +++ lib/lib80211/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libalias/libalias/Makefile.depend lib/libalias/libalias/Makefile.depend index 54c1f6f1442e..d5ed563ecfc8 100644 --- lib/libalias/libalias/Makefile.depend +++ lib/libalias/libalias/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libalias/modules/cuseeme/Makefile.depend lib/libalias/modules/cuseeme/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libalias/modules/cuseeme/Makefile.depend +++ lib/libalias/modules/cuseeme/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libalias/modules/dummy/Makefile.depend lib/libalias/modules/dummy/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libalias/modules/dummy/Makefile.depend +++ lib/libalias/modules/dummy/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libalias/modules/ftp/Makefile.depend lib/libalias/modules/ftp/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libalias/modules/ftp/Makefile.depend +++ lib/libalias/modules/ftp/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libalias/modules/irc/Makefile.depend lib/libalias/modules/irc/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libalias/modules/irc/Makefile.depend +++ lib/libalias/modules/irc/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libalias/modules/nbt/Makefile.depend lib/libalias/modules/nbt/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libalias/modules/nbt/Makefile.depend +++ lib/libalias/modules/nbt/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libalias/modules/pptp/Makefile.depend lib/libalias/modules/pptp/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libalias/modules/pptp/Makefile.depend +++ lib/libalias/modules/pptp/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libalias/modules/skinny/Makefile.depend lib/libalias/modules/skinny/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libalias/modules/skinny/Makefile.depend +++ lib/libalias/modules/skinny/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libalias/modules/smedia/Makefile.depend lib/libalias/modules/smedia/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libalias/modules/smedia/Makefile.depend +++ lib/libalias/modules/smedia/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libarchive/Makefile lib/libarchive/Makefile index e2547015431d..c2f9e87105e4 100644 --- lib/libarchive/Makefile +++ lib/libarchive/Makefile @@ -97,6 +97,7 @@ SRCS= archive_acl.c \ archive_read_support_filter_rpm.c \ archive_read_support_filter_uu.c \ archive_read_support_filter_xz.c \ + archive_read_support_filter_zstd.c \ archive_read_support_format_7zip.c \ archive_read_support_format_all.c \ archive_read_support_format_ar.c \ @@ -139,6 +140,7 @@ SRCS= archive_acl.c \ archive_write_add_filter_program.c \ archive_write_add_filter_uuencode.c \ archive_write_add_filter_xz.c \ + archive_write_add_filter_zstd.c \ archive_write_set_format.c \ archive_write_set_format_7zip.c \ archive_write_set_format_ar.c \ diff --git lib/libarchive/Makefile.depend lib/libarchive/Makefile.depend index 1d68a5a5ded7..d18bae375b6e 100644 --- lib/libarchive/Makefile.depend +++ lib/libarchive/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libarchive/tests/Makefile lib/libarchive/tests/Makefile index 9252de271166..d5e3aa16879b 100644 --- lib/libarchive/tests/Makefile +++ lib/libarchive/tests/Makefile @@ -83,6 +83,7 @@ TESTS_SRCS= \ test_compat_uudecode_large.c \ test_compat_xz.c \ test_compat_zip.c \ + test_compat_zstd.c \ test_empty_write.c \ test_entry.c \ test_entry_strmode.c \ @@ -240,6 +241,7 @@ TESTS_SRCS= \ test_write_filter_program.c \ test_write_filter_uuencode.c \ test_write_filter_xz.c \ + test_write_filter_zstd.c \ test_write_format_7zip.c \ test_write_format_7zip_empty.c \ test_write_format_7zip_large.c \ @@ -373,6 +375,7 @@ ${PACKAGE}FILES+= test_compat_zip_4.zip.uu ${PACKAGE}FILES+= test_compat_zip_5.zip.uu ${PACKAGE}FILES+= test_compat_zip_6.zip.uu ${PACKAGE}FILES+= test_compat_zip_7.xps.uu +${PACKAGE}FILES+= test_compat_zstd_1.tar.zst.uu ${PACKAGE}FILES+= test_fuzz.cab.uu ${PACKAGE}FILES+= test_fuzz.lzh.uu ${PACKAGE}FILES+= test_fuzz_1.iso.Z.uu diff --git lib/libarchive/tests/Makefile.depend lib/libarchive/tests/Makefile.depend index d61a89fbe1b0..a6e32a1b4b3e 100644 --- lib/libarchive/tests/Makefile.depend +++ lib/libarchive/tests/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libauditd/Makefile.depend lib/libauditd/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libauditd/Makefile.depend +++ lib/libauditd/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libbegemot/Makefile.depend lib/libbegemot/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libbegemot/Makefile.depend +++ lib/libbegemot/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libblacklist/Makefile.depend lib/libblacklist/Makefile.depend index 7b92dbd89f4a..8bb1973e0ff5 100644 --- lib/libblacklist/Makefile.depend +++ lib/libblacklist/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libblocksruntime/Makefile.depend lib/libblocksruntime/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libblocksruntime/Makefile.depend +++ lib/libblocksruntime/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libbluetooth/Makefile.depend lib/libbluetooth/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libbluetooth/Makefile.depend +++ lib/libbluetooth/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libbsdstat/Makefile.depend lib/libbsdstat/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libbsdstat/Makefile.depend +++ lib/libbsdstat/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libbsm/Makefile.depend lib/libbsm/Makefile.depend index 54c1f6f1442e..d5ed563ecfc8 100644 --- lib/libbsm/Makefile.depend +++ lib/libbsm/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libbsnmp/libbsnmp/Makefile.depend lib/libbsnmp/libbsnmp/Makefile.depend index f318cc1a6b40..2518ffc9b5ad 100644 --- lib/libbsnmp/libbsnmp/Makefile.depend +++ lib/libbsnmp/libbsnmp/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libbz2/Makefile.depend lib/libbz2/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libbz2/Makefile.depend +++ lib/libbz2/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc++/Makefile.depend lib/libc++/Makefile.depend index c609e5dd30e5..f1a26726dffb 100644 --- lib/libc++/Makefile.depend +++ lib/libc++/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/Makefile lib/libc/Makefile index 10230e1fc90b..6c897455dd07 100644 --- lib/libc/Makefile +++ lib/libc/Makefile @@ -110,7 +110,7 @@ NOASM= .include "${LIBC_SRCTOP}/uuid/Makefile.inc" .include "${LIBC_SRCTOP}/xdr/Makefile.inc" .if (${LIBC_ARCH} == "arm" && \ - (${MACHINE_ARCH:Marmv6*} == "" || (defined(CPUTYPE) && ${CPUTYPE:M*soft*}))) || \ + (${MACHINE_ARCH:Marmv[67]*} == "" || (defined(CPUTYPE) && ${CPUTYPE:M*soft*}))) || \ (${LIBC_ARCH} == "mips" && ${MACHINE_ARCH:Mmips*hf} == "") || \ (${LIBC_ARCH} == "riscv" && ${MACHINE_ARCH:Mriscv*sf} != "") .include "${LIBC_SRCTOP}/softfloat/Makefile.inc" diff --git lib/libc/arm/Makefile.inc lib/libc/arm/Makefile.inc index eaf361eb8ffb..c4b3458ba2cd 100644 --- lib/libc/arm/Makefile.inc +++ lib/libc/arm/Makefile.inc @@ -11,7 +11,7 @@ SYM_MAPS+=${LIBC_SRCTOP}/arm/Symbol.map .include "${LIBC_SRCTOP}/arm/aeabi/Makefile.inc" -.if ${MACHINE_ARCH:Marmv6*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") +.if ${MACHINE_ARCH:Marmv[67]*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") SYM_MAPS+=${LIBC_SRCTOP}/arm/Symbol_vfp.map .endif diff --git lib/libc/arm/aeabi/Makefile.inc lib/libc/arm/aeabi/Makefile.inc index 25f76ab099da..ecb1a1f2866e 100644 --- lib/libc/arm/aeabi/Makefile.inc +++ lib/libc/arm/aeabi/Makefile.inc @@ -5,14 +5,14 @@ SRCS+= aeabi_atexit.c \ aeabi_unwind_cpp.c \ aeabi_unwind_exidx.c -.if (${MACHINE_ARCH:Marmv6*} && defined(CPUTYPE) && ${CPUTYPE:M*soft*} != "") || \ - ${MACHINE_ARCH:Marmv6*} == "" +.if (${MACHINE_ARCH:Marmv[67]*} && defined(CPUTYPE) && ${CPUTYPE:M*soft*} != "") || \ + ${MACHINE_ARCH:Marmv[67]*} == "" SRCS+= aeabi_asm_double.S \ aeabi_asm_float.S \ aeabi_double.c \ aeabi_float.c .endif -.if ${MACHINE_ARCH:Marmv6*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") +.if ${MACHINE_ARCH:Marmv[67]*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") SRCS+= aeabi_vfp_double.S \ aeabi_vfp_float.S .endif diff --git lib/libc/arm/gen/Makefile.inc lib/libc/arm/gen/Makefile.inc index 615ee17dc449..05f3e95889a5 100644 --- lib/libc/arm/gen/Makefile.inc +++ lib/libc/arm/gen/Makefile.inc @@ -5,9 +5,9 @@ SRCS+= _ctx_start.S _setjmp.S _set_tp.c alloca.S fabs.c \ infinity.c ldexp.c makecontext.c \ __aeabi_read_tp.S setjmp.S signalcontext.c sigsetjmp.S flt_rounds.c \ arm_initfini.c \ - trivial-getcontextx.c + getcontextx.c -.if ${MACHINE_ARCH:Marmv6*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") +.if ${MACHINE_ARCH:Marmv[67]*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") SRCS+= fpgetmask_vfp.c fpgetround_vfp.c fpgetsticky_vfp.c fpsetmask_vfp.c \ fpsetround_vfp.c fpsetsticky_vfp.c .endif diff --git sys/boot/arm/at91/boot2/kb920x_board.c lib/libc/arm/gen/getcontextx.c similarity index 50% rename from sys/boot/arm/at91/boot2/kb920x_board.c rename to lib/libc/arm/gen/getcontextx.c index 52f9676be411..3092e2818e92 100644 --- sys/boot/arm/at91/boot2/kb920x_board.c +++ lib/libc/arm/gen/getcontextx.c @@ -1,9 +1,11 @@ -/*- - * Copyright (c) 2006 M. Warner Losh. All rights reserved. +/* + * Copyright (c) 2017 Michal Meloun <mmel@FreeBSD.org> + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -20,47 +22,78 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include <sys/param.h> +#include <sys/types.h> +#include <sys/ucontext.h> +#include <errno.h> +#include <stdlib.h> +#include <machine/sysarch.h> -#include "emac.h" -#include "lib.h" -#include "board.h" -#include "sd-card.h" +struct ucontextx { + ucontext_t ucontext; + mcontext_vfp_t mcontext_vfp; +}; -unsigned char mac[6] = { 0x42, 0x53, 0x44, 0, 0, 1 }; +int +__getcontextx_size(void) +{ -static void -MacFromEE() -{ - uint32_t sig; - sig = 0; - ReadEEPROM(12 * 1024, (uint8_t *)&sig, sizeof(sig)); - if (sig != 0x92021054) - return; - ReadEEPROM(12 * 1024 + 4, mac, 6); - printf("MAC %x:%x:%x:%x:%x:%x\n", mac[0], - mac[1], mac[2], mac[3], mac[4], mac[5]); + return (sizeof(struct ucontextx)); } -void -board_init(void) +int +__fillcontextx2(char *ctx) { - InitEEPROM(); - MacFromEE(); - EMAC_Init(); - EMAC_SetMACAddress(mac); - while (sdcard_init() == 0) - printf("Looking for SD card\n"); + struct ucontextx *ucxp; + ucontext_t *ucp; + mcontext_vfp_t *mvp; + struct arm_get_vfpstate_args vfp_arg; + + ucxp = (struct ucontextx *)ctx; + ucp = &ucxp->ucontext; + mvp = &ucxp->mcontext_vfp; + + vfp_arg.mc_vfp_size = sizeof(mcontext_vfp_t); + vfp_arg.mc_vfp = mvp; + if (sysarch(ARM_GET_VFPSTATE, &vfp_arg) == -1) + return (-1); + ucp->uc_mcontext.mc_vfp_size = sizeof(mcontext_vfp_t); + ucp->uc_mcontext.mc_vfp_ptr = mvp; + return (0); } int -drvread(void *buf, unsigned lba, unsigned nblk) +__fillcontextx(char *ctx) { - return (MCI_read((char *)buf, lba << 9, nblk << 9)); + struct ucontextx *ucxp; + + ucxp = (struct ucontextx *)ctx; + if (getcontext(&ucxp->ucontext) == -1) + return (-1); + __fillcontextx2(ctx); + return (0); +} + +__weak_reference(__getcontextx, getcontextx); + +ucontext_t * +__getcontextx(void) +{ + char *ctx; + int error; + + ctx = malloc(__getcontextx_size()); + if (ctx == NULL) + return (NULL); + if (__fillcontextx(ctx) == -1) { + error = errno; + free(ctx); + errno = error; + return (NULL); + } + return ((ucontext_t *)ctx); } diff --git lib/libc/gen/Symbol.map lib/libc/gen/Symbol.map index 3108f822b675..459657cf4535 100644 --- lib/libc/gen/Symbol.map +++ lib/libc/gen/Symbol.map @@ -398,6 +398,7 @@ FBSD_1.5 { devname; devname_r; dirname; + elf_aux_info; fts_children; fts_close; fts_get_clientptr; diff --git lib/libc/gen/auxv.c lib/libc/gen/auxv.c index 3767ac0a263c..816b6891dd87 100644 --- lib/libc/gen/auxv.c +++ lib/libc/gen/auxv.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <link.h> #include <pthread.h> #include <string.h> +#include <sys/auxv.h> #include "un-namespace.h" #include "libc_private.h" @@ -65,8 +66,10 @@ __init_elf_aux_vector(void) static pthread_once_t aux_once = PTHREAD_ONCE_INIT; static int pagesize, osreldate, canary_len, ncpus, pagesizes_len; +static int hwcap_present, hwcap2_present; static char *canary, *pagesizes; static void *timekeep; +static u_long hwcap, hwcap2; static void init_aux(void) @@ -83,6 +86,16 @@ init_aux(void) canary_len = aux->a_un.a_val; break; + case AT_HWCAP: + hwcap_present = 1; + hwcap = (u_long)(aux->a_un.a_val); + break; + + case AT_HWCAP2: + hwcap2_present = 1; + hwcap2 = (u_long)(aux->a_un.a_val); + break; + case AT_PAGESIZES: pagesizes = (char *)(aux->a_un.a_ptr); break; @@ -110,6 +123,8 @@ init_aux(void) } } +__weak_reference(_elf_aux_info, elf_aux_info); + int _elf_aux_info(int aux, void *buf, int buflen) { @@ -130,6 +145,20 @@ _elf_aux_info(int aux, void *buf, int buflen) } else res = ENOENT; break; + case AT_HWCAP: + if (hwcap_present && buflen == sizeof(u_long)) { + *(u_long *)buf = hwcap; + res = 0; + } else + res = ENOENT; + break; + case AT_HWCAP2: + if (hwcap2_present && buflen == sizeof(u_long)) { + *(u_long *)buf = hwcap2; + res = 0; + } else + res = ENOENT; + break; case AT_PAGESIZES: if (pagesizes != NULL && pagesizes_len >= buflen) { memcpy(buf, pagesizes, buflen); @@ -137,7 +166,6 @@ _elf_aux_info(int aux, void *buf, int buflen) } else res = ENOENT; break; - case AT_PAGESZ: if (buflen == sizeof(int)) { if (pagesize != 0) { diff --git lib/libc/gen/fnmatch.c lib/libc/gen/fnmatch.c index 5a988af06c2a..bc5799104fe8 100644 --- lib/libc/gen/fnmatch.c +++ lib/libc/gen/fnmatch.c @@ -249,7 +249,7 @@ rangematch(const char *pattern, wchar_t test, int flags, char **newp, * consistency with the regular expression syntax. * J.T. Conklin (conklin@ngai.kaleida.com) */ - if ( (negate = (*pattern == '!' || *pattern == '^')) ) + if ((negate = (*pattern == '!' || *pattern == '^'))) ++pattern; if (flags & FNM_CASEFOLD) diff --git lib/libc/gen/getmntinfo.c lib/libc/gen/getmntinfo.c index 0acc9bb219b8..bf2080719900 100644 --- lib/libc/gen/getmntinfo.c +++ lib/libc/gen/getmntinfo.c @@ -38,6 +38,9 @@ __FBSDID("$FreeBSD$"); #include <sys/mount.h> #include <stdlib.h> +#define MAX_TRIES 3 +#define SCALING_FACTOR 2 + /* * Return information about mounted filesystems. */ @@ -47,20 +50,21 @@ getmntinfo(struct statfs **mntbufp, int mode) static struct statfs *mntbuf; static int mntsize; static long bufsize; + unsigned tries = 0; if (mntsize <= 0 && (mntsize = getfsstat(0, 0, MNT_NOWAIT)) < 0) return (0); if (bufsize > 0 && (mntsize = getfsstat(mntbuf, bufsize, mode)) < 0) return (0); - while (bufsize <= mntsize * sizeof(struct statfs)) { - if (mntbuf) - free(mntbuf); - bufsize = (mntsize + 1) * sizeof(struct statfs); - if ((mntbuf = malloc(bufsize)) == NULL) + while (tries++ < MAX_TRIES && bufsize <= mntsize * sizeof(*mntbuf)) { + bufsize = (mntsize * SCALING_FACTOR) * sizeof(*mntbuf); + if ((mntbuf = reallocf(mntbuf, bufsize)) == NULL) return (0); if ((mntsize = getfsstat(mntbuf, bufsize, mode)) < 0) return (0); } *mntbufp = mntbuf; + if (mntsize > (bufsize / sizeof(*mntbuf))) + return (bufsize / sizeof(*mntbuf)); return (mntsize); } diff --git lib/libc/gen/setmode.c lib/libc/gen/setmode.c index c64c94743a0c..d3c4234594bd 100644 --- lib/libc/gen/setmode.c +++ lib/libc/gen/setmode.c @@ -356,7 +356,7 @@ getumask(void) * security.bsd.unprivileged_proc_debug is set to 0. */ len = sizeof(smask); - if (sysctl((int[4]){ CTL_KERN, KERN_PROC, KERN_PROC_UMASK, getpid() }, + if (sysctl((int[4]){ CTL_KERN, KERN_PROC, KERN_PROC_UMASK, 0 }, 4, &smask, &len, NULL, 0) == 0) return (smask); diff --git lib/libc/gen/sysctl.3 lib/libc/gen/sysctl.3 index 959573ec9623..ba1cd8f2a13f 100644 --- lib/libc/gen/sysctl.3 +++ lib/libc/gen/sysctl.3 @@ -28,7 +28,7 @@ .\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd September 10, 2015 +.Dd October 22, 2017 .Dt SYSCTL 3 .Os .Sh NAME @@ -741,6 +741,7 @@ privilege may change the value. .It Dv VM_V_FREE_TARGET Ta integer Ta yes .It Dv VM_V_INACTIVE_TARGET Ta integer Ta yes .It Dv VM_V_PAGEOUT_FREE_MIN Ta integer Ta yes +.It Dv VM_OVERCOMMIT Ta integer Ta yes .El .Bl -tag -width 6n .It Li VM_LOADAVG @@ -773,6 +774,9 @@ process address space when needed. .It Li VM_V_PAGEOUT_FREE_MIN If the amount of free and cache memory falls below this value, the pageout daemon will enter "memory conserving mode" to avoid deadlock. +.It Li VM_OVERCOMMIT +Overcommit behaviour, as described in +.Xr tuning 7 . .El .Sh RETURN VALUES .Rv -std diff --git lib/libc/gen/syslog.3 lib/libc/gen/syslog.3 index 28950b9dd59c..89c526dd0e98 100644 --- lib/libc/gen/syslog.3 +++ lib/libc/gen/syslog.3 @@ -28,7 +28,7 @@ .\" @(#)syslog.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd July 21, 2015 +.Dd November 5, 2017 .Dt SYSLOG 3 .Os .Sh NAME @@ -270,7 +270,7 @@ setlogmask(LOG_UPTO(LOG_ERR)); syslog(LOG_INFO, "Connection from host %d", CallingHost); -syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m"); +syslog(LOG_ERR|LOG_LOCAL2, "foobar error: %m"); .Ed .Sh SEE ALSO .Xr logger 1 , diff --git lib/libc/gen/tls.c lib/libc/gen/tls.c index d0ae591ac21a..c2d608a43cf9 100644 --- lib/libc/gen/tls.c +++ lib/libc/gen/tls.c @@ -37,9 +37,15 @@ #include <stdlib.h> #include <string.h> #include <elf.h> +#include <unistd.h> #include "libc_private.h" +#define tls_assert(cond) ((cond) ? (void) 0 : \ + (tls_msg(#cond ": assert failed: " __FILE__ ":" \ + __XSTRING(__LINE__) "\n"), abort())) +#define tls_msg(s) write(STDOUT_FILENO, s, strlen(s)) + /* Provided by jemalloc to avoid bootstrapping issues. */ void *__je_bootstrap_malloc(size_t size); void *__je_bootstrap_calloc(size_t num, size_t size); @@ -85,6 +91,7 @@ void __libc_free_tls(void *tls, size_t tcbsize, size_t tcbalign); static size_t tls_static_space; static size_t tls_init_size; +static size_t tls_init_align; static void *tls_init; #endif @@ -109,6 +116,35 @@ __libc_tls_get_addr(void *ti __unused) #ifndef PIC +static void * +malloc_aligned(size_t size, size_t align) +{ + void *mem, *res; + + if (align < sizeof(void *)) + align = sizeof(void *); + + mem = __je_bootstrap_malloc(size + sizeof(void *) + align - 1); + res = (void *)roundup2((uintptr_t)mem + sizeof(void *), align); + *(void **)((uintptr_t)res - sizeof(void *)) = mem; + return (res); +} + +static void +free_aligned(void *ptr) +{ + void *mem; + uintptr_t x; + + if (ptr == NULL) + return; + + x = (uintptr_t)ptr; + x -= sizeof(void *); + mem = *(void **)x; + __je_bootstrap_free(mem); +} + #ifdef TLS_VARIANT_I #define TLS_TCB_SIZE (2 * sizeof(void *)) @@ -117,55 +153,63 @@ __libc_tls_get_addr(void *ti __unused) * Free Static TLS using the Variant I method. */ void -__libc_free_tls(void *tcb, size_t tcbsize, size_t tcbalign __unused) +__libc_free_tls(void *tcb, size_t tcbsize __unused, size_t tcbalign __unused) { Elf_Addr *dtv; Elf_Addr **tls; - tls = (Elf_Addr **)((Elf_Addr)tcb + tcbsize - TLS_TCB_SIZE); + tls = (Elf_Addr **)tcb; dtv = tls[0]; __je_bootstrap_free(dtv); - __je_bootstrap_free(tcb); + free_aligned(tls); } /* * Allocate Static TLS using the Variant I method. */ void * -__libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign __unused) +__libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign) { Elf_Addr *dtv; Elf_Addr **tls; - char *tcb; if (oldtcb != NULL && tcbsize == TLS_TCB_SIZE) return (oldtcb); - tcb = __je_bootstrap_calloc(1, tls_static_space + tcbsize - TLS_TCB_SIZE); - tls = (Elf_Addr **)(tcb + tcbsize - TLS_TCB_SIZE); + tls_assert(tcbalign >= TLS_TCB_ALIGN); + tls_assert(tcbsize == TLS_TCB_SIZE); + + tcbsize = roundup2(tcbsize, tcbalign); + tls = malloc_aligned(tcbsize + tls_static_space, tcbalign); + if (tls == NULL) { + tls_msg("__libc_allocate_tls: Out of memory.\n"); + abort(); + } + memset(tls, 0, tcbsize + tls_static_space); if (oldtcb != NULL) { - memcpy(tls, oldtcb, tls_static_space); + memcpy(tls, oldtcb, tcbsize + tls_static_space); __je_bootstrap_free(oldtcb); /* Adjust the DTV. */ dtv = tls[0]; - dtv[2] = (Elf_Addr)tls + TLS_TCB_SIZE; + dtv[2] = (Elf_Addr)tls + tcbsize; } else { dtv = __je_bootstrap_malloc(3 * sizeof(Elf_Addr)); + if (dtv == NULL) { + tls_msg("__libc_allocate_tls: Out of memory.\n"); + abort(); + } tls[0] = dtv; - dtv[0] = 1; - dtv[1] = 1; - dtv[2] = (Elf_Addr)tls + TLS_TCB_SIZE; + dtv[0] = 1; /* Generation. */ + dtv[1] = 1; /* Segments count. */ + dtv[2] = (Elf_Addr)tls + tcbsize; if (tls_init_size > 0) memcpy((void*)dtv[2], tls_init, tls_init_size); - if (tls_static_space > tls_init_size) - memset((void*)(dtv[2] + tls_init_size), 0, - tls_static_space - tls_init_size); } - return(tcb); + return (tls); } #endif @@ -193,7 +237,7 @@ __libc_free_tls(void *tcb, size_t tcbsize __unused, size_t tcbalign) dtv = ((Elf_Addr**)tcb)[1]; tlsend = (Elf_Addr) tcb; tlsstart = tlsend - size; - __je_bootstrap_free((void*) tlsstart); + free_aligned((void*)tlsstart); __je_bootstrap_free(dtv); } @@ -212,8 +256,17 @@ __libc_allocate_tls(void *oldtls, size_t tcbsize, size_t tcbalign) if (tcbsize < 2 * sizeof(Elf_Addr)) tcbsize = 2 * sizeof(Elf_Addr); - tls = __je_bootstrap_calloc(1, size + tcbsize); + tls = malloc_aligned(size + tcbsize, tcbalign); + if (tls == NULL) { + tls_msg("__libc_allocate_tls: Out of memory.\n"); + abort(); + } + memset(tls, 0, size + tcbsize); dtv = __je_bootstrap_malloc(3 * sizeof(Elf_Addr)); + if (dtv == NULL) { + tls_msg("__libc_allocate_tls: Out of memory.\n"); + abort(); + } segbase = (Elf_Addr)(tls + size); ((Elf_Addr*)segbase)[0] = segbase; @@ -308,18 +361,14 @@ _init_tls(void) tls_static_space = roundup2(phdr[i].p_memsz, phdr[i].p_align); tls_init_size = phdr[i].p_filesz; + tls_init_align = phdr[i].p_align; tls_init = (void*) phdr[i].p_vaddr; + break; } } -#ifdef TLS_VARIANT_I - /* - * tls_static_space should include space for TLS structure - */ - tls_static_space += TLS_TCB_SIZE; -#endif - - tls = _rtld_allocate_tls(NULL, TLS_TCB_SIZE, TLS_TCB_ALIGN); + tls = _rtld_allocate_tls(NULL, TLS_TCB_SIZE, + MAX(TLS_TCB_ALIGN, tls_init_align)); _set_tp(tls); #endif diff --git lib/libc/locale/collate.c lib/libc/locale/collate.c index 045b847bd29a..51745dfaf745 100644 --- lib/libc/locale/collate.c +++ lib/libc/locale/collate.c @@ -125,8 +125,7 @@ __collate_load_tables_l(const char *encoding, struct xlocale_collate *table) return (_LDP_CACHE); } - asprintf(&buf, "%s/%s/LC_COLLATE", _PathLocale, encoding); - if (buf == NULL) + if (asprintf(&buf, "%s/%s/LC_COLLATE", _PathLocale, encoding) == -1) return (_LDP_ERROR); if ((fd = _open(buf, O_RDONLY)) < 0) { diff --git lib/libc/locale/setlocale.c lib/libc/locale/setlocale.c index 68656f3128ed..cb91d37997a5 100644 --- lib/libc/locale/setlocale.c +++ lib/libc/locale/setlocale.c @@ -42,48 +42,48 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #include <limits.h> #include <locale.h> -#include <paths.h> /* for _PATH_LOCALE */ +#include <paths.h> /* for _PATH_LOCALE */ #include <stdlib.h> #include <string.h> #include <unistd.h> #include "collate.h" -#include "lmonetary.h" /* for __monetary_load_locale() */ -#include "lnumeric.h" /* for __numeric_load_locale() */ -#include "lmessages.h" /* for __messages_load_locale() */ +#include "lmonetary.h" /* for __monetary_load_locale() */ +#include "lnumeric.h" /* for __numeric_load_locale() */ +#include "lmessages.h" /* for __messages_load_locale() */ #include "setlocale.h" #include "ldpart.h" -#include "../stdtime/timelocal.h" /* for __time_load_locale() */ +#include "../stdtime/timelocal.h" /* for __time_load_locale() */ /* * Category names for getenv() */ static const char categories[_LC_LAST][12] = { - "LC_ALL", - "LC_COLLATE", - "LC_CTYPE", - "LC_MONETARY", - "LC_NUMERIC", - "LC_TIME", - "LC_MESSAGES", + "LC_ALL", + "LC_COLLATE", + "LC_CTYPE", + "LC_MONETARY", + "LC_NUMERIC", + "LC_TIME", + "LC_MESSAGES", }; /* * Current locales for each category */ static char current_categories[_LC_LAST][ENCODING_LEN + 1] = { - "C", - "C", - "C", - "C", - "C", - "C", - "C", + "C", + "C", + "C", + "C", + "C", + "C", + "C", }; /* * Path to locale storage directory */ -char *_PathLocale; +char *_PathLocale; /* * The locales we are going to try and load @@ -93,21 +93,20 @@ static char saved_categories[_LC_LAST][ENCODING_LEN + 1]; static char current_locale_string[_LC_LAST * (ENCODING_LEN + 1/*"/"*/ + 1)]; -static char *currentlocale(void); -static char *loadlocale(int); +static char *currentlocale(void); +static char *loadlocale(int); const char *__get_locale_env(int); char * setlocale(int category, const char *locale) { int i, j, len, saverr; - const char *env, *r; + const char *env, *r; if (category < LC_ALL || category >= _LC_LAST) { errno = EINVAL; return (NULL); } - if (locale == NULL) return (category != LC_ALL ? current_categories[category] : currentlocale()); @@ -162,13 +161,13 @@ setlocale(int category, const char *locale) } do { if (i == _LC_LAST) - break; /* Too many slashes... */ + break; /* Too many slashes... */ if ((len = r - locale) > ENCODING_LEN) { errno = EINVAL; return (NULL); } (void)strlcpy(new_categories[i], locale, - len + 1); + len + 1); i++; while (*r == '/') r++; @@ -178,7 +177,7 @@ setlocale(int category, const char *locale) } while (*locale); while (i < _LC_LAST) { (void)strcpy(new_categories[i], - new_categories[i-1]); + new_categories[i - 1]); i++; } } @@ -193,7 +192,7 @@ setlocale(int category, const char *locale) saverr = errno; for (j = 1; j < i; j++) { (void)strcpy(new_categories[j], - saved_categories[j]); + saved_categories[j]); if (loadlocale(j) == NULL) { (void)strcpy(new_categories[j], "C"); (void)loadlocale(j); @@ -218,7 +217,7 @@ currentlocale(void) for (i = 2; i < _LC_LAST; ++i) { (void)strcat(current_locale_string, "/"); (void)strcat(current_locale_string, - current_categories[i]); + current_categories[i]); } break; } @@ -230,16 +229,15 @@ loadlocale(int category) { char *new = new_categories[category]; char *old = current_categories[category]; - int (*func)(const char *); + int (*func) (const char *); int saved_errno; if ((new[0] == '.' && - (new[1] == '\0' || (new[1] == '.' && new[2] == '\0'))) || + (new[1] == '\0' || (new[1] == '.' && new[2] == '\0'))) || strchr(new, '/') != NULL) { errno = EINVAL; return (NULL); } - saved_errno = errno; errno = __detect_path_locale(); if (errno != 0) @@ -285,22 +283,22 @@ loadlocale(int category) const char * __get_locale_env(int category) { - const char *env; + const char *env; - /* 1. check LC_ALL. */ - env = getenv(categories[0]); + /* 1. check LC_ALL. */ + env = getenv(categories[0]); - /* 2. check LC_* */ + /* 2. check LC_* */ if (env == NULL || !*env) - env = getenv(categories[category]); + env = getenv(categories[category]); - /* 3. check LANG */ + /* 3. check LANG */ if (env == NULL || !*env) - env = getenv("LANG"); + env = getenv("LANG"); - /* 4. if none is set, fall to "C" */ + /* 4. if none is set, fall to "C" */ if (env == NULL || !*env) - env = "C"; + env = "C"; return (env); } @@ -326,4 +324,3 @@ __detect_path_locale(void) } return (0); } - diff --git lib/libc/locale/setrunelocale.c lib/libc/locale/setrunelocale.c index 842f06da6aea..cf6309b5cb5d 100644 --- lib/libc/locale/setrunelocale.c +++ lib/libc/locale/setrunelocale.c @@ -38,7 +38,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#define __RUNETYPE_INTERNAL 1 +#define __RUNETYPE_INTERNAL 1 #include <runetype.h> #include <errno.h> @@ -72,7 +72,7 @@ destruct_ctype(void *v) { struct xlocale_ctype *l = v; - if (&_DefaultRuneLocale != l->runes) + if (&_DefaultRuneLocale != l->runes) free(l->runes); free(l); } @@ -81,7 +81,7 @@ const _RuneLocale * __getCurrentRuneLocale(void) { - return XLOCALE_CTYPE(__get_locale())->runes; + return (XLOCALE_CTYPE(__get_locale())->runes); } static void @@ -110,9 +110,8 @@ __setrunelocale(struct xlocale_ctype *l, const char *encoding) } /* Range checking not needed, encoding length already checked before */ - asprintf(&path, "%s/%s/LC_CTYPE", _PathLocale, encoding); - if (path == NULL) - return (0); + if (asprintf(&path, "%s/%s/LC_CTYPE", _PathLocale, encoding) == -1) + return (errno); if ((rl = _Read_RuneMagi(path)) == NULL) { free(path); @@ -144,7 +143,7 @@ __setrunelocale(struct xlocale_ctype *l, const char *encoding) else if (strcmp(rl->__encoding, "EUC-TW") == 0) ret = _EUC_TW_init(l, rl); else if (strcmp(rl->__encoding, "GB18030") == 0) - ret = _GB18030_init(l, rl); + ret = _GB18030_init(l, rl); else if (strcmp(rl->__encoding, "GB2312") == 0) ret = _GB2312_init(l, rl); else if (strcmp(rl->__encoding, "GBK") == 0) @@ -204,10 +203,9 @@ __ctype_load(const char *locale, locale_t unused __unused) struct xlocale_ctype *l = calloc(sizeof(struct xlocale_ctype), 1); l->header.header.destructor = destruct_ctype; - if (__setrunelocale(l, locale)) - { + if (__setrunelocale(l, locale)) { free(l); - return NULL; + return (NULL); } - return l; + return (l); } diff --git lib/libc/locale/xlocale_private.h lib/libc/locale/xlocale_private.h index 77b9ff4ee44f..e9917a5f5d62 100644 --- lib/libc/locale/xlocale_private.h +++ lib/libc/locale/xlocale_private.h @@ -40,6 +40,14 @@ #include <machine/atomic.h> #include "setlocale.h" +/** + * The XLC_ values are indexes into the components array. They are defined in + * the same order as the LC_ values in locale.h, but without the LC_ALL zero + * value. Translating from LC_X to XLC_X is done by subtracting one. + * + * Any reordering of this enum should ensure that these invariants are not + * violated. + */ enum { XLC_COLLATE = 0, XLC_CTYPE, @@ -50,6 +58,19 @@ enum { XLC_LAST }; +_Static_assert(XLC_LAST - XLC_COLLATE == 6, "XLC values should be contiguous"); +_Static_assert(XLC_COLLATE == LC_COLLATE - 1, + "XLC_COLLATE doesn't match the LC_COLLATE value."); +_Static_assert(XLC_CTYPE == LC_CTYPE - 1, + "XLC_CTYPE doesn't match the LC_CTYPE value."); +_Static_assert(XLC_MONETARY == LC_MONETARY - 1, + "XLC_MONETARY doesn't match the LC_MONETARY value."); +_Static_assert(XLC_NUMERIC == LC_NUMERIC - 1, + "XLC_NUMERIC doesn't match the LC_NUMERIC value."); +_Static_assert(XLC_TIME == LC_TIME - 1, + "XLC_TIME doesn't match the LC_TIME value."); +_Static_assert(XLC_MESSAGES == LC_MESSAGES - 1, + "XLC_MESSAGES doesn't match the LC_MESSAGES value."); /** * Header used for objects that are reference counted. Objects may optionally diff --git lib/libc/net/getaddrinfo.3 lib/libc/net/getaddrinfo.3 index 7380428e9fb3..fdfaddb98b0e 100644 --- lib/libc/net/getaddrinfo.3 +++ lib/libc/net/getaddrinfo.3 @@ -18,7 +18,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 21, 2015 +.Dd September 13, 2017 .Dt GETADDRINFO 3 .Os .Sh NAME @@ -351,6 +351,17 @@ pointer should be a .Li addrinfo structure created by a call to .Fn getaddrinfo . +.Sh IMPLEMENTATION NOTES +The behavior of +.Li freeadrinfo(NULL) +is left unspecified by both +.St -susv4 +and +.Dv "RFC 3493" . +The current implementation ignores a +.Dv NULL +argument for compatibility with programs that rely on the implementation +details of other operating systems. .Sh RETURN VALUES .Fn getaddrinfo returns zero on success or one of the error codes listed in diff --git lib/libc/net/getaddrinfo.c lib/libc/net/getaddrinfo.c index 5988ebc1372b..d70502870024 100644 --- lib/libc/net/getaddrinfo.c +++ lib/libc/net/getaddrinfo.c @@ -35,7 +35,7 @@ * in the source code. This is because RFC2553 is silent about which error * code must be returned for which situation. * - freeaddrinfo(NULL). RFC2553 is silent about it. XNET 5.2 says it is - * invalid. current code - SEGV on freeaddrinfo(NULL) + * invalid. Current code accepts NULL to be compatible with other OSes. * * Note: * - The code filters out AFs that are not supported by the kernel, @@ -359,14 +359,13 @@ freeaddrinfo(struct addrinfo *ai) { struct addrinfo *next; - do { + while (ai != NULL) { next = ai->ai_next; - if (ai->ai_canonname) - free(ai->ai_canonname); + free(ai->ai_canonname); /* no need to free(ai->ai_addr) */ free(ai); ai = next; - } while (ai); + } } static int diff --git lib/libc/net/gethostbyname.3 lib/libc/net/gethostbyname.3 index 83be23c2f1fb..591024f59360 100644 --- lib/libc/net/gethostbyname.3 +++ lib/libc/net/gethostbyname.3 @@ -28,7 +28,7 @@ .\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 .\" $FreeBSD$ .\" -.Dd May 12, 2006 +.Dd October 4, 2017 .Dt GETHOSTBYNAME 3 .Os .Sh NAME @@ -189,19 +189,20 @@ function may be used to request the use of a connected .Tn TCP socket for queries. +Queries will by default use +.Tn UDP +datagrams. If the .Fa stayopen -flag is non-zero, -this sets the option to send all queries to the name server using +flag is non-zero, a .Tn TCP -and to retain the connection after each call to +connection to the name server will be used. +It will remain open after calls to .Fn gethostbyname , .Fn gethostbyname2 or -.Fn gethostbyaddr . -Otherwise, queries are performed using -.Tn UDP -datagrams. +.Fn gethostbyaddr +have completed. .Pp The .Fn endhostent diff --git lib/libc/regex/regcomp.c lib/libc/regex/regcomp.c index 9d3327d009d0..2d0bacffb7c6 100644 --- lib/libc/regex/regcomp.c +++ lib/libc/regex/regcomp.c @@ -1059,7 +1059,7 @@ p_b_coll_elem(struct parse *p, } len = p->next - sp; for (cp = cnames; cp->name != NULL; cp++) - if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0') + if (strncmp(cp->name, sp, len) == 0 && strlen(cp->name) == len) return(cp->code); /* known name */ memset(&mbs, 0, sizeof(mbs)); if ((clen = mbrtowc(&wc, sp, len, &mbs)) == len) diff --git lib/libc/stdio/gets.c lib/libc/stdio/gets.c index f31221a74c63..06e56f7f0c3b 100644 --- lib/libc/stdio/gets.c +++ lib/libc/stdio/gets.c @@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include <unistd.h> #include <stdio.h> -#include <sys/cdefs.h> #include "un-namespace.h" #include "libc_private.h" #include "local.h" @@ -62,13 +61,13 @@ gets(char *buf) warned = 1; } for (s = buf; (c = __sgetc(stdin)) != '\n'; ) { - if (c == EOF) + if (c == EOF) { if (s == buf) { ret = NULL; goto end; } else break; - else + } else *s++ = c; } *s = 0; diff --git lib/libc/stdlib/quick_exit.3 lib/libc/stdlib/quick_exit.3 index fb1e346bb106..9d316c7e46ea 100644 --- lib/libc/stdlib/quick_exit.3 +++ lib/libc/stdlib/quick_exit.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 13, 2014 +.Dd November 4, 2017 .Dt QUICK_EXIT 3 .Os .Sh NAME @@ -44,6 +44,17 @@ with .Xr at_quick_exit 3 but not any C++ destructors or cleanup code registered with .Xr atexit 3 . +The +.Xr stdio 3 +file buffers are not flushed. +.Pp +The function +.Fn quick_exit +is +.Em async-signal safe +when the functions registered with +.Xr at_quick_exit 3 +are. .Sh RETURN VALUES The .Fn quick_exit diff --git lib/libc/stdlib/quick_exit.c lib/libc/stdlib/quick_exit.c index ef8cdb1b401a..4d81a35f5375 100644 --- lib/libc/stdlib/quick_exit.c +++ lib/libc/stdlib/quick_exit.c @@ -26,6 +26,8 @@ * $FreeBSD$ */ +#include <sys/types.h> +#include <machine/atomic.h> #include <stdlib.h> #include <pthread.h> @@ -60,6 +62,7 @@ at_quick_exit(void (*func)(void)) h->cleanup = func; pthread_mutex_lock(&atexit_mutex); h->next = handlers; + __compiler_membar(); handlers = h; pthread_mutex_unlock(&atexit_mutex); return (0); @@ -74,7 +77,9 @@ quick_exit(int status) * XXX: The C++ spec requires us to call std::terminate if there is an * exception here. */ - for (h = handlers; NULL != h; h = h->next) + for (h = handlers; NULL != h; h = h->next) { + __compiler_membar(); h->cleanup(); + } _Exit(status); } diff --git lib/libc/sys/Makefile.inc lib/libc/sys/Makefile.inc index a5e7e04597d0..c1237cdab68f 100644 --- lib/libc/sys/Makefile.inc +++ lib/libc/sys/Makefile.inc @@ -124,7 +124,7 @@ SYM_MAPS+= ${LIBC_SRCTOP}/sys/Symbol.map CLEANFILES+= ${SASM} ${SPSEUDO} .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" || \ - ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_ARCH:Marmv6*} + ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_ARCH:Marmv[67]*} NOTE_GNU_STACK='\t.section .note.GNU-stack,"",%%progbits\n' .else NOTE_GNU_STACK='' diff --git lib/libc/sys/aio_suspend.2 lib/libc/sys/aio_suspend.2 index 0ff25f51c5ab..be6d7e1bbbb9 100644 --- lib/libc/sys/aio_suspend.2 +++ lib/libc/sys/aio_suspend.2 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 2, 1999 +.Dd Oct 23, 2017 .Dt AIO_SUSPEND 2 .Os .Sh NAME @@ -85,10 +85,10 @@ expired before any I/O requests completed. The .Fa iocbs argument -contains more than -.Dv AIO_LISTIO_MAX -asynchronous I/O requests, or at least one of the requests is not -valid. +contains more asynchronous I/O requests than the +.Va vfs.aio.max_aio_queue_per_proc +.Xr sysctl 8 +variable, or at least one of the requests is not valid. .It Bq Er EINTR the suspend was interrupted by a signal. .El diff --git lib/libc/sys/lio_listio.2 lib/libc/sys/lio_listio.2 index ae228f7e2d8f..abc9f0c979c9 100644 --- lib/libc/sys/lio_listio.2 +++ lib/libc/sys/lio_listio.2 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 15, 2016 +.Dd Oct 23, 2017 .Dt LIO_LISTIO 2 .Os .Sh NAME @@ -161,7 +161,7 @@ function will fail if: There are not enough resources to enqueue the requests. .It Bq Er EAGAIN The request would cause the system-wide limit -.Dv AIO_MAX +.Dv {AIO_MAX} to be exceeded. .It Bq Er EINVAL The @@ -173,7 +173,7 @@ nor or .Fa nent is greater than -.Dv AIO_LISTIO_MAX . +.Dv {AIO_LISTIO_MAX} . .It Bq Er EINVAL The asynchronous notification method in .Fa sig->sigev_notify diff --git lib/libc/sys/open.2 lib/libc/sys/open.2 index 69274c00a729..7aeb286aaaea 100644 --- lib/libc/sys/open.2 +++ lib/libc/sys/open.2 @@ -28,7 +28,7 @@ .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" $FreeBSD$ .\" -.Dd November 22, 2016 +.Dd September 15, 2017 .Dt OPEN 2 .Os .Sh NAME @@ -487,7 +487,9 @@ is specified and the process is in capability mode. was called and the process is in capability mode. .It Bq Er ENOTCAPABLE .Fa path -is an absolute path or contained "..". +is an absolute path or contained a ".." component leading to a +directory outside of the directory hierarchy specified by +.Fa fd . .El .Sh SEE ALSO .Xr chmod 2 , diff --git lib/libc/sys/posix_fallocate.2 lib/libc/sys/posix_fallocate.2 index 0fe635541334..4fba3dd87611 100644 --- lib/libc/sys/posix_fallocate.2 +++ lib/libc/sys/posix_fallocate.2 @@ -28,7 +28,7 @@ .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" $FreeBSD$ .\" -.Dd January 23, 2014 +.Dd November 4, 2017 .Dt POSIX_FALLOCATE 2 .Os .Sh NAME @@ -106,9 +106,10 @@ A signal was caught during execution. .It Bq Er EINVAL The .Fa len -argument was less than or equal to zero or the +argument was less than or equal to zero, the .Fa offset -argument was less than zero. +argument was less than zero, +or the operation is not supported by the file system. .It Bq Er EIO An I/O error occurred while reading from or writing to a file system. .It Bq Er ENODEV @@ -118,6 +119,10 @@ argument does not refer to a regular file. .It Bq Er ENOSPC There is insufficient free space remaining on the file system storage media. +.It Bq Er ENOTCAPABLE +The file descriptor +.Fa fd +has insufficient rights. .It Bq Er ESPIPE The .Fa fd diff --git lib/libc/sys/ptrace.2 lib/libc/sys/ptrace.2 index b8968ebaa3da..d1dac69e641c 100644 --- lib/libc/sys/ptrace.2 +++ lib/libc/sys/ptrace.2 @@ -2,7 +2,7 @@ .\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $ .\" .\" This file is in the public domain. -.Dd June 11, 2017 +.Dd September 14, 2017 .Dt PTRACE 2 .Os .Sh NAME @@ -762,6 +762,28 @@ The .Fa data argument is ignored. .El +.Sh ARM MACHINE-SPECIFIC REQUESTS +.Bl -tag -width "Dv PT_SETVFPREGS" +.It Dv PT_GETVFPREGS +Return the thread's +.Dv VFP +machine state in the buffer pointed to by +.Fa addr . +.Pp +The +.Fa data +argument is ignored. +.It Dv PT_SETVFPREGS +Set the thread's +.Dv VFP +machine state from the buffer pointed to by +.Fa addr . +.Pp +The +.Fa data +argument is ignored. +.El +.Pp .Sh x86 MACHINE-SPECIFIC REQUESTS .Bl -tag -width "Dv PT_GETXSTATE_INFO" .It Dv PT_GETXMMREGS diff --git lib/libc/sys/reboot.2 lib/libc/sys/reboot.2 index 6805ceddceff..3629070c60d1 100644 --- lib/libc/sys/reboot.2 +++ lib/libc/sys/reboot.2 @@ -28,7 +28,7 @@ .\" @(#)reboot.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd September 18, 2015 +.Dd October 24, 2017 .Dt REBOOT 2 .Os .Sh NAME @@ -84,6 +84,14 @@ for more information. .It Dv RB_HALT The processor is simply halted; no reboot takes place. This option should be used with caution. +.It Dv RB_POWERCYCLE +After halting, the shutdown code will do what it can to turn +off the power and then turn the power back on. +This requires hardware support, usually an auxiliary microprocessor +that can sequence the power supply. +At present only the +.Xr ipmi 4 +driver implements this feature. .It Dv RB_POWEROFF After halting, the shutdown code will do what it can to turn off the power. diff --git lib/libc/sys/recv.2 lib/libc/sys/recv.2 index 1b83eaf273f6..a8095578b28d 100644 --- lib/libc/sys/recv.2 +++ lib/libc/sys/recv.2 @@ -28,7 +28,7 @@ .\" @(#)recv.2 8.3 (Berkeley) 2/21/94 .\" $FreeBSD$ .\" -.Dd February 3, 2017 +.Dd October 3, 2017 .Dt RECV 2 .Os .Sh NAME @@ -230,7 +230,7 @@ Here .Fa msg_name and .Fa msg_namelen -specify the destination address if the socket is unconnected; +specify the source address if the socket is unconnected; .Fa msg_name may be given as a null pointer if no names are desired or required. The diff --git lib/libc/sys/rename.2 lib/libc/sys/rename.2 index 9ba29e3d639a..2ca04a81b4b3 100644 --- lib/libc/sys/rename.2 +++ lib/libc/sys/rename.2 @@ -28,7 +28,7 @@ .\" @(#)rename.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd April 10, 2008 +.Dd September 15, 2017 .Dt RENAME 2 .Os .Sh NAME @@ -252,6 +252,9 @@ The .Fa to argument is a directory and is not empty. +.It Bq Er ECAPMODE +.Fn rename +was called and the process is in capability mode. .El .Pp In addition to the errors returned by the @@ -288,6 +291,26 @@ argument is not an absolute path and is neither .Dv AT_FDCWD nor a file descriptor associated with a directory. +.It Bq Er ECAPMODE +.Dv AT_FDCWD +is specified and the process is in capability mode. +.It Bq Er ENOTCAPABLE +.Fa path +is an absolute path or contained a ".." component leading to a directory +outside of the directory hierarchy specified by +.Fa fromfd +or +.Fa tofd . +.It Bq Er ENOTCAPABLE +The +.Fa fromfd +file descriptor lacks the +.Dv CAP_RENAMEAT_SOURCE +right, or the +.Fa tofd +file descriptor lacks the +.Dv CAP_RENAMEAT_TARGET +right. .El .Sh SEE ALSO .Xr chflags 2 , diff --git lib/libc/sys/write.2 lib/libc/sys/write.2 index 823201362f28..9d469b5e9f00 100644 --- lib/libc/sys/write.2 +++ lib/libc/sys/write.2 @@ -28,7 +28,7 @@ .\" @(#)write.2 8.5 (Berkeley) 4/2/94 .\" $FreeBSD$ .\" -.Dd December 15, 2015 +.Dd October 16, 2017 .Dt WRITE 2 .Os .Sh NAME @@ -199,7 +199,12 @@ to enable writing on the disk label area. The value .Fa nbytes is greater than -.Dv INT_MAX . +.Dv SSIZE_MAX +(or greater than +.Dv INT_MAX , +if the sysctl +.Va debug.iosize_max_clamp +is non-zero). .El .Pp In addition, diff --git lib/libc/tests/c063/Makefile.depend lib/libc/tests/c063/Makefile.depend index e8ee295f115a..10e58b789640 100644 --- lib/libc/tests/c063/Makefile.depend +++ lib/libc/tests/c063/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/db/Makefile.depend lib/libc/tests/db/Makefile.depend index 3646e2e2b1af..10e58b789640 100644 --- lib/libc/tests/db/Makefile.depend +++ lib/libc/tests/db/Makefile.depend @@ -3,12 +3,13 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ + lib/atf/libatf-c \ lib/libc \ lib/libcompiler_rt \ + lib/libnetbsd \ .include <dirdeps.mk> diff --git lib/libc/tests/gen/Makefile lib/libc/tests/gen/Makefile index 6685552a139b..bd00cd2ddd6f 100644 --- lib/libc/tests/gen/Makefile +++ lib/libc/tests/gen/Makefile @@ -8,6 +8,7 @@ ATF_TESTS_C+= fmtmsg_test ATF_TESTS_C+= fnmatch2_test ATF_TESTS_C+= fpclassify2_test ATF_TESTS_C+= ftw_test +ATF_TESTS_C+= getmntinfo_test ATF_TESTS_C+= glob2_test ATF_TESTS_C+= popen_test ATF_TESTS_C+= posix_spawn_test diff --git lib/libc/tests/gen/Makefile.depend lib/libc/tests/gen/Makefile.depend index 7826828c8155..a359c100b4e2 100644 --- lib/libc/tests/gen/Makefile.depend +++ lib/libc/tests/gen/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/gen/execve/Makefile.depend lib/libc/tests/gen/execve/Makefile.depend index e8ee295f115a..10e58b789640 100644 --- lib/libc/tests/gen/execve/Makefile.depend +++ lib/libc/tests/gen/execve/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/gen/getmntinfo_test.c lib/libc/tests/gen/getmntinfo_test.c new file mode 100644 index 000000000000..183fa84ed0e6 --- /dev/null +++ lib/libc/tests/gen/getmntinfo_test.c @@ -0,0 +1,86 @@ +/*- + * Copyright (c) 2017 Conrad Meyer <cem@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Limited test program for getmntinfo(3), a non-standard BSDism. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/mount.h> +#include <sys/ucred.h> + +#include <errno.h> + +#include <atf-c.h> + +static void +check_mntinfo(struct statfs *mntinfo, int n) +{ + int i; + + for (i = 0; i < n; i++) { + ATF_REQUIRE_MSG(mntinfo[i].f_version == STATFS_VERSION, "%ju", + (uintmax_t)mntinfo[i].f_version); + ATF_REQUIRE(mntinfo[i].f_namemax <= sizeof(mntinfo[0].f_mntonname)); + } +} + +ATF_TC_WITHOUT_HEAD(getmntinfo_test); +ATF_TC_BODY(getmntinfo_test, tc) +{ + int nmnts; + struct statfs *mntinfo; + + /* Test bogus mode */ + nmnts = getmntinfo(&mntinfo, 199); + ATF_REQUIRE_MSG(nmnts == 0 && errno == EINVAL, + "getmntinfo() succeeded; errno=%d", errno); + + /* Valid modes */ + nmnts = getmntinfo(&mntinfo, MNT_NOWAIT); + ATF_REQUIRE_MSG(nmnts != 0, "getmntinfo(MNT_NOWAIT) failed; errno=%d", + errno); + + check_mntinfo(mntinfo, nmnts); + memset(mntinfo, 0xdf, sizeof(*mntinfo) * nmnts); + + nmnts = getmntinfo(&mntinfo, MNT_WAIT); + ATF_REQUIRE_MSG(nmnts != 0, "getmntinfo(MNT_WAIT) failed; errno=%d", + errno); + + check_mntinfo(mntinfo, nmnts); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, getmntinfo_test); + + return (atf_no_error()); +} diff --git lib/libc/tests/gen/posix_spawn/Makefile.depend lib/libc/tests/gen/posix_spawn/Makefile.depend index e8ee295f115a..10e58b789640 100644 --- lib/libc/tests/gen/posix_spawn/Makefile.depend +++ lib/libc/tests/gen/posix_spawn/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/hash/Makefile.depend lib/libc/tests/hash/Makefile.depend index b1a491e414cc..81f787db80e9 100644 --- lib/libc/tests/hash/Makefile.depend +++ lib/libc/tests/hash/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git usr.bin/catman/Makefile.depend lib/libc/tests/iconv/Makefile.depend similarity index 93% rename from usr.bin/catman/Makefile.depend rename to lib/libc/tests/iconv/Makefile.depend index 3646e2e2b1af..c062f6026d94 100644 --- usr.bin/catman/Makefile.depend +++ lib/libc/tests/iconv/Makefile.depend @@ -3,10 +3,10 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ + lib/atf/libatf-c \ lib/libc \ lib/libcompiler_rt \ diff --git lib/libc/tests/inet/Makefile.depend lib/libc/tests/inet/Makefile.depend index 08e76dc00e2a..4be488723cf3 100644 --- lib/libc/tests/inet/Makefile.depend +++ lib/libc/tests/inet/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libc/tests/locale/Makefile.depend lib/libc/tests/locale/Makefile.depend index 68a9dd09c55e..45823695c1bb 100644 --- lib/libc/tests/locale/Makefile.depend +++ lib/libc/tests/locale/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/net/Makefile.depend lib/libc/tests/net/Makefile.depend index 949a9f66ea92..22a01a72015a 100644 --- lib/libc/tests/net/Makefile.depend +++ lib/libc/tests/net/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/nss/Makefile.depend lib/libc/tests/nss/Makefile.depend index 4d038059d9d9..d313b17d4486 100644 --- lib/libc/tests/nss/Makefile.depend +++ lib/libc/tests/nss/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/rpc \ diff --git lib/libc/tests/regex/Makefile.depend lib/libc/tests/regex/Makefile.depend index 5212dd0e39f5..1b5e74fae1b0 100644 --- lib/libc/tests/regex/Makefile.depend +++ lib/libc/tests/regex/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/resolv/Makefile.depend lib/libc/tests/resolv/Makefile.depend index 505fe5ac3403..c3293e1c797c 100644 --- lib/libc/tests/resolv/Makefile.depend +++ lib/libc/tests/resolv/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/rpc/Makefile.depend lib/libc/tests/rpc/Makefile.depend index 7cd75155dd46..ad95e3223964 100644 --- lib/libc/tests/rpc/Makefile.depend +++ lib/libc/tests/rpc/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/rpc \ include/xlocale \ diff --git lib/libc/tests/setjmp/Makefile.depend lib/libc/tests/setjmp/Makefile.depend index e8ee295f115a..10e58b789640 100644 --- lib/libc/tests/setjmp/Makefile.depend +++ lib/libc/tests/setjmp/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/ssp/Makefile.depend lib/libc/tests/ssp/Makefile.depend index bb203f1bf8c2..cf65fef9f923 100644 --- lib/libc/tests/ssp/Makefile.depend +++ lib/libc/tests/ssp/Makefile.depend @@ -3,11 +3,11 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ + lib/libclang_rt/ubsan_standalone.host \ lib/libcompiler_rt \ lib/librt \ lib/libthr \ diff --git lib/libc/tests/stdio/Makefile.depend lib/libc/tests/stdio/Makefile.depend index 68a9dd09c55e..45823695c1bb 100644 --- lib/libc/tests/stdio/Makefile.depend +++ lib/libc/tests/stdio/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/stdlib/Makefile.depend lib/libc/tests/stdlib/Makefile.depend index 1ace922e7b2a..7332c13b1b62 100644 --- lib/libc/tests/stdlib/Makefile.depend +++ lib/libc/tests/stdlib/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/string/Makefile.depend lib/libc/tests/string/Makefile.depend index fbc70c89a626..8e6506e2f706 100644 --- lib/libc/tests/string/Makefile.depend +++ lib/libc/tests/string/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/sys/Makefile.depend lib/libc/tests/sys/Makefile.depend index ae11679ef381..0e9a9cda6452 100644 --- lib/libc/tests/sys/Makefile.depend +++ lib/libc/tests/sys/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libc/tests/termios/Makefile.depend lib/libc/tests/termios/Makefile.depend index e8ee295f115a..10e58b789640 100644 --- lib/libc/tests/termios/Makefile.depend +++ lib/libc/tests/termios/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/time/Makefile.depend lib/libc/tests/time/Makefile.depend index e8ee295f115a..10e58b789640 100644 --- lib/libc/tests/time/Makefile.depend +++ lib/libc/tests/time/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/tls/Makefile.depend lib/libc/tests/tls/Makefile.depend index 933417c3fdd8..eae2edfd9e27 100644 --- lib/libc/tests/tls/Makefile.depend +++ lib/libc/tests/tls/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libc/tests/tls/dso/Makefile.depend lib/libc/tests/tls/dso/Makefile.depend new file mode 100644 index 000000000000..c062f6026d94 --- /dev/null +++ lib/libc/tests/tls/dso/Makefile.depend @@ -0,0 +1,18 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/atf/libatf-c \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git lib/libc/tests/tls_dso/Makefile.depend lib/libc/tests/tls_dso/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- lib/libc/tests/tls_dso/Makefile.depend +++ lib/libc/tests/tls_dso/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git lib/libc/tests/ttyio/Makefile.depend lib/libc/tests/ttyio/Makefile.depend index 5212dd0e39f5..1b5e74fae1b0 100644 --- lib/libc/tests/ttyio/Makefile.depend +++ lib/libc/tests/ttyio/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libcalendar/Makefile.depend lib/libcalendar/Makefile.depend index 9cb890b58360..cae7e645ef6a 100644 --- lib/libcalendar/Makefile.depend +++ lib/libcalendar/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git lib/libcam/Makefile.depend lib/libcam/Makefile.depend index 6002005509a1..cfec878c09d0 100644 --- lib/libcam/Makefile.depend +++ lib/libcam/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libcam/tests/Makefile.depend lib/libcam/tests/Makefile.depend new file mode 100644 index 000000000000..1054fb20686a --- /dev/null +++ lib/libcam/tests/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/atf/libatf-c \ + lib/libc \ + lib/libcam \ + lib/libcompiler_rt \ + lib/libsbuf \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git lib/libcapsicum/capsicum_helpers.h lib/libcapsicum/capsicum_helpers.h index 69a32cf8dcba..1ff2b3587cb1 100644 --- lib/libcapsicum/capsicum_helpers.h +++ lib/libcapsicum/capsicum_helpers.h @@ -50,7 +50,8 @@ caph_limit_stream(int fd, int flags) cap_rights_t rights; unsigned long cmds[] = { TIOCGETA, TIOCGWINSZ, FIODTYPE }; - cap_rights_init(&rights, CAP_FCNTL, CAP_FSTAT, CAP_IOCTL); + cap_rights_init(&rights, CAP_EVENT, CAP_FCNTL, CAP_FSTAT, + CAP_IOCTL, CAP_SEEK); if ((flags & CAPH_READ) != 0) cap_rights_set(&rights, CAP_READ); diff --git lib/libcasper/Makefile.inc lib/libcasper/Makefile.inc index 265f86d1ed55..d6baedd2ed8e 100644 --- lib/libcasper/Makefile.inc +++ lib/libcasper/Makefile.inc @@ -1,3 +1,9 @@ # $FreeBSD$ +.include <src.opts.mk> + +.if ${MK_CASPER} != "no" +CFLAGS+=-DWITH_CASPER +.endif + .include "../Makefile.inc" diff --git lib/libcasper/libcasper/Makefile lib/libcasper/libcasper/Makefile index c8eface43627..65d8271da788 100644 --- lib/libcasper/libcasper/Makefile +++ lib/libcasper/libcasper/Makefile @@ -1,16 +1,21 @@ # $FreeBSD$ -PACKAGE=${LIB} -LIB= casper +SHLIBDIR?= /lib + +.include <src.opts.mk> +PACKAGE=casper + +.if ${MK_CASPER} != "no" +SHLIB= casper SHLIB_MAJOR= 0 -SHLIBDIR?= /lib SRCS= libcasper.c SRCS+= libcasper_impl.c SRCS+= libcasper_service.c SRCS+= service.c SRCS+= zygote.c +.endif INCS= libcasper.h INCS+= libcasper_service.h diff --git lib/libcasper/libcasper/Makefile.depend lib/libcasper/libcasper/Makefile.depend index 4f7989bd2e64..25c2f4a9c8f2 100644 --- lib/libcasper/libcasper/Makefile.depend +++ lib/libcasper/libcasper/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libcasper/libcasper/libcasper.3 lib/libcasper/libcasper/libcasper.3 index 4433b648d514..c7beb300e144 100644 --- lib/libcasper/libcasper/libcasper.3 +++ lib/libcasper/libcasper/libcasper.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 5, 2016 +.Dd October 29, 2017 .Dt LIBCASPER 3 .Os .Sh NAME @@ -47,8 +47,8 @@ .Sh LIBRARY .Lb libcasper .Sh SYNOPSIS +.In sys/nv.h .In libcasper.h -.In nv.h .Ft "cap_channel_t *" .Fn cap_init "void" .Ft "cap_channel_t *" diff --git lib/libcasper/libcasper/libcasper.h lib/libcasper/libcasper/libcasper.h index 2d6f15825a39..a49561bcbd81 100644 --- lib/libcasper/libcasper/libcasper.h +++ lib/libcasper/libcasper/libcasper.h @@ -1,6 +1,6 @@ /*- * Copyright (c) 2012-2013 The FreeBSD Foundation - * Copyright (c) 2015 Mariusz Zaborski <oshogbo@FreeBSD.org> + * Copyright (c) 2015-2017 Mariusz Zaborski <oshogbo@FreeBSD.org> * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -33,7 +33,15 @@ #ifndef _LIBCASPER_H_ #define _LIBCASPER_H_ +#ifdef HAVE_CASPER +#define WITH_CASPER +#endif + #include <sys/types.h> +#include <sys/nv.h> + +#include <stdlib.h> +#include <unistd.h> #ifndef _NVLIST_T_DECLARED #define _NVLIST_T_DECLARED @@ -44,72 +52,191 @@ typedef struct nvlist nvlist_t; #ifndef _CAP_CHANNEL_T_DECLARED #define _CAP_CHANNEL_T_DECLARED +#ifdef WITH_CASPER struct cap_channel; typedef struct cap_channel cap_channel_t; -#endif +#else +struct cap_channel { + int cch_fd; +}; +typedef struct cap_channel cap_channel_t; +#endif /* ! WITH_CASPER */ +#endif /* ! _CAP_CHANNEL_T_DECLARED */ /* * The functions opens unrestricted communication channel to Casper. */ +#ifdef WITH_CASPER cap_channel_t *cap_init(void); +#else +static inline cap_channel_t * +cap_init(void) +{ + cap_channel_t *chan; + + chan = malloc(sizeof(*chan)); + if (chan != NULL) { + chan->cch_fd = -1; + } + return (chan); +} +#endif /* * The functions to communicate with service. */ +#ifdef WITH_CASPER cap_channel_t *cap_service_open(const cap_channel_t *chan, const char *name); int cap_service_limit(const cap_channel_t *chan, const char * const *names, size_t nnames); +#else +#define cap_service_open(chan, name) (cap_init()) +#define cap_service_limit(chan, names, nnames) (0) +#endif /* * The function creates cap_channel_t based on the given socket. */ +#ifdef WITH_CASPER cap_channel_t *cap_wrap(int sock); +#else +static inline cap_channel_t * +cap_wrap(int sock) +{ + cap_channel_t *chan; + + chan = cap_init(); + if (chan != NULL) { + chan->cch_fd = sock; + } + return (chan); +} +#endif /* * The function returns communication socket and frees cap_channel_t. */ +#ifdef WITH_CASPER int cap_unwrap(cap_channel_t *chan); +#else +#define cap_unwrap(chan) (chan->cch_fd) +#endif /* * The function clones the given capability. */ +#ifdef WITH_CASPER cap_channel_t *cap_clone(const cap_channel_t *chan); +#else +static inline cap_channel_t * +cap_clone(const cap_channel_t *chan) +{ + cap_channel_t *newchan; + + newchan = cap_init(); + if (newchan == NULL) { + return (NULL); + } + + if (chan->cch_fd == -1) { + newchan->cch_fd = -1; + } else { + newchan->cch_fd = dup(chan->cch_fd); + if (newchan->cch_fd < 0) { + free(newchan); + newchan = NULL; + } + } + + return (newchan); +} +#endif /* * The function closes the given capability. */ +#ifdef WITH_CASPER void cap_close(cap_channel_t *chan); +#else +static inline void +cap_close(cap_channel_t *chan) +{ + + if (chan->cch_fd >= 0) { + close(chan->cch_fd); + } + free(chan); +} +#endif /* * The function returns socket descriptor associated with the given * cap_channel_t for use with select(2)/kqueue(2)/etc. */ +#ifdef WITH_CASPER int cap_sock(const cap_channel_t *chan); +#else +#define cap_sock(chan) (chan->cch_fd) +#endif /* * The function limits the given capability. * It always destroys 'limits' on return. */ +#ifdef WITH_CASPER int cap_limit_set(const cap_channel_t *chan, nvlist_t *limits); +#else +#define cap_limit_set(chan, limits) (0) +#endif /* * The function returns current limits of the given capability. */ +#ifdef WITH_CASPER int cap_limit_get(const cap_channel_t *chan, nvlist_t **limitsp); +#else +static inline int +cap_limit_get(const cap_channel_t *chan __unused, nvlist_t **limitsp) +{ + + *limitsp = nvlist_create(0); + return (0); +} +#endif /* * Function sends nvlist over the given capability. */ +#ifdef WITH_CASPER int cap_send_nvlist(const cap_channel_t *chan, const nvlist_t *nvl); +#else +#define cap_send_nvlist(chan, nvl) (0) +#endif + /* * Function receives nvlist over the given capability. */ +#ifdef WITH_CASPER nvlist_t *cap_recv_nvlist(const cap_channel_t *chan, int flags); +#else +#define cap_recv_nvlist(chan, flags) (0) +#endif + /* * Function sends the given nvlist, destroys it and receives new nvlist in * response over the given capability. */ +#ifdef WITH_CASPER nvlist_t *cap_xfer_nvlist(const cap_channel_t *chan, nvlist_t *nvl, int flags); +#else +static inline nvlist_t * +cap_xfer_nvlist(const cap_channel_t *chan __unused, nvlist_t *nvl, int flags) +{ + + nvlist_destroy(nvl); + return (nvlist_create(flags)); +} +#endif #endif /* !_LIBCASPER_H_ */ diff --git lib/libcasper/services/Makefile lib/libcasper/services/Makefile index 3eeac69d9857..d14f34d5a3c3 100644 --- lib/libcasper/services/Makefile +++ lib/libcasper/services/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +.include <src.opts.mk> + SUBDIR= cap_dns SUBDIR+= cap_grp SUBDIR+= cap_pwd diff --git lib/libcasper/services/cap_dns/Makefile lib/libcasper/services/cap_dns/Makefile index 4f89b0270ca3..e89be7f5396d 100644 --- lib/libcasper/services/cap_dns/Makefile +++ lib/libcasper/services/cap_dns/Makefile @@ -5,12 +5,15 @@ SHLIBDIR?= /lib/casper .include <src.opts.mk> PACKAGE=libcasper -LIB= cap_dns SHLIB_MAJOR= 0 INCSDIR?= ${INCLUDEDIR}/casper +.if ${MK_CASPER} != "no" +SHLIB= cap_dns + SRCS= cap_dns.c +.endif INCS= cap_dns.h diff --git lib/libcasper/services/cap_dns/Makefile.depend lib/libcasper/services/cap_dns/Makefile.depend index fcd81696889c..a293d0a10b77 100644 --- lib/libcasper/services/cap_dns/Makefile.depend +++ lib/libcasper/services/cap_dns/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libcasper/services/cap_dns/cap_dns.h lib/libcasper/services/cap_dns/cap_dns.h index ea3754255286..d9d12bfd2c49 100644 --- lib/libcasper/services/cap_dns/cap_dns.h +++ lib/libcasper/services/cap_dns/cap_dns.h @@ -32,11 +32,16 @@ #ifndef _CAP_DNS_H_ #define _CAP_DNS_H_ +#ifdef HAVE_CASPER +#define WITH_CASPER +#endif + #include <sys/socket.h> /* socklen_t */ struct addrinfo; struct hostent; +#ifdef WITH_CASPER struct hostent *cap_gethostbyname(cap_channel_t *chan, const char *name); struct hostent *cap_gethostbyname2(cap_channel_t *chan, const char *name, int type); @@ -53,5 +58,18 @@ int cap_dns_type_limit(cap_channel_t *chan, const char * const *types, size_t ntypes); int cap_dns_family_limit(cap_channel_t *chan, const int *families, size_t nfamilies); +#else +#define cap_gethostbyname(chan, name) gethostbyname(name) +#define cap_gethostbyname2(chan, name, type) gethostbyname2(name, type) +#define cap_gethostbyaddr(chan, addr, len, type) gethostbyaddr(addr, len, type) + +#define cap_getaddrinfo(chan, hostname, servname, hints, res) \ + getaddrinfo(hostname, servname, hints, res) +#define cap_getnameinfo(chan, sa, salen, host, hostlen, serv, servlen, flags) \ + getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) + +#define cap_dns_type_limit(chan, types, ntypes) (0) +#define cap_dns_family_limit(chan, families, nfamilies) (0) +#endif #endif /* !_CAP_DNS_H_ */ diff --git lib/libcasper/services/cap_dns/tests/Makefile lib/libcasper/services/cap_dns/tests/Makefile index 38af7117fe2f..20049a06ccb7 100644 --- lib/libcasper/services/cap_dns/tests/Makefile +++ lib/libcasper/services/cap_dns/tests/Makefile @@ -1,9 +1,13 @@ # $FreeBSD$ +.include <src.opts.mk> + TAP_TESTS_C= dns_test +.if ${MK_CASPER} != "no" LIBADD+= casper LIBADD+= cap_dns +.endif LIBADD+= nv WARNS?= 3 diff --git libexec/rlogind/Makefile.depend lib/libcasper/services/cap_dns/tests/Makefile.depend similarity index 79% rename from libexec/rlogind/Makefile.depend rename to lib/libcasper/services/cap_dns/tests/Makefile.depend index 5ac9545f6f12..ab0b691a1299 100644 --- libexec/rlogind/Makefile.depend +++ lib/libcasper/services/cap_dns/tests/Makefile.depend @@ -3,16 +3,15 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ lib/${CSU_DIR} \ - lib/libblacklist \ lib/libc \ + lib/libcasper/libcasper \ + lib/libcasper/services/cap_dns \ lib/libcompiler_rt \ - lib/libthr \ - lib/libutil \ + lib/libnv \ .include <dirdeps.mk> diff --git lib/libcasper/services/cap_dns/tests/dns_test.c lib/libcasper/services/cap_dns/tests/dns_test.c index 0629869c69b2..66469604afa0 100644 --- lib/libcasper/services/cap_dns/tests/dns_test.c +++ lib/libcasper/services/cap_dns/tests/dns_test.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include <sys/capsicum.h> +#include <sys/nv.h> #include <arpa/inet.h> #include <netinet/in.h> diff --git lib/libcasper/services/cap_grp/Makefile lib/libcasper/services/cap_grp/Makefile index 5fba3d2ba7b0..5b464774f9f5 100644 --- lib/libcasper/services/cap_grp/Makefile +++ lib/libcasper/services/cap_grp/Makefile @@ -5,12 +5,15 @@ SHLIBDIR?= /lib/casper .include <src.opts.mk> PACKAGE=libcasper -LIB= cap_grp SHLIB_MAJOR= 0 INCSDIR?= ${INCLUDEDIR}/casper +.if ${MK_CASPER} != "no" +SHLIB= cap_grp + SRCS= cap_grp.c +.endif INCS= cap_grp.h diff --git lib/libcasper/services/cap_grp/Makefile.depend lib/libcasper/services/cap_grp/Makefile.depend index fcd81696889c..a293d0a10b77 100644 --- lib/libcasper/services/cap_grp/Makefile.depend +++ lib/libcasper/services/cap_grp/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libcasper/services/cap_grp/cap_grp.h lib/libcasper/services/cap_grp/cap_grp.h index 68595c145e23..7c109bcc199c 100644 --- lib/libcasper/services/cap_grp/cap_grp.h +++ lib/libcasper/services/cap_grp/cap_grp.h @@ -32,6 +32,11 @@ #ifndef _CAP_GRP_H_ #define _CAP_GRP_H_ +#ifdef HAVE_CASPER +#define WITH_CASPER +#endif + +#ifdef WITH_CASPER struct group *cap_getgrent(cap_channel_t *chan); struct group *cap_getgrnam(cap_channel_t *chan, const char *name); struct group *cap_getgrgid(cap_channel_t *chan, gid_t gid); @@ -53,5 +58,32 @@ int cap_grp_limit_fields(cap_channel_t *chan, const char * const *fields, size_t nfields); int cap_grp_limit_groups(cap_channel_t *chan, const char * const *names, size_t nnames, gid_t *gids, size_t ngids); +#else +#define cap_getgrent(chan) getgrent() +#define cap_getgrnam(chan, name) getgrnam(name) +#define cap_getgrgid(chan, gid) getgrgid(gid) + +#define cap_setgroupent(chan, stayopen) etgroupent(stayopen) +#define endgrent(chan) endgrent() +static inline int +cap_setgrent(cap_channel_t *chan __unused) +{ + + setgrent(); + return(0); +} + +#define cap_getgrent_r(chan, grp, buffer, bufsize, result) \ + getgrent_r(grp, buffer, bufsize, result) +#define cap_getgrnam_r(chan, name, grp, buffer, bufsize, result) \ + getgrnam_r(name, grp, buffer, bufsize, result) +#define cap_getgrgid_r(chan, gid, grp, buffer, bufsize, result) \ + getgrgid_r(gid, grp, buffer, bufsize, result) + +#define cap_grp_limit_cmds(chan, cmds, ncmds) (0) +#define cap_grp_limit_fields(chan, fields, nfields) (0) +#define cap_grp_limit_groups(chan, names, nnames, gids, ngids) (0) + +#endif #endif /* !_CAP_GRP_H_ */ diff --git lib/libcasper/services/cap_grp/tests/Makefile lib/libcasper/services/cap_grp/tests/Makefile index 656188513188..b1b7e05d0ee2 100644 --- lib/libcasper/services/cap_grp/tests/Makefile +++ lib/libcasper/services/cap_grp/tests/Makefile @@ -1,9 +1,13 @@ # $FreeBSD$ +.include <src.opts.mk> + TAP_TESTS_C= grp_test +.if ${MK_CASPER} != "no" LIBADD+= casper LIBADD+= cap_grp +.endif LIBADD+= nv WARNS?= 3 diff --git lib/libcasper/services/cap_grp/tests/Makefile.depend lib/libcasper/services/cap_grp/tests/Makefile.depend new file mode 100644 index 000000000000..92889dfb4269 --- /dev/null +++ lib/libcasper/services/cap_grp/tests/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcasper/libcasper \ + lib/libcasper/services/cap_grp \ + lib/libcompiler_rt \ + lib/libnv \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git lib/libcasper/services/cap_grp/tests/grp_test.c lib/libcasper/services/cap_grp/tests/grp_test.c index cdda7c6a4d70..05cf09e81ef8 100644 --- lib/libcasper/services/cap_grp/tests/grp_test.c +++ lib/libcasper/services/cap_grp/tests/grp_test.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include <sys/capsicum.h> +#include <sys/nv.h> #include <assert.h> #include <err.h> diff --git lib/libcasper/services/cap_pwd/Makefile lib/libcasper/services/cap_pwd/Makefile index e8c87d47b923..be4ae89181c7 100644 --- lib/libcasper/services/cap_pwd/Makefile +++ lib/libcasper/services/cap_pwd/Makefile @@ -5,12 +5,15 @@ SHLIBDIR?= /lib/casper .include <src.opts.mk> PACKAGE=libcasper -LIB= cap_pwd SHLIB_MAJOR= 0 INCSDIR?= ${INCLUDEDIR}/casper +.if ${MK_CASPER} != "no" +SHLIB= cap_pwd + SRCS= cap_pwd.c +.endif INCS= cap_pwd.h diff --git lib/libcasper/services/cap_pwd/Makefile.depend lib/libcasper/services/cap_pwd/Makefile.depend index fcd81696889c..a293d0a10b77 100644 --- lib/libcasper/services/cap_pwd/Makefile.depend +++ lib/libcasper/services/cap_pwd/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libcasper/services/cap_pwd/cap_pwd.h lib/libcasper/services/cap_pwd/cap_pwd.h index a75fba74f972..99b643174910 100644 --- lib/libcasper/services/cap_pwd/cap_pwd.h +++ lib/libcasper/services/cap_pwd/cap_pwd.h @@ -32,6 +32,11 @@ #ifndef _CAP_PWD_H_ #define _CAP_PWD_H_ +#ifdef HAVE_CASPER +#define WITH_CASPER +#endif + +#ifdef WITH_CASPER struct passwd *cap_getpwent(cap_channel_t *chan); struct passwd *cap_getpwnam(cap_channel_t *chan, const char *login); struct passwd *cap_getpwuid(cap_channel_t *chan, uid_t uid); @@ -53,5 +58,25 @@ int cap_pwd_limit_fields(cap_channel_t *chan, const char * const *fields, size_t nfields); int cap_pwd_limit_users(cap_channel_t *chan, const char * const *names, size_t nnames, uid_t *uids, size_t nuids); +#else +#define cap_getpwent(chan) getpwent() +#define cap_getpwnam(chan, login) getpwnam(login) +#define cap_getpwuid(chan, uid) getpwuid(uid) + +#define cap_getpwent_r(chan, pwd, buffer, bufsize, result) \ + getpwent_r(pwd, buffer, bufsize, result) +#define cap_getpwnam_r(chan, name, pwd, buffer, bufsize, result) \ + getpwnam_r(name, pwd, buffer, bufsize, result) +#define cap_getpwuid_r(chan, uid, pwd, buffer, bufsize, result) \ + getpwuid_r(uid, pwd, buffer, bufsize, result) + +#define cap_setpassent(chan, stayopen) setpassent(stayopen) +#define cap_setpwent(chan) setpwent() +#define cap_endpwent(chan) endpwent() + +#define cap_pwd_limit_cmds(chan, cmds, ncmds) (0) +#define cap_pwd_limit_fields(chan, fields, nfields) (0) +#define cap_pwd_limit_users(chan, names, nnames, uids, nuids) (0) +#endif #endif /* !_CAP_PWD_H_ */ diff --git lib/libcasper/services/cap_pwd/tests/Makefile lib/libcasper/services/cap_pwd/tests/Makefile index 8c88753e59d1..b4e75d346fc9 100644 --- lib/libcasper/services/cap_pwd/tests/Makefile +++ lib/libcasper/services/cap_pwd/tests/Makefile @@ -1,9 +1,13 @@ # $FreeBSD$ +.include <src.opts.mk> + TAP_TESTS_C= pwd_test +.if ${MK_CASPER} != "no" LIBADD+= casper LIBADD+= cap_pwd +.endif LIBADD+= nv WARNS?= 3 diff --git lib/libcasper/services/cap_pwd/tests/Makefile.depend lib/libcasper/services/cap_pwd/tests/Makefile.depend new file mode 100644 index 000000000000..d7db2fe99621 --- /dev/null +++ lib/libcasper/services/cap_pwd/tests/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcasper/libcasper \ + lib/libcasper/services/cap_pwd \ + lib/libcompiler_rt \ + lib/libnv \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git lib/libcasper/services/cap_pwd/tests/pwd_test.c lib/libcasper/services/cap_pwd/tests/pwd_test.c index e5764dba6305..a906788204fa 100644 --- lib/libcasper/services/cap_pwd/tests/pwd_test.c +++ lib/libcasper/services/cap_pwd/tests/pwd_test.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include <sys/capsicum.h> +#include <sys/nv.h> #include <assert.h> #include <err.h> diff --git lib/libcasper/services/cap_random/Makefile lib/libcasper/services/cap_random/Makefile index 97a27beb134a..fad8e3f9cdb7 100644 --- lib/libcasper/services/cap_random/Makefile +++ lib/libcasper/services/cap_random/Makefile @@ -1,13 +1,19 @@ # $FreeBSD$ +SHLIBDIR?= /lib/casper + +.include <src.opts.mk> + PACKAGE=libcasper -LIB= cap_random SHLIB_MAJOR= 0 -SHLIBDIR?= /lib/casper INCSDIR?= ${INCLUDEDIR}/casper +.if ${MK_CASPER} != "no" +SHLIB= cap_random + SRCS= cap_random.c +.endif INCS= cap_random.h diff --git lib/libcasper/services/cap_random/Makefile.depend lib/libcasper/services/cap_random/Makefile.depend index fcd81696889c..a293d0a10b77 100644 --- lib/libcasper/services/cap_random/Makefile.depend +++ lib/libcasper/services/cap_random/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libcasper/services/cap_random/cap_random.h lib/libcasper/services/cap_random/cap_random.h index 2039b5fe8460..2c37b9c618d4 100644 --- lib/libcasper/services/cap_random/cap_random.h +++ lib/libcasper/services/cap_random/cap_random.h @@ -32,6 +32,20 @@ #ifndef _CAP_RANDOM_H_ #define _CAP_RANDOM_H_ +#ifdef HAVE_CASPER +#define WITH_CASPER +#endif + +#ifdef WITH_CASPER int cap_random_buf(cap_channel_t *chan, void *buf, size_t nbytes); +#else +inline int +cap_random_buf(cap_channel_t *chan, void *buf, size_t nbytes) +{ + + arc4random_buf(buf, nbytes); + return(0); +} +#endif #endif /* !_CAP_RANDOM_H_ */ diff --git lib/libcasper/services/cap_sysctl/Makefile lib/libcasper/services/cap_sysctl/Makefile index 5b9960161932..14f2bd60cf97 100644 --- lib/libcasper/services/cap_sysctl/Makefile +++ lib/libcasper/services/cap_sysctl/Makefile @@ -5,12 +5,15 @@ SHLIBDIR?= /lib/casper .include <src.opts.mk> PACKAGE=libcasper -LIB= cap_sysctl SHLIB_MAJOR= 0 INCSDIR?= ${INCLUDEDIR}/casper +.if ${MK_CASPER} != "no" +SHLIB= cap_sysctl + SRCS= cap_sysctl.c +.endif INCS= cap_sysctl.h diff --git lib/libcasper/services/cap_sysctl/Makefile.depend lib/libcasper/services/cap_sysctl/Makefile.depend index fcd81696889c..a293d0a10b77 100644 --- lib/libcasper/services/cap_sysctl/Makefile.depend +++ lib/libcasper/services/cap_sysctl/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libcasper/services/cap_sysctl/cap_sysctl.h lib/libcasper/services/cap_sysctl/cap_sysctl.h index 2af6d2157695..6532874f2e94 100644 --- lib/libcasper/services/cap_sysctl/cap_sysctl.h +++ lib/libcasper/services/cap_sysctl/cap_sysctl.h @@ -32,12 +32,21 @@ #ifndef _CAP_SYSCTL_H_ #define _CAP_SYSCTL_H_ +#ifdef HAVE_CASPER +#define WITH_CASPER +#endif + #define CAP_SYSCTL_READ 0x01 #define CAP_SYSCTL_WRITE 0x02 #define CAP_SYSCTL_RDWR (CAP_SYSCTL_READ | CAP_SYSCTL_WRITE) #define CAP_SYSCTL_RECURSIVE 0x04 +#ifdef WITH_CASPER int cap_sysctlbyname(cap_channel_t *chan, const char *name, void *oldp, size_t *oldlenp, const void *newp, size_t newlen); +#else +#define cap_sysctlbyname(chan, name, oldp, oldlenp, newp, newlen) \ + sysctlbyname(name, oldp, oldlenp, newp, newlen) +#endif #endif /* !_CAP_SYSCTL_H_ */ diff --git lib/libcasper/services/cap_sysctl/tests/Makefile lib/libcasper/services/cap_sysctl/tests/Makefile index cd0f3bb5d749..b11c45fb6563 100644 --- lib/libcasper/services/cap_sysctl/tests/Makefile +++ lib/libcasper/services/cap_sysctl/tests/Makefile @@ -1,9 +1,13 @@ # $FreeBSD$ +.include <src.opts.mk> + TAP_TESTS_C= sysctl_test +.if ${MK_CASPER} != "no" LIBADD+= casper LIBADD+= cap_sysctl +.endif LIBADD+= nv WARNS?= 3 diff --git lib/libcasper/services/cap_sysctl/tests/Makefile.depend lib/libcasper/services/cap_sysctl/tests/Makefile.depend new file mode 100644 index 000000000000..81ebff999213 --- /dev/null +++ lib/libcasper/services/cap_sysctl/tests/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcasper/libcasper \ + lib/libcasper/services/cap_sysctl \ + lib/libcompiler_rt \ + lib/libnv \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git lib/libcasper/services/tests/Makefile.depend lib/libcasper/services/tests/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ lib/libcasper/services/tests/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git lib/libclang_rt/Makefile lib/libclang_rt/Makefile index ecd3910dff26..38fe9bd52fe2 100644 --- lib/libclang_rt/Makefile +++ lib/libclang_rt/Makefile @@ -1,11 +1,14 @@ # $FreeBSD$ +<<<<<<< HEAD .include <src.opts.mk> .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || \ ${MACHINE_CPUARCH} == "aarch64" SUBDIR+= include .endif +======= +>>>>>>> upstream/hardened/current/master .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" SUBDIR+= asan SUBDIR+= asan-preinit diff --git lib/libclang_rt/Makefile.inc lib/libclang_rt/Makefile.inc index f7687ef3376b..0f08d8054505 100644 --- lib/libclang_rt/Makefile.inc +++ lib/libclang_rt/Makefile.inc @@ -1,8 +1,14 @@ # $FreeBSD$ -.include <src.opts.mk> +.include <bsd.compiler.mk> -CRTARCH= ${MACHINE_CPUARCH:C/amd64/x86_64/} +# armv[67] is a bit special since we allow a soft-floating version via +# CPUTYPE matching *soft*. This variant is may not actually work though. +.if ${MACHINE_ARCH:Marmv[67]*} != "" && \ + (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") +CRTARCH= armhf +.endif +CRTARCH?= ${MACHINE_CPUARCH:C/amd64/x86_64/} CRTSRC= ${SRCTOP}/contrib/compiler-rt .PATH: ${CRTSRC}/lib @@ -20,13 +26,13 @@ CFLAGS+= -DNDEBUG CFLAGS+= ${PICFLAG} CFLAGS+= -fno-builtin CFLAGS+= -fno-exceptions -CFLAGS+= -fno-rtti -.if ${COMPILER_VERSION} >= 30700 +CXXFLAGS+= -fno-rtti +.if ${COMPILER_TYPE} == clang && ${COMPILER_VERSION} >= 30700 CFLAGS+= -fno-sanitize=safe-stack .endif CFLAGS+= -fno-stack-protector CFLAGS+= -funwind-tables -CFLAGS+= -fvisibility-inlines-hidden -CFLAGS+= -fvisibility=hidden +CXXFLAGS+= -fvisibility-inlines-hidden +CXXFLAGS+= -fvisibility=hidden CFLAGS+= -I${CRTSRC}/lib CXXFLAGS+= -std=c++11 diff --git lib/libclang_rt/asan_dynamic/Makefile.depend lib/libclang_rt/asan_dynamic/Makefile.depend index 98f4a5fec371..76b383a31c6e 100644 --- lib/libclang_rt/asan_dynamic/Makefile.depend +++ lib/libclang_rt/asan_dynamic/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libclang_rt/profile/Makefile lib/libclang_rt/profile/Makefile index f5860a69dd76..063f8bb11c36 100644 --- lib/libclang_rt/profile/Makefile +++ lib/libclang_rt/profile/Makefile @@ -5,7 +5,7 @@ LIB= clang_rt.profile-${CRTARCH} # This is needed for --coverage -CFLAGS+= -fvisibility=default +CXXFLAGS+= -fvisibility=default SRCS+= profile/GCDAProfiling.c SRCS+= profile/InstrProfiling.c diff --git lib/libcom_err/Makefile.depend lib/libcom_err/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libcom_err/Makefile.depend +++ lib/libcom_err/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libcompiler_rt/Makefile.inc lib/libcompiler_rt/Makefile.inc index 7a4da165913f..e568df37729a 100644 --- lib/libcompiler_rt/Makefile.inc +++ lib/libcompiler_rt/Makefile.inc @@ -57,18 +57,12 @@ SRCF+= fixunsxfsi SRCF+= fixunsxfti SRCF+= fixxfdi SRCF+= fixxfti -SRCF+= floatdidf -SRCF+= floatdisf SRCF+= floatditf -SRCF+= floatdixf SRCF+= floatsitf SRCF+= floattidf SRCF+= floattisf SRCF+= floattixf -SRCF+= floatundidf -SRCF+= floatundisf SRCF+= floatunditf -SRCF+= floatundixf SRCF+= floatunsidf SRCF+= floatunsisf SRCF+= floatuntidf @@ -128,6 +122,23 @@ SRCF+= umoddi3 SRCF+= umodsi3 SRCF+= umodti3 +# Avoid using SSE2 instructions on i386, if unsupported. +.if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2) +SRCS+= floatdidf.c +SRCS+= floatdisf.c +SRCS+= floatdixf.c +SRCS+= floatundidf.c +SRCS+= floatundisf.c +SRCS+= floatundixf.c +.else +SRCF+= floatdidf +SRCF+= floatdisf +SRCF+= floatdixf +SRCF+= floatundidf +SRCF+= floatundisf +SRCF+= floatundixf +.endif + # __cpu_model support, only used on x86 .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" SRCF+= cpu_model @@ -193,7 +204,7 @@ SRCF+= stdatomic .endif .for file in ${SRCF} -.if ${MACHINE_ARCH:Marmv6*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") \ +.if ${MACHINE_ARCH:Marmv[67]*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") \ && exists(${CRTSRC}/${CRTARCH}/${file}vfp.S) SRCS+= ${file}vfp.S . elif exists(${CRTSRC}/${CRTARCH}/${file}.S) diff --git lib/libcrypt/Makefile.depend lib/libcrypt/Makefile.depend index 54c1f6f1442e..d5ed563ecfc8 100644 --- lib/libcrypt/Makefile.depend +++ lib/libcrypt/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libcrypt/tests/Makefile.depend lib/libcrypt/tests/Makefile.depend index 2945c88dbc67..f9e5a947d4b2 100644 --- lib/libcrypt/tests/Makefile.depend +++ lib/libcrypt/tests/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libcuse/Makefile.depend lib/libcuse/Makefile.depend index 7b92dbd89f4a..8bb1973e0ff5 100644 --- lib/libcuse/Makefile.depend +++ lib/libcuse/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libcuse/cuse.3 lib/libcuse/cuse.3 index 6d8d2a3cd860..89eef889a8b6 100644 --- lib/libcuse/cuse.3 +++ lib/libcuse/cuse.3 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 6, 2014 +.Dd October 5, 2017 .Dt CUSE 3 .Os .Sh NAME @@ -292,6 +292,7 @@ enum { CUSE_ERR_SIGNAL CUSE_ERR_OTHER CUSE_ERR_NOT_LOADED + CUSE_ERR_NO_DEVICE CUSE_POLL_NONE CUSE_POLL_READ diff --git lib/libcxxrt/Makefile.depend lib/libcxxrt/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libcxxrt/Makefile.depend +++ lib/libcxxrt/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libcxxrt/Version.map lib/libcxxrt/Version.map index 39f98e371146..cef47b9dc6a3 100644 --- lib/libcxxrt/Version.map +++ lib/libcxxrt/Version.map @@ -377,9 +377,15 @@ GLIBCXX_3.4.9 { }; } GLIBCXX_3.4; +GLIBCXX_3.4.20 { + extern "C++" { + "std::get_new_handler()"; + }; +} GLIBCXX_3.4.9; + GLIBCXX_3.4.22 { extern "C++" { "std::uncaught_exceptions()"; }; -} GLIBCXX_3.4.9; +} GLIBCXX_3.4.20; diff --git lib/libdevctl/Makefile.depend lib/libdevctl/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libdevctl/Makefile.depend +++ lib/libdevctl/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libdevdctl/Makefile.depend lib/libdevdctl/Makefile.depend index b6027086c86c..ea8bba31ec06 100644 --- lib/libdevdctl/Makefile.depend +++ lib/libdevdctl/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libdevdctl/guid.h lib/libdevdctl/guid.h index ede414bec649..02ea6f27dc04 100644 --- lib/libdevdctl/guid.h +++ lib/libdevdctl/guid.h @@ -62,9 +62,13 @@ class Guid { public: /* Constructors */ + /* Default constructor: an Invalid guid */ Guid(); + /* Construct a guid from a provided integer */ Guid(uint64_t guid); + /* Construct a guid from a string in base 8, 10, or 16 */ Guid(const std::string &guid); + static Guid InvalidGuid(); /* Assignment */ Guid& operator=(const Guid& rhs); @@ -80,8 +84,9 @@ public: operator uint64_t() const; operator bool() const; - static const uint64_t INVALID_GUID = 0; protected: + static const uint64_t INVALID_GUID = 0; + /* The integer value of the GUID. */ uint64_t m_GUID; }; @@ -99,6 +104,12 @@ Guid::Guid(uint64_t guid) { } +inline Guid +Guid::InvalidGuid() +{ + return (Guid(INVALID_GUID)); +} + inline Guid& Guid::operator=(const Guid &rhs) { diff --git lib/libdevinfo/Makefile.depend lib/libdevinfo/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libdevinfo/Makefile.depend +++ lib/libdevinfo/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libdevstat/Makefile.depend lib/libdevstat/Makefile.depend index a1ac545aff09..dc18ed8c991a 100644 --- lib/libdevstat/Makefile.depend +++ lib/libdevstat/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libdl/Makefile.depend lib/libdl/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libdl/Makefile.depend +++ lib/libdl/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libdpv/Makefile.depend lib/libdpv/Makefile.depend index 7de4367f1fe9..76d78a21af4d 100644 --- lib/libdpv/Makefile.depend +++ lib/libdpv/Makefile.depend @@ -4,7 +4,6 @@ DIRDEPS = \ gnu/lib/csu \ gnu/lib/libdialog \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libdwarf/Makefile.depend lib/libdwarf/Makefile.depend index b76756941743..f6315009319e 100644 --- lib/libdwarf/Makefile.depend +++ lib/libdwarf/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libedit/Makefile lib/libedit/Makefile index 81ba64712fec..a11d89d81323 100644 --- lib/libedit/Makefile +++ lib/libedit/Makefile @@ -7,6 +7,8 @@ LIB= edit SHLIB_MAJOR= 7 SHLIBDIR?= /lib +WARNS?= 3 + OSRCS= chared.c common.c el.c eln.c emacs.c fcns.c filecomplete.c help.c \ hist.c keymacro.c map.c chartype.c \ parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c @@ -41,8 +43,6 @@ CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/edit -DWIDECHAR #CFLAGS+= -DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH #CFLAGS+= -DDEBUG_PASTE -DDEBUG_EDIT -WARNS?= 1 - SUBDIR= edit/readline AHDR= vi.h emacs.h common.h diff --git lib/libedit/Makefile.depend lib/libedit/Makefile.depend index 59bc82802604..9b2a343de2dc 100644 --- lib/libedit/Makefile.depend +++ lib/libedit/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libedit/chartype.c lib/libedit/chartype.c index 9cb54ac11a7b..44fb953f8581 100644 --- lib/libedit/chartype.c +++ lib/libedit/chartype.c @@ -223,6 +223,7 @@ ct_mbrtowc(wchar_t *wc, const char *s, size_t n) size_t ct_mbrtowc(wchar_t *wc, const char *s, size_t n) +{ if (s == NULL) return 0; if (n == 0) diff --git lib/libefivar/Makefile lib/libefivar/Makefile index d7f7898e8446..b4368ce9e97c 100644 --- lib/libefivar/Makefile +++ lib/libefivar/Makefile @@ -64,4 +64,4 @@ WARNS?= 9 .include <bsd.lib.mk> -CFLAGS+= -Wno-cast-align -Wno-unused-parameter +CFLAGS+= -fno-strict-aliasing -Wno-cast-align -Wno-unused-parameter diff --git lib/libefivar/Makefile.depend lib/libefivar/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libefivar/Makefile.depend +++ lib/libefivar/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libefivar/efivar-dp-format.c lib/libefivar/efivar-dp-format.c index 491476378f6d..ca122ef63c36 100644 --- lib/libefivar/efivar-dp-format.c +++ lib/libefivar/efivar-dp-format.c @@ -36,6 +36,8 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <string.h> +#include "efichar.h" + #include "efi-osdep.h" #include "efivar-dp.h" @@ -1872,9 +1874,12 @@ DevPathToTextFilePath ( ) { FILEPATH_DEVICE_PATH *Fp; + char *name = NULL; Fp = DevPath; - UefiDevicePathLibCatPrint (Str, "%s", Fp->PathName); + ucs2_to_utf8(Fp->PathName, &name); + UefiDevicePathLibCatPrint (Str, "File(%s)", name); + free(name); } /** @@ -2425,3 +2430,9 @@ efidp_format_device_path(char *buf, size_t len, const_efidp dp, ssize_t max) return retval; } + +size_t +efidp_size(const_efidp dp) +{ + return GetDevicePathSize(__DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp)); +} diff --git lib/libefivar/efivar-dp-parse.c lib/libefivar/efivar-dp-parse.c index c1ca9b72afca..1a280d70cfe3 100644 --- lib/libefivar/efivar-dp-parse.c +++ lib/libefivar/efivar-dp-parse.c @@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <wchar.h> +#include "efichar.h" + #include "efi-osdep.h" #include "efivar-dp.h" @@ -3031,21 +3033,15 @@ DevPathFromTextFilePath ( StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode); #else + size_t len = (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2); + efi_char * v; File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode ( MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, - (UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) + 1) + (UINT16)len ); - - /* - * Note: We'd have to change the Tianocore header files to fix this - * to not need a cast. Instead we just cast it here. The Interface - * to the user may have issues since this won't be a UCS-2 - * string. Also note that in the original code, a NUL wasn't - * allocated for the end of the string, but we copy that below. This - * has been corrected. - */ - StrCpyS ((char *)File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode); + v = File->PathName; + utf8_to_ucs2(TextDeviceNode, &v, &len); #endif return (EFI_DEVICE_PATH_PROTOCOL *) File; @@ -3560,6 +3556,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP {"Media", DevPathFromTextMedia }, {"Fv", DevPathFromTextFv }, {"FvFile", DevPathFromTextFvFile }, + {"File", DevPathFromTextFilePath }, {"Offset", DevPathFromTextRelativeOffsetRange }, {"RamDisk", DevPathFromTextRamDisk }, {"VirtualDisk", DevPathFromTextVirtualDisk }, diff --git lib/libefivar/efivar-dp.h lib/libefivar/efivar-dp.h index 94dd1189cebe..f620a67550a0 100644 --- lib/libefivar/efivar-dp.h +++ lib/libefivar/efivar-dp.h @@ -62,4 +62,6 @@ ssize_t efidp_format_device_path(char *buf, size_t len, const_efidp dp, ssize_t max); ssize_t efidp_parse_device_path(char *path, efidp out, size_t max); +size_t efidp_size(const_efidp); + #endif /* _EFIVAR_DP_H_ */ diff --git lib/libefivar/efivar.c lib/libefivar/efivar.c index bce4a1449ab2..a825d9e9f9bf 100644 --- lib/libefivar/efivar.c +++ lib/libefivar/efivar.c @@ -150,7 +150,7 @@ efi_append_variable(efi_guid_t guid, const char *name, { return efi_set_variable(guid, name, data, data_size, - attributes | EFI_VARIABLE_APPEND_WRITE, 0); + attributes | EFI_VARIABLE_APPEND_WRITE); } int @@ -158,7 +158,7 @@ efi_del_variable(efi_guid_t guid, const char *name) { /* data_size of 0 deletes the variable */ - return efi_set_variable(guid, name, NULL, 0, 0, 0); + return efi_set_variable(guid, name, NULL, 0, 0); } int @@ -225,8 +225,13 @@ efi_get_next_variable_name(efi_guid_t **guid, char **name) if (efi_open_dev() == -1) return -1; + /* + * Always allocate enough for an extra NUL on the end, but don't tell + * the IOCTL about it so we can NUL terminate the name before converting + * it to UTF8. + */ if (buf == NULL) - buf = malloc(buflen); + buf = malloc(buflen + sizeof(efi_char)); again: efi_var_reset(&var); @@ -244,21 +249,23 @@ again: rv = ioctl(efi_fd, EFIIOC_VAR_NEXT, &var); if (rv == 0 && var.name == NULL) { /* - * oops, too little space. Try again. + * Variable name not long enough, so allocate more space for the + * name and try again. As above, mind the NUL we add. */ - void *new = realloc(buf, buflen); - buflen = var.namesize; + void *new = realloc(buf, var.namesize + sizeof(efi_char)); if (new == NULL) { rv = -1; errno = ENOMEM; goto done; } + buflen = var.namesize; buf = new; goto again; } if (rv == 0) { - *name = NULL; /* XXX */ + free(*name); /* Free last name, to avoid leaking */ + *name = NULL; /* Force ucs2_to_utf8 to malloc new space */ var.name[var.namesize / sizeof(efi_char)] = 0; /* EFI doesn't NUL terminate */ rv = ucs2_to_utf8(var.name, name); if (rv != 0) @@ -269,9 +276,11 @@ again: errout: /* XXX The linux interface expects name to be a static buffer -- fix or leak memory? */ + /* XXX for the moment, we free just before we'd leak, but still leak last one */ done: - if (errno == ENOENT) { + if (rv != 0 && errno == ENOENT) { errno = 0; + free(*name); /* Free last name, to avoid leaking */ return 0; } @@ -349,7 +358,7 @@ efi_name_to_guid(const char *name, efi_guid_t *guid) int efi_set_variable(efi_guid_t guid, const char *name, - uint8_t *data, size_t data_size, uint32_t attributes, mode_t mode __unused) + uint8_t *data, size_t data_size, uint32_t attributes) { struct efi_var_ioc var; int rv; diff --git lib/libefivar/efivar.h lib/libefivar/efivar.h index cba8a8e61849..5725bb029d7c 100644 --- lib/libefivar/efivar.h +++ lib/libefivar/efivar.h @@ -83,7 +83,7 @@ int efi_guid_to_symbol(efi_guid_t *guid, char **symbol); int efi_guid_to_str(const efi_guid_t *guid, char **sp); int efi_name_to_guid(const char *name, efi_guid_t *guid); int efi_set_variable(efi_guid_t guid, const char *name, - uint8_t *data, size_t data_size, uint32_t attributes, mode_t mode); + uint8_t *data, size_t data_size, uint32_t attributes); int efi_str_to_guid(const char *s, efi_guid_t *guid); int efi_variables_supported(void); @@ -99,37 +99,4 @@ int efi_known_guid(struct uuid_table **); extern const efi_guid_t efi_guid_empty; -/* Stubs that are expected, but aren't really used */ -static inline int -efi_error_get(unsigned int n __unused, char ** const fn __unused, - char ** const func __unused, int *line __unused, - char ** const msg __unused, int *err __unused) -{ - return 0; -} - -static inline int -efi_error_set(const char *fn __unused, const char *func __unused, - int line __unused, int err __unused, const char *fmt __unused, ...) -{ - return 0; -} - -static inline void -efi_error_clear(void) -{ -} - -static inline int -efi_error(const char *fmt __unused, ...) -{ - return 0; -} - -static inline int -efi_error_val(int val __unused, const char *fmt __unused, ...) -{ - return 0; -} - #endif /* _EFIVAR_H_ */ diff --git lib/libelf/Makefile.depend lib/libelf/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libelf/Makefile.depend +++ lib/libelf/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libevent/Makefile.depend lib/libevent/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libevent/Makefile.depend +++ lib/libevent/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libexecinfo/Makefile.depend lib/libexecinfo/Makefile.depend index b76756941743..f6315009319e 100644 --- lib/libexecinfo/Makefile.depend +++ lib/libexecinfo/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libexpat/Makefile.depend lib/libexpat/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libexpat/Makefile.depend +++ lib/libexpat/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libfetch/Makefile.depend lib/libfetch/Makefile.depend index 9d5105e918de..43f916ed9679 100644 --- lib/libfetch/Makefile.depend +++ lib/libfetch/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libfigpar/Makefile.depend lib/libfigpar/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libfigpar/Makefile.depend +++ lib/libfigpar/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git sys/boot/userboot/zfs/Makefile.depend lib/libgcc_eh/Makefile.depend similarity index 100% rename from sys/boot/userboot/zfs/Makefile.depend rename to lib/libgcc_eh/Makefile.depend diff --git lib/libgcc_eh/Makefile.inc lib/libgcc_eh/Makefile.inc index 6337f3890e18..d69084f059cf 100644 --- lib/libgcc_eh/Makefile.inc +++ lib/libgcc_eh/Makefile.inc @@ -29,7 +29,8 @@ CXXFLAGS+= -std=c++11 .endif CXXFLAGS+= -fno-rtti STATIC_CXXFLAGS+= -fvisibility=hidden -fPIC +# Probably need to just move this earlier or use CXXFLAGS .if ${MK_DIRDEPS_BUILD} == "yes" # Avoid dependency on lib/libc++ -CFLAGS+= -I${SRCTOP}/contrib/libc++/include +CFLAGS+= -isystem ${SRCTOP}/contrib/libc++/include -nostdinc++ .endif diff --git lib/libgcc_s/Makefile.depend lib/libgcc_s/Makefile.depend new file mode 100644 index 000000000000..2f6d8d110c49 --- /dev/null +++ lib/libgcc_s/Makefile.depend @@ -0,0 +1,16 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git lib/libgeom/Makefile lib/libgeom/Makefile index ea1f6c83a961..b7877cc56ece 100644 --- lib/libgeom/Makefile +++ lib/libgeom/Makefile @@ -33,6 +33,10 @@ MLINKS+= \ libgeom.3 gctl_issue.3 \ libgeom.3 gctl_free.3 \ libgeom.3 gctl_dump.3 \ + libgeom.3 geom_getxml.3 \ + libgeom.3 geom_xml2tree.3 \ + libgeom.3 geom_gettree.3 \ + libgeom.3 geom_deletetree.3 \ libgeom.3 g_close.3 \ libgeom.3 g_delete.3 \ libgeom.3 g_device_path.3 \ diff --git lib/libgeom/Makefile.depend lib/libgeom/Makefile.depend index 7f43259d6ba3..a04957c6b683 100644 --- lib/libgeom/Makefile.depend +++ lib/libgeom/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libgeom/geom_util.c lib/libgeom/geom_util.c index 54844c6e451c..73c305a4201b 100644 --- lib/libgeom/geom_util.c +++ lib/libgeom/geom_util.c @@ -56,8 +56,6 @@ g_open(const char *name, int dowrite) path = g_device_path_open(name, &fd, dowrite); if (path != NULL) free(path); - if (fd == -1) - return (-1); return (fd); } @@ -281,58 +279,45 @@ g_device_path_open(const char *devpath, int *fdp, int dowrite) /* Make sure that we can fail. */ if (fdp != NULL) *fdp = -1; + /* Use the device node if we're able to open it. */ - do { - fd = open(devpath, dowrite ? O_RDWR : O_RDONLY); - if (fd == -1) - break; - /* - * Let try to get sectorsize, which will prove it is a GEOM - * provider. - */ - if (g_sectorsize(fd) == -1) { - close(fd); - errno = EFTYPE; - return (NULL); - } + fd = open(devpath, dowrite ? O_RDWR : O_RDONLY); + if (fd != -1) { if ((path = strdup(devpath)) == NULL) { close(fd); return (NULL); } - if (fdp != NULL) - *fdp = fd; - else - close(fd); - return (path); - } while (0); + goto fd_ok; + } /* If we're not given an absolute path, assume /dev/ prefix. */ - if (*devpath != '/') { - asprintf(&path, "%s%s", _PATH_DEV, devpath); - if (path == NULL) - return (NULL); - fd = open(path, dowrite ? O_RDWR : O_RDONLY); - if (fd == -1) { - free(path); - return (NULL); - } - /* - * Let try to get sectorsize, which will prove it is a GEOM - * provider. - */ - if (g_sectorsize(fd) == -1) { - free(path); - close(fd); - errno = EFTYPE; - return (NULL); - } - if (fdp != NULL) - *fdp = fd; - else - close(fd); - return (path); + if (*devpath == '/') + return (NULL); + + asprintf(&path, "%s%s", _PATH_DEV, devpath); + if (path == NULL) + return (NULL); + fd = open(path, dowrite ? O_RDWR : O_RDONLY); + if (fd == -1) { + free(path); + return (NULL); } - return (NULL); + +fd_ok: + /* + * Let try to get sectorsize, which will prove it is a GEOM provider. + */ + if (g_sectorsize(fd) == -1) { + free(path); + close(fd); + errno = EFTYPE; + return (NULL); + } + if (fdp != NULL) + *fdp = fd; + else + close(fd); + return (path); } char * diff --git lib/libgeom/libgeom.3 lib/libgeom/libgeom.3 index dbe21c84d38e..e1a3a35b7062 100644 --- lib/libgeom/libgeom.3 +++ lib/libgeom/libgeom.3 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 22, 2017 +.Dd October 16, 2017 .Dt LIBGEOM 3 .Os .Sh NAME @@ -46,6 +46,10 @@ .Nm gctl_issue , .Nm gctl_free , .Nm gctl_dump , +.Nm geom_getxml , +.Nm geom_xml2tree , +.Nm geom_gettree , +.Nm geom_deletetree , .Nm g_open , .Nm g_close , .Nm g_mediasize , @@ -99,6 +103,14 @@ .Ft void .Fn gctl_dump "struct gctl_req *req" "FILE *f" .Ss "Utility Functions" +.Ft "char *" +.Fn geom_getxml void +.Ft int +.Fn geom_xml2tree "struct gmesh *gmp" "char *p" +.Ft int +.Fn geom_gettree "struct gmesh *gmp" +.Ft void +.Fn geom_deletetree "struct gmesh *gmp" .Ft int .Fn g_open "const char *name" "int dowrite" .Ft int @@ -279,6 +291,46 @@ on success, or an error message corresponding to the first error which happened. .Ss "Utility Functions" The +.Fn geom_getxml +function is a wrapper around +.Xr sysctl 3 +that fetches the +.Ar kern.geom.confxml +OID, and returns it's value. +The allocated memory should be released with +.Xr free 2 +after use. +.Pp +The +.Fn geom_xml2tree +function parses the XML representation of a GEOM topology passed as +.Ar p , +allocates the needed data structures to access this information and fills in +the passed +.Ar gmp +data structure. +Memory allocated during this transformation should be released +using +.Fn geom_deletetree +after use. +.Pp +The +.Fn geom_gettree +function is a wrapper around the +.Fn geom_getxml +and +.Fn geom_xml2tree +functions. +Memory allocated during this operation should be released using +.Fn geom_deletetree +after use. +.Pp +The +.Fn geom_deletetree +function releases memory allocated for storing the data-structures referenced by +.Ar gmp . +.Pp +The .Fn g_* functions are used to communicate with GEOM providers. .Pp diff --git lib/libgpio/Makefile.depend lib/libgpio/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libgpio/Makefile.depend +++ lib/libgpio/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libgssapi/Makefile.depend lib/libgssapi/Makefile.depend index 08a5ffff1f63..115ce71ae2d9 100644 --- lib/libgssapi/Makefile.depend +++ lib/libgssapi/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/gssapi \ include/xlocale \ diff --git lib/libiconv_modules/BIG5/Makefile.depend lib/libiconv_modules/BIG5/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/BIG5/Makefile.depend +++ lib/libiconv_modules/BIG5/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/DECHanyu/Makefile.depend lib/libiconv_modules/DECHanyu/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/DECHanyu/Makefile.depend +++ lib/libiconv_modules/DECHanyu/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/EUC/Makefile.depend lib/libiconv_modules/EUC/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/EUC/Makefile.depend +++ lib/libiconv_modules/EUC/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/EUCTW/Makefile.depend lib/libiconv_modules/EUCTW/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/EUCTW/Makefile.depend +++ lib/libiconv_modules/EUCTW/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/GBK2K/Makefile.depend lib/libiconv_modules/GBK2K/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/GBK2K/Makefile.depend +++ lib/libiconv_modules/GBK2K/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/HZ/Makefile.depend lib/libiconv_modules/HZ/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/HZ/Makefile.depend +++ lib/libiconv_modules/HZ/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/ISO2022/Makefile.depend lib/libiconv_modules/ISO2022/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/ISO2022/Makefile.depend +++ lib/libiconv_modules/ISO2022/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/JOHAB/Makefile.depend lib/libiconv_modules/JOHAB/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/JOHAB/Makefile.depend +++ lib/libiconv_modules/JOHAB/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/MSKanji/Makefile.depend lib/libiconv_modules/MSKanji/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/MSKanji/Makefile.depend +++ lib/libiconv_modules/MSKanji/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/UES/Makefile.depend lib/libiconv_modules/UES/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/UES/Makefile.depend +++ lib/libiconv_modules/UES/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/UTF1632/Makefile.depend lib/libiconv_modules/UTF1632/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/UTF1632/Makefile.depend +++ lib/libiconv_modules/UTF1632/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/UTF7/Makefile.depend lib/libiconv_modules/UTF7/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/UTF7/Makefile.depend +++ lib/libiconv_modules/UTF7/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/UTF8/Makefile.depend lib/libiconv_modules/UTF8/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/UTF8/Makefile.depend +++ lib/libiconv_modules/UTF8/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/VIQR/Makefile.depend lib/libiconv_modules/VIQR/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/VIQR/Makefile.depend +++ lib/libiconv_modules/VIQR/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/ZW/Makefile.depend lib/libiconv_modules/ZW/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/ZW/Makefile.depend +++ lib/libiconv_modules/ZW/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/iconv_none/Makefile.depend lib/libiconv_modules/iconv_none/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/iconv_none/Makefile.depend +++ lib/libiconv_modules/iconv_none/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/iconv_std/Makefile.depend lib/libiconv_modules/iconv_std/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/iconv_std/Makefile.depend +++ lib/libiconv_modules/iconv_std/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/mapper_646/Makefile.depend lib/libiconv_modules/mapper_646/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/mapper_646/Makefile.depend +++ lib/libiconv_modules/mapper_646/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/mapper_none/Makefile.depend lib/libiconv_modules/mapper_none/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/mapper_none/Makefile.depend +++ lib/libiconv_modules/mapper_none/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/mapper_parallel/Makefile.depend lib/libiconv_modules/mapper_parallel/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/mapper_parallel/Makefile.depend +++ lib/libiconv_modules/mapper_parallel/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/mapper_serial/Makefile.depend lib/libiconv_modules/mapper_serial/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/mapper_serial/Makefile.depend +++ lib/libiconv_modules/mapper_serial/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/mapper_std/Makefile.depend lib/libiconv_modules/mapper_std/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/mapper_std/Makefile.depend +++ lib/libiconv_modules/mapper_std/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libiconv_modules/mapper_zone/Makefile.depend lib/libiconv_modules/mapper_zone/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libiconv_modules/mapper_zone/Makefile.depend +++ lib/libiconv_modules/mapper_zone/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libifconfig/Makefile lib/libifconfig/Makefile index 9c3116e747b2..9d84f627e97e 100644 --- lib/libifconfig/Makefile +++ lib/libifconfig/Makefile @@ -3,8 +3,6 @@ PACKAGE= lib${LIB} LIB= ifconfig PRIVATELIB= true -# Don't build shared library, for now. -NO_PIC= SHLIBDIR?= /lib SHLIB_MAJOR= 1 diff --git lib/libifconfig/libifconfig.c lib/libifconfig/libifconfig.c index 1f57d3fdd73b..07b5145d6311 100644 --- lib/libifconfig/libifconfig.c +++ lib/libifconfig/libifconfig.c @@ -61,9 +61,43 @@ * $FreeBSD$ */ + /* + * Copyright 1996 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include <sys/types.h> #include <sys/ioctl.h> +#include <sys/sysctl.h> #include <net/if.h> +#include <net/if_mib.h> #include <err.h> #include <errno.h> @@ -247,6 +281,67 @@ ifconfig_set_name(ifconfig_handle_t *h, const char *name, const char *newname) return (0); } +int +ifconfig_get_orig_name(ifconfig_handle_t *h, const char *ifname, + char **orig_name) +{ + struct ifmibdata ifmd; + size_t len; + int name[6]; + int i, maxifno; + + name[0] = CTL_NET; + name[1] = PF_LINK; + name[2] = NETLINK_GENERIC; + name[3] = IFMIB_SYSTEM; + name[4] = IFMIB_IFCOUNT; + + len = sizeof maxifno; + if (sysctl(name, 5, &maxifno, &len, 0, 0) < 0) { + h->error.errtype = OTHER; + h->error.errcode = errno; + return (-1); + } + + name[3] = IFMIB_IFDATA; + name[5] = IFDATA_GENERAL; + for (i = 1; i <= maxifno; i++) { + len = sizeof ifmd; + name[4] = i; + if (sysctl(name, 6, &ifmd, &len, 0, 0) < 0) { + if (errno == ENOENT) + continue; + + goto fail; + } + + if (strncmp(ifmd.ifmd_name, ifname, IFNAMSIZ) != 0) + continue; + + len = 0; + name[5] = IFDATA_DRIVERNAME; + if (sysctl(name, 6, NULL, &len, 0, 0) < 0) + goto fail; + + *orig_name = malloc(len); + if (*orig_name == NULL) + goto fail; + + if (sysctl(name, 6, *orig_name, &len, 0, 0) < 0) { + free(*orig_name); + *orig_name = NULL; + goto fail; + } + + return (0); + } + +fail: + h->error.errtype = OTHER; + h->error.errcode = (i <= maxifno) ? errno : ENOENT; + return (-1); +} + int ifconfig_set_mtu(ifconfig_handle_t *h, const char *name, const int mtu) { diff --git lib/libifconfig/libifconfig.h lib/libifconfig/libifconfig.h index de635334ad7a..b5508740de10 100644 --- lib/libifconfig/libifconfig.h +++ lib/libifconfig/libifconfig.h @@ -82,6 +82,8 @@ int ifconfig_set_description(ifconfig_handle_t *h, const char *name, int ifconfig_unset_description(ifconfig_handle_t *h, const char *name); int ifconfig_set_name(ifconfig_handle_t *h, const char *name, const char *newname); +int ifconfig_get_orig_name(ifconfig_handle_t *h, const char *ifname, + char **orig_name); int ifconfig_set_mtu(ifconfig_handle_t *h, const char *name, const int mtu); int ifconfig_get_mtu(ifconfig_handle_t *h, const char *name, int *mtu); int ifconfig_set_metric(ifconfig_handle_t *h, const char *name, diff --git lib/libipsec/Makefile.depend lib/libipsec/Makefile.depend index 75e27669e9f3..f2071f254a6b 100644 --- lib/libipsec/Makefile.depend +++ lib/libipsec/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libjail/Makefile.depend lib/libjail/Makefile.depend index 54c1f6f1442e..d5ed563ecfc8 100644 --- lib/libjail/Makefile.depend +++ lib/libjail/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libkiconv/Makefile.depend lib/libkiconv/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libkiconv/Makefile.depend +++ lib/libkiconv/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libkvm/Makefile.depend lib/libkvm/Makefile.depend index b76756941743..f6315009319e 100644 --- lib/libkvm/Makefile.depend +++ lib/libkvm/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libkvm/tests/Makefile.depend lib/libkvm/tests/Makefile.depend new file mode 100644 index 000000000000..b8f799312bc4 --- /dev/null +++ lib/libkvm/tests/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/atf/libatf-c \ + lib/libc \ + lib/libcompiler_rt \ + lib/libelf \ + lib/libkvm \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git lib/libldns/Makefile.depend lib/libldns/Makefile.depend index b3f22d1b14c1..53dff6f79864 100644 --- lib/libldns/Makefile.depend +++ lib/libldns/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/liblzma/Makefile.depend lib/liblzma/Makefile.depend index 7b92dbd89f4a..8bb1973e0ff5 100644 --- lib/liblzma/Makefile.depend +++ lib/liblzma/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libmagic/Makefile.depend lib/libmagic/Makefile.depend index d209adbd4ff2..9a8221bf3321 100644 --- lib/libmagic/Makefile.depend +++ lib/libmagic/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libmagic/config.h lib/libmagic/config.h index 03d5897ba4d9..91b7088129c6 100644 --- lib/libmagic/config.h +++ lib/libmagic/config.h @@ -293,7 +293,7 @@ #define PACKAGE_NAME "file" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "file 5.29" +#define PACKAGE_STRING "file 5.32" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "file" @@ -302,7 +302,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "5.29" +#define PACKAGE_VERSION "5.32" /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 @@ -333,7 +333,7 @@ /* Version number of package */ -#define VERSION "5.29" +#define VERSION "5.32" /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ diff --git lib/libmd/Makefile.depend lib/libmd/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libmd/Makefile.depend +++ lib/libmd/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libmemstat/Makefile.depend lib/libmemstat/Makefile.depend index a1ac545aff09..dc18ed8c991a 100644 --- lib/libmemstat/Makefile.depend +++ lib/libmemstat/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libmilter/Makefile.depend lib/libmilter/Makefile.depend index 54c1f6f1442e..d5ed563ecfc8 100644 --- lib/libmilter/Makefile.depend +++ lib/libmilter/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libmp/Makefile.depend lib/libmp/Makefile.depend index fc0b63320671..cdd96948933d 100644 --- lib/libmp/Makefile.depend +++ lib/libmp/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libmp/tests/Makefile.depend lib/libmp/tests/Makefile.depend index bd34832143dd..4e18a97cda4f 100644 --- lib/libmp/tests/Makefile.depend +++ lib/libmp/tests/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libmt/Makefile.depend lib/libmt/Makefile.depend index 7f43259d6ba3..a04957c6b683 100644 --- lib/libmt/Makefile.depend +++ lib/libmt/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libmt/mtlib.c lib/libmt/mtlib.c index 08dce9d4a6b0..0ada983823a1 100644 --- lib/libmt/mtlib.c +++ lib/libmt/mtlib.c @@ -645,6 +645,7 @@ static struct densities { { 0x58, 15142, 384607, "LTO-5" }, { 0x5A, 15142, 384607, "LTO-6" }, { 0x5C, 19107, 485318, "LTO-7" }, + { 0x5D, 19107, 485318, "LTO-M8" }, { 0x5E, 20669, 524993, "LTO-8" }, { 0x71, 11800, 299720, "3592A1 (encrypted)" }, { 0x72, 11800, 299720, "3592A2 (encrypted)" }, diff --git lib/libnandfs/Makefile.depend lib/libnandfs/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libnandfs/Makefile.depend +++ lib/libnandfs/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libnetgraph/Makefile lib/libnetgraph/Makefile index d3c7c3fa64a4..3f80ee84f47d 100644 --- lib/libnetgraph/Makefile +++ lib/libnetgraph/Makefile @@ -15,7 +15,7 @@ MLINKS+= netgraph.3 NgMkSockNode.3 MLINKS+= netgraph.3 NgNameNode.3 MLINKS+= netgraph.3 NgSendMsg.3 MLINKS+= netgraph.3 NgSendAsciiMsg.3 -MLINKS+= netgraph.3 NgSendMsgReply.3 +MLINKS+= netgraph.3 NgSendReplyMsg.3 MLINKS+= netgraph.3 NgRecvMsg.3 MLINKS+= netgraph.3 NgAllocRecvMsg.3 MLINKS+= netgraph.3 NgRecvAsciiMsg.3 diff --git lib/libnetgraph/Makefile.depend lib/libnetgraph/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libnetgraph/Makefile.depend +++ lib/libnetgraph/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libnetgraph/netgraph.3 lib/libnetgraph/netgraph.3 index 9d8d26a0571e..ec4de0b09302 100644 --- lib/libnetgraph/netgraph.3 +++ lib/libnetgraph/netgraph.3 @@ -43,7 +43,7 @@ .Nm NgNameNode , .Nm NgSendMsg , .Nm NgSendAsciiMsg , -.Nm NgSendMsgReply , +.Nm NgSendReplyMsg , .Nm NgRecvMsg , .Nm NgAllocRecvMsg , .Nm NgRecvAsciiMsg , @@ -70,7 +70,7 @@ .Ft int .Fn NgSendAsciiMsg "int cs" "const char *path" "const char *fmt" ... .Ft int -.Fo NgSendMsgReply +.Fo NgSendReplyMsg .Fa "int cs" "const char *path" "struct ng_mesg *msg" "const void *arg" .Fa "size_t arglen" .Fc @@ -162,7 +162,7 @@ header is returned. This value is typically used to associate replies. .Pp Use -.Fn NgSendMsgReply +.Fn NgSendReplyMsg to send reply to a previously received control message. The original message header should be pointed to by .Fa msg . diff --git lib/libngatm/Makefile.depend lib/libngatm/Makefile.depend index 54c1f6f1442e..d5ed563ecfc8 100644 --- lib/libngatm/Makefile.depend +++ lib/libngatm/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libnv/Makefile.depend lib/libnv/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libnv/Makefile.depend +++ lib/libnv/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libnv/msgio.c lib/libnv/msgio.c index 27620a184f9a..283ddccbdd79 100644 --- lib/libnv/msgio.c +++ lib/libnv/msgio.c @@ -299,7 +299,6 @@ fd_package_recv(int sock, int *fds, size_t nfds) PJDLOG_ASSERT(nfds > 0); PJDLOG_ASSERT(fds != NULL); - i = 0; bzero(&msg, sizeof(msg)); bzero(&iov, sizeof(iov)); diff --git lib/libnv/tests/Makefile.depend lib/libnv/tests/Makefile.depend index e6cfb180bb83..7d28bf776082 100644 --- lib/libnv/tests/Makefile.depend +++ lib/libnv/tests/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libopie/Makefile.depend lib/libopie/Makefile.depend index 6a2d4068b6cc..9dfb51c0b371 100644 --- lib/libopie/Makefile.depend +++ lib/libopie/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libpam/libpam/Makefile.depend lib/libpam/libpam/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libpam/libpam/Makefile.depend +++ lib/libpam/libpam/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_chroot/Makefile.depend lib/libpam/modules/pam_chroot/Makefile.depend index 8e0956024b47..a3a7ac4e5850 100644 --- lib/libpam/modules/pam_chroot/Makefile.depend +++ lib/libpam/modules/pam_chroot/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_deny/Makefile.depend lib/libpam/modules/pam_deny/Makefile.depend index 1078f3391c30..5fb710255efc 100644 --- lib/libpam/modules/pam_deny/Makefile.depend +++ lib/libpam/modules/pam_deny/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git lib/libpam/modules/pam_echo/Makefile.depend lib/libpam/modules/pam_echo/Makefile.depend index 8e0956024b47..a3a7ac4e5850 100644 --- lib/libpam/modules/pam_echo/Makefile.depend +++ lib/libpam/modules/pam_echo/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_exec/Makefile.depend lib/libpam/modules/pam_exec/Makefile.depend index 8e0956024b47..a3a7ac4e5850 100644 --- lib/libpam/modules/pam_exec/Makefile.depend +++ lib/libpam/modules/pam_exec/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_ftpusers/Makefile.depend lib/libpam/modules/pam_ftpusers/Makefile.depend index 8e0956024b47..a3a7ac4e5850 100644 --- lib/libpam/modules/pam_ftpusers/Makefile.depend +++ lib/libpam/modules/pam_ftpusers/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_group/Makefile.depend lib/libpam/modules/pam_group/Makefile.depend index 8e0956024b47..a3a7ac4e5850 100644 --- lib/libpam/modules/pam_group/Makefile.depend +++ lib/libpam/modules/pam_group/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_guest/Makefile.depend lib/libpam/modules/pam_guest/Makefile.depend index 8e0956024b47..a3a7ac4e5850 100644 --- lib/libpam/modules/pam_guest/Makefile.depend +++ lib/libpam/modules/pam_guest/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_krb5/Makefile.depend lib/libpam/modules/pam_krb5/Makefile.depend index 8bd8a57c6396..f4ad591d36ba 100644 --- lib/libpam/modules/pam_krb5/Makefile.depend +++ lib/libpam/modules/pam_krb5/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ kerberos5/lib/libasn1 \ diff --git lib/libpam/modules/pam_ksu/Makefile.depend lib/libpam/modules/pam_ksu/Makefile.depend index d951012ff8c4..ad4fcd166520 100644 --- lib/libpam/modules/pam_ksu/Makefile.depend +++ lib/libpam/modules/pam_ksu/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ kerberos5/lib/libasn1 \ diff --git lib/libpam/modules/pam_lastlog/Makefile.depend lib/libpam/modules/pam_lastlog/Makefile.depend index 8e0956024b47..a3a7ac4e5850 100644 --- lib/libpam/modules/pam_lastlog/Makefile.depend +++ lib/libpam/modules/pam_lastlog/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_login_access/Makefile.depend lib/libpam/modules/pam_login_access/Makefile.depend index 8e0956024b47..a3a7ac4e5850 100644 --- lib/libpam/modules/pam_login_access/Makefile.depend +++ lib/libpam/modules/pam_login_access/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_nologin/Makefile.depend lib/libpam/modules/pam_nologin/Makefile.depend index 8f9750f34f37..0f5cf60ca00c 100644 --- lib/libpam/modules/pam_nologin/Makefile.depend +++ lib/libpam/modules/pam_nologin/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_opie/Makefile.depend lib/libpam/modules/pam_opie/Makefile.depend index 62a94081539a..da2957f739ba 100644 --- lib/libpam/modules/pam_opie/Makefile.depend +++ lib/libpam/modules/pam_opie/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_opieaccess/Makefile.depend lib/libpam/modules/pam_opieaccess/Makefile.depend index cbfda79831cc..81514fa091b5 100644 --- lib/libpam/modules/pam_opieaccess/Makefile.depend +++ lib/libpam/modules/pam_opieaccess/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git lib/libpam/modules/pam_passwdqc/Makefile.depend lib/libpam/modules/pam_passwdqc/Makefile.depend index e82ea2412810..3e2c57639cd5 100644 --- lib/libpam/modules/pam_passwdqc/Makefile.depend +++ lib/libpam/modules/pam_passwdqc/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_permit/Makefile.depend lib/libpam/modules/pam_permit/Makefile.depend index 1078f3391c30..5fb710255efc 100644 --- lib/libpam/modules/pam_permit/Makefile.depend +++ lib/libpam/modules/pam_permit/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git lib/libpam/modules/pam_radius/Makefile.depend lib/libpam/modules/pam_radius/Makefile.depend index f8940bfd4c0c..88b5297a79c5 100644 --- lib/libpam/modules/pam_radius/Makefile.depend +++ lib/libpam/modules/pam_radius/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_rhosts/Makefile.depend lib/libpam/modules/pam_rhosts/Makefile.depend index 8e0956024b47..a3a7ac4e5850 100644 --- lib/libpam/modules/pam_rhosts/Makefile.depend +++ lib/libpam/modules/pam_rhosts/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_rootok/Makefile.depend lib/libpam/modules/pam_rootok/Makefile.depend index 1078f3391c30..5fb710255efc 100644 --- lib/libpam/modules/pam_rootok/Makefile.depend +++ lib/libpam/modules/pam_rootok/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git lib/libpam/modules/pam_securetty/Makefile.depend lib/libpam/modules/pam_securetty/Makefile.depend index 8e0956024b47..a3a7ac4e5850 100644 --- lib/libpam/modules/pam_securetty/Makefile.depend +++ lib/libpam/modules/pam_securetty/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_self/Makefile.depend lib/libpam/modules/pam_self/Makefile.depend index 1078f3391c30..5fb710255efc 100644 --- lib/libpam/modules/pam_self/Makefile.depend +++ lib/libpam/modules/pam_self/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ lib/${CSU_DIR} \ lib/libc \ diff --git lib/libpam/modules/pam_ssh/Makefile.depend lib/libpam/modules/pam_ssh/Makefile.depend index 6b7118bcd2a0..bee3c0e355ef 100644 --- lib/libpam/modules/pam_ssh/Makefile.depend +++ lib/libpam/modules/pam_ssh/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_tacplus/Makefile.depend lib/libpam/modules/pam_tacplus/Makefile.depend index 98723a0082ef..bab66eeb796c 100644 --- lib/libpam/modules/pam_tacplus/Makefile.depend +++ lib/libpam/modules/pam_tacplus/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpam/modules/pam_unix/Makefile.depend lib/libpam/modules/pam_unix/Makefile.depend index 0876f5fc95f0..ccb6060a48f6 100644 --- lib/libpam/modules/pam_unix/Makefile.depend +++ lib/libpam/modules/pam_unix/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libpam/modules/pam_unix/pam_unix.c lib/libpam/modules/pam_unix/pam_unix.c index 5403d5d555e2..2fd3b61970cf 100644 --- lib/libpam/modules/pam_unix/pam_unix.c +++ lib/libpam/modules/pam_unix/pam_unix.c @@ -111,6 +111,7 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused, if (!(flags & PAM_DISALLOW_NULL_AUTHTOK) && openpam_get_option(pamh, PAM_OPT_NULLOK)) return (PAM_SUCCESS); + PAM_LOG("Password is empty, using fake password"); realpw = "*"; } lc = login_getpwclass(pwd); @@ -125,6 +126,10 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused, if (retval != PAM_SUCCESS) return (retval); PAM_LOG("Got password"); + if (strnlen(pass, _PASSWORD_LEN + 1) > _PASSWORD_LEN) { + PAM_LOG("Password is too long, using fake password"); + realpw = "*"; + } if (strcmp(crypt(pass, realpw), realpw) == 0) return (PAM_SUCCESS); diff --git lib/libpathconv/Makefile lib/libpathconv/Makefile index fd9924e686e3..5aeae6ebd988 100644 --- lib/libpathconv/Makefile +++ lib/libpathconv/Makefile @@ -14,6 +14,6 @@ SRCS= abs2rel.c rel2abs.c #SYMBOL_MAPS= ${.CURDIR}/Symbol.map HAS_TESTS= -SUBDIR.${MK_TESTS}+= tests +#SUBDIR.${MK_TESTS}+= tests .include <bsd.lib.mk> diff --git usr.bin/rlogin/Makefile.depend lib/libpathconv/Makefile.depend similarity index 93% rename from usr.bin/rlogin/Makefile.depend rename to lib/libpathconv/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- usr.bin/rlogin/Makefile.depend +++ lib/libpathconv/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git usr.sbin/procctl/Makefile.depend lib/libpathconv/tests/Makefile.depend similarity index 93% rename from usr.sbin/procctl/Makefile.depend rename to lib/libpathconv/tests/Makefile.depend index 3646e2e2b1af..0c909c5bb53a 100644 --- usr.sbin/procctl/Makefile.depend +++ lib/libpathconv/tests/Makefile.depend @@ -3,12 +3,12 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ + lib/libpathconv \ .include <dirdeps.mk> diff --git lib/libpcap/Makefile.depend lib/libpcap/Makefile.depend index 75e27669e9f3..f2071f254a6b 100644 --- lib/libpcap/Makefile.depend +++ lib/libpcap/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libpjdlog/Makefile.depend lib/libpjdlog/Makefile.depend index 7de116d21d37..4fc5be2a35f0 100644 --- lib/libpjdlog/Makefile.depend +++ lib/libpjdlog/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/arpa \ include/xlocale \ diff --git lib/libpmc/Makefile.depend lib/libpmc/Makefile.depend index 3646e2e2b1af..6cfaab1c3644 100644 --- lib/libpmc/Makefile.depend +++ lib/libpmc/Makefile.depend @@ -3,7 +3,6 @@ DIRDEPS = \ gnu/lib/csu \ - gnu/lib/libgcc \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git lib/libpmc/libpmc.c lib/libpmc/libpmc.c index 0e54b68dabbf..8193769bdedb 100644 --- lib/libpmc/libpmc.c +++ lib/libpmc/libpmc.c @@ -232,6 +232,11 @@ static const struct pmc_event_descr skylake_event_table[] = __PMC_EV_ALIAS_SKYLAKE() }; +static const struct pmc_event_descr skylake_xeon_event_table[] = +{ + __PMC_EV_ALIAS_SKYLAKE_XEON() +}; + static const struct pmc_event_descr ivybridge_event_table[] = { __PMC_EV_ALIAS_IVYBRIDGE() @@ -328,6 +333,7 @@ PMC_MDEP_TABLE(haswell_xeon, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_MDEP_TABLE(broadwell, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP); PMC_MDEP_TABLE(broadwell_xeon, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP); PMC_MDEP_TABLE(skylake, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP); +PMC_MDEP_TABLE(skylake_xeon, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC); PMC_MDEP_TABLE(ivybridge, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC); PMC_MDEP_TABLE(ivybridge_xeon, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC); PMC_MDEP_TABLE(sandybridge, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP); @@ -383,6 +389,7 @@ PMC_CLASS_TABLE_DESC(haswell_xeon, IAP, haswell_xeon, iap); PMC_CLASS_TABLE_DESC(broadwell, IAP, broadwell, iap); PMC_CLASS_TABLE_DESC(broadwell_xeon, IAP, broadwell_xeon, iap); PMC_CLASS_TABLE_DESC(skylake, IAP, skylake, iap); +PMC_CLASS_TABLE_DESC(skylake_xeon, IAP, skylake_xeon, iap); PMC_CLASS_TABLE_DESC(ivybridge, IAP, ivybridge, iap); PMC_CLASS_TABLE_DESC(ivybridge_xeon, IAP, ivybridge_xeon, iap); PMC_CLASS_TABLE_DESC(sandybridge, IAP, sandybridge, iap); @@ -721,6 +728,8 @@ static struct pmc_event_alias core2_aliases_without_iaf[] = { #define broadwell_xeon_aliases_without_iaf core2_aliases_without_iaf #define skylake_aliases core2_aliases #define skylake_aliases_without_iaf core2_aliases_without_iaf +#define skylake_xeon_aliases core2_aliases +#define skylake_xeon_aliases_without_iaf core2_aliases_without_iaf #define ivybridge_aliases core2_aliases #define ivybridge_aliases_without_iaf core2_aliases_without_iaf #define ivybridge_xeon_aliases core2_aliases @@ -1017,27 +1026,28 @@ iap_allocate_pmc(enum pmc_event pe, char *ctrspec, return (-1); } else if (cpu_info.pm_cputype == PMC_CPU_INTEL_SANDYBRIDGE || cpu_info.pm_cputype == PMC_CPU_INTEL_SANDYBRIDGE_XEON || - cpu_info.pm_cputype == PMC_CPU_INTEL_IVYBRIDGE || - cpu_info.pm_cputype == PMC_CPU_INTEL_IVYBRIDGE_XEON ) { + cpu_info.pm_cputype == PMC_CPU_INTEL_IVYBRIDGE || + cpu_info.pm_cputype == PMC_CPU_INTEL_IVYBRIDGE_XEON ) { if (KWPREFIXMATCH(p, IAP_KW_RSP "=")) { n = pmc_parse_mask(iap_rsp_mask_sb_sbx_ib, p, &rsp); } else return (-1); } else if (cpu_info.pm_cputype == PMC_CPU_INTEL_HASWELL || - cpu_info.pm_cputype == PMC_CPU_INTEL_HASWELL_XEON) { + cpu_info.pm_cputype == PMC_CPU_INTEL_HASWELL_XEON) { if (KWPREFIXMATCH(p, IAP_KW_RSP "=")) { n = pmc_parse_mask(iap_rsp_mask_haswell, p, &rsp); } else return (-1); } else if (cpu_info.pm_cputype == PMC_CPU_INTEL_BROADWELL || - cpu_info.pm_cputype == PMC_CPU_INTEL_BROADWELL_XEON) { + cpu_info.pm_cputype == PMC_CPU_INTEL_BROADWELL_XEON) { /* Broadwell is defined to use same mask as haswell */ if (KWPREFIXMATCH(p, IAP_KW_RSP "=")) { n = pmc_parse_mask(iap_rsp_mask_haswell, p, &rsp); } else return (-1); - } else if (cpu_info.pm_cputype == PMC_CPU_INTEL_SKYLAKE) { + } else if (cpu_info.pm_cputype == PMC_CPU_INTEL_SKYLAKE || + cpu_info.pm_cputype == PMC_CPU_INTEL_SKYLAKE_XEON) { if (KWPREFIXMATCH(p, IAP_KW_RSP "=")) { n = pmc_parse_mask(iap_rsp_mask_skylake, p, &rsp); } else @@ -3007,6 +3017,10 @@ pmc_event_names_of_class(enum pmc_class cl, const char ***eventnames, ev = skylake_event_table; count = PMC_EVENT_TABLE_SIZE(skylake); break; + case PMC_CPU_INTEL_SKYLAKE_XEON: + ev = skylake_xeon_event_table; + count = PMC_EVENT_TABLE_SIZE(skylake_xeon); + break; case PMC_CPU_INTEL_IVYBRIDGE: ev = ivybridge_event_table; count = PMC_EVENT_TABLE_SIZE(ivybridge); @@ -3386,6 +3400,9 @@ pmc_init(void) case PMC_CPU_INTEL_SKYLAKE: PMC_MDEP_INIT_INTEL_V2(skylake); break; + case PMC_CPU_INTEL_SKYLAKE_XEON: + PMC_MDEP_INIT_INTEL_V2(skylake_xeon); + break; case PMC_CPU_INTEL_IVYBRIDGE: PMC_MDEP_INIT_INTEL_V2(ivybridge); break; @@ -3595,7 +3612,13 @@ _pmc_name_of_event(enum pmc_event pe, enum pmc_cputype cpu) break; case PMC_CPU_INTEL_SKYLAKE: ev = skylake_event_table; - evfence = skylake_event_table + PMC_EVENT_TABLE_SIZE(skylake); + evfence = skylake_event_table + + PMC_EVENT_TABLE_SIZE(skylake); + break; + case PMC_CPU_INTEL_SKYLAKE_XEON: + ev = skylake_xeon_event_table; + evfence = skylake_xeon_event_table + + PMC_EVENT_TABLE_SIZE(skylake_xeon); break; case PMC_CPU_INTEL_IVYBRIDGE: ev = ivybridge_event_table; diff --git lib/libpmcstat/Makefile lib/libpmcstat/Makefile new file mode 100644 index 000000000000..948a86767c84 --- /dev/null +++ lib/libpmcstat/Makefile @@ -0,0 +1,16 @@ +# $FreeBSD$ + +PACKAGE=lib${LIB} +LIB= pmcstat +INTERNALLIB= + +SRCS= \ + libpmcstat_event.c \ + libpmcstat_image.c \ + libpmcstat_logging.c \ + libpmcstat_process.c \ + libpmcstat_string.c \ + libpmcstat_symbol.c +INCS= libpmcstat.h + +.include <bsd.lib.mk> diff --git sys/boot/userboot/ficl/Makefile.depend lib/libpmcstat/Makefile.depend similarity index 88% rename from sys/boot/userboot/ficl/Makefile.depend rename to lib/libpmcstat/Makefile.depend index c04b7c302dd3..787f0cfde451 100644 --- sys/boot/userboot/ficl/Makefile.depend +++ lib/libpmcstat/Makefile.depend @@ -4,8 +4,8 @@ DIRDEPS = \ include \ include/xlocale \ - lib/libstand \ - lib/msun \ + lib/libelf \ + lib/libpmc \ .include <dirdeps.mk> diff --git lib/libpmcstat/libpmcstat.h lib/libpmcstat/libpmcstat.h new file mode 100644 index 000000000000..4ead605c88a9 --- /dev/null +++ lib/libpmcstat/libpmcstat.h @@ -0,0 +1,382 @@ +/*- + * Copyright (c) 2005-2007, Joseph Koshy + * Copyright (c) 2007 The FreeBSD Foundation + * All rights reserved. + * + * Portions of this software were developed by A. Joseph Koshy under + * sponsorship from the FreeBSD Foundation and Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions ########## TRUNCATED ###########