Sync to HEAD@r272516.

This commit is contained in:
Alexander V. Chernikov 2014-10-04 12:42:37 +00:00
commit 1ce4b35740
3918 changed files with 275845 additions and 45731 deletions

View File

@ -1,42 +1,6 @@
#
# $FreeBSD$
#
# Copyright (c) 2014 Kevin Lo. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
S= ${.CURDIR}/../../..
.PATH: $S/dev/usb/misc
KMOD= uled
SRCS= opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h vnode_if.h usbdevs.h \
uled.c
.include <bsd.kmod.mk>
#
# $FreeBSD$
#
# The user-driven targets are:
#
# universe - *Really* build *everything* (buildworld and

View File

@ -336,11 +336,11 @@ XFLAGS+= -B${CROSS_BINUTILS_PREFIX}
.else
XFLAGS+= -B${WORLDTMP}/usr/bin
.endif
.if ${TARGET} == "arm" && ${MK_ARM_EABI} != "no"
.if ${TARGET_ARCH:M*eb*} == ""
TARGET_ABI= gnueabi
.elif ${TARGET_ARCH} == "armv6hf"
.if ${TARGET} == "arm"
.if ${TARGET_ARCH:M*hf*} != ""
TARGET_ABI= gnueabihf
.else
TARGET_ABI= gnueabi
.endif
.endif
TARGET_ABI?= unknown
@ -352,6 +352,7 @@ WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP}
.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
# 32 bit world
LIB32_OBJTREE= ${OBJTREE}${.CURDIR}/world32
LIB32TMP= ${OBJTREE}${.CURDIR}/lib32
.if ${TARGET_ARCH} == "amd64"
@ -387,7 +388,7 @@ LIB32FLAGS+= --sysroot=${WORLDTMP}
.endif
# Yes, the flags are redundant.
LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \
LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
_SHLIBDIRPREFIX=${LIB32TMP} \
_LDSCRIPTROOT=${LIB32TMP} \
VERSION="${VERSION}" \
@ -611,7 +612,7 @@ build32:
cd ${.CURDIR}/${_dir}; \
WORLDTMP=${WORLDTMP} \
MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \
MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
build-tools
.endfor
@ -910,7 +911,7 @@ packageworld:
# and do a 'make reinstall' on the *client* to install new binaries from the
# most recent server build.
#
reinstall:
reinstall: .MAKE
@echo "--------------------------------------------------------------"
@echo ">>> Making hierarchy"
@echo "--------------------------------------------------------------"
@ -925,7 +926,7 @@ reinstall:
${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32
.endif
redistribute:
redistribute: .MAKE
@echo "--------------------------------------------------------------"
@echo ">>> Distributing everything"
@echo "--------------------------------------------------------------"
@ -935,7 +936,7 @@ redistribute:
DISTRIBUTION=lib32
.endif
distrib-dirs distribution:
distrib-dirs distribution: .MAKE
cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
@ -1463,7 +1464,7 @@ native-xtools: .MAKE
#
# hierarchy - ensure that all the needed directories are present
#
hierarchy hier:
hierarchy hier: .MAKE
cd ${.CURDIR}/etc && ${HMAKE} distrib-dirs
#
@ -1530,7 +1531,9 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \
lib/ncurses/ncurses lib/ncurses/ncursesw \
lib/libopie lib/libpam ${_lib_libthr} \
lib/libradius lib/libsbuf lib/libtacplus \
lib/libgeom \
${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
${_cddl_lib_libuutil} \
${_cddl_lib_libavl} \
${_cddl_lib_libzfs_core} \
lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
@ -1542,6 +1545,8 @@ gnu/lib/libstdc++__L: lib/msun__L
gnu/lib/libsupc++__L: gnu/lib/libstdc++__L
.endif
lib/libgeom__L: lib/libexpat__L
.if defined(WITH_ATF) || ${MK_TESTS} != "no"
.if !defined(WITH_ATF)
# Ensure that the ATF libraries will be built during make libraries, even
@ -1579,9 +1584,11 @@ lib/libopie__L lib/libtacplus__L: lib/libmd__L
_cddl_lib_libumem= cddl/lib/libumem
_cddl_lib_libnvpair= cddl/lib/libnvpair
_cddl_lib_libavl= cddl/lib/libavl
_cddl_lib_libuutil= cddl/lib/libuutil
_cddl_lib_libzfs_core= cddl/lib/libzfs_core
_cddl_lib= cddl/lib
cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
cddl/lib/libzfs__L: lib/libgeom__L
.endif
.if ${MK_CRYPT} != "no"

View File

@ -38,6 +38,14 @@
# xargs -n1 | sort | uniq -d;
# done
# 20140922: sleepq_calc_signal_retval.9 and sleepq_catch_signals.9 removed
OLD_FILES+=usr/share/man/man9/sleepq_calc_signal_retval.9.gz
OLD_FILES+=usr/share/man/man9/sleepq_catch_signals.9.gz
# 20140917: hv_kvpd rc.d script removed in favor of devd configuration
OLD_FILES+=etc/rc.d/hv_kvpd
# 20140917: libnv was accidentally being installed to /usr/lib instead of /lib
OLD_LIBS+=usr/lib/libnv.a
OLD_LIBS+=usr/lib/libnv.so.0
# 20140814: libopie version bump
OLD_LIBS+=usr/lib/libopie.so.7
OLD_LIBS+=usr/lib32/libopie.so.7
@ -1488,6 +1496,7 @@ OLD_LIBS+=usr/lib/libpanel.so.4
OLD_LIBS+=usr/lib/libpanelw.so.4
OLD_LIBS+=usr/lib/libpmc.so.4
OLD_LIBS+=usr/lib/libproc.so.1
OLD_LIBS+=usr/lib/libproc.so.2
OLD_LIBS+=usr/lib/libradius.so.3
OLD_LIBS+=usr/lib/librpcsvc.so.4
OLD_LIBS+=usr/lib/libsdp.so.3

View File

@ -31,6 +31,18 @@ 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".)
20140923:
pjdfstest has been moved from tools/regression/pjdfstest to
contrib/pjdfstest .
20140922:
At svn r271982, The default linux compat kernel ABI has been adjusted
to 2.6.18 in support of the linux-c6 compat ports infrastructure
update. If you wish to continue using the linux-f10 compat ports,
add compat.linux.osrelease=2.6.16 to your local sysctl.conf. Users are
encouraged to update their linux-compat packages to linux-c6 during
their next update cycle.
20140729:
The ofwfb driver, used to provide a graphics console on PowerPC when
using vt(4), no longer allows mmap() of all of physical memory. This

View File

@ -94,7 +94,7 @@ GENHDRS+= iconv.h
SRCS+= iconv_stub.c
iconv.h: ${.CURDIR}/iconv_stub.h
cp ${.CURDIR}/iconv_stub.h ${.TARGET}
cp -f ${.CURDIR}/iconv_stub.h ${.TARGET}
.endif
.endif

View File

@ -1,7 +1,23 @@
#!/bin/sh
# $FreeBSD$
base=`basename $0`
jail_name_to_jid()
{
local check_name="$1"
(
line="$(jls -n 2> /dev/null | grep name=$check_name )"
for nv in $line; do
local name="${nv%=*}"
if [ "${name}" = "jid" ]; then
eval $nv
echo $jid
break
fi
done
)
}
base=pgrep_j_test
echo "1..3"
@ -9,21 +25,25 @@ name="pgrep -j <jid>"
if [ `id -u` -eq 0 ]; then
sleep=$(pwd)/sleep.txt
ln -sf /bin/sleep $sleep
jail / $base-1 127.0.0.1 $sleep 5 &
chpid=$!
jail / $base-2 127.0.0.1 $sleep 5 &
chpid2=$!
$sleep 5 &
chpid3=$!
sleep 0.5
jid=`jls | awk "/127\\.0\\.0\\.1.*${base}-1/ {print \$1}"`
pid=`pgrep -f -j $jid $sleep`
if [ "$pid" = "$chpid" ]; then
jail -c path=/ name=${base}_1_1 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_1_1.pid $sleep 5 &
jail -c path=/ name=${base}_1_2 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_1_2.pid $sleep 5 &
jid1=$(jail_name_to_jid ${base}_1_1)
jid2=$(jail_name_to_jid ${base}_1_2)
jid="${jid1},${jid2}"
pid1="$(pgrep -f -x -j $jid "$sleep 5" | sort)"
pid2=$(printf "%s\n%s" "$(cat ${PWD}/${base}_1_1.pid)" \
$(cat ${PWD}/${base}_1_2.pid) | sort)
if [ "$pid1" = "$pid2" ]; then
echo "ok 1 - $name"
else
echo "not ok 1 - $name"
fi
kill $chpid $chpid2 $chpid3
[ -f ${PWD}/${base}_1_1.pid ] && kill $(cat ${PWD}/${base}_1_1.pid)
[ -f ${PWD}/${base}_1_2.pid ] && kill $(cat ${PWD}/${base}_1_2.pid)
rm -f $sleep
else
echo "ok 1 - $name # skip Test needs uid 0."
@ -33,21 +53,23 @@ name="pgrep -j any"
if [ `id -u` -eq 0 ]; then
sleep=$(pwd)/sleep.txt
ln -sf /bin/sleep $sleep
jail / $base-1 127.0.0.1 $sleep 5 &
chpid=$!
jail / $base-2 127.0.0.1 $sleep 5 &
chpid2=$!
$sleep 5 &
chpid3=$!
sleep 0.5
pids=`pgrep -f -j any $sleep | sort`
refpids=`{ echo $chpid; echo $chpid2; } | sort`
if [ "$pids" = "$refpids" ]; then
jail -c path=/ name=${base}_2_1 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_2_1.pid $sleep 5 &
jail -c path=/ name=${base}_2_2 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_2_2.pid $sleep 5 &
sleep 2
pid1="$(pgrep -f -x -j any "$sleep 5" | sort)"
pid2=$(printf "%s\n%s" "$(cat ${PWD}/${base}_2_1.pid)" \
$(cat ${PWD}/${base}_2_2.pid) | sort)
if [ "$pid1" = "$pid2" ]; then
echo "ok 2 - $name"
else
echo "not ok 2 - $name"
fi
kill $chpid $chpid2 $chpid3
[ -f ${PWD}/${base}_2_1.pid ] && kill $(cat ${PWD}/${base}_2_1.pid)
[ -f ${PWD}/${base}_2_2.pid ] && kill $(cat ${PWD}/${base}_2_2.pid)
rm -f $sleep
else
echo "ok 2 - $name # skip Test needs uid 0."
@ -57,19 +79,19 @@ name="pgrep -j none"
if [ `id -u` -eq 0 ]; then
sleep=$(pwd)/sleep.txt
ln -sf /bin/sleep $sleep
$sleep 5 &
chpid=$!
jail / $base 127.0.0.1 $sleep 5 &
chpid2=$!
sleep 0.5
pid=`pgrep -f -j none $sleep`
if [ "$pid" = "$chpid" ]; then
daemon -p ${PWD}/${base}_3_1.pid $sleep 5 &
jail -c path=/ name=${base}_3_2 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_3_2.pid $sleep 5 &
sleep 2
pid="$(pgrep -f -x -j none "$sleep 5")"
if [ "$pid" = "$(cat ${PWD}/${base}_3_1.pid)" ]; then
echo "ok 3 - $name"
else
echo "not ok 3 - $name"
fi
kill $chpid $chpid2
rm -f $sleep
[ -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)
else
echo "ok 3 - $name # skip Test needs uid 0."
fi

View File

@ -1,7 +1,23 @@
#!/bin/sh
# $FreeBSD$
base=`basename $0`
jail_name_to_jid()
{
local check_name="$1"
(
line="$(jls -n 2> /dev/null | grep name=$check_name )"
for nv in $line; do
local name="${nv%=*}"
if [ "${name}" = "jid" ]; then
eval $nv
echo $jid
break
fi
done
)
}
base=pkill_j_test
echo "1..3"
@ -9,21 +25,28 @@ name="pkill -j <jid>"
if [ `id -u` -eq 0 ]; then
sleep=$(pwd)/sleep.txt
ln -sf /bin/sleep $sleep
jail / $base-1 127.0.0.1 $sleep 5 &
chpid=$!
jail / $base-2 127.0.0.1 $sleep 5 &
chpid2=$!
jail -c path=/ name=${base}_1_1 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_1_1.pid $sleep 5 &
jail -c path=/ name=${base}_1_2 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_1_2.pid $sleep 5 &
$sleep 5 &
chpid3=$!
sleep 0.5
jid=`jls | awk "/127\\.0\\.0\\.1.*${base}-1/ {print \$1}"`
if pkill -f -j $jid $sleep && sleep 0.5 &&
! kill $chpid && kill $chpid2 $chpid3; then
jid1=$(jail_name_to_jid ${base}_1_1)
jid2=$(jail_name_to_jid ${base}_1_2)
jid="${jid1},${jid2}"
if pkill -f -j "$jid" $sleep && sleep 0.5 &&
! -f ${PWD}/${base}_1_1.pid &&
! -f ${PWD}/${base}_1_2.pid ; then
echo "ok 1 - $name"
else
echo "not ok 1 - $name"
fi 2>/dev/null
rm -f $sleep
[ -f ${PWD}/${base}_1_1.pid ] && kill $(cat ${PWD}/${base}_1_1.pid)
[ -f ${PWD}/${base}_1_2.pid ] && kill $(cat ${PWD}/${base}_1_2.pid)
wait
else
echo "ok 1 - $name # skip Test needs uid 0."
fi
@ -32,20 +55,26 @@ name="pkill -j any"
if [ `id -u` -eq 0 ]; then
sleep=$(pwd)/sleep.txt
ln -sf /bin/sleep $sleep
jail / $base-1 127.0.0.1 $sleep 5 &
chpid=$!
jail / $base-2 127.0.0.1 $sleep 5 &
chpid2=$!
jail -c path=/ name=${base}_2_1 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_2_1.pid $sleep 5 &
jail -c path=/ name=${base}_2_2 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_2_2.pid $sleep 5 &
$sleep 5 &
chpid3=$!
sleep 0.5
chpid3=$!
if pkill -f -j any $sleep && sleep 0.5 &&
! kill $chpid && ! kill $chpid2 && kill $chpid3; then
[ ! -f ${PWD}/${base}_2_1.pid -a
! -f ${PWD}/${base}_2_2.pid ] && kill $chpid3; then
echo "ok 2 - $name"
else
echo "not ok 2 - $name"
fi 2>/dev/null
rm -f $sleep
[ -f ${PWD}/${base}_2_1.pid ] && kill $(cat ${PWD}/${base}_2_1.pid)
[ -f ${PWD}/${base}_2_2.pid ] && kill $(cat ${PWD}/${base}_2_2.pid)
wait
else
echo "ok 2 - $name # skip Test needs uid 0."
fi
@ -54,18 +83,20 @@ name="pkill -j none"
if [ `id -u` -eq 0 ]; then
sleep=$(pwd)/sleep.txt
ln -sf /bin/sleep $sleep
$sleep 5 &
chpid=$!
jail / $base 127.0.0.1 $sleep 5 &
chpid2=$!
sleep 0.5
if pkill -f -j none $sleep && sleep 0.5 &&
! kill $chpid && kill $chpid2; then
daemon -p ${PWD}/${base}_3_1.pid $sleep 5
jail -c path=/ name=${base}_3_2 ip4.addr=127.0.0.1 \
command=daemon -p ${PWD}/${base}_3_2.pid $sleep 5 &
sleep 1
if pkill -f -j none "$sleep 5" && sleep 1 &&
[ ! -f ${PWD}/${base}_3_1.pid -a -f ${PWD}/${base}_3_2.pid ] ; then
echo "ok 3 - $name"
else
ls ${PWD}/*.pid
echo "not ok 3 - $name"
fi 2>/dev/null
rm -f $sleep
[ -f ${PWD}/${base}_3_1.pid ] && kill $(cat ${base}_3_1.pid)
[ -f ${PWD}/${base}_3_2.pid ] && kill $(cat ${base}_3_2.pid)
else
echo "ok 3 - $name # skip Test needs uid 0."
fi

View File

@ -116,33 +116,6 @@ resetinput(void)
}
/*
* Read a line from the script.
*/
char *
pfgets(char *line, int len)
{
char *p = line;
int nleft = len;
int c;
while (--nleft > 0) {
c = pgetc_macro();
if (c == PEOF) {
if (p == line)
return NULL;
break;
}
*p++ = c;
if (c == '\n')
break;
}
*p = '\0';
return line;
}
/*
* Read a character from the script, returning PEOF on end of file.
@ -338,7 +311,7 @@ pungetc(void)
* We handle aliases this way.
*/
void
pushstring(char *s, int len, struct alias *ap)
pushstring(const char *s, int len, struct alias *ap)
{
struct strpush *sp;

View File

@ -48,12 +48,11 @@ struct alias;
struct parsefile;
void resetinput(void);
char *pfgets(char *, int);
int pgetc(void);
int preadbuffer(void);
int preadateof(void);
void pungetc(void);
void pushstring(char *, int, struct alias *);
void pushstring(const char *, int, struct alias *);
void setinputfile(const char *, int);
void setinputfd(int, int);
void setinputstring(const char *, int);

View File

@ -66,7 +66,6 @@ __FBSDID("$FreeBSD$");
* Shell command parser.
*/
#define EOFMARKLEN 79
#define PROMPTLEN 128
/* values of checkkwd variable */
@ -718,7 +717,6 @@ parsefname(void)
if (n->type == NHERE) {
struct heredoc *here = heredoc;
struct heredoc *p;
int i;
if (quoteflag == 0)
n->type = NXHERE;
@ -727,7 +725,7 @@ parsefname(void)
while (*wordtext == '\t')
wordtext++;
}
if (! noexpand(wordtext) || (i = strlen(wordtext)) == 0 || i > EOFMARKLEN)
if (! noexpand(wordtext))
synerror("Illegal eof marker for << redirection");
rmescapes(wordtext);
here->eofmark = wordtext;
@ -945,6 +943,41 @@ struct tokenstate
};
/*
* Check to see whether we are at the end of the here document. When this
* is called, c is set to the first character of the next input line. If
* we are at the end of the here document, this routine sets the c to PEOF.
* The new value of c is returned.
*/
static int
checkend(int c, const char *eofmark, int striptabs)
{
if (striptabs) {
while (c == '\t')
c = pgetc();
}
if (c == *eofmark) {
int c2;
const char *q;
for (q = eofmark + 1; c2 = pgetc(), *q != '\0' && c2 == *q; q++)
;
if ((c2 == PEOF || c2 == '\n') && *q == '\0') {
c = PEOF;
if (c2 == '\n') {
plinno++;
needprompt = doprompt;
}
} else {
pungetc();
pushstring(eofmark + 1, q - (eofmark + 1), NULL);
}
}
return (c);
}
/*
* Called to parse command substitutions.
*/
@ -1246,6 +1279,13 @@ readcstyleesc(char *out)
c = pgetc();
if (c == PEOF)
synerror("Unterminated quoted string");
if (c == '\n') {
plinno++;
if (doprompt)
setprompt(2);
else
setprompt(0);
}
}
pungetc();
return out;
@ -1269,7 +1309,6 @@ readcstyleesc(char *out)
* will run code that appears at the end of readtoken1.
*/
#define CHECKEND() {goto checkend; checkend_return:;}
#define PARSEREDIR() {goto parseredir; parseredir_return:;}
#define PARSESUB() {goto parsesub; parsesub_return:;}
#define PARSEARITH() {goto parsearith; parsearith_return:;}
@ -1281,7 +1320,6 @@ readtoken1(int firstc, char const *initialsyntax, const char *eofmark,
int c = firstc;
char *out;
int len;
char line[EOFMARKLEN + 1];
struct nodelist *bqlist;
int quotef;
int newvarnest;
@ -1303,7 +1341,9 @@ readtoken1(int firstc, char const *initialsyntax, const char *eofmark,
STARTSTACKSTR(out);
loop: { /* for each line, until end of word */
CHECKEND(); /* set c to PEOF if at end of here document */
if (eofmark)
/* set c to PEOF if at end of here document */
c = checkend(c, eofmark, striptabs);
for (;;) { /* until end of line or end of word */
CHECKSTRSPACE(4, out); /* permit 4 calls to USTPUTC */
@ -1483,40 +1523,6 @@ readtoken1(int firstc, char const *initialsyntax, const char *eofmark,
/* end of readtoken routine */
/*
* Check to see whether we are at the end of the here document. When this
* is called, c is set to the first character of the next input line. If
* we are at the end of the here document, this routine sets the c to PEOF.
*/
checkend: {
if (eofmark) {
if (striptabs) {
while (c == '\t')
c = pgetc();
}
if (c == *eofmark) {
if (pfgets(line, sizeof line) != NULL) {
const char *p, *q;
p = line;
for (q = eofmark + 1 ; *q && *p == *q ; p++, q++);
if ((*p == '\0' || *p == '\n') && *q == '\0') {
c = PEOF;
if (*p == '\n') {
plinno++;
needprompt = doprompt;
}
} else {
pushstring(line, strlen(line), NULL);
}
}
}
}
goto checkend_return;
}
/*
* Parse a redirection operator. The variable "out" points to a string
* specifying the fd to be redirected. The variable "c" contains the
@ -1915,7 +1921,7 @@ char *
getprompt(void *unused __unused)
{
static char ps[PROMPTLEN];
char *fmt;
const char *fmt;
const char *pwd;
int i, trim;
static char internal_error[] = "??";
@ -2029,7 +2035,7 @@ expandstr(const char *ps)
parser_temp = NULL;
setinputstring(ps, 1);
doprompt = 0;
readtoken1(pgetc(), DQSYNTAX, "\n\n", 0);
readtoken1(pgetc(), DQSYNTAX, "", 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 September 4, 2014
.Dd September 21, 2014
.Dt SH 1
.Os
.Sh NAME
@ -590,7 +590,8 @@ the following actions:
Leading words of the form
.Dq Li name=value
are stripped off and assigned to the environment of
the simple command.
the simple command
(they do not affect expansions).
Redirection operators and
their arguments (as described below) are stripped
off and saved for processing.

View File

@ -100,6 +100,7 @@ FILES+= jobid2.0
FILES+= kill1.0 kill2.0
FILES+= lineno.0 lineno.0.stdout
FILES+= lineno2.0
FILES+= lineno3.0 lineno3.0.stdout
FILES+= local1.0
FILES+= local2.0
FILES+= local3.0

View File

@ -0,0 +1,6 @@
# $FreeBSD$
echo before: $LINENO
dummy=$'a\0
'
echo after: $LINENO

View File

@ -0,0 +1,2 @@
before: 3
after: 6

View File

@ -54,6 +54,7 @@ FILES+= heredoc8.0
FILES+= heredoc9.0
FILES+= heredoc10.0
FILES+= heredoc11.0
FILES+= heredoc12.0
FILES+= no-space1.0
FILES+= no-space2.0
FILES+= only-redir1.0

View File

@ -0,0 +1,47 @@
# $FreeBSD$
failures=0
check() {
if ! eval "[ $* ]"; then
echo "Failed: $*"
: $((failures += 1))
fi
}
longmark=`printf %01000d 4`
longmarkstripped=`printf %0999d 0`
check '"$(cat <<'"$longmark
$longmark"'
echo yes)" = "yes"'
check '"$(cat <<\'"$longmark
$longmark"'
echo yes)" = "yes"'
check '"$(cat <<'"$longmark
yes
$longmark"'
)" = "yes"'
check '"$(cat <<\'"$longmark
yes
$longmark"'
)" = "yes"'
check '"$(cat <<'"$longmark
$longmarkstripped
$longmark.
$longmark"'
)" = "'"$longmarkstripped
$longmark."'"'
check '"$(cat <<\'"$longmark
$longmarkstripped
$longmark.
$longmark"'
)" = "'"$longmarkstripped
$longmark."'"'
exit $((failures != 0))

View File

@ -277,6 +277,19 @@ Generate a header file containing macros that correspond to probes in the
specified provider definitions.
This option should be used to generate a header file that is included by other
source files for later use with the
.Fl G
option.
If the
.Fl o
option is present, the header file is saved using the pathname specified as the
argument for that option.
If the
.Fl o
option is not present and the DTrace program is contained within a file whose
name is
.Ar filename.d ,
then the header file is saved using the name
.Ar filename.h .
.It Fl H
Print the pathnames of included files when invoking
.Xr cpp 1
@ -289,20 +302,6 @@ option to each
.Xr cpp 1
invocation, causing it to display the list of pathnames, one for each line, to
standard error.
.Fl G
option.
If the
.Fl o
option
is present, the header file is saved using the pathname specified as the
argument for that option.
If the
.Fl o
option is not present and the DTrace program is contained with a file whose
name is
.Ar filename.d ,
then the header file is saved using the name
.Ar filename.h .
.It Fl i Ar probe-id Op Oo Ar predicate Oc Ar action
Specify probe identifier
.Ar ( probe-id )

View File

@ -710,6 +710,9 @@ list_probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *arg)
if (g_verbose && dtrace_probe_info(dtp, pdp, &p) == 0)
print_probe_info(&p);
if (g_intr != 0)
return (1);
return (0);
}
@ -1220,11 +1223,34 @@ intr(int signo)
g_impatient = 1;
}
static void
installsighands(void)
{
struct sigaction act, oact;
(void) sigemptyset(&act.sa_mask);
act.sa_flags = 0;
act.sa_handler = intr;
if (sigaction(SIGINT, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
(void) sigaction(SIGINT, &act, NULL);
if (sigaction(SIGTERM, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
(void) sigaction(SIGTERM, &act, NULL);
#if !defined(sun)
if (sigaction(SIGPIPE, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
(void) sigaction(SIGPIPE, &act, NULL);
if (sigaction(SIGUSR1, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
(void) sigaction(SIGUSR1, &act, NULL);
#endif
}
int
main(int argc, char *argv[])
{
dtrace_bufdesc_t buf;
struct sigaction act, oact;
dtrace_status_t status[2];
dtrace_optval_t opt;
dtrace_cmd_t *dcp;
@ -1776,6 +1802,8 @@ main(int argc, char *argv[])
if (g_ofile != NULL && (g_ofp = fopen(g_ofile, "a")) == NULL)
fatal("failed to open output file '%s'", g_ofile);
installsighands();
oprintf("%5s %10s %17s %33s %s\n",
"ID", "PROVIDER", "MODULE", "FUNCTION", "NAME");
@ -1861,20 +1889,7 @@ main(int argc, char *argv[])
if (opt != DTRACEOPT_UNSET)
notice("allowing destructive actions\n");
(void) sigemptyset(&act.sa_mask);
act.sa_flags = 0;
act.sa_handler = intr;
if (sigaction(SIGINT, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
(void) sigaction(SIGINT, &act, NULL);
if (sigaction(SIGTERM, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
(void) sigaction(SIGTERM, &act, NULL);
#if !defined(sun)
if (sigaction(SIGUSR1, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
(void) sigaction(SIGUSR1, &act, NULL);
#endif
installsighands();
/*
* Now that tracing is active and we are ready to consume trace data,

View File

@ -34,14 +34,14 @@
* leading underscores.
*/
#pragma weak _go = go
static int
go(int a)
{
return (a + 1);
}
#pragma weak _go = go
static void
handle(int sig)
{

View File

@ -29,6 +29,7 @@ dtrace=$1
t="season_8_mountain_of_madness_t"
pid=$$
rc=`$dtrace -n "BEGIN{ trace(pid$pid`$t)0); }"`
$dtrace -n "BEGIN{ trace(pid$pid\`$t)0); }"
rc=$?
exit $rc

View File

@ -30,6 +30,7 @@ dtrace=$1
t="season_8_mountain_of_madness_t"
pid=$$
rc=`$dtrace -n "BEGIN{ trace(pid`$t)0); }"` -p $pid
$dtrace -n "BEGIN{ trace(pid$pid\`$t)0); }" -p $pid
rc=$?
exit $rc

View File

@ -31,7 +31,7 @@ dtrace=$1
t="zelda_info_t"
exe="tst.chasestrings.exe"
elfdump "./$exe" | grep -q '.SUNW_ctf'
elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
if [[ $? -ne 0 ]]; then
echo "CTF does not exist in $exe, that's a bug" >&2
exit 1

View File

@ -25,10 +25,10 @@ if [ $# != 1 ]; then
fi
dtrace=$1
t="season_7_lisa_the_vegetrian_t *"
t="season_7_lisa_the_vegetarian_t *"
exe="tst.aouttype.exe"
elfdump "./$exe" | grep -q '.SUNW_ctf'
elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
if [[ $? -ne 0 ]]; then
echo "CTF does not exist in $exe, that's a bug" >&2
exit 1
@ -37,7 +37,8 @@ fi
./$exe &
pid=$!
rc=`$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }"`
$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }"
rc=$?
kill -9 $pid

View File

@ -29,7 +29,7 @@ dtrace=$1
t="zelda_info_t"
exe="tst.chasestrings.exe"
elfdump "./$exe" | grep -q '.SUNW_ctf'
elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
if [[ $? -ne 0 ]]; then
echo "CTF does not exist in $exe, that's a bug" >&2
exit 1

View File

@ -29,7 +29,7 @@ dtrace=$1
t="int"
exe="tst.libtype.exe"
elfdump "./$exe" | grep -q '.SUNW_ctf'
elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
if [[ $? -eq 0 ]]; then
echo "CTF exists in $exe, that's a bug" >&2
exit 1
@ -38,7 +38,8 @@ fi
./$exe &
pid=$!
rc=`$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }"`
$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }"
rc=$?
kill -9 $pid

View File

@ -28,7 +28,7 @@ dtrace=$1
t="final_fantasy_info_t"
exe="tst.printtype.exe"
elfdump "./$exe" | grep -q '.SUNW_ctf'
elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
if [[ $? -ne 0 ]]; then
echo "CTF does not exist in $exe, that's a bug" >&2
exit 1

View File

@ -29,7 +29,7 @@ dtrace=$1
t="final_fantasy_info_t"
exe="tst.printtype.exe"
elfdump "./$exe" | grep -q '.SUNW_ctf'
elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
if [[ $? -ne 0 ]]; then
echo "CTF does not exist in $exe, that's a bug" >&2
exit 1

View File

@ -28,7 +28,7 @@ dtrace=$1
t="final_fantasy_info_t"
exe="tst.printtype.exe"
elfdump "./$exe" | grep -q '.SUNW_ctf'
elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
if [[ $? -ne 0 ]]; then
echo "CTF does not exist in $exe, that's a bug" >&2
exit 1

View File

@ -29,7 +29,7 @@ dtrace=$1
t="final_fantasy_info_t"
exe="tst.printtype.exe"
elfdump "./$exe" | grep -q '.SUNW_ctf'
elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
if [[ $? -ne 0 ]]; then
echo "CTF does not exist in $exe, that's a bug" >&2
exit 1

View File

@ -29,7 +29,7 @@ dtrace=$1
t="zelda_info_t"
exe="tst.chasestrings.exe"
elfdump "./$exe" | grep -q '.SUNW_ctf'
elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
if [[ $? -ne 0 ]]; then
echo "CTF does not exist in $exe, that's a bug" >&2
exit 1
@ -38,7 +38,7 @@ fi
./$exe &
pid=$!
$dtrace -32 -qs /dev/stdin <<EOF
$dtrace -qs /dev/stdin <<EOF
typedef struct info {
char *zi_gamename;
int zi_ndungeons;

View File

@ -28,7 +28,7 @@ fi
dtrace=$1
exe="tst.chasestrings.exe"
elfdump "./$exe" | grep -q '.SUNW_ctf'
elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf'
if [[ $? -ne 0 ]]; then
echo "CTF does not exist in $exe, that's a bug" >&2
exit 1

View File

@ -414,7 +414,7 @@ or smaller can take advantage of this feature.
When this feature is enabled, the contents of highly-compressible blocks are
stored in the block "pointer" itself
.Po a misnomer in this case, as it contains
the compresseed data, rather than a pointer to its location on disk
the compressed data, rather than a pointer to its location on disk
.Pc .
Thus
the space of the block

View File

@ -2857,10 +2857,7 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb)
right_justify = B_FALSE;
if (pl->pl_prop != ZPROP_INVAL) {
if (pl->pl_prop == ZPOOL_PROP_EXPANDSZ &&
zpool_get_prop_int(zhp, pl->pl_prop, NULL) == 0)
propstr = "-";
else if (zpool_get_prop(zhp, pl->pl_prop, property,
if (zpool_get_prop(zhp, pl->pl_prop, property,
sizeof (property), NULL, cb->cb_literal) != 0)
propstr = "-";
else
@ -2894,21 +2891,37 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb)
}
static void
print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted)
print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted,
boolean_t valid)
{
char propval[64];
boolean_t fixed;
size_t width = zprop_width(prop, &fixed, ZFS_TYPE_POOL);
if (prop == ZPOOL_PROP_EXPANDSZ && value == 0)
(void) strlcpy(propval, "-", sizeof (propval));
else if (prop == ZPOOL_PROP_FRAGMENTATION && value == ZFS_FRAG_INVALID)
(void) strlcpy(propval, "-", sizeof (propval));
else if (prop == ZPOOL_PROP_FRAGMENTATION)
switch (prop) {
case ZPOOL_PROP_EXPANDSZ:
if (value == 0)
(void) strlcpy(propval, "-", sizeof (propval));
else
zfs_nicenum(value, propval, sizeof (propval));
break;
case ZPOOL_PROP_FRAGMENTATION:
if (value == ZFS_FRAG_INVALID) {
(void) strlcpy(propval, "-", sizeof (propval));
} else {
(void) snprintf(propval, sizeof (propval), "%llu%%",
value);
}
break;
case ZPOOL_PROP_CAPACITY:
(void) snprintf(propval, sizeof (propval), "%llu%%", value);
else
break;
default:
zfs_nicenum(value, propval, sizeof (propval));
}
if (!valid)
(void) strlcpy(propval, "-", sizeof (propval));
if (scripted)
(void) printf("\t%s", propval);
@ -2930,6 +2943,9 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
(uint64_t **)&vs, &c) == 0);
if (name != NULL) {
boolean_t toplevel = (vs->vs_space != 0);
uint64_t cap;
if (scripted)
(void) printf("\t%s", name);
else if (strlen(name) + depth > cb->cb_namewidth)
@ -2938,24 +2954,26 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
(void) printf("%*s%s%*s", depth, "", name,
(int)(cb->cb_namewidth - strlen(name) - depth), "");
/* only toplevel vdevs have capacity stats */
if (vs->vs_space == 0) {
if (scripted)
(void) printf("\t-\t-\t-\t-");
else
(void) printf(" - - - -");
} else {
print_one_column(ZPOOL_PROP_SIZE, vs->vs_space,
scripted);
print_one_column(ZPOOL_PROP_CAPACITY, vs->vs_alloc,
scripted);
print_one_column(ZPOOL_PROP_FREE,
vs->vs_space - vs->vs_alloc, scripted);
print_one_column(ZPOOL_PROP_FRAGMENTATION,
vs->vs_fragmentation, scripted);
}
print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize,
scripted);
/*
* Print the properties for the individual vdevs. Some
* properties are only applicable to toplevel vdevs. The
* 'toplevel' boolean value is passed to the print_one_column()
* to indicate that the value is valid.
*/
print_one_column(ZPOOL_PROP_SIZE, vs->vs_space, scripted,
toplevel);
print_one_column(ZPOOL_PROP_ALLOCATED, vs->vs_alloc, scripted,
toplevel);
print_one_column(ZPOOL_PROP_FREE, vs->vs_space - vs->vs_alloc,
scripted, toplevel);
print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, scripted,
B_TRUE);
print_one_column(ZPOOL_PROP_FRAGMENTATION,
vs->vs_fragmentation, scripted,
(vs->vs_fragmentation != ZFS_FRAG_INVALID && toplevel));
cap = (vs->vs_space == 0) ? 0 :
(vs->vs_alloc * 100 / vs->vs_space);
print_one_column(ZPOOL_PROP_CAPACITY, cap, scripted, toplevel);
(void) printf("\n");
}
@ -3024,7 +3042,8 @@ list_callback(zpool_handle_t *zhp, void *data)
* -H Scripted mode. Don't display headers, and separate properties
* by a single tab.
* -o List of properties to display. Defaults to
* "name,size,allocated,free,capacity,health,altroot"
* "name,size,allocated,free,expandsize,fragmentation,capacity,"
* "dedupratio,health,altroot"
* -p Diplay values in parsable (exact) format.
* -T Display a timestamp in date(1) or Unix format
*
@ -3038,7 +3057,7 @@ zpool_do_list(int argc, char **argv)
int ret;
list_cbdata_t cb = { 0 };
static char default_props[] =
"name,size,allocated,free,fragmentation,expandsize,capacity,"
"name,size,allocated,free,expandsize,fragmentation,capacity,"
"dedupratio,health,altroot";
char *props = default_props;
unsigned long interval = 0, count = 0;
@ -4524,7 +4543,8 @@ is_root_pool(zpool_handle_t *zhp)
}
static void
root_pool_upgrade_check(zpool_handle_t *zhp, char *poolname, int size) {
root_pool_upgrade_check(zpool_handle_t *zhp, char *poolname, int size)
{
if (poolname[0] == '\0' && is_root_pool(zhp))
(void) strlcpy(poolname, zpool_get_name(zhp), size);
@ -4623,7 +4643,7 @@ upgrade_cb(zpool_handle_t *zhp, void *arg)
#ifdef __FreeBSD__
root_pool_upgrade_check(zhp, cbp->cb_poolname,
sizeof(cbp->cb_poolname));
#endif /* ___FreeBSD__ */
#endif /* __FreeBSD__ */
printnl = B_TRUE;
#ifdef illumos
@ -4647,6 +4667,10 @@ upgrade_cb(zpool_handle_t *zhp, void *arg)
if (count > 0) {
cbp->cb_first = B_FALSE;
printnl = B_TRUE;
#ifdef __FreeBSD__
root_pool_upgrade_check(zhp, cbp->cb_poolname,
sizeof(cbp->cb_poolname));
#endif /* __FreeBSD__ */
/*
* If they did "zpool upgrade -a", then we could
* be doing ioctls to different pools. We need
@ -4788,7 +4812,7 @@ upgrade_one(zpool_handle_t *zhp, void *data)
#ifdef __FreeBSD__
root_pool_upgrade_check(zhp, cbp->cb_poolname,
sizeof(cbp->cb_poolname));
#endif /* ___FreeBSD__ */
#endif /* __FreeBSD__ */
}
if (cbp->cb_version >= SPA_VERSION_FEATURES) {

View File

@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
*/
/*
@ -652,6 +653,7 @@ get_replication(nvlist_t *nvroot, boolean_t fatal)
dontreport = 0;
vdev_size = -1ULL;
for (c = 0; c < children; c++) {
boolean_t is_replacing, is_spare;
nvlist_t *cnv = child[c];
char *path;
struct stat64 statbuf;
@ -668,16 +670,19 @@ get_replication(nvlist_t *nvroot, boolean_t fatal)
* If this is a replacing or spare vdev, then
* get the real first child of the vdev.
*/
if (strcmp(childtype,
VDEV_TYPE_REPLACING) == 0 ||
strcmp(childtype, VDEV_TYPE_SPARE) == 0) {
is_replacing = strcmp(childtype,
VDEV_TYPE_REPLACING) == 0;
is_spare = strcmp(childtype,
VDEV_TYPE_SPARE) == 0;
if (is_replacing || is_spare) {
nvlist_t **rchild;
uint_t rchildren;
verify(nvlist_lookup_nvlist_array(cnv,
ZPOOL_CONFIG_CHILDREN, &rchild,
&rchildren) == 0);
assert(rchildren == 2);
assert((is_replacing && rchildren == 2)
|| (is_spare && rchildren >= 2));
cnv = rchild[0];
verify(nvlist_lookup_string(cnv,
@ -1068,8 +1073,8 @@ is_spare(nvlist_t *config, const char *path)
* Go through and find any devices that are in use. We rely on libdiskmgt for
* the majority of this task.
*/
static int
check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force,
static boolean_t
is_device_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force,
boolean_t replacing, boolean_t isspare)
{
nvlist_t **child;
@ -1078,6 +1083,7 @@ check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force,
int ret;
char buf[MAXPATHLEN];
uint64_t wholedisk;
boolean_t anyinuse = B_FALSE;
verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) == 0);
@ -1102,38 +1108,37 @@ check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force,
(void) strlcpy(buf, path, sizeof (buf));
if (is_spare(config, buf))
return (0);
return (B_FALSE);
}
if (strcmp(type, VDEV_TYPE_DISK) == 0)
ret = check_device(path, force, isspare);
if (strcmp(type, VDEV_TYPE_FILE) == 0)
else if (strcmp(type, VDEV_TYPE_FILE) == 0)
ret = check_file(path, force, isspare);
return (ret);
return (ret != 0);
}
for (c = 0; c < children; c++)
if ((ret = check_in_use(config, child[c], force,
replacing, B_FALSE)) != 0)
return (ret);
if (is_device_in_use(config, child[c], force, replacing,
B_FALSE))
anyinuse = B_TRUE;
if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_SPARES,
&child, &children) == 0)
for (c = 0; c < children; c++)
if ((ret = check_in_use(config, child[c], force,
replacing, B_TRUE)) != 0)
return (ret);
if (is_device_in_use(config, child[c], force, replacing,
B_TRUE))
anyinuse = B_TRUE;
if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_L2CACHE,
&child, &children) == 0)
for (c = 0; c < children; c++)
if ((ret = check_in_use(config, child[c], force,
replacing, B_FALSE)) != 0)
return (ret);
if (is_device_in_use(config, child[c], force, replacing,
B_FALSE))
anyinuse = B_TRUE;
return (0);
return (anyinuse);
}
static const char *
@ -1487,7 +1492,7 @@ make_root_vdev(zpool_handle_t *zhp, int force, int check_rep,
* uses (such as a dedicated dump device) that even '-f' cannot
* override.
*/
if (check_in_use(poolconfig, newroot, force, replacing, B_FALSE) != 0) {
if (is_device_in_use(poolconfig, newroot, force, replacing, B_FALSE)) {
nvlist_free(newroot);
return (NULL);
}

View File

@ -274,7 +274,7 @@ ctf_fdopen(int fd, int *errp)
*/
if (nbytes >= (ssize_t) sizeof (Elf32_Ehdr) &&
bcmp(&hdr.e32.e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) {
#ifdef _BIG_ENDIAN
#if BYTE_ORDER == _BIG_ENDIAN
uchar_t order = ELFDATA2MSB;
#else
uchar_t order = ELFDATA2LSB;

View File

@ -90,36 +90,6 @@ dprintf(int debug, const char *fmt, ...)
va_end(ap);
}
#if !defined(sun)
static void
fixsymbol(Elf *e, Elf_Data *data, size_t idx, int nprobes, char *buf,
dof_sec_t *sec, int *fixedprobes, char *dofstrtab)
{
GElf_Sym sym;
char *s;
unsigned char *funcname;
dof_probe_t *prb;
int j = 0;
int ndx;
while (gelf_getsym(data, j++, &sym) != NULL) {
prb = (dof_probe_t *)(void *)(buf + sec->dofs_offset);
for (ndx = nprobes; ndx; ndx--, prb += 1) {
funcname = dofstrtab + prb->dofpr_func;
s = elf_strptr(e, idx, sym.st_name);
if (strcmp(s, funcname) == 0) {
dprintf(1, "fixing %s() symbol\n", s);
prb->dofpr_addr = sym.st_value;
(*fixedprobes)++;
}
}
if (*fixedprobes == nprobes)
break;
}
}
#endif
#if defined(sun)
#pragma init(dtrace_dof_init)
#else
@ -145,24 +115,18 @@ dtrace_dof_init(void)
Lmid_t lmid;
#else
u_long lmid = 0;
dof_sec_t *sec, *secstart, *dofstrtab, *dofprobes;
dof_provider_t *dofprovider;
size_t i;
#endif
int fd;
const char *p;
#if !defined(sun)
Elf *e;
Elf_Scn *scn = NULL;
Elf_Data *symtabdata = NULL, *dynsymdata = NULL, *dofdata = NULL;
Elf_Data *dofdata = NULL;
dof_hdr_t *dof_next = NULL;
GElf_Shdr shdr;
int efd, nprobes;
int efd;
char *s;
char *dofstrtabraw;
size_t shstridx, symtabidx = 0, dynsymidx = 0;
unsigned char *buf;
int fixedprobes;
size_t shstridx;
#endif
if (getenv("DTRACE_DOF_INIT_DISABLE") != NULL)
@ -183,7 +147,6 @@ dtrace_dof_init(void)
}
#endif
if ((modname = strrchr(lmp->l_name, '/')) == NULL)
modname = lmp->l_name;
else
@ -203,15 +166,9 @@ dtrace_dof_init(void)
dof = NULL;
while ((scn = elf_nextscn(e, scn)) != NULL) {
gelf_getshdr(scn, &shdr);
if (shdr.sh_type == SHT_SYMTAB) {
symtabidx = shdr.sh_link;
symtabdata = elf_getdata(scn, NULL);
} else if (shdr.sh_type == SHT_DYNSYM) {
dynsymidx = shdr.sh_link;
dynsymdata = elf_getdata(scn, NULL);
} else if (shdr.sh_type == SHT_PROGBITS) {
if (shdr.sh_type == SHT_SUNW_dof) {
s = elf_strptr(e, shstridx, shdr.sh_name);
if (s && strcmp(s, ".SUNW_dof") == 0) {
if (s != NULL && strcmp(s, ".SUNW_dof") == 0) {
dofdata = elf_getdata(scn, NULL);
dof = dofdata->d_buf;
}
@ -225,7 +182,6 @@ dtrace_dof_init(void)
}
while ((char *) dof < (char *) dofdata->d_buf + dofdata->d_size) {
fixedprobes = 0;
dof_next = (void *) ((char *) dof + dof->dofh_filesz);
#endif
@ -273,76 +229,6 @@ dtrace_dof_init(void)
return;
#endif
}
#if !defined(sun)
/*
* We need to fix the base address of each probe since this wasn't
* done by ld(1). (ld(1) needs to grow support for parsing the
* SUNW_dof section).
*
* The complexity of this is not that great. The first for loop
* iterates over the sections inside the DOF file. There are usually
* 10 sections here. We asume the STRTAB section comes first and the
* PROBES section comes after. Since we are only interested in fixing
* data inside the PROBES section we quit the for loop after processing
* the PROBES section. It's usually the case that the first section
* is the STRTAB section and the second section is the PROBES section,
* so this for loop is not meaningful when doing complexity analysis.
*
* After finding the probes section, we iterate over the symbols
* in the symtab section. When we find a symbol name that matches
* the probe function name, we fix it. If we have fixed all the
* probes, we exit all the loops and we are done.
* The number of probes is given by the variable 'nprobes' and this
* depends entirely on the user, but some optimizations were done.
*
* We are assuming the number of probes is less than the number of
* symbols (libc can have 4k symbols, for example).
*/
secstart = sec = (dof_sec_t *)(dof + 1);
buf = (char *)dof;
for (i = 0; i < dof->dofh_secnum; i++, sec++) {
if (sec->dofs_type != DOF_SECT_PROVIDER)
continue;
dofprovider = (void *) (buf + sec->dofs_offset);
dofstrtab = secstart + dofprovider->dofpv_strtab;
dofprobes = secstart + dofprovider->dofpv_probes;
if (dofstrtab->dofs_type != DOF_SECT_STRTAB) {
fprintf(stderr, "WARNING: expected STRTAB section, but got %d\n",
dofstrtab->dofs_type);
break;
}
if (dofprobes->dofs_type != DOF_SECT_PROBES) {
fprintf(stderr, "WARNING: expected PROBES section, but got %d\n",
dofprobes->dofs_type);
break;
}
dprintf(1, "found provider %p\n", dofprovider);
dofstrtabraw = (char *)(buf + dofstrtab->dofs_offset);
nprobes = dofprobes->dofs_size / dofprobes->dofs_entsize;
fixsymbol(e, symtabdata, symtabidx, nprobes, buf, dofprobes, &fixedprobes,
dofstrtabraw);
if (fixedprobes != nprobes) {
/*
* If we haven't fixed all the probes using the
* symtab section, look inside the dynsym
* section.
*/
fixsymbol(e, dynsymdata, dynsymidx, nprobes, buf, dofprobes,
&fixedprobes, dofstrtabraw);
}
if (fixedprobes != nprobes) {
fprintf(stderr, "WARNING: number of probes "
"fixed does not match the number of "
"defined probes (%d != %d, "
"respectively)\n", fixedprobes, nprobes);
fprintf(stderr, "WARNING: some probes might "
"not fire or your program might crash\n");
}
}
#endif
if ((gen = ioctl(fd, DTRACEHIOC_ADDDOF, &dh)) == -1)
dprintf(1, "DTrace ioctl failed for DOF at %p", dof);
else {

View File

@ -322,7 +322,11 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep)
char *strtab;
int i, j, nrel;
size_t strtabsz = 1;
#if defined(sun)
uint32_t count = 0;
#else
uint64_t count = 0;
#endif
size_t base;
Elf64_Sym *sym;
Elf64_Rela *rel;
@ -418,7 +422,6 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep)
s = &dofs[dofrh->dofr_tgtsec];
for (j = 0; j < nrel; j++) {
#ifdef DOODAD
#if defined(__arm__)
/* XXX */
#elif defined(__mips__)
@ -431,8 +434,13 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep)
#elif defined(__i386) || defined(__amd64)
rel->r_offset = s->dofs_offset +
dofr[j].dofr_offset;
#if defined(sun)
rel->r_info = ELF64_R_INFO(count + dep->de_global,
R_AMD64_64);
#else
rel->r_info = ELF64_R_INFO(count + dep->de_global,
R_X86_64_RELATIVE);
#endif
#elif defined(__sparc)
rel->r_offset = s->dofs_offset +
dofr[j].dofr_offset;
@ -440,7 +448,6 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep)
R_SPARC_64);
#else
#error unknown ISA
#endif
#endif
sym->st_name = base + dofr[j].dofr_name - 1;
@ -704,7 +711,11 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd)
shp = &elf_file.shdr[ESHDR_DOF];
shp->sh_name = 11; /* DTRACE_SHSTRTAB64[11] = ".SUNW_dof" */
#if defined(sun)
shp->sh_flags = SHF_ALLOC;
#else
shp->sh_flags = SHF_WRITE | SHF_ALLOC;
#endif
shp->sh_type = SHT_SUNW_dof;
shp->sh_offset = off;
shp->sh_size = dof->dofh_filesz;
@ -1662,19 +1673,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
{
#if !defined(sun)
char tfile[PATH_MAX];
Elf *e;
Elf_Scn *scn;
Elf_Data *data;
GElf_Shdr shdr;
int efd;
size_t stridx;
unsigned char *buf;
char *s;
int loc;
GElf_Ehdr ehdr;
Elf_Scn *scn0;
GElf_Shdr shdr0;
uint64_t off, rc;
#endif
char drti[PATH_MAX];
dof_hdr_t *dof;
@ -1810,21 +1808,21 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
(void) unlink(file);
#endif
#if defined(sun)
if (dtp->dt_oflags & DTRACE_O_LP64)
status = dump_elf64(dtp, dof, fd);
else
status = dump_elf32(dtp, dof, fd);
#if defined(sun)
if (status != 0 || lseek(fd, 0, SEEK_SET) != 0) {
return (dt_link_error(dtp, NULL, -1, NULL,
"failed to write %s: %s", file, strerror(errno)));
}
#else
/* We don't write the ELF header, just the DOF section */
if (dt_write(dtp, fd, dof, dof->dofh_filesz) < dof->dofh_filesz)
if (status != 0)
return (dt_link_error(dtp, NULL, -1, NULL,
"failed to write %s: %s", tfile, strerror(errno)));
"failed to write %s: %s", tfile,
strerror(dtrace_errno(dtp))));
#endif
if (!dtp->dt_lazyload) {
@ -1846,7 +1844,7 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
(void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, fd, drti);
#else
const char *fmt = "%s -o %s -r %s";
const char *fmt = "%s -o %s -r %s %s";
#if defined(__amd64__)
/*
@ -1868,10 +1866,9 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
len = snprintf(&tmp, 1, fmt, dtp->dt_ld_path, file, tfile,
drti) + 1;
len *= 2;
cmd = alloca(len);
(void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file,
(void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, tfile,
drti);
#endif
if ((status = system(cmd)) == -1) {
@ -1894,85 +1891,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
file, dtp->dt_ld_path, WEXITSTATUS(status));
goto done;
}
#if !defined(sun)
/*
* FreeBSD's ld(1) is not instructed to interpret and add
* correctly the SUNW_dof section present in tfile.
* We use libelf to add this section manually and hope the next
* ld invocation won't remove it.
*/
elf_version(EV_CURRENT);
if ((efd = open(file, O_RDWR, 0)) < 0) {
ret = dt_link_error(dtp, NULL, -1, NULL,
"failed to open file %s: %s",
file, strerror(errno));
goto done;
}
if ((e = elf_begin(efd, ELF_C_RDWR, NULL)) == NULL) {
close(efd);
ret = dt_link_error(dtp, NULL, -1, NULL,
"failed to open elf file: %s",
elf_errmsg(elf_errno()));
goto done;
}
/*
* Add the string '.SUWN_dof' to the shstrtab section.
*/
elf_getshdrstrndx(e, &stridx);
scn = elf_getscn(e, stridx);
gelf_getshdr(scn, &shdr);
data = elf_newdata(scn);
data->d_off = shdr.sh_size;
data->d_buf = ".SUNW_dof";
data->d_size = 10;
data->d_type = ELF_T_BYTE;
loc = shdr.sh_size;
shdr.sh_size += data->d_size;
gelf_update_shdr(scn, &shdr);
/*
* Construct the .SUNW_dof section.
*/
scn = elf_newscn(e);
data = elf_newdata(scn);
buf = mmap(NULL, dof->dofh_filesz, PROT_READ, MAP_SHARED,
fd, 0);
if (buf == MAP_FAILED) {
ret = dt_link_error(dtp, NULL, -1, NULL,
"failed to mmap buffer %s", strerror(errno));
elf_end(e);
close(efd);
goto done;
}
data->d_buf = buf;
data->d_align = 4;
data->d_size = dof->dofh_filesz;
data->d_version = EV_CURRENT;
gelf_getshdr(scn, &shdr);
shdr.sh_name = loc;
shdr.sh_flags = SHF_ALLOC;
/*
* Actually this should be SHT_SUNW_dof, but FreeBSD's ld(1)
* will remove this 'unknown' section when we try to create an
* executable using the object we are modifying, so we stop
* playing by the rules and use SHT_PROGBITS.
* Also, note that our drti has modifications to handle this.
*/
shdr.sh_type = SHT_PROGBITS;
shdr.sh_addralign = 4;
gelf_update_shdr(scn, &shdr);
if (elf_update(e, ELF_C_WRITE) < 0) {
ret = dt_link_error(dtp, NULL, -1, NULL,
"failed to add the SUNW_dof section: %s",
elf_errmsg(elf_errno()));
munmap(buf, dof->dofh_filesz);
elf_end(e);
close(efd);
goto done;
}
munmap(buf, dof->dofh_filesz);
elf_end(e);
close(efd);
#endif
(void) close(fd); /* release temporary file */
} else {
(void) close(fd);

View File

@ -434,15 +434,10 @@ static const prmap_t *
dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P)
{
char m[MAXPATHLEN];
#if defined(sun)
Lmid_t lmid = PR_LMID_EVERY;
#else
Lmid_t lmid = 0;
#endif
const char *obj;
const prmap_t *pmp;
#if defined(sun)
/*
* Pick apart the link map from the library name.
*/
@ -463,20 +458,17 @@ dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P)
} else {
obj = pdp->dtpd_mod;
}
#else
obj = pdp->dtpd_mod;
#endif
if ((pmp = Plmid_to_map(P, lmid, obj)) == NULL)
return (NULL);
#if defined(sun)
(void) Pobjname(P, pmp->pr_vaddr, m, sizeof (m));
if ((obj = strrchr(m, '/')) == NULL)
obj = &m[0];
else
obj++;
#if defined(sun)
(void) Plmid(P, pmp->pr_vaddr, &lmid);
#endif
@ -571,9 +563,7 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname)
{
struct ps_prochandle *P = data;
GElf_Sym sym;
#if defined(sun)
prsyminfo_t sip;
#endif
dof_helper_t dh;
GElf_Half e_type;
const char *mname;
@ -852,11 +842,7 @@ dt_pid_get_types(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp,
ctf_funcinfo_t f;
ctf_id_t argv[32];
GElf_Sym sym;
#if defined(sun)
prsyminfo_t si;
#else
void *si;
#endif
struct ps_prochandle *p;
int i, args;
char buf[DTRACE_ARGTYPELEN];
@ -941,13 +927,11 @@ dt_pid_get_types(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp,
pdp->dtpd_func, pdp->dtpd_provider, pdp->dtpd_mod);
goto out;
}
#if defined(sun)
if (ctf_func_info(fp, si.prs_id, &f) == CTF_ERR) {
dt_dprintf("failed to get ctf information for %s in %s`%s\n",
pdp->dtpd_func, pdp->dtpd_provider, pdp->dtpd_mod);
goto out;
}
#endif
(void) snprintf(buf, sizeof (buf), "%s`%s", pdp->dtpd_provider,
pdp->dtpd_mod);
@ -977,7 +961,6 @@ dt_pid_get_types(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp,
(void) ctf_type_qname(fp, f.ctc_return, adp->dtargd_native +
ret, DTRACE_ARGTYPELEN - ret, buf);
*nargs = 2;
#if defined(sun)
} else {
if (ctf_func_args(fp, si.prs_id, argc, argv) == CTF_ERR)
goto out;
@ -993,7 +976,6 @@ dt_pid_get_types(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp,
(void) ctf_type_qname(fp, argv[i], adp->dtargd_native +
ret, DTRACE_ARGTYPELEN - ret, buf);
}
#endif
}
out:
dt_proc_unlock(dtp, p);

View File

@ -167,7 +167,7 @@ print_bitfield(dt_printarg_t *pap, ulong_t off, ctf_encoding_t *ep)
* to the lowest 'size' bytes in 'value', and we need to shift based on
* the offset from the end of the data, not the offset of the start.
*/
#ifdef _BIG_ENDIAN
#if BYTE_ORDER == _BIG_ENDIAN
buf += sizeof (value) - size;
off += ep->cte_bits;
#endif
@ -178,7 +178,7 @@ print_bitfield(dt_printarg_t *pap, ulong_t off, ctf_encoding_t *ep)
* Offsets are counted from opposite ends on little- and
* big-endian machines.
*/
#ifdef _BIG_ENDIAN
#if BYTE_ORDER == _BIG_ENDIAN
shift = NBBY - shift;
#endif

View File

@ -1457,6 +1457,12 @@ zfs_setprop_error(libzfs_handle_t *hdl, zfs_prop_t prop, int err,
(void) zfs_error(hdl, EZFS_DSREADONLY, errbuf);
break;
case E2BIG:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property value too long"));
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
break;
case ENOTSUP:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"pool and or dataset must be upgraded to set this "

View File

@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
@ -1426,21 +1426,15 @@ zpool_find_import_cached(libzfs_handle_t *hdl, const char *cachefile,
elem = NULL;
while ((elem = nvlist_next_nvpair(raw, elem)) != NULL) {
verify(nvpair_value_nvlist(elem, &src) == 0);
src = fnvpair_value_nvlist(elem);
verify(nvlist_lookup_string(src, ZPOOL_CONFIG_POOL_NAME,
&name) == 0);
name = fnvlist_lookup_string(src, ZPOOL_CONFIG_POOL_NAME);
if (poolname != NULL && strcmp(poolname, name) != 0)
continue;
verify(nvlist_lookup_uint64(src, ZPOOL_CONFIG_POOL_GUID,
&this_guid) == 0);
if (guid != 0) {
verify(nvlist_lookup_uint64(src, ZPOOL_CONFIG_POOL_GUID,
&this_guid) == 0);
if (guid != this_guid)
continue;
}
this_guid = fnvlist_lookup_uint64(src, ZPOOL_CONFIG_POOL_GUID);
if (guid != 0 && guid != this_guid)
continue;
if (pool_active(hdl, name, this_guid, &active) != 0) {
nvlist_free(raw);

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) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
@ -304,7 +304,6 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
case ZPOOL_PROP_FREE:
case ZPOOL_PROP_FREEING:
case ZPOOL_PROP_LEAKED:
case ZPOOL_PROP_EXPANDSZ:
if (literal) {
(void) snprintf(buf, len, "%llu",
(u_longlong_t)intval);
@ -312,7 +311,16 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
(void) zfs_nicenum(intval, buf, len);
}
break;
case ZPOOL_PROP_EXPANDSZ:
if (intval == 0) {
(void) strlcpy(buf, "-", len);
} else if (literal) {
(void) snprintf(buf, len, "%llu",
(u_longlong_t)intval);
} else {
(void) zfs_nicenum(intval, buf, len);
}
break;
case ZPOOL_PROP_CAPACITY:
if (literal) {
(void) snprintf(buf, len, "%llu",
@ -330,13 +338,11 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
(u_longlong_t)intval);
}
break;
case ZPOOL_PROP_DEDUPRATIO:
(void) snprintf(buf, len, "%llu.%02llux",
(u_longlong_t)(intval / 100),
(u_longlong_t)(intval % 100));
break;
case ZPOOL_PROP_HEALTH:
verify(nvlist_lookup_nvlist(zpool_get_config(zhp, NULL),
ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0);

View File

@ -650,6 +650,9 @@ dprintf_setup(int *argc, char **argv)
*/
if (dprintf_find_string("on"))
dprintf_print_all = 1;
if (dprintf_string != NULL)
zfs_flags |= ZFS_DEBUG_DPRINTF;
}
int

View File

@ -38,7 +38,7 @@
#define Pxlookup_by_addr(p, a, n, s, sym, i) \
proc_addr2sym(p, a, n, s, sym)
#define Pxlookup_by_name(p, l, s1, s2, sym, a) \
proc_name2sym((p), (s1), (s2), (sym))
proc_name2sym(p, s1, s2, sym, a)
#define Paddr_to_map proc_addr2map
#define Pcreate_error strerror
#define Pdelbkpt proc_bkptdel
@ -46,10 +46,10 @@
#define Plmid(p, a, l) (-1)
#define Plmid_to_map(p, l, o) proc_obj2map((p), (o))
#define Plookup_by_addr proc_addr2sym
#define Pname_to_ctf(p, obj) NULL
#define Pname_to_ctf(p, obj) (ctf_file_t *)proc_name2ctf(p, obj)
#define Pname_to_map proc_name2map
#define Pobject_iter proc_iter_objs
#define Pobject_iter_resolved(p, f, arg) 1
#define Pobject_iter_resolved(p, f, arg) proc_iter_objs(p, f, arg)
#define Pobjname proc_objname
#define Pread proc_read
#define Prd_agent proc_rdagent

View File

@ -7,8 +7,11 @@
LIB= zfs
DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBUMEM} ${LIBUTIL} ${LIBM} ${LIBNVPAIR} \
${LIBAVL} ${LIBZFS_CORE}
LDADD= -lmd -lpthread -lumem -lutil -lm -lnvpair -lavl -lzfs_core
${LIBAVL} ${LIBZFS_CORE} ${LIBUUTIL} ${LIBBSDXML} ${LIBGEOM} \
${LIBNVPAIR}
LDADD= -lmd -lpthread -lumem -lutil -luutil -lm -lnvpair -lavl \
-lbsdxml -lgeom -lnvpair -lzfs_core
SRCS= deviceid.c \
fsshare.c \

View File

@ -56,8 +56,9 @@ CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/thread
CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/sys
CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_CPUARCH}/include
DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ}
LDADD= -lmd -lpthread -lz
DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ} ${LIBNVPAIR} \
${LIBAVL} ${LIBUMEM}
LDADD= -lmd -lpthread -lz -lnvpair -lavl -lumem
# atomic.S doesn't like profiling.
MK_PROFILE= no

View File

@ -5,6 +5,7 @@
SUBDIR= ${_dtrace} \
${_dtruss} \
${_lockstat} \
${_plockstat} \
${_tests} \
${_zdb} \
${_zhack}
@ -24,6 +25,9 @@ _zhack= zhack
_dtrace= dtrace
_dtruss= dtruss
_lockstat= lockstat
.if defined(WITH_PLOCKSTAT)
_plockstat= plockstat
.endif
.endif
.if ${MACHINE_CPUARCH} == "mips"

View File

@ -1,4 +1,30 @@
-*- coding: utf-8 -*-
Changes with APR-util 1.5.4
*) MySQL driver: Fix incorrect handling of bad parameter in the
driver support for apr_dbd_transaction_end(). PR 56330.
[Weiqiang Li <weiqiang_li hotmail.com>]
*) apr_crypto_get_driver(): Fix invalid storage reference on error path.
[Philip Martin <philip.martin wandisco.com>]
*) Fix compile failure for Android. PR 56627. [Fredrik Fornwall
<fredrik fornwall.net>, Jeff Trawick]
*) Fix to let ODBC driver build with MSVC6, which does not have intptr_t
[Tom Donovan]
*) Windows cmake build: Fix incompatiblities with Visual Studio
generators with all cmake versions, and the NMake Makefile generator
with cmake 2.8.12 and later. PR 56616 and other bugs. [Jeff Trawick,
Bert Huijben]
*) Fix detection of Berkeley DB 6.0. PR 55277.
[Lars Wendler <polynomial-c gentoo.org>]
*) Improve platform detection for bundled expat by updating
config.guess and config.sub. [Rainer Jung]
Changes with APR-util 1.5.3
*) Cygwin: Use correct file extension when loading APR DSOs. PR 55587.

View File

@ -1,7 +1,7 @@
Apache Portable Runtime Utility Library
Copyright (c) 2011 The Apache Software Foundation.
Copyright (c) 2000-2014 The Apache Software Foundation.
This product includes software developed by
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Portions of this software were developed at the National Center

View File

@ -3,7 +3,7 @@
Summary: Apache Portable Runtime Utility library
Name: apr-util
Version: 1.5.3
Version: 1.5.4
Release: 1
License: Apache Software License
Group: System Environment/Libraries

View File

@ -11608,19 +11608,34 @@ fi
apu_db_version=0
# Maximum supported version announced in help string.
# Although we search for all versions up to 5.9,
# Although we search for all versions up to 6.9,
# we should only include existing versions in our
# help string.
db_max_version=53
db_min_version=41
dbm_list="sdbm, gdbm, ndbm, db, db1, db185, db2, db3, db4"
db_max_version=48
db_min_version=41
db_version="$db_min_version"
while [ $db_version -le $db_max_version ]
do
dbm_list="$dbm_list, db$db_version"
db_version=`expr $db_version + 1`
done
db_max_version=53
db_min_version=50
db_version="$db_min_version"
while [ $db_version -le $db_max_version ]
do
dbm_list="$dbm_list, db$db_version"
db_version=`expr $db_version + 1`
done
db_max_version=60
db_min_version=60
db_version="$db_min_version"
while [ $db_version -le $db_max_version ]
do
dbm_list="$dbm_list, db$db_version"
db_version=`expr $db_version + 1`
done
dbm_list="$dbm_list, db60"
# Check whether --with-dbm was given.
@ -12093,8 +12108,8 @@ if test "${with_berkeley_db+set}" = set; then :
all_places="$check_places"
# Start version search at version 5.9
db_version=59
# Start version search at version 6.9
db_version=69
while [ $db_version -ge 40 ]
do
db_major=`echo $db_version | sed -e 's/.$//'`
@ -12178,7 +12193,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5"; then
if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5" -o ""${db_major}"" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -12580,7 +12595,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test "3" = "3" -o "3" = "4" -o "3" = "5"; then
if test "3" = "3" -o "3" = "4" -o "3" = "5" -o "3" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -12978,7 +12993,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test "2" = "3" -o "2" = "4" -o "2" = "5"; then
if test "2" = "3" -o "2" = "4" -o "2" = "5" -o "2" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -13376,7 +13391,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test "1" = "3" -o "1" = "4" -o "1" = "5"; then
if test "1" = "3" -o "1" = "4" -o "1" = "5" -o "1" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -13774,7 +13789,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test "1" = "3" -o "1" = "4" -o "1" = "5"; then
if test "1" = "3" -o "1" = "4" -o "1" = "5" -o "1" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -14186,7 +14201,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test "1" = "3" -o "1" = "4" -o "1" = "5"; then
if test "1" = "3" -o "1" = "4" -o "1" = "5" -o "1" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -14587,7 +14602,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test "1" = "3" -o "1" = "4" -o "1" = "5"; then
if test "1" = "3" -o "1" = "4" -o "1" = "5" -o "1" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -14988,7 +15003,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test "2" = "3" -o "2" = "4" -o "2" = "5"; then
if test "2" = "3" -o "2" = "4" -o "2" = "5" -o "2" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -15389,7 +15404,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test "3" = "3" -o "3" = "4" -o "3" = "5"; then
if test "3" = "3" -o "3" = "4" -o "3" = "5" -o "3" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -15794,7 +15809,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5"; then
if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5" -o ""${db_major}"" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -16202,7 +16217,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5"; then
if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5" -o ""${db_major}"" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -16534,8 +16549,8 @@ fi
all_places="$check_places"
# Start version search at version 5.9
db_version=59
# Start version search at version 6.9
db_version=69
while [ $db_version -ge 40 ]
do
db_major=`echo $db_version | sed -e 's/.$//'`
@ -16619,7 +16634,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5"; then
if test ""${db_major}"" = "3" -o ""${db_major}"" = "4" -o ""${db_major}"" = "5" -o ""${db_major}"" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -17021,7 +17036,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test "3" = "3" -o "3" = "4" -o "3" = "5"; then
if test "3" = "3" -o "3" = "4" -o "3" = "5" -o "3" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -17419,7 +17434,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test "2" = "3" -o "2" = "4" -o "2" = "5"; then
if test "2" = "3" -o "2" = "4" -o "2" = "5" -o "2" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -17817,7 +17832,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test "1" = "3" -o "1" = "4" -o "1" = "5"; then
if test "1" = "3" -o "1" = "4" -o "1" = "5" -o "1" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of
@ -18215,7 +18230,7 @@ $as_echo "" >&6; }
ac_fn_c_check_header_mongrel "$LINENO" "$bdb_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
if test "1" = "3" -o "1" = "4" -o "1" = "5"; then
if test "1" = "3" -o "1" = "4" -o "1" = "5" -o "1" = "6"; then
# We generate a separate cache variable for each prefix and libname
# we search under. That way, we avoid caching information that
# changes if the user runs `configure' with a different set of

View File

@ -204,7 +204,7 @@ APU_DECLARE(apr_status_t) apr_crypto_get_driver(
if (err && buffer) {
apr_dso_error(dso, buffer, ERROR_SIZE - 1);
err->msg = buffer;
err->reason = modname;
err->reason = apr_pstrdup(pool, modname);
*result = err;
}
}

View File

@ -66,6 +66,12 @@ static void crypt_mutex_unlock(void)
#endif
#endif
#if defined(WIN32) || defined(BEOS) || defined(NETWARE) || defined(__ANDROID__)
#define CRYPT_MISSING 1
#else
#define CRYPT_MISSING 0
#endif
/*
* Validate a plaintext password against a smashed one. Uses either
* crypt() (if available) or apr_md5_encode() or apr_sha1_base64(), depending
@ -77,7 +83,7 @@ APU_DECLARE(apr_status_t) apr_password_validate(const char *passwd,
const char *hash)
{
char sample[200];
#if !defined(WIN32) && !defined(BEOS) && !defined(NETWARE)
#if !CRYPT_MISSING
char *crypt_pw;
#endif
if (hash[0] == '$'
@ -100,7 +106,7 @@ APU_DECLARE(apr_status_t) apr_password_validate(const char *passwd,
/*
* It's not our algorithm, so feed it to crypt() if possible.
*/
#if defined(WIN32) || defined(BEOS) || defined(NETWARE)
#if CRYPT_MISSING
return (strcmp(passwd, hash) == 0) ? APR_SUCCESS : APR_EMISMATCH;
#elif defined(CRYPT_R_CRYPTD)
apr_status_t rv;

View File

@ -1050,9 +1050,9 @@ static int dbd_mysql_end_transaction(apr_dbd_transaction_t *trans)
else {
ret = mysql_commit(trans->handle->conn);
}
ret |= mysql_autocommit(trans->handle->conn, 1);
trans->handle->trans = NULL;
}
ret |= mysql_autocommit(trans->handle->conn, 1);
trans->handle->trans = NULL;
return ret;
}
/* Whether or not transactions work depends on whether the

View File

@ -47,6 +47,21 @@
#include <odbc/sqlext.h>
#endif
/*
* MSVC6 does not support intptr_t (C99)
* APR does not have a signed inptr type until 2.0 (r1557720)
*/
#if defined(_MSC_VER) && _MSC_VER < 1400
#if APR_SIZEOF_VOIDP == 8
#define ODBC_INTPTR_T apr_int64_t
#else
#define ODBC_INTPTR_T apr_int32_t
#endif
#else
#define ODBC_INTPTR_T intptr_t
#endif
/* Driver name is "odbc" and the entry point is 'apr_dbd_odbc_driver'
* unless ODBC_DRIVER_NAME is defined and it is linked with another db library which
* is ODBC source-compatible. e.g. DB2, Informix, TimesTen, mysql.
@ -114,9 +129,9 @@ struct apr_dbd_t
char lastError[MAX_ERROR_STRING];
int defaultBufferSize; /* used for CLOBs in text mode,
* and when fld size is indeterminate */
intptr_t transaction_mode;
intptr_t dboptions; /* driver options re SQLGetData */
intptr_t default_transaction_mode;
ODBC_INTPTR_T transaction_mode;
ODBC_INTPTR_T dboptions; /* driver options re SQLGetData */
ODBC_INTPTR_T default_transaction_mode;
int can_commit; /* controls end_trans behavior */
};
@ -359,7 +374,7 @@ static SQLRETURN odbc_set_result_column(int icol, apr_dbd_results_t *res,
SQLHANDLE stmt)
{
SQLRETURN rc;
intptr_t maxsize, textsize, realsize, type, isunsigned = 1;
ODBC_INTPTR_T maxsize, textsize, realsize, type, isunsigned = 1;
/* discover the sql type */
rc = SQLColAttribute(stmt, icol + 1, SQL_DESC_UNSIGNED, NULL, 0, NULL,
@ -747,7 +762,7 @@ static void *odbc_get(const apr_dbd_row_t *row, const int col,
SQLRETURN rc;
SQLLEN indicator;
int state = row->res->colstate[col];
intptr_t options = row->res->apr_dbd->dboptions;
ODBC_INTPTR_T options = row->res->apr_dbd->dboptions;
switch (state) {
case (COL_UNAVAIL):
@ -817,13 +832,13 @@ static apr_status_t odbc_parse_params(apr_pool_t *pool, const char *params,
int *connect, SQLCHAR **datasource,
SQLCHAR **user, SQLCHAR **password,
int *defaultBufferSize, int *nattrs,
int **attrs, intptr_t **attrvals)
int **attrs, ODBC_INTPTR_T **attrvals)
{
char *seps, *last, *next, *name[MAX_PARAMS], *val[MAX_PARAMS];
int nparams = 0, i, j;
*attrs = apr_pcalloc(pool, MAX_PARAMS * sizeof(char *));
*attrvals = apr_pcalloc(pool, MAX_PARAMS * sizeof(intptr_t));
*attrvals = apr_pcalloc(pool, MAX_PARAMS * sizeof(ODBC_INTPTR_T));
*nattrs = 0;
seps = DEFAULTSEPS;
name[nparams] = apr_strtok(apr_pstrdup(pool, params), seps, &last);
@ -1063,7 +1078,7 @@ static apr_dbd_t *odbc_open(apr_pool_t *pool, const char *params, const char **e
SQLCHAR *datasource = (SQLCHAR *)"", *user = (SQLCHAR *)"",
*password = (SQLCHAR *)"";
int nattrs = 0, *attrs = NULL, connect = 0;
intptr_t *attrvals = NULL;
ODBC_INTPTR_T *attrvals = NULL;
err_step = "SQLAllocHandle (SQL_HANDLE_DBC)";
err_htype = SQL_HANDLE_ENV;
@ -1117,10 +1132,10 @@ static apr_dbd_t *odbc_open(apr_pool_t *pool, const char *params, const char **e
handle->default_transaction_mode = 0;
handle->can_commit = APR_DBD_TRANSACTION_IGNORE_ERRORS;
SQLGetInfo(hdbc, SQL_DEFAULT_TXN_ISOLATION,
&(handle->default_transaction_mode), sizeof(intptr_t), NULL);
&(handle->default_transaction_mode), sizeof(ODBC_INTPTR_T), NULL);
handle->transaction_mode = handle->default_transaction_mode;
SQLGetInfo(hdbc, SQL_GETDATA_EXTENSIONS ,&(handle->dboptions),
sizeof(intptr_t), NULL);
sizeof(ODBC_INTPTR_T), NULL);
apr_pool_cleanup_register(pool, handle, odbc_close_cleanup, apr_pool_cleanup_null);
return handle;
}

View File

@ -235,7 +235,7 @@ nlms :: libs $(TARGET_nlm)
# correct place. (See $(AP_WORK)\build\NWGNUhead.inc for examples)
#
install :: nlms $(INSTDIRS) FORCE
copy $(OBJDIR)\*.nlm $(INSTALLBASE)
$(call COPY,$(OBJDIR)/*.nlm,$(INSTALLBASE))
#
# Any specialized rules here

View File

@ -38,7 +38,7 @@
*/
#define APU_COPYRIGHT "Copyright (c) 2013 The Apache Software " \
#define APU_COPYRIGHT "Copyright (c) 2000-2014 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 APU_PATCH_VERSION 3
#define APU_PATCH_VERSION 4
/**
* The symbol APU_IS_DEV_VERSION is only defined for internal,

View File

@ -88,6 +88,8 @@ APROUTDIR=$(OUTDIR)
!IF "$(MODEL)" == "static"
PROGRAM_DEPENDENCIES = \
$(APR_PATH)\$(APROUTDIR)\apr-1.lib \
$(API_PATH)\$(OUTDIR)\apriconv-1.lib \
..\xml\expat\lib\$(OUTDIR)\xml.lib \
..\$(OUTDIR)\aprutil-1.lib
STATIC_CFLAGS = /D APR_DECLARE_STATIC /D APU_DECLARE_STATIC
STATIC_LIBS = odbc32.lib odbccp32.lib wldap32.lib

View File

@ -7,10 +7,9 @@ branches and you are supposed to follow those:
http://www.freebsd.org/doc/en/articles/committers-guide/subversion-primer.html
The ATF source code is hosted on Google Code as a subcomponent of the
Kyua project:
The ATF source code is hosted on GitHub:
http://code.google.com/p/kyua/downloads/list
https://github.com/jmmv/atf
and is imported into the atf vendor branch (see base/vendor/atf/).
@ -42,7 +41,7 @@ the vendor branch as you easily risk committing build products into the
tree.
Lastly, with the list of old and new files in this import, make sure
to udpate the reachover Makefiles accordingly.
to update the reachover Makefiles accordingly.
Test the build (keeping in mind the WITH_TESTS/WITHOUT_TESTS knobs) and,
if all looks good, you are ready to commit all the changes in one go.

View File

@ -14,6 +14,9 @@ the 'tools' directory for your own consumption.
* Removed the deprecated tools. This includes atf-config, atf-report,
atf-run and atf-version.
* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang
that ships with FreeBSD 11.0-CURRENT.
Changes in version 0.19
***********************

View File

@ -26,7 +26,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd November 15, 2013
.Dd March 2, 2014
.Dt ATF-C++-API 3
.Os
.Sh NAME
@ -330,9 +330,8 @@ If
.Va exitcode
is not
.Sq -1 ,
.Xr atf-run 1
will validate that the exit code of the test case matches the one provided
in this call.
the runtime engine will validate that the exit code of the test case
matches the one provided in this call.
Otherwise, the exact value will be ignored.
.It Fn expect_fail "reason"
Any failure (be it fatal or non-fatal) raised in this mode is recorded.
@ -368,9 +367,8 @@ If
.Va signo
is not
.Sq -1 ,
.Xr atf-run 1
will validate that the signal that terminated the test case matches the one
provided in this call.
the runtime engine will validate that the signal that terminated the test
case matches the one provided in this call.
Otherwise, the exact value will be ignored.
.It Fn expect_timeout "reason"
Expects the test case to execute for longer than its timeout.
@ -631,5 +629,4 @@ ATF_INIT_TEST_CASES(tcs)
.Ed
.Sh SEE ALSO
.Xr atf-test-program 1 ,
.Xr atf-test-case 4 ,
.Xr atf 7
.Xr atf-test-case 4

View File

@ -26,7 +26,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd November 15, 2013
.Dd March 2, 2014
.Dt ATF-C-API 3
.Os
.Sh NAME
@ -409,9 +409,8 @@ If
.Va exitcode
is not
.Sq -1 ,
.Xr atf-run 1
will validate that the exit code of the test case matches the one provided
in this call.
the runtime engine will validate that the exit code of the test case
matches the one provided in this call.
Otherwise, the exact value will be ignored.
.It Fn atf_tc_expect_fail "reason" "..."
Any failure (be it fatal or non-fatal) raised in this mode is recorded.
@ -443,9 +442,8 @@ If
.Va signo
is not
.Sq -1 ,
.Xr atf-run 1
will validate that the signal that terminated the test case matches the one
provided in this call.
the runtime engine will validate that the signal that terminated the test
case matches the one provided in this call.
Otherwise, the exact value will be ignored.
.It Fn atf_tc_expect_timeout "reason" "..."
Expects the test case to execute for longer than its timeout.
@ -771,5 +769,4 @@ ATF_TP_ADD_TCS(tp)
.Ed
.Sh SEE ALSO
.Xr atf-test-program 1 ,
.Xr atf-test-case 4 ,
.Xr atf 7
.Xr atf-test-case 4

View File

@ -87,6 +87,7 @@ ATF_TC(TEST_MACRO_1);
ATF_TC_HEAD(TEST_MACRO_1, tc) { if (tc != NULL) {} }
ATF_TC_BODY(TEST_MACRO_1, tc) { if (tc != NULL) {} }
atf_tc_t *test_name_1 = &ATF_TC_NAME(TEST_MACRO_1);
atf_tc_pack_t *test_pack_1 = &ATF_TC_PACK_NAME(TEST_MACRO_1);
void (*head_1)(atf_tc_t *) = ATF_TC_HEAD_NAME(TEST_MACRO_1);
void (*body_1)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_1);
ATF_TC_WITH_CLEANUP(TEST_MACRO_2);
@ -94,10 +95,12 @@ ATF_TC_HEAD(TEST_MACRO_2, tc) { if (tc != NULL) {} }
ATF_TC_BODY(TEST_MACRO_2, tc) { if (tc != NULL) {} }
ATF_TC_CLEANUP(TEST_MACRO_2, tc) { if (tc != NULL) {} }
atf_tc_t *test_name_2 = &ATF_TC_NAME(TEST_MACRO_2);
atf_tc_pack_t *test_pack_2 = &ATF_TC_PACK_NAME(TEST_MACRO_2);
void (*head_2)(atf_tc_t *) = ATF_TC_HEAD_NAME(TEST_MACRO_2);
void (*body_2)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_2);
void (*cleanup_2)(const atf_tc_t *) = ATF_TC_CLEANUP_NAME(TEST_MACRO_2);
ATF_TC_WITHOUT_HEAD(TEST_MACRO_3);
ATF_TC_BODY(TEST_MACRO_3, tc) { if (tc != NULL) {} }
atf_tc_t *test_name_3 = &ATF_TC_NAME(TEST_MACRO_3);
atf_tc_pack_t *test_pack_3 = &ATF_TC_PACK_NAME(TEST_MACRO_3);
void (*body_3)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_3);

View File

@ -26,7 +26,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd June 27, 2010
.Dd March 2, 2014
.Dt ATF-CHECK 1
.Os
.Sh NAME
@ -118,15 +118,20 @@ Analyzes standard error (syntax identical to above)
Executes
.Ar command
as a shell command line, executing it with the system shell defined by
.Va ATF_SHELL
in
.Xr atf-config 1 .
.Va ATF_SHELL .
You should avoid using this flag if at all possible to prevent shell quoting
issues.
.El
.Sh EXIT STATUS
.Nm
exits 0 on success, and other (unspecified) value on failure.
.Sh ENVIRONMENT
.Bl -tag -width ATFXSHELLXX -compact
.It Va ATF_SHELL
Path to the system shell to be used when the
.Fl x
is given to run commands.
.El
.Sh EXAMPLES
.Bd -literal -offset indent
# Exit code 0, nothing on stdout/stderr
@ -146,6 +151,3 @@ atf-check -s signal:sigsegv my_program
# Combined checks
atf-check -o match:foo -o not-match:bar echo foo baz
.Ed
.Sh SEE ALSO
.Xr atf-config 1 ,
.Xr atf 7

View File

@ -26,7 +26,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 13, 2013
.Dd March 2, 2014
.Dt ATF-SH-API 3
.Os
.Sh NAME
@ -224,9 +224,8 @@ If
.Va exitcode
is not
.Sq -1 ,
.Xr atf-run 1
will validate that the exit code of the test case matches the one provided
in this call.
the runtime engine will validate that the exit code of the test case
matches the one provided in this call.
Otherwise, the exact value will be ignored.
.It Fn atf_expect_fail "reason"
Any failure raised in this mode is recorded, but such failures do not report
@ -258,9 +257,8 @@ If
.Va signo
is not
.Sq -1 ,
.Xr atf-run 1
will validate that the signal that terminated the test case matches the one
provided in this call.
the runtime engine will validate that the signal that terminated the test
case matches the one provided in this call.
Otherwise, the exact value will be ignored.
.It Fn atf_expect_timeout "reason" "..."
Expects the test case to execute for longer than its timeout.
@ -339,5 +337,4 @@ atf_check -s exit:0 -o match:"^foo$" -e empty 'ls'
.Sh SEE ALSO
.Xr atf-sh 1 ,
.Xr atf-test-program 1 ,
.Xr atf-test-case 4 ,
.Xr atf 7
.Xr atf-test-case 4

View File

@ -26,7 +26,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 15, 2013
.Dd March 2, 2014
.Dt ATF-SH 1
.Os
.Sh NAME
@ -47,10 +47,8 @@ library.
.Pp
.Nm
is not a real interpreter though: it is just a wrapper around
the system-wide shell defined by the
.Sq atf_shell
configuration value in
.Xr atf-config 1 .
the system-wide shell defined by
.Va ATF_SHELL .
.Nm
executes the interpreter, loads the
.Xr atf-sh-api 3
@ -68,7 +66,10 @@ The following options are available:
.It Fl h
Shows a short summary of all available options and their purpose.
.El
.Sh ENVIRONMENT
.Bl -tag -width ATFXSHELLXX -compact
.It Va ATF_SHELL
Path to the system shell to be used in the generated scripts.
.El
.Sh SEE ALSO
.Xr atf-config 1 ,
.Xr atf-sh-api 3 ,
.Xr atf 7
.Xr atf-sh-api 3

View File

@ -26,7 +26,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd January 13, 2011
.Dd March 2, 2014
.Dt ATF-TEST-CASE 4
.Os
.Sh NAME
@ -171,9 +171,7 @@ Type: boolean.
Optional.
.Pp
If set to true, specifies that the test case has a cleanup routine that has
to be executed by
.Xr atf-run 1
during the cleanup phase of the execution.
to be executed by the runtime engine during the cleanup phase of the execution.
This property is automatically set by the framework when defining a test case
with a cleanup routine, so it should never be set by hand.
.It ident
@ -251,8 +249,7 @@ the test case is
.Pp
If the test case is running as root and this property is
.Sq unprivileged ,
.Xr atf-run 1
will automatically drop the privileges if the
the runtime engine will automatically drop the privileges if the
.Sq unprivileged-user
configuration property is set; otherwise the test case is
.Em skipped .
@ -314,7 +311,4 @@ Test cases are always executed with a file creation mode mask (umask) of
.Sq 0022 .
The test case's code is free to change this during execution.
.Sh SEE ALSO
.Xr atf-run 1 ,
.Xr atf-test-program 1 ,
.Xr atf-formats 5 ,
.Xr atf 7
.Xr atf-test-program 1

View File

@ -26,7 +26,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd February 6, 2011
.Dd March 2, 2014
.Dt ATF-TEST-PROGRAM 1
.Os
.Sh NAME
@ -61,16 +61,17 @@ instead of the test case body; see
Note that the test case is
.Em executed without isolation ,
so it can and probably will create and modify files in the current directory.
To execute test cases in a controller manner, refer to
.Xr atf-run 1 ,
which is the preferred way to run test cases.
To execute test cases in a controller manner, you need a runtime engine
that understands the ATF interface.
The recommended runtime engine is
.Xr kyua 1 .
You should only execute test cases by hand for debugging purposes.
.Pp
In the second synopsis form, the test program will list all available
test cases alongside their meta-data properties in a format that is
machine parseable.
This list is processed by
.Xr atf-run 1
.Xr kyua 1
to know how to execute the test cases of a given test program.
.Pp
The following options are available:
@ -99,5 +100,4 @@ to the value
.Ar value .
.El
.Sh SEE ALSO
.Xr atf-run 1 ,
.Xr atf 7
.Xr kyua 1

View File

@ -4688,6 +4688,23 @@ parse_address_main (char **str, int i, int group_relocations,
return PARSE_OPERAND_FAIL;
}
}
else if (skip_past_char (&p, ':') == SUCCESS)
{
/* FIXME: '@' should be used here, but it's filtered out by generic
code before we get to see it here. This may be subject to
change. */
expressionS exp;
my_get_expression (&exp, &p, GE_NO_PREFIX);
if (exp.X_op != O_constant)
{
inst.error = _("alignment must be constant");
return PARSE_OPERAND_FAIL;
}
inst.operands[i].imm = exp.X_add_number << 8;
inst.operands[i].immisalign = 1;
/* Alignments are not pre-indexes. */
inst.operands[i].preind = 0;
}
if (skip_past_char (&p, ']') == FAIL)
{
@ -6571,6 +6588,7 @@ do_barrier (void)
if (inst.operands[0].present)
{
constraint ((inst.instruction & 0xf0) != 0x40
&& (inst.instruction & 0xf0) != 0x50
&& inst.operands[0].imm != 0xf,
"bad barrier type");
inst.instruction |= inst.operands[0].imm;
@ -14694,10 +14712,18 @@ static const struct asm_cond conds[] =
static struct asm_barrier_opt barrier_opt_names[] =
{
{ "sy", 0xf },
{ "un", 0x7 },
{ "st", 0xe },
{ "unst", 0x6 }
{ "sy", 0xf },
{ "un", 0x7 },
{ "st", 0xe },
{ "unst", 0x6 },
{ "ish", 0xb },
{ "sh", 0xb },
{ "ishst", 0xa },
{ "shst", 0xa },
{ "nsh", 0x7 },
{ "nshst", 0x6 },
{ "osh", 0x3 },
{ "oshst", 0x2 }
};
/* Table of ARM-format instructions. */

View File

@ -0,0 +1,68 @@
.\" Copyright (c) 2014 Microsoft Corp.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd September 10, 2013
.Dt HYPER-V 4
.Os
.Sh NAME
.Nm hv_kvp_daemon
.Nd Hyper-V Key Value Pair Daemon
.Sh SYNOPSIS
The \fBhv_kvp_daemon\fP daemon provides the ability to store, retrieve, modify and delete
Key Value pairs for FreeBSD guest partitions running on Hyper-V.
.Sh DESCRIPTION
Hyper-V allows administrators to store custom metadata in the form
of Key Value pairs inside the FreeBSD guest partition. Administrators can
use Windows Powershell scripts to add, read, modify and delete such
Key Value pairs.
The \fBhv_kvp_daemon\fP accepts Key Value pair management requests from the
\fBhv_utils\fP driver and performs the actual metadata management on the file-system.
The same daemon and driver combination is also used to set and get
IP addresses from a FreeBSD guest.
The set functionality is particularly
useful when the FreeBSD guest is assigned a static IP address and is failed
over from one Hyper-V host to another. After failover, Hyper-V uses the set IP
functionality to automatically
update the FreeBSD guest's IP address to its original static value.
On the other hand, the get IP functionality is used to update the guest IP
address in the Hyper-V management console window.
.Sh SEE ALSO
.Xr hv_vmbus 4 ,
.Xr hv_utils 4 ,
.Xr hv_netvsc 4 ,
.Xr hv_storvsc 4 ,
.Xr hv_ata_pci_disengage 4
.Sh HISTORY
Support for Hyper-V in the form of ports was first released in September 2013.
The daemon was developed through a joint effort between Citrix Inc.,
Microsoft Corp. and Network Appliance Inc..
.Sh AUTHORS
.An -nosplit
.Fx
support for \fBhv_kvp_daemon\fP was first added by
.An Microsoft BSD Integration Services Team Aq bsdic@microsoft.com .

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
#!/bin/sh
# This is the script retrieves the DHCP state of a given interface.
# The kvp daemon code invokes this external script to gather
# DHCP setting for the specific interface.
#
# Input: Name of the interface
#
# Output: The script prints the string "Enabled" to stdout to indicate
# that DHCP is enabled on the interface. If DHCP is not enabled,
# the script prints the string "Disabled" to stdout.
#
. /etc/rc.subr
. /etc/network.subr
load_rc_config netif
if dhcpif hn0;
then
echo "Enabled"
else
echo "Disabled"
fi

View File

@ -0,0 +1,12 @@
#!/bin/sh
# This script parses /etc/resolv.conf to retrive DNS information.
# Khe kvp daemon code invokes this external script to gather
# DNS information.
# This script is expected to print the nameserver values to stdout.
#if test -r /etc/resolv.conf
#then
# awk -- '/^nameserver/ { print $2 }' /etc/resolv.conf
#fi
cat /etc/resolv.conf 2>/dev/null | awk '/^nameserver/ { print $2 }'

View File

@ -0,0 +1,73 @@
#!/bin/sh
# This script activates an interface based on the specified
# configuration. The kvp daemon code invokes this external script
# to configure the interface.
#
# The only argument to this script is the configuration file that is to
# be used to configure the interface.
#
# Here is the format of the ip configuration file:
#
# HWADDR=macaddr
# IF_NAME=interface name
# DHCP=yes (This is optional; if yes, DHCP is configured)
#
# IPADDR=ipaddr1
# IPADDR_1=ipaddr2
# IPADDR_x=ipaddry (where y = x + 1)
#
# NETMASK=netmask1
# NETMASK_x=netmasky (where y = x + 1)
#
# GATEWAY=ipaddr1
# GATEWAY_x=ipaddry (where y = x + 1)
#
# DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc)
#
# IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be
# tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as
# IPV6NETMASK.
#
# The host can specify multiple ipv4 and ipv6 addresses to be
# configured for the interface. Furthermore, the configuration
# needs to be persistent. A subsequent GET call on the interface
# is expected to return the configuration that is set via the SET
# call.
#
. $1
sed -i".bak" '/ifconfig_hn0="SYNCDHCP"/d' /etc/rc.conf
sed -i".bak" '/ifconfig_hn0="DHCP"/d' /etc/rc.conf
# MAC Address
ifconfig $IF_NAME ether $HWADDR
# IP and Subnet Mask
ifconfig $IF_NAME inet $IP_ADDR netmask $SUBNET
# DNS
sed -i".bak" '/nameserver/d' /etc/resolv.conf
echo "nameserver" $DNS >> /etc/resolv.conf
#Gateway
# Need to implment if Gateway is not present
route flush
route add default $GATEWAY
#route change default $GATEWAY
#/etc/rc.d/netif restart
#/etc/rc.d/routing restart
# DHCP
if [ $DHCP -eq 1 ]
then
echo ifconfig_hn0=\"DHCP\" >> /etc/rc.conf
echo Enabled
else
echo Disabled DHCP >> /var/log/messages
echo Disabled
fi
echo "Set IP-Injection Success"

View File

@ -19,16 +19,17 @@ int gethost(family, name, hostp)
struct netent *n;
u_32_t addr;
bzero(hostp, sizeof(*hostp));
if (!strcmp(name, "test.host.dots")) {
if (family == AF_INET) {
hostp->in4.s_addr = htonl(0xfedcba98);
}
#ifdef USE_INET6
if (family == AF_INET6) {
hostp->i6[0] = 0xfe80aa55;
hostp->i6[1] = 0x12345678;
hostp->i6[2] = 0x5a5aa5a5;
hostp->i6[3] = 0xfedcba98;
hostp->i6[0] = htonl(0xfe80aa55);
hostp->i6[1] = htonl(0x12345678);
hostp->i6[2] = htonl(0x5a5aa5a5);
hostp->i6[3] = htonl(0xfedcba98);
}
#endif
return 0;

View File

@ -153,7 +153,8 @@ printnat(np, opts)
} else if (np->in_redir & NAT_REWRITE) {
PRINTF(" -> src ");
if (np->in_nsrc.na_type == IPLT_DSTLIST) {
if (np->in_nsrc.na_atype == FRI_LOOKUP &&
np->in_nsrc.na_type == IPLT_DSTLIST) {
PRINTF("dstlist/");
if (np->in_nsrc.na_subtype == 0)
PRINTF("%d", np->in_nsrc.na_num);
@ -174,7 +175,8 @@ printnat(np, opts)
}
}
PRINTF(" dst ");
if (np->in_ndst.na_type == IPLT_DSTLIST) {
if (np->in_ndst.na_atype == FRI_LOOKUP &&
np->in_ndst.na_type == IPLT_DSTLIST) {
PRINTF("dstlist/");
if (np->in_ndst.na_subtype == 0)
PRINTF("%d", np->in_nsrc.na_num);

View File

@ -1020,12 +1020,13 @@ addr: pool '/' YY_NUMBER { pooled = 1;
yyexpectaddr = 0; }
;
ipaddr: IPFY_ANY { bzero(&($$), sizeof($$));
ipaddr: IPFY_ANY { memset(&($$), 0, sizeof($$));
$$.type = FRI_NORMAL;
$$.ifpos = -1;
yyexpectaddr = 0;
}
| hostname { $$.a = $1.adr;
| hostname { memset(&($$), 0, sizeof($$));
$$.a = $1.adr;
$$.f = $1.f;
if ($1.f == AF_INET6)
fill6bits(128, $$.m.i6);
@ -1038,7 +1039,8 @@ ipaddr: IPFY_ANY { bzero(&($$), sizeof($$));
| hostname { yyresetdict(); }
maskspace { yysetdict(maskwords);
yyexpectaddr = 2; }
ipmask { ntomask($1.f, $5, $$.m.i6);
ipmask { memset(&($$), 0, sizeof($$));
ntomask($1.f, $5, $$.m.i6);
$$.a = $1.adr;
$$.a.i6[0] &= $$.m.i6[0];
$$.a.i6[1] &= $$.m.i6[1];
@ -1060,7 +1062,8 @@ ipaddr: IPFY_ANY { bzero(&($$), sizeof($$));
yyresetdict();
yyexpectaddr = 0;
}
| '(' YY_STR ')' { $$.type = FRI_DYNAMIC;
| '(' YY_STR ')' { memset(&($$), 0, sizeof($$));
$$.type = FRI_DYNAMIC;
ifpflag = FRI_DYNAMIC;
$$.ifpos = addname(&fr, $2);
$$.lif = 0;
@ -1068,7 +1071,8 @@ ipaddr: IPFY_ANY { bzero(&($$), sizeof($$));
| '(' YY_STR ')' '/'
{ ifpflag = FRI_DYNAMIC; yysetdict(maskwords); }
maskopts
{ $$.type = ifpflag;
{ memset(&($$), 0, sizeof($$));
$$.type = ifpflag;
$$.ifpos = addname(&fr, $2);
$$.lif = 0;
if (frc->fr_family == AF_UNSPEC)
@ -1083,7 +1087,8 @@ ipaddr: IPFY_ANY { bzero(&($$), sizeof($$));
| '(' YY_STR ':' YY_NUMBER ')' '/'
{ ifpflag = FRI_DYNAMIC; yysetdict(maskwords); }
maskopts
{ $$.type = ifpflag;
{ memset(&($$), 0, sizeof($$));
$$.type = ifpflag;
$$.ifpos = addname(&fr, $2);
$$.lif = $4;
if (frc->fr_family == AF_UNSPEC)
@ -1142,30 +1147,35 @@ maskopts:
;
hostname:
ipv4 { $$.adr.in4 = $1;
ipv4 { memset(&($$), 0, sizeof($$));
$$.adr.in4 = $1;
if (frc->fr_family == AF_INET6)
YYERROR;
$$.f = AF_INET;
yyexpectaddr = 2;
}
| YY_NUMBER { if (frc->fr_family == AF_INET6)
| YY_NUMBER { memset(&($$), 0, sizeof($$));
if (frc->fr_family == AF_INET6)
YYERROR;
$$.adr.in4_addr = $1;
$$.f = AF_INET;
yyexpectaddr = 2;
}
| YY_HEX { if (frc->fr_family == AF_INET6)
| YY_HEX { memset(&($$), 0, sizeof($$));
if (frc->fr_family == AF_INET6)
YYERROR;
$$.adr.in4_addr = $1;
$$.f = AF_INET;
yyexpectaddr = 2;
}
| YY_STR { if (lookuphost($1, &$$.adr) == 0)
| YY_STR { memset(&($$), 0, sizeof($$));
if (lookuphost($1, &$$.adr) == 0)
$$.f = AF_INET;
free($1);
yyexpectaddr = 2;
}
| YY_IPV6 { if (frc->fr_family == AF_INET)
| YY_IPV6 { memset(&($$), 0, sizeof($$));
if (frc->fr_family == AF_INET)
YYERROR;
$$.adr = $1;
$$.f = AF_INET6;

View File

@ -871,9 +871,9 @@ mapport:
}
free($2);
if ($3.p1 < 0 || $3.p1 > 65535)
yyerror("invalid ICMP Id number");
yyerror("invalid 1st ICMP Id number");
if ($3.p2 < 0 || $3.p2 > 65535)
yyerror("invalid ICMP Id number");
yyerror("invalid 2nd ICMP Id number");
if (strcmp($2, "ipv6-icmp") == 0) {
nat->in_pr[0] = IPPROTO_ICMPV6;
nat->in_pr[1] = IPPROTO_ICMPV6;
@ -1058,7 +1058,7 @@ hash: IPNY_HASH { if (!(nat->in_flags & IPN_FILTER)) {
;
portstuff:
compare portspec { $$.pc = $1; $$.p1 = $2; }
compare portspec { $$.pc = $1; $$.p1 = $2; $$.p2 = 0; }
| portspec range portspec { $$.pc = $2; $$.p1 = $1; $$.p2 = $3; }
;
@ -1151,7 +1151,7 @@ proto: YY_NUMBER { $$ = $1;
| YY_STR { $$ = getproto($1);
free($1);
if ($$ == -1)
yyerror("unknwon protocol");
yyerror("unknown protocol");
if ($$ != IPPROTO_TCP &&
$$ != IPPROTO_UDP)
suggest_port = 0;
@ -1164,17 +1164,20 @@ hexnumber:
hostname:
YY_STR { i6addr_t addr;
int family;
bzero(&$$, sizeof($$));
if (gethost(AF_INET, $1,
#ifdef USE_INET6
if (nat->in_v[0] == 6)
family = AF_INET6;
else
#endif
family = AF_INET;
memset(&($$), 0, sizeof($$));
memset(&addr, 0, sizeof(addr));
$$.f = family;
if (gethost(family, $1,
&addr) == 0) {
$$.a = addr;
$$.f = AF_INET;
} else
if (gethost(AF_INET6, $1,
&addr) == 0) {
$$.a = addr;
$$.f = AF_INET6;
} else {
FPRINTF(stderr,
"Unknown host '%s'\n",
@ -1182,17 +1185,17 @@ hostname:
}
free($1);
}
| YY_NUMBER { bzero(&$$, sizeof($$));
| YY_NUMBER { memset(&($$), 0, sizeof($$));
$$.a.in4.s_addr = htonl($1);
if ($$.a.in4.s_addr != 0)
$$.f = AF_INET;
}
| ipv4 { $$ = $1; }
| YY_IPV6 { bzero(&$$, sizeof($$));
| YY_IPV6 { memset(&($$), 0, sizeof($$));
$$.a = $1;
$$.f = AF_INET6;
}
| YY_NUMBER YY_IPV6 { bzero(&$$, sizeof($$));
| YY_NUMBER YY_IPV6 { memset(&($$), 0, sizeof($$));
$$.a = $2;
$$.f = AF_INET6;
}
@ -1427,6 +1430,9 @@ setnatproto(p)
nat->in_flags |= IPN_UDP;
nat->in_flags &= ~IPN_TCP;
break;
#ifdef USE_INET6
case IPPROTO_ICMPV6 :
#endif
case IPPROTO_ICMP :
nat->in_flags &= ~IPN_TCPUDP;
if (!(nat->in_flags & IPN_ICMPQUERY) &&
@ -1506,7 +1512,7 @@ ipnat_addrule(fd, ioctlfunc, ptr)
printnat(ipn, opts);
if (opts & OPT_DEBUG)
binprint(ipn, sizeof(*ipn));
binprint(ipn, ipn->in_size);
if ((opts & OPT_ZERORULEST) != 0) {
if ((*ioctlfunc)(fd, add, (void *)&obj) == -1) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: vis.c,v 1.60 2013/02/21 16:21:20 joerg Exp $ */
/* $NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -57,7 +57,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: vis.c,v 1.60 2013/02/21 16:21:20 joerg Exp $");
__RCSID("$NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef __FBSDID
__FBSDID("$FreeBSD$");
@ -357,7 +357,7 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
ssize_t mbslength, maxolen;
_DIAGASSERT(mbdst != NULL);
_DIAGASSERT(mbsrc != NULL);
_DIAGASSERT(mbsrc != NULL || mblength == 0);
_DIAGASSERT(mbextra != NULL);
/*
@ -375,8 +375,6 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
/* Allocate space for the wide char strings */
psrc = pdst = extra = NULL;
if (!mblength)
mblength = strlen(mbsrc);
if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL)
return -1;
if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL)
@ -528,6 +526,15 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
free(psrc);
return error;
}
static int
istrsenvisxl(char *mbdst, size_t *dlen, const char *mbsrc,
int flags, const char *mbextra, int *cerr_ptr)
{
return istrsenvisx(mbdst, dlen, mbsrc,
mbsrc != NULL ? strlen(mbsrc) : 0, flags, mbextra, cerr_ptr);
}
#endif
#if !HAVE_SVIS
@ -571,13 +578,13 @@ snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra
int
strsvis(char *mbdst, const char *mbsrc, int flags, const char *mbextra)
{
return istrsenvisx(mbdst, NULL, mbsrc, 0, flags, mbextra, NULL);
return istrsenvisxl(mbdst, NULL, mbsrc, flags, mbextra, NULL);
}
int
strsnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags, const char *mbextra)
{
return istrsenvisx(mbdst, &dlen, mbsrc, 0, flags, mbextra, NULL);
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, mbextra, NULL);
}
int
@ -646,13 +653,13 @@ nvis(char *mbdst, size_t dlen, int c, int flags, int nextc)
int
strvis(char *mbdst, const char *mbsrc, int flags)
{
return istrsenvisx(mbdst, NULL, mbsrc, 0, flags, "", NULL);
return istrsenvisxl(mbdst, NULL, mbsrc, flags, "", NULL);
}
int
strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
{
return istrsenvisx(mbdst, &dlen, mbsrc, 0, flags, "", NULL);
return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
}
/*

View File

@ -300,6 +300,8 @@ void X86TargetLowering::resetOperationActions() {
setTruncStoreAction(MVT::i32, MVT::i8 , Expand);
setTruncStoreAction(MVT::i16, MVT::i8, Expand);
setTruncStoreAction(MVT::f64, MVT::f32, Expand);
// SETOEQ and SETUNE require checking two conditions.
setCondCodeAction(ISD::SETOEQ, MVT::f32, Expand);
setCondCodeAction(ISD::SETOEQ, MVT::f64, Expand);
@ -1011,8 +1013,6 @@ void X86TargetLowering::resetOperationActions() {
AddPromotedToType (ISD::SELECT, VT, MVT::v2i64);
}
setTruncStoreAction(MVT::f64, MVT::f32, Expand);
// Custom lower v2i64 and v2f64 selects.
setOperationAction(ISD::LOAD, MVT::v2f64, Legal);
setOperationAction(ISD::LOAD, MVT::v2i64, Legal);

View File

@ -0,0 +1,34 @@
Update the ARMv6 core clang targets to be an arm1176jzf-s. This brings us
in line with gcc in base as this makes llvm generate code for the armv6k
variant of the instruction set.
Introduced here: http://svnweb.freebsd.org/changeset/base/269387
Index: tools/clang/lib/Driver/ToolChain.cpp
===================================================================
--- tools/clang/lib/Driver/ToolChain.cpp (revision 269386)
+++ tools/clang/lib/Driver/ToolChain.cpp (revision 269387)
@@ -183,7 +183,8 @@ static const char *getARMTargetCPU(const ArgList &
MArch = Triple.getArchName();
}
- if (Triple.getOS() == llvm::Triple::NetBSD) {
+ if (Triple.getOS() == llvm::Triple::NetBSD ||
+ Triple.getOS() == llvm::Triple::FreeBSD) {
if (MArch == "armv6")
return "arm1176jzf-s";
}
Index: tools/clang/lib/Driver/Tools.cpp
===================================================================
--- tools/clang/lib/Driver/Tools.cpp (revision 269386)
+++ tools/clang/lib/Driver/Tools.cpp (revision 269387)
@@ -499,7 +499,8 @@ static std::string getARMTargetCPU(const ArgList &
MArch = Triple.getArchName();
}
- if (Triple.getOS() == llvm::Triple::NetBSD) {
+ if (Triple.getOS() == llvm::Triple::NetBSD ||
+ Triple.getOS() == llvm::Triple::FreeBSD) {
if (MArch == "armv6")
return "arm1176jzf-s";
}

View File

@ -1,7 +1,31 @@
Index: contrib/llvm/include/llvm/Support/ELF.h
Backport r197824, r213427 and r213960 from LLVM trunk:
r197824 | rdivacky | 2013-12-20 19:08:54 +0100 (Fri, 20 Dec 2013) | 2 lines
Implement initial-exec TLS for PPC32.
r213427 | hfinkel | 2014-07-19 01:29:49 +0200 (Sat, 19 Jul 2014) | 7 lines
[PowerPC] 32-bit ELF PIC support
This adds initial support for PPC32 ELF PIC (Position Independent Code; the
-fPIC variety), thus rectifying a long-standing deficiency in the PowerPC
backend.
Patch by Justin Hibbits!
r213960 | hfinkel | 2014-07-25 19:47:22 +0200 (Fri, 25 Jul 2014) | 3 lines
[PowerPC] Support TLS on PPC32/ELF
Patch by Justin Hibbits!
Introduced here: http://svnweb.freebsd.org/changeset/base/270147
Index: include/llvm/Support/ELF.h
===================================================================
--- contrib/llvm/include/llvm/Support/ELF.h (revision 270019)
+++ contrib/llvm/include/llvm/Support/ELF.h (working copy)
--- include/llvm/Support/ELF.h (revision 270019)
+++ include/llvm/Support/ELF.h (working copy)
@@ -437,6 +437,7 @@
R_PPC_GOT16_LO = 15,
R_PPC_GOT16_HI = 16,
@ -10,10 +34,10 @@ Index: contrib/llvm/include/llvm/Support/ELF.h
R_PPC_REL32 = 26,
R_PPC_TLS = 67,
R_PPC_DTPMOD32 = 68,
Index: contrib/llvm/lib/Object/ELF.cpp
Index: lib/Object/ELF.cpp
===================================================================
--- contrib/llvm/lib/Object/ELF.cpp (revision 270019)
+++ contrib/llvm/lib/Object/ELF.cpp (working copy)
--- lib/Object/ELF.cpp (revision 270019)
+++ lib/Object/ELF.cpp (working copy)
@@ -507,6 +507,7 @@
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT16_LO);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT16_HI);
@ -22,10 +46,10 @@ Index: contrib/llvm/lib/Object/ELF.cpp
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL32);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TLS);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPMOD32);
Index: contrib/llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
Index: lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
===================================================================
--- contrib/llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp (working copy)
--- lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp (revision 270019)
+++ lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp (working copy)
@@ -18,6 +18,7 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
@ -52,10 +76,10 @@ Index: contrib/llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
}
Index: contrib/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
Index: lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
===================================================================
--- contrib/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (working copy)
--- lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (revision 270019)
+++ lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (working copy)
@@ -64,7 +64,15 @@
llvm_unreachable("Unimplemented");
case PPC::fixup_ppc_br24:
@ -123,10 +147,10 @@ Index: contrib/llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
break;
}
break;
Index: contrib/llvm/lib/Target/PowerPC/PPC.h
Index: lib/Target/PowerPC/PPC.h
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPC.h (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPC.h (working copy)
--- lib/Target/PowerPC/PPC.h (revision 270019)
+++ lib/Target/PowerPC/PPC.h (working copy)
@@ -53,10 +53,11 @@
// PPC Specific MachineOperand flags.
MO_NO_FLAG,
@ -143,10 +167,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPC.h
/// MO_PIC_FLAG - If this bit is set, the symbol reference is relative to
/// the function's picbase, e.g. lo16(symbol-picbase).
Index: contrib/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
Index: lib/Target/PowerPC/PPCAsmPrinter.cpp
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp (working copy)
--- lib/Target/PowerPC/PPCAsmPrinter.cpp (revision 270019)
+++ lib/Target/PowerPC/PPCAsmPrinter.cpp (working copy)
@@ -19,6 +19,7 @@
#define DEBUG_TYPE "asmprinter"
#include "PPC.h"
@ -578,10 +602,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
}
}
Index: contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
Index: lib/Target/PowerPC/PPCFrameLowering.cpp
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp (working copy)
--- lib/Target/PowerPC/PPCFrameLowering.cpp (revision 270019)
+++ lib/Target/PowerPC/PPCFrameLowering.cpp (working copy)
@@ -299,7 +299,7 @@
const PPCRegisterInfo *RegInfo =
static_cast<const PPCRegisterInfo*>(MF.getTarget().getRegisterInfo());
@ -664,10 +688,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
// Allocate the frame index for the base pointer save area.
BPSI = MFI->CreateFixedObject(isPPC64? 8 : 4, BPOffset, true);
// Save the result.
Index: contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.h
Index: lib/Target/PowerPC/PPCFrameLowering.h
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.h (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.h (working copy)
--- lib/Target/PowerPC/PPCFrameLowering.h (revision 270019)
+++ lib/Target/PowerPC/PPCFrameLowering.h (working copy)
@@ -96,12 +96,14 @@
/// getBasePointerSaveOffset - Return the previous frame offset to save the
@ -685,10 +709,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.h
}
/// getLinkageSize - Return the size of the PowerPC ABI linkage area.
Index: contrib/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
Index: lib/Target/PowerPC/PPCISelDAGToDAG.cpp
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (working copy)
--- lib/Target/PowerPC/PPCISelDAGToDAG.cpp (revision 270019)
+++ lib/Target/PowerPC/PPCISelDAGToDAG.cpp (working copy)
@@ -15,6 +15,7 @@
#define DEBUG_TYPE "ppc-codegen"
#include "PPC.h"
@ -748,10 +772,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
case PPCISD::VADD_SPLAT: {
// This expands into one of three sequences, depending on whether
// the first operand is odd or even, positive or negative.
Index: contrib/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
Index: lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCISelLowering.cpp (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCISelLowering.cpp (working copy)
--- lib/Target/PowerPC/PPCISelLowering.cpp (revision 270019)
+++ lib/Target/PowerPC/PPCISelLowering.cpp (working copy)
@@ -670,6 +670,7 @@
case PPCISD::ADDIS_TOC_HA: return "PPCISD::ADDIS_TOC_HA";
case PPCISD::LD_TOC_L: return "PPCISD::LD_TOC_L";
@ -972,10 +996,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
MachineInstrBuilder MIB;
Index: contrib/llvm/lib/Target/PowerPC/PPCISelLowering.h
Index: lib/Target/PowerPC/PPCISelLowering.h
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCISelLowering.h (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCISelLowering.h (working copy)
--- lib/Target/PowerPC/PPCISelLowering.h (revision 270019)
+++ lib/Target/PowerPC/PPCISelLowering.h (working copy)
@@ -177,6 +177,12 @@
CR6SET,
CR6UNSET,
@ -989,10 +1013,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCISelLowering.h
/// G8RC = ADDIS_GOT_TPREL_HA %X2, Symbol - Used by the initial-exec
/// TLS model, produces an ADDIS8 instruction that adds the GOT
/// base to sym\@got\@tprel\@ha.
Index: contrib/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
Index: lib/Target/PowerPC/PPCInstr64Bit.td
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCInstr64Bit.td (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCInstr64Bit.td (working copy)
--- lib/Target/PowerPC/PPCInstr64Bit.td (revision 270019)
+++ lib/Target/PowerPC/PPCInstr64Bit.td (working copy)
@@ -36,10 +36,6 @@
def tocentry : Operand<iPTR> {
let MIOperandInfo = (ops i64imm:$imm);
@ -1004,10 +1028,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
def tlsreg : Operand<i64> {
let EncoderMethod = "getTLSRegEncoding";
let ParserMatchClass = PPCTLSRegOperand;
Index: contrib/llvm/lib/Target/PowerPC/PPCInstrInfo.td
Index: lib/Target/PowerPC/PPCInstrInfo.td
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCInstrInfo.td (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCInstrInfo.td (working copy)
--- lib/Target/PowerPC/PPCInstrInfo.td (revision 270019)
+++ lib/Target/PowerPC/PPCInstrInfo.td (working copy)
@@ -57,6 +57,9 @@
SDTCisPtrTy<0>, SDTCisVT<1, i32>
]>;
@ -1130,10 +1154,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCInstrInfo.td
// Standard shifts. These are represented separately from the real shifts above
// so that we can distinguish between shifts that allow 5-bit and 6-bit shift
// amounts.
Index: contrib/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
Index: lib/Target/PowerPC/PPCMCInstLower.cpp
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp (working copy)
--- lib/Target/PowerPC/PPCMCInstLower.cpp (revision 270019)
+++ lib/Target/PowerPC/PPCMCInstLower.cpp (working copy)
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
@ -1188,10 +1212,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
const MCExpr *Expr = MCSymbolRefExpr::Create(Symbol, RefKind, Ctx);
if (!MO.isJTI() && MO.getOffset())
Index: contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp
Index: lib/Target/PowerPC/PPCMachineFunctionInfo.cpp
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp (working copy)
--- lib/Target/PowerPC/PPCMachineFunctionInfo.cpp (revision 270019)
+++ lib/Target/PowerPC/PPCMachineFunctionInfo.cpp (working copy)
@@ -8,8 +8,16 @@
//===----------------------------------------------------------------------===//
@ -1209,10 +1233,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp
+ return MF.getContext().GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix())+
+ Twine(MF.getFunctionNumber())+"$poff");
+}
Index: contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h
Index: lib/Target/PowerPC/PPCMachineFunctionInfo.h
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h (working copy)
--- lib/Target/PowerPC/PPCMachineFunctionInfo.h (revision 270019)
+++ lib/Target/PowerPC/PPCMachineFunctionInfo.h (working copy)
@@ -92,6 +92,12 @@
/// 64-bit SVR4 ABI.
SmallVector<unsigned, 3> MustSaveCRs;
@ -1249,10 +1273,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h
};
} // end of namespace llvm
Index: contrib/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
Index: lib/Target/PowerPC/PPCRegisterInfo.cpp
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp (working copy)
--- lib/Target/PowerPC/PPCRegisterInfo.cpp (revision 270019)
+++ lib/Target/PowerPC/PPCRegisterInfo.cpp (working copy)
@@ -199,7 +199,16 @@
if (PPCFI->needsFP(MF))
Reserved.set(PPC::R31);
@ -1287,10 +1311,10 @@ Index: contrib/llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
}
bool PPCRegisterInfo::hasBasePointer(const MachineFunction &MF) const {
Index: contrib/llvm/lib/Target/PowerPC/PPCSubtarget.h
Index: lib/Target/PowerPC/PPCSubtarget.h
===================================================================
--- contrib/llvm/lib/Target/PowerPC/PPCSubtarget.h (revision 270019)
+++ contrib/llvm/lib/Target/PowerPC/PPCSubtarget.h (working copy)
--- lib/Target/PowerPC/PPCSubtarget.h (revision 270019)
+++ lib/Target/PowerPC/PPCSubtarget.h (working copy)
@@ -189,6 +189,9 @@
/// isBGQ - True if this is a BG/Q platform.
bool isBGQ() const { return TargetTriple.getVendor() == Triple::BGQ; }

View File

@ -1,14 +0,0 @@
Index: lib/Target/ARM/ARMInstrInfo.td
===================================================================
--- lib/Target/ARM/ARMInstrInfo.td (revision 271024)
+++ lib/Target/ARM/ARMInstrInfo.td (revision 271026)
@@ -3248,7 +3248,8 @@
def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR),
(SBCri GPR:$src, so_imm_not:$imm)>;
def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
- (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>;
+ (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
+ Requires<[IsARM, HasV6T2]>;
// Note: These are implemented in C++ code, because they have to generate
// ADD/SUBrs instructions, which use a complex pattern that a xform function

View File

@ -0,0 +1,78 @@
Pull in r216989 from upstream llvm trunk (by Renato Golin):
MFV: Only emit movw on ARMv6T2+
Pull in r216990 from upstream llvm trunk (by Renato Golin):
Missing test from r216989
Building for the FreeBSD default target ARMv6 was emitting movw ASM on certain
test cases (found building qmake4/5 for ARM). Don't do that, moreover, the AS
in base doesn't understand this instruction for this target. One would need
to use --integrated-as to get this to build if desired.
Introduced here: http://svnweb.freebsd.org/changeset/base/271025
Index: lib/Target/ARM/ARMInstrInfo.td
===================================================================
--- lib/Target/ARM/ARMInstrInfo.td
+++ lib/Target/ARM/ARMInstrInfo.td
@@ -3248,7 +3248,8 @@
def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR),
(SBCri GPR:$src, so_imm_not:$imm)>;
def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
- (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>;
+ (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
+ Requires<[IsARM, HasV6T2]>;
// Note: These are implemented in C++ code, because they have to generate
// ADD/SUBrs instructions, which use a complex pattern that a xform function
Index: test/CodeGen/ARM/carry.ll
===================================================================
--- test/CodeGen/ARM/carry.ll
+++ test/CodeGen/ARM/carry.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=arm | FileCheck %s
+; RUN: llc < %s -mtriple=armv6t2-eabi | FileCheck %s
define i64 @f1(i64 %a, i64 %b) {
; CHECK-LABEL: f1:
Index: test/CodeGen/ARM/pr18364-movw.ll
===================================================================
--- test/CodeGen/ARM/pr18364-movw.ll
+++ test/CodeGen/ARM/pr18364-movw.ll
@@ -0,0 +1,34 @@
+; RUN: llc < %s -mtriple=armv5te | FileCheck %s --check-prefix=V5
+; RUN: llc < %s -mtriple=armv6 | FileCheck %s --check-prefix=V6
+; RUN: llc < %s -mtriple=armv6t2 | FileCheck %s --check-prefix=V6T2
+; RUN: llc < %s -mtriple=armv7 | FileCheck %s --check-prefix=V7
+; PR18364
+
+define i64 @f() #0 {
+entry:
+; V5-NOT: movw
+; V6-NOT: movw
+; V6T2: movw
+; V7: movw
+ %y = alloca i64, align 8
+ %z = alloca i64, align 8
+ store i64 1, i64* %y, align 8
+ store i64 11579764786944, i64* %z, align 8
+ %0 = load i64* %y, align 8
+ %1 = load i64* %z, align 8
+ %sub = sub i64 %0, %1
+ ret i64 %sub
+}
+
+define i64 @g(i64 %a, i32 %b) #0 {
+entry:
+; V5-NOT: movw
+; V6-NOT: movw
+; V6T2: movw
+; V7: movw
+ %0 = mul i64 %a, 86400000
+ %mul = add i64 %0, -210866803200000
+ %conv = sext i32 %b to i64
+ %add = add nsw i64 %mul, %conv
+ ret i64 %add
+}

View File

@ -0,0 +1,68 @@
Pull in r200797 from upstream clang trunk (by Adrian Prantl):
Debug info: fix a crasher when when emitting debug info for
not-yet-completed templated types. getTypeSize() needs a complete type.
rdar://problem/15931354
Introduced here: http://svnweb.freebsd.org/changeset/base/271282
Index: tools/clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- tools/clang/lib/CodeGen/CGDebugInfo.cpp
+++ tools/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2251,9 +2251,10 @@ llvm::DICompositeType CGDebugInfo::CreateLimitedTy
if (T && (!T.isForwardDecl() || !RD->getDefinition()))
return T;
- // If this is just a forward declaration, construct an appropriately
- // marked node and just return it.
- if (!RD->getDefinition())
+ // If this is just a forward or incomplete declaration, construct an
+ // appropriately marked node and just return it.
+ const RecordDecl *D = RD->getDefinition();
+ if (!D || !D->isCompleteDefinition())
return getOrCreateRecordFwdDecl(Ty, RDContext);
uint64_t Size = CGM.getContext().getTypeSize(Ty);
Index: tools/clang/test/CodeGenCXX/debug-info-template-fwd.cpp
===================================================================
--- tools/clang/test/CodeGenCXX/debug-info-template-fwd.cpp
+++ tools/clang/test/CodeGenCXX/debug-info-template-fwd.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -g -emit-llvm -o - | FileCheck %s
+// This test is for a crash when emitting debug info for not-yet-completed types.
+// Test that we don't actually emit a forward decl for the offending class:
+// CHECK: [ DW_TAG_class_type ] [Derived<const __CFString, Foo>] {{.*}} [def]
+// rdar://problem/15931354
+typedef const struct __CFString * CFStringRef;
+template <class R> class Returner {};
+typedef const __CFString String;
+
+template <class A, class B> class Derived;
+
+template <class A, class B>
+class Base
+{
+ static Derived<A, B>* create();
+};
+
+template <class A, class B>
+class Derived : public Base<A, B> {
+public:
+ static void foo();
+};
+
+class Foo
+{
+ Foo();
+ static Returner<Base<String,Foo> > all();
+};
+
+Foo::Foo(){}
+
+Returner<Base<String,Foo> > Foo::all()
+{
+ Derived<String,Foo>::foo();
+ return Foo::all();
+}

View File

@ -0,0 +1,43 @@
Pull in r205331 from upstream clang trunk (by Adrian Prantl):
Debug info: fix a crash when emitting IndirectFieldDecls, which were
previously not handled at all.
rdar://problem/16348575
Introduced here: http://svnweb.freebsd.org/changeset/base/271432
Index: tools/clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- tools/clang/lib/CodeGen/CGDebugInfo.cpp (revision 205330)
+++ tools/clang/lib/CodeGen/CGDebugInfo.cpp (revision 205331)
@@ -1252,7 +1252,7 @@ CollectTemplateParams(const TemplateParameterList
V = CGM.GetAddrOfFunction(FD);
// Member data pointers have special handling too to compute the fixed
// offset within the object.
- if (isa<FieldDecl>(D)) {
+ if (isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) {
// These five lines (& possibly the above member function pointer
// handling) might be able to be refactored to use similar code in
// CodeGenModule::getMemberPointerConstant
Index: tools/clang/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
===================================================================
--- tools/clang/test/CodeGenCXX/debug-info-indirect-field-decl.cpp (revision 0)
+++ tools/clang/test/CodeGenCXX/debug-info-indirect-field-decl.cpp (revision 205331)
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+//
+// Test that indirect field decls are handled gracefully.
+// rdar://problem/16348575
+//
+template <class T, int T::*ptr> class Foo { };
+
+struct Bar {
+ int i1;
+ // CHECK: [ DW_TAG_member ] [line [[@LINE+1]], size 32, align 32, offset 32] [from _ZTSN3BarUt_E]
+ union {
+ // CHECK: [ DW_TAG_member ] [i2] [line [[@LINE+1]], size 32, align 32, offset 0] [from int]
+ int i2;
+ };
+};
+
+Foo<Bar, &Bar::i2> the_foo;

View File

@ -0,0 +1,64 @@
Pull in r217410 from upstream llvm trunk (by Bob Wilson):
Set trunc store action to Expand for all X86 targets.
When compiling without SSE2, isTruncStoreLegal(F64, F32) would return
Legal, whereas with SSE2 it would return Expand. And since the Target
doesn't seem to actually handle a truncstore for double -> float, it
would just output a store of a full double in the space for a float
hence overwriting other bits on the stack.
Patch by Luqman Aden!
This should fix clang -O0 on i386 assigning garbage to floats, in
certain scenarios.
Introduced here: http://svnweb.freebsd.org/changeset/base/271597
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp (revision 208032)
+++ lib/Target/X86/X86ISelLowering.cpp (working copy)
@@ -300,6 +300,8 @@ void X86TargetLowering::resetOperationActions() {
setTruncStoreAction(MVT::i32, MVT::i8 , Expand);
setTruncStoreAction(MVT::i16, MVT::i8, Expand);
+ setTruncStoreAction(MVT::f64, MVT::f32, Expand);
+
// SETOEQ and SETUNE require checking two conditions.
setCondCodeAction(ISD::SETOEQ, MVT::f32, Expand);
setCondCodeAction(ISD::SETOEQ, MVT::f64, Expand);
@@ -1011,8 +1013,6 @@ void X86TargetLowering::resetOperationActions() {
AddPromotedToType (ISD::SELECT, VT, MVT::v2i64);
}
- setTruncStoreAction(MVT::f64, MVT::f32, Expand);
-
// Custom lower v2i64 and v2f64 selects.
setOperationAction(ISD::LOAD, MVT::v2f64, Legal);
setOperationAction(ISD::LOAD, MVT::v2i64, Legal);
Index: test/CodeGen/X86/dont-trunc-store-double-to-float.ll
===================================================================
--- test/CodeGen/X86/dont-trunc-store-double-to-float.ll (revision 0)
+++ test/CodeGen/X86/dont-trunc-store-double-to-float.ll (working copy)
@@ -0,0 +1,20 @@
+; RUN: llc -march=x86 < %s | FileCheck %s
+
+; CHECK-LABEL: @bar
+; CHECK: movl $1074339512,
+; CHECK: movl $1374389535,
+; CHECK: movl $1078523331,
+define void @bar() unnamed_addr {
+entry-block:
+ %a = alloca double
+ %b = alloca float
+
+ store double 3.140000e+00, double* %a
+ %0 = load double* %a
+
+ %1 = fptrunc double %0 to float
+
+ store float %1, float* %b
+
+ ret void
+}

View File

@ -1241,7 +1241,7 @@ CollectTemplateParams(const TemplateParameterList *TPList,
V = CGM.GetAddrOfFunction(FD);
// Member data pointers have special handling too to compute the fixed
// offset within the object.
if (isa<FieldDecl>(D)) {
if (isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) {
// These five lines (& possibly the above member function pointer
// handling) might be able to be refactored to use similar code in
// CodeGenModule::getMemberPointerConstant
@ -2235,9 +2235,10 @@ llvm::DICompositeType CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
if (T && (!T.isForwardDecl() || !RD->getDefinition()))
return T;
// If this is just a forward declaration, construct an appropriately
// marked node and just return it.
if (!RD->getDefinition())
// If this is just a forward or incomplete declaration, construct an
// appropriately marked node and just return it.
const RecordDecl *D = RD->getDefinition();
if (!D || !D->isCompleteDefinition())
return getOrCreateRecordFwdDecl(Ty, RDContext);
uint64_t Size = CGM.getContext().getTypeSize(Ty);

View File

@ -0,0 +1,38 @@
$FreeBSD$
This document contains a collection of notes specific to the import
of the NetBSD test suite into head. These notes are built on the instructions
in the FreeBSD Subversion Primer that detail how to deal with vendor
branches and you are supposed to follow those:
http://www.freebsd.org/doc/en/articles/committers-guide/subversion-primer.html
The NetBSD test source code was originally obtained via NetBSD anoncvs as
described in the NetBSD handbook:
http://www.netbsd.org/docs/guide/en/chap-fetch.html#chap-fetch-cvs
and is imported into the NetBSD/tests vendor branch (see
base/vendor/NetBSD/tests/).
The process used to bootstrap the vendor tree was similar to the following:
/bin/sh
export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
cvs -z9 co -D "09/30/2014 20:45" -P src/tests
mv src/tests/* tests/dist/.
Please adjust the checkout date spec (the argument passed via -D) to match
the desired checkout time.
To merge the vendor branch into head do something like this:
cd .../base/head/contrib/netbsd-tests
svn merge --accept=postpone \
svn+ssh://svn.freebsd.org/base/vendor/NetBSD/tests/dist .
find . -name Makefile\* | xargs svn rm --force
and resolve any conflicts that may arise at this point.
Lastly, with the list of old and new files in this import, make sure
to update the reachover Makefiles accordingly.

View File

@ -0,0 +1,3 @@
a b c
1 2 3
x y z

View File

@ -0,0 +1,3 @@
1 a b c$
2 1 2 3$
3 x y z$

View File

@ -0,0 +1,59 @@
# $NetBSD: t_cat.sh,v 1.2 2012/03/27 17:57:02 jruoho Exp $
#
# Copyright (c) 2012 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Jukka Ruohonen.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
atf_test_case align
align_head() {
atf_set "descr" "Test that cat(1) aligns the output " \
"right with options '-be' (PR bin/4841)"
}
align_body() {
atf_check -s ignore -o file:$(atf_get_srcdir)/d_align.out \
-x "cat -be $(atf_get_srcdir)/d_align.in"
}
atf_test_case nonexistent
nonexistent_head() {
atf_set "descr" "Test that cat(1) doesn't return zero exit " \
"status for a nonexistent file (PR bin/3538)"
}
nonexistent_body() {
atf_check -s not-exit:0 -o empty -e not-empty \
-x "cat /some/name/that/does/not/exist"
}
atf_init_test_cases()
{
atf_add_test_case align
atf_add_test_case nonexistent
}

View File

@ -0,0 +1,294 @@
# $NetBSD: t_cp.sh,v 1.1 2012/03/17 16:33:10 jruoho Exp $
#
# Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
FILES="file file2 file3 link dir dir2 dirlink target"
cleanup() {
rm -fr ${FILES}
}
cp_compare() {
echo "Ensuring that $2 and $3 are identical"
cmp -s $2 $3 || atf_fail "$2 and $3 are different"
}
reset() {
cleanup
echo "I'm a file" > file
echo "I'm a file, 2" > file2
echo "I'm a file, 3" > file3
ln -s file link
mkdir dir
ln -s dir dirlink
}
atf_test_case file_to_file
file_to_file_head() {
atf_set "descr" "Checks the copy of a file to a file"
}
file_to_file_body() {
reset
file_to_file_simple
file_to_file_preserve
file_to_file_noflags
}
file_to_file_simple() {
rm -f file2
umask 022
chmod 777 file
atf_check -s eq:0 -o empty -e empty cp file file2
cp_compare file_to_file_simple file file2
if [ `stat -f "%Lp" file2` != "755" ]; then
atf_fail "new file not created with umask"
fi
chmod 644 file
chmod 777 file2
cp_compare file_to_file_simple file file2
if [ `stat -f "%Lp" file2` != "777" ]; then
atf_fail "existing files permissions not retained"
fi
}
file_to_file_preserve() {
rm file3
chmod 644 file
chflags nodump file
atf_check -s eq:0 -o empty -e empty cp -p file file3
finfo=`stat -f "%p%u%g%m%z%f" file`
f3info=`stat -f "%p%u%g%m%z%f" file3`
if [ $finfo != $f3info ]; then
atf_fail "attributes not preserved"
fi
}
file_to_file_noflags() {
rm file3
chmod 644 file
chflags nodump file
atf_check -s eq:0 -o empty -e empty cp -p -N file file3
finfo=`stat -f "%f" file`
f3info=`stat -f "%f" file3`
if [ $finfo = $f3info ]; then
atf_fail "-p -N preserved file flags"
fi
}
atf_test_case file_to_link
file_to_link_head() {
atf_set "descr" "Checks the copy of a file to a symbolic link"
}
file_to_link_body() {
reset
atf_check -s eq:0 -o empty -e empty cp file2 link
cp_compare file_to_link file file2
}
atf_test_case link_to_file
link_to_file_head() {
atf_set "descr" "Checks the copy of a symbolic link to a file"
}
link_to_file_body() {
reset
# file and link are identical (not copied).
atf_check -s eq:1 -o empty -e ignore cp link file
atf_check -s eq:0 -o empty -e empty cp link file2
cp_compare link_to_file file file2
}
atf_test_case file_over_link
file_over_link_head() {
atf_set "descr" "Checks the copy of a file to a symbolic link" \
"without following it"
}
file_over_link_body() {
reset
atf_check -s eq:0 -o empty -e empty cp -P file link
cp_compare file_over_link file link
}
atf_test_case link_over_file
link_over_file_head() {
atf_set "descr" "Checks the copy of a symbolic link to a file" \
"without following the former"
}
link_over_file_body() {
reset
atf_check -s eq:0 -o empty -e empty cp -P link file
if [ `readlink link` != `readlink file` ]; then
atf_fail "readlink link != readlink file"
fi
}
atf_test_case files_to_dir
files_to_dir_head() {
atf_set "descr" "Checks the copy of multiple files into a directory"
}
files_to_dir_body() {
reset
# can't copy multiple files to a file
atf_check -s eq:1 -o empty -e ignore cp file file2 file3
atf_check -s eq:0 -o empty -e empty cp file file2 link dir
cp_compare files_to_dir file "dir/file"
}
atf_test_case dir_to_file
dir_to_file_head() {
atf_set "descr" "Checks the copy of a directory onto a file, which" \
"should not work"
}
dir_to_file_body() {
reset
# can't copy a dir onto a file
atf_check -s eq:1 -o empty -e ignore cp dir file
atf_check -s eq:1 -o empty -e ignore cp -R dir file
}
atf_test_case file_to_linkdir
file_to_linkdir_head() {
atf_set "descr" "Checks the copy of a file to a symbolic link that" \
"points to a directory"
}
file_to_linkdir_body() {
reset
atf_check -s eq:0 -o empty -e empty cp file dirlink
cp_compare file_to_linkdir file "dir/file"
# overwrite the link
atf_check -s eq:0 -o empty -e empty cp -P file dirlink
atf_check -s eq:1 -o empty -e empty readlink dirlink
cp_compare file_to_linkdir file dirlink
}
atf_test_case linkdir_to_file
linkdir_to_file_head() {
atf_set "descr" "Checks the copy of a symbolic link that points to" \
"a directory onto a file"
}
linkdir_to_file_body() {
reset
# cannot copy a dir onto a file
atf_check -s eq:1 -o empty -e ignore cp dirlink file
# overwrite the link
atf_check -s eq:0 -o empty -e empty cp -P dirlink file
if [ `readlink file` != `readlink dirlink` ]; then
atf_fail "readlink link != readlink file"
fi
}
dir_to_dne_no_R() {
atf_check -s eq:1 -o empty -e ignore cp dir dir2
}
dir_to_dne() {
atf_check -s eq:0 -o empty -e empty cp -R dir dir2
cp_compare dir_to_dne "dir/file" "dir2/file"
readlink dir2/link >/dev/null
if [ $? -gt 0 ]; then
atf_fail "-R didn't copy a link as a link"
fi
}
dir_to_dir_H() {
dir_to_dir_setup
atf_check -s eq:0 -o empty -e empty cp -R dir dir2
chmod 777 dir
# copy a dir into a dir, only command-line links are followed
atf_check -s eq:0 -o empty -e empty cp -R -H dirlink dir2
cp_compare dir_to_dir_H "dir/file" "dir2/dirlink/file"
readlink dir2/dirlink/link >/dev/null
if [ $? -gt 0 ]; then
atf_fail "didn't copy a link as a link"
fi
# Created directories have the same mode as the corresponding
# source directory, unmodified by the process's umask.
if [ `stat -f "%Lp" dir2/dirlink` != "777" ]; then
atf_fail "-R modified dir perms with umask"
fi
}
dir_to_dir_L() {
dir_to_dir_setup
atf_check -s eq:0 -o empty -e empty cp -R dir dir2
atf_check -s eq:0 -o empty -e empty cp -R -H dirlink dir2
# copy a dir into a dir, following all links
atf_check -s eq:0 -o empty -e empty cp -R -H -L dirlink dir2/dirlink
cp_compare dir_to_dir_L "dir/file" "dir2/dirlink/dirlink/file"
# fail if -R -L copied a link as a link
atf_check -s eq:1 -o ignore -e empty readlink dir2/dirlink/dirlink/link
}
dir_to_dir_subdir_exists() {
# recursively copy a dir into another dir, with some subdirs already
# existing
cleanup
mkdir -p dir/1 dir/2 dir/3 target/2
echo "file" > dir/2/file
atf_check -s eq:0 -o empty -e empty cp -R dir/* target
cp_compare dir_to_dir_subdir_exists "dir/2/file" "target/2/file"
}
dir_to_dir_setup() {
reset
umask 077
cp -P file file2 file3 link dir
}
atf_test_case dir_to_dir
dir_to_dir_head() {
atf_set "descr" "Checks the copy of a directory onto another directory"
}
dir_to_dir_body() {
dir_to_dir_setup
dir_to_dne_no_R
dir_to_dne
dir_to_dir_H
dir_to_dir_L
dir_to_dir_subdir_exists
}
atf_init_test_cases()
{
atf_add_test_case file_to_file
atf_add_test_case file_to_link
atf_add_test_case link_to_file
atf_add_test_case file_over_link
atf_add_test_case link_over_file
atf_add_test_case files_to_dir
atf_add_test_case file_to_linkdir
atf_add_test_case linkdir_to_file
atf_add_test_case dir_to_file
atf_add_test_case dir_to_dir
}

View File

@ -0,0 +1,130 @@
# $NetBSD: t_dd.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $
#
# Copyright (c) 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
test_dd_length() {
result=$1
cmd=$2
set -- x `eval $cmd | wc -c`
res=$2
if [ x"$res" != x"$result" ]; then
atf_fail "Expected $result bytes of output, got $res: $cmd"
fi
}
atf_test_case length
length_head() {
# XXX The PR should be stored in a tag.
atf_set "descr" "Test for result messages accidentally pumped into" \
"the output file if the standard IO descriptors are" \
"closed. The last of the three following tests is" \
"the one expected to fail. (NetBSD PR bin/8521)"
}
length_body() {
test_dd_length 512 \
"dd if=/dev/zero of=/dev/fd/5 count=1 5>&1 >/dev/null 2>/dev/null"
test_dd_length 512 \
"dd if=/dev/zero of=/dev/fd/5 count=1 5>&1 >&- 2>/dev/null"
test_dd_length 512 \
"dd if=/dev/zero of=/dev/fd/5 count=1 5>&1 >&- 2>&-"
}
test_dd_io() {
res="`echo -n "$2" | eval $1`"
if [ x"$res" != x"$3" ]; then
atf_fail "Expected \"$3\", got \"$res\": $1"
fi
}
allbits1="\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"
ebcdicbits1="\000\001\002\003\067\055\056\057\026\005\045\013\014\015\016\017\020\021\022\023\074\075\062\046\030\031\077\047\034\035\036\037\100\132\177\173\133\154\120\175\115\135\134\116\153\140\113\141\360\361\362\363\364\365\366\367\370\371\172\136\114\176\156\157\174\301\302\303\304\305\306\307\310\311\321\322\323\324\325\326\327\330\331\342\343\344\345\346\347\350\351\255\340\275\232\155\171\201\202\203\204\205\206\207\210\211\221\222\223\224\225\226\227\230\231\242\243\244\245\246\247\250\251\300\117\320\137\007\040\041\042\043\044\025\006\027\050\051\052\053\054\011\012\033\060\061\032\063\064\065\066\010\070\071\072\073\004\024\076\341\101\102\103\104\105\106\107\110\111\121\122\123\124\125\126\127\130\131\142\143\144\145\146\147\150\151\160\161\162\163\164\165\166\167\170\200\212\213\214\215\216\217\220\152\233\234\235\236\237\240\252\253\254\112\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\241\276\277\312\313\314\315\316\317\332\333\334\335\336\337\352\353\354\355\356\357\372\373\374\375\376\377"
allvisbits=`echo -n "$allbits1" | unvis | vis`
ebcdicvisbits=`echo -n "$ebcdicbits1" | unvis | vis`
atf_test_case io
io_head() {
atf_set "descr" "This checks the combination of bs= with" \
"conv=ebcdic. Prior to revision 1.24 of dd's" \
"args.c, the conv option would be ignored."
}
io_body() {
test_dd_io "unvis | dd 2>/dev/null | vis" \
"$allvisbits" "$allvisbits"
test_dd_io "unvis | dd ibs=1 2>/dev/null | vis" \
"$allvisbits" "$allvisbits"
test_dd_io "unvis | dd obs=1 2>/dev/null | vis" \
"$allvisbits" "$allvisbits"
test_dd_io "unvis | dd bs=1 2>/dev/null | vis" \
"$allvisbits" "$allvisbits"
test_dd_io "unvis | dd conv=ebcdic 2>/dev/null | vis" \
"$allvisbits" "$ebcdicvisbits"
test_dd_io "unvis | dd conv=ebcdic ibs=512 2>/dev/null | vis" \
"$allvisbits" "$ebcdicvisbits"
test_dd_io "unvis | dd conv=ebcdic obs=512 2>/dev/null | vis" \
"$allvisbits" "$ebcdicvisbits"
test_dd_io "unvis | dd conv=ebcdic bs=512 2>/dev/null | vis" \
"$allvisbits" "$ebcdicvisbits"
test_dd_io "unvis | dd conv=ebcdic 2>/dev/null | vis" \
"$allvisbits" "$ebcdicvisbits"
test_dd_io "unvis | dd conv=ebcdic ibs=1 2>/dev/null | vis" \
"$allvisbits" "$ebcdicvisbits"
test_dd_io "unvis | dd conv=ebcdic obs=1 2>/dev/null | vis" \
"$allvisbits" "$ebcdicvisbits"
test_dd_io "unvis | dd conv=ebcdic bs=1 2>/dev/null | vis" \
"$allvisbits" "$ebcdicvisbits"
}
atf_test_case seek
seek_head() {
atf_set "descr" "Tests output file seeking"
}
seek_body() {
echo TEST1234 > testfile
atf_check -s exit:0 -e ignore \
dd if=/dev/zero of=testfile seek=1 bs=8k count=1
atf_check -s exit:0 -e ignore -o match:'^TEST1234$' dd if=testfile
eval $(stat -s testfile)
atf_check_equal $st_size $((2*8192))
echo -n TEST1234 > tf2
atf_check -s exit:0 -e ignore -x \
'dd bs=4 if=/dev/zero count=1 | tr \\0 \\n | dd of=tf2 bs=4 seek=1'
atf_check -s exit:0 -e ignore -o match:'^TEST$' dd if=tf2
eval $(stat -s tf2)
atf_check_equal $st_size 8
}
atf_init_test_cases()
{
atf_add_test_case length
atf_add_test_case io
atf_add_test_case seek
}

View File

@ -0,0 +1,218 @@
/* $NetBSD: getmntinfo.c,v 1.1 2012/03/17 16:33:11 jruoho Exp $ */
/*
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
#include <err.h>
#include <stdlib.h>
#include <string.h>
#define KB * 1024
#define MB * 1024 KB
#define GB * 1024 MB
static struct statvfs *getnewstatvfs(void);
static void other_variants(const struct statvfs *, const int *, int,
const int *, int);
static void setup_filer(void);
static void setup_ld0g(void);
static void setup_strpct(void);
static struct statvfs *allstatvfs;
static int sftotal, sfused;
struct statvfs *
getnewstatvfs(void)
{
if (sftotal == sfused) {
sftotal = sftotal ? sftotal * 2 : 1;
allstatvfs = realloc(allstatvfs,
sftotal * sizeof(struct statvfs));
if (allstatvfs == NULL)
err(EXIT_FAILURE, "realloc");
}
return (&allstatvfs[sfused++]);
}
void
other_variants(const struct statvfs *tmpl, const int *minfree, int minfreecnt,
const int *consumed, int consumedcnt)
{
int64_t total, used;
struct statvfs *sf;
int i, j;
for (i = 0; i < minfreecnt; i++)
for (j = 0; j < consumedcnt; j++) {
sf = getnewstatvfs();
*sf = *tmpl;
total = (int64_t)(u_long)sf->f_blocks * sf->f_bsize;
used = total * consumed[j] / 100;
sf->f_bfree = (total - used) / sf->f_bsize;
sf->f_bavail = (total * (100 - minfree[i]) / 100 -
used) / (int)sf->f_bsize;
sf->f_bresvd = sf->f_bfree - sf->f_bavail;
}
}
/*
* Parameter taken from:
* http://mail-index.NetBSD.org/tech-userlevel/2004/03/24/0001.html
*/
void
setup_filer(void)
{
static const struct statvfs tmpl = {
#define BSIZE 512
#define TOTAL 1147ULL GB
#define USED 132ULL MB
.f_bsize = BSIZE,
.f_frsize = BSIZE,
.f_blocks = TOTAL / BSIZE,
.f_bfree = (TOTAL - USED) / BSIZE,
.f_bavail = (TOTAL - USED) / BSIZE,
.f_bresvd = 0,
.f_mntfromname = "filer:/",
.f_mntonname = "/filer",
#undef USED
#undef TOTAL
#undef BSIZE
};
static const int minfree[] = { 0, 5, 10, 15, };
static const int consumed[] = { 0, 20, 60, 95, 100 };
*getnewstatvfs() = tmpl;
other_variants(&tmpl, minfree, sizeof(minfree) / sizeof(minfree[0]),
consumed, sizeof(consumed) / sizeof(consumed[0]));
}
/*
* Parameter taken from:
* http://mail-index.NetBSD.org/current-users/2004/03/01/0038.html
*/
void
setup_ld0g(void)
{
static const struct statvfs tmpl = {
#define BSIZE 4096 /* Guess */
#define TOTAL 1308726116ULL KB
#define USED 17901268ULL KB
#define AVAIL 1225388540ULL KB
.f_bsize = BSIZE,
.f_frsize = BSIZE,
.f_blocks = TOTAL / BSIZE,
.f_bfree = (TOTAL - USED) / BSIZE,
.f_bavail = AVAIL / BSIZE,
.f_bresvd = (TOTAL - USED) / BSIZE - AVAIL / BSIZE,
.f_mntfromname = "/dev/ld0g",
.f_mntonname = "/anon-root",
#undef AVAIL
#undef USED
#undef TOTAL
#undef BSIZE
};
static const int minfree[] = { 0, 5, 10, 15, };
static const int consumed[] = { 0, 20, 60, 95, 100 };
*getnewstatvfs() = tmpl;
other_variants(&tmpl, minfree, sizeof(minfree) / sizeof(minfree[0]),
consumed, sizeof(consumed) / sizeof(consumed[0]));
}
/*
* Test of strpct() with huge number.
*/
void
setup_strpct(void)
{
static const struct statvfs tmpl = {
#define BSIZE 4096 /* Guess */
#define TOTAL 0x4ffffffffULL KB
#define USED (TOTAL / 2)
#define AVAIL (TOTAL / 2)
.f_bsize = BSIZE,
.f_frsize = BSIZE,
.f_blocks = TOTAL / BSIZE,
.f_bfree = (TOTAL - USED) / BSIZE,
.f_bavail = AVAIL / BSIZE,
.f_bresvd = (TOTAL - USED) / BSIZE - AVAIL / BSIZE,
.f_mntfromname = "/dev/strpct",
.f_mntonname = "/strpct",
#undef AVAIL
#undef USED
#undef TOTAL
#undef BSIZE
};
*getnewstatvfs() = tmpl;
}
/*
* Parameter taken from:
* http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=23600
*/
static void
setup_pr23600(void)
{
static const struct statvfs tmpl = {
#define BSIZE 512
#define TOTAL 20971376ULL
#define USED 5719864ULL
#define AVAIL 15251512ULL
.f_bsize = BSIZE,
.f_frsize = BSIZE,
.f_blocks = TOTAL,
.f_bfree = TOTAL - USED,
.f_bavail = AVAIL,
.f_bresvd = TOTAL - USED - AVAIL,
.f_mntfromname = "/dev/wd0e",
.f_mntonname = "/mount/windows/C",
#undef AVAIL
#undef USED
#undef TOTAL
#undef BSIZE
};
*getnewstatvfs() = tmpl;
}
int
getmntinfo(struct statvfs **mntbuf, int flags)
{
setup_filer();
setup_ld0g();
setup_strpct();
setup_pr23600();
*mntbuf = allstatvfs;
return (sfused);
}

View File

@ -0,0 +1,148 @@
# $NetBSD: t_df.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $
#
# Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
atf_test_case normal
normal_head() {
atf_set "descr" "Checks that the output of df without flags is" \
"correct according to some already-known, sane" \
"output"
}
normal_body() {
cat >expout <<EOF
Filesystem 1K-blocks Used Avail %Cap Mounted on
filer:/ 1202716672 135168 1202581504 0% /filer
filer:/ 1202716672 0 1202716672 0% /filer
filer:/ 1202716672 240543334 962173337 20% /filer
filer:/ 1202716672 721630003 481086668 60% /filer
filer:/ 1202716672 1142580838 60135833 95% /filer
filer:/ 1202716672 1202716672 0 100% /filer
filer:/ 1202716672 0 1142580838 0% /filer
filer:/ 1202716672 240543334 902037504 21% /filer
filer:/ 1202716672 721630003 420950835 63% /filer
filer:/ 1202716672 1142580838 0 100% /filer
filer:/ 1202716672 1202716672 -60135833 105% /filer
filer:/ 1202716672 0 1082445004 0% /filer
filer:/ 1202716672 240543334 841901670 22% /filer
filer:/ 1202716672 721630003 360815001 66% /filer
filer:/ 1202716672 1142580838 -60135833 105% /filer
filer:/ 1202716672 1202716672 -120271667 111% /filer
filer:/ 1202716672 0 1022309171 0% /filer
filer:/ 1202716672 240543334 781765836 23% /filer
filer:/ 1202716672 721630003 300679168 70% /filer
filer:/ 1202716672 1142580838 -120271667 111% /filer
filer:/ 1202716672 1202716672 -180407500 117% /filer
/dev/ld0g 1308726116 17901268 1225388540 1% /anon-root
/dev/ld0g 1308726116 0 1308726116 0% /anon-root
/dev/ld0g 1308726116 261745224 1046980892 20% /anon-root
/dev/ld0g 1308726116 785235672 523490444 60% /anon-root
/dev/ld0g 1308726116 1243289812 65436304 95% /anon-root
/dev/ld0g 1308726116 1308726116 0 100% /anon-root
/dev/ld0g 1308726116 0 1243289808 0% /anon-root
/dev/ld0g 1308726116 261745224 981544584 21% /anon-root
/dev/ld0g 1308726116 785235672 458054140 63% /anon-root
/dev/ld0g 1308726116 1243289812 0 100% /anon-root
/dev/ld0g 1308726116 1308726116 -65436304 105% /anon-root
/dev/ld0g 1308726116 0 1177853504 0% /anon-root
/dev/ld0g 1308726116 261745224 916108280 22% /anon-root
/dev/ld0g 1308726116 785235672 392617832 66% /anon-root
/dev/ld0g 1308726116 1243289812 -65436304 105% /anon-root
/dev/ld0g 1308726116 1308726116 -130872608 111% /anon-root
/dev/ld0g 1308726116 0 1112417196 0% /anon-root
/dev/ld0g 1308726116 261745224 850671972 23% /anon-root
/dev/ld0g 1308726116 785235672 327181528 70% /anon-root
/dev/ld0g 1308726116 1243289812 -130872608 111% /anon-root
/dev/ld0g 1308726116 1308726116 -196308916 117% /anon-root
/dev/strpct 21474836476 10737418240 10737418236 50% /strpct
/dev/wd0e 10485688 2859932 7625756 27% /mount/windows/C
EOF
atf_check -s eq:0 -o file:expout -e empty \
-x "BLOCKSIZE=1k $(atf_get_srcdir)/h_df -n"
}
atf_test_case hflag
hflag_head() {
atf_set "descr" "Checks that the output of df is correct according" \
"to some already-known, sane output when using the" \
"human readable format"
}
hflag_body() {
cat >expout <<EOF
Filesystem Size Used Avail %Cap Mounted on
filer:/ 1.1T 132M 1.1T 0% /filer
filer:/ 1.1T 0B 1.1T 0% /filer
filer:/ 1.1T 229G 918G 20% /filer
filer:/ 1.1T 688G 459G 60% /filer
filer:/ 1.1T 1.1T 57G 95% /filer
filer:/ 1.1T 1.1T 0B 100% /filer
filer:/ 1.1T 0B 1.1T 0% /filer
filer:/ 1.1T 229G 860G 21% /filer
filer:/ 1.1T 688G 401G 63% /filer
filer:/ 1.1T 1.1T 0B 100% /filer
filer:/ 1.1T 1.1T -57G 105% /filer
filer:/ 1.1T 0B 1.0T 0% /filer
filer:/ 1.1T 229G 803G 22% /filer
filer:/ 1.1T 688G 344G 66% /filer
filer:/ 1.1T 1.1T -57G 105% /filer
filer:/ 1.1T 1.1T -115G 111% /filer
filer:/ 1.1T 0B 975G 0% /filer
filer:/ 1.1T 229G 746G 23% /filer
filer:/ 1.1T 688G 287G 70% /filer
filer:/ 1.1T 1.1T -115G 111% /filer
filer:/ 1.1T 1.1T -172G 117% /filer
/dev/ld0g 1.2T 17G 1.1T 1% /anon-root
/dev/ld0g 1.2T 0B 1.2T 0% /anon-root
/dev/ld0g 1.2T 250G 998G 20% /anon-root
/dev/ld0g 1.2T 749G 499G 60% /anon-root
/dev/ld0g 1.2T 1.2T 62G 95% /anon-root
/dev/ld0g 1.2T 1.2T 0B 100% /anon-root
/dev/ld0g 1.2T 0B 1.2T 0% /anon-root
/dev/ld0g 1.2T 250G 936G 21% /anon-root
/dev/ld0g 1.2T 749G 437G 63% /anon-root
/dev/ld0g 1.2T 1.2T 0B 100% /anon-root
/dev/ld0g 1.2T 1.2T -62G 105% /anon-root
/dev/ld0g 1.2T 0B 1.1T 0% /anon-root
/dev/ld0g 1.2T 250G 874G 22% /anon-root
/dev/ld0g 1.2T 749G 374G 66% /anon-root
/dev/ld0g 1.2T 1.2T -62G 105% /anon-root
/dev/ld0g 1.2T 1.2T -125G 111% /anon-root
/dev/ld0g 1.2T 0B 1.0T 0% /anon-root
/dev/ld0g 1.2T 250G 811G 23% /anon-root
/dev/ld0g 1.2T 749G 312G 70% /anon-root
/dev/ld0g 1.2T 1.2T -125G 111% /anon-root
/dev/ld0g 1.2T 1.2T -187G 117% /anon-root
/dev/strpct 20T 10T 10T 50% /strpct
/dev/wd0e 10G 2.7G 7.3G 27% /mount/windows/C
EOF
atf_check -s eq:0 -o file:expout -e empty \
-x "BLOCKSIZE=1k $(atf_get_srcdir)/h_df -hn"
}
atf_init_test_cases()
{
atf_add_test_case normal
atf_add_test_case hflag
}

View File

@ -0,0 +1,228 @@
# $NetBSD: t_expr.sh,v 1.3 2012/03/27 07:23:06 jruoho Exp $
#
# Copyright (c) 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The first arg will get eval'd so escape any meta characters
# The 2nd arg is an expected string/response from expr for that op.
test_expr() {
echo "Expression '${1}', expecting '${2}'"
res=`eval expr $1 2>&1`
if [ "$res" != "$2" ]; then
atf_fail "Expected $2, got $res from expression: " \
"`eval echo $1`"
fi
}
atf_test_case lang
lang_ops_head() {
atf_set "descr" "Test that expr(1) works with non-C LANG (PR bin/2486)"
}
lang_body() {
export LANG=nonexistent
atf_check -s exit:0 -o inline:"21\n" -e empty -x "expr 10 + 11"
export LANG=ru_RU.KOI8-R
atf_check -s exit:0 -o inline:"21\n" -e empty -x "expr 10 + 11"
}
atf_test_case overflow
overflow_head() {
atf_set "descr" "Test overflow cases"
}
overflow_body() {
test_expr '4611686018427387904 + 4611686018427387903' \
'9223372036854775807'
test_expr '4611686018427387904 + 4611686018427387904' \
"expr: integer overflow or underflow occurred for operation '4611686018427387904 + 4611686018427387904'"
test_expr '4611686018427387904 - -4611686018427387904' \
"expr: integer overflow or underflow occurred for operation '4611686018427387904 - -4611686018427387904'"
test_expr '-4611686018427387904 - 4611686018427387903' \
'-9223372036854775807'
test_expr '-4611686018427387904 - 4611686018427387905' \
"expr: integer overflow or underflow occurred for operation '-4611686018427387904 - 4611686018427387905'"
test_expr '-4611686018427387904 \* 1' '-4611686018427387904'
test_expr '-4611686018427387904 \* -1' '4611686018427387904'
test_expr '-4611686018427387904 \* 2' '-9223372036854775808'
test_expr '-4611686018427387904 \* 3' \
"expr: integer overflow or underflow occurred for operation '-4611686018427387904 * 3'"
test_expr '-4611686018427387904 \* -2' \
"expr: integer overflow or underflow occurred for operation '-4611686018427387904 * -2'"
test_expr '4611686018427387904 \* 1' '4611686018427387904'
test_expr '4611686018427387904 \* 2' \
"expr: integer overflow or underflow occurred for operation '4611686018427387904 * 2'"
test_expr '4611686018427387904 \* 3' \
"expr: integer overflow or underflow occurred for operation '4611686018427387904 * 3'"
}
atf_test_case gtkmm
gtkmm_head() {
atf_set "descr" "Test from gtk-- configure that cause problems on old expr"
}
gtkmm_body() {
test_expr '3 \> 3 \| 3 = 3 \& 4 \> 4 \| 3 = 3 \& 4 = 4 \& 5 \>= 5' '1'
test_expr '3 \> 3 \| 3 = 3 \& 4 \> 4 \| 3 = 3 \& 4 = 4 \& 5 \>= 6' '0'
test_expr '3 \> 3 \| 3 = 3 \& 4 \> 4 \| 3 = 3 \& 4 = 3 \& 5 \>= 5' '0'
test_expr '3 \> 3 \| 3 = 3 \& 4 \> 4 \| 3 = 2 \& 4 = 4 \& 5 \>= 5' '0'
test_expr '3 \> 2 \| 3 = 3 \& 4 \> 4 \| 3 = 3 \& 4 = 4 \& 5 \>= 6' '1'
test_expr '3 \> 3 \| 3 = 3 \& 4 \> 3 \| 3 = 3 \& 4 = 4 \& 5 \>= 5' '1'
}
atf_test_case colon_vs_math
colon_vs_math_head() {
atf_set "descr" "Basic precendence test with the : operator vs. math"
}
colon_vs_math_body() {
test_expr '2 : 4 / 2' '0'
test_expr '4 : 4 % 3' '1'
}
atf_test_case arithmetic_ops
arithmetic_ops_head() {
atf_set "descr" "Dangling arithemtic operator"
}
arithmetic_ops_body() {
test_expr '.java_wrapper : /' '0'
test_expr '4 : \*' '0'
test_expr '4 : +' '0'
test_expr '4 : -' '0'
test_expr '4 : /' '0'
test_expr '4 : %' '0'
}
atf_test_case basic_math
basic_math_head() {
atf_set "descr" "Basic math test"
}
basic_math_body() {
test_expr '2 + 4 \* 5' '22'
}
atf_test_case basic_functional
basic_functional_head() {
atf_set "descr" "Basic functional tests"
}
basic_functional_body() {
test_expr '2' '2'
test_expr '-4' '-4'
test_expr 'hello' 'hello'
}
atf_test_case compare_ops_precedence
compare_ops_precedence_head() {
atf_set "descr" "Compare operator precendence test"
}
compare_ops_precedence_body() {
test_expr '2 \> 1 \* 17' '0'
}
atf_test_case compare_ops
compare_ops_head() {
atf_set "descr" "Compare operator tests"
}
compare_ops_body() {
test_expr '2 \!= 5' '1'
test_expr '2 \!= 2' '0'
test_expr '2 \<= 3' '1'
test_expr '2 \<= 2' '1'
test_expr '2 \<= 1' '0'
test_expr '2 \< 3' '1'
test_expr '2 \< 2' '0'
test_expr '2 = 2' '1'
test_expr '2 = 4' '0'
test_expr '2 \>= 1' '1'
test_expr '2 \>= 2' '1'
test_expr '2 \>= 3' '0'
test_expr '2 \> 1' '1'
test_expr '2 \> 2' '0'
}
atf_test_case multiply
multiply_head() {
atf_set "descr" "Test the multiply operator (PR bin/12838)"
}
multiply_body() {
test_expr '1 \* -1' '-1'
test_expr '2 \> 1 \* 17' '0'
}
atf_test_case negative
negative_head() {
atf_set "descr" "Test the additive inverse"
}
negative_body() {
test_expr '-1 + 5' '4'
test_expr '- 1 + 5' 'expr: syntax error'
test_expr '5 + -1' '4'
test_expr '5 + - 1' 'expr: syntax error'
test_expr '1 - -5' '6'
}
atf_test_case math_precedence
math_precedence_head() {
atf_set "descr" "More complex math test for precedence"
}
math_precedence_body() {
test_expr '-3 + -1 \* 4 + 3 / -6' '-7'
}
atf_test_case precedence
precedence_head() {
atf_set "descr" "Test precedence"
}
precedence_body() {
# This is messy but the shell escapes cause that
test_expr 'X1/2/3 : X\\\(.\*[^/]\\\)//\*[^/][^/]\*/\*$ \| . : \\\(.\\\)' '1/2'
}
atf_test_case regex
regex_head() {
atf_set "descr" "Test proper () returning \1 from a regex"
}
regex_body() {
# This is messy but the shell escapes cause that
test_expr '1/2 : .\*/\\\(.\*\\\)' '2'
}
atf_init_test_cases()
{
atf_add_test_case lang
atf_add_test_case overflow
atf_add_test_case gtkmm
atf_add_test_case colon_vs_math
atf_add_test_case arithmetic_ops
atf_add_test_case basic_math
atf_add_test_case basic_functional
atf_add_test_case compare_ops_precedence
atf_add_test_case compare_ops
atf_add_test_case multiply
atf_add_test_case negative
atf_add_test_case math_precedence
atf_add_test_case precedence
atf_add_test_case regex
}

View File

@ -0,0 +1,54 @@
# $NetBSD: t_pax.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $
#
# Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
atf_test_case append
append_head() {
atf_set "descr" "Ensure that appending a file to an archive" \
"produces the same results as if the file" \
"had been there during the archive's creation"
}
append_body() {
touch foo bar
# store both foo and bar into file1.tar
atf_check -s eq:0 -o empty -e empty \
pax -w -b 512 -x ustar -f file1.tar foo bar
# store foo into file2.tar, then append bar to file2.tar
atf_check -s eq:0 -o empty -e empty \
pax -w -b 512 -x ustar -f file2.tar foo
atf_check -s eq:0 -o empty -e empty \
pax -w -b 512 -x ustar -f file2.tar -a bar
# ensure that file1.tar and file2.tar are equal
atf_check -s eq:0 -o empty -e empty cmp file1.tar file2.tar
}
atf_init_test_cases()
{
atf_add_test_case append
}

View File

@ -0,0 +1,123 @@
# $NetBSD: keywords,v 1.2 2014/01/16 04:16:32 mlelstv Exp $
#
# Table of keywords for use with ps "-o" option.
#
# The first column (keyword) is the name of a keyword.
#
# The second column (header) is the default column header associated
# with the keyword, except if the keyword is an alias, in which case the
# second column is the name of another keyword.
#
# The third column (flag) may be blank, "LJUST", or "ALIAS". "ALIAS"
# means that the keyword is an alias. "LJUST" means that the keyword
# should be displayed in a left-justified column. The default is that
# the keyword should be displayed in a right-justified column.
#
# keyword header flag
#
ktracep KTRACEP
nwchan WCHAN
p_ru P_RU
paddr PADDR
rlink RLINK
%cpu %CPU
%mem %MEM
acflag ACFLG
acflg acflag ALIAS
args command ALIAS
blocked sigmask ALIAS
caught sigcatch ALIAS
comm COMMAND LJUST
command COMMAND LJUST
cpu CPU
cputime time ALIAS
ctime CTIME
egid EGID
egroup EGROUP LJUST
etime ELAPSED
euid EUID
euser EUSER LJUST
f F
flags f ALIAS
gid GID
group GROUP LJUST
groupnames GROUPNAMES LJUST
groups GROUPS LJUST
holdcnt HOLDCNT
ignored sigignore ALIAS
inblk INBLK
inblock inblk ALIAS
jobc JOBC
ktrace KTRACE
laddr LADDR
lid LID
lim LIM
login LOGIN LJUST
logname login ALIAS
lstart STARTED LJUST
lstate STAT LJUST
ltime LTIME
majflt MAJFLT
minflt MINFLT
msgrcv MSGRCV
msgsnd MSGSND
ni nice ALIAS
nice NI
nivcsw NIVCSW
nlwp NLWP
nsignals nsigs ALIAS
nsigs NSIGS
nswap NSWAP
nvcsw NVCSW
oublk OUBLK
oublock oublk ALIAS
pagein PAGEIN
pcpu %cpu ALIAS
pending sig ALIAS
pgid PGID
pid PID
pmem %mem ALIAS
ppid PPID
pri PRI
re RE
rgid RGID
rgroup RGROUP LJUST
rlwp RLWP
rss RSS
rssize rsz ALIAS
rsz RSZ
ruid RUID
ruser RUSER LJUST
sess SESS
sid SID
sig PENDING
sigcatch CAUGHT
sigignore IGNORED
sigmask BLOCKED
sl SL
start STARTED
stat state ALIAS
state STAT LJUST
stime STIME
svgid SVGID
svgroup SVGROUP LJUST
svuid SVUID
svuser SVUSER LJUST
tdev TDEV
time TIME
tpgid TPGID
tsess TSESS
tsiz TSIZ
tt TTY LJUST
tty TTY LJUST
uaddr UADDR
ucomm UCOMM LJUST
uid UID
upr UPR
user USER LJUST
usrpri upr ALIAS
utime UTIME
vsize vsz ALIAS
vsz VSZ
wchan WCHAN LJUST
xstat XSTAT

View File

@ -0,0 +1,404 @@
# $NetBSD: t_ps.sh,v 1.2 2014/01/16 04:16:32 mlelstv Exp $
#
# Copyright (c) 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# the implementation of "ps" to test
: ${TEST_PS:="ps"}
# tab and newline characters
tab="$(printf '\t')"
# nl="$(printf '\n')" doesn't work
nl='
'
#
# Parse the "keywords" file into a load of shell variables
#
setup_keywords()
{
# Set variables representing the header text
# for all normal keywords (except aliases), and
# for regular expressions to match the text in left- or
# right-justified columns.
# For example, head_text_p_cpu="%CPU" head_regexp_p_cpu=" *%CPU".
while read keyword heading flag
do
case "$keyword" in
''|\#*) continue
;;
esac
[ x"$flag" = x"ALIAS" ] && continue
kvar="${keyword}"
case "${keyword}" in
%*) kvar="p_${keyword#%}"
;;
esac
eval head_text_${kvar}=\'"${heading}"\'
case "${flag}" in
'') # right justified
eval head_regexp_${kvar}=\'" *${heading}"\'
;;
LJUST) # left justified
eval head_regexp_${kvar}=\'"${heading} *"\'
;;
*) atf_fail "unknown flag in keywords"
;;
esac
done <"$(atf_get_srcdir)/keywords"
# Now do the aliases.
while read keyword heading flag
do
case "$keyword" in
''|\#*) continue
;;
esac
[ x"$flag" != x"ALIAS" ] && continue
kvar="${keyword}"
avar="${heading}"
case "${keyword}" in
%*) kvar="p_${keyword#%}"
;;
esac
case "${heading}" in
%*) avar="p_${heading#%}"
;;
esac
eval head_text_${kvar}=\"\$head_text_${avar}\"
eval head_regexp_${kvar}=\"\$head_regexp_${avar}\"
done <"$(atf_get_srcdir)/keywords"
# default sets of keywords
default_keywords='pid tty stat time command'
j_keywords='user pid ppid pgid sess jobc state tt time command'
l_keywords='uid pid ppid cpu pri nice vsz rss wchan state tt time command'
s_keywords='uid pid ppid cpu lid nlwp pri nice vsz rss wchan lstate tt ltime command'
u_keywords='user pid %cpu %mem vsz rss tt state start time command'
v_keywords='pid state time sl re pagein vsz rss lim tsiz %cpu %mem command'
}
# Convert a list of keywords like "pid comm" to a regexp
# like " *PID COMMAND *"
heading_keywords_to_regexp()
{
local keywords="$1"
local regexp
regexp="$(echo "$keywords" | \
sed -E -e 's/\%/p_/g' -e 's/(^| )/\1\$head_regexp_/g')"
eval regexp=\""${regexp}"\"
regexp="^${regexp}\$"
echo "$regexp"
}
#
# Check that a string matches a regexp; use the specified id
# in error or success messages.
#
check_regexp() {
local id="$1" string="$2" regexp="$3"
if ! expr "$string" : "$regexp" >/dev/null
then
atf_fail "${id}: expected [${regexp}], got [${string}]"
false
fi
}
#
# Run "ps $args -p $$"; check that only one line is printed,
# without a preceding header line.
#
check_no_heading_line()
{
local args="$1"
local output="$(eval "${TEST_PS} $args -p $$")"
case "$output" in
*"$nl"*)
local firstline="${output%%${nl}*}"
atf_fail "check_no_heading_line [$args] got [$firstline]"
;;
*)
;;
esac
}
#
# Run "ps $args"; check that the heading matches the expected regexp.
#
check_heading_regexp()
{
args="$1"
regexp="$2"
actual="$( eval "${TEST_PS} $args" | sed -e 1q )"
check_regexp "heading [$args]" "${actual}" "${regexp}"
}
#
# Run "ps $args"; check that the heading matches a regexp constructed
# from the specified keywords.
#
check_heading_keywords()
{
args="$1"
keywords="$2"
check_heading_regexp "$args" "$(heading_keywords_to_regexp "$keywords")"
}
#
# Try several variations on "ps $flag", "ps -$flag", etc.,
# and check that the heading always has the correct keywords.
#
check_heading_variations()
{
flag="$1"
keywords="$2"
for args in "$flag" "-$flag" "-$flag$flag -$flag"; do
check_heading_keywords "$args" "$keywords"
done
}
atf_test_case default_columns
default_columns_head()
{
atf_set "descr" "Checks that the default set of columns is correct" \
"and also check that the columns printed by the -j," \
"-l, -s, -u and -v flags alone are correct"
}
default_columns_body()
{
setup_keywords
check_heading_keywords '' "$default_keywords"
check_heading_variations 'j' "$j_keywords"
check_heading_variations 'l' "$l_keywords"
check_heading_variations 's' "$s_keywords"
check_heading_variations 'u' "$u_keywords"
check_heading_variations 'v' "$v_keywords"
}
atf_test_case minus_O
minus_O_head()
{
atf_set "descr" "Checks that 'ps -O foo' inserts columns just after" \
"the pid column"
}
minus_O_body()
{
setup_keywords
check_heading_keywords '-O %cpu,%mem' \
"$(echo "${default_keywords}" | sed -e 's/pid/pid %cpu %mem/')"
check_heading_keywords '-O %cpu -O %mem' \
"$(echo "${default_keywords}" | sed -e 's/pid/pid %cpu %mem/')"
check_heading_keywords '-O%cpu -O%mem' \
"$(echo "${default_keywords}" | sed -e 's/pid/pid %cpu %mem/')"
}
atf_test_case minus_o
minus_o_head()
{
atf_set "descr" "Checks simple cases of 'ps -o foo' to control which" \
"columns are printed; this does not test header" \
"overriding via 'ps -o foo=BAR'"
}
minus_o_body()
{
setup_keywords
# Keywords for "-o name" override the default display
check_heading_keywords '-o pid,%cpu,%mem' \
"pid %cpu %mem"
check_heading_keywords '-o pid -o %cpu,%mem' \
"pid %cpu %mem"
check_heading_keywords '-opid -o %cpu,%mem' \
"pid %cpu %mem"
# Space works like comma
check_heading_keywords '-opid -o "%cpu %mem"' \
"pid %cpu %mem"
# Check missing pid
check_heading_keywords '-o comm' \
"comm"
# Check pid present but not first
check_heading_keywords '-o comm,pid' \
"comm pid"
}
atf_test_case override_heading_simple
override_heading_simple_head()
{
atf_set "descr" "Tests simple uses of header overriding via" \
"'ps -o foo=BAR'. This does not test columns " \
"with null headings, or headings with embedded" \
"space, ',' or '='."
}
override_heading_simple_body()
{
setup_keywords
check_heading_regexp '-o pid=PPP -o comm' \
'^ *PPP '"${head_text_comm}"'$' # no trailing space
check_heading_regexp '-o pid=PPP -o comm=CCC' \
'^ *PPP CCC$'
check_heading_regexp '-o pid,comm=CCC' \
'^'"${head_regexp_pid}"' CCC$'
check_heading_regexp '-o pid -o comm=CCC' \
'^'"${head_regexp_pid}"' CCC$'
# Check missing pid
check_heading_regexp '-o comm=CCC' \
'^CCC$'
# Check pid present but not first
check_heading_regexp '-o comm=CCC -o pid=PPP' \
'^CCC *PPP$'
check_heading_regexp '-o comm,pid=PPP' \
'^'"${head_regexp_comm}"' *PPP$'
}
atf_test_case override_heading_embedded_specials
override_heading_embedded_specials_head()
{
atf_set "descr" "Tests header overriding with embedded space," \
"',' or '='. Everything after the first '='" \
"is part of the heading."
}
override_heading_embedded_specials_body()
{
setup_keywords
# Check embedded "," or "=" in override header.
check_heading_regexp '-o comm,pid==' \
'^'"${head_regexp_comm}"' *=$'
check_heading_regexp '-o comm,pid=,' \
'^'"${head_regexp_comm}"' *,$'
check_heading_regexp '-o pid=PPP,comm' \
'^ *PPP,comm$' # not like '-o pid=PPP -o comm'
check_heading_regexp '-o pid=PPP,comm=CCC' \
'^ *PPP,comm=CCC$' # not like '-o pid=PPP -o comm=CCC'
check_heading_regexp '-o comm,pid=PPP,QQQ' \
'^'"${head_regexp_comm}"' *PPP,QQQ$'
check_heading_regexp '-o comm,pid=ppid,tty=state' \
'^'"${head_regexp_comm}"' *ppid,tty=state$'
# Check embedded space or tab in override header.
check_heading_regexp '-o comm,pid="PPP QQQ"' \
'^'"${head_regexp_comm}"' *PPP QQQ$'
check_heading_regexp '-o comm,pid="PPP${tab}QQQ"' \
'^'"${head_regexp_comm}"' *PPP'"${tab}"'QQQ$'
}
atf_test_case override_heading_some_null
override_heading_some_null_head()
{
atf_set "descr" "Tests simple uses of null column headings" \
"overriding via 'ps -o foo=BAR -o baz='. This" \
"does not test the case where all columns have" \
"null headings."
}
override_heading_some_null_body()
{
setup_keywords
check_heading_regexp '-o pid=PPP -o comm=' \
'^ *PPP *$'
check_heading_regexp '-o pid= -o comm=CCC' \
'^ * CCC$'
check_heading_regexp '-o pid -o comm=' \
'^'"${head_regexp_pid}"' *$'
# Check missing pid
check_heading_regexp '-o ppid= -o comm=CCC' \
'^ * CCC$'
check_heading_regexp '-o ppid=PPP -o comm=' \
'^ *PPP *$'
# Check pid present but not first
check_heading_regexp '-o comm= -o pid=PPP' \
'^ * PPP$'
check_heading_regexp '-o comm,pid=' \
'^'"${head_regexp_comm}"' *$'
# A field with a null custom heading retains a minimum width
# derived from the default heading. This does not apply
# to a field with a very short (non-null) custom heading.
#
# We choose "holdcnt" as a column whose width is likely to be
# determined entirely by the header width, because the values
# are likely to be very small.
check_heading_regexp '-o holdcnt -o holdcnt -o holdcnt' \
'^HOLDCNT HOLDCNT HOLDCNT$'
check_heading_regexp '-o holdcnt -o holdcnt= -o holdcnt' \
'^HOLDCNT HOLDCNT$'
check_heading_regexp '-o holdcnt -o holdcnt=HH -o holdcnt' \
'^HOLDCNT HH HOLDCNT$'
}
atf_test_case override_heading_all_null
override_heading_all_null_head()
{
atf_set "descr" "Tests the use of 'ps -o foo= -o bar=' (with a" \
"null heading for every column). The heading" \
"should not be printed at all in this case."
}
override_heading_all_null_body()
{
setup_keywords
# A heading with a space is not a null heading,
# so should not be suppressed
check_heading_regexp '-o comm=" "' \
'^ *$'
# Null headings should be suppressed
check_no_heading_line '-o pid= -o comm='
check_no_heading_line '-o pid= -o comm='
# Check missing pid
check_no_heading_line '-o ppid='
check_no_heading_line '-o comm='
check_no_heading_line '-o command='
check_no_heading_line '-o ppid= -o comm='
check_no_heading_line '-o comm= -o ppid='
# Check pid present but not first
check_no_heading_line '-o comm= -o pid='
check_no_heading_line '-o ppid= -o pid= -o command='
}
atf_test_case duplicate_column
duplicate_column_head()
{
atf_set "descr" "Tests the use of -o options to display the" \
"same column more than once"
}
duplicate_column_body()
{
setup_keywords
# two custom headers
check_heading_regexp '-o pid=PPP -o pid=QQQ' \
'^ *PPP *QQQ$'
# one custom header, before and after default header
check_heading_regexp '-o pid=PPP -o pid' \
'^ *PPP '"${head_regexp_pid}"'$'
check_heading_regexp '-o pid -o pid=QQQ' \
'^'"${head_regexp_pid}"' *QQQ$'
# custom headers both before and after default header
check_heading_regexp '-o pid=PPP -o pid -o pid=QQQ' \
'^ *PPP '"${head_regexp_pid}"' *QQQ$'
}
atf_init_test_cases() {
atf_add_test_case default_columns
atf_add_test_case minus_O
atf_add_test_case minus_o
atf_add_test_case override_heading_simple
atf_add_test_case override_heading_embedded_specials
atf_add_test_case override_heading_some_null
atf_add_test_case override_heading_all_null
atf_add_test_case duplicate_column
}

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