aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rwxr-xr-xusr.bin/diff/tests/diff_test.sh22
-rw-r--r--usr.bin/du/Makefile4
-rw-r--r--usr.bin/du/du.c3
-rw-r--r--usr.bin/du/tests/Makefile5
-rwxr-xr-xusr.bin/du/tests/du_test.sh153
-rw-r--r--usr.bin/finger/finger.c1
-rw-r--r--usr.bin/fstat/fstat.c2
-rw-r--r--usr.bin/hexdump/display.c4
-rw-r--r--usr.bin/stat/Makefile4
-rw-r--r--usr.bin/stat/stat.110
-rw-r--r--usr.bin/stat/tests/Makefile6
-rwxr-xr-xusr.bin/stat/tests/readlink_test.sh73
-rwxr-xr-xusr.bin/stat/tests/stat_test.sh235
-rw-r--r--usr.bin/top/machine.c8
-rw-r--r--usr.bin/top/top.local.15
-rw-r--r--usr.bin/truss/syscall.h2
-rw-r--r--usr.bin/truss/syscalls.c29
-rw-r--r--usr.bin/xohtml/Makefile31
-rwxr-xr-xusr.bin/xohtml/xohtml.sh79
-rw-r--r--usr.bin/xolint/Makefile13
-rw-r--r--usr.bin/xopo/Makefile21
-rw-r--r--usr.bin/yes/yes.c35
22 files changed, 719 insertions, 26 deletions
diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh
index 62ca8277c5f3..e5566b134cc3 100755
--- a/usr.bin/diff/tests/diff_test.sh
+++ b/usr.bin/diff/tests/diff_test.sh
@@ -6,6 +6,7 @@ atf_test_case header
atf_test_case header_ns
atf_test_case ifdef
atf_test_case group_format
+atf_test_case side_by_side
simple_body()
{
@@ -88,6 +89,26 @@ group_format_body()
' "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in"
}
+side_by_side_body()
+{
+ atf_expect_fail "--side-by-side not currently implemented (bug # 219933)"
+
+ atf_check -o save:A printf "A\nB\nC\n"
+ atf_check -o save:B printf "D\nB\nE\n"
+
+ exp_output="A[[:space:]]+|[[:space:]]+D\nB[[:space:]]+B\nC[[:space:]]+|[[:space:]]+E"
+ exp_output_suppressed="A[[:space:]]+|[[:space:]]+D\nC[[:space:]]+|[[:space:]]+E"
+
+ atf_check -o match:"$exp_output" -s exit:1 \
+ diff --side-by-side A B
+ atf_check -o match:"$exp_output" -s exit:1 \
+ diff -y A B
+ atf_check -o match:"$exp_output_suppressed" -s exit:1 \
+ diff -y --suppress-common-lines A B
+ atf_check -o match:"$exp_output_suppressed" -s exit:1 \
+ diff -W 65 -y --suppress-common-lines A B
+}
+
atf_init_test_cases()
{
atf_add_test_case simple
@@ -96,4 +117,5 @@ atf_init_test_cases()
atf_add_test_case header_ns
atf_add_test_case ifdef
atf_add_test_case group_format
+ atf_add_test_case side_by_side
}
diff --git a/usr.bin/du/Makefile b/usr.bin/du/Makefile
index 9f96ec657a7e..4340812457d8 100644
--- a/usr.bin/du/Makefile
+++ b/usr.bin/du/Makefile
@@ -1,7 +1,11 @@
# @(#)Makefile 8.1 (Berkeley) 6/6/93
# $FreeBSD$
+.include <src.opts.mk>
+
PROG= du
LIBADD= util
+SUBDIR.${MK_TESTS}+= tests
+
.include <bsd.prog.mk>
diff --git a/usr.bin/du/du.c b/usr.bin/du/du.c
index 71be71fd497a..6affc12ad240 100644
--- a/usr.bin/du/du.c
+++ b/usr.bin/du/du.c
@@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
-
#include <err.h>
#include <errno.h>
#include <fnmatch.h>
@@ -514,7 +513,7 @@ static void
ignoreclean(void)
{
struct ignentry *ign;
-
+
while (!SLIST_EMPTY(&ignores)) {
ign = SLIST_FIRST(&ignores);
SLIST_REMOVE_HEAD(&ignores, next);
diff --git a/usr.bin/du/tests/Makefile b/usr.bin/du/tests/Makefile
new file mode 100644
index 000000000000..cf5b4d6715b7
--- /dev/null
+++ b/usr.bin/du/tests/Makefile
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+ATF_TESTS_SH+= du_test
+
+.include <bsd.test.mk>
diff --git a/usr.bin/du/tests/du_test.sh b/usr.bin/du/tests/du_test.sh
new file mode 100755
index 000000000000..f730b3ca3c58
--- /dev/null
+++ b/usr.bin/du/tests/du_test.sh
@@ -0,0 +1,153 @@
+#
+# Copyright (c) 2017 Ngie Cooper <ngie@FreeBSD.org>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+atf_test_case A_flag
+A_flag_head()
+{
+ atf_set "descr" "Verify -A behavior"
+}
+A_flag_body()
+{
+ # XXX: compressed volumes?
+ atf_check truncate -s 10g sparse.file
+ atf_check -o inline:'1\tsparse.file\n' du -g sparse.file
+ atf_check -o inline:'10\tsparse.file\n' du -A -g sparse.file
+}
+
+atf_test_case H_flag
+H_flag_head()
+{
+ atf_set "descr" "Verify -H behavior"
+}
+H_flag_body()
+{
+ local paths1='testdir/A/B testdir/A testdir/C testdir'
+ local paths2='testdir/A/B testdir/A testdir/C testdir'
+ local sep='\n[0-9]+\t'
+
+ atf_check mkdir testdir
+ atf_check -x "cd testdir && mkdir A && touch A/B && ln -s A C"
+
+ atf_check -o save:du.out du -aAH testdir
+ atf_check egrep -q "[0-9]+\t$(echo $paths1 | tr ' ' "$sep")\n" du.out
+ atf_check -o save:du_C.out du -aAH testdir/C
+ atf_check egrep -q "[0-9]+\t$(echo $paths2 | tr ' ' "$sep")\n" du_C.out
+}
+
+atf_test_case I_flag
+I_flag_head()
+{
+ atf_set "descr" "Verify -I behavior"
+}
+I_flag_body()
+{
+ paths_sans_foo_named="a/motley/fool/of/sorts fool/parts/with/their/cache bar baz"
+ paths_foo_named="foo foobar"
+ paths="$paths_sans_foo_named $paths_foo_named"
+
+ # cd'ing to testdir helps ensure that files from atf/kyua don't
+ # pollute the results.
+ atf_check -x "mkdir testdir && cd testdir && mkdir -p $paths"
+ atf_check -o save:du.out -x "cd testdir && du -s $paths_sans_foo_named"
+ atf_check -o save:du_I.out -x "cd testdir && du -I '*foo*' -s $paths"
+
+ atf_check diff -u du.out du_I.out
+}
+
+atf_test_case c_flag
+c_flag_head()
+{
+ atf_set "descr" "Verify -c output"
+}
+c_flag_body()
+{
+ atf_check truncate -s 0 foo bar
+}
+
+atf_test_case g_flag
+g_flag_head()
+{
+ atf_set "descr" "Verify -g output"
+}
+g_flag_body()
+{
+ atf_check truncate -s 1k A
+ atf_check truncate -s 1m B
+ atf_check truncate -s 1g C
+ atf_check truncate -s 1t D
+ atf_check -o inline:'1\tA\n1\tB\n1\tC\n1024\tD\n' du -Ag A B C D
+}
+
+atf_test_case h_flag
+h_flag_head()
+{
+ atf_set "descr" "Verify -h output"
+}
+h_flag_body()
+{
+ atf_check truncate -s 1k A
+ atf_check truncate -s 1m B
+ atf_check truncate -s 1g C
+ atf_check truncate -s 1t D
+ atf_check -o inline:'1.0K\tA\n1.0M\tB\n1.0G\tC\n1.0T\tD\n' du -Ah A B C D
+}
+
+atf_test_case k_flag
+k_flag_head()
+{
+ atf_set "descr" "Verify -k output"
+}
+k_flag_body()
+{
+ atf_check truncate -s 1k A
+ atf_check truncate -s 1m B
+ atf_check -o inline:'1\tA\n1024\tB\n' du -Ak A B
+}
+
+atf_test_case m_flag
+m_flag_head()
+{
+ atf_set "descr" "Verify -m output"
+}
+m_flag_body()
+{
+ atf_check truncate -s 1k A
+ atf_check truncate -s 1m B
+ atf_check truncate -s 1g C
+ atf_check -o inline:'1\tA\n1\tB\n1024\tC\n' du -Am A B C
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case A_flag
+ atf_add_test_case H_flag
+ atf_add_test_case I_flag
+ atf_add_test_case g_flag
+ atf_add_test_case h_flag
+ atf_add_test_case k_flag
+ atf_add_test_case m_flag
+}
diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c
index f250ce609dee..219878a51145 100644
--- a/usr.bin/finger/finger.c
+++ b/usr.bin/finger/finger.c
@@ -371,6 +371,7 @@ net: for (p = nargv; *p;) {
printf("\n");
}
+ free(nargv);
free(used);
if (entries == 0)
return;
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c
index 7d0db3399a32..2292bc523a3d 100644
--- a/usr.bin/fstat/fstat.c
+++ b/usr.bin/fstat/fstat.c
@@ -67,7 +67,7 @@ static int vflg; /* be verbose */
typedef struct devs {
struct devs *next;
- uint32_t fsid;
+ uint64_t fsid;
uint64_t ino;
const char *name;
} DEVS;
diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c
index be2264a5f0ae..f7b19cd466aa 100644
--- a/usr.bin/hexdump/display.c
+++ b/usr.bin/hexdump/display.c
@@ -361,12 +361,12 @@ next(char **argv)
if (caph_limit_stream(fileno(stdin), CAPH_READ) < 0)
err(1, "unable to restrict %s",
- statok ? _argv[-1] : "stdin");
+ statok ? *_argv : "stdin");
/*
* We've opened our last input file; enter capsicum sandbox.
*/
- if (*_argv == NULL) {
+ if (statok == 0 || *(_argv + 1) == NULL) {
if (cap_enter() < 0 && errno != ENOSYS)
err(1, "unable to enter capability mode");
}
diff --git a/usr.bin/stat/Makefile b/usr.bin/stat/Makefile
index 1a549793bb7c..bc560a4243d0 100644
--- a/usr.bin/stat/Makefile
+++ b/usr.bin/stat/Makefile
@@ -1,8 +1,12 @@
# $FreeBSD$
+.include <src.opts.mk>
+
PROG= stat
LINKS= ${BINDIR}/stat ${BINDIR}/readlink
MLINKS= stat.1 readlink.1
+SUBDIR.${MK_TESTS}+= tests
+
.include <bsd.prog.mk>
diff --git a/usr.bin/stat/stat.1 b/usr.bin/stat/stat.1
index 96e172415e33..a2d81ca266d4 100644
--- a/usr.bin/stat/stat.1
+++ b/usr.bin/stat/stat.1
@@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 22, 2012
+.Dd June 22, 2017
.Dt STAT 1
.Os
.Sh NAME
@@ -179,15 +179,15 @@ Display information in
.Dq shell output
format,
suitable for initializing variables.
-.It Fl x
-Display information in a more verbose way as known from some
-.Tn Linux
-distributions.
.It Fl t Ar timefmt
Display timestamps using the specified format.
This format is
passed directly to
.Xr strftime 3 .
+.It Fl x
+Display information in a more verbose way as known from some
+.Tn Linux
+distributions.
.El
.Ss Formats
Format strings are similar to
diff --git a/usr.bin/stat/tests/Makefile b/usr.bin/stat/tests/Makefile
new file mode 100644
index 000000000000..3249d1720258
--- /dev/null
+++ b/usr.bin/stat/tests/Makefile
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+ATF_TESTS_SH+= readlink_test
+ATF_TESTS_SH+= stat_test
+
+.include <bsd.test.mk>
diff --git a/usr.bin/stat/tests/readlink_test.sh b/usr.bin/stat/tests/readlink_test.sh
new file mode 100755
index 000000000000..8e5deb173653
--- /dev/null
+++ b/usr.bin/stat/tests/readlink_test.sh
@@ -0,0 +1,73 @@
+#
+# Copyright (c) 2017 Dell EMC
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+atf_test_case f_flag
+basic_head()
+{
+ atf_set "descr" "Verify that calling readlink without any flags " \
+ "prints out the symlink target for a file"
+}
+basic_body()
+{
+ atf_check ln -s foo bar
+ atf_check -o inline:'foo\n' readlink bar
+}
+
+atf_test_case f_flag
+f_flag_head()
+{
+ atf_set "descr" "Verify that calling readlink with -f will not emit " \
+ "an error message/exit with a non-zero code"
+}
+f_flag_body()
+{
+ atf_check touch A.file
+ atf_check ln -s nonexistent A.link
+ atf_check -o inline:"nonexistent\n" \
+ -s exit:1 readlink A.file A.link
+ atf_check -o inline:"$(realpath A.file)\n$PWD/nonexistent\n" \
+ -s exit:1 readlink -f A.file A.link
+}
+
+atf_test_case n_flag
+n_flag_head()
+{
+}
+n_flag_body()
+{
+ atf_check ln -s nonexistent.A A
+ atf_check ln -s nonexistent.B B
+ atf_check -o 'inline:nonexistent.A\nnonexistent.B\n' readlink A B
+ atf_check -o 'inline:nonexistent.Anonexistent.B' readlink -n A B
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case basic
+ atf_add_test_case f_flag
+ atf_add_test_case n_flag
+}
diff --git a/usr.bin/stat/tests/stat_test.sh b/usr.bin/stat/tests/stat_test.sh
new file mode 100755
index 000000000000..6088b924c0d5
--- /dev/null
+++ b/usr.bin/stat/tests/stat_test.sh
@@ -0,0 +1,235 @@
+#
+# Copyright (c) 2017 Dell EMC
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+atf_test_case F_flag
+F_flag_head()
+{
+ atf_set "descr" "Verify the output format for -F"
+}
+F_flag_body()
+{
+ # TODO: socket, whiteout file
+ atf_check touch a
+ atf_check mkdir b
+ atf_check install -m 0777 /dev/null c
+ atf_check ln -s a d
+ atf_check mkfifo f
+
+ atf_check -o match:'.* a' stat -Fn a
+ atf_check -o match:'.* b/' stat -Fn b
+ atf_check -o match:'.* c\*' stat -Fn c
+ atf_check -o match:'.* d@' stat -Fn d
+ atf_check -o match:'.* f\|' stat -Fn f
+}
+
+atf_test_case l_flag
+l_flag_head()
+{
+ atf_set "descr" "Verify the output format for -l"
+}
+l_flag_body()
+{
+ atf_check touch a
+ atf_check ln a b
+ atf_check ln -s a c
+ atf_check mkdir d
+
+ paths="a b c d"
+
+ # NOTE:
+ # - Even though stat -l claims to be equivalent to `ls -lT`, the
+ # whitespace is a bit more liberal in the `ls -lT` output.
+ # - `ls -ldT` is used to not recursively list the contents of
+ # directories.
+ for path in $paths; do
+ atf_check -o inline:"$(ls -ldT $path | sed -e 's, , ,g')\n" \
+ stat -l $path
+ done
+}
+
+atf_test_case n_flag
+n_flag_head()
+{
+ atf_set "descr" "Verify that -n suppresses newline output for lines"
+}
+n_flag_body()
+{
+ atf_check touch a b
+ atf_check -o inline:"$(stat a | tr -d '\n')" stat -n a
+ atf_check -o inline:"$(stat a b | tr -d '\n')" stat -n a b
+}
+
+atf_test_case q_flag
+q_flag_head()
+{
+ atf_set "descr" "Verify that -q suppresses error messages from l?stat(2)"
+}
+q_flag_body()
+{
+ ln -s nonexistent broken-link
+
+ atf_check -s exit:1 stat -q nonexistent
+ atf_check -s exit:1 stat -q nonexistent
+ atf_check -o not-empty stat -q broken-link
+ atf_check -o not-empty stat -qL broken-link
+}
+
+atf_test_case r_flag
+r_flag_head()
+{
+ atf_set "descr" "Verify that -r displays output in 'raw mode'"
+}
+r_flag_body()
+{
+ atf_check touch a
+ # TODO: add more thorough checks.
+ atf_check -o not-empty stat -r a
+}
+
+atf_test_case s_flag
+s_flag_head()
+{
+ atf_set "descr" "Verify the output format for -s"
+}
+s_flag_body()
+{
+ atf_check touch a
+ atf_check ln a b
+ atf_check ln -s a c
+ atf_check mkdir d
+
+ paths="a b c d"
+
+ # The order/name of each of the fields is specified by stat(1) manpage.
+ fields="st_dev st_ino st_mode st_nlink"
+ fields="$fields st_uid st_gid st_rdev st_size"
+ fields="$fields st_uid st_gid st_mode"
+ fields="$fields st_atime st_mtime st_ctime st_birthtime"
+ fields="$fields st_blksize st_blocks st_flags"
+
+ # NOTE: the following...
+ # - ... relies on set -eu to ensure that the fields are set, as
+ # documented, in stat(1).
+ # - ... uses a subshell to ensure that the eval'ed variables don't
+ # pollute the next iteration's behavior.
+ for path in $paths; do
+ (
+ set -eu
+ eval $(stat -s $path)
+ for field in $fields; do
+ eval "$field=\$$field"
+ done
+ ) || atf_fail 'One or more fields not set by stat(1)'
+ done
+}
+
+atf_test_case t_flag
+t_flag_head()
+{
+ atf_set "descr" "Verify the output format for -t"
+}
+
+t_flag_body()
+{
+ atf_check touch foo
+ atf_check touch -d 1970-01-01T00:00:42 foo
+ atf_check -o inline:'42\n' \
+ stat -t '%s' -f '%a' foo
+ atf_check -o inline:'1970-01-01 00:00:42\n' \
+ stat -t '%F %H:%M:%S' -f '%Sa' foo
+}
+
+x_output_date()
+{
+ local date_format='%a %b %d %H:%M:%S %Y'
+
+ stat -t "$date_format" "$@"
+}
+
+x_output()
+{
+ local path=$1; shift
+
+ local atime_s=$(x_output_date -f '%Sa' $path)
+ local ctime_s=$(x_output_date -f '%Sc' $path)
+ local devid=$(stat -f '%Hd,%Ld' $path)
+ local file_type_s=$(stat -f '%HT' $path)
+ local gid=$(stat -f '%5g' $path)
+ local groupname=$(stat -f '%8Sg' $path)
+ local inode=$(stat -f '%i' $path)
+ local mode=$(stat -f '%Mp%Lp' $path)
+ local mode_s=$(stat -f '%Sp' $path)
+ local mtime_s=$(x_output_date -f '%Sm' $path)
+ local nlink=$(stat -f '%l' $path)
+ local size_a=$(stat -f '%-11z' $path)
+ local uid=$(stat -f '%5u' $path)
+ local username=$(stat -f '%8Su' $path)
+
+ cat <<EOF
+ File: "$path"
+ Size: $size_a FileType: $file_type_s
+ Mode: ($mode/$mode_s) Uid: ($uid/$username) Gid: ($gid/$groupname)
+Device: $devid Inode: $inode Links: $nlink
+Access: $atime_s
+Modify: $mtime_s
+Change: $ctime_s
+EOF
+}
+
+atf_test_case x_flag
+x_flag_head()
+{
+ atf_set "descr" "Verify the output format for -x"
+}
+x_flag_body()
+{
+ atf_check touch a
+ atf_check ln a b
+ atf_check ln -s a c
+ atf_check mkdir d
+
+ paths="a b c d"
+
+ for path in $paths; do
+ atf_check -o "inline:$(x_output $path)\n" stat -x $path
+ done
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case F_flag
+ #atf_add_test_case H_flag
+ #atf_add_test_case L_flag
+ #atf_add_test_case f_flag
+ atf_add_test_case l_flag
+ atf_add_test_case n_flag
+ atf_add_test_case q_flag
+ atf_add_test_case r_flag
+ atf_add_test_case s_flag
+ atf_add_test_case t_flag
+ atf_add_test_case x_flag
+}
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c
index df36c45f8bbb..3886bd8ec1ef 100644
--- a/usr.bin/top/machine.c
+++ b/usr.bin/top/machine.c
@@ -188,9 +188,9 @@ char *arcnames[] = {
NULL
};
-int carc_stats[5];
+int carc_stats[4];
char *carcnames[] = {
- "K Compressed, ", "K Uncompressed, ", ":1 Ratio, ", "K Overhead",
+ "K Compressed, ", "K Uncompressed, ", ":1 Ratio, ",
NULL
};
@@ -580,11 +580,9 @@ get_system_info(struct system_info *si)
if (carc_enabled) {
GETSYSCTL("kstat.zfs.misc.arcstats.compressed_size", arc_stat);
carc_stats[0] = arc_stat >> 10;
+ carc_stats[2] = arc_stat >> 10; /* For ratio */
GETSYSCTL("kstat.zfs.misc.arcstats.uncompressed_size", arc_stat);
carc_stats[1] = arc_stat >> 10;
- carc_stats[2] = arc_stats[0]; /* ARC Total */
- GETSYSCTL("kstat.zfs.misc.arcstats.overhead_size", arc_stat);
- carc_stats[3] = arc_stat >> 10;
si->carc = carc_stats;
}
diff --git a/usr.bin/top/top.local.1 b/usr.bin/top/top.local.1
index a77fb5fae257..eb4035395e88 100644
--- a/usr.bin/top/top.local.1
+++ b/usr.bin/top/top.local.1
@@ -65,10 +65,7 @@ bytes of memory used by ARC caches
bytes of data stored in ARC caches before compression
.TP
.B Ratio:
-ratio of uncompressed data to total ARC size
-.TP
-.B Overhead:
-amount of overhead from ARC compression
+compression ratio of data cached in the ARC
.SS Swap Stats
.TP
.B Total:
diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h
index 2f9c0f31bb4d..86f0411ba472 100644
--- a/usr.bin/truss/syscall.h
+++ b/usr.bin/truss/syscall.h
@@ -50,7 +50,7 @@ enum Argtype { None = 1, Hex, Octal, Int, UInt, LongHex, Name, Ptr, Stat, Ioctl,
Kldunloadflags, Sizet, Madvice, Socklent, Sockprotocol, Sockoptlevel,
Sockoptname, Msgflags, CapRights, PUInt, PQuadHex, Acltype,
Extattrnamespace, Minherit, Mlockall, Mountflags, Msync, Priowhich,
- Ptraceop, Quotactlcmd, Reboothowto, Rtpriofunc,
+ Ptraceop, Quotactlcmd, Reboothowto, Rtpriofunc, Schedpolicy, Schedparam,
CloudABIAdvice, CloudABIClockID, ClouduABIFDSFlags,
CloudABIFDStat, CloudABIFileStat, CloudABIFileType,
diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c
index 3c0ba799ad53..7601476854d0 100644
--- a/usr.bin/truss/syscalls.c
+++ b/usr.bin/truss/syscalls.c
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <fcntl.h>
#include <poll.h>
+#include <sched.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
@@ -395,6 +396,20 @@ static struct syscall decoded_syscalls[] = {
.args = { { Rtpriofunc, 0 }, { Int, 1 }, { Ptr, 2 } } },
{ .name = "rtprio_thread", .ret_type = 1, .nargs = 3,
.args = { { Rtpriofunc, 0 }, { Int, 1 }, { Ptr, 2 } } },
+ { .name = "sched_get_priority_max", .ret_type = 1, .nargs = 1,
+ .args = { { Schedpolicy, 0 } } },
+ { .name = "sched_get_priority_min", .ret_type = 1, .nargs = 1,
+ .args = { { Schedpolicy, 0 } } },
+ { .name = "sched_getparam", .ret_type = 1, .nargs = 2,
+ .args = { { Int, 0 }, { Schedparam | OUT, 1 } } },
+ { .name = "sched_getscheduler", .ret_type = 1, .nargs = 1,
+ .args = { { Int, 0 } } },
+ { .name = "sched_rr_get_interval", .ret_type = 1, .nargs = 2,
+ .args = { { Int, 0 }, { Timespec | OUT, 1 } } },
+ { .name = "sched_setparam", .ret_type = 1, .nargs = 2,
+ .args = { { Int, 0 }, { Schedparam, 1 } } },
+ { .name = "sched_setscheduler", .ret_type = 1, .nargs = 3,
+ .args = { { Int, 0 }, { Schedpolicy, 1 }, { Schedparam, 2 } } },
{ .name = "sctp_generic_recvmsg", .ret_type = 1, .nargs = 7,
.args = { { Int, 0 }, { Ptr | IN, 1 }, { Int, 2 },
{ Sockaddr | OUT, 3 }, { Ptr | OUT, 4 }, { Ptr | OUT, 5 },
@@ -2155,6 +2170,20 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval,
print_integer_arg(sysdecode_rtprio_function, fp,
args[sc->offset]);
break;
+ case Schedpolicy:
+ print_integer_arg(sysdecode_scheduler_policy, fp,
+ args[sc->offset]);
+ break;
+ case Schedparam: {
+ struct sched_param sp;
+
+ if (get_struct(pid, (void *)args[sc->offset], &sp,
+ sizeof(sp)) != -1)
+ fprintf(fp, "{ %d }", sp.sched_priority);
+ else
+ fprintf(fp, "0x%lx", args[sc->offset]);
+ break;
+ }
case CloudABIAdvice:
fputs(xlookup(cloudabi_advice, args[sc->offset]), fp);
diff --git a/usr.bin/xohtml/Makefile b/usr.bin/xohtml/Makefile
new file mode 100644
index 000000000000..0efb843f8cec
--- /dev/null
+++ b/usr.bin/xohtml/Makefile
@@ -0,0 +1,31 @@
+# $FreeBSD$
+
+.include <src.opts.mk>
+
+LIBXOSRC= ${SRCTOP}/contrib/libxo
+
+.PATH:
+.PATH: ${LIBXOSRC}/xohtml
+
+SCRIPTS= xohtml.sh
+MAN= xohtml.1
+
+EXTERNAL_FILES = \
+ external/jquery.js \
+ external/jquery.qtip.css \
+ external/jquery.qtip.js
+
+INTERNAL_FILES = \
+ xohtml.js \
+ xohtml.css
+
+FILES= ${INTERNAL_FILES} ${EXTERNAL_FILES}
+FILESDIR= /usr/share/xohtml
+FILESMODE= ${NOBINMODE}
+
+beforeinstall: mkfilesdir
+mkfilesdir:
+ test -d ${DESTDIR}${FILESDIR} \
+ || ${INSTALL} -d -o ${FILESOWN} -g ${FILESGRP} -m 755 ${DESTDIR}${FILESDIR}
+
+.include <bsd.prog.mk>
diff --git a/usr.bin/xohtml/xohtml.sh b/usr.bin/xohtml/xohtml.sh
new file mode 100755
index 000000000000..c1e85f7e151d
--- /dev/null
+++ b/usr.bin/xohtml/xohtml.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+# $FreeBSD$
+#
+# Copyright (c) 2014, Juniper Networks, Inc.
+# All rights reserved.
+# This SOFTWARE is licensed under the LICENSE provided in the
+# ../Copyright file. By downloading, installing, copying, or otherwise
+# using the SOFTWARE, you agree to be bound by the terms of that
+# LICENSE.
+# Phil Shafer, July 2014
+#
+
+BASE=/usr/share/libxo
+CMD=cat
+DONE=
+
+do_help () {
+ echo "xohtml: wrap libxo-enabled output in HTML"
+ echo "Usage: xohtml [options] [command [arguments]]"
+ echo "Valid options are:"
+ echo " -b <basepath> | --base <basepath>"
+ echo " -c <command> | --command <command>"
+ echo " -f <output-file> | --file <output-file>"
+ exit 1
+}
+
+while [ -z "$DONE" -a ! -z "$1" ]; do
+ case "$1" in
+ -b|--base)
+ shift;
+ BASE="$1";
+ shift;
+ ;;
+ -c|--command)
+ shift;
+ CMD="$1";
+ shift;
+ ;;
+ -f|--file)
+ shift;
+ FILE="$1";
+ shift;
+ exec > "$FILE";
+ ;;
+ -*)
+ do_help
+ ;;
+ *)
+ DONE=1;
+ XX=$1;
+ shift;
+ CMD="$XX --libxo=html $@"
+ ;;
+ esac
+done
+
+if [ "$CMD" = "cat" -a -t 0 ]; then
+ do_help
+fi
+
+echo '<html>'
+echo '<head>'
+echo '<meta http-equiv="content-type" content="text/html; charset=utf-8"/>'
+echo '<link rel="stylesheet" href="'$BASE'/xohtml.css">'
+echo '<link rel="stylesheet" href="'$BASE'/external/jquery.qtip.css"/>'
+echo '<script type="text/javascript" src="'$BASE'/external/jquery.js"></script>'
+echo '<script type="text/javascript" src="'$BASE'/external/jquery.qtip.js"></script>'
+echo '<script type="text/javascript" src="'$BASE'/xohtml.js"></script>'
+echo '<script>'
+echo '</script>'
+echo '</head>'
+echo '<body>'
+
+$CMD
+
+echo '</body>'
+echo '</html>'
+
+exit 0
diff --git a/usr.bin/xolint/Makefile b/usr.bin/xolint/Makefile
new file mode 100644
index 000000000000..ea8217e66ada
--- /dev/null
+++ b/usr.bin/xolint/Makefile
@@ -0,0 +1,13 @@
+# $FreeBSD$
+
+.include <src.opts.mk>
+
+LIBXOSRC= ${SRCTOP}/contrib/libxo
+
+.PATH:
+.PATH: ${LIBXOSRC}/xolint
+
+SCRIPTS= xolint.pl
+MAN= xolint.1
+
+.include <bsd.prog.mk>
diff --git a/usr.bin/xopo/Makefile b/usr.bin/xopo/Makefile
new file mode 100644
index 000000000000..c8cf4bde7ba8
--- /dev/null
+++ b/usr.bin/xopo/Makefile
@@ -0,0 +1,21 @@
+# $FreeBSD$
+
+.include <src.opts.mk>
+
+LIBXOSRC= ${SRCTOP}/contrib/libxo
+
+.PATH:
+.PATH: ${LIBXOSRC}/xopo
+
+PROG= xopo
+MAN= xopo.1
+
+# XXX For xoversion.h
+CFLAGS+=-I${LIBXOSRC}/libxo
+
+# XXX For xo_config.h
+CFLAGS+=-I${SRCTOP}/lib/libxo
+
+LIBADD= xo util
+
+.include <bsd.prog.mk>
diff --git a/usr.bin/yes/yes.c b/usr.bin/yes/yes.c
index 8febdded8986..4a30e3b65a82 100644
--- a/usr.bin/yes/yes.c
+++ b/usr.bin/yes/yes.c
@@ -44,20 +44,43 @@ static const char rcsid[] = "$FreeBSD$";
#include <capsicum_helpers.h>
#include <err.h>
#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
int
main(int argc, char **argv)
{
+ char buf[8192];
+ char y[2] = { 'y', '\n' };
+ char * exp = y;
+ size_t buflen = 0;
+ size_t explen = sizeof(y);
+ size_t more;
+ ssize_t ret;
if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS))
err(1, "capsicum");
- if (argc > 1)
- while (puts(argv[1]) != EOF)
- ;
- else
- while (puts("y") != EOF)
- ;
+ if (argc > 1) {
+ exp = argv[1];
+ explen = strlen(exp) + 1;
+ exp[explen - 1] = '\n';
+ }
+
+ if (explen <= sizeof(buf)) {
+ while (buflen < sizeof(buf) - explen) {
+ memcpy(buf + buflen, exp, explen);
+ buflen += explen;
+ }
+ exp = buf;
+ explen = buflen;
+ }
+
+ more = explen;
+ while ((ret = write(STDOUT_FILENO, exp + (explen - more), more)) > 0)
+ if ((more -= ret) == 0)
+ more = explen;
+
err(1, "stdout");
/*NOTREACHED*/
}