Finish merging from head, messed up in previous attempt

This commit is contained in:
bapt 2015-09-12 12:03:02 +00:00
commit 934c5c6da6
1897 changed files with 181379 additions and 60779 deletions

View File

@ -234,11 +234,16 @@ INSTALLTMP!= /usr/bin/mktemp -d -u -t install
# 2. build-tools stage [TMAKE]
# This stage is responsible for creating the object
# tree and building any tools that are needed during
# the build process.
# the build process. Some programs are listed during
# this phase because they build binaries to generate
# files needed to build these programs. This stage also
# builds the 'build-tools' target rather than 'all'.
# 3. cross-tools stage [XMAKE]
# This stage is responsible for creating any tools that
# are needed for building the system. A cross-compiler is one
# of them.
# of them. This differs from build tools in two ways:
# 1. the 'all' target is built rather than 'build-tools'
# 2. these tools are installed into TMPPATH for stage 4.
# 4. world stage [WMAKE]
# This stage actually builds the world.
# 5. install stage (optional) [IMAKE]
@ -459,7 +464,6 @@ LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
PATH=${TMPPATH} \
LIBDIR=/usr/lib32 \
SHLIBDIR=/usr/lib32 \
LIBPRIVATEDIR=/usr/lib32/private \
DTRACE="${DTRACE} -32"
LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
CXX="${XCXX} ${LIB32FLAGS}" \
@ -825,7 +829,7 @@ __installcheck_UGID:
_zoneinfo= zic tzsetup
.endif
ITOOLS= [ awk cap_mkdb cat chflags chmod chown \
ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
date echo egrep find grep id install ${_install-info} \
ln lockf make mkdir mtree mv pwd_mkdb \
rm sed services_mkdb sh strip sysctl test true uname wc ${_zoneinfo} \
@ -1155,6 +1159,16 @@ reinstallkernel reinstallkernel.debug: _installcheck_kernel
cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
${CROSSENV} PATH=${TMPPATH} \
${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
.if ${BUILDKERNELS:[#]} > 1
.for _kernel in ${BUILDKERNELS:[2..-1]}
@echo "--------------------------------------------------------------"
@echo ">>> Installing kernel ${_kernel}"
@echo "--------------------------------------------------------------"
cd ${KRNLOBJDIR}/${_kernel}; \
${CROSSENV} PATH=${TMPPATH} \
${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
.endfor
.endif
distributekernel distributekernel.debug:
.if empty(INSTALLKERNEL)
@ -1174,7 +1188,8 @@ distributekernel distributekernel.debug:
sed -e 's|^./kernel|.|' ${DESTDIR}/${DISTDIR}/kernel.premeta > \
${DESTDIR}/${DISTDIR}/kernel.meta
.endif
.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
.if ${BUILDKERNELS:[#]} > 1
.for _kernel in ${BUILDKERNELS:[2..-1]}
.if defined(NO_ROOT)
echo "#${MTREE_MAGIC}" > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.premeta
.endif
@ -1190,27 +1205,32 @@ distributekernel distributekernel.debug:
${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta
.endif
.endfor
.endif
packagekernel:
.if defined(NO_ROOT)
cd ${DESTDIR}/${DISTDIR}/kernel; \
tar cvf - @${DESTDIR}/${DISTDIR}/kernel.meta | \
${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.txz
.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
.if ${BUILDKERNELS:[#]} > 1
.for _kernel in ${BUILDKERNELS:[2..-1]}
cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
tar cvf - @${DESTDIR}/${DISTDIR}/kernel.${_kernel}.meta | \
${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz
.endfor
.endif
.else
cd ${DESTDIR}/${DISTDIR}/kernel; \
tar cvf - . | \
${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.txz
.for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//}
.if ${BUILDKERNELS:[#]} > 1
.for _kernel in ${BUILDKERNELS:[2..-1]}
cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \
tar cvf - . | \
${XZ_CMD} > ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz
.endfor
.endif
.endif
create-world-packages:
@rm -f ${DESTDIR}/*.plist 2>/dev/null || :
@ -1349,16 +1369,23 @@ update:
#
#
# legacy: Build compatibility shims for the next three targets. This is a minimal
# set of tools and shims necessary to compensate for older systems which don't have
# the APIs that the targets built in bootstrap-tools, build-tools or cross-tools.
# legacy: Build compatibility shims for the next three targets. This is a
# minimal set of tools and shims necessary to compensate for older systems
# which don't have the APIs required by the targets built in bootstrap-tools,
# build-tools or cross-tools.
#
# ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
.if ${BOOTSTRAPPING} < 1100006
_elftoolchain_libs= lib/libelf lib/libdwarf
.endif
legacy:
.if ${BOOTSTRAPPING} < 800107 && ${BOOTSTRAPPING} != 0
@echo "ERROR: Source upgrades from versions prior to 8.0 not supported."; \
false
.endif
.for _tool in tools/build
.for _tool in tools/build ${_elftoolchain_libs}
${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \
cd ${.CURDIR}/${_tool} && \
${MAKE} DIRPRFX=${_tool}/ obj && \
@ -1421,7 +1448,8 @@ _lex= usr.bin/lex
# r277259 crunchide: Correct 64-bit section header offset
# r281674 crunchide: always include both 32- and 64-bit ELF support
.if ${BOOTSTRAPPING} < 1100071
# r285986 crunchen: use STRIPBIN rather than STRIP
.if ${BOOTSTRAPPING} < 1100078
_crunch= usr.sbin/crunch
.endif
@ -1456,13 +1484,12 @@ ${_bt}-usr.bin/clang/tblgen: ${_bt}-lib/clang/libllvmtablegen ${_bt}-lib/clang/l
# pre libdwarf
.if ${BOOTSTRAPPING} < 1100006 || (${MACHINE} != ${TARGET} || \
${MACHINE_ARCH} != ${TARGET_ARCH})
_elftoolchain_libs= lib/libelf lib/libdwarf
.if ${MK_CDDL} != "no"
_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf cddl/usr.bin/ctfconvert \
cddl/usr.bin/ctfmerge
${_bt}-cddl/usr.bin/ctfconvert: ${_bt}-lib/libelf ${_bt}-lib/libdwarf ${_bt}-cddl/lib/libctf
${_bt}-cddl/usr.bin/ctfmerge: ${_bt}-lib/libelf ${_bt}-lib/libdwarf ${_bt}-cddl/lib/libctf
${_bt}-cddl/usr.bin/ctfconvert: ${_bt}-cddl/lib/libctf
${_bt}-cddl/usr.bin/ctfmerge: ${_bt}-cddl/lib/libctf
.endif
.endif
@ -1505,7 +1532,6 @@ bootstrap-tools: .PHONY
.for _tool in \
${_clang_tblgen} \
${_kerberos5_bootstrap_tools} \
${_elftoolchain_libs} \
${_dtrace_tools} \
${_strfile} \
${_gperf} \
@ -1551,6 +1577,7 @@ _gcc_tools= gnu/usr.bin/cc/cc_tools
.endif
.if ${MK_RESCUE} != "no"
# rescue includes programs that have build-tools targets
_rescue=rescue/rescue
.endif
@ -1558,10 +1585,10 @@ build-tools: .MAKE
.for _tool in \
bin/csh \
bin/sh \
${_rescue} \
${LOCAL_TOOL_DIRS} \
lib/ncurses/ncurses \
lib/ncurses/ncursesw \
${_rescue} \
${_share} \
usr.bin/awk \
lib/libmagic \
@ -1606,7 +1633,7 @@ _btxld= usr.sbin/btxld
.if ${MK_BINUTILS_BOOTSTRAP} != "no"
_binutils= gnu/usr.bin/binutils
.endif
.if ${MK_ELFTOOLCHAIN_TOOLS} != "no"
.if ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
_elftctools= lib/libelftc \
usr.bin/elfcopy \
usr.bin/nm \
@ -1616,7 +1643,7 @@ _elftctools= lib/libelftc \
# cross-build on a FreeBSD 10 host:
_elftctools+= usr.bin/addr2line
.endif
.elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_TOOLS} != "no"
.elif ${TARGET_ARCH} != ${MACHINE_ARCH} && ${MK_ELFTOOLCHAIN_BOOTSTRAP} != "no"
# If cross-building with an external binutils we still need to build strip for
# the target (for at least crunchide).
_elftctools= lib/libelftc \
@ -1890,9 +1917,7 @@ cddl/lib/libctf__L: lib/libz__L
.endif
# cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
# on select architectures though (see cddl/lib/Makefile)
.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_ARCH} == "amd64" || \
${MACHINE_CPUARCH} == "arm" || ${MACHINE_ARCH} == "i386" || \
${MACHINE_CPUARCH} == "mips" || ${MACHINE_CPUARCH} == "powerpc"
.if ${MACHINE_CPUARCH} != "sparc64"
_prebuild_libs+= lib/libproc lib/librtld_db
.endif

View File

@ -38,6 +38,14 @@
# xargs -n1 | sort | uniq -d;
# done
# 20150818: *allocm() are gone in jemalloc 4.0.0
OLD_FILES+=usr/share/man/man3/allocm.3.gz
OLD_FILES+=usr/share/man/man3/dallocm.3.gz
OLD_FILES+=usr/share/man/man3/nallocm.3.gz
OLD_FILES+=usr/share/man/man3/rallocm.3.gz
OLD_FILES+=usr/share/man/man3/sallocm.3.gz
# 20150802: Remove netbsd's test on pw(8)
OLD_FILES+=usr/tests/usr.sbin/pw/pw_test
# 20150719: Remove libarchive.pc
OLD_FILES+=usr/libdata/pkgconfig/libarchive.pc
# 20150705: Rename DTrace provider man pages.
@ -47,6 +55,9 @@ OLD_FILES+=usr/share/man/man4/dtrace-proc.4.gz
OLD_FILES+=usr/share/man/man4/dtrace-sched.4.gz
OLD_FILES+=usr/share/man/man4/dtrace-tcp.4.gz
OLD_FILES+=usr/share/man/man4/dtrace-udp.4.gz
# 20150624
OLD_LIBS+=usr/lib/libugidfw.so.4
OLD_LIBS+=usr/lib32/libugidfw.so.4
# 20150604: Move nvlist man pages to section 9.
OLD_FILES+=usr/share/man/man3/libnv.3.gz
OLD_FILES+=usr/share/man/man3/nvlist.3.gz

View File

@ -31,6 +31,79 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
20150827:
The wireless drivers had undergone changes that remove the 'parent
interface' from the ifconfig -l output. The rc.d network scripts
used to check presence of a parent interface in the list, so old
scripts would fail to start wireless networking. Thus, etcupdate(3)
or mergemaster(8) run is required after kernel update, to update your
rc.d scripts in /etc.
20150827:
pf no longer supports 'scrub fragment crop' or 'scrub fragment drop-ovl'
These configurations are now automatically interpreted as
'scrub fragment reassemble'.
20150817:
Kernel-loadable modules for the random(4) device are back. To use
them, the kernel must have
device random
options RANDOM_LOADABLE
kldload(8) can then be used to load random_fortuna.ko
or random_yarrow.ko. Please note that due to the indirect
function calls that the loadable modules need to provide,
the build-in variants will be slightly more efficient.
The random(4) kernel option RANDOM_DUMMY has been retired due to
unpopularity. It was not all that useful anyway.
20150813:
The WITHOUT_ELFTOOLCHAIN_TOOLS src.conf(5) knob has been retired.
Control over building the ELF Tool Chain tools is now provided by
the WITHOUT_TOOLCHAIN knob.
20150810:
The polarity of Pulse Per Second (PPS) capture events with the
uart(4) driver has been corrected. Prior to this change the PPS
"assert" event corresponded to the trailing edge of a positive PPS
pulse and the "clear" event was the leading edge of the next pulse.
As the width of a PPS pulse in a typical GPS receiver is on the
order of 1 millisecond, most users will not notice any significant
difference with this change.
Anyone who has compensated for the historical polarity reversal by
configuring a negative offset equal to the pulse width will need to
remove that workaround.
20150809:
The default group assigned to /dev/dri entries has been changed
from 'wheel' to 'video' with the id of '44'. If you want to have
access to the dri devices please add yourself to the video group
with:
# pw groupmod video -m $USER
20150806:
The menu.rc and loader.rc files will now be replaced during
upgrades. Please migrate local changes to menu.rc.local and
loader.rc.local instead.
20150805:
GNU Binutils versions of addr2line, c++filt, nm, readelf, size,
strings and strip have been removed. The src.conf(5) knob
WITHOUT_ELFTOOLCHAIN_TOOLS no longer provides the binutils tools.
20150728:
As ZFS requires more kernel stack pages than is the default on some
architectures e.g. i386, it now warns if KSTACK_PAGES is less than
ZFS_MIN_KSTACK_PAGES (which is 4 at the time of writing).
Please consider using 'options KSTACK_PAGES=X' where X is greater
than or equal to ZFS_MIN_KSTACK_PAGES i.e. 4 in such configurations.
20150706:
sendmail has been updated to 8.15.2. Starting with FreeBSD 11.0
and sendmail 8.15, sendmail uses uncompressed IPv6 addresses by
@ -216,7 +289,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
taken from the ELF Tool Chain project rather than GNU binutils. They
should be drop-in replacements, with the addition of arm64 support.
The WITHOUT_ELFTOOLCHAIN_TOOLS= knob may be used to obtain the
binutils tools, if necessary.
binutils tools, if necessary. See 20150805 for updated information.
20150105:
The default Unbound configuration now enables remote control
@ -569,6 +642,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
or
# pkg install pkg; ldd /usr/local/sbin/pkg | grep bsdyml
20131010:
The stable/10 branch has been created in subversion from head
revision r256279.
20131010:
The rc.d/jail script has been updated to support jail(8)
configuration file. The "jail_<jname>_*" rc.conf(5) variables
@ -1112,6 +1189,13 @@ COMMON ITEMS:
around can lead to problems if pam has changed too much from your
starting point to allow continued authentication after the upgrade.
This file should be read as a log of events. When a later event changes
information of a prior event, the prior event should not be deleted.
Instead, a pointer to the entry with the new information should be
placed in the old entry. Readers of this file should also sanity check
older entries before relying on them blindly. Authors of new entries
should write them with this in mind.
ZFS notes
---------
When upgrading the boot ZFS pool to a new version, always follow
@ -1282,7 +1366,7 @@ FORMAT:
This file contains a list, in reverse chronological order, of major
breakages in tracking -current. It is not guaranteed to be a complete
list of such breakages, and only contains entries since October 10, 2007.
list of such breakages, and only contains entries since September 23, 2011.
If you need to see UPDATING entries from before that date, you will need
to fetch an UPDATING file from an older FreeBSD release.

View File

@ -311,7 +311,7 @@ main(int argc, char *argv[])
xo_close_container("storage-system-information");
xo_finish();
return (rv);
exit(rv);
}
static char *

View File

@ -5,7 +5,7 @@
PROG= ls
SRCS= cmp.c ls.c print.c util.c
LIBADD= util xo
LIBADD= xo util
.if !defined(RELEASE_CRUNCH) && \
${MK_LS_COLORS} != no

View File

@ -5,7 +5,7 @@
PROG= pkill
LIBADD= kvm
LIBADD= kvm jail
LINKS= ${BINDIR}/pkill ${BINDIR}/pgrep
MLINKS= pkill.1 pgrep.1

View File

@ -9,6 +9,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libjail \
lib/libkvm \

View File

@ -29,7 +29,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd August 9, 2013
.Dd August 21, 2015
.Dt PKILL 1
.Os
.Sh NAME
@ -47,7 +47,7 @@
.Op Fl c Ar class
.Op Fl d Ar delim
.Op Fl g Ar pgrp
.Op Fl j Ar jid
.Op Fl j Ar jail
.Op Fl s Ar sid
.Op Fl t Ar tty
.Op Fl u Ar euid
@ -63,7 +63,7 @@
.Op Fl U Ar uid
.Op Fl c Ar class
.Op Fl g Ar pgrp
.Op Fl j Ar jid
.Op Fl j Ar jail
.Op Fl s Ar sid
.Op Fl t Ar tty
.Op Fl u Ar euid
@ -149,16 +149,16 @@ or
command.
.It Fl i
Ignore case distinctions in both the process table and the supplied pattern.
.It Fl j Ar jid
Restrict matches to processes inside jails with a jail ID in the comma-separated
list
.Ar jid .
The value
.It Fl j Ar jail
Restrict matches to processes inside the specified jails.
The argument
.Ar jail
may be
.Dq Li any
matches processes in any jail.
The value
to match processes in any jail,
.Dq Li none
matches processes not in jail.
to match processes not in jail,
or a comma-separated list of jail IDs or names.
.It Fl l
Long output.
For

View File

@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <grp.h>
#include <errno.h>
#include <locale.h>
#include <jail.h>
#define STATUS_MATCH 0
#define STATUS_NOMATCH 1
@ -78,7 +79,7 @@ enum listtype {
LT_GROUP,
LT_TTY,
LT_PGRP,
LT_JID,
LT_JAIL,
LT_SID,
LT_CLASS
};
@ -245,7 +246,7 @@ main(int argc, char **argv)
cflags |= REG_ICASE;
break;
case 'j':
makelist(&jidlist, LT_JID, optarg);
makelist(&jidlist, LT_JAIL, optarg);
criteria = 1;
break;
case 'l':
@ -585,7 +586,7 @@ usage(void)
fprintf(stderr,
"usage: %s %s [-F pidfile] [-G gid] [-M core] [-N system]\n"
" [-P ppid] [-U uid] [-c class] [-g pgrp] [-j jid]\n"
" [-P ppid] [-U uid] [-c class] [-g pgrp] [-j jail]\n"
" [-s sid] [-t tty] [-u euid] pattern ...\n",
getprogname(), ustr);
@ -700,7 +701,7 @@ makelist(struct listhead *head, enum listtype type, char *src)
if (li->li_number == 0)
li->li_number = getsid(mypid);
break;
case LT_JID:
case LT_JAIL:
if (li->li_number < 0)
errx(STATUS_BADUSAGE,
"Negative jail ID `%s'", sp);
@ -766,15 +767,20 @@ foundtty: if ((st.st_mode & S_IFCHR) == 0)
li->li_number = st.st_rdev;
break;
case LT_JID:
case LT_JAIL: {
int jid;
if (strcmp(sp, "none") == 0)
li->li_number = 0;
else if (strcmp(sp, "any") == 0)
li->li_number = -1;
else if ((jid = jail_getid(sp)) != -1)
li->li_number = jid;
else if (*ep != '\0')
errx(STATUS_BADUSAGE,
"Invalid jail ID `%s'", sp);
"Invalid jail ID or name `%s'", sp);
break;
}
case LT_CLASS:
li->li_number = -1;
li->li_name = strdup(sp);

View File

@ -14,7 +14,7 @@ if [ `id -u` -ne 0 ]; then
exit 0
fi
echo "1..3"
echo "1..4"
sleep=$(pwd)/sleep.txt
ln -sf /bin/sleep $sleep
@ -87,5 +87,30 @@ else
fi
[ -f ${PWD}/${base}_3_1.pid ] && kill $(cat $PWD/${base}_3_1.pid)
[ -f ${PWD}/${base}_3_2.pid ] && kill $(cat $PWD/${base}_3_2.pid)
wait
# test 4 is like test 1 except with jname instead of jid.
name="pgrep -j <jname>"
sleep_amount=8
jail -c path=/ name=${base}_4_1 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_4_1.pid $sleep $sleep_amount &
jail -c path=/ name=${base}_4_2 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_4_2.pid $sleep $sleep_amount &
sleep 0.5
jname="${base}_4_1,${base}_4_2"
pid1="$(pgrep -f -x -j "$jname" "$sleep $sleep_amount" | sort)"
pid2=$(printf "%s\n%s" "$(cat ${PWD}/${base}_4_1.pid)" \
$(cat ${PWD}/${base}_4_2.pid) | sort)
if [ "$pid1" = "$pid2" ]; then
echo "ok 4 - $name"
else
echo "not ok 4 - $name # pgrep output: '$(echo $pid1)', pidfile output: '$(echo $pid2)'"
fi
[ -f ${PWD}/${base}_4_1.pid ] && kill $(cat ${PWD}/${base}_4_1.pid)
[ -f ${PWD}/${base}_4_2.pid ] && kill $(cat ${PWD}/${base}_4_2.pid)
wait
rm -f $sleep

View File

@ -14,7 +14,7 @@ if [ `id -u` -ne 0 ]; then
exit 0
fi
echo "1..3"
echo "1..4"
sleep=$(pwd)/sleep.txt
ln -sf /bin/sleep $sleep
@ -90,5 +90,31 @@ else
fi 2>/dev/null
[ -f ${PWD}/${base}_3_1.pid ] && kill $(cat ${base}_3_1.pid)
[ -f ${PWD}/${base}_3_2.pid ] && kill $(cat ${base}_3_2.pid)
wait
# test 4 is like test 1 except with jname instead of jid.
name="pkill -j <jname>"
sleep_amount=8
jail -c path=/ name=${base}_4_1 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_4_1.pid $sleep $sleep_amount &
jail -c path=/ name=${base}_4_2 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_4_2.pid $sleep $sleep_amount &
$sleep $sleep_amount &
sleep 0.5
jname="${base}_4_1,${base}_4_2"
if pkill -f -j "$jname" $sleep && sleep 0.5 &&
! -f ${PWD}/${base}_4_1.pid &&
! -f ${PWD}/${base}_4_2.pid ; then
echo "ok 4 - $name"
else
echo "not ok 4 - $name"
fi 2>/dev/null
[ -f ${PWD}/${base}_4_1.pid ] && kill $(cat ${PWD}/${base}_4_1.pid)
[ -f ${PWD}/${base}_4_2.pid ] && kill $(cat ${PWD}/${base}_4_2.pid)
wait
rm -f $sleep

View File

@ -11,6 +11,6 @@ SRCS= fmt.c keyword.c nlist.c print.c ps.c
# on large systems.
#
CFLAGS+=-DLAZY_PS
LIBADD= m kvm jail xo
LIBADD= m kvm jail xo util
.include <bsd.prog.mk>

View File

@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <fts.h>
#include <grp.h>
#include <locale.h>
#include <pwd.h>
#include <stdint.h>
#include <stdio.h>
@ -86,6 +87,8 @@ main(int argc, char *argv[])
int ch;
char *p;
(void)setlocale(LC_ALL, "");
/*
* Test for the special case where the utility is called as
* "unlink", for which the functionality provided is greatly

View File

@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd April 1, 2013
.Dd September 4, 2015
.Dt SETFACL 1
.Os
.Sh NAME
@ -378,9 +378,11 @@ dir_inherit
inherit_only
.It n
no_propagate
.It I
inherited
.El
.Pp
Inheritance flags may be only set on directories.
Other than the "inherited" flag, inheritance flags may be only set on directories.
.It Ar "ACL type"
The ACL type field is either
.Dq Li allow

View File

@ -886,7 +886,7 @@ varvalue(const char *name, int quoted, int subtype, int flag)
num = backgndpidval();
break;
case '-':
for (i = 0 ; i < NOPTS ; i++) {
for (i = 0 ; i < NSHORTOPTS ; i++) {
if (optlist[i].val)
STPUTC(optlist[i].letter, expdest);
}
@ -1464,21 +1464,11 @@ patmatch(const char *pattern, const char *string, int squoted)
bt_q = q;
break;
case '[': {
const char *endp;
const char *savep, *saveq;
int invert, found;
wchar_t chr;
endp = p;
if (*endp == '!' || *endp == '^')
endp++;
do {
while (*endp == CTLQUOTEMARK)
endp++;
if (*endp == 0)
goto dft; /* no matching ] */
if (*endp == CTLESC)
endp++;
} while (*++endp != ']');
savep = p, saveq = q;
invert = 0;
if (*p == '!' || *p == '^') {
invert++;
@ -1497,6 +1487,11 @@ patmatch(const char *pattern, const char *string, int squoted)
chr = (unsigned char)*q++;
c = *p++;
do {
if (c == '\0') {
p = savep, q = saveq;
c = '[';
goto dft;
}
if (c == CTLQUOTEMARK)
continue;
if (c == '[' && *p == ':') {

View File

@ -100,6 +100,7 @@ readcmd(int argc __unused, char **argv __unused)
int i;
int is_ifs;
int saveall = 0;
ptrdiff_t lastnonifs, lastnonifsws;
struct timeval tv;
char *tvptr;
fd_set ifds;
@ -169,6 +170,7 @@ readcmd(int argc __unused, char **argv __unused)
startword = 2;
backslash = 0;
STARTSTACKSTR(p);
lastnonifs = lastnonifsws = -1;
for (;;) {
nread = read(STDIN_FILENO, &c, 1);
if (nread == -1) {
@ -191,9 +193,11 @@ readcmd(int argc __unused, char **argv __unused)
CHECKSTRSPACE(1, p);
if (backslash) {
backslash = 0;
if (c != '\n') {
startword = 0;
if (c != '\n')
lastnonifs = lastnonifsws = p - stackblock();
USTPUTC(c, p);
}
continue;
}
if (!rflag && c == '\\') {
@ -217,8 +221,10 @@ readcmd(int argc __unused, char **argv __unused)
if (is_ifs == 2 && startword == 1) {
/* Only one non-whitespace IFS per word */
startword = 2;
if (saveall)
if (saveall) {
lastnonifsws = p - stackblock();
USTPUTC(c, p);
}
continue;
}
}
@ -229,6 +235,7 @@ readcmd(int argc __unused, char **argv __unused)
if (saveall)
/* Not just a spare terminator */
saveall++;
lastnonifs = lastnonifsws = p - stackblock();
USTPUTC(c, p);
continue;
}
@ -239,6 +246,8 @@ readcmd(int argc __unused, char **argv __unused)
if (ap[1] == NULL) {
/* Last variable needs all IFS chars */
saveall++;
if (is_ifs == 2)
lastnonifsws = p - stackblock();
USTPUTC(c, p);
continue;
}
@ -247,20 +256,17 @@ readcmd(int argc __unused, char **argv __unused)
setvar(*ap, stackblock(), 0);
ap++;
STARTSTACKSTR(p);
lastnonifs = lastnonifsws = -1;
}
STACKSTRNUL(p);
/* Remove trailing IFS chars */
for (; stackblock() <= --p; *p = 0) {
if (!strchr(ifs, *p))
break;
if (strchr(" \t\n", *p))
/* Always remove whitespace */
continue;
if (saveall > 1)
/* Don't remove non-whitespace unless it was naked */
break;
}
/*
* Remove trailing IFS chars: always remove whitespace, don't remove
* non-whitespace unless it was naked
*/
if (saveall <= 1)
lastnonifsws = lastnonifs;
stackblock()[lastnonifsws + 1] = '\0';
setvar(*ap, stackblock(), 0);
/* Set any remaining args to "" */

View File

@ -73,6 +73,7 @@ char *minusc; /* argument to -c option */
static void options(int);
static void minus_o(char *, int);
static void setoption(int, int);
static void setoptionbyindex(int, int);
static int getopts(char *, char *, char **, char ***, char **);
@ -269,7 +270,7 @@ minus_o(char *name, int val)
} else {
for (i = 0; i < NOPTS; i++)
if (equal(name, optlist[i].name)) {
setoption(optlist[i].letter, val);
setoptionbyindex(i, val);
return;
}
error("Illegal option -o %s", name);
@ -278,26 +279,32 @@ minus_o(char *name, int val)
static void
setoption(int flag, int val)
setoptionbyindex(int idx, int val)
{
int i;
if (flag == 'p' && !val && privileged) {
if (optlist[idx].letter == 'p' && !val && privileged) {
if (setgid(getgid()) == -1)
error("setgid");
if (setuid(getuid()) == -1)
error("setuid");
}
for (i = 0; i < NOPTS; i++)
if (optlist[i].letter == flag) {
optlist[i].val = val;
optlist[idx].val = val;
if (val) {
/* #%$ hack for ksh semantics */
if (flag == 'V')
if (optlist[idx].letter == 'V')
Eflag = 0;
else if (flag == 'E')
else if (optlist[idx].letter == 'E')
Vflag = 0;
}
}
static void
setoption(int flag, int val)
{
int i;
for (i = 0; i < NSHORTOPTS; i++)
if (optlist[i].letter == flag) {
setoptionbyindex(i, val);
return;
}
error("Illegal option -%c", flag);

View File

@ -64,8 +64,10 @@ struct shparam {
#define Tflag optlist[16].val
#define Pflag optlist[17].val
#define hflag optlist[18].val
#define nologflag optlist[19].val
#define NOPTS 19
#define NSHORTOPTS 19
#define NOPTS 20
struct optent {
const char *name;
@ -95,6 +97,7 @@ struct optent optlist[NOPTS] = {
{ "trapsasync", 'T', 0 },
{ "physical", 'P', 0 },
{ "trackall", 'h', 0 },
{ "nolog", '\0', 0 },
};
#endif

View File

@ -106,6 +106,8 @@ static int startlinno; /* line # where last token started */
static int funclinno; /* line # where the current function started */
static struct parser_temp *parser_temp;
#define NOEOFMARK ((const char *)&heredoclist)
static union node *list(int);
static union node *andor(void);
@ -972,6 +974,10 @@ checkend(int c, const char *eofmark, int striptabs)
pungetc();
pushstring(eofmark + 1, q - (eofmark + 1), NULL);
}
} else if (c == '\n' && *eofmark == '\0') {
c = PEOF;
plinno++;
needprompt = doprompt;
}
return (c);
}
@ -1195,7 +1201,8 @@ parsebackq(char *out, struct nodelist **pbqlist,
static char *
readcstyleesc(char *out)
{
int c, v, i, n;
int c, vc, i, n;
unsigned int v;
c = pgetc();
switch (c) {
@ -1310,12 +1317,12 @@ readcstyleesc(char *out)
default:
synerror("Bad escape sequence");
}
v = (char)v;
vc = (char)v;
/*
* We can't handle NUL bytes.
* POSIX says we should skip till the closing quote.
*/
if (v == '\0') {
if (vc == '\0') {
while ((c = pgetc()) != '\'') {
if (c == '\\')
c = pgetc();
@ -1332,9 +1339,9 @@ readcstyleesc(char *out)
pungetc();
return out;
}
if (SQSYNTAX[v] == CCTL)
if (SQSYNTAX[vc] == CCTL)
USTPUTC(CTLESC, out);
USTPUTC(v, out);
USTPUTC(vc, out);
return out;
}
@ -1382,7 +1389,7 @@ readtoken1(int firstc, char const *initialsyntax, const char *eofmark,
STARTSTACKSTR(out);
loop: { /* for each line, until end of word */
if (eofmark)
if (eofmark && eofmark != NOEOFMARK)
/* set c to PEOF if at end of here document */
c = checkend(c, eofmark, striptabs);
for (;;) { /* until end of line or end of word */
@ -1661,7 +1668,7 @@ parsesub: {
pungetc();
else if (c == '\n' || c == PEOF)
synerror("Unexpected end of line in substitution");
else
else if (BASESYNTAX[c] != CCTL)
USTPUTC(c, out);
}
if (subtype == 0) {
@ -1677,6 +1684,7 @@ parsesub: {
synerror("Unexpected end of line in substitution");
if (flags == VSNUL)
STPUTC(':', out);
if (BASESYNTAX[c] != CCTL)
STPUTC(c, out);
subtype = VSERROR;
} else
@ -2044,7 +2052,7 @@ expandstr(const char *ps)
parser_temp = NULL;
setinputstring(ps, 1);
doprompt = 0;
readtoken1(pgetc(), DQSYNTAX, "", 0);
readtoken1(pgetc(), DQSYNTAX, NOEOFMARK, 0);
if (backquotelist != NULL)
error("Command substitution not allowed here");

View File

@ -32,7 +32,7 @@
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
.\" $FreeBSD$
.\"
.Dd July 11, 2015
.Dd August 29, 2015
.Dt SH 1
.Os
.Sh NAME
@ -343,6 +343,11 @@ Write each command
variable subjected to parameter expansion and arithmetic expansion)
to standard error before it is executed.
Useful for debugging.
.It nolog
Another do-nothing option for
.Tn POSIX
compliance.
It only has a long name.
.El
.Pp
The
@ -1173,7 +1178,9 @@ The only special parameter that can be made local is
.Ql - .
Making
.Ql -
local causes any shell options that are
local causes any shell options
(including those that only have long names)
that are
changed via the
.Ic set
command inside the function to be

View File

@ -39,6 +39,7 @@ FILES+= case16.0
FILES+= case17.0
FILES+= case18.0
FILES+= case19.0
FILES+= case20.0
FILES+= cd1.0
FILES+= cd2.0
FILES+= cd3.0
@ -121,6 +122,8 @@ FILES+= read4.0 read4.0.stdout
FILES+= read5.0
FILES+= read6.0
FILES+= read7.0
FILES+= read8.0
FILES+= read9.0
FILES+= return1.0
FILES+= return2.1
FILES+= return3.1

View File

@ -0,0 +1,9 @@
# $FreeBSD$
# Shells do not agree about what this pattern should match, but it is
# certain that it must not crash and the missing close bracket must not
# be simply ignored.
case B in
[[:alpha:]) echo bad ;;
esac

View File

@ -0,0 +1,17 @@
# $FreeBSD$
read a b c <<\EOF
\
A\
\
\
\
B\
\
\
C\
\
\
\
EOF
[ "$a.$b.$c" = "A.B.C" ]

View File

@ -0,0 +1,10 @@
# $FreeBSD$
empty=''
read a b c <<EOF
\ \ A B\ \ B C\ \ $empty
EOF
read d e <<EOF
D\ $empty
EOF
[ "$a.$b.$c.$d.$e" = " A.B B.C .D ." ]

View File

@ -19,6 +19,8 @@ FILES+= bad-parm-exp3.2 bad-parm-exp3.2.stderr
FILES+= bad-parm-exp4.2 bad-parm-exp4.2.stderr
FILES+= bad-parm-exp5.2 bad-parm-exp5.2.stderr
FILES+= bad-parm-exp6.2 bad-parm-exp6.2.stderr
FILES+= bad-parm-exp7.0
FILES+= bad-parm-exp8.0
FILES+= option-error.0
FILES+= redirection-error.0
FILES+= redirection-error2.2

View File

@ -0,0 +1,4 @@
# $FreeBSD$
v=1
eval ": $(printf '${v-${\372}}')"

View File

@ -0,0 +1,4 @@
# $FreeBSD$
v=1
eval ": $(printf '${v-${w\372}}')"

View File

@ -36,6 +36,8 @@ FILES+= dollar-quote8.0
FILES+= dollar-quote9.0
FILES+= dollar-quote10.0
FILES+= dollar-quote11.0
FILES+= dollar-quote12.0
FILES+= dollar-quote13.0
FILES+= empty-braces1.0
FILES+= empty-cmd1.0
FILES+= for1.0
@ -55,6 +57,7 @@ FILES+= heredoc9.0
FILES+= heredoc10.0
FILES+= heredoc11.0
FILES+= heredoc12.0
FILES+= heredoc13.0
FILES+= line-cont1.0
FILES+= line-cont2.0
FILES+= line-cont3.0

View File

@ -0,0 +1,7 @@
# $FreeBSD$
# \u without any digits at all remains invalid.
# Our choice is a parse error.
v=$( (eval ": \$'\u'") 2>&1 >/dev/null)
[ $? -ne 0 ] && [ -n "$v" ]

View File

@ -0,0 +1,8 @@
# $FreeBSD$
# This Unicode escape sequence that has never been in range should either
# fail to expand or expand to a fallback.
c=$(eval printf %s \$\'\\Uffffff41\' 2>/dev/null)
r=$(($? != 0))
[ "$r.$c" = '1.' ] || [ "$r.$c" = '0.?' ] || [ "$r.$c" = $'0.\u2222' ]

View File

@ -0,0 +1,21 @@
# $FreeBSD$
failures=0
check() {
if ! eval "[ $* ]"; then
echo "Failed: $*"
: $((failures += 1))
fi
}
check '"$(cat <<""
echo yes)" = "yes"'
check '"$(cat <<""
yes
)" = "yes"'
exit $((failures != 0))

View File

@ -34,7 +34,7 @@
*
*/
lockstat:kernel:mtx_lock:adaptive-acquire
lockstat:::adaptive-acquire
{
mutex_owned();
exit(1);

View File

@ -34,7 +34,7 @@
*
*/
lockstat:kernel:mtx_lock:adaptive-acquire
lockstat:::adaptive-acquire
{
mutex_owned((kmutex_t *)arg0, 99);
exit(1);

View File

@ -36,7 +36,7 @@
*/
lockstat:kernel:mtx_lock:adaptive-acquire
lockstat:::adaptive-acquire
{
mutex_type_adaptive();
exit(1);

View File

@ -35,7 +35,7 @@
*/
lockstat:kernel:mtx_lock:adaptive-acquire
lockstat:::adaptive-acquire
{
mutex_type_adaptive((kmutex_t *)arg0, 99);
exit(1);

View File

@ -48,7 +48,7 @@ BEGIN
i = 0;
}
lockstat::mtx_lock:adaptive-acquire
lockstat:::adaptive-acquire
{
ptr = mutex_owner((struct mtx *)arg0);

View File

@ -44,7 +44,7 @@ BEGIN
ret = -99;
}
mtx_lock:adaptive-acquire
lockstat:::adaptive-acquire
{
ret = mutex_type_adaptive((struct mtx *)arg0);
i++;

View File

@ -1,4 +1,4 @@
#!/usr/bin/perl -w
#!/usr/bin/env perl
#
# CDDL HEADER START
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/perl -w
#!/usr/bin/env perl
#
# CDDL HEADER START
#

View File

@ -58,12 +58,25 @@ fi
dtrace=$1
local=127.0.0.1
tcpport=22
DIR=/var/tmp/dtest.$$
tcpport=1024
bound=5000
while [ $tcpport -lt $bound ]; do
nc -z $local $tcpport >/dev/null || break
tcpport=$(($tcpport + 1))
done
if [ $tcpport -eq $bound ]; then
echo "couldn't find an available TCP port"
exit 1
fi
mkdir $DIR
cd $DIR
# nc will exit when the connection is closed.
nc -l $local $tcpport &
cat > test.pl <<-EOPERL
use IO::Socket;
my \$s = IO::Socket::INET->new(
@ -76,7 +89,7 @@ cat > test.pl <<-EOPERL
sleep(2);
EOPERL
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
BEGIN
{
ipsend = tcpsend = ipreceive = tcpreceive = 0;

View File

@ -79,7 +79,7 @@ cat > test.pl <<-EOPERL
sleep(2);
EOPERL
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
BEGIN
{
ipsend = tcpsend = ipreceive = tcpreceive = 0;

View File

@ -82,7 +82,7 @@ cat > test.pl <<-EOPERL
sleep(2);
EOPERL
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
BEGIN
{
ipsend = tcpsend = ipreceive = tcpreceive = 0;

View File

@ -87,7 +87,7 @@ cat > test.pl <<-EOPERL
sleep(2);
EOPERL
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
BEGIN
{
ipsend = tcpsend = ipreceive = tcpreceive = 0;

View File

@ -132,6 +132,8 @@ typedef struct msg_string {
static msg_string *msg_head;
static msg_string *msg_tail;
int aok;
/*
* message_append() is responsible for both inserting strings into
* the master Str_tbl as well as maintaining a list of the

View File

@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
*/
#include <stdio.h>
@ -95,6 +95,8 @@ static int zopt_objects = 0;
static libzfs_handle_t *g_zfs;
static uint64_t max_inflight = 1000;
static void snprintf_blkptr_compact(char *, size_t, const blkptr_t *);
/*
* These libumem hooks provide a reasonable set of defaults for the allocator's
* debugging facilities.
@ -418,6 +420,79 @@ dump_zap(objset_t *os, uint64_t object, void *data, size_t size)
zap_cursor_fini(&zc);
}
static void
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];
if (bpop == NULL)
return;
zdb_nicenum(bpop->bpo_bytes, bytes);
zdb_nicenum(bpop->bpo_comp, comp);
zdb_nicenum(bpop->bpo_uncomp, uncomp);
(void) printf("\t\tnum_blkptrs = %llu\n",
(u_longlong_t)bpop->bpo_num_blkptrs);
(void) printf("\t\tbytes = %s\n", bytes);
if (size >= BPOBJ_SIZE_V1) {
(void) printf("\t\tcomp = %s\n", comp);
(void) printf("\t\tuncomp = %s\n", uncomp);
}
if (size >= sizeof (*bpop)) {
(void) printf("\t\tsubobjs = %llu\n",
(u_longlong_t)bpop->bpo_subobjs);
(void) printf("\t\tnum_subobjs = %llu\n",
(u_longlong_t)bpop->bpo_num_subobjs);
}
if (dump_opt['d'] < 5)
return;
for (uint64_t i = 0; i < bpop->bpo_num_blkptrs; i++) {
char blkbuf[BP_SPRINTF_LEN];
blkptr_t bp;
int err = dmu_read(os, object,
i * sizeof (bp), sizeof (bp), &bp, 0);
if (err != 0) {
(void) printf("got error %u from dmu_read\n", err);
break;
}
snprintf_blkptr_compact(blkbuf, sizeof (blkbuf), &bp);
(void) printf("\t%s\n", blkbuf);
}
}
/* ARGSUSED */
static void
dump_bpobj_subobjs(objset_t *os, uint64_t object, void *data, size_t size)
{
dmu_object_info_t doi;
VERIFY0(dmu_object_info(os, object, &doi));
uint64_t *subobjs = kmem_alloc(doi.doi_max_offset, KM_SLEEP);
int err = dmu_read(os, object, 0, doi.doi_max_offset, subobjs, 0);
if (err != 0) {
(void) printf("got error %u from dmu_read\n", err);
kmem_free(subobjs, doi.doi_max_offset);
return;
}
int64_t last_nonzero = -1;
for (uint64_t i = 0; i < doi.doi_max_offset / 8; i++) {
if (subobjs[i] != 0)
last_nonzero = i;
}
for (int64_t i = 0; i <= last_nonzero; i++) {
(void) printf("\t%llu\n", (longlong_t)subobjs[i]);
}
kmem_free(subobjs, doi.doi_max_offset);
}
/*ARGSUSED*/
static void
dump_ddt_zap(objset_t *os, uint64_t object, void *data, size_t size)
@ -1397,7 +1472,7 @@ dump_bpobj_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
}
static void
dump_bpobj(bpobj_t *bpo, char *name, int indent)
dump_full_bpobj(bpobj_t *bpo, char *name, int indent)
{
char bytes[32];
char comp[32];
@ -1411,11 +1486,12 @@ dump_bpobj(bpobj_t *bpo, char *name, int indent)
zdb_nicenum(bpo->bpo_phys->bpo_comp, comp);
zdb_nicenum(bpo->bpo_phys->bpo_uncomp, uncomp);
(void) printf(" %*s: object %llu, %llu local blkptrs, "
"%llu subobjs, %s (%s/%s comp)\n",
"%llu subobjs in object %llu, %s (%s/%s comp)\n",
indent * 8, name,
(u_longlong_t)bpo->bpo_object,
(u_longlong_t)bpo->bpo_phys->bpo_num_blkptrs,
(u_longlong_t)bpo->bpo_phys->bpo_num_subobjs,
(u_longlong_t)bpo->bpo_phys->bpo_subobjs,
bytes, comp, uncomp);
for (uint64_t i = 0; i < bpo->bpo_phys->bpo_num_subobjs; i++) {
@ -1432,7 +1508,7 @@ dump_bpobj(bpobj_t *bpo, char *name, int indent)
error, (u_longlong_t)subobj);
continue;
}
dump_bpobj(&subbpo, "subobj", indent + 1);
dump_full_bpobj(&subbpo, "subobj", indent + 1);
bpobj_close(&subbpo);
}
} else {
@ -1466,7 +1542,7 @@ dump_deadlist(dsl_deadlist_t *dl)
return;
if (dl->dl_oldfmt) {
dump_bpobj(&dl->dl_bpobj, "old-format deadlist", 0);
dump_full_bpobj(&dl->dl_bpobj, "old-format deadlist", 0);
return;
}
@ -1491,7 +1567,7 @@ dump_deadlist(dsl_deadlist_t *dl)
(void) snprintf(buf, sizeof (buf), "mintxg %llu -> "
"obj %llu", (longlong_t)dle->dle_mintxg,
(longlong_t)dle->dle_bpobj.bpo_object);
dump_bpobj(&dle->dle_bpobj, buf, 0);
dump_full_bpobj(&dle->dle_bpobj, buf, 0);
} else {
(void) printf("mintxg %llu -> obj %llu\n",
(longlong_t)dle->dle_mintxg,
@ -1682,8 +1758,8 @@ static object_viewer_t *object_viewer[DMU_OT_NUMTYPES + 1] = {
dump_uint64, /* object array */
dump_none, /* packed nvlist */
dump_packed_nvlist, /* packed nvlist size */
dump_none, /* bplist */
dump_none, /* bplist header */
dump_none, /* bpobj */
dump_bpobj, /* bpobj header */
dump_none, /* SPA space map header */
dump_none, /* SPA space map */
dump_none, /* ZIL intent log */
@ -1730,7 +1806,7 @@ static object_viewer_t *object_viewer[DMU_OT_NUMTYPES + 1] = {
dump_zap, /* deadlist */
dump_none, /* deadlist hdr */
dump_zap, /* dsl clones */
dump_none, /* bpobj subobjs */
dump_bpobj_subobjs, /* bpobj subobjs */
dump_unknown, /* Unknown type, must be last */
};
@ -2145,7 +2221,7 @@ dump_label(const char *dev)
(void) close(fd);
}
static uint64_t num_large_blocks;
static uint64_t dataset_feature_count[SPA_FEATURES];
/*ARGSUSED*/
static int
@ -2159,8 +2235,15 @@ dump_one_dir(const char *dsname, void *arg)
(void) printf("Could not open %s, error %d\n", dsname, error);
return (0);
}
if (dmu_objset_ds(os)->ds_large_blocks)
num_large_blocks++;
for (spa_feature_t f = 0; f < SPA_FEATURES; f++) {
if (!dmu_objset_ds(os)->ds_feature_inuse[f])
continue;
ASSERT(spa_feature_table[f].fi_flags &
ZFEATURE_FLAG_PER_DATASET);
dataset_feature_count[f]++;
}
dump_dir(os);
dmu_objset_disown(os, FTAG);
fuid_table_destroy();
@ -2352,6 +2435,9 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
dmu_object_type_t type;
boolean_t is_metadata;
if (bp == NULL)
return (0);
if (dump_opt['b'] >= 5 && bp->blk_birth > 0) {
char blkbuf[BP_SPRINTF_LEN];
snprintf_blkptr(blkbuf, sizeof (blkbuf), bp);
@ -2841,7 +2927,7 @@ zdb_ddt_add_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
avl_index_t where;
zdb_ddt_entry_t *zdde, zdde_search;
if (BP_IS_HOLE(bp) || BP_IS_EMBEDDED(bp))
if (bp == NULL || BP_IS_HOLE(bp) || BP_IS_EMBEDDED(bp))
return (0);
if (dump_opt['S'] > 1 && zb->zb_level == ZB_ROOT_LEVEL) {
@ -2956,13 +3042,13 @@ dump_zpool(spa_t *spa)
dump_metaslab_groups(spa);
if (dump_opt['d'] || dump_opt['i']) {
uint64_t refcount;
dump_dir(dp->dp_meta_objset);
if (dump_opt['d'] >= 3) {
dump_bpobj(&spa->spa_deferred_bpobj,
dump_full_bpobj(&spa->spa_deferred_bpobj,
"Deferred frees", 0);
if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
dump_bpobj(&spa->spa_dsl_pool->dp_free_bpobj,
dump_full_bpobj(
&spa->spa_dsl_pool->dp_free_bpobj,
"Pool snapshot frees", 0);
}
@ -2977,17 +3063,29 @@ dump_zpool(spa_t *spa)
(void) dmu_objset_find(spa_name(spa), dump_one_dir,
NULL, DS_FIND_SNAPSHOTS | DS_FIND_CHILDREN);
for (spa_feature_t f = 0; f < SPA_FEATURES; f++) {
uint64_t refcount;
if (!(spa_feature_table[f].fi_flags &
ZFEATURE_FLAG_PER_DATASET)) {
ASSERT0(dataset_feature_count[f]);
continue;
}
(void) feature_get_refcount(spa,
&spa_feature_table[SPA_FEATURE_LARGE_BLOCKS], &refcount);
if (num_large_blocks != refcount) {
(void) printf("large_blocks feature refcount mismatch: "
"expected %lld != actual %lld\n",
(longlong_t)num_large_blocks,
&spa_feature_table[f], &refcount);
if (dataset_feature_count[f] != refcount) {
(void) printf("%s feature refcount mismatch: "
"%lld datasets != %lld refcount\n",
spa_feature_table[f].fi_uname,
(longlong_t)dataset_feature_count[f],
(longlong_t)refcount);
rc = 2;
} else {
(void) printf("Verified large_blocks feature refcount "
"is correct (%llu)\n", (longlong_t)refcount);
(void) printf("Verified %s feature refcount "
"of %llu is correct\n",
spa_feature_table[f].fi_uname,
(longlong_t)refcount);
}
}
}
if (rc == 0 && (dump_opt['b'] || dump_opt['c']))

View File

@ -27,11 +27,11 @@
.\" Copyright (c) 2013, Steven Hartland <smh@FreeBSD.org>
.\" Copyright (c) 2014 Nexenta Systems, Inc. All Rights Reserved.
.\" Copyright (c) 2014, Xin LI <delphij@FreeBSD.org>
.\" Copyright (c) 2014, The FreeBSD Foundation, All Rights Reserved.
.\" Copyright (c) 2014-2015, The FreeBSD Foundation, All Rights Reserved.
.\"
.\" $FreeBSD$
.\"
.Dd December 12, 2014
.Dd July 30, 2015
.Dt ZFS 8
.Os
.Sh NAME
@ -191,11 +191,13 @@
.Nm
.Cm receive Ns | Ns Cm recv
.Op Fl vnFu
.Op Fl o Sy origin Ns = Ns Ar snapshot
.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
.Nm
.Cm receive Ns | Ns Cm recv
.Op Fl vnFu
.Op Fl d | e
.Op Fl o Sy origin Ns = Ns Ar snapshot
.Ar filesystem
.Nm
.Cm allow
@ -938,8 +940,24 @@ not be used by any other dataset.
Disabling checksums is
.Em NOT
a recommended practice.
.It Sy compression Ns = Ns Cm on | off | lzjb | gzip | gzip- Ns Ar N | zle | Cm lz4
Controls the compression algorithm used for this dataset. The
.It Sy compression Ns = Ns Cm on | off | lzjb | gzip | gzip- Ns Ar N | Cm zle | Cm lz4
Controls the compression algorithm used for this dataset.
Setting compression to
.Cm on
indicates that the current default compression algorithm should be used.
The default balances compression and decompression speed, with compression
ratio and is expected to work well on a wide variety of workloads.
Unlike all other settings for this property, on does not select a fixed
compression type.
As new compression algorithms are added to ZFS and enabled on a pool, the
default compression algorithm may change.
The current default compression algorthm is either
.Cm lzjb
or, if the
.Sy lz4_compress
feature is enabled,
.Cm lz4 .
The
.Cm lzjb
compression algorithm is optimized for performance while providing decent data
compression. Setting compression to
@ -2689,6 +2707,7 @@ feature.
.Nm
.Cm receive Ns | Ns Cm recv
.Op Fl vnFu
.Op Fl o Sy origin Ns = Ns Ar snapshot
.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
.Xc
.It Xo
@ -2696,6 +2715,7 @@ feature.
.Cm receive Ns | Ns Cm recv
.Op Fl vnFu
.Op Fl d | e
.Op Fl o Sy origin Ns = Ns Ar snapshot
.Ar filesystem
.Xc
.Pp
@ -2780,6 +2800,10 @@ receive operation.
Do not actually receive the stream. This can be useful in conjunction with the
.Fl v
option to verify the name the receive operation would use.
.It Fl o Sy origin Ns = Ns Ar snapshot
Forces the stream to be received as a clone of the given snapshot.
This is only valid if the stream is an incremental stream whose source
is the same as the provided origin.
.It Fl F
Force a rollback of the file system to the most recent snapshot before
performing the receive operation. If receiving an incremental replication

View File

@ -265,7 +265,8 @@ get_usage(zfs_help_t idx)
case HELP_RECEIVE:
return (gettext("\treceive|recv [-vnFu] <filesystem|volume|"
"snapshot>\n"
"\treceive|recv [-vnFu] [-d | -e] <filesystem>\n"));
"\treceive|recv [-vnFu] [-o origin=<snapshot>] [-d | -e] "
"<filesystem>\n"));
case HELP_RENAME:
return (gettext("\trename [-f] <filesystem|volume|snapshot> "
"<filesystem|volume|snapshot>\n"
@ -791,7 +792,7 @@ zfs_do_create(int argc, char **argv)
nomem();
break;
case 'o':
if (parseprop(props, optarg))
if (parseprop(props, optarg) != 0)
goto error;
break;
case 's':
@ -3659,7 +3660,7 @@ zfs_do_snapshot(int argc, char **argv)
while ((c = getopt(argc, argv, "ro:")) != -1) {
switch (c) {
case 'o':
if (parseprop(props, optarg))
if (parseprop(props, optarg) != 0)
return (1);
break;
case 'r':
@ -3918,10 +3919,19 @@ zfs_do_receive(int argc, char **argv)
{
int c, err;
recvflags_t flags = { 0 };
nvlist_t *props;
nvpair_t *nvp = NULL;
if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0)
nomem();
/* check options */
while ((c = getopt(argc, argv, ":denuvF")) != -1) {
while ((c = getopt(argc, argv, ":o:denuvF")) != -1) {
switch (c) {
case 'o':
if (parseprop(props, optarg) != 0)
return (1);
break;
case 'd':
flags.isprefix = B_TRUE;
break;
@ -3966,6 +3976,13 @@ zfs_do_receive(int argc, char **argv)
usage(B_FALSE);
}
while ((nvp = nvlist_next_nvpair(props, nvp))) {
if (strcmp(nvpair_name(nvp), "origin") != 0) {
(void) fprintf(stderr, gettext("invalid option"));
usage(B_FALSE);
}
}
if (isatty(STDIN_FILENO)) {
(void) fprintf(stderr,
gettext("Error: Backup stream can not be read "
@ -3974,7 +3991,7 @@ zfs_do_receive(int argc, char **argv)
return (1);
}
err = zfs_receive(g_zfs, argv[0], &flags, STDIN_FILENO, NULL);
err = zfs_receive(g_zfs, argv[0], props, &flags, STDIN_FILENO, NULL);
return (err != 0);
}

View File

@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
*/
@ -294,8 +294,8 @@ zhack_feature_enable_sync(void *arg, dmu_tx_t *tx)
feature_enable_sync(spa, feature, tx);
spa_history_log_internal(spa, "zhack enable feature", tx,
"name=%s can_readonly=%u",
feature->fi_guid, feature->fi_can_readonly);
"guid=%s flags=%x",
feature->fi_guid, feature->fi_flags);
}
static void
@ -314,9 +314,7 @@ zhack_do_feature_enable(int argc, char **argv)
*/
desc = NULL;
feature.fi_uname = "zhack";
feature.fi_mos = B_FALSE;
feature.fi_can_readonly = B_FALSE;
feature.fi_activate_on_enable = B_FALSE;
feature.fi_flags = 0;
feature.fi_depends = nodeps;
feature.fi_feature = SPA_FEATURE_NONE;
@ -324,7 +322,7 @@ zhack_do_feature_enable(int argc, char **argv)
while ((c = getopt(argc, argv, "rmd:")) != -1) {
switch (c) {
case 'r':
feature.fi_can_readonly = B_TRUE;
feature.fi_flags |= ZFEATURE_FLAG_READONLY_COMPAT;
break;
case 'd':
desc = strdup(optarg);
@ -413,7 +411,7 @@ zhack_do_feature_ref(int argc, char **argv)
* disk later.
*/
feature.fi_uname = "zhack";
feature.fi_mos = B_FALSE;
feature.fi_flags = 0;
feature.fi_desc = NULL;
feature.fi_depends = nodeps;
feature.fi_feature = SPA_FEATURE_NONE;
@ -422,7 +420,7 @@ zhack_do_feature_ref(int argc, char **argv)
while ((c = getopt(argc, argv, "md")) != -1) {
switch (c) {
case 'm':
feature.fi_mos = B_TRUE;
feature.fi_flags |= ZFEATURE_FLAG_MOS;
break;
case 'd':
decr = B_TRUE;
@ -455,10 +453,10 @@ zhack_do_feature_ref(int argc, char **argv)
if (0 == zap_contains(mos, spa->spa_feat_for_read_obj,
feature.fi_guid)) {
feature.fi_can_readonly = B_FALSE;
feature.fi_flags &= ~ZFEATURE_FLAG_READONLY_COMPAT;
} else if (0 == zap_contains(mos, spa->spa_feat_for_write_obj,
feature.fi_guid)) {
feature.fi_can_readonly = B_TRUE;
feature.fi_flags |= ZFEATURE_FLAG_READONLY_COMPAT;
} else {
fatal(spa, FTAG, "feature is not enabled: %s", feature.fi_guid);
}

View File

@ -22,7 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright (c) 2011, 2015 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.
@ -4986,7 +4986,8 @@ zpool_do_upgrade(int argc, char **argv)
"---------------\n");
for (i = 0; i < SPA_FEATURES; i++) {
zfeature_info_t *fi = &spa_feature_table[i];
const char *ro = fi->fi_can_readonly ?
const char *ro =
(fi->fi_flags & ZFEATURE_FLAG_READONLY_COMPAT) ?
" (read-only compatible)" : "";
(void) printf("%-37s%s\n", fi->fi_uname, ro);

View File

@ -25,7 +25,7 @@
*/
/*
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2013, 2014 by Delphix. All rights reserved.
*/
#include <ctype.h>
@ -34,6 +34,7 @@
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <stddef.h>
#include <sys/dmu.h>
#include <sys/zfs_ioctl.h>
@ -83,7 +84,6 @@ safe_malloc(size_t size)
*
* Read while computing incremental checksum
*/
static size_t
ssread(void *buf, size_t len, zio_cksum_t *cksum)
{
@ -92,7 +92,7 @@ ssread(void *buf, size_t len, zio_cksum_t *cksum)
if ((outlen = fread(buf, len, 1, send_stream)) == 0)
return (0);
if (do_cksum && cksum) {
if (do_cksum) {
if (do_byteswap)
fletcher_4_incremental_byteswap(buf, len, cksum);
else
@ -102,6 +102,34 @@ ssread(void *buf, size_t len, zio_cksum_t *cksum)
return (outlen);
}
static size_t
read_hdr(dmu_replay_record_t *drr, zio_cksum_t *cksum)
{
ASSERT3U(offsetof(dmu_replay_record_t, drr_u.drr_checksum.drr_checksum),
==, sizeof (dmu_replay_record_t) - sizeof (zio_cksum_t));
size_t r = ssread(drr, sizeof (*drr) - sizeof (zio_cksum_t), cksum);
if (r == 0)
return (0);
zio_cksum_t saved_cksum = *cksum;
r = ssread(&drr->drr_u.drr_checksum.drr_checksum,
sizeof (zio_cksum_t), cksum);
if (r == 0)
return (0);
if (!ZIO_CHECKSUM_IS_ZERO(&drr->drr_u.drr_checksum.drr_checksum) &&
!ZIO_CHECKSUM_EQUAL(saved_cksum,
drr->drr_u.drr_checksum.drr_checksum)) {
fprintf(stderr, "invalid checksum\n");
(void) printf("Incorrect checksum in record header.\n");
(void) printf("Expected checksum = %llx/%llx/%llx/%llx\n",
saved_cksum.zc_word[0],
saved_cksum.zc_word[1],
saved_cksum.zc_word[2],
saved_cksum.zc_word[3]);
exit(1);
}
return (sizeof (*drr));
}
/*
* Print part of a block in ASCII characters
*/
@ -183,8 +211,10 @@ main(int argc, char *argv[])
struct drr_free *drrf = &thedrr.drr_u.drr_free;
struct drr_spill *drrs = &thedrr.drr_u.drr_spill;
struct drr_write_embedded *drrwe = &thedrr.drr_u.drr_write_embedded;
struct drr_checksum *drrc = &thedrr.drr_u.drr_checksum;
char c;
boolean_t verbose = B_FALSE;
boolean_t very_verbose = B_FALSE;
boolean_t first = B_TRUE;
/*
* dump flag controls whether the contents of any modified data blocks
@ -202,11 +232,14 @@ main(int argc, char *argv[])
do_cksum = B_FALSE;
break;
case 'v':
if (verbose)
very_verbose = B_TRUE;
verbose = B_TRUE;
break;
case 'd':
dump = B_TRUE;
verbose = B_TRUE;
very_verbose = B_TRUE;
break;
case ':':
(void) fprintf(stderr,
@ -230,7 +263,7 @@ main(int argc, char *argv[])
send_stream = stdin;
pcksum = zc;
while (ssread(drr, sizeof (dmu_replay_record_t), &zc)) {
while (read_hdr(drr, &zc)) {
/*
* If this is the first DMU record being processed, check for
@ -553,6 +586,13 @@ main(int argc, char *argv[])
P2ROUNDUP(drrwe->drr_psize, 8), &zc);
break;
}
if (drr->drr_type != DRR_BEGIN && very_verbose) {
(void) printf(" checksum = %llx/%llx/%llx/%llx\n",
(longlong_t)drrc->drr_checksum.zc_word[0],
(longlong_t)drrc->drr_checksum.zc_word[1],
(longlong_t)drrc->drr_checksum.zc_word[2],
(longlong_t)drrc->drr_checksum.zc_word[3]);
}
pcksum = zc;
}
free(buf);

View File

@ -3586,7 +3586,8 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
*/
n = ztest_random(regions) * stride + ztest_random(width);
s = 1 + ztest_random(2 * width - 1);
dmu_prefetch(os, bigobj, n * chunksize, s * chunksize);
dmu_prefetch(os, bigobj, 0, n * chunksize, s * chunksize,
ZIO_PRIORITY_SYNC_READ);
/*
* Pick a random index and compute the offsets into packobj and bigobj.
@ -5705,8 +5706,10 @@ ztest_run(ztest_shared_t *zs)
* Right before closing the pool, kick off a bunch of async I/O;
* spa_close() should wait for it to complete.
*/
for (uint64_t object = 1; object < 50; object++)
dmu_prefetch(spa->spa_meta_objset, object, 0, 1ULL << 20);
for (uint64_t object = 1; object < 50; object++) {
dmu_prefetch(spa->spa_meta_objset, object, 0, 0, 1ULL << 20,
ZIO_PRIORITY_SYNC_READ);
}
spa_close(spa, FTAG);
@ -5905,6 +5908,7 @@ ztest_init(ztest_shared_t *zs)
}
VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props, NULL));
nvlist_free(nvroot);
nvlist_free(props);
VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
zs->zs_metaslab_sz =

View File

@ -1348,6 +1348,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
dtrace_aggdesc_t *agg;
caddr_t lim = (caddr_t)buf + len, limit;
char format[64] = "%";
size_t ret;
int i, aggrec, curagg = -1;
uint64_t normal;
@ -1379,7 +1380,9 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
int prec = pfd->pfd_prec;
int rval;
const char *start;
char *f = format + 1; /* skip initial '%' */
size_t fmtsz = sizeof(format) - 1;
const dtrace_recdesc_t *rec;
dt_pfprint_f *func;
caddr_t addr;
@ -1536,6 +1539,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
break;
}
start = f;
if (pfd->pfd_flags & DT_PFCONV_ALT)
*f++ = '#';
if (pfd->pfd_flags & DT_PFCONV_ZPAD)
@ -1548,6 +1552,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
*f++ = '\'';
if (pfd->pfd_flags & DT_PFCONV_SPACE)
*f++ = ' ';
fmtsz -= f - start;
/*
* If we're printing a stack and DT_PFCONV_LEFT is set, we
@ -1558,13 +1563,20 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
if (func == pfprint_stack && (pfd->pfd_flags & DT_PFCONV_LEFT))
width = 0;
if (width != 0)
f += snprintf(f, sizeof (format), "%d", ABS(width));
if (width != 0) {
ret = snprintf(f, fmtsz, "%d", ABS(width));
f += ret;
fmtsz = MAX(0, fmtsz - ret);
}
if (prec > 0)
f += snprintf(f, sizeof (format), ".%d", prec);
if (prec > 0) {
ret = snprintf(f, fmtsz, ".%d", prec);
f += ret;
fmtsz = MAX(0, fmtsz - ret);
}
(void) strcpy(f, pfd->pfd_fmt);
if (strlcpy(f, pfd->pfd_fmt, fmtsz) >= fmtsz)
return (dt_set_errno(dtp, EDT_COMPILER));
pfd->pfd_rec = rec;
if (func(dtp, fp, format, pfd, addr, size, normal) < 0)

View File

@ -668,8 +668,8 @@ typedef struct recvflags {
boolean_t nomount;
} recvflags_t;
extern int zfs_receive(libzfs_handle_t *, const char *, recvflags_t *,
int, avl_tree_t *);
extern int zfs_receive(libzfs_handle_t *, const char *, nvlist_t *,
recvflags_t *, int, avl_tree_t *);
typedef enum diff_flags {
ZFS_DIFF_PARSEABLE = 0x1,

View File

@ -3535,7 +3535,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
}
static int
zbookmark_compare(const void *a, const void *b)
zbookmark_mem_compare(const void *a, const void *b)
{
return (memcmp(a, b, sizeof (zbookmark_phys_t)));
}
@ -3598,7 +3598,7 @@ zpool_get_errlog(zpool_handle_t *zhp, nvlist_t **nverrlistp)
zc.zc_nvlist_dst_size;
count -= zc.zc_nvlist_dst_size;
qsort(zb, count, sizeof (zbookmark_phys_t), zbookmark_compare);
qsort(zb, count, sizeof (zbookmark_phys_t), zbookmark_mem_compare);
verify(nvlist_alloc(nverrlistp, 0, KM_SLEEP) == 0);

View File

@ -64,8 +64,9 @@ extern void zfs_setprop_error(libzfs_handle_t *, zfs_prop_t, int, char *);
/* We need to use something for ENODATA. */
#define ENODATA EIDRM
static int zfs_receive_impl(libzfs_handle_t *, const char *, recvflags_t *,
int, const char *, nvlist_t *, avl_tree_t *, char **, int, uint64_t *);
static int zfs_receive_impl(libzfs_handle_t *, const char *, const char *,
recvflags_t *, int, const char *, nvlist_t *, avl_tree_t *, char **, int,
uint64_t *);
static const zio_cksum_t zero_cksum = { 0 };
@ -188,10 +189,28 @@ ddt_update(libzfs_handle_t *hdl, dedup_table_t *ddt, zio_cksum_t *cs,
}
static int
cksum_and_write(const void *buf, uint64_t len, zio_cksum_t *zc, int outfd)
dump_record(dmu_replay_record_t *drr, void *payload, int payload_len,
zio_cksum_t *zc, int outfd)
{
fletcher_4_incremental_native(buf, len, zc);
return (write(outfd, buf, len));
ASSERT3U(offsetof(dmu_replay_record_t, drr_u.drr_checksum.drr_checksum),
==, sizeof (dmu_replay_record_t) - sizeof (zio_cksum_t));
fletcher_4_incremental_native(drr,
offsetof(dmu_replay_record_t, drr_u.drr_checksum.drr_checksum), zc);
if (drr->drr_type != DRR_BEGIN) {
ASSERT(ZIO_CHECKSUM_IS_ZERO(&drr->drr_u.
drr_checksum.drr_checksum));
drr->drr_u.drr_checksum.drr_checksum = *zc;
}
fletcher_4_incremental_native(&drr->drr_u.drr_checksum.drr_checksum,
sizeof (zio_cksum_t), zc);
if (write(outfd, drr, sizeof (*drr)) == -1)
return (errno);
if (payload_len != 0) {
fletcher_4_incremental_native(payload, payload_len, zc);
if (write(outfd, payload, payload_len) == -1)
return (errno);
}
return (0);
}
/*
@ -218,16 +237,8 @@ cksummer(void *arg)
char *buf = zfs_alloc(dda->dedup_hdl, SPA_MAXBLOCKSIZE);
dmu_replay_record_t thedrr;
dmu_replay_record_t *drr = &thedrr;
struct drr_begin *drrb = &thedrr.drr_u.drr_begin;
struct drr_end *drre = &thedrr.drr_u.drr_end;
struct drr_object *drro = &thedrr.drr_u.drr_object;
struct drr_write *drrw = &thedrr.drr_u.drr_write;
struct drr_spill *drrs = &thedrr.drr_u.drr_spill;
struct drr_write_embedded *drrwe = &thedrr.drr_u.drr_write_embedded;
FILE *ofp;
int outfd;
dmu_replay_record_t wbr_drr = {0};
struct drr_write_byref *wbr_drrr = &wbr_drr.drr_u.drr_write_byref;
dedup_table_t ddt;
zio_cksum_t stream_cksum;
uint64_t physmem = sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE);
@ -253,32 +264,29 @@ cksummer(void *arg)
ddt.numhashbits = high_order_bit(numbuckets) - 1;
ddt.ddt_full = B_FALSE;
/* Initialize the write-by-reference block. */
wbr_drr.drr_type = DRR_WRITE_BYREF;
wbr_drr.drr_payloadlen = 0;
outfd = dda->outputfd;
ofp = fdopen(dda->inputfd, "r");
while (ssread(drr, sizeof (dmu_replay_record_t), ofp) != 0) {
while (ssread(drr, sizeof (*drr), ofp) != 0) {
switch (drr->drr_type) {
case DRR_BEGIN:
{
struct drr_begin *drrb = &drr->drr_u.drr_begin;
int fflags;
int sz = 0;
ZIO_SET_CHECKSUM(&stream_cksum, 0, 0, 0, 0);
ASSERT3U(drrb->drr_magic, ==, DMU_BACKUP_MAGIC);
/* set the DEDUP feature flag for this stream */
fflags = DMU_GET_FEATUREFLAGS(drrb->drr_versioninfo);
fflags |= (DMU_BACKUP_FEATURE_DEDUP |
DMU_BACKUP_FEATURE_DEDUPPROPS);
DMU_SET_FEATUREFLAGS(drrb->drr_versioninfo, fflags);
if (cksum_and_write(drr, sizeof (dmu_replay_record_t),
&stream_cksum, outfd) == -1)
goto out;
if (DMU_GET_STREAM_HDRTYPE(drrb->drr_versioninfo) ==
DMU_COMPOUNDSTREAM && drr->drr_payloadlen != 0) {
int sz = drr->drr_payloadlen;
sz = drr->drr_payloadlen;
if (sz > SPA_MAXBLOCKSIZE) {
buf = zfs_realloc(dda->dedup_hdl, buf,
@ -287,64 +295,60 @@ cksummer(void *arg)
(void) ssread(buf, sz, ofp);
if (ferror(stdin))
perror("fread");
if (cksum_and_write(buf, sz, &stream_cksum,
outfd) == -1)
goto out;
}
if (dump_record(drr, buf, sz, &stream_cksum,
outfd) != 0)
goto out;
break;
}
case DRR_END:
{
struct drr_end *drre = &drr->drr_u.drr_end;
/* use the recalculated checksum */
ZIO_SET_CHECKSUM(&drre->drr_checksum,
stream_cksum.zc_word[0], stream_cksum.zc_word[1],
stream_cksum.zc_word[2], stream_cksum.zc_word[3]);
if ((write(outfd, drr,
sizeof (dmu_replay_record_t))) == -1)
drre->drr_checksum = stream_cksum;
if (dump_record(drr, NULL, 0, &stream_cksum,
outfd) != 0)
goto out;
break;
}
case DRR_OBJECT:
{
if (cksum_and_write(drr, sizeof (dmu_replay_record_t),
&stream_cksum, outfd) == -1)
goto out;
struct drr_object *drro = &drr->drr_u.drr_object;
if (drro->drr_bonuslen > 0) {
(void) ssread(buf,
P2ROUNDUP((uint64_t)drro->drr_bonuslen, 8),
ofp);
if (cksum_and_write(buf,
P2ROUNDUP((uint64_t)drro->drr_bonuslen, 8),
&stream_cksum, outfd) == -1)
goto out;
}
if (dump_record(drr, buf,
P2ROUNDUP((uint64_t)drro->drr_bonuslen, 8),
&stream_cksum, outfd) != 0)
goto out;
break;
}
case DRR_SPILL:
{
if (cksum_and_write(drr, sizeof (dmu_replay_record_t),
&stream_cksum, outfd) == -1)
goto out;
struct drr_spill *drrs = &drr->drr_u.drr_spill;
(void) ssread(buf, drrs->drr_length, ofp);
if (cksum_and_write(buf, drrs->drr_length,
&stream_cksum, outfd) == -1)
if (dump_record(drr, buf, drrs->drr_length,
&stream_cksum, outfd) != 0)
goto out;
break;
}
case DRR_FREEOBJECTS:
{
if (cksum_and_write(drr, sizeof (dmu_replay_record_t),
&stream_cksum, outfd) == -1)
if (dump_record(drr, NULL, 0, &stream_cksum,
outfd) != 0)
goto out;
break;
}
case DRR_WRITE:
{
struct drr_write *drrw = &drr->drr_u.drr_write;
dataref_t dataref;
(void) ssread(buf, drrw->drr_length, ofp);
@ -382,7 +386,13 @@ cksummer(void *arg)
if (ddt_update(dda->dedup_hdl, &ddt,
&drrw->drr_key.ddk_cksum, drrw->drr_key.ddk_prop,
&dataref)) {
dmu_replay_record_t wbr_drr = {0};
struct drr_write_byref *wbr_drrr =
&wbr_drr.drr_u.drr_write_byref;
/* block already present in stream */
wbr_drr.drr_type = DRR_WRITE_BYREF;
wbr_drrr->drr_object = drrw->drr_object;
wbr_drrr->drr_offset = drrw->drr_offset;
wbr_drrr->drr_length = drrw->drr_length;
@ -402,19 +412,13 @@ cksummer(void *arg)
wbr_drrr->drr_key.ddk_prop =
drrw->drr_key.ddk_prop;
if (cksum_and_write(&wbr_drr,
sizeof (dmu_replay_record_t), &stream_cksum,
outfd) == -1)
if (dump_record(&wbr_drr, NULL, 0,
&stream_cksum, outfd) != 0)
goto out;
} else {
/* block not previously seen */
if (cksum_and_write(drr,
sizeof (dmu_replay_record_t), &stream_cksum,
outfd) == -1)
goto out;
if (cksum_and_write(buf,
drrw->drr_length,
&stream_cksum, outfd) == -1)
if (dump_record(drr, buf, drrw->drr_length,
&stream_cksum, outfd) != 0)
goto out;
}
break;
@ -422,28 +426,27 @@ cksummer(void *arg)
case DRR_WRITE_EMBEDDED:
{
if (cksum_and_write(drr, sizeof (dmu_replay_record_t),
&stream_cksum, outfd) == -1)
goto out;
struct drr_write_embedded *drrwe =
&drr->drr_u.drr_write_embedded;
(void) ssread(buf,
P2ROUNDUP((uint64_t)drrwe->drr_psize, 8), ofp);
if (cksum_and_write(buf,
if (dump_record(drr, buf,
P2ROUNDUP((uint64_t)drrwe->drr_psize, 8),
&stream_cksum, outfd) == -1)
&stream_cksum, outfd) != 0)
goto out;
break;
}
case DRR_FREE:
{
if (cksum_and_write(drr, sizeof (dmu_replay_record_t),
&stream_cksum, outfd) == -1)
if (dump_record(drr, NULL, 0, &stream_cksum,
outfd) != 0)
goto out;
break;
}
default:
(void) printf("INVALID record type 0x%x\n",
(void) fprintf(stderr, "INVALID record type 0x%x\n",
drr->drr_type);
/* should never happen, so assert */
assert(B_FALSE);
@ -1470,18 +1473,11 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
sizeof (drr.drr_u.drr_begin.drr_toname),
"%s@%s", zhp->zfs_name, tosnap);
drr.drr_payloadlen = buflen;
err = cksum_and_write(&drr, sizeof (drr), &zc, outfd);
/* write header nvlist */
if (err != -1 && packbuf != NULL) {
err = cksum_and_write(packbuf, buflen, &zc,
outfd);
}
err = dump_record(&drr, packbuf, buflen, &zc, outfd);
free(packbuf);
if (err == -1) {
err = errno;
if (err != 0)
goto stderr_out;
}
/* write end record */
bzero(&drr, sizeof (drr));
@ -1714,6 +1710,8 @@ recv_read(libzfs_handle_t *hdl, int fd, void *buf, int ilen,
int rv;
int len = ilen;
assert(ilen <= SPA_MAXBLOCKSIZE);
do {
rv = read(fd, cp, len);
cp += rv;
@ -2501,7 +2499,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
* zfs_receive_one() will take care of it (ie,
* recv_skip() and return 0).
*/
error = zfs_receive_impl(hdl, destname, flags, fd,
error = zfs_receive_impl(hdl, destname, NULL, flags, fd,
sendfs, stream_nv, stream_avl, top_zfs, cleanup_fd,
action_handlep);
if (error == ENODATA) {
@ -2634,9 +2632,9 @@ recv_skip(libzfs_handle_t *hdl, int fd, boolean_t byteswap)
*/
static int
zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
recvflags_t *flags, dmu_replay_record_t *drr,
dmu_replay_record_t *drr_noswap, const char *sendfs,
nvlist_t *stream_nv, avl_tree_t *stream_avl, char **top_zfs, int cleanup_fd,
const char *originsnap, recvflags_t *flags, dmu_replay_record_t *drr,
dmu_replay_record_t *drr_noswap, const char *sendfs, nvlist_t *stream_nv,
avl_tree_t *stream_avl, char **top_zfs, int cleanup_fd,
uint64_t *action_handlep)
{
zfs_cmd_t zc = { 0 };
@ -2801,10 +2799,15 @@ 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, ZFS_MAXNAMELEN);
if (flags->verbose)
(void) printf("using provided clone origin %s\n",
zc.zc_string);
}
stream_wantsnewfs = (drrb->drr_fromguid == 0 ||
(drrb->drr_flags & DRR_FLAG_CLONE));
(drrb->drr_flags & DRR_FLAG_CLONE) || originsnap);
if (stream_wantsnewfs) {
/*
@ -3182,9 +3185,10 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
}
static int
zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap, recvflags_t *flags,
int infd, const char *sendfs, nvlist_t *stream_nv, avl_tree_t *stream_avl,
char **top_zfs, int cleanup_fd, uint64_t *action_handlep)
zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap,
const char *originsnap, recvflags_t *flags, int infd, const char *sendfs,
nvlist_t *stream_nv, avl_tree_t *stream_avl, char **top_zfs, int cleanup_fd,
uint64_t *action_handlep)
{
int err;
dmu_replay_record_t drr, drr_noswap;
@ -3203,6 +3207,12 @@ zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap, recvflags_t *flags,
"(%s) does not exist"), tosnap);
return (zfs_error(hdl, EZFS_NOENT, errbuf));
}
if (originsnap &&
!zfs_dataset_exists(hdl, originsnap, ZFS_TYPE_DATASET)) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "specified origin fs "
"(%s) does not exist"), originsnap);
return (zfs_error(hdl, EZFS_NOENT, errbuf));
}
/* read in the BEGIN record */
if (0 != (err = recv_read(hdl, infd, &drr, sizeof (drr), B_FALSE,
@ -3275,14 +3285,14 @@ zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap, recvflags_t *flags,
*cp = '\0';
sendfs = nonpackage_sendfs;
}
return (zfs_receive_one(hdl, infd, tosnap, flags,
&drr, &drr_noswap, sendfs, stream_nv, stream_avl,
top_zfs, cleanup_fd, action_handlep));
return (zfs_receive_one(hdl, infd, tosnap, originsnap, flags,
&drr, &drr_noswap, sendfs, stream_nv, stream_avl, top_zfs,
cleanup_fd, action_handlep));
} else {
assert(DMU_GET_STREAM_HDRTYPE(drrb->drr_versioninfo) ==
DMU_COMPOUNDSTREAM);
return (zfs_receive_package(hdl, infd, tosnap, flags,
&drr, &zcksum, top_zfs, cleanup_fd, action_handlep));
return (zfs_receive_package(hdl, infd, tosnap, flags, &drr,
&zcksum, top_zfs, cleanup_fd, action_handlep));
}
}
@ -3293,18 +3303,24 @@ zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap, recvflags_t *flags,
* (-1 will override -2).
*/
int
zfs_receive(libzfs_handle_t *hdl, const char *tosnap, recvflags_t *flags,
int infd, avl_tree_t *stream_avl)
zfs_receive(libzfs_handle_t *hdl, const char *tosnap, nvlist_t *props,
recvflags_t *flags, int infd, avl_tree_t *stream_avl)
{
char *top_zfs = NULL;
int err;
int cleanup_fd;
uint64_t action_handle = 0;
char *originsnap = NULL;
if (props) {
err = nvlist_lookup_string(props, "origin", &originsnap);
if (err && err != ENOENT)
return (err);
}
cleanup_fd = open(ZFS_DEV, O_RDWR|O_EXCL);
VERIFY(cleanup_fd >= 0);
err = zfs_receive_impl(hdl, tosnap, flags, infd, NULL, NULL,
err = zfs_receive_impl(hdl, tosnap, originsnap, flags, infd, NULL, NULL,
stream_avl, &top_zfs, cleanup_fd, &action_handle);
VERIFY(0 == close(cleanup_fd));

View File

@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
*/
@ -532,18 +532,30 @@ lzc_send(const char *snapname, const char *from, int fd,
}
/*
* If fromsnap is NULL, a full (non-incremental) stream will be estimated.
* "from" can be NULL, a snapshot, or a bookmark.
*
* If from is NULL, a full (non-incremental) stream will be estimated. This
* is calculated very efficiently.
*
* If from is a snapshot, lzc_send_space uses the deadlists attached to
* each snapshot to efficiently estimate the stream size.
*
* If from is a bookmark, the indirect blocks in the destination snapshot
* are traversed, looking for blocks with a birth time since the creation TXG of
* the snapshot this bookmark was created from. This will result in
* significantly more I/O and be less efficient than a send space estimation on
* an equivalent snapshot.
*/
int
lzc_send_space(const char *snapname, const char *fromsnap, uint64_t *spacep)
lzc_send_space(const char *snapname, const char *from, uint64_t *spacep)
{
nvlist_t *args;
nvlist_t *result;
int err;
args = fnvlist_alloc();
if (fromsnap != NULL)
fnvlist_add_string(args, "fromsnap", fromsnap);
if (from != NULL)
fnvlist_add_string(args, "from", from);
err = lzc_ioctl(ZFS_IOC_SEND_SPACE, snapname, args, &result);
nvlist_free(args);
if (err == 0)

View File

@ -135,8 +135,18 @@ extern int aok;
/*
* DTrace SDT probes have different signatures in userland than they do in
* kernel. If they're being used in kernel code, re-define them out of
* the kernel. If they're being used in kernel code, re-define them out of
* existence for their counterparts in libzpool.
*
* Here's an example of how to use the set-error probes in userland:
* zfs$target:::set-error /arg0 == EBUSY/ {stack();}
*
* Here's an example of how to use DTRACE_PROBE probes in userland:
* If there is a probe declared as follows:
* DTRACE_PROBE2(zfs__probe_name, uint64_t, blkid, dnode_t *, dn);
* Then you can use it as follows:
* zfs$target:::probe2 /copyinstr(arg0) == "zfs__probe_name"/
* {printf("%u %p\n", arg1, arg2);}
*/
#ifdef DTRACE_PROBE
@ -645,13 +655,6 @@ extern int zfs_secpolicy_rename_perms(const char *from, const char *to,
extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr);
extern zoneid_t getzoneid(void);
/* Random compatibility stuff. */
#define lbolt (gethrtime() >> 23)
#define lbolt64 (gethrtime() >> 23)
extern uint64_t physmem;
#define gethrestime_sec() time(NULL)
#define pwrite64(d, p, n, o) pwrite(d, p, n, o)
#define readdir64(d) readdir(d)
#define SIGPENDING(td) (0)

View File

@ -349,7 +349,7 @@ equiv_node(tdesc_t *ctdp, tdesc_t *mtdp, equiv_data_t *ed)
int (*equiv)(tdesc_t *, tdesc_t *, equiv_data_t *);
int mapping;
if (ctdp->t_emark > ed->ed_clear_mark ||
if (ctdp->t_emark > ed->ed_clear_mark &&
mtdp->t_emark > ed->ed_clear_mark)
return (ctdp->t_emark == mtdp->t_emark);

View File

@ -26,9 +26,7 @@ _libzpool= libzpool
.endif
.endif
.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_ARCH} == "amd64" || \
${MACHINE_CPUARCH} == "arm" || ${MACHINE_ARCH} == "i386" || \
${MACHINE_CPUARCH} == "mips" || ${MACHINE_CPUARCH} == "powerpc"
.if ${MACHINE_CPUARCH} != "sparc64"
_drti= drti
_libdtrace= libdtrace
.endif

View File

@ -25,8 +25,7 @@
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#pragma D depends_on module kernel
#pragma D depends_on provider io
typedef struct devinfo {

View File

@ -25,6 +25,7 @@
* Copyright (c) 2013 Mark Johnston <markj@freebsd.org>
*/
#pragma D depends_on module kernel
#pragma D depends_on provider ip
/*

View File

@ -30,6 +30,7 @@
#pragma D depends_on library ip.d
#pragma D depends_on library net.d
#pragma D depends_on module kernel
#pragma D depends_on module nfs
typedef struct nfsv4opinfo {

View File

@ -30,7 +30,8 @@
#pragma D depends_on library ip.d
#pragma D depends_on library net.d
#pragma D depends_on module nfs.d
#pragma D depends_on library nfs.d
#pragma D depends_on module kernel
#pragma D depends_on module nfssrv
#pragma D binding "1.5" translator

View File

@ -28,6 +28,8 @@
* Use is subject to license terms.
*/
#pragma D depends_on module kernel
typedef struct psinfo {
int pr_nlwp; /* number of threads */
pid_t pr_pid; /* unique process id */

View File

@ -28,8 +28,6 @@
* Use is subject to license terms.
*/
#pragma ident "@(#)regs.d.in 1.1 04/09/28 SMI"
inline int R_GS = 0;
#pragma D binding "1.0" R_GS
inline int R_FS = 1;

View File

@ -27,9 +27,7 @@
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#pragma D depends_on module unix
#pragma D depends_on module kernel
#pragma D depends_on provider sched
struct cpuinfo {

View File

@ -21,6 +21,7 @@
* $FreeBSD$
*/
#pragma D depends_on module kernel
#pragma D depends_on module siftr
#pragma D depends_on provider tcp

View File

@ -26,6 +26,7 @@
*/
#pragma D depends_on library ip.d
#pragma D depends_on module kernel
#pragma D depends_on provider tcp
/*

View File

@ -26,6 +26,7 @@
*/
#pragma D depends_on library ip.d
#pragma D depends_on module kernel
#pragma D depends_on provider udp
/*

View File

@ -1,5 +1,7 @@
# $FreeBSD$
.include <src.opts.mk>
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/dtrace
PROG= dtrace
@ -22,4 +24,8 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
LIBADD= dtrace
.if ${MK_DTRACE_TESTS} != "no"
SUBDIR+= tests
.endif
.include <bsd.prog.mk>

View File

@ -1,4 +1,63 @@
-*- coding: utf-8 -*-
Changes for APR 1.5.2
*) SECURITY: CVE-2015-1829 (cve.mitre.org)
APR applications using APR named pipe support on Windows can be
vulnerable to a pipe squatting attack from a local process; the extent
of the vulnerability, when present, depends on the application.
Initial analysis and report was provided by John Hernandez of Casaba
Security via HP SSRT Security Alert. [Yann Ylavic]
*) apr_atomic: Fix errors when building on Visual Studio 2013 while
maintaining the ability to build on Visual Studio 6 with Windows
Server 2003 R2 SDK. PR 57191. [Gregg Smith]
*) Switch to generic atomics for early/unpatched Solaris 10 not exporting
some atomic functions. PR 55418. [Yann Ylavic]
*) apr_file_mktemp() on HP-UX: Remove limitation of 26 temporary files
per process. PR 57677. [Jeff Trawick]
*) apr_escape: Correctly calculate the size of the returned string in
apr_escape_path and set the correct return value in case we actually
escape the string. [<aduryagin gmail.com>] PR 57230.
*) pollcb on Windows: Handle calls with no file/socket descriptors.
Follow up to PR 49882. [Jeff Trawick, Yann Ylavic]
*) apr_poll(cb): fix error paths returned values and leaks. [Yann Ylavic]
*) apr_thread_cond_*wait() on BeOS: Fix broken logic. PR 45800.
[Jochen Voss (no e-mail)]
*) apr_skiplist: Optimize the number of allocations by reusing pooled or
malloc()ed nodes for the lifetime of the skiplist. [Yann Ylavic]
*) apr_skiplist: Fix possible multiple-free() on the same value in
apr_skiplist_remove_all(). [Yann Ylavic]
*) apr_pollset: On z/OS, threadsafe apr_pollset_poll() may return
"EDC8102I Operation would block" under load.
[Pat Odonnell <patod us.ibm.com>]
*) On z/OS, apr_sockaddr_info_get() with family == APR_UNSPEC was not
returning IPv4 addresses if any IPv6 addresses were returned.
[Eric Covener]
*) Windows cmake build: Fix an incompatibility with cmake 2.8.12 and
later. [Jeff Trawick]
*) apr_global_mutex/apr_proc_mutex: Resolve failures with the
POSIX sem implementation in environments which receive signals.
[Jeff Trawick]
*) apr_skiplist: Fix potential corruption of skiplists leading to
results or crashes. [Takashi Sato <takashi tks st>, Eric Covener]
PR 56654.
*) Improve platform detection by updating config.guess and config.sub.
[Rainer Jung]
Changes for APR 1.5.1
*) apr_os_proc_mutex_get() on Unix: Avoid segfault for cross-
@ -37,8 +96,8 @@ Changes for APR 1.5.1
*) Correct a regression in 1.5.0 which affected out-of-tree
builds on Unix. [Rainer Jung]
*) Improve platform detection for bundled expat by updating
config.guess and config.sub. [Rainer Jung]
*) Improve platform detection by updating config.guess and config.sub.
[Rainer Jung]
Changes for APR 1.5.0

View File

@ -234,6 +234,7 @@ SET(APR_TEST_SOURCES
test/testprocmutex.c
test/testrand.c
test/testshm.c
test/testskiplist.c
test/testsleep.c
test/testsock.c
test/testsockets.c
@ -252,7 +253,6 @@ SET(APR_TEST_SOURCES
SET(install_targets)
SET(install_bin_pdb)
SET(install_lib_pdb)
# libapr-1 is shared, apr-1 is static
ADD_LIBRARY(libapr-1 SHARED ${APR_SOURCES} ${APR_PUBLIC_HEADERS_GENERATED} libapr.rc)
@ -264,7 +264,6 @@ ADD_DEPENDENCIES(libapr-1 test_char_header)
ADD_LIBRARY(apr-1 STATIC ${APR_SOURCES} ${APR_PUBLIC_HEADERS_GENERATED})
SET(install_targets ${install_targets} apr-1)
SET(install_lib_pdb ${install_lib_pdb} ${PROJECT_BINARY_DIR}/apr-1.pdb)
TARGET_LINK_LIBRARIES(apr-1 ${APR_SYSTEM_LIBS})
SET_TARGET_PROPERTIES(apr-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_STATIC;WINNT")
ADD_DEPENDENCIES(apr-1 test_char_header)
@ -272,12 +271,10 @@ ADD_DEPENDENCIES(apr-1 test_char_header)
# libaprapp-1 and aprapp-1 are static
ADD_LIBRARY(libaprapp-1 STATIC misc/win32/apr_app.c misc/win32/internal.c ${APR_PUBLIC_HEADERS_GENERATED})
SET(install_targets ${install_targets} libaprapp-1)
SET(install_lib_pdb ${install_lib_pdb} ${PROJECT_BINARY_DIR}/libaprapp-1.pdb)
SET_TARGET_PROPERTIES(libaprapp-1 PROPERTIES COMPILE_DEFINITIONS "APR_APP;WINNT")
ADD_LIBRARY(aprapp-1 STATIC misc/win32/apr_app.c misc/win32/internal.c ${APR_PUBLIC_HEADERS_GENERATED})
SET(install_targets ${install_targets} aprapp-1)
SET(install_lib_pdb ${install_lib_pdb} ${PROJECT_BINARY_DIR}/aprapp-1.pdb)
SET_TARGET_PROPERTIES(aprapp-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_STATIC;APR_APP;WINNT")
IF(APR_BUILD_TESTAPR)
@ -394,10 +391,6 @@ IF(INSTALL_PDB)
INSTALL(FILES ${install_bin_pdb}
DESTINATION bin
CONFIGURATIONS RelWithDebInfo Debug)
INSTALL(FILES ${install_lib_pdb}
DESTINATION lib
CONFIGURATIONS RelWithDebInfo Debug)
ENDIF()
INSTALL(FILES ${APR_PUBLIC_HEADERS_STATIC} ${APR_PUBLIC_HEADERS_GENERATED} DESTINATION include)

View File

@ -129,11 +129,11 @@ check: $(TARGET_LIB)
etags:
etags `find . -name '*.[ch]'`
make_tools_dir:
$(APR_MKDIR) tools
OBJECTS_gen_test_char = tools/gen_test_char.lo $(LOCAL_LIBS)
tools/gen_test_char.lo: make_tools_dir
tools/gen_test_char.lo: tools/gen_test_char.c
$(APR_MKDIR) tools
$(LT_COMPILE)
tools/gen_test_char@EXEEXT@: $(OBJECTS_gen_test_char)
$(LINK_PROG) $(OBJECTS_gen_test_char) $(ALL_LIBS)

View File

@ -1,5 +1,5 @@
Apache Portable Runtime
Copyright (c) 2000-2014 The Apache Software Foundation.
Copyright (c) 2000-2015 The Apache Software Foundation.
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).

View File

@ -50,6 +50,7 @@ include $(APR_WORK)/build/NWGNUhead.inc
#
XINCDIRS += \
$(APR)/include \
$(APR)/include/private \
$(APR)/include/arch/NetWare \
$(APR)/include/arch/unix \
$(APR)/memory/unix \
@ -293,11 +294,13 @@ FILES_nlm_exports = \
FILES_lib_objs = \
$(OBJDIR)/apr_atomic.o \
$(OBJDIR)/apr_cpystrn.o \
$(OBJDIR)/apr_escape.o \
$(OBJDIR)/apr_fnmatch.o \
$(OBJDIR)/apr_getpass.o \
$(OBJDIR)/apr_hash.o \
$(OBJDIR)/apr_pools.o \
$(OBJDIR)/apr_random.o \
$(OBJDIR)/apr_skiplist.o \
$(OBJDIR)/apr_snprintf.o \
$(OBJDIR)/apr_strings.o \
$(OBJDIR)/apr_strnatcmp.o \
@ -407,7 +410,7 @@ endif
vpath %.c atomic/netware:strings:tables:passwd:lib:time/unix
vpath %.c file_io/unix:locks/netware:misc/netware:misc/unix:threadproc/netware
vpath %.c poll/unix:shmem/unix:support/unix:random/unix
vpath %.c dso/netware:memory/unix:mmap/unix:user/netware
vpath %.c dso/netware:memory/unix:mmap/unix:user/netware:encoding
# Use the win32 network_io if Winsock is being used
ifndef USE_STDSOCKETS

View File

@ -907,69 +907,6 @@ SOURCE=.\include\apr_version.h
# Begin Source File
SOURCE=.\include\apr_want.h
!IF "$(CFG)" == "apr - Win32 Release"
# Begin Custom Build
InputPath=.\include\apr_want.h
".\LibR\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
type .\include\apr.hw > .\include\apr.h
# End Custom Build
!ELSEIF "$(CFG)" == "apr - Win32 Debug"
# Begin Custom Build
InputPath=.\include\apr_want.h
".\LibD\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
type .\include\apr.hw > .\include\apr.h
# End Custom Build
!ELSEIF "$(CFG)" == "apr - Win32 Release9x"
# Begin Custom Build
InputPath=.\include\apr_want.h
".\9x\LibR\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
type .\include\apr.hw > .\include\apr.h
# End Custom Build
!ELSEIF "$(CFG)" == "apr - Win32 Debug9x"
# Begin Custom Build
InputPath=.\include\apr_want.h
".\9x\LibD\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
type .\include\apr.hw > .\include\apr.h
# End Custom Build
!ELSEIF "$(CFG)" == "apr - x64 Release"
# Begin Custom Build
InputPath=.\include\apr_want.h
".\x64\LibR\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
type .\include\apr.hw > .\include\apr.h
# End Custom Build
!ELSEIF "$(CFG)" == "apr - x64 Debug"
# Begin Custom Build
InputPath=.\include\apr_want.h
".\x64\LibD\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
type .\include\apr.hw > .\include\apr.h
# End Custom Build
!ENDIF
# End Source File
# End Group
# End Target

View File

@ -3,7 +3,7 @@
Summary: Apache Portable Runtime library
Name: apr
Version: 1.5.1
Version: 1.5.2
Release: 1
License: Apache Software License
Group: System Environment/Libraries
@ -76,7 +76,7 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root,-)
%doc docs/APRDesign.html docs/canonical_filenames.html
%doc docs/incomplete_types docs/non_apr_programs
%doc --parents html
%doc html
%{_bindir}/apr*config
%{_libdir}/libapr-%{aprver}.*a
%{_libdir}/libapr-%{aprver}.so

View File

@ -251,7 +251,7 @@ file_io/win32/filestat.lo: file_io/win32/filestat.c .make.dirs include/apr_alloc
file_io/win32/filesys.lo: file_io/win32/filesys.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_want.h
file_io/win32/flock.lo: file_io/win32/flock.c .make.dirs
file_io/win32/open.lo: file_io/win32/open.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h
file_io/win32/pipe.lo: file_io/win32/pipe.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h
file_io/win32/pipe.lo: file_io/win32/pipe.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_escape.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h
file_io/win32/readwrite.lo: file_io/win32/readwrite.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h
file_io/win32/seek.lo: file_io/win32/seek.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h

73
contrib/apr/configure vendored
View File

@ -6802,10 +6802,10 @@ if test "x$apr_preload_done" != "xyes" ; then
*-apple-darwin*)
if test "x$CPPFLAGS" = "x"; then
test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp\""
CPPFLAGS="-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp"
test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK\""
CPPFLAGS="-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK"
else
apr_addto_bugger="-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp"
apr_addto_bugger="-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK"
for i in $apr_addto_bugger; do
apr_addto_duplicate="0"
for j in $CPPFLAGS; do
@ -18794,7 +18794,34 @@ if test "${enable_nonportable_atomics+set}" = set; then :
else
case $host_cpu in
i[456]86) force_generic_atomics=yes ;;
*) force_generic_atomics=no ;;
*) force_generic_atomics=no
case $host in
*solaris2.10*)
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <atomic.h>
int
main ()
{
void *ptr = NULL; atomic_cas_ptr(&ptr, NULL, NULL);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
else
force_generic_atomics=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test $force_generic_atomics = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: nonportable atomic support disabled, system needs Patch-ID 118884 or 118885" >&5
$as_echo "$as_me: nonportable atomic support disabled, system needs Patch-ID 118884 or 118885" >&6;}
fi
;;
esac
;;
esac
fi
@ -22292,7 +22319,7 @@ else
fi
done
for ac_func in getpass getpassphrase gmtime_r localtime_r mkstemp
for ac_func in getpass getpassphrase gmtime_r localtime_r
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@ -22304,6 +22331,23 @@ _ACEOF
fi
done
case $host in
*-hp-hpux*)
;;
*)
for ac_func in mkstemp
do :
ac_fn_c_check_func "$LINENO" "mkstemp" "ac_cv_func_mkstemp"
if test "x$ac_cv_func_mkstemp" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_MKSTEMP 1
_ACEOF
fi
done
;;
esac
@ -23902,7 +23946,7 @@ _ACEOF
if test "${ac_cv_sizeof_off_t}${apr_cv_use_lfs64}" = "4yes"; then
# Enable LFS
aprlfs=1
for ac_func in mmap64 sendfile64 sendfilev64 mkstemp64 readdir64_r
for ac_func in mmap64 sendfile64 sendfilev64 readdir64_r
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@ -23914,6 +23958,23 @@ _ACEOF
fi
done
case $host in
*-hp-hpux*)
;;
*)
for ac_func in mkstemp64
do :
ac_fn_c_check_func "$LINENO" "mkstemp64" "ac_cv_func_mkstemp64"
if test "x$ac_cv_func_mkstemp64" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_MKSTEMP64 1
_ACEOF
fi
done
;;
esac
elif test "${ac_cv_sizeof_off_t}" != "${ac_cv_sizeof_size_t}"; then
# unsure of using -gt above is as portable, can can't forsee where
# off_t can legitimately be smaller than size_t

View File

@ -640,7 +640,20 @@ AC_ARG_ENABLE(nonportable-atomics,
],
[case $host_cpu in
i[[456]]86) force_generic_atomics=yes ;;
*) force_generic_atomics=no ;;
*) force_generic_atomics=no
case $host in
*solaris2.10*)
AC_TRY_COMPILE(
[#include <atomic.h>],
[void *ptr = NULL; atomic_cas_ptr(&ptr, NULL, NULL);],,
[force_generic_atomics=yes]
)
if test $force_generic_atomics = yes; then
AC_MSG_NOTICE([nonportable atomic support disabled, system needs Patch-ID 118884 or 118885])
fi
;;
esac
;;
esac
])
@ -1400,7 +1413,15 @@ if test "$native_mmap_emul" = "1"; then
mmap="1"
fi
AC_CHECK_FUNCS(memmove, [ have_memmove="1" ], [have_memmove="0" ])
AC_CHECK_FUNCS([getpass getpassphrase gmtime_r localtime_r mkstemp])
AC_CHECK_FUNCS([getpass getpassphrase gmtime_r localtime_r])
case $host in
*-hp-hpux*)
dnl mkstemp is limited to 26 temporary files (a-z); use APR replacement
;;
*)
AC_CHECK_FUNCS(mkstemp)
;;
esac
AC_SUBST(fork)
AC_SUBST(have_inet_addr)
@ -1801,7 +1822,15 @@ APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], off_t, 8)
if test "${ac_cv_sizeof_off_t}${apr_cv_use_lfs64}" = "4yes"; then
# Enable LFS
aprlfs=1
AC_CHECK_FUNCS([mmap64 sendfile64 sendfilev64 mkstemp64 readdir64_r])
AC_CHECK_FUNCS([mmap64 sendfile64 sendfilev64 readdir64_r])
case $host in
*-hp-hpux*)
dnl mkstemp64 is limited to 26 temporary files (a-z); use APR replacement
;;
*)
AC_CHECK_FUNCS(mkstemp64)
;;
esac
elif test "${ac_cv_sizeof_off_t}" != "${ac_cv_sizeof_size_t}"; then
# unsure of using -gt above is as portable, can can't forsee where
# off_t can legitimately be smaller than size_t

View File

@ -436,6 +436,8 @@ APR_DECLARE(apr_status_t) apr_escape_path(char *escaped, const char *path,
while ((c = *s) && slen) {
if (TEST_CHAR(c, T_OS_ESCAPE_PATH)) {
d = c2x(c, '%', d);
size += 2;
found = 1;
}
else {
*d++ = c;

View File

@ -40,7 +40,9 @@ extern "C" {
/**
* apr_skiplist_compare is the function type that must be implemented
* per object type that is used in a skip list for comparisons to maintain
* order
* order. A value <0 indicates placement after this node; a value of 0
* indicates collision with this exact node; a value >0 indicates placement
* before this node.
* */
typedef int (*apr_skiplist_compare) (void *, void *);
@ -171,7 +173,8 @@ APR_DECLARE(void *) apr_skiplist_next(apr_skiplist *sl, apr_skiplistnode **iter)
APR_DECLARE(void *) apr_skiplist_previous(apr_skiplist *sl, apr_skiplistnode **iter);
/**
* Insert an element into the skip list using the specified comparison function.
* Insert an element into the skip list using the specified comparison function
* if it does not already exist.
* @param sl The skip list
* @param data The element to insert
* @param comp The comparison function to use for placement into the skip list
@ -180,7 +183,8 @@ APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist *sl,
void *data, apr_skiplist_compare comp);
/**
* Insert an element into the skip list using the existing comparison function.
* Insert an element into the skip list using the existing comparison function
* if it does not already exist (as determined by the comparison function)
* @param sl The skip list
* @param data The element to insert
* @remark If no comparison function has been set for the skip list, the element
@ -190,7 +194,7 @@ APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist* sl, void *data
/**
* Remove an element from the skip list using the specified comparison function for
* locating the element.
* locating the element. In the case of duplicates, the 1st entry will be removed.
* @param sl The skip list
* @param data The element to remove
* @param myfree A function to be called for each removed element
@ -203,7 +207,7 @@ APR_DECLARE(int) apr_skiplist_remove_compare(apr_skiplist *sl, void *data,
/**
* Remove an element from the skip list using the existing comparison function for
* locating the element.
* locating the element. In the case of duplicates, the 1st entry will be removed.
* @param sl The skip list
* @param data The element to remove
* @param myfree A function to be called for each removed element
@ -229,7 +233,7 @@ APR_DECLARE(void) apr_skiplist_remove_all(apr_skiplist *sl, apr_skiplist_freefun
APR_DECLARE(void) apr_skiplist_destroy(apr_skiplist *sl, apr_skiplist_freefunc myfree);
/**
* Return the first element in the skip list, leaving the element in the skip list.
* Return the first element in the skip list, removing the element from the skip list.
* @param sl The skip list
* @param myfree A function to be called for the removed element
* @remark NULL will be returned if there are no elements

View File

@ -38,7 +38,7 @@
*/
#define APR_COPYRIGHT "Copyright (c) 2000-2014 The Apache Software " \
#define APR_COPYRIGHT "Copyright (c) 2000-2015 The Apache Software " \
"Foundation or its licensors, as applicable."
/* The numeric compile-time version constants. These constants are the
@ -62,7 +62,7 @@
* The Patch Level never includes API changes, simply bug fixes.
* Reset to 0 when upgrading APR_MINOR_VERSION
*/
#define APR_PATCH_VERSION 1
#define APR_PATCH_VERSION 2
/**
* The symbol APR_IS_DEV_VERSION is only defined for internal,

View File

@ -765,7 +765,7 @@ SOURCE=.\include\apr_escape.h
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
InputPath=.\include\apr_escape.h
".\Release\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl.exe /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\Release\gen_test_char /Fe.\Release\gen_test_char.exe .\tools\gen_test_char.c
.\Release\gen_test_char.exe > .\include\apr_escape_test_char.h
@ -776,7 +776,7 @@ InputPath=.\include\apr_escape.h
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
InputPath=.\include\apr_escape.h
".\Debug\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl.exe /nologo /W3 /EHsc /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\Debug\gen_test_char /Fe.\Debug\gen_test_char.exe .\tools\gen_test_char.c
.\Debug\gen_test_char.exe > .\include\apr_escape_test_char.h
@ -787,7 +787,7 @@ InputPath=.\include\apr_escape.h
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
InputPath=.\include\apr_escape.h
".\9x\Release\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl.exe /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\9x\Release\gen_test_char /Fe.\9x\Release\gen_test_char.exe .\tools\gen_test_char.c
.\9x\Release\gen_test_char.exe > .\include\apr_escape_test_char.h
@ -798,7 +798,7 @@ InputPath=.\include\apr_escape.h
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
InputPath=.\include\apr_escape.h
".\9x\Debug\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl.exe /nologo /W3 /EHsc /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\9x\Debug\gen_test_char /Fe.\9x\Debug\gen_test_char.exe .\tools\gen_test_char.c
.\9x\Debug\gen_test_char.exe > .\include\apr_escape_test_char.h
@ -809,7 +809,7 @@ InputPath=.\include\apr_escape.h
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
InputPath=.\include\apr_escape.h
".\x64\Release\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl.exe /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\x64\Release\gen_test_char /Fe.\x64\Release\gen_test_char.exe .\tools\gen_test_char.c
.\x64\Release\gen_test_char.exe > .\include\apr_escape_test_char.h
@ -820,7 +820,7 @@ InputPath=.\include\apr_escape.h
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
InputPath=.\include\apr_escape.h
".\x64\Debug\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl.exe /nologo /W3 /EHsc /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\x64\Debug\gen_test_char /Fe.\x64\Debug\gen_test_char.exe .\tools\gen_test_char.c
.\x64\Debug\gen_test_char.exe > .\include\apr_escape_test_char.h
@ -952,69 +952,6 @@ SOURCE=.\include\apr_version.h
# Begin Source File
SOURCE=.\include\apr_want.h
!IF "$(CFG)" == "libapr - Win32 Release"
# Begin Custom Build
InputPath=.\include\apr_want.h
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
type .\include\apr.hw > .\include\apr.h
# End Custom Build
!ELSEIF "$(CFG)" == "libapr - Win32 Debug"
# Begin Custom Build
InputPath=.\include\apr_want.h
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
type .\include\apr.hw > .\include\apr.h
# End Custom Build
!ELSEIF "$(CFG)" == "libapr - Win32 Release9x"
# Begin Custom Build
InputPath=.\include\apr_want.h
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
type .\include\apr.hw > .\include\apr.h
# End Custom Build
!ELSEIF "$(CFG)" == "libapr - Win32 Debug9x"
# Begin Custom Build
InputPath=.\include\apr_want.h
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
type .\include\apr.hw > .\include\apr.h
# End Custom Build
!ELSEIF "$(CFG)" == "libapr - x64 Release"
# Begin Custom Build
InputPath=.\include\apr_want.h
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
type .\include\apr.hw > .\include\apr.h
# End Custom Build
!ELSEIF "$(CFG)" == "libapr - x64 Debug"
# Begin Custom Build
InputPath=.\include\apr_want.h
".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
type .\include\apr.hw > .\include\apr.h
# End Custom Build
!ENDIF
# End Source File
# End Group
# Begin Source File

View File

@ -114,7 +114,9 @@ static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex,
usec = apr_time_usec(now);
apr_snprintf(semname, sizeof(semname), "/ApR.%lxZ%lx", sec, usec);
}
do {
psem = sem_open(semname, O_CREAT | O_EXCL, 0644, 1);
} while (psem == (sem_t *)SEM_FAILED && errno == EINTR);
if (psem == (sem_t *)SEM_FAILED) {
if (errno == ENAMETOOLONG) {
/* Oh well, good try */
@ -122,7 +124,9 @@ static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex,
} else {
return errno;
}
do {
psem = sem_open(semname, O_CREAT | O_EXCL, 0644, 1);
} while (psem == (sem_t *)SEM_FAILED && errno == EINTR);
}
if (psem == (sem_t *)SEM_FAILED) {
@ -140,7 +144,12 @@ static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex,
static apr_status_t proc_mutex_posix_acquire(apr_proc_mutex_t *mutex)
{
if (sem_wait(mutex->psem_interproc) < 0) {
int rc;
do {
rc = sem_wait(mutex->psem_interproc);
} while (rc < 0 && errno == EINTR);
if (rc < 0) {
return errno;
}
mutex->curr_locked = 1;
@ -149,7 +158,12 @@ static apr_status_t proc_mutex_posix_acquire(apr_proc_mutex_t *mutex)
static apr_status_t proc_mutex_posix_tryacquire(apr_proc_mutex_t *mutex)
{
if (sem_trywait(mutex->psem_interproc) < 0) {
int rc;
do {
rc = sem_trywait(mutex->psem_interproc);
} while (rc < 0 && errno == EINTR);
if (rc < 0) {
if (errno == EAGAIN) {
return APR_EBUSY;
}

View File

@ -1135,21 +1135,12 @@ APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap)
* room to hold the NUL terminator.
*/
if (ps.node->first_avail == ps.node->endp) {
if (psprintf_flush(&ps.vbuff) == -1) {
if (pool->abort_fn) {
pool->abort_fn(APR_ENOMEM);
if (psprintf_flush(&ps.vbuff) == -1)
goto error;
}
return NULL;
}
}
if (apr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap) == -1) {
if (pool->abort_fn)
pool->abort_fn(APR_ENOMEM);
return NULL;
}
if (apr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap) == -1)
goto error;
strp = ps.vbuff.curpos;
*strp++ = '\0';
@ -1195,6 +1186,15 @@ APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap)
list_insert(active, node);
return strp;
error:
if (pool->abort_fn)
pool->abort_fn(APR_ENOMEM);
if (ps.got_a_new_node) {
ps.node->next = ps.free;
allocator_free(pool->allocator, ps.node);
}
return NULL;
}

View File

@ -39,6 +39,8 @@ static char *stuffbuffer(char *buf, apr_size_t bufsize, const char *s)
static char *apr_error_string(apr_status_t statcode)
{
switch (statcode) {
case APR_ENOSTAT:
return "Could not perform a stat on the file.";
case APR_ENOPOOL:
return "A new pool could not be created.";
case APR_EBADDATE:
@ -73,7 +75,10 @@ static char *apr_error_string(apr_status_t statcode)
return "The specified IP address is invalid.";
case APR_EBADMASK:
return "The specified network mask is invalid.";
case APR_ESYMNOTFOUND:
return "Could not find the requested symbol.";
case APR_ENOTENOUGHENTROPY:
return "Not enough entropy to continue.";
case APR_INCHILD:
return
"Your code just forked, and you are currently executing in the "
@ -128,10 +133,12 @@ static char *apr_error_string(apr_status_t statcode)
return "The given path is misformatted or contained invalid characters";
case APR_EPATHWILD:
return "The given path contained wildcard characters";
case APR_EBUSY:
return "The given lock was busy.";
case APR_EPROC_UNKNOWN:
return "The process is not recognized.";
case APR_EGENERAL:
return "Internal error";
return "Internal error (specific information not available)";
default:
return "Error string not specified yet";
}

View File

@ -325,6 +325,16 @@ static apr_status_t call_resolver(apr_sockaddr_t **sa,
hints.ai_flags = AI_ADDRCONFIG;
}
#endif
#ifdef __MVS__
/* z/OS will not return IPv4 address under AF_UNSPEC if any IPv6 results
* are returned, w/o AI_ALL.
*/
if (family == APR_UNSPEC) {
hints.ai_flags |= AI_ALL;
}
#endif
if(hostname == NULL) {
#ifdef AI_PASSIVE
/* If hostname is NULL, assume we are trying to bind to all

View File

@ -145,13 +145,22 @@ apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type,
#ifndef HAVE_SOCK_CLOEXEC
{
int flags;
apr_status_t rv;
if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1)
return errno;
if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) {
rv = errno;
close((*new)->socketdes);
(*new)->socketdes = -1;
return rv;
}
flags |= FD_CLOEXEC;
if (fcntl((*new)->socketdes, F_SETFD, flags) == -1)
return errno;
if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) {
rv = errno;
close((*new)->socketdes);
(*new)->socketdes = -1;
return rv;
}
}
#endif
@ -306,13 +315,22 @@ apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock,
#ifndef HAVE_ACCEPT4
{
int flags;
apr_status_t rv;
if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1)
return errno;
if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) {
rv = errno;
close((*new)->socketdes);
(*new)->socketdes = -1;
return rv;
}
flags |= FD_CLOEXEC;
if (fcntl((*new)->socketdes, F_SETFD, flags) == -1)
return errno;
if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) {
rv = errno;
close((*new)->socketdes);
(*new)->socketdes = -1;
return rv;
}
}
#endif

View File

@ -104,14 +104,22 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset,
#ifndef HAVE_EPOLL_CREATE1
{
int flags;
int fd_flags;
if ((flags = fcntl(fd, F_GETFD)) == -1)
return errno;
if ((fd_flags = fcntl(fd, F_GETFD)) == -1) {
rv = errno;
close(fd);
pollset->p = NULL;
return rv;
}
flags |= FD_CLOEXEC;
if (fcntl(fd, F_SETFD, flags) == -1)
return errno;
fd_flags |= FD_CLOEXEC;
if (fcntl(fd, F_SETFD, fd_flags) == -1) {
rv = errno;
close(fd);
pollset->p = NULL;
return rv;
}
}
#endif
@ -122,11 +130,13 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset,
((rv = apr_thread_mutex_create(&pollset->p->ring_lock,
APR_THREAD_MUTEX_DEFAULT,
p)) != APR_SUCCESS)) {
close(fd);
pollset->p = NULL;
return rv;
}
#else
if (flags & APR_POLLSET_THREADSAFE) {
close(fd);
pollset->p = NULL;
return APR_ENOTIMPL;
}
@ -345,14 +355,23 @@ static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb,
#ifndef HAVE_EPOLL_CREATE1
{
int flags;
int fd_flags;
apr_status_t rv;
if ((flags = fcntl(fd, F_GETFD)) == -1)
return errno;
if ((fd_flags = fcntl(fd, F_GETFD)) == -1) {
rv = errno;
close(fd);
pollcb->fd = -1;
return rv;
}
flags |= FD_CLOEXEC;
if (fcntl(fd, F_SETFD, flags) == -1)
return errno;
fd_flags |= FD_CLOEXEC;
if (fcntl(fd, F_SETFD, fd_flags) == -1) {
rv = errno;
close(fd);
pollcb->fd = -1;
return rv;
}
}
#endif

View File

@ -115,12 +115,20 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset,
{
int flags;
if ((flags = fcntl(pollset->p->kqueue_fd, F_GETFD)) == -1)
return errno;
if ((flags = fcntl(pollset->p->kqueue_fd, F_GETFD)) == -1) {
rv = errno;
close(pollset->p->kqueue_fd);
pollset->p = NULL;
return rv;
}
flags |= FD_CLOEXEC;
if (fcntl(pollset->p->kqueue_fd, F_SETFD, flags) == -1)
return errno;
if (fcntl(pollset->p->kqueue_fd, F_SETFD, flags) == -1) {
rv = errno;
close(pollset->p->kqueue_fd);
pollset->p = NULL;
return rv;
}
}
pollset->p->result_set = apr_palloc(p, pollset->p->setsize * sizeof(apr_pollfd_t));
@ -338,13 +346,22 @@ static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb,
{
int flags;
apr_status_t rv;
if ((flags = fcntl(fd, F_GETFD)) == -1)
return errno;
if ((flags = fcntl(fd, F_GETFD)) == -1) {
rv = errno;
close(fd);
pollcb->fd = -1;
return rv;
}
flags |= FD_CLOEXEC;
if (fcntl(fd, F_SETFD, flags) == -1)
return errno;
if (fcntl(fd, F_SETFD, flags) == -1) {
rv = errno;
close(fd);
pollcb->fd = -1;
return rv;
}
}
pollcb->fd = fd;

View File

@ -240,26 +240,25 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
{
int ret;
apr_status_t rv = APR_SUCCESS;
#ifdef WIN32
apr_interval_time_t orig_timeout = timeout;
#endif
if (timeout > 0) {
timeout /= 1000;
}
#ifdef WIN32
/* WSAPoll() requires at least one socket. */
if (pollset->nelts == 0) {
*num = 0;
if (orig_timeout > 0) {
apr_sleep(orig_timeout);
if (timeout > 0) {
apr_sleep(timeout);
return APR_TIMEUP;
}
return APR_SUCCESS;
}
if (timeout > 0) {
timeout /= 1000;
}
ret = WSAPoll(pollset->p->pollset, pollset->nelts, (int)timeout);
#else
if (timeout > 0) {
timeout /= 1000;
}
ret = poll(pollset->p->pollset, pollset->nelts, timeout);
#endif
(*num) = ret;
@ -398,12 +397,23 @@ static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb,
apr_status_t rv = APR_SUCCESS;
apr_uint32_t i;
#ifdef WIN32
/* WSAPoll() requires at least one socket. */
if (pollcb->nelts == 0) {
if (timeout > 0) {
apr_sleep(timeout);
return APR_TIMEUP;
}
return APR_SUCCESS;
}
if (timeout > 0) {
timeout /= 1000;
}
#ifdef WIN32
ret = WSAPoll(pollcb->pollset.ps, pollcb->nelts, (int)timeout);
#else
if (timeout > 0) {
timeout /= 1000;
}
ret = poll(pollcb->pollset.ps, pollcb->nelts, timeout);
#endif
if (ret < 0) {

View File

@ -136,6 +136,9 @@ APR_DECLARE(apr_status_t) apr_pollcb_create_ex(apr_pollcb_t **ret_pollcb,
}
pollcb->provider = provider;
}
else if (rv != APR_SUCCESS) {
return rv;
}
*ret_pollcb = pollcb;
return APR_SUCCESS;

View File

@ -188,12 +188,20 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset,
{
int flags;
if ((flags = fcntl(pollset->p->port_fd, F_GETFD)) == -1)
return errno;
if ((flags = fcntl(pollset->p->port_fd, F_GETFD)) == -1) {
rv = errno;
close(pollset->p->port_fd);
pollset->p = NULL;
return rv;
}
flags |= FD_CLOEXEC;
if (fcntl(pollset->p->port_fd, F_SETFD, flags) == -1)
return errno;
if (fcntl(pollset->p->port_fd, F_SETFD, flags) == -1) {
rv = errno;
close(pollset->p->port_fd);
pollset->p = NULL;
return rv;
}
}
pollset->p->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
@ -478,13 +486,22 @@ static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb,
{
int flags;
apr_status_t rv;
if ((flags = fcntl(pollcb->fd, F_GETFD)) == -1)
return errno;
if ((flags = fcntl(pollcb->fd, F_GETFD)) == -1) {
rv = errno;
close(pollcb->fd);
pollcb->fd = -1;
return rv;
}
flags |= FD_CLOEXEC;
if (fcntl(pollcb->fd, F_SETFD, flags) == -1)
return errno;
if (fcntl(pollcb->fd, F_SETFD, flags) == -1) {
rv = errno;
close(pollcb->fd);
pollcb->fd = -1;
return rv;
}
}
pollcb->pollset.port = apr_palloc(p, size * sizeof(port_event_t));

View File

@ -272,7 +272,7 @@ static apr_status_t asio_pollset_create(apr_pollset_t *pollset,
APR_THREAD_MUTEX_DEFAULT,
p) != APR_SUCCESS) {
DBG1(1, "apr_thread_mutex_create returned %d\n", rv);
pollset = NULL;
pollset->p = NULL;
return rv;
}
rv = msgget(IPC_PRIVATE, S_IWUSR+S_IRUSR); /* user r/w perms */
@ -280,7 +280,7 @@ static apr_status_t asio_pollset_create(apr_pollset_t *pollset,
#if DEBUG
perror(__FUNCTION__ " msgget returned < 0 ");
#endif
pollset = NULL;
pollset->p = NULL;
return rv;
}
@ -292,7 +292,7 @@ static apr_status_t asio_pollset_create(apr_pollset_t *pollset,
APR_RING_INIT(&priv->prior_ready_ring, asio_elem_t, link);
#else /* APR doesn't have threads but caller wants a threadsafe pollset */
pollset = NULL;
pollset->p = NULL;
return APR_ENOTIMPL;
#endif
@ -304,6 +304,7 @@ static apr_status_t asio_pollset_create(apr_pollset_t *pollset,
priv->query_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
if ((!priv->pollset) || (!priv->query_set)) {
pollset->p = NULL;
return APR_ENOMEM;
}
}
@ -314,6 +315,10 @@ static apr_status_t asio_pollset_create(apr_pollset_t *pollset,
priv->size = size;
priv->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
if (!priv->result_set) {
if (flags & APR_POLLSET_THREADSAFE) {
msgctl(priv->msg_q, IPC_RMID, NULL);
}
pollset->p = NULL;
return APR_ENOMEM;
}
@ -379,6 +384,7 @@ static apr_status_t asio_pollset_add(apr_pollset_t *pollset,
APR_RING_REMOVE(elem, link);
DBG1(3, "used recycled memory at %08p\n", elem);
elem->state = ASIO_INIT;
elem->a.aio_cflags = 0;
}
else {
elem = (asio_elem_t *) apr_pcalloc(pollset->pool, sizeof(asio_elem_t));
@ -659,6 +665,7 @@ static apr_status_t asio_pollset_poll(apr_pollset_t *pollset,
if (ret == 1) {
DBG(4, "asyncio() completed inline\n");
/* it's ready now */
elem->state = ASIO_COMPLETE;
APR_RING_INSERT_TAIL(&(priv->ready_ring), elem, asio_elem_t,
link);
}

View File

@ -25,12 +25,18 @@
#include "apr_skiplist.h"
typedef struct {
apr_skiplistnode **data;
size_t size, pos;
apr_pool_t *p;
} apr_skiplist_q;
struct apr_skiplist {
apr_skiplist_compare compare;
apr_skiplist_compare comparek;
int height;
int preheight;
int size;
size_t size;
apr_skiplistnode *top;
apr_skiplistnode *bottom;
/* These two are needed for appending */
@ -38,6 +44,8 @@ struct apr_skiplist {
apr_skiplistnode *bottomend;
apr_skiplist *index;
apr_array_header_t *memlist;
apr_skiplist_q nodes_q,
stack_q;
apr_pool_t *pool;
};
@ -52,20 +60,15 @@ struct apr_skiplistnode {
apr_skiplist *sl;
};
#ifndef MIN
#define MIN(a,b) ((a<b)?(a):(b))
#endif
static int get_b_rand(void)
{
static int ph = 32; /* More bits than we will ever use */
static apr_uint32_t randseq;
static int randseq;
if (ph > 31) { /* Num bits in return of rand() */
ph = 0;
randseq = (apr_uint32_t) rand();
randseq = rand();
}
ph++;
return ((randseq & (1 << (ph - 1))) >> (ph - 1));
return randseq & (1 << ph++);
}
typedef struct {
@ -103,7 +106,7 @@ APR_DECLARE(void *) apr_skiplist_alloc(apr_skiplist *sl, size_t size)
memlist++;
}
/* no free chunks */
ptr = apr_pcalloc(sl->pool, size);
ptr = apr_palloc(sl->pool, size);
if (!ptr) {
return ptr;
}
@ -122,7 +125,7 @@ APR_DECLARE(void *) apr_skiplist_alloc(apr_skiplist *sl, size_t size)
return ptr;
}
else {
return calloc(1, size);
return malloc(size);
}
}
@ -149,27 +152,73 @@ APR_DECLARE(void) apr_skiplist_free(apr_skiplist *sl, void *mem)
}
}
static apr_status_t skiplist_qpush(apr_skiplist_q *q, apr_skiplistnode *m)
{
if (q->pos >= q->size) {
apr_skiplistnode **data;
size_t size = (q->pos) ? q->pos * 2 : 32;
if (q->p) {
data = apr_palloc(q->p, size * sizeof(*data));
if (data) {
memcpy(data, q->data, q->pos * sizeof(*data));
}
}
else {
data = realloc(q->data, size * sizeof(*data));
}
if (!data) {
return APR_ENOMEM;
}
q->data = data;
q->size = size;
}
q->data[q->pos++] = m;
return APR_SUCCESS;
}
static APR_INLINE apr_skiplistnode *skiplist_qpop(apr_skiplist_q *q)
{
return (q->pos > 0) ? q->data[--q->pos] : NULL;
}
static APR_INLINE void skiplist_qclear(apr_skiplist_q *q)
{
q->pos = 0;
}
static apr_skiplistnode *skiplist_new_node(apr_skiplist *sl)
{
apr_skiplistnode *m = skiplist_qpop(&sl->nodes_q);
if (!m) {
if (sl->pool) {
m = apr_palloc(sl->pool, sizeof *m);
}
else {
m = malloc(sizeof *m);
}
}
return m;
}
static apr_status_t skiplist_free_node(apr_skiplist *sl, apr_skiplistnode *m)
{
return skiplist_qpush(&sl->nodes_q, m);
}
static apr_status_t skiplisti_init(apr_skiplist **s, apr_pool_t *p)
{
apr_skiplist *sl;
if (p) {
sl = apr_pcalloc(p, sizeof(apr_skiplist));
sl->memlist = apr_array_make(p, 20, sizeof(memlist_t));
sl->pool = sl->nodes_q.p = sl->stack_q.p = p;
}
else {
sl = calloc(1, sizeof(apr_skiplist));
if (!sl) {
return APR_ENOMEM;
}
}
#if 0
sl->compare = (apr_skiplist_compare) NULL;
sl->comparek = (apr_skiplist_compare) NULL;
sl->height = 0;
sl->preheight = 0;
sl->size = 0;
sl->top = NULL;
sl->bottom = NULL;
sl->index = NULL;
#endif
sl->pool = p;
*s = sl;
return APR_SUCCESS;
}
@ -248,40 +297,16 @@ APR_DECLARE(void) apr_skiplist_add_index(apr_skiplist *sl,
}
}
APR_DECLARE(apr_skiplistnode *) apr_skiplist_getlist(apr_skiplist *sl)
{
if (!sl->bottom) {
return NULL;
}
return sl->bottom->next;
}
APR_DECLARE(void *) apr_skiplist_find(apr_skiplist *sl, void *data, apr_skiplistnode **iter)
{
void *ret;
apr_skiplistnode *aiter;
if (!sl->compare) {
return 0;
}
if (iter) {
ret = apr_skiplist_find_compare(sl, data, iter, sl->compare);
}
else {
ret = apr_skiplist_find_compare(sl, data, &aiter, sl->compare);
}
return ret;
}
static int skiplisti_find_compare(apr_skiplist *sl, void *data,
apr_skiplistnode **ret,
apr_skiplist_compare comp)
{
apr_skiplistnode *m = NULL;
int count = 0;
apr_skiplistnode *m;
m = sl->top;
while (m) {
int compared;
compared = (m->next) ? comp(data, m->next->data) : -1;
if (m->next) {
int compared = comp(data, m->next->data);
if (compared == 0) {
m = m->next;
while (m->down) {
@ -290,15 +315,15 @@ static int skiplisti_find_compare(apr_skiplist *sl, void *data,
*ret = m;
return count;
}
if ((m->next == NULL) || (compared < 0)) {
m = m->down;
count++;
}
else {
if (compared > 0) {
m = m->next;
count++;
continue;
}
}
m = m->down;
count++;
}
*ret = NULL;
return count;
}
@ -307,19 +332,47 @@ APR_DECLARE(void *) apr_skiplist_find_compare(apr_skiplist *sli, void *data,
apr_skiplistnode **iter,
apr_skiplist_compare comp)
{
apr_skiplistnode *m = NULL;
apr_skiplistnode *m;
apr_skiplist *sl;
if (!comp) {
if (iter) {
*iter = NULL;
}
return NULL;
}
if (comp == sli->compare || !sli->index) {
sl = sli;
}
else {
apr_skiplist_find(sli->index, (void *)comp, &m);
if (!m) {
if (iter) {
*iter = NULL;
}
return NULL;
}
sl = (apr_skiplist *) m->data;
}
skiplisti_find_compare(sl, data, iter, sl->comparek);
return (iter && *iter) ? ((*iter)->data) : NULL;
skiplisti_find_compare(sl, data, &m, sl->comparek);
if (iter) {
*iter = m;
}
return (m) ? m->data : NULL;
}
APR_DECLARE(void *) apr_skiplist_find(apr_skiplist *sl, void *data, apr_skiplistnode **iter)
{
return apr_skiplist_find_compare(sl, data, iter, sl->compare);
}
APR_DECLARE(apr_skiplistnode *) apr_skiplist_getlist(apr_skiplist *sl)
{
if (!sl->bottom) {
return NULL;
}
return sl->bottom->next;
}
APR_DECLARE(void *) apr_skiplist_next(apr_skiplist *sl, apr_skiplistnode **iter)
{
@ -339,98 +392,74 @@ APR_DECLARE(void *) apr_skiplist_previous(apr_skiplist *sl, apr_skiplistnode **i
return (*iter) ? ((*iter)->data) : NULL;
}
APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist *sl, void *data)
static APR_INLINE int skiplist_height(const apr_skiplist *sl)
{
if (!sl->compare) {
return 0;
}
return apr_skiplist_insert_compare(sl, data, sl->compare);
/* Skiplists (even empty) always have a top node, although this
* implementation defers its creation until the first insert, or
* deletes it with the last remove. We want the real height here.
*/
return sl->height ? sl->height : 1;
}
APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist *sl, void *data,
apr_skiplist_compare comp)
{
apr_skiplistnode *m, *p, *tmp, *ret = NULL, **stack;
int nh = 1, ch, stacki;
if (!sl->top) {
sl->height = 1;
sl->topend = sl->bottomend = sl->top = sl->bottom =
(apr_skiplistnode *)apr_skiplist_alloc(sl, sizeof(apr_skiplistnode));
#if 0
sl->top->next = (apr_skiplistnode *)NULL;
sl->top->data = (apr_skiplistnode *)NULL;
sl->top->prev = (apr_skiplistnode *)NULL;
sl->top->up = (apr_skiplistnode *)NULL;
sl->top->down = (apr_skiplistnode *)NULL;
sl->top->nextindex = (apr_skiplistnode *)NULL;
sl->top->previndex = (apr_skiplistnode *)NULL;
#endif
sl->top->sl = sl;
apr_skiplistnode *m, *p, *tmp, *ret = NULL;
int ch, nh = 1;
if (!comp) {
return NULL;
}
ch = skiplist_height(sl);
if (sl->preheight) {
while (nh < sl->preheight && get_b_rand()) {
nh++;
}
}
else {
while (nh <= sl->height && get_b_rand()) {
while (nh <= ch && get_b_rand()) {
nh++;
}
}
/* Now we have the new height at which we wish to insert our new node */
/*
* Let us make sure that our tree is a least that tall (grow if
* necessary)
/* Now we have in nh the height at which we wish to insert our new node,
* and in ch the current height: don't create skip paths to the inserted
* element until the walk down through the tree (which decrements ch)
* reaches nh. From there, any walk down pushes the current node on a
* stack (the node(s) after which we would insert) to pop back through
* for insertion later.
*/
for (; sl->height < nh; sl->height++) {
sl->top->up =
(apr_skiplistnode *)apr_skiplist_alloc(sl, sizeof(apr_skiplistnode));
sl->top->up->down = sl->top;
sl->top = sl->topend = sl->top->up;
#if 0
sl->top->prev = sl->top->next = sl->top->nextindex =
sl->top->previndex = sl->top->up = NULL;
sl->top->data = NULL;
#endif
sl->top->sl = sl;
}
ch = sl->height;
/* Find the node (or node after which we would insert) */
/* Keep a stack to pop back through for insertion */
/* malloc() is OK since we free the temp stack */
m = sl->top;
stack = (apr_skiplistnode **)malloc(sizeof(apr_skiplistnode *) * (nh));
stacki = 0;
while (m) {
int compared = -1;
if (m->next) {
compared = comp(data, m->next->data);
}
int compared = comp(data, m->next->data);
if (compared == 0) {
free(stack); /* OK. was malloc'ed */
return 0;
/* Keep the existing element(s) */
skiplist_qclear(&sl->stack_q);
return NULL;
}
if (compared > 0) {
m = m->next;
continue;
}
}
if ((m->next == NULL) || (compared < 0)) {
if (ch <= nh) {
/* push on stack */
stack[stacki++] = m;
skiplist_qpush(&sl->stack_q, m);
}
m = m->down;
ch--;
}
else {
m = m->next;
}
}
/* Pop the stack and insert nodes */
p = NULL;
for (; stacki > 0; stacki--) {
m = stack[stacki - 1];
tmp = (apr_skiplistnode *)apr_skiplist_alloc(sl, sizeof(apr_skiplistnode));
while ((m = skiplist_qpop(&sl->stack_q))) {
tmp = skiplist_new_node(sl);
tmp->next = m->next;
if (m->next) {
m->next->prev = tmp;
}
m->next = tmp;
tmp->prev = m;
tmp->up = NULL;
tmp->nextindex = tmp->previndex = NULL;
@ -438,17 +467,44 @@ APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist *sl, vo
if (p) {
p->up = tmp;
}
else {
/* This sets ret to the bottom-most node we are inserting */
ret = tmp;
}
tmp->data = data;
tmp->sl = sl;
p = tmp;
}
/* Now we are sure the node is inserted, grow our tree to 'nh' tall */
for (; sl->height < nh; sl->height++) {
m = skiplist_new_node(sl);
tmp = skiplist_new_node(sl);
m->up = m->prev = m->nextindex = m->previndex = NULL;
m->next = tmp;
m->down = sl->top;
m->data = NULL;
m->sl = sl;
if (sl->top) {
sl->top->up = m;
}
else {
sl->bottom = sl->bottomend = m;
}
sl->top = sl->topend = tmp->prev = m;
tmp->up = tmp->next = tmp->nextindex = tmp->previndex = NULL;
tmp->down = p;
tmp->data = data;
tmp->sl = sl;
if (p) {
p->up = tmp;
}
else {
/* This sets ret to the bottom-most node we are inserting */
if (!p) {
ret = tmp;
sl->size++; /* this seems to go here got each element to be counted */
}
p = tmp;
}
free(stack); /* OK. was malloc'ed */
if (sl->index != NULL) {
/*
* this is a external insertion, we must insert into each index as
@ -457,25 +513,20 @@ APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist *sl, vo
apr_skiplistnode *ni, *li;
li = ret;
for (p = apr_skiplist_getlist(sl->index); p; apr_skiplist_next(sl->index, &p)) {
ni = apr_skiplist_insert((apr_skiplist *) p->data, ret->data);
apr_skiplist *sli = (apr_skiplist *)p->data;
ni = apr_skiplist_insert_compare(sli, ret->data, sli->compare);
li->nextindex = ni;
ni->previndex = li;
li = ni;
}
}
else {
/* sl->size++; */
}
sl->size++;
return ret;
}
APR_DECLARE(int) apr_skiplist_remove(apr_skiplist *sl, void *data, apr_skiplist_freefunc myfree)
APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist *sl, void *data)
{
if (!sl->compare) {
return 0;
}
return apr_skiplist_remove_compare(sl, data, myfree, sl->comparek);
return apr_skiplist_insert_compare(sl, data, sl->compare);
}
#if 0
@ -520,7 +571,7 @@ static int skiplisti_remove(apr_skiplist *sl, apr_skiplistnode *m, apr_skiplist_
if (!m && myfree && p->data) {
myfree(p->data);
}
apr_skiplist_free(sl, p);
skiplist_free_node(sl, p);
}
sl->size--;
while (sl->top && sl->top->next == NULL) {
@ -530,13 +581,14 @@ static int skiplisti_remove(apr_skiplist *sl, apr_skiplistnode *m, apr_skiplist_
if (sl->top) {
sl->top->up = NULL; /* Make it think its the top */
}
apr_skiplist_free(sl, p);
skiplist_free_node(sl, p);
sl->height--;
}
if (!sl->top) {
sl->bottom = NULL;
sl->bottom = sl->bottomend = NULL;
sl->topend = NULL;
}
return sl->height; /* return 1; ?? */
return skiplist_height(sl);
}
APR_DECLARE(int) apr_skiplist_remove_compare(apr_skiplist *sli,
@ -545,11 +597,17 @@ APR_DECLARE(int) apr_skiplist_remove_compare(apr_skiplist *sli,
{
apr_skiplistnode *m;
apr_skiplist *sl;
if (!comp) {
return 0;
}
if (comp == sli->comparek || !sli->index) {
sl = sli;
}
else {
apr_skiplist_find(sli->index, (void *)comp, &m);
if (!m) {
return 0;
}
sl = (apr_skiplist *) m->data;
}
skiplisti_find_compare(sl, data, &m, comp);
@ -562,6 +620,11 @@ APR_DECLARE(int) apr_skiplist_remove_compare(apr_skiplist *sli,
return skiplisti_remove(sl, m, myfree);
}
APR_DECLARE(int) apr_skiplist_remove(apr_skiplist *sl, void *data, apr_skiplist_freefunc myfree)
{
return apr_skiplist_remove_compare(sl, data, myfree, sl->comparek);
}
APR_DECLARE(void) apr_skiplist_remove_all(apr_skiplist *sl, apr_skiplist_freefunc myfree)
{
/*
@ -573,16 +636,18 @@ APR_DECLARE(void) apr_skiplist_remove_all(apr_skiplist *sl, apr_skiplist_freefun
m = sl->bottom;
while (m) {
p = m->next;
if (p && myfree && p->data)
if (myfree && p && p->data) {
myfree(p->data);
while (m) {
u = m->up;
apr_skiplist_free(sl, p);
m = u;
}
do {
u = m->up;
skiplist_free_node(sl, m);
m = u;
} while (m);
m = p;
}
sl->top = sl->bottom = NULL;
sl->topend = sl->bottomend = NULL;
sl->height = 0;
sl->size = 0;
}
@ -611,8 +676,7 @@ APR_DECLARE(void *) apr_skiplist_peek(apr_skiplist *a)
static void skiplisti_destroy(void *vsl)
{
apr_skiplist_destroy((apr_skiplist *) vsl, NULL);
apr_skiplist_free((apr_skiplist *) vsl, vsl);
apr_skiplist_destroy(vsl, NULL);
}
APR_DECLARE(void) apr_skiplist_destroy(apr_skiplist *sl, apr_skiplist_freefunc myfree)
@ -620,6 +684,13 @@ APR_DECLARE(void) apr_skiplist_destroy(apr_skiplist *sl, apr_skiplist_freefunc m
while (apr_skiplist_pop(sl->index, skiplisti_destroy) != NULL)
;
apr_skiplist_remove_all(sl, myfree);
if (!sl->pool) {
while (sl->nodes_q.pos)
free(sl->nodes_q.data[--sl->nodes_q.pos]);
free(sl->nodes_q.data);
free(sl->stack_q.data);
free(sl);
}
}
APR_DECLARE(apr_skiplist *) apr_skiplist_merge(apr_skiplist *sl1, apr_skiplist *sl2)

View File

@ -914,8 +914,8 @@ fits_in_signed_long (offsetT num ATTRIBUTE_UNUSED)
#ifndef BFD64
return 1;
#else
return (!(((offsetT) -1 << 31) & num)
|| (((offsetT) -1 << 31) & num) == ((offsetT) -1 << 31));
return (!(-((offsetT) 1 << 31) & num)
|| (-((offsetT) 1 << 31) & num) == -((offsetT) 1 << 31));
#endif
} /* fits_in_signed_long() */

View File

@ -151,7 +151,7 @@ int
op_ip(struct snmp_context *ctx, struct snmp_value *value,
u_int sub, u_int idx __unused, enum snmp_op op)
{
int old;
int old = 0;
switch (op) {

View File

@ -34,7 +34,7 @@ COMPILER_RT_ABI fp_t __floatditf(di_int a) {
}
// Exponent of (fp_t)a is the width of abs(a).
const int exponent = (aWidth - 1) - __builtin_clz(a);
const int exponent = (aWidth - 1) - __builtin_clzll(a);
rep_t result;
// Shift a into the significand field and clear the implicit bit. Extra

View File

@ -25,7 +25,7 @@ COMPILER_RT_ABI fp_t __floatunditf(du_int a) {
if (a == 0) return fromRep(0);
// Exponent of (fp_t)a is the width of abs(a).
const int exponent = (aWidth - 1) - __builtin_clz(a);
const int exponent = (aWidth - 1) - __builtin_clzll(a);
rep_t result;
// Shift a into the significand field and clear the implicit bit.

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