summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xetc/netstart3
-rwxr-xr-xetc/periodic/daily/400.status-disks7
-rwxr-xr-xetc/rc.d/local_unbound2
-rwxr-xr-xetc/rc.d/othermta2
-rw-r--r--etc/rc.shutdown2
-rw-r--r--lib/libc/net/sctp_sys_calls.c16
-rw-r--r--lib/libc/stdio/fopen.312
-rw-r--r--lib/libc/stdlib/tdelete.c11
-rw-r--r--lib/libdpv/dpv.c6
-rw-r--r--lib/libdpv/dpv.h3
-rw-r--r--release/doc/share/xml/security.xml15
-rw-r--r--share/dtrace/Makefile5
-rwxr-xr-xshare/dtrace/watch_execve227
-rwxr-xr-xshare/dtrace/watch_kill232
-rwxr-xr-xshare/dtrace/watch_vop_remove476
-rw-r--r--share/man/man4/splash.412
-rw-r--r--share/mk/bsd.dep.mk17
-rw-r--r--sys/amd64/linux/linux.h4
-rw-r--r--sys/amd64/linux/linux_machdep.c1
-rw-r--r--sys/amd64/linux/linux_sysvec.c4
-rw-r--r--sys/amd64/linux32/linux32_sysvec.c4
-rw-r--r--sys/boot/common/ufsread.c1
-rw-r--r--sys/boot/efi/boot1/Makefile6
-rw-r--r--sys/boot/efi/boot1/boot1.c292
-rw-r--r--sys/boot/efi/boot1/fat-amd64.tmpl.bz2.uu34
-rw-r--r--sys/boot/efi/include/amd64/efibind.h6
-rw-r--r--sys/boot/efi/include/i386/efibind.h6
-rw-r--r--sys/boot/efi/include/ia64/efibind.h4
-rw-r--r--sys/boot/efi/loader/devicename.c4
-rw-r--r--sys/boot/forth/support.4th6
-rw-r--r--sys/boot/i386/libi386/Makefile3
-rw-r--r--sys/boot/i386/libi386/smbios.c16
-rw-r--r--sys/boot/powerpc/boot1.chrp/boot1.c4
-rw-r--r--sys/boot/zfs/zfs.c4
-rw-r--r--sys/cddl/boot/zfs/lz4.c2
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c2
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c104
-rw-r--r--sys/conf/kmod.mk13
-rw-r--r--sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c88
-rw-r--r--sys/dev/mlx5/mlx5_en/en.h4
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c40
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_main.c120
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_rx.c14
-rw-r--r--sys/dev/syscons/plasma/fp16.c155
-rw-r--r--sys/dev/syscons/plasma/fp16.h85
-rw-r--r--sys/dev/syscons/plasma/plasma_saver.c239
-rw-r--r--sys/fs/nandfs/nandfs_segment.c5
-rw-r--r--sys/i386/linux/linux_sysvec.c4
-rw-r--r--sys/kern/kern_condvar.c33
-rw-r--r--sys/modules/syscons/Makefile2
-rw-r--r--sys/modules/syscons/plasma/Makefile8
-rw-r--r--tools/build/mk/OptionalObsoleteFiles.inc20
-rw-r--r--usr.bin/dpv/dpv.16
-rw-r--r--usr.bin/locate/locate/locate.rc2
-rw-r--r--usr.bin/locate/locate/updatedb.sh2
-rw-r--r--usr.bin/truncate/tests/truncate_test.sh11
-rw-r--r--usr.sbin/Makefile1
-rw-r--r--usr.sbin/bhyvectl/Makefile2
-rw-r--r--usr.sbin/bhyvectl/bhyvectl.897
-rw-r--r--usr.sbin/bsdconfig/share/dialog.subr1
-rw-r--r--usr.sbin/bsdconfig/share/strings.subr2
-rw-r--r--usr.sbin/vigr/Makefile6
-rw-r--r--usr.sbin/vigr/vigr.871
-rw-r--r--usr.sbin/vigr/vigr.sh95
64 files changed, 2232 insertions, 449 deletions
diff --git a/etc/netstart b/etc/netstart
index 44b8ab7..99d4f81 100755
--- a/etc/netstart
+++ b/etc/netstart
@@ -34,9 +34,6 @@
# the network by hand, this script will do it for you).
#
-. /etc/rc.subr
-
-load_rc_config 'XXX'
_start=quietstart
/etc/rc.d/devd ${_start}
diff --git a/etc/periodic/daily/400.status-disks b/etc/periodic/daily/400.status-disks
index dd828aa..bab2810 100755
--- a/etc/periodic/daily/400.status-disks
+++ b/etc/periodic/daily/400.status-disks
@@ -16,7 +16,12 @@ case "$daily_status_disks_enable" in
echo ""
echo "Disk status:"
- df $daily_status_disks_df_flags && rc=1 || rc=3
+ if [ -n "${daily_status_disks_ignore}" ] ; then
+ ignore="egrep -v ${daily_status_disks_ignore}"
+ else
+ ignore="cat"
+ fi
+ (df $daily_status_disks_df_flags | ${ignore}) && rc=1 || rc=3
# display which filesystems need backing up
if [ -s /etc/dumpdates ]; then
diff --git a/etc/rc.d/local_unbound b/etc/rc.d/local_unbound
index 0a81e2c..0cd1ff3 100755
--- a/etc/rc.d/local_unbound
+++ b/etc/rc.d/local_unbound
@@ -30,6 +30,7 @@ load_rc_config $name
: ${local_unbound_config:=${local_unbound_workdir}/unbound.conf}
: ${local_unbound_flags:="-c ${local_unbound_config}"}
: ${local_unbound_forwardconf:=${local_unbound_workdir}/forward.conf}
+: ${local_unbound_controlconf:=${local_unbound_workdir}/control.conf}
: ${local_unbound_anchor:=${local_unbound_workdir}/root.key}
: ${local_unbound_forwarders:=}
@@ -68,6 +69,7 @@ local_unbound_setup()
-w ${local_unbound_workdir} \
-c ${local_unbound_config} \
-f ${local_unbound_forwardconf} \
+ -o ${local_unbound_controlconf} \
-a ${local_unbound_anchor} \
${local_unbound_forwarders}
}
diff --git a/etc/rc.d/othermta b/etc/rc.d/othermta
index 7ab3e63..36292ae 100755
--- a/etc/rc.d/othermta
+++ b/etc/rc.d/othermta
@@ -10,7 +10,7 @@
#
. /etc/rc.subr
-load_rc_config 'XXX'
+load_rc_config
if [ -n "${mta_start_script}" ]; then
[ "${mta_start_script}" != "/etc/rc.sendmail" ] && \
diff --git a/etc/rc.shutdown b/etc/rc.shutdown
index a0dd698..15779c7 100644
--- a/etc/rc.shutdown
+++ b/etc/rc.shutdown
@@ -45,7 +45,7 @@ export HOME PATH
. /etc/rc.subr
-load_rc_config 'XXX'
+load_rc_config
# reverse_list list
# print the list in reverse order
diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c
index f07aa43..dcbcee7 100644
--- a/lib/libc/net/sctp_sys_calls.c
+++ b/lib/libc/net/sctp_sys_calls.c
@@ -700,14 +700,19 @@ sctp_sendx(int sd, const void *msg, size_t msg_len,
#ifdef SYS_sctp_generic_sendmsg
if (addrcnt == 1) {
socklen_t l;
+ ssize_t ret;
/*
* Quick way, we don't need to do a connectx so lets use the
* syscall directly.
*/
l = addrs->sa_len;
- return (syscall(SYS_sctp_generic_sendmsg, sd,
- msg, msg_len, addrs, l, sinfo, flags));
+ ret = syscall(SYS_sctp_generic_sendmsg, sd,
+ msg, msg_len, addrs, l, sinfo, flags);
+ if ((ret >= 0) && (sinfo != NULL)) {
+ sinfo->sinfo_assoc_id = sctp_getassocid(sd, addrs);
+ }
+ return (ret);
}
#endif
@@ -984,6 +989,7 @@ sctp_sendv(int sd,
struct sockaddr *addr;
struct sockaddr_in *addr_in;
struct sockaddr_in6 *addr_in6;
+ sctp_assoc_t *assoc_id;
if ((addrcnt < 0) ||
(iovcnt < 0) ||
@@ -1002,6 +1008,7 @@ sctp_sendv(int sd,
errno = ENOMEM;
return (-1);
}
+ assoc_id = NULL;
msg.msg_control = cmsgbuf;
msg.msg_controllen = 0;
cmsg = (struct cmsghdr *)cmsgbuf;
@@ -1025,6 +1032,7 @@ sctp_sendv(int sd,
memcpy(CMSG_DATA(cmsg), info, sizeof(struct sctp_sndinfo));
msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_sndinfo));
cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_sndinfo)));
+ assoc_id = &(((struct sctp_sndinfo *)info)->snd_assoc_id);
break;
case SCTP_SENDV_PRINFO:
if ((info == NULL) || (infolen < sizeof(struct sctp_prinfo))) {
@@ -1066,6 +1074,7 @@ sctp_sendv(int sd,
memcpy(CMSG_DATA(cmsg), &spa_info->sendv_sndinfo, sizeof(struct sctp_sndinfo));
msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_sndinfo));
cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_sndinfo)));
+ assoc_id = &(spa_info->sendv_sndinfo.snd_assoc_id);
}
if (spa_info->sendv_flags & SCTP_SEND_PRINFO_VALID) {
cmsg->cmsg_level = IPPROTO_SCTP;
@@ -1164,6 +1173,9 @@ sctp_sendv(int sd,
msg.msg_flags = 0;
ret = sendmsg(sd, &msg, flags);
free(cmsgbuf);
+ if ((ret >= 0) && (addrs != NULL) && (assoc_id != NULL)) {
+ *assoc_id = sctp_getassocid(sd, addrs);
+ }
return (ret);
}
diff --git a/lib/libc/stdio/fopen.3 b/lib/libc/stdio/fopen.3
index b39cb5a..f25e6df 100644
--- a/lib/libc/stdio/fopen.3
+++ b/lib/libc/stdio/fopen.3
@@ -120,7 +120,9 @@ This is strictly for compatibility with
.St -isoC
and has effect only for
.Fn fmemopen
-; otherwise the ``b'' is ignored.
+; otherwise
+.Dq Li b
+is ignored.
.Pp
Any created files will have mode
.Do Dv S_IRUSR
@@ -230,7 +232,9 @@ allocates
.Fa size
bytes of memory. This buffer is automatically freed when the
stream is closed. Buffers can be opened in text-mode (default) or binary-mode
-(if ``b'' is present in the second or third position of the
+(if
+.Dq Li b
+is present in the second or third position of the
.Fa mode
argument). Buffers opened in text-mode make sure that writes are terminated with
a NULL byte, if the last write hasn't filled up the whole buffer. Buffers
@@ -343,5 +347,7 @@ The
function
conforms to
.St -p1003.1-2008 .
-The ``b'' mode does not conform to any standard
+The
+.Dq Li b
+mode does not conform to any standard
but is also supported by glibc.
diff --git a/lib/libc/stdlib/tdelete.c b/lib/libc/stdlib/tdelete.c
index bef187e..8a599e5 100644
--- a/lib/libc/stdlib/tdelete.c
+++ b/lib/libc/stdlib/tdelete.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $ */
+/* $NetBSD: tdelete.c,v 1.8 2016/01/20 20:47:41 christos Exp $ */
/*
* Tree search generalized from Knuth (6.2.2) Algorithm T just like
@@ -14,7 +14,7 @@
#include <sys/cdefs.h>
#if 0
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: tdelete.c,v 1.6 2012/06/25 22:32:45 abs Exp $");
+__RCSID("$NetBSD: tdelete.c,v 1.8 2016/01/20 20:47:41 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#endif
__FBSDID("$FreeBSD$");
@@ -25,9 +25,9 @@ __FBSDID("$FreeBSD$");
/*
- * find a node with given key
+ * delete node with given key
*
- * vkey: key to be found
+ * vkey: key to be deleted
* vrootp: address of the root of the tree
* compar: function to carry out node comparisons
*/
@@ -65,8 +65,7 @@ tdelete(const void * __restrict vkey, void ** __restrict vrootp,
q->rlink = (*rootp)->rlink;
}
}
- if (p != *rootp)
- free(*rootp); /* D4: Free node */
+ free(*rootp); /* D4: Free node */
*rootp = q; /* link parent to new node */
return p;
}
diff --git a/lib/libdpv/dpv.c b/lib/libdpv/dpv.c
index 6a03922..d3506ca 100644
--- a/lib/libdpv/dpv.c
+++ b/lib/libdpv/dpv.c
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <dialog.h>
#include <err.h>
#include <limits.h>
+#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -482,6 +483,11 @@ dpv(struct dpv_config *config, struct dpv_file_node *file_list)
/* Reads: label_size pbar_size pprompt aprompt dpv_nfiles */
/* Inits: dheight and dwidth */
+ /* Default localeconv(3) settings for dialog(3) status */
+ setlocale(LC_NUMERIC,
+ getenv("LC_ALL") == NULL && getenv("LC_NUMERIC") == NULL ?
+ LC_NUMERIC_DEFAULT : "");
+
if (!debug) {
/* Internally create the initial `--gauge' prompt text */
dprompt_recreate(file_list, (struct dpv_file_node *)NULL, 0);
diff --git a/lib/libdpv/dpv.h b/lib/libdpv/dpv.h
index dbcd59b..03768a7 100644
--- a/lib/libdpv/dpv.h
+++ b/lib/libdpv/dpv.h
@@ -38,6 +38,9 @@
#define FALSE 0
#endif
+/* localeconv(3) */
+#define LC_NUMERIC_DEFAULT "en_US.ISO8859-1"
+
/* Data to process */
extern long long dpv_overall_read;
diff --git a/release/doc/share/xml/security.xml b/release/doc/share/xml/security.xml
index fc05ae1..e37b089 100644
--- a/release/doc/share/xml/security.xml
+++ b/release/doc/share/xml/security.xml
@@ -107,6 +107,21 @@
<entry><para><application>OpenSSH</application> client
information leak</para></entry>
</row>
+
+ <row>
+ <entry><link
+ xlink:href="&security.url;/FreeBSD-SA-16:09.ntp.asc">FreeBSD-SA-16:09.ntp</link></entry>
+ <entry>27&nbsp;January&nbsp;2016</entry>
+ <entry><para>Multiple vulnerabilities.</para></entry>
+ </row>
+
+ <row>
+ <entry><link
+ xlink:href="&security.url;/FreeBSD-SA-16:10.linux.asc">FreeBSD-SA-16:10.linux</link></entry>
+ <entry>27&nbsp;January&nbsp;2016</entry>
+ <entry><para>&man.issetugid.2; system call
+ vulnerability.</para></entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
diff --git a/share/dtrace/Makefile b/share/dtrace/Makefile
index adbdc84..39ca2a6 100644
--- a/share/dtrace/Makefile
+++ b/share/dtrace/Makefile
@@ -12,7 +12,10 @@ SUBDIR= ${_toolkit}
_toolkit= toolkit
.endif
-SCRIPTS= nfsclienttime hotopen
+SCRIPTS= nfsclienttime hotopen \
+ watch_execve \
+ watch_kill \
+ watch_vop_remove
SCRIPTSDIR= ${SHAREDIR}/dtrace
diff --git a/share/dtrace/watch_execve b/share/dtrace/watch_execve
new file mode 100755
index 0000000..1817d4b
--- /dev/null
+++ b/share/dtrace/watch_execve
@@ -0,0 +1,227 @@
+#!/usr/sbin/dtrace -s
+/* -
+ * Copyright (c) 2014 Devin Teske <dteske@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.
+ *
+ * $Title: dtrace(1) script to log process(es) entering syscall::execve $
+ * $FreeBSD$
+ */
+
+#pragma D option quiet
+#pragma D option dynvarsize=16m
+#pragma D option switchrate=10hz
+
+/*********************************************************/
+
+syscall::execve:entry /* probe ID 1 */
+{
+ this->caller_execname = execname;
+}
+
+/*********************************************************/
+
+syscall::execve:return /execname != this->caller_execname/ /* probe ID 2 */
+{
+ /*
+ * Examine process, parent process, and grandparent process details
+ */
+
+ /******************* CURPROC *******************/
+
+ this->proc = curthread->td_proc;
+ this->pid0 = this->proc->p_pid;
+ this->uid0 = this->proc->p_ucred->cr_uid;
+ this->gid0 = this->proc->p_ucred->cr_rgid;
+ this->p_args = this->proc->p_args;
+ this->ar_length = this->p_args ? this->p_args->ar_length : 0;
+ this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
+
+ this->arg0_0 = this->ar_length > 0 ?
+ this->ar_args : stringof(this->proc->p_comm);
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg0_1 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg0_2 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg0_3 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg0_4 = this->ar_length > 0 ? "..." : "";
+
+ /******************* PPARENT *******************/
+
+ this->proc = this->proc->p_pptr;
+ this->pid1 = this->proc->p_pid;
+ this->uid1 = this->proc->p_ucred->cr_uid;
+ this->gid1 = this->proc->p_ucred->cr_rgid;
+ this->p_args = this->proc ? this->proc->p_args : 0;
+ this->ar_length = this->p_args ? this->p_args->ar_length : 0;
+ this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
+
+ this->arg1_0 = this->ar_length > 0 ?
+ this->ar_args : stringof(this->proc->p_comm);
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg1_1 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg1_2 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg1_3 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg1_4 = this->ar_length > 0 ? "..." : "";
+
+ /******************* GPARENT *******************/
+
+ this->proc = this->proc->p_pptr;
+ this->pid2 = this->proc->p_pid;
+ this->uid2 = this->proc->p_ucred->cr_uid;
+ this->gid2 = this->proc->p_ucred->cr_rgid;
+ this->p_args = this->proc ? this->proc->p_args : 0;
+ this->ar_length = this->p_args ? this->p_args->ar_length : 0;
+ this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
+
+ this->arg2_0 = this->ar_length > 0 ?
+ this->ar_args : stringof(this->proc->p_comm);
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg2_1 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg2_2 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg2_3 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg2_4 = this->ar_length > 0 ? "..." : "";
+
+ /******************* APARENT *******************/
+
+ this->proc = this->proc->p_pptr;
+ this->pid3 = this->proc->p_pid;
+ this->uid3 = this->proc->p_ucred->cr_uid;
+ this->gid3 = this->proc->p_ucred->cr_rgid;
+ this->p_args = this->proc ? this->proc->p_args : 0;
+ this->ar_length = this->p_args ? this->p_args->ar_length : 0;
+ this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
+
+ this->arg3_0 = this->ar_length > 0 ?
+ this->ar_args : stringof(this->proc->p_comm);
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg3_1 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg3_2 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg3_3 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg3_4 = this->ar_length > 0 ? "..." : "";
+
+ /***********************************************/
+
+ /*
+ * Print process, parent, and grandparent details
+ */
+
+ printf("%Y %s[%d]: ", timestamp + 1406598400000000000,
+ this->caller_execname, this->pid1);
+ printf("%s", this->arg0_0);
+ printf("%s%s", this->arg0_1 != "" ? " " : "", this->arg0_1);
+ printf("%s%s", this->arg0_2 != "" ? " " : "", this->arg0_2);
+ printf("%s%s", this->arg0_3 != "" ? " " : "", this->arg0_3);
+ printf("%s%s", this->arg0_4 != "" ? " " : "", this->arg0_4);
+ printf("\n");
+
+ printf(" -+= %05d %d.%d %s",
+ this->pid3, this->uid3, this->gid3, this->arg3_0);
+ printf("%s%s", this->arg3_1 != "" ? " " : "", this->arg3_1);
+ printf("%s%s", this->arg3_2 != "" ? " " : "", this->arg3_2);
+ printf("%s%s", this->arg3_3 != "" ? " " : "", this->arg3_3);
+ printf("%s%s", this->arg3_4 != "" ? " " : "", this->arg3_4);
+ printf("%s", this->arg3_0 != "" ? "\n" : "");
+
+ printf(" \-+= %05d %d.%d %s",
+ this->pid2, this->uid2, this->gid2, this->arg2_0);
+ printf("%s%s", this->arg2_1 != "" ? " " : "", this->arg2_1);
+ printf("%s%s", this->arg2_2 != "" ? " " : "", this->arg2_2);
+ printf("%s%s", this->arg2_3 != "" ? " " : "", this->arg2_3);
+ printf("%s%s", this->arg2_4 != "" ? " " : "", this->arg2_4);
+ printf("%s", this->arg2_0 != "" ? "\n" : "");
+
+ printf(" \-+= %05d %d.%d %s",
+ this->pid1, this->uid1, this->gid1, this->arg1_0);
+ printf("%s%s", this->arg1_1 != "" ? " " : "", this->arg1_1);
+ printf("%s%s", this->arg1_2 != "" ? " " : "", this->arg1_2);
+ printf("%s%s", this->arg1_3 != "" ? " " : "", this->arg1_3);
+ printf("%s%s", this->arg1_4 != "" ? " " : "", this->arg1_4);
+ printf("%s", this->arg1_0 != "" ? "\n" : "");
+
+ printf(" \-+= %05d %d.%d %s",
+ this->pid0, this->uid0, this->gid0, this->arg0_0);
+ printf("%s%s", this->arg0_1 != "" ? " " : "", this->arg0_1);
+ printf("%s%s", this->arg0_2 != "" ? " " : "", this->arg0_2);
+ printf("%s%s", this->arg0_3 != "" ? " " : "", this->arg0_3);
+ printf("%s%s", this->arg0_4 != "" ? " " : "", this->arg0_4);
+ printf("%s", this->arg0_0 != "" ? "\n" : "");
+}
diff --git a/share/dtrace/watch_kill b/share/dtrace/watch_kill
new file mode 100755
index 0000000..46f3cd8
--- /dev/null
+++ b/share/dtrace/watch_kill
@@ -0,0 +1,232 @@
+#!/usr/sbin/dtrace -s
+/* -
+ * Copyright (c) 2014-2016 Devin Teske <dteske@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.
+ *
+ * $Title: dtrace(1) script to log process(es) entering syscall::kill $
+ * $FreeBSD$
+ */
+
+#pragma D option quiet
+#pragma D option dynvarsize=16m
+#pragma D option switchrate=10hz
+
+/*********************************************************/
+
+syscall::execve:entry /* probe ID 1 */
+{
+ this->caller_execname = execname;
+}
+
+/*********************************************************/
+
+syscall::kill:entry /* probe ID 2 */
+{
+ this->pid_to_kill = (pid_t)arg0;
+ this->kill_signal = (int)arg1;
+
+ /*
+ * Examine process, parent process, and grandparent process details
+ */
+
+ /******************* CURPROC *******************/
+
+ this->proc = curthread->td_proc;
+ this->pid0 = this->proc->p_pid;
+ this->uid0 = this->proc->p_ucred->cr_uid;
+ this->gid0 = this->proc->p_ucred->cr_rgid;
+ this->p_args = this->proc->p_args;
+ this->ar_length = this->p_args ? this->p_args->ar_length : 0;
+ this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
+
+ this->arg0_0 = this->ar_length > 0 ?
+ this->ar_args : stringof(this->proc->p_comm);
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg0_1 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg0_2 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg0_3 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg0_4 = this->ar_length > 0 ? "..." : "";
+
+ /******************* PPARENT *******************/
+
+ this->proc = this->proc->p_pptr;
+ this->pid1 = this->proc->p_pid;
+ this->uid1 = this->proc->p_ucred->cr_uid;
+ this->gid1 = this->proc->p_ucred->cr_rgid;
+ this->p_args = this->proc ? this->proc->p_args : 0;
+ this->ar_length = this->p_args ? this->p_args->ar_length : 0;
+ this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
+
+ this->arg1_0 = this->ar_length > 0 ?
+ this->ar_args : stringof(this->proc->p_comm);
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg1_1 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg1_2 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg1_3 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg1_4 = this->ar_length > 0 ? "..." : "";
+
+ /******************* GPARENT *******************/
+
+ this->proc = this->proc->p_pptr;
+ this->pid2 = this->proc->p_pid;
+ this->uid2 = this->proc->p_ucred->cr_uid;
+ this->gid2 = this->proc->p_ucred->cr_rgid;
+ this->p_args = this->proc ? this->proc->p_args : 0;
+ this->ar_length = this->p_args ? this->p_args->ar_length : 0;
+ this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
+
+ this->arg2_0 = this->ar_length > 0 ?
+ this->ar_args : stringof(this->proc->p_comm);
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg2_1 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg2_2 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg2_3 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg2_4 = this->ar_length > 0 ? "..." : "";
+
+ /******************* APARENT *******************/
+
+ this->proc = this->proc->p_pptr;
+ this->pid3 = this->proc->p_pid;
+ this->uid3 = this->proc->p_ucred->cr_uid;
+ this->gid3 = this->proc->p_ucred->cr_rgid;
+ this->p_args = this->proc ? this->proc->p_args : 0;
+ this->ar_length = this->p_args ? this->p_args->ar_length : 0;
+ this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
+
+ this->arg3_0 = this->ar_length > 0 ?
+ this->ar_args : stringof(this->proc->p_comm);
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg3_1 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg3_2 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg3_3 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg3_4 = this->ar_length > 0 ? "..." : "";
+
+ /***********************************************/
+
+ /*
+ * Print process, parent, and grandparent details
+ */
+
+ printf("%Y %s[%d]: ", timestamp + 1406598400000000000,
+ this->caller_execname, this->pid1);
+ printf("%s", this->arg0_0);
+ printf("%s%s", this->arg0_1 != "" ? " " : "", this->arg0_1);
+ printf("%s%s", this->arg0_2 != "" ? " " : "", this->arg0_2);
+ printf("%s%s", this->arg0_3 != "" ? " " : "", this->arg0_3);
+ printf("%s%s", this->arg0_4 != "" ? " " : "", this->arg0_4);
+ printf(" (sending signal %u to pid %u)",
+ this->kill_signal, this->pid_to_kill);
+ printf("\n");
+
+ printf(" -+= %05d %d.%d %s",
+ this->pid3, this->uid3, this->gid3, this->arg3_0);
+ printf("%s%s", this->arg3_1 != "" ? " " : "", this->arg3_1);
+ printf("%s%s", this->arg3_2 != "" ? " " : "", this->arg3_2);
+ printf("%s%s", this->arg3_3 != "" ? " " : "", this->arg3_3);
+ printf("%s%s", this->arg3_4 != "" ? " " : "", this->arg3_4);
+ printf("%s", this->arg3_0 != "" ? "\n" : "");
+
+ printf(" \-+= %05d %d.%d %s",
+ this->pid2, this->uid2, this->gid2, this->arg2_0);
+ printf("%s%s", this->arg2_1 != "" ? " " : "", this->arg2_1);
+ printf("%s%s", this->arg2_2 != "" ? " " : "", this->arg2_2);
+ printf("%s%s", this->arg2_3 != "" ? " " : "", this->arg2_3);
+ printf("%s%s", this->arg2_4 != "" ? " " : "", this->arg2_4);
+ printf("%s", this->arg2_0 != "" ? "\n" : "");
+
+ printf(" \-+= %05d %d.%d %s",
+ this->pid1, this->uid1, this->gid1, this->arg1_0);
+ printf("%s%s", this->arg1_1 != "" ? " " : "", this->arg1_1);
+ printf("%s%s", this->arg1_2 != "" ? " " : "", this->arg1_2);
+ printf("%s%s", this->arg1_3 != "" ? " " : "", this->arg1_3);
+ printf("%s%s", this->arg1_4 != "" ? " " : "", this->arg1_4);
+ printf("%s", this->arg1_0 != "" ? "\n" : "");
+
+ printf(" \-+= %05d %d.%d %s",
+ this->pid0, this->uid0, this->gid0, this->arg0_0);
+ printf("%s%s", this->arg0_1 != "" ? " " : "", this->arg0_1);
+ printf("%s%s", this->arg0_2 != "" ? " " : "", this->arg0_2);
+ printf("%s%s", this->arg0_3 != "" ? " " : "", this->arg0_3);
+ printf("%s%s", this->arg0_4 != "" ? " " : "", this->arg0_4);
+ printf("%s", this->arg0_0 != "" ? "\n" : "");
+}
diff --git a/share/dtrace/watch_vop_remove b/share/dtrace/watch_vop_remove
new file mode 100755
index 0000000..6a5e7c4
--- /dev/null
+++ b/share/dtrace/watch_vop_remove
@@ -0,0 +1,476 @@
+#!/usr/sbin/dtrace -s
+/* -
+ * Copyright (c) 2014 Devin Teske <dteske@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.
+ *
+ * $Title: dtrace(1) script to log process(es) entering vfs::vop_remove $
+ * $FreeBSD$
+ */
+
+#pragma D option quiet
+#pragma D option dynvarsize=16m
+#pragma D option switchrate=10hz
+
+/*********************************************************/
+
+vfs::vop_remove:entry /* probe ID 1 */
+{
+ this->vp = (struct vnode *)arg0;
+ this->ncp = &(this->vp->v_cache_dst) != NULL ?
+ this->vp->v_cache_dst.tqh_first : 0;
+ this->fi_name = args[1] ? (
+ args[1]->a_cnp != NULL ?
+ stringof(args[1]->a_cnp->cn_nameptr) : ""
+ ) : "";
+ this->mount = this->vp->v_mount; /* ptr to vfs we are in */
+ this->fi_fs = this->mount != 0 ?
+ stringof(this->mount->mnt_stat.f_fstypename) : "";
+ this->fi_mount = this->mount != 0 ?
+ stringof(this->mount->mnt_stat.f_mntonname) : "";
+ this->d_name = args[0]->v_cache_dd != NULL ?
+ stringof(args[0]->v_cache_dd->nc_name) : "";
+}
+
+vfs::vop_remove:entry /this->vp == 0 || this->fi_fs == 0 ||
+ this->fi_fs == "devfs" || this->fi_fs == "" ||
+ this->fi_name == ""/ /* probe ID 2 */
+{
+ this->ncp = 0;
+}
+
+/*********************************************************/
+
+vfs::vop_remove:entry /this->ncp/ /* probe ID 3 (depth 1) */
+{
+ this->dvp = this->ncp->nc_dvp != NULL ? (
+ &(this->ncp->nc_dvp->v_cache_dst) != NULL ?
+ this->ncp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name1 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->name1 == 0 || this->fi_fs == 0 ||
+ this->fi_fs == "devfs" || this->fi_fs == "" ||
+ this->name1 == "/" || this->name1 == ""/ /* probe ID 4 */
+{
+ this->dvp = 0;
+}
+
+/*********************************************************/
+
+/*
+ * BEGIN Pathname-depth iterators (copy/paste as many times as-desired)
+ */
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 5 (depth 2) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name2 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 6 (depth 3) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name3 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 7 (depth 4) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name4 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 8 (depth 5) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name5 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 9 (depth 6) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name6 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 10 (depth 7) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name7 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 11 (depth 8) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name8 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 12 (depth 9) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name9 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 13 (depth 10) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name10 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 14 (depth 11) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name11 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 15 (depth 12) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name12 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 16 (depth 13) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name13 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 17 (depth 14) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name14 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 18 (depth 15) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name15 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 19 (depth 16) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name16 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 20 (depth 17) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name17 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 21 (depth 18) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name18 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 22 (depth 19) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name19 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+vfs::vop_remove:entry /this->dvp/ /* probe ID 23 (depth 20) */
+{
+ this->dvp = this->dvp->nc_dvp != NULL ? (
+ &(this->dvp->nc_dvp->v_cache_dst) != NULL ?
+ this->dvp->nc_dvp->v_cache_dst.tqh_first : 0
+ ) : 0;
+ this->name20 = this->dvp != 0 ? (
+ this->dvp->nc_name != 0 ? stringof(this->dvp->nc_name) : ""
+ ) : "";
+}
+
+/*
+ * END Pathname-depth iterators
+ */
+
+/*********************************************************/
+
+vfs::vop_remove:entry /this->fi_mount != 0/ /* probe ID 24 */
+{
+ printf("%Y %s[%d]: ", timestamp + 1406598400000000000, execname, pid);
+
+ /*
+ * Print full path of file to delete
+ * NB: Up-to but not including the parent directory (printed below)
+ */
+ printf("%s%s", this->fi_mount, this->fi_mount != 0 ? (
+ this->fi_mount == "/" ? "" : "/"
+ ) : "/");
+ printf("%s%s", this->name = this->name20, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name19, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name18, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name17, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name16, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name15, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name14, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name13, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name12, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name11, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name10, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name9, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name8, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name7, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name6, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name5, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name4, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name3, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name2, this->name != "" ? "/" : "");
+ printf("%s%s", this->name = this->name1, this->name != "" ? "/" : "");
+
+ /* Print the parent directory name */
+ this->name = this->d_name != 0 ? this->d_name : "";
+ printf("%s%s", this->name, this->name != "" ? "/" : "");
+
+ /* Print the entry name */
+ this->name = this->fi_name != 0 ? this->fi_name : "";
+ printf("%s", this->name);
+
+ printf("\n");
+
+ /*
+ * Examine process, parent process, and grandparent process details
+ */
+
+ /******************* CURPROC *******************/
+
+ this->proc = curthread->td_proc;
+ this->pid0 = this->proc->p_pid;
+ this->uid0 = this->proc->p_ucred->cr_uid;
+ this->gid0 = this->proc->p_ucred->cr_rgid;
+ this->p_args = this->proc->p_args;
+ this->ar_length = this->p_args ? this->p_args->ar_length : 0;
+ this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
+
+ this->arg0_0 = this->ar_length > 0 ?
+ this->ar_args : stringof(this->proc->p_comm);
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg0_1 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg0_2 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg0_3 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg0_4 = this->ar_length > 0 ? "..." : "";
+
+ /******************* PPARENT *******************/
+
+ this->proc = this->proc->p_pptr;
+ this->pid1 = this->proc->p_pid;
+ this->uid1 = this->proc->p_ucred->cr_uid;
+ this->gid1 = this->proc->p_ucred->cr_rgid;
+ this->p_args = this->proc ? this->proc->p_args : 0;
+ this->ar_length = this->p_args ? this->p_args->ar_length : 0;
+ this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
+
+ this->arg1_0 = this->ar_length > 0 ?
+ this->ar_args : stringof(this->proc->p_comm);
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg1_1 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg1_2 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg1_3 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg1_4 = this->ar_length > 0 ? "..." : "";
+
+ /******************* GPARENT *******************/
+
+ this->proc = this->proc->p_pptr;
+ this->pid2 = this->proc->p_pid;
+ this->uid2 = this->proc->p_ucred->cr_uid;
+ this->gid2 = this->proc->p_ucred->cr_rgid;
+ this->p_args = this->proc ? this->proc->p_args : 0;
+ this->ar_length = this->p_args ? this->p_args->ar_length : 0;
+ this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0);
+
+ this->arg2_0 = this->ar_length > 0 ?
+ this->ar_args : stringof(this->proc->p_comm);
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg2_1 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg2_2 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg2_3 = this->ar_length > 0 ? this->ar_args : "";
+ this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0;
+ this->ar_args += this->len;
+ this->ar_length -= this->len;
+
+ this->arg2_4 = this->ar_length > 0 ? "..." : "";
+
+ /***********************************************/
+
+ /*
+ * Print process, parent, and grandparent details
+ */
+
+ printf(" -+= %05d %d.%d %s",
+ this->pid2, this->uid2, this->gid2, this->arg2_0);
+ printf("%s%s", this->arg2_1 != "" ? " " : "", this->arg2_1);
+ printf("%s%s", this->arg2_2 != "" ? " " : "", this->arg2_2);
+ printf("%s%s", this->arg2_3 != "" ? " " : "", this->arg2_3);
+ printf("%s%s", this->arg2_4 != "" ? " " : "", this->arg2_4);
+ printf("%s", this->arg2_0 != "" ? "\n" : "");
+
+ printf(" \-+= %05d %d.%d %s",
+ this->pid1, this->uid1, this->gid1, this->arg1_0);
+ printf("%s%s", this->arg1_1 != "" ? " " : "", this->arg1_1);
+ printf("%s%s", this->arg1_2 != "" ? " " : "", this->arg1_2);
+ printf("%s%s", this->arg1_3 != "" ? " " : "", this->arg1_3);
+ printf("%s%s", this->arg1_4 != "" ? " " : "", this->arg1_4);
+ printf("%s", this->arg1_0 != "" ? "\n" : "");
+
+ printf(" \-+= %05d %d.%d %s",
+ this->pid0, this->uid0, this->gid0, this->arg0_0);
+ printf("%s%s", this->arg0_1 != "" ? " " : "", this->arg0_1);
+ printf("%s%s", this->arg0_2 != "" ? " " : "", this->arg0_2);
+ printf("%s%s", this->arg0_3 != "" ? " " : "", this->arg0_3);
+ printf("%s%s", this->arg0_4 != "" ? " " : "", this->arg0_4);
+ printf("%s", this->arg0_0 != "" ? "\n" : "");
+}
diff --git a/share/man/man4/splash.4 b/share/man/man4/splash.4
index 2a9a297..c53828f 100644
--- a/share/man/man4/splash.4
+++ b/share/man/man4/splash.4
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 29, 2010
+.Dd December 31, 2015
.Dt SPLASH 4
.Os
.Sh NAME
@@ -130,6 +130,8 @@ the screen will also be powered off.
Animated graphical
.Fx
logo.
+.It Pa plasma_saver.ko
+Draws an animated interference pattern.
.It Pa rain_saver.ko
Draws a shower on the screen.
.It Pa snake_saver.ko
@@ -282,6 +284,14 @@ based on the
code, with some additional inspiration from the
.Pa daemon_saver
code.
+The
+.Pa logo_saver ,
+.Pa plasma_saver ,
+.Pa rain_saver
+and
+.Pa warp_saver
+modules were written by
+.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
.Sh CAVEATS
Both the splash screen and the screen saver work with
.Xr syscons 4
diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk
index d59ed28..3e49a6e 100644
--- a/share/mk/bsd.dep.mk
+++ b/share/mk/bsd.dep.mk
@@ -160,12 +160,25 @@ depend: beforedepend ${DEPENDFILE} afterdepend
# Tell bmake not to look for generated files via .PATH
.NOPATH: ${DEPENDFILE}
+# Capture -include from CFLAGS.
+# This could be simpler with bmake :tW but needs to support fmake for MFC.
+_CFLAGS_INCLUDES= ${CFLAGS:Q:S/\\ /,/g:C/-include,/-include%/g:C/,/ /g:M-include*:C/%/ /g}
+_CXXFLAGS_INCLUDES= ${CXXFLAGS:Q:S/\\ /,/g:C/-include,/-include%/g:C/,/ /g:M-include*:C/%/ /g}
+# XXX: Temporary hack to workaround .depend files not tracking -include
+.if !empty(_CFLAGS_INCLUDES)
+${OBJS} ${POBJS} ${SOBJS}: ${_CFLAGS_INCLUDES:M*.h}
+.endif
+.if !empty(_CXXFLAGS_INCLUDES)
+${OBJS} ${POBJS} ${SOBJS}: ${_CXXFLAGS_INCLUDES:M*.h}
+.endif
+
# Different types of sources are compiled with slightly different flags.
# Split up the sources, and filter out headers and non-applicable flags.
MKDEP_CFLAGS= ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BIDU]*} ${CFLAGS:M-std=*} \
- ${CFLAGS:M-ansi}
+ ${CFLAGS:M-ansi} ${_CFLAGS_INCLUDES}
MKDEP_CXXFLAGS= ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BIDU]*} \
- ${CXXFLAGS:M-std=*} ${CXXFLAGS:M-ansi} ${CXXFLAGS:M-stdlib=*}
+ ${CXXFLAGS:M-std=*} ${CXXFLAGS:M-ansi} ${CXXFLAGS:M-stdlib=*} \
+ ${_CXXFLAGS_INCLUDES}
DPSRCS+= ${SRCS}
${DEPENDFILE}: ${DPSRCS}
diff --git a/sys/amd64/linux/linux.h b/sys/amd64/linux/linux.h
index c4fe9ae..639499a 100644
--- a/sys/amd64/linux/linux.h
+++ b/sys/amd64/linux/linux.h
@@ -530,8 +530,8 @@ struct l_pollfd {
#define LINUX_ARCH_SET_GS 0x1001
#define LINUX_ARCH_SET_FS 0x1002
-#define LINUX_ARCH_GET_GS 0x1003
-#define LINUX_ARCH_GET_FS 0x1004
+#define LINUX_ARCH_GET_FS 0x1003
+#define LINUX_ARCH_GET_GS 0x1004
#define linux_copyout_rusage(r, u) copyout(r, u, sizeof(*r))
diff --git a/sys/amd64/linux/linux_machdep.c b/sys/amd64/linux/linux_machdep.c
index d6174e6..9664dac 100644
--- a/sys/amd64/linux/linux_machdep.c
+++ b/sys/amd64/linux/linux_machdep.c
@@ -383,7 +383,6 @@ linux_sigaltstack(struct thread *td, struct linux_sigaltstack_args *uap)
return (error);
}
-/* XXX do all */
int
linux_arch_prctl(struct thread *td, struct linux_arch_prctl_args *args)
{
diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c
index d53a266..fc8ee3e 100644
--- a/sys/amd64/linux/linux_sysvec.c
+++ b/sys/amd64/linux/linux_sysvec.c
@@ -271,6 +271,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
Elf_Addr *pos;
struct ps_strings *arginfo;
struct proc *p;
+ int issetugid;
p = imgp->proc;
arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
@@ -281,6 +282,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
args = (Elf64_Auxargs *)imgp->auxargs;
pos = base + (imgp->args->argc + imgp->args->envc + 2);
+ issetugid = p->p_flag & P_SUGID ? 1 : 0;
AUXARGS_ENTRY(pos, LINUX_AT_SYSINFO_EHDR,
imgp->proc->p_sysent->sv_shared_page_base);
AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, cpu_feature);
@@ -296,7 +298,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
- AUXARGS_ENTRY(pos, LINUX_AT_SECURE, 0);
+ AUXARGS_ENTRY(pos, LINUX_AT_SECURE, issetugid);
AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
AUXARGS_ENTRY(pos, LINUX_AT_RANDOM, imgp->canary);
if (imgp->execpathp != 0)
diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c
index 73949d9..a7baa15 100644
--- a/sys/amd64/linux32/linux32_sysvec.c
+++ b/sys/amd64/linux32/linux32_sysvec.c
@@ -230,6 +230,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
Elf32_Addr *base;
Elf32_Addr *pos;
struct linux32_ps_strings *arginfo;
+ int issetugid;
arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS;
@@ -239,6 +240,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
args = (Elf32_Auxargs *)imgp->auxargs;
pos = base + (imgp->args->argc + imgp->args->envc + 2);
+ issetugid = imgp->proc->p_flag & P_SUGID ? 1 : 0;
AUXARGS_ENTRY_32(pos, LINUX_AT_SYSINFO_EHDR,
imgp->proc->p_sysent->sv_shared_page_base);
AUXARGS_ENTRY_32(pos, LINUX_AT_SYSINFO, linux32_vsyscall);
@@ -261,7 +263,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
AUXARGS_ENTRY_32(pos, AT_FLAGS, args->flags);
AUXARGS_ENTRY_32(pos, AT_ENTRY, args->entry);
AUXARGS_ENTRY_32(pos, AT_BASE, args->base);
- AUXARGS_ENTRY_32(pos, LINUX_AT_SECURE, 0);
+ AUXARGS_ENTRY_32(pos, LINUX_AT_SECURE, issetugid);
AUXARGS_ENTRY_32(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
AUXARGS_ENTRY_32(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
AUXARGS_ENTRY_32(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
diff --git a/sys/boot/common/ufsread.c b/sys/boot/common/ufsread.c
index c02010f..d0ca57a 100644
--- a/sys/boot/common/ufsread.c
+++ b/sys/boot/common/ufsread.c
@@ -211,7 +211,6 @@ fsread(ufs_ino_t inode, void *buf, size_t nbyte)
break;
}
if (sblock_try[n] == -1) {
- printf("Not ufs\n");
return -1;
}
dsk_meta++;
diff --git a/sys/boot/efi/boot1/Makefile b/sys/boot/efi/boot1/Makefile
index 8cb6c62..1f59c33 100644
--- a/sys/boot/efi/boot1/Makefile
+++ b/sys/boot/efi/boot1/Makefile
@@ -38,6 +38,12 @@ LDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared
LDFLAGS+= -Wl,-znocombreloc
.endif
+#
+# Add libstand for required string and memory functions for all platforms.
+#
+DPADD+= ${LIBSTAND}
+LDADD+= -lstand
+
DPADD+= ${LDSCRIPT}
OBJCOPY?= objcopy
diff --git a/sys/boot/efi/boot1/boot1.c b/sys/boot/efi/boot1/boot1.c
index 1e3821b..9d5bac3 100644
--- a/sys/boot/efi/boot1/boot1.c
+++ b/sys/boot/efi/boot1/boot1.c
@@ -24,6 +24,7 @@ __FBSDID("$FreeBSD$");
#include <sys/dirent.h>
#include <machine/elf.h>
#include <machine/stdarg.h>
+#include <stand.h>
#include <efi.h>
#include <eficonsctl.h>
@@ -33,28 +34,8 @@ __FBSDID("$FreeBSD$");
#define BSIZEMAX 16384
-typedef int putc_func_t(char c, void *arg);
-
-struct sp_data {
- char *sp_buf;
- u_int sp_len;
- u_int sp_size;
-};
-
-static const char digits[] = "0123456789abcdef";
-
-static void panic(const char *fmt, ...) __dead2;
-static int printf(const char *fmt, ...);
-static int putchar(char c, void *arg);
-static int vprintf(const char *fmt, va_list ap);
-static int vsnprintf(char *str, size_t sz, const char *fmt, va_list ap);
-
-static int __printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap);
-static int __putc(char c, void *arg);
-static int __puts(const char *s, putc_func_t *putc, void *arg);
-static int __sputc(char c, void *arg);
-static char *__uitoa(char *buf, u_int val, int base);
-static char *__ultoa(char *buf, u_long val, int base);
+void panic(const char *fmt, ...) __dead2;
+void putchar(int c);
static int domount(EFI_DEVICE_PATH *device, EFI_BLOCK_IO *blkio, int quiet);
static void load(const char *fname);
@@ -62,39 +43,6 @@ static void load(const char *fname);
EFI_SYSTEM_TABLE *systab;
EFI_HANDLE *image;
-static void
-bcopy(const void *src, void *dst, size_t len)
-{
- const char *s = src;
- char *d = dst;
-
- while (len-- != 0)
- *d++ = *s++;
-}
-
-static void
-memcpy(void *dst, const void *src, size_t len)
-{
- bcopy(src, dst, len);
-}
-
-static void
-bzero(void *b, size_t len)
-{
- char *p = b;
-
- while (len-- != 0)
- *p++ = 0;
-}
-
-static int
-strcmp(const char *s1, const char *s2)
-{
- for (; *s1 == *s2 && *s1; s1++, s2++)
- ;
- return ((u_char)*s1 - (u_char)*s2);
-}
-
static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL;
static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL;
static EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL;
@@ -108,11 +56,12 @@ EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE* Xsystab)
{
EFI_HANDLE handles[128];
EFI_BLOCK_IO *blkio;
- UINTN i, nparts = sizeof(handles);
+ UINTN i, nparts = sizeof(handles), cols, rows, max_dim, best_mode;
EFI_STATUS status;
EFI_DEVICE_PATH *devpath;
EFI_BOOT_SERVICES *BS;
EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL;
+ SIMPLE_TEXT_OUTPUT_INTERFACE *conout = NULL;
char *path = _PATH_LOADER;
systab = Xsystab;
@@ -124,6 +73,25 @@ EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE* Xsystab)
if (status == EFI_SUCCESS)
(void)ConsoleControl->SetMode(ConsoleControl,
EfiConsoleControlScreenText);
+ /*
+ * Reset the console and find the best text mode.
+ */
+ conout = systab->ConOut;
+ conout->Reset(conout, TRUE);
+ max_dim = best_mode = 0;
+ for (i = 0; ; i++) {
+ status = conout->QueryMode(conout, i, &cols, &rows);
+ if (EFI_ERROR(status))
+ break;
+ if (cols * rows > max_dim) {
+ max_dim = cols * rows;
+ best_mode = i;
+ }
+ }
+ if (max_dim > 0)
+ conout->SetMode(conout, best_mode);
+ conout->EnableCursor(conout, TRUE);
+ conout->ClearScreen(conout);
printf(" \n>> FreeBSD EFI boot block\n");
printf(" Loader path: %s\n", path);
@@ -229,7 +197,6 @@ fsstat(ufs_ino_t inode)
break;
}
if (sblock_try[n] == -1) {
- printf("Not ufs\n");
return -1;
}
dsk_meta++;
@@ -325,38 +292,22 @@ load(const char *fname)
EFI_ERROR_CODE(status));
}
-static void
+void
panic(const char *fmt, ...)
{
- char buf[128];
va_list ap;
+ printf("panic: ");
va_start(ap, fmt);
- vsnprintf(buf, sizeof buf, fmt, ap);
- printf("panic: %s\n", buf);
+ vprintf(fmt, ap);
va_end(ap);
+ printf("\n");
while (1) {}
}
-static int
-printf(const char *fmt, ...)
-{
- va_list ap;
- int ret;
-
- /* Don't annoy the user as we probe for partitions */
- if (strcmp(fmt,"Not ufs\n") == 0)
- return 0;
-
- va_start(ap, fmt);
- ret = vprintf(fmt, ap);
- va_end(ap);
- return (ret);
-}
-
-static int
-putchar(char c, void *arg)
+void
+putchar(int c)
{
CHAR16 buf[2];
@@ -368,187 +319,4 @@ putchar(char c, void *arg)
buf[0] = c;
buf[1] = 0;
systab->ConOut->OutputString(systab->ConOut, buf);
- return (1);
-}
-
-static int
-vprintf(const char *fmt, va_list ap)
-{
- int ret;
-
- ret = __printf(fmt, putchar, 0, ap);
- return (ret);
-}
-
-static int
-vsnprintf(char *str, size_t sz, const char *fmt, va_list ap)
-{
- struct sp_data sp;
- int ret;
-
- sp.sp_buf = str;
- sp.sp_len = 0;
- sp.sp_size = sz;
- ret = __printf(fmt, __sputc, &sp, ap);
- return (ret);
-}
-
-static int
-__printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap)
-{
- char buf[(sizeof(long) * 8) + 1];
- char *nbuf;
- u_long ul;
- u_int ui;
- int lflag;
- int sflag;
- char *s;
- int pad;
- int ret;
- int c;
-
- nbuf = &buf[sizeof buf - 1];
- ret = 0;
- while ((c = *fmt++) != 0) {
- if (c != '%') {
- ret += putc(c, arg);
- continue;
- }
- lflag = 0;
- sflag = 0;
- pad = 0;
-reswitch: c = *fmt++;
- switch (c) {
- case '#':
- sflag = 1;
- goto reswitch;
- case '%':
- ret += putc('%', arg);
- break;
- case 'c':
- c = va_arg(ap, int);
- ret += putc(c, arg);
- break;
- case 'd':
- if (lflag == 0) {
- ui = (u_int)va_arg(ap, int);
- if (ui < (int)ui) {
- ui = -ui;
- ret += putc('-', arg);
- }
- s = __uitoa(nbuf, ui, 10);
- } else {
- ul = (u_long)va_arg(ap, long);
- if (ul < (long)ul) {
- ul = -ul;
- ret += putc('-', arg);
- }
- s = __ultoa(nbuf, ul, 10);
- }
- ret += __puts(s, putc, arg);
- break;
- case 'l':
- lflag = 1;
- goto reswitch;
- case 'o':
- if (lflag == 0) {
- ui = (u_int)va_arg(ap, u_int);
- s = __uitoa(nbuf, ui, 8);
- } else {
- ul = (u_long)va_arg(ap, u_long);
- s = __ultoa(nbuf, ul, 8);
- }
- ret += __puts(s, putc, arg);
- break;
- case 'p':
- ul = (u_long)va_arg(ap, void *);
- s = __ultoa(nbuf, ul, 16);
- ret += __puts("0x", putc, arg);
- ret += __puts(s, putc, arg);
- break;
- case 's':
- s = va_arg(ap, char *);
- ret += __puts(s, putc, arg);
- break;
- case 'u':
- if (lflag == 0) {
- ui = va_arg(ap, u_int);
- s = __uitoa(nbuf, ui, 10);
- } else {
- ul = va_arg(ap, u_long);
- s = __ultoa(nbuf, ul, 10);
- }
- ret += __puts(s, putc, arg);
- break;
- case 'x':
- if (lflag == 0) {
- ui = va_arg(ap, u_int);
- s = __uitoa(nbuf, ui, 16);
- } else {
- ul = va_arg(ap, u_long);
- s = __ultoa(nbuf, ul, 16);
- }
- if (sflag)
- ret += __puts("0x", putc, arg);
- ret += __puts(s, putc, arg);
- break;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- pad = pad * 10 + c - '0';
- goto reswitch;
- default:
- break;
- }
- }
- return (ret);
-}
-
-static int
-__sputc(char c, void *arg)
-{
- struct sp_data *sp;
-
- sp = arg;
- if (sp->sp_len < sp->sp_size)
- sp->sp_buf[sp->sp_len++] = c;
- sp->sp_buf[sp->sp_len] = '\0';
- return (1);
-}
-
-static int
-__puts(const char *s, putc_func_t *putc, void *arg)
-{
- const char *p;
- int ret;
-
- ret = 0;
- for (p = s; *p != '\0'; p++)
- ret += putc(*p, arg);
- return (ret);
-}
-
-static char *
-__uitoa(char *buf, u_int ui, int base)
-{
- char *p;
-
- p = buf;
- *p = '\0';
- do
- *--p = digits[ui % base];
- while ((ui /= base) != 0);
- return (p);
-}
-
-static char *
-__ultoa(char *buf, u_long ul, int base)
-{
- char *p;
-
- p = buf;
- *p = '\0';
- do
- *--p = digits[ul % base];
- while ((ul /= base) != 0);
- return (p);
}
diff --git a/sys/boot/efi/boot1/fat-amd64.tmpl.bz2.uu b/sys/boot/efi/boot1/fat-amd64.tmpl.bz2.uu
index d8a44b7..85a4b0f 100644
--- a/sys/boot/efi/boot1/fat-amd64.tmpl.bz2.uu
+++ b/sys/boot/efi/boot1/fat-amd64.tmpl.bz2.uu
@@ -2,19 +2,25 @@ FAT template boot filesystem created by generate-fat.sh
DO NOT EDIT
$FreeBSD$
begin 644 fat-amd64.tmpl.bz2
-M0EIH.3%!629362AK*D(`&I+____[ZZKJZ_^N_ZO^Z_Z_OJ[L`4`!7I0$#&$"
-M0$!$3&(<P`(;J*C:0E0E#30&AH`T````9#0```9````#)ZF0:,-3U/409,`)
-M@`"8`C3",````$R:8F@P`C`````"24U,D>I-DTU,)ZAZ0VA-!M0T'J`>H#"9
-M'I#0-H&HQI&0&3&FH>H>*`JHHU3V]1%/4/2``T#0`!H``#0`````#1H,@``6
-M'1&G'&@?$6[T#A)?X8$A160"20BO#")0J4TB1*4GXF$B4I,&>43+=_?K=#3*
-M6]<E0HE`UBF?(J%8BRF#?8OQ2'D)`)(EL2;F4.'R>R"ZNKJZI,9*68E8*E2Q
-M4J5*E3'(1830A"$(12A-"<(0A#]VD)H0A"$,>I0FA"$(0I\>P^=F5:M6K5JU
-M:DI3:64UN;[7%5B]Y-^\]@_K@B:N\/,5F%&H<\G#IXQXAEFC&D?![6%0'6MR
-MX1@@%FC"FD`M7,/SXFNG:2`'-0<-C$8^+$N.7M1B,^6)9,DV9,0A\OL<:C"L
-ML1V&,<\9YRB>XV#BG")'6NKRK^("UF2XO?_L!#29">MGDF$R3).!PX&%E,4C
-M''=(FL1.`_3?CN@-IB2PI3!FF\<8X.X@D,>CA90I)#M$XRPNDFJELL<3=1?8
-M2B7\5Z64,!7Z;EEBW-MXN-4IJ@W$462]-*\YCR,-B,5[W?=3&L/U>SX,WV#\
-M\B`:I"'0Z)5"$1B.E)(K[5I4RS`%R$>Y\D0NR*,;<9CZ:^V3P(I?D<D#!UC)
-D^M-HEE3SAN-8O0FQ$(`$(DF`?ZQ]'U2F_XNY(IPH2!0UE2$`
+M0EIH.3%!62936;D*A>0`&T#_____ZZKJ[_^N_^O^Z_Z[OJ_NJ^JK^KZNKNNJ
+MZ^KNZOJ^P`+\&$`!D#0T:`80&@T#`@`-`:9`:`P"`R::```:8)II@@,FC(-&
+M$`!D,(:9`E5%&3_]*J?ZHC(--&@::#3)HQ#0`&C330,"9,F$::9!D#`F30#3
+M3)H9-&1DTR`R:,3"`&0-#1H!A`:#0,"``T!ID!H#`(#)IH``!I@FFF"`R:,@
+MT80`&0PAID!5)$)Y0@R&HQ#3U-I--,@-&0R-&@T-`&FF@9-!IIIH-&1ILHTT
+M&ADQ#-$\B;1-/2-H93$\4\34Q9ZDM*M:U49"2K6F0C'21$(GD$1$085)7RB(
+M00A7Q'^3"!"&CM$T+&UM5A49]7/"3^:EK7GMDVS9MRWK=+E>.(OG-?ZZMDA:
+MR74C/HR\T0"$,Y+,YBA.JO&6C*K-DV26*@S24I%*E-2I4J5*JH43)*%"A0H4
+M*5-"E)2E2I4J5+!RPP]&&&&&&,P(9X]&&&&&&.IMKISQPX<.'#AP@0A"$(0A
+M"$(0A"(MX]&&&&&&&$(0A"$(0(0A"$(?ME2N'#APX<.'"+EZ,,,,,,,($(0A
+M"$0>NEGIM!8-(Y6FM$:.>9*3D219:RJKD^H2><E'K)-B^-<-VW[]G'7J_835
+MV`;*SC5&G@`GJ:N1`"ME+C<;GOI5H@!F'<0==<-#$2A&BJ%];5)UFHN9,G4?
+M]G6ARV-EJBOU_NY'021>1%9\LD8<E236-:]ILVV?0M6\<%=N2Y;G.DQ&<9G;
+MYJUNKRLLL]6X.TJQ;DFP1"P)D;"2W:]/XKP9*EC5W57(SUF^DRDD9N1\+:MN
+MLGV-ZX"Y<5R'+7S`832.Y=383)I.'I9>O.X4EIVM=.HDTT1'B:J=8;[A9NLU
+M"OX%C.X>0U/WZ^E74T&IHJ3EG))(^U[S\6_?HX;B.,Y*]7SGN@PV*_(O+^9#
+M+^Q,N_S1'42+=METV+CK9;+US'.8#H,%B,9Y*RD-/)TYXB8XQHI(RLF')')<
+MI>OZ<QW[FL!T6"X+#8C:LZZ5O?(VDD<W&Y\YA<5&NDFDA@-2Z#HNDWC!83#;
+MMB/W8SIL=EC%D8\FXDOI':7&/BN`UTRVDB;11`(0E`!CSIY+M)?HOW^+N2*<
+'*$A<A4+R````
`
end
diff --git a/sys/boot/efi/include/amd64/efibind.h b/sys/boot/efi/include/amd64/efibind.h
index 1905596..9858da4 100644
--- a/sys/boot/efi/include/amd64/efibind.h
+++ b/sys/boot/efi/include/amd64/efibind.h
@@ -39,7 +39,7 @@ Revision History
// No ANSI C 1999/2000 stdint.h integer width declarations
- #if _MSC_EXTENSIONS
+ #ifdef _MSC_EXTENSIONS
// Use Microsoft C compiler integer width declarations
@@ -160,7 +160,7 @@ typedef uint64_t UINTN;
#endif
#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options
- #if _MSC_EXTENSIONS
+ #ifdef _MSC_EXTENSIONS
#define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler
#else
#define EFIAPI // Substitute expresion to force C calling convention
@@ -261,7 +261,7 @@ typedef uint64_t UINTN;
#endif
#endif /* __FreeBSD__ */
-#if _MSC_EXTENSIONS
+#ifdef _MSC_EXTENSIONS
#pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP
#endif
diff --git a/sys/boot/efi/include/i386/efibind.h b/sys/boot/efi/include/i386/efibind.h
index f28057b..37f7f4b 100644
--- a/sys/boot/efi/include/i386/efibind.h
+++ b/sys/boot/efi/include/i386/efibind.h
@@ -39,7 +39,7 @@ Revision History
// No ANSI C 1999/2000 stdint.h integer width declarations
- #if _MSC_EXTENSIONS
+ #ifdef _MSC_EXTENSIONS
// Use Microsoft C compiler integer width declarations
@@ -156,7 +156,7 @@ typedef uint32_t UINTN;
//
#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options
- #if _MSC_EXTENSIONS
+ #ifdef _MSC_EXTENSIONS
#define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler
#else
#define EFIAPI // Substitute expresion to force C calling convention
@@ -257,7 +257,7 @@ typedef uint32_t UINTN;
#endif
#endif /* __FreeBSD__ */
-#if _MSC_EXTENSIONS
+#ifdef _MSC_EXTENSIONS
#pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP
#endif
diff --git a/sys/boot/efi/include/ia64/efibind.h b/sys/boot/efi/include/ia64/efibind.h
index 21f0d25..6569f96 100644
--- a/sys/boot/efi/include/ia64/efibind.h
+++ b/sys/boot/efi/include/ia64/efibind.h
@@ -39,7 +39,7 @@ Revision History
// No ANSI C 1999/2000 stdint.h integer width declarations
- #if _MSC_EXTENSIONS
+ #ifdef _MSC_EXTENSIONS
// Use Microsoft C compiler integer width declarations
@@ -159,7 +159,7 @@ typedef uint64_t UINTN;
//
#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options
- #if _MSC_EXTENSIONS
+ #ifdef _MSC_EXTENSIONS
#define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler
#else
#define EFIAPI // Substitute expresion to force C calling convention
diff --git a/sys/boot/efi/loader/devicename.c b/sys/boot/efi/loader/devicename.c
index a9327dc..4e9764c 100644
--- a/sys/boot/efi/loader/devicename.c
+++ b/sys/boot/efi/loader/devicename.c
@@ -147,7 +147,7 @@ efi_fmtdev(void *vdev)
break;
}
- return(buf);
+ return (buf);
}
/*
@@ -161,7 +161,7 @@ efi_setcurrdev(struct env_var *ev, int flags, const void *value)
rv = efi_parsedev(&ncurr, value, NULL);
if (rv != 0)
- return(rv);
+ return (rv);
free(ncurr);
env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
diff --git a/sys/boot/forth/support.4th b/sys/boot/forth/support.4th
index 3d9990d..3a8e1f2 100644
--- a/sys/boot/forth/support.4th
+++ b/sys/boot/forth/support.4th
@@ -1460,12 +1460,12 @@ also builtins
abort" Unable to load a kernel!"
;
-: load_xen ( -- )
+: load_xen ( -- flag )
s" xen_kernel" getenv dup -1 <> if
- 1 1 load
+ 1 1 load ( c-addr/u flag N -- flag )
else
drop
- 0
+ 0 ( -1 -- flag )
then
;
diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile
index d4fea80..0f360e9 100644
--- a/sys/boot/i386/libi386/Makefile
+++ b/sys/boot/i386/libi386/Makefile
@@ -36,6 +36,9 @@ CFLAGS+= -DSMBIOS_SERIAL_NUMBERS
.if defined(BOOT_LITTLE_ENDIAN_UUID)
# Use little-endian UUID format as defined in SMBIOS 2.6.
CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID
+.elif defined(BOOT_NETWORK_ENDIAN_UUID)
+# Use network-endian UUID format for backward compatibility.
+CFLAGS+= -DSMBIOS_NETWORK_ENDIAN_UUID
.endif
.endif
diff --git a/sys/boot/i386/libi386/smbios.c b/sys/boot/i386/libi386/smbios.c
index 8e6c790..6e4fb84 100644
--- a/sys/boot/i386/libi386/smbios.c
+++ b/sys/boot/i386/libi386/smbios.c
@@ -152,7 +152,7 @@ static void
smbios_setuuid(const char *name, const caddr_t addr, const int ver)
{
char uuid[37];
- int i, ones, zeros;
+ int byteorder, i, ones, zeros;
UUID_TYPE n;
uint32_t f1;
uint16_t f2, f3;
@@ -182,14 +182,18 @@ smbios_setuuid(const char *name, const caddr_t addr, const int ver)
* Note: We use network byte order for backward compatibility
* unless SMBIOS version is 2.6+ or little-endian is forced.
*/
-#ifndef SMBIOS_LITTLE_ENDIAN_UUID
- if (ver < 0x0206) {
+#if defined(SMBIOS_LITTLE_ENDIAN_UUID)
+ byteorder = LITTLE_ENDIAN;
+#elif defined(SMBIOS_NETWORK_ENDIAN_UUID)
+ byteorder = BIG_ENDIAN;
+#else
+ byteorder = ver < 0x0206 ? BIG_ENDIAN : LITTLE_ENDIAN;
+#endif
+ if (byteorder != LITTLE_ENDIAN) {
f1 = ntohl(SMBIOS_GET32(addr, 0));
f2 = ntohs(SMBIOS_GET16(addr, 4));
f3 = ntohs(SMBIOS_GET16(addr, 6));
- } else
-#endif
- {
+ } else {
f1 = le32toh(SMBIOS_GET32(addr, 0));
f2 = le16toh(SMBIOS_GET16(addr, 4));
f3 = le16toh(SMBIOS_GET16(addr, 6));
diff --git a/sys/boot/powerpc/boot1.chrp/boot1.c b/sys/boot/powerpc/boot1.chrp/boot1.c
index 30e695b..af22488 100644
--- a/sys/boot/powerpc/boot1.chrp/boot1.c
+++ b/sys/boot/powerpc/boot1.chrp/boot1.c
@@ -564,10 +564,6 @@ printf(const char *fmt, ...)
va_list ap;
int ret;
- /* Don't annoy the user as we probe for partitions */
- if (strcmp(fmt,"Not ufs\n") == 0)
- return 0;
-
va_start(ap, fmt);
ret = vprintf(fmt, ap);
va_end(ap);
diff --git a/sys/boot/zfs/zfs.c b/sys/boot/zfs/zfs.c
index 0679a57..c339b2d 100644
--- a/sys/boot/zfs/zfs.c
+++ b/sys/boot/zfs/zfs.c
@@ -154,7 +154,7 @@ zfs_read(struct open_file *f, void *start, size_t size, size_t *resid /* out */)
n = size;
if (fp->f_seekp + n > sb.st_size)
n = sb.st_size - fp->f_seekp;
-
+
rc = dnode_read(spa, &fp->f_dnode, fp->f_seekp, start, n);
if (rc)
return (rc);
@@ -507,7 +507,7 @@ zfs_probe_dev(const char *devname, uint64_t *pool_guid)
}
}
close(pa.fd);
- return (0);
+ return (ret);
}
/*
diff --git a/sys/cddl/boot/zfs/lz4.c b/sys/cddl/boot/zfs/lz4.c
index 055bd62..c29f861 100644
--- a/sys/cddl/boot/zfs/lz4.c
+++ b/sys/cddl/boot/zfs/lz4.c
@@ -52,7 +52,7 @@ lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int dum
* Returns 0 on success (decompression function returned non-negative)
* and non-zero on failure (decompression function returned negative).
*/
- return (LZ4_uncompress_unknownOutputSize(s_start + 4, d_start, bufsiz,
+ return (LZ4_uncompress_unknownOutputSize((const char *)s_start + 4, d_start, bufsiz,
d_len) < 0);
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
index ee0b52f..69b84b7 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
@@ -5951,6 +5951,8 @@ spa_async_remove(spa_t *spa, vdev_t *vd)
vd->vdev_stat.vs_checksum_errors = 0;
vdev_state_dirty(vd->vdev_top);
+ /* Tell userspace that the vdev is gone. */
+ zfs_post_remove(spa, vd);
}
for (int c = 0; c < vd->vdev_children; c++)
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
index 4cc0472..763ea1a 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
@@ -116,7 +116,6 @@ vdev_geom_orphan(struct g_consumer *cp)
* async removal support to invoke a close on this
* vdev once it is safe to do so.
*/
- zfs_post_remove(vd->vdev_spa, vd);
vd->vdev_remove_wanted = B_TRUE;
spa_async_request(vd->vdev_spa, SPA_ASYNC_REMOVE);
}
@@ -208,14 +207,12 @@ vdev_geom_detach(void *arg, int flag __unused)
}
}
-static uint64_t
-nvlist_get_guid(nvlist_t *list)
+static void
+nvlist_get_guids(nvlist_t *list, uint64_t *pguid, uint64_t *vguid)
{
- uint64_t value;
- value = 0;
- nvlist_lookup_uint64(list, ZPOOL_CONFIG_GUID, &value);
- return (value);
+ (void) nvlist_lookup_uint64(list, ZPOOL_CONFIG_GUID, vguid);
+ (void) nvlist_lookup_uint64(list, ZPOOL_CONFIG_POOL_GUID, pguid);
}
static int
@@ -270,7 +267,7 @@ vdev_geom_read_config(struct g_consumer *cp, nvlist_t **config)
size_t buflen;
uint64_t psize;
off_t offset, size;
- uint64_t guid, state, txg;
+ uint64_t state, txg;
int error, l, len;
g_topology_assert_not();
@@ -284,7 +281,6 @@ vdev_geom_read_config(struct g_consumer *cp, nvlist_t **config)
size = sizeof(*label) + pp->sectorsize -
((sizeof(*label) - 1) % pp->sectorsize) - 1;
- guid = 0;
label = kmem_alloc(size, KM_SLEEP);
buflen = sizeof(label->vl_vdev_phys.vp_nvlist);
@@ -479,30 +475,29 @@ vdev_geom_read_pool_label(const char *name,
return (*count > 0 ? 0 : ENOENT);
}
-static uint64_t
-vdev_geom_read_guid(struct g_consumer *cp)
+static void
+vdev_geom_read_guids(struct g_consumer *cp, uint64_t *pguid, uint64_t *vguid)
{
nvlist_t *config;
- uint64_t guid;
g_topology_assert_not();
- guid = 0;
+ *pguid = 0;
+ *vguid = 0;
if (vdev_geom_read_config(cp, &config) == 0) {
- guid = nvlist_get_guid(config);
+ nvlist_get_guids(config, pguid, vguid);
nvlist_free(config);
}
- return (guid);
}
static struct g_consumer *
-vdev_geom_attach_by_guid(uint64_t guid)
+vdev_geom_attach_by_guids(uint64_t pool_guid, uint64_t vdev_guid)
{
struct g_class *mp;
struct g_geom *gp, *zgp;
struct g_provider *pp;
struct g_consumer *cp, *zcp;
- uint64_t pguid;
+ uint64_t pguid, vguid;
g_topology_assert();
@@ -522,15 +517,24 @@ vdev_geom_attach_by_guid(uint64_t guid)
if (vdev_geom_attach_taster(zcp, pp) != 0)
continue;
g_topology_unlock();
- pguid = vdev_geom_read_guid(zcp);
+ vdev_geom_read_guids(zcp, &pguid, &vguid);
g_topology_lock();
vdev_geom_detach_taster(zcp);
- if (pguid != guid)
+ /*
+ * Check that the label's vdev guid matches the
+ * desired guid. If the label has a pool guid,
+ * check that it matches too. (Inactive spares
+ * and L2ARCs do not have any pool guid in the
+ * label.)
+ */
+ if ((pguid != 0 &&
+ pguid != pool_guid) ||
+ vguid != vdev_guid)
continue;
cp = vdev_geom_attach(pp);
if (cp == NULL) {
- printf("ZFS WARNING: Unable to attach to %s.\n",
- pp->name);
+ printf("ZFS WARNING: Unable to "
+ "attach to %s.\n", pp->name);
continue;
}
break;
@@ -548,7 +552,7 @@ end:
}
static struct g_consumer *
-vdev_geom_open_by_guid(vdev_t *vd)
+vdev_geom_open_by_guids(vdev_t *vd)
{
struct g_consumer *cp;
char *buf;
@@ -557,7 +561,7 @@ vdev_geom_open_by_guid(vdev_t *vd)
g_topology_assert();
ZFS_LOG(1, "Searching by guid [%ju].", (uintmax_t)vd->vdev_guid);
- cp = vdev_geom_attach_by_guid(vd->vdev_guid);
+ cp = vdev_geom_attach_by_guids(spa_guid(vd->vdev_spa), vd->vdev_guid);
if (cp != NULL) {
len = strlen(cp->provider->name) + strlen("/dev/") + 1;
buf = kmem_alloc(len, KM_SLEEP);
@@ -566,10 +570,12 @@ vdev_geom_open_by_guid(vdev_t *vd)
spa_strfree(vd->vdev_path);
vd->vdev_path = buf;
- ZFS_LOG(1, "Attach by guid [%ju] succeeded, provider %s.",
+ ZFS_LOG(1, "Attach by guid [%ju:%ju] succeeded, provider %s.",
+ (uintmax_t)spa_guid(vd->vdev_spa),
(uintmax_t)vd->vdev_guid, vd->vdev_path);
} else {
- ZFS_LOG(1, "Search by guid [%ju] failed.",
+ ZFS_LOG(1, "Search by guid [%ju:%ju] failed.",
+ (uintmax_t)spa_guid(vd->vdev_spa),
(uintmax_t)vd->vdev_guid);
}
@@ -581,7 +587,7 @@ vdev_geom_open_by_path(vdev_t *vd, int check_guid)
{
struct g_provider *pp;
struct g_consumer *cp;
- uint64_t guid;
+ uint64_t pguid, vguid;
g_topology_assert();
@@ -593,14 +599,17 @@ vdev_geom_open_by_path(vdev_t *vd, int check_guid)
if (cp != NULL && check_guid && ISP2(pp->sectorsize) &&
pp->sectorsize <= VDEV_PAD_SIZE) {
g_topology_unlock();
- guid = vdev_geom_read_guid(cp);
+ vdev_geom_read_guids(cp, &pguid, &vguid);
g_topology_lock();
- if (guid != vd->vdev_guid) {
+ if (pguid != spa_guid(vd->vdev_spa) ||
+ vguid != vd->vdev_guid) {
vdev_geom_detach(cp, 0);
cp = NULL;
ZFS_LOG(1, "guid mismatch for provider %s: "
- "%ju != %ju.", vd->vdev_path,
- (uintmax_t)vd->vdev_guid, (uintmax_t)guid);
+ "%ju:%ju != %ju:%ju.", vd->vdev_path,
+ (uintmax_t)spa_guid(vd->vdev_spa),
+ (uintmax_t)vd->vdev_guid,
+ (uintmax_t)pguid, (uintmax_t)vguid);
} else {
ZFS_LOG(1, "guid match for provider %s.",
vd->vdev_path);
@@ -634,23 +643,38 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
g_topology_lock();
error = 0;
- /*
- * If we're creating or splitting a pool, just find the GEOM provider
- * by its name and ignore GUID mismatches.
- */
- if (vd->vdev_spa->spa_load_state == SPA_LOAD_NONE ||
- vd->vdev_spa->spa_splitting_newspa == B_TRUE)
+ if (vd->vdev_spa->spa_splitting_newspa ||
+ (vd->vdev_prevstate == VDEV_STATE_UNKNOWN &&
+ vd->vdev_spa->spa_load_state == SPA_LOAD_NONE)) {
+ /*
+ * We are dealing with a vdev that hasn't been previously
+ * opened (since boot), and we are not loading an
+ * existing pool configuration. This looks like a
+ * vdev add operation to a new or existing pool.
+ * Assume the user knows what he/she is doing and find
+ * GEOM provider by its name, ignoring GUID mismatches.
+ *
+ * XXPOLICY: It would be safer to only allow a device
+ * that is unlabeled or labeled but missing
+ * GUID information to be opened in this fashion,
+ * unless we are doing a split, in which case we
+ * should allow any guid.
+ */
cp = vdev_geom_open_by_path(vd, 0);
- else {
+ } else {
+ /*
+ * Try using the recorded path for this device, but only
+ * accept it if its label data contains the expected GUIDs.
+ */
cp = vdev_geom_open_by_path(vd, 1);
if (cp == NULL) {
/*
* The device at vd->vdev_path doesn't have the
- * expected guid. The disks might have merely
+ * expected GUIDs. The disks might have merely
* moved around so try all other GEOM providers
- * to find one with the right guid.
+ * to find one with the right GUIDs.
*/
- cp = vdev_geom_open_by_guid(vd);
+ cp = vdev_geom_open_by_guids(vd);
}
}
diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk
index 58d1df9..6b81ec0 100644
--- a/sys/conf/kmod.mk
+++ b/sys/conf/kmod.mk
@@ -31,6 +31,9 @@
# MFILES Optionally a list of interfaces used by the module.
# This file contains a default list of interfaces.
#
+# KMODISLOADED Command to check whether a kernel module is
+# loaded [/sbin/kldstat -q -n]
+#
# PROG The name of the kernel module to build.
# If not supplied, ${KMOD}.ko is used.
#
@@ -59,6 +62,9 @@
# unload:
# Unload a module.
#
+# reload:
+# Unload if loaded, then load.
+#
# backwards compat option for older systems.
MACHINE_CPUARCH?=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc64/powerpc/}
@@ -66,6 +72,7 @@ MACHINE_CPUARCH?=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:
AWK?= awk
KMODLOAD?= /sbin/kldload
KMODUNLOAD?= /sbin/kldunload
+KMODISLOADED?= /sbin/kldstat -q -n
OBJCOPY?= objcopy
.if defined(KMODDEPS)
@@ -324,7 +331,11 @@ load: ${PROG}
.if !target(unload)
unload:
- ${KMODUNLOAD} -v ${PROG}
+ if ${KMODISLOADED} ${PROG} ; then ${KMODUNLOAD} -v ${PROG} ; fi
+.endif
+
+.if !target(reload)
+reload: unload load
.endif
.if defined(KERNBUILDDIR)
diff --git a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
index 3a27115..7582aec 100644
--- a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
@@ -1923,6 +1923,66 @@ create_storvsc_request(union ccb *ccb, struct hv_storvsc_request *reqp)
return(0);
}
+/*
+ * Modified based on scsi_print_inquiry which is responsible to
+ * print the detail information for scsi_inquiry_data.
+ *
+ * Return 1 if it is valid, 0 otherwise.
+ */
+static inline int
+is_inquiry_valid(const struct scsi_inquiry_data *inq_data)
+{
+ uint8_t type;
+ char vendor[16], product[48], revision[16];
+
+ /*
+ * Check device type and qualifier
+ */
+ if (!(SID_QUAL_IS_VENDOR_UNIQUE(inq_data) ||
+ SID_QUAL(inq_data) == SID_QUAL_LU_CONNECTED))
+ return (0);
+
+ type = SID_TYPE(inq_data);
+ switch (type) {
+ case T_DIRECT:
+ case T_SEQUENTIAL:
+ case T_PRINTER:
+ case T_PROCESSOR:
+ case T_WORM:
+ case T_CDROM:
+ case T_SCANNER:
+ case T_OPTICAL:
+ case T_CHANGER:
+ case T_COMM:
+ case T_STORARRAY:
+ case T_ENCLOSURE:
+ case T_RBC:
+ case T_OCRW:
+ case T_OSD:
+ case T_ADC:
+ break;
+ case T_NODEVICE:
+ default:
+ return (0);
+ }
+
+ /*
+ * Check vendor, product, and revision
+ */
+ cam_strvis(vendor, inq_data->vendor, sizeof(inq_data->vendor),
+ sizeof(vendor));
+ cam_strvis(product, inq_data->product, sizeof(inq_data->product),
+ sizeof(product));
+ cam_strvis(revision, inq_data->revision, sizeof(inq_data->revision),
+ sizeof(revision));
+ if (strlen(vendor) == 0 ||
+ strlen(product) == 0 ||
+ strlen(revision) == 0)
+ return (0);
+
+ return (1);
+}
+
/**
* @brief completion function before returning to CAM
*
@@ -1993,11 +2053,33 @@ storvsc_io_done(struct hv_storvsc_request *reqp)
ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
ccb->ccb_h.status &= ~CAM_STATUS_MASK;
if (vm_srb->scsi_status == SCSI_STATUS_OK) {
- ccb->ccb_h.status |= CAM_REQ_CMP;
- } else {
+ const struct scsi_generic *cmd;
+
+ /*
+ * Check whether the data for INQUIRY cmd is valid or
+ * not. Windows 10 and Windows 2016 send all zero
+ * inquiry data to VM even for unpopulated slots.
+ */
+ cmd = (const struct scsi_generic *)
+ ((ccb->ccb_h.flags & CAM_CDB_POINTER) ?
+ csio->cdb_io.cdb_ptr : csio->cdb_io.cdb_bytes);
+ if (cmd->opcode == INQUIRY &&
+ is_inquiry_valid(
+ (const struct scsi_inquiry_data *)csio->data_ptr) == 0) {
+ ccb->ccb_h.status |= CAM_DEV_NOT_THERE;
+ if (bootverbose) {
+ mtx_lock(&sc->hs_lock);
+ xpt_print(ccb->ccb_h.path,
+ "storvsc uninstalled device\n");
+ mtx_unlock(&sc->hs_lock);
+ }
+ } else {
+ ccb->ccb_h.status |= CAM_REQ_CMP;
+ }
+ } else {
mtx_lock(&sc->hs_lock);
xpt_print(ccb->ccb_h.path,
- "srovsc scsi_status = %d\n",
+ "storvsc scsi_status = %d\n",
vm_srb->scsi_status);
mtx_unlock(&sc->hs_lock);
ccb->ccb_h.status |= CAM_SCSI_STATUS_ERROR;
diff --git a/sys/dev/mlx5/mlx5_en/en.h b/sys/dev/mlx5/mlx5_en/en.h
index 0db15bd..b3433f7 100644
--- a/sys/dev/mlx5/mlx5_en/en.h
+++ b/sys/dev/mlx5/mlx5_en/en.h
@@ -375,11 +375,11 @@ struct mlx5e_params {
bool cqe_zipping_en;
u32 lro_wqe_sz;
u16 rx_hash_log_tbl_sz;
+ u32 tx_pauseframe_control;
+ u32 rx_pauseframe_control;
};
#define MLX5E_PARAMS(m) \
- m(+1, u64 tx_pauseframe_control, "tx_pauseframe_control", "Set to enable TX pause frames. Clear to disable.") \
- m(+1, u64 rx_pauseframe_control, "rx_pauseframe_control", "Set to enable RX pause frames. Clear to disable.") \
m(+1, u64 tx_queue_size_max, "tx_queue_size_max", "Max send queue size") \
m(+1, u64 rx_queue_size_max, "rx_queue_size_max", "Max receive queue size") \
m(+1, u64 tx_queue_size, "tx_queue_size", "Default send queue size") \
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c b/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
index e389a07..f7993e9 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
@@ -113,21 +113,6 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS)
}
priv->params.tx_cq_moderation_pkts = priv->params_ethtool.tx_coalesce_pkts;
- if (&priv->params_ethtool.arg[arg2] == &priv->params_ethtool.rx_pauseframe_control ||
- &priv->params_ethtool.arg[arg2] == &priv->params_ethtool.tx_pauseframe_control) {
- /* range check parameters */
- priv->params_ethtool.rx_pauseframe_control =
- priv->params_ethtool.rx_pauseframe_control ? 1 : 0;
- priv->params_ethtool.tx_pauseframe_control =
- priv->params_ethtool.tx_pauseframe_control ? 1 : 0;
-
- /* update firmware */
- error = -mlx5_set_port_pause(priv->mdev, 1,
- priv->params_ethtool.rx_pauseframe_control,
- priv->params_ethtool.tx_pauseframe_control);
- goto done;
- }
-
was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
if (was_opened) {
u64 *xarg = priv->params_ethtool.arg + arg2;
@@ -193,23 +178,21 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS)
priv->params.tx_cq_moderation_mode = priv->params_ethtool.tx_coalesce_mode;
/* we always agree to turn off HW LRO - but not always to turn on */
- if (priv->params_ethtool.hw_lro) {
- if (priv->params_ethtool.hw_lro != 1) {
- priv->params_ethtool.hw_lro = priv->params.hw_lro_en;
- error = EINVAL;
- goto done;
- }
- if (priv->ifp->if_capenable & IFCAP_LRO)
- priv->params.hw_lro_en = !!MLX5_CAP_ETH(priv->mdev, lro_cap);
- else {
- /* set the correct (0) value to params_ethtool.hw_lro, issue a warning and return error */
+ if (priv->params_ethtool.hw_lro != 0) {
+ if ((priv->ifp->if_capenable & IFCAP_LRO) &&
+ MLX5_CAP_ETH(priv->mdev, lro_cap)) {
+ priv->params.hw_lro_en = 1;
+ priv->params_ethtool.hw_lro = 1;
+ } else {
+ priv->params.hw_lro_en = 0;
priv->params_ethtool.hw_lro = 0;
error = EINVAL;
- if_printf(priv->ifp, "Can't set HW_LRO to a device with LRO turned off");
- goto done;
+
+ if_printf(priv->ifp, "Can't enable HW LRO: "
+ "The HW or SW LRO feature is disabled");
}
} else {
- priv->params.hw_lro_en = false;
+ priv->params.hw_lro_en = 0;
}
if (&priv->params_ethtool.arg[arg2] ==
@@ -223,7 +206,6 @@ mlx5e_ethtool_handler(SYSCTL_HANDLER_ARGS)
priv->params_ethtool.cqe_zipping = 0;
}
}
-
if (was_opened)
mlx5e_open_locked(priv->ifp);
done:
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
index 82ea69d..3676910 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
@@ -222,8 +222,8 @@ mlx5e_media_status(struct ifnet *dev, struct ifmediareq *ifmr)
ifmr->ifm_status = priv->media_status_last;
ifmr->ifm_active = priv->media_active_last |
- (priv->params_ethtool.rx_pauseframe_control ? IFM_ETH_RXPAUSE : 0) |
- (priv->params_ethtool.tx_pauseframe_control ? IFM_ETH_TXPAUSE : 0);
+ (priv->params.rx_pauseframe_control ? IFM_ETH_RXPAUSE : 0) |
+ (priv->params.tx_pauseframe_control ? IFM_ETH_TXPAUSE : 0);
}
@@ -250,6 +250,7 @@ mlx5e_media_change(struct ifnet *dev)
struct mlx5_core_dev *mdev = priv->mdev;
u32 eth_proto_cap;
u32 link_mode;
+ int was_opened;
int locked;
int error;
@@ -263,24 +264,45 @@ mlx5e_media_change(struct ifnet *dev)
}
link_mode = mlx5e_find_link_mode(IFM_SUBTYPE(priv->media.ifm_media));
+ /* query supported capabilities */
error = mlx5_query_port_proto_cap(mdev, &eth_proto_cap, MLX5_PTYS_EN);
- if (error) {
+ if (error != 0) {
if_printf(dev, "Query port media capability failed\n");
goto done;
}
- if (IFM_SUBTYPE(priv->media.ifm_media) == IFM_AUTO)
+ /* check for autoselect */
+ if (IFM_SUBTYPE(priv->media.ifm_media) == IFM_AUTO) {
link_mode = eth_proto_cap;
- else
+ if (link_mode == 0) {
+ if_printf(dev, "Port media capability is zero\n");
+ error = EINVAL;
+ goto done;
+ }
+ } else {
link_mode = link_mode & eth_proto_cap;
-
- if (!link_mode) {
- if_printf(dev, "Not supported link mode requested\n");
- error = EINVAL;
- goto done;
+ if (link_mode == 0) {
+ if_printf(dev, "Not supported link mode requested\n");
+ error = EINVAL;
+ goto done;
+ }
}
+ /* update pauseframe control bits */
+ priv->params.rx_pauseframe_control =
+ (priv->media.ifm_media & IFM_ETH_RXPAUSE) ? 1 : 0;
+ priv->params.tx_pauseframe_control =
+ (priv->media.ifm_media & IFM_ETH_TXPAUSE) ? 1 : 0;
+
+ /* check if device is opened */
+ was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
+
+ /* reconfigure the hardware */
mlx5_set_port_status(mdev, MLX5_PORT_DOWN);
mlx5_set_port_proto(mdev, link_mode, MLX5_PTYS_EN);
- mlx5_set_port_status(mdev, MLX5_PORT_UP);
+ mlx5_set_port_pause(mdev, 1,
+ priv->params.rx_pauseframe_control,
+ priv->params.tx_pauseframe_control);
+ if (was_opened)
+ mlx5_set_port_status(mdev, MLX5_PORT_UP);
done:
if (!locked)
@@ -2749,6 +2771,56 @@ mlx5e_add_hw_stats(struct mlx5e_priv *priv)
"Board ID");
}
+static void
+mlx5e_setup_pauseframes(struct mlx5e_priv *priv)
+{
+#if (__FreeBSD_version < 1100000)
+ char path[64];
+
+#endif
+ /* Only receiving pauseframes is enabled by default */
+ priv->params.tx_pauseframe_control = 0;
+ priv->params.rx_pauseframe_control = 1;
+
+#if (__FreeBSD_version < 1100000)
+ /* compute path for sysctl */
+ snprintf(path, sizeof(path), "dev.mce.%d.tx_pauseframe_control",
+ device_get_unit(priv->mdev->pdev->dev.bsddev));
+
+ /* try to fetch tunable, if any */
+ TUNABLE_INT_FETCH(path, &priv->params.tx_pauseframe_control);
+
+ /* compute path for sysctl */
+ snprintf(path, sizeof(path), "dev.mce.%d.rx_pauseframe_control",
+ device_get_unit(priv->mdev->pdev->dev.bsddev));
+
+ /* try to fetch tunable, if any */
+ TUNABLE_INT_FETCH(path, &priv->params.rx_pauseframe_control);
+#endif
+
+ /* register pausframe SYSCTLs */
+ SYSCTL_ADD_INT(&priv->sysctl_ctx, SYSCTL_CHILDREN(priv->sysctl_ifnet),
+ OID_AUTO, "tx_pauseframe_control", CTLFLAG_RDTUN,
+ &priv->params.tx_pauseframe_control, 0,
+ "Set to enable TX pause frames. Clear to disable.");
+
+ SYSCTL_ADD_INT(&priv->sysctl_ctx, SYSCTL_CHILDREN(priv->sysctl_ifnet),
+ OID_AUTO, "rx_pauseframe_control", CTLFLAG_RDTUN,
+ &priv->params.rx_pauseframe_control, 0,
+ "Set to enable RX pause frames. Clear to disable.");
+
+ /* range check */
+ priv->params.tx_pauseframe_control =
+ priv->params.tx_pauseframe_control ? 1 : 0;
+ priv->params.rx_pauseframe_control =
+ priv->params.rx_pauseframe_control ? 1 : 0;
+
+ /* update firmware */
+ mlx5_set_port_pause(priv->mdev, 1,
+ priv->params.rx_pauseframe_control,
+ priv->params.tx_pauseframe_control);
+}
+
static void *
mlx5e_create_ifp(struct mlx5_core_dev *mdev)
{
@@ -2874,11 +2946,11 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
/* Set default media status */
priv->media_status_last = IFM_AVALID;
- priv->media_active_last = IFM_ETHER | IFM_AUTO;
+ priv->media_active_last = IFM_ETHER | IFM_AUTO |
+ IFM_ETH_RXPAUSE | IFM_FDX;
- /* Pauseframes are enabled by default */
- priv->params_ethtool.tx_pauseframe_control = 1;
- priv->params_ethtool.rx_pauseframe_control = 1;
+ /* setup default pauseframes configuration */
+ mlx5e_setup_pauseframes(priv);
err = mlx5_query_port_proto_cap(mdev, &eth_proto_cap, MLX5_PTYS_EN);
if (err) {
@@ -2894,14 +2966,24 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
for (i = 0; i < MLX5E_LINK_MODES_NUMBER; ++i) {
if (mlx5e_mode_table[i].baudrate == 0)
continue;
- if (MLX5E_PROT_MASK(i) & eth_proto_cap)
+ if (MLX5E_PROT_MASK(i) & eth_proto_cap) {
+ ifmedia_add(&priv->media,
+ mlx5e_mode_table[i].subtype |
+ IFM_ETHER, 0, NULL);
ifmedia_add(&priv->media,
- IFM_ETHER | mlx5e_mode_table[i].subtype |
- IFM_FDX, 0, NULL);
+ mlx5e_mode_table[i].subtype |
+ IFM_ETHER | IFM_FDX |
+ IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE, 0, NULL);
+ }
}
ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL);
- ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO);
+ ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO | IFM_FDX |
+ IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE, 0, NULL);
+
+ /* Set autoselect by default */
+ ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO | IFM_FDX |
+ IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE);
ether_ifattach(ifp, dev_addr);
/* Register for VLAN events */
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
index 059b5ef..48339be 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
@@ -100,20 +100,23 @@ mlx5e_lro_update_hdr(struct mbuf *mb, struct mlx5_cqe64 *cqe)
/* TODO: consider vlans, ip options, ... */
struct ether_header *eh;
uint16_t eh_type;
+ uint16_t tot_len;
struct ip6_hdr *ip6 = NULL;
struct ip *ip4 = NULL;
struct tcphdr *th;
uint32_t *ts_ptr;
+ uint8_t l4_hdr_type;
+ int tcp_ack;
eh = mtod(mb, struct ether_header *);
eh_type = ntohs(eh->ether_type);
- u8 l4_hdr_type = get_cqe_l4_hdr_type(cqe);
- int tcp_ack = ((CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA == l4_hdr_type) ||
+ l4_hdr_type = get_cqe_l4_hdr_type(cqe);
+ tcp_ack = ((CQE_L4_HDR_TYPE_TCP_ACK_NO_DATA == l4_hdr_type) ||
(CQE_L4_HDR_TYPE_TCP_ACK_AND_DATA == l4_hdr_type));
/* TODO: consider vlan */
- u16 tot_len = be32_to_cpu(cqe->byte_cnt) - ETHER_HDR_LEN;
+ tot_len = be32_to_cpu(cqe->byte_cnt) - ETHER_HDR_LEN;
switch (eh_type) {
case ETHERTYPE_IP:
@@ -267,6 +270,11 @@ mlx5e_decompress_cqe(struct mlx5e_cq *cq, struct mlx5_cqe64 *title,
struct mlx5_mini_cqe8 *mini,
u16 wqe_counter, int i)
{
+ /*
+ * NOTE: The fields which are not set here are copied from the
+ * initial and common title. See memcpy() in
+ * mlx5e_write_cqe_slot().
+ */
title->byte_cnt = mini->byte_cnt;
title->wqe_counter = cpu_to_be16((wqe_counter + i) & cq->wq.sz_m1);
title->check_sum = mini->checksum;
diff --git a/sys/dev/syscons/plasma/fp16.c b/sys/dev/syscons/plasma/fp16.c
new file mode 100644
index 0000000..dddba2e
--- /dev/null
+++ b/sys/dev/syscons/plasma/fp16.c
@@ -0,0 +1,155 @@
+/*-
+ * Copyright (c) 2015 Dag-Erling Smørgrav
+ * 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$
+ */
+
+#ifdef _KERNEL
+#include <sys/libkern.h>
+#else
+#include <stdio.h>
+#include <strings.h>
+#endif
+
+#include "fp16.h"
+
+/*
+ * Compute the quare root of x, using Newton's method with 2^(log2(x)/2)
+ * as the initial estimate.
+ */
+fp16_t
+fp16_sqrt(fp16_t x)
+{
+ fp16_t y, delta;
+ signed int log2x;
+
+ /* special case */
+ if (x == 0)
+ return (0);
+
+ /* shift toward 0 by half the logarithm */
+ log2x = flsl(x) - 1;
+ if (log2x >= 16) {
+ y = x >> (log2x - 16) / 2;
+ } else {
+#if 0
+ y = x << (16 - log2x) / 2;
+#else
+ /* XXX for now, return 0 for anything < 1 */
+ return (0);
+#endif
+ }
+ while (y > 0) {
+ /* delta = y^2 / 2y */
+ delta = fp16_div(fp16_sub(fp16_mul(y, y), x), y * 2);
+ if (delta == 0)
+ break;
+ y = fp16_sub(y, delta);
+ }
+ return (y);
+}
+
+static fp16_t fp16_sin_table[256] = {
+ 0, 402, 804, 1206, 1608, 2010, 2412, 2814,
+ 3215, 3617, 4018, 4420, 4821, 5222, 5622, 6023,
+ 6423, 6823, 7223, 7623, 8022, 8421, 8819, 9218,
+ 9616, 10013, 10410, 10807, 11204, 11600, 11995, 12390,
+ 12785, 13179, 13573, 13966, 14359, 14751, 15142, 15533,
+ 15923, 16313, 16702, 17091, 17479, 17866, 18253, 18638,
+ 19024, 19408, 19792, 20175, 20557, 20938, 21319, 21699,
+ 22078, 22456, 22833, 23210, 23586, 23960, 24334, 24707,
+ 25079, 25450, 25820, 26189, 26557, 26925, 27291, 27656,
+ 28020, 28383, 28745, 29105, 29465, 29824, 30181, 30538,
+ 30893, 31247, 31600, 31952, 32302, 32651, 32999, 33346,
+ 33692, 34036, 34379, 34721, 35061, 35400, 35738, 36074,
+ 36409, 36743, 37075, 37406, 37736, 38064, 38390, 38716,
+ 39039, 39362, 39682, 40002, 40319, 40636, 40950, 41263,
+ 41575, 41885, 42194, 42501, 42806, 43110, 43412, 43712,
+ 44011, 44308, 44603, 44897, 45189, 45480, 45768, 46055,
+ 46340, 46624, 46906, 47186, 47464, 47740, 48015, 48288,
+ 48558, 48828, 49095, 49360, 49624, 49886, 50146, 50403,
+ 50660, 50914, 51166, 51416, 51665, 51911, 52155, 52398,
+ 52639, 52877, 53114, 53348, 53581, 53811, 54040, 54266,
+ 54491, 54713, 54933, 55152, 55368, 55582, 55794, 56004,
+ 56212, 56417, 56621, 56822, 57022, 57219, 57414, 57606,
+ 57797, 57986, 58172, 58356, 58538, 58718, 58895, 59070,
+ 59243, 59414, 59583, 59749, 59913, 60075, 60235, 60392,
+ 60547, 60700, 60850, 60998, 61144, 61288, 61429, 61568,
+ 61705, 61839, 61971, 62100, 62228, 62353, 62475, 62596,
+ 62714, 62829, 62942, 63053, 63162, 63268, 63371, 63473,
+ 63571, 63668, 63762, 63854, 63943, 64030, 64115, 64197,
+ 64276, 64353, 64428, 64501, 64571, 64638, 64703, 64766,
+ 64826, 64884, 64939, 64992, 65043, 65091, 65136, 65179,
+ 65220, 65258, 65294, 65327, 65358, 65386, 65412, 65436,
+ 65457, 65475, 65491, 65505, 65516, 65524, 65531, 65534,
+};
+
+/*
+ * Compute the sine of theta.
+ */
+fp16_t
+fp16_sin(fp16_t theta)
+{
+ unsigned int i;
+
+ i = 1024 * (theta % FP16_2PI) / FP16_2PI;
+ switch (i / 256) {
+ case 0:
+ return (fp16_sin_table[i % 256]);
+ case 1:
+ return (fp16_sin_table[255 - i % 256]);
+ case 2:
+ return (-fp16_sin_table[i % 256]);
+ case 3:
+ return (-fp16_sin_table[255 - i % 256]);
+ default:
+ /* inconceivable! */
+ return (0);
+ }
+}
+
+/*
+ * Compute the cosine of theta.
+ */
+fp16_t
+fp16_cos(fp16_t theta)
+{
+ unsigned int i;
+
+ i = 1024 * (theta % FP16_2PI) / FP16_2PI;
+ switch (i / 256) {
+ case 0:
+ return (fp16_sin_table[255 - i % 256]);
+ case 1:
+ return (-fp16_sin_table[i % 256]);
+ case 2:
+ return (-fp16_sin_table[255 - i % 256]);
+ case 3:
+ return (fp16_sin_table[i % 256]);
+ default:
+ /* inconceivable! */
+ return (0);
+ }
+}
diff --git a/sys/dev/syscons/plasma/fp16.h b/sys/dev/syscons/plasma/fp16.h
new file mode 100644
index 0000000..ae54d20
--- /dev/null
+++ b/sys/dev/syscons/plasma/fp16.h
@@ -0,0 +1,85 @@
+/*-
+ * Copyright (c) 2015 Dag-Erling Smørgrav
+ * 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$
+ */
+
+#ifndef FP16_H_INCLUDED
+#define FP16_H_INCLUDED
+
+typedef signed long long fp16_t;
+
+#define ItoFP16(n) ((signed long long)(n) << 16)
+#define FP16toI(n) ((signed long long)(n) >> 16)
+
+#ifndef _KERNEL
+#define FP16toF(n) ((n) / 65536.0)
+#endif
+
+/* add a and b */
+static inline fp16_t
+fp16_add(fp16_t a, fp16_t b)
+{
+
+ return (a + b);
+}
+
+/* subtract b from a */
+static inline fp16_t
+fp16_sub(fp16_t a, fp16_t b)
+{
+
+ return (a - b);
+}
+
+/* multiply a by b */
+static inline fp16_t
+fp16_mul(fp16_t a, fp16_t b)
+{
+
+ return (a * b >> 16);
+}
+
+/* divide a by b */
+static inline fp16_t
+fp16_div(fp16_t a, fp16_t b)
+{
+
+ return ((a << 16) / b);
+}
+
+/* square root */
+fp16_t fp16_sqrt(fp16_t);
+
+#define FP16_2PI 411774
+#define FP16_PI 205887
+#define FP16_PI_2 102943
+#define FP16_PI_4 51471
+
+/* sine and cosine */
+fp16_t fp16_sin(fp16_t);
+fp16_t fp16_cos(fp16_t);
+
+#endif
diff --git a/sys/dev/syscons/plasma/plasma_saver.c b/sys/dev/syscons/plasma/plasma_saver.c
new file mode 100644
index 0000000..761aa5c
--- /dev/null
+++ b/sys/dev/syscons/plasma/plasma_saver.c
@@ -0,0 +1,239 @@
+/*-
+ * Copyright (c) 2015 Dag-Erling Smørgrav
+ * 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$
+ *
+ * To CJA, in appreciation of Nighthawk brunches past and future.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/syslog.h>
+#include <sys/consio.h>
+#include <sys/fbio.h>
+
+#include <dev/fb/fbreg.h>
+#include <dev/fb/splashreg.h>
+#include <dev/syscons/syscons.h>
+
+#define SAVER_NAME "plasma_saver"
+
+#include "fp16.h"
+
+/*
+ * Preferred video modes
+ */
+static int modes[] = {
+ M_VGA_CG640,
+ M_PC98_PEGC640x480,
+ M_PC98_PEGC640x400,
+ M_VGA_CG320,
+ -1
+};
+
+/*
+ * Display parameters
+ */
+static unsigned char *vid;
+static unsigned int banksize, scrmode, scrw, scrh;
+static unsigned int blanked;
+
+/*
+ * List of foci
+ */
+#define FOCI 3
+static struct {
+ int x, y; /* coordinates */
+ int vx, vy; /* velocity */
+} plasma_foci[FOCI];
+
+/*
+ * Palette
+ */
+static struct {
+ unsigned char r, g, b;
+} plasma_pal[256];
+
+/*
+ * Draw a new frame
+ */
+static void
+plasma_update(video_adapter_t *adp)
+{
+ unsigned int x, y; /* coordinates */
+ signed int dx, dy; /* horizontal / vertical distance */
+ fp16_t sqd, d; /* square of distance and distance */
+ fp16_t m; /* magnitude */
+ unsigned int org, off; /* origin and offset */
+ unsigned int i; /* loop index */
+
+ /* switch to bank 0 */
+ vidd_set_win_org(adp, 0);
+ /* for each scan line */
+ for (y = org = off = 0; y < scrh; ++y) {
+ /* for each pixel on scan line */
+ for (x = 0; x < scrw; ++x, ++off) {
+ /* for each focus */
+ for (i = m = 0; i < FOCI; ++i) {
+ dx = x - plasma_foci[i].x;
+ dy = y - plasma_foci[i].y;
+ sqd = ItoFP16(dx * dx + dy * dy);
+ d = fp16_sqrt(sqd);
+ /* divide by 4 to stretch out the pattern */
+ m = fp16_sub(m, fp16_cos(d / 4));
+ }
+ /*
+ * m is now in the range +/- FOCI, but we need a
+ * value between 0 and 255. We scale to +/- 127
+ * and add 127, which moves it into the range [0,
+ * 254].
+ */
+ m = fp16_mul(m, ItoFP16(127));
+ m = fp16_div(m, ItoFP16(FOCI));
+ m = fp16_add(m, ItoFP16(127));
+ /* switch banks if necessary */
+ if (off > banksize) {
+ off -= banksize;
+ org += banksize;
+ vidd_set_win_org(adp, org);
+ }
+ /* plot */
+ vid[off] = FP16toI(m);
+ }
+ }
+ /* now move the foci */
+ for (i = 0; i < FOCI; ++i) {
+ plasma_foci[i].x += plasma_foci[i].vx;
+ if (plasma_foci[i].x < 0) {
+ /* bounce against left wall */
+ plasma_foci[i].vx = -plasma_foci[i].vx;
+ plasma_foci[i].x = -plasma_foci[i].x;
+ } else if (plasma_foci[i].x >= scrw) {
+ /* bounce against right wall */
+ plasma_foci[i].vx = -plasma_foci[i].vx;
+ plasma_foci[i].x = scrw - (plasma_foci[i].x - scrw);
+ }
+ plasma_foci[i].y += plasma_foci[i].vy;
+ if (plasma_foci[i].y < 0) {
+ /* bounce against ceiling */
+ plasma_foci[i].vy = -plasma_foci[i].vy;
+ plasma_foci[i].y = -plasma_foci[i].y;
+ } else if (plasma_foci[i].y >= scrh) {
+ /* bounce against floor */
+ plasma_foci[i].vy = -plasma_foci[i].vy;
+ plasma_foci[i].y = scrh - (plasma_foci[i].y - scrh);
+ }
+ }
+}
+
+/*
+ * Start or stop the screensaver
+ */
+static int
+plasma_saver(video_adapter_t *adp, int blank)
+{
+ int pl;
+
+ if (blank) {
+ /* switch to graphics mode */
+ if (blanked <= 0) {
+ pl = splhigh();
+ vidd_set_mode(adp, scrmode);
+ vidd_load_palette(adp, (unsigned char *)plasma_pal);
+ vidd_set_border(adp, 0);
+ blanked++;
+ vid = (unsigned char *)adp->va_window;
+ banksize = adp->va_window_size;
+ splx(pl);
+ vidd_clear(adp);
+ }
+ /* update display */
+ plasma_update(adp);
+ } else {
+ blanked = 0;
+ }
+ return (0);
+}
+
+/*
+ * Initialize on module load
+ */
+static int
+plasma_init(video_adapter_t *adp)
+{
+ video_info_t info;
+ int i;
+
+ /* select video mode */
+ for (i = 0; modes[i] >= 0; ++i)
+ if (vidd_get_info(adp, modes[i], &info) == 0)
+ break;
+ if (modes[i] < 0) {
+ log(LOG_NOTICE, "%s: no supported video modes\n", SAVER_NAME);
+ return (ENODEV);
+ }
+ scrmode = modes[i];
+ scrw = info.vi_width;
+ scrh = info.vi_height;
+
+ /* initialize the palette */
+ for (i = 0; i < 256; ++i)
+ plasma_pal[i].r = plasma_pal[i].g = plasma_pal[i].b = i;
+
+ /* randomize the foci */
+ for (i = 0; i < FOCI; i++) {
+ plasma_foci[i].x = random() % scrw;
+ plasma_foci[i].y = random() % scrh;
+ plasma_foci[i].vx = random() % 5 - 2;
+ plasma_foci[i].vy = random() % 5 - 2;
+ }
+
+ return (0);
+}
+
+/*
+ * Clean up before module unload
+ */
+static int
+plasma_term(video_adapter_t *adp)
+{
+
+ return (0);
+}
+
+/*
+ * Boilerplate
+ */
+static scrn_saver_t plasma_module = {
+ SAVER_NAME,
+ plasma_init,
+ plasma_term,
+ plasma_saver,
+ NULL
+};
+
+SAVER_MODULE(plasma_saver, plasma_module);
diff --git a/sys/fs/nandfs/nandfs_segment.c b/sys/fs/nandfs/nandfs_segment.c
index 8b1dc41..22fb7cd 100644
--- a/sys/fs/nandfs/nandfs_segment.c
+++ b/sys/fs/nandfs/nandfs_segment.c
@@ -479,6 +479,7 @@ nandfs_iterate_dirty_vnodes(struct mount *mp, struct nandfs_seginfo *seginfo)
struct nandfs_node *nandfs_node;
struct vnode *vp, *mvp;
struct thread *td;
+ struct bufobj *bo;
int error, update;
td = curthread;
@@ -499,17 +500,21 @@ nandfs_iterate_dirty_vnodes(struct mount *mp, struct nandfs_seginfo *seginfo)
update = 1;
}
+ bo = &vp->v_bufobj;
+ BO_LOCK(bo);
if (vp->v_bufobj.bo_dirty.bv_cnt) {
error = nandfs_iterate_dirty_buf(vp, seginfo, 0);
if (error) {
nandfs_error("%s: cannot iterate vnode:%p "
"err:%d\n", __func__, vp, error);
vput(vp);
+ BO_UNLOCK(bo);
return (error);
}
update = 1;
} else
vput(vp);
+ BO_UNLOCK(bo);
if (update)
nandfs_node_update(nandfs_node);
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
index df5441b..5419af8 100644
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -238,11 +238,13 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
Elf32_Addr *uplatform;
struct ps_strings *arginfo;
register_t *pos;
+ int issetugid;
KASSERT(curthread->td_proc == imgp->proc,
("unsafe elf_linux_fixup(), should be curproc"));
p = imgp->proc;
+ issetugid = imgp->proc->p_flag & P_SUGID ? 1 : 0;
arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
uplatform = (Elf32_Addr *)((caddr_t)arginfo - linux_szplatform);
args = (Elf32_Auxargs *)imgp->auxargs;
@@ -270,7 +272,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
AUXARGS_ENTRY(pos, AT_BASE, args->base);
- AUXARGS_ENTRY(pos, LINUX_AT_SECURE, 0);
+ AUXARGS_ENTRY(pos, LINUX_AT_SECURE, issetugid);
AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
diff --git a/sys/kern/kern_condvar.c b/sys/kern/kern_condvar.c
index 2700a25..95a6d09 100644
--- a/sys/kern/kern_condvar.c
+++ b/sys/kern/kern_condvar.c
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
@@ -47,6 +48,17 @@ __FBSDID("$FreeBSD$");
#endif
/*
+ * A bound below which cv_waiters is valid. Once cv_waiters reaches this bound,
+ * cv_signal must manually check the wait queue for threads.
+ */
+#define CV_WAITERS_BOUND INT_MAX
+
+#define CV_WAITERS_INC(cvp) do { \
+ if ((cvp)->cv_waiters < CV_WAITERS_BOUND) \
+ (cvp)->cv_waiters++; \
+} while (0)
+
+/*
* Common sanity checks for cv_wait* functions.
*/
#define CV_ASSERT(cvp, lock, td) do { \
@@ -122,7 +134,7 @@ _cv_wait(struct cv *cvp, struct lock_object *lock)
sleepq_lock(cvp);
- cvp->cv_waiters++;
+ CV_WAITERS_INC(cvp);
if (lock == &Giant.lock_object)
mtx_assert(&Giant, MA_OWNED);
DROP_GIANT();
@@ -184,7 +196,7 @@ _cv_wait_unlock(struct cv *cvp, struct lock_object *lock)
sleepq_lock(cvp);
- cvp->cv_waiters++;
+ CV_WAITERS_INC(cvp);
DROP_GIANT();
sleepq_add(cvp, lock, cvp->cv_description, SLEEPQ_CONDVAR, 0);
@@ -240,7 +252,7 @@ _cv_wait_sig(struct cv *cvp, struct lock_object *lock)
sleepq_lock(cvp);
- cvp->cv_waiters++;
+ CV_WAITERS_INC(cvp);
if (lock == &Giant.lock_object)
mtx_assert(&Giant, MA_OWNED);
DROP_GIANT();
@@ -307,7 +319,7 @@ _cv_timedwait_sbt(struct cv *cvp, struct lock_object *lock, sbintime_t sbt,
sleepq_lock(cvp);
- cvp->cv_waiters++;
+ CV_WAITERS_INC(cvp);
if (lock == &Giant.lock_object)
mtx_assert(&Giant, MA_OWNED);
DROP_GIANT();
@@ -376,7 +388,7 @@ _cv_timedwait_sig_sbt(struct cv *cvp, struct lock_object *lock,
sleepq_lock(cvp);
- cvp->cv_waiters++;
+ CV_WAITERS_INC(cvp);
if (lock == &Giant.lock_object)
mtx_assert(&Giant, MA_OWNED);
DROP_GIANT();
@@ -422,8 +434,15 @@ cv_signal(struct cv *cvp)
wakeup_swapper = 0;
sleepq_lock(cvp);
if (cvp->cv_waiters > 0) {
- cvp->cv_waiters--;
- wakeup_swapper = sleepq_signal(cvp, SLEEPQ_CONDVAR, 0, 0);
+ if (cvp->cv_waiters == CV_WAITERS_BOUND &&
+ sleepq_lookup(cvp) == NULL) {
+ cvp->cv_waiters = 0;
+ } else {
+ if (cvp->cv_waiters < CV_WAITERS_BOUND)
+ cvp->cv_waiters--;
+ wakeup_swapper = sleepq_signal(cvp, SLEEPQ_CONDVAR, 0,
+ 0);
+ }
}
sleepq_release(cvp);
if (wakeup_swapper)
diff --git a/sys/modules/syscons/Makefile b/sys/modules/syscons/Makefile
index b047845..85e513d 100644
--- a/sys/modules/syscons/Makefile
+++ b/sys/modules/syscons/Makefile
@@ -9,6 +9,7 @@ SUBDIR= ${_apm} \
${_fire} \
green \
${_logo} \
+ ${_plasma} \
${_rain} \
${_snake} \
${_star} \
@@ -25,6 +26,7 @@ _daemon= daemon
_dragon= dragon
_fire= fire
_logo= logo
+_plasma= plasma
_rain= rain
_snake= snake
_star= star
diff --git a/sys/modules/syscons/plasma/Makefile b/sys/modules/syscons/plasma/Makefile
new file mode 100644
index 0000000..c71c864
--- /dev/null
+++ b/sys/modules/syscons/plasma/Makefile
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../dev/syscons/plasma
+
+KMOD= plasma_saver
+SRCS= fp16.c plasma_saver.c
+
+.include <bsd.kmod.mk>
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index f75e1c7..a682631 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -336,25 +336,44 @@ OLD_FILES+=usr/include/bsnmp/snmpagent.h
OLD_FILES+=usr/include/bsnmp/snmpclient.h
OLD_FILES+=usr/include/bsnmp/snmpmod.h
OLD_FILES+=usr/lib/libbsnmp.a
+OLD_FILES+=usr/lib/libbsnmp.so
OLD_LIBS+=usr/lib/libbsnmp.so.6
OLD_FILES+=usr/lib/libbsnmp_p.a
OLD_FILES+=usr/lib/libbsnmptools.a
+OLD_FILES+=usr/lib/libbsnmptools.so
OLD_LIBS+=usr/lib/libbsnmptools.so.0
OLD_FILES+=usr/lib/libbsnmptools_p.a
+OLD_FILES+=usr/lib/snmp_atm.so
OLD_LIBS+=usr/lib/snmp_atm.so.6
+OLD_FILES+=usr/lib/snmp_bridge.so
OLD_LIBS+=usr/lib/snmp_bridge.so.6
+OLD_FILES+=usr/lib/snmp_hast.so
OLD_LIBS+=usr/lib/snmp_hast.so.6
+OLD_FILES+=usr/lib/snmp_hostres.so
OLD_LIBS+=usr/lib/snmp_hostres.so.6
+OLD_FILES+=usr/lib/snmp_lm75.so
OLD_LIBS+=usr/lib/snmp_lm75.so.6
+OLD_FILES+=usr/lib/snmp_mibII.so
OLD_LIBS+=usr/lib/snmp_mibII.so.6
+OLD_FILES+=usr/lib/snmp_netgraph.so
OLD_LIBS+=usr/lib/snmp_netgraph.so.6
+OLD_FILES+=usr/lib/snmp_pf.so
OLD_LIBS+=usr/lib/snmp_pf.so.6
+OLD_FILES+=usr/lib/snmp_target.so
OLD_LIBS+=usr/lib/snmp_target.so.6
+OLD_FILES+=usr/lib/snmp_usm.so
OLD_LIBS+=usr/lib/snmp_usm.so.6
+OLD_FILES+=usr/lib/snmp_vacm.so
OLD_LIBS+=usr/lib/snmp_vacm.so.6
+OLD_FILES+=usr/lib/snmp_wlan.so
OLD_LIBS+=usr/lib/snmp_wlan.so.6
+OLD_FILES+=usr/lib32/libbsnmp.a
+OLD_FILES+=usr/lib32/libbsnmp.so
+OLD_LIBS+=usr/lib32/libbsnmp.so.6
+OLD_FILES+=usr/lib32/libbsnmp_p.a
OLD_FILES+=usr/sbin/bsnmpd
OLD_FILES+=usr/sbin/gensnmptree
+OLD_FILES+=usr/share/examples/etc/snmpd.config
OLD_FILES+=usr/share/man/man1/bsnmpd.1.gz
OLD_FILES+=usr/share/man/man1/bsnmpget.1.gz
OLD_FILES+=usr/share/man/man1/bsnmpset.1.gz
@@ -3485,6 +3504,7 @@ OLD_FILES+=usr/include/c++/v1/unwind.h
OLD_FILES+=usr/include/c++/v1/utility
OLD_FILES+=usr/include/c++/v1/valarray
OLD_FILES+=usr/include/c++/v1/vector
+OLD_DIRS+=usr/include/c++/v1/tr1
OLD_DIRS+=usr/include/c++/v1/experimental
OLD_DIRS+=usr/include/c++/v1/ext
OLD_DIRS+=usr/include/c++/v1
diff --git a/usr.bin/dpv/dpv.1 b/usr.bin/dpv/dpv.1
index c8d321b..da9f776 100644
--- a/usr.bin/dpv/dpv.1
+++ b/usr.bin/dpv/dpv.1
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2013-2014 Devin Teske
+.\" Copyright (c) 2013-2015 Devin Teske
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd Sep 7, 2014
+.Dd Oct 22, 2015
.Dt DPV 1
.Os
.Sh NAME
@@ -425,6 +425,6 @@ for additional information.
A
.Nm
utility first appeared in
-.Fx 11.0 .
+.Fx 10.2 .
.Sh AUTHORS
.An Devin Teske Aq dteske@FreeBSD.org
diff --git a/usr.bin/locate/locate/locate.rc b/usr.bin/locate/locate/locate.rc
index 3ed0c38..99655c5 100644
--- a/usr.bin/locate/locate/locate.rc
+++ b/usr.bin/locate/locate/locate.rc
@@ -16,7 +16,7 @@
#SEARCHPATHS="/"
# paths unwanted in output
-#PRUNEPATHS="/tmp /usr/tmp /var/tmp /var/db/portsnap"
+#PRUNEPATHS="/tmp /usr/tmp /var/tmp /var/db/portsnap /var/db/freebsd-update"
# directories unwanted in output
#PRUNEDIRS=".zfs"
diff --git a/usr.bin/locate/locate/updatedb.sh b/usr.bin/locate/locate/updatedb.sh
index 37c42e3..97f096d 100644
--- a/usr.bin/locate/locate/updatedb.sh
+++ b/usr.bin/locate/locate/updatedb.sh
@@ -51,7 +51,7 @@ PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH
: ${mklocatedb:=locate.mklocatedb} # make locate database program
: ${FCODES:=/var/db/locate.database} # the database
: ${SEARCHPATHS="/"} # directories to be put in the database
-: ${PRUNEPATHS="/tmp /usr/tmp /var/tmp /var/db/portsnap"} # unwanted directories
+: ${PRUNEPATHS="/tmp /usr/tmp /var/tmp /var/db/portsnap /var/db/freebsd-update"} # unwanted directories
: ${PRUNEDIRS=".zfs"} # unwanted directories, in any parent
: ${FILESYSTEMS="$(lsvfs | tail -n +3 | \
egrep -vw "loopback|network|synthetic|read-only|0" | \
diff --git a/usr.bin/truncate/tests/truncate_test.sh b/usr.bin/truncate/tests/truncate_test.sh
index e66f48a..369deba 100644
--- a/usr.bin/truncate/tests/truncate_test.sh
+++ b/usr.bin/truncate/tests/truncate_test.sh
@@ -173,26 +173,23 @@ bad_refer_body()
[ ! -e afile ] || atf_fail "afile should not exist"
}
-atf_test_case bad_truncate cleanup
+atf_test_case bad_truncate
bad_truncate_head()
{
atf_set "descr" "Verifies that truncate reports an error during" \
"truncation"
+ atf_set "require.user" "unprivileged"
}
bad_truncate_body()
{
- create_stderr_file "truncate: exists.txt: Operation not permitted"
+ create_stderr_file "truncate: exists.txt: Permission denied"
# Trying to get the ftruncate() call to return -1.
> exists.txt
- atf_check chflags uimmutable exists.txt
+ atf_check chmod 444 exists.txt
atf_check -s not-exit:0 -e file:stderr.txt truncate -s1 exists.txt
}
-bad_truncate_cleanup()
-{
- chflags 0 exists.txt
-}
atf_test_case new_absolute_grow
new_absolute_grow_head()
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index fccef4a..7d58988 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -90,6 +90,7 @@ SUBDIR= adduser \
tzsetup \
uefisign \
ugidfw \
+ vigr \
vipw \
wake \
watch \
diff --git a/usr.sbin/bhyvectl/Makefile b/usr.sbin/bhyvectl/Makefile
index 5f879fe..48477ff 100644
--- a/usr.sbin/bhyvectl/Makefile
+++ b/usr.sbin/bhyvectl/Makefile
@@ -5,7 +5,7 @@
PROG= bhyvectl
SRCS= bhyvectl.c
-MAN=
+MAN= bhyvectl.8
DPADD= ${LIBVMMAPI} ${LIBUTIL}
LDADD= -lvmmapi -lutil
diff --git a/usr.sbin/bhyvectl/bhyvectl.8 b/usr.sbin/bhyvectl/bhyvectl.8
new file mode 100644
index 0000000..d72a795
--- /dev/null
+++ b/usr.sbin/bhyvectl/bhyvectl.8
@@ -0,0 +1,97 @@
+.\" Copyright (c) 2015 Christian Brueffer
+.\" 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$
+.\"
+.Dd January 12, 2016
+.Dt BHYVECTL 8
+.Os
+.Sh NAME
+.Nm bhyvectl
+.Nd "control utility for bhyve instances"
+.Sh SYNOPSIS
+.Nm
+.Fl -vm= Ns Ar <vmname>
+.Op Fl -create
+.Op Fl -destroy
+.Op Fl -get-stats
+.Op Fl -inject-nmi
+.Op Fl -force-reset
+.Op Fl -force-poweroff
+.Sh DESCRIPTION
+The
+.Nm
+command is a control utility for active
+.Xr bhyve 8
+virtual machine instances.
+.Pp
+.Em Note :
+Most
+.Nm
+flags are intended for querying and setting the state of an active instance.
+These commands are intended for development purposes, and are not documented here.
+A complete list can be obtained by executing
+.Nm
+without any arguments.
+.Pp
+The user-facing options are as follows:
+.Bl -tag -width ".Fl d Ar argument"
+.It Fl -vm= Ns Ar <vmname>
+Operate on the virtual machine
+.Ar <vmname> .
+.It Fl -create
+Create the specified VM.
+.It Fl -destroy
+Destroy the specified VM.
+.It Fl -get-state
+Retrieve statistics for the specified VM.
+.It Fl -inject-nmi
+Inject a non-maskable interrupt (NMI) into the VM.
+.It Fl -force-reset
+Force the VM to reset.
+.It Fl -force-poweroff
+Force the VM to power off.
+.El
+.Sh EXIT STATUS
+.Ex -std
+.Sh EXAMPLES
+Destroy the VM called fbsd10:
+.Pp
+.Dl "bhyvectl --vm=fbsd10 --destroy"
+.Sh SEE ALSO
+.Xr bhyve 8 ,
+.Xr bhyveload 8
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Fx 10.1 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+utility was written by
+.An Peter Grehan
+and
+.An Neel Natu .
diff --git a/usr.sbin/bsdconfig/share/dialog.subr b/usr.sbin/bsdconfig/share/dialog.subr
index d7c2d2c..1e63aec 100644
--- a/usr.sbin/bsdconfig/share/dialog.subr
+++ b/usr.sbin/bsdconfig/share/dialog.subr
@@ -1605,7 +1605,6 @@ f_dialog_pause()
$height $width
else
[ $duration -gt 0 ] && duration=$(( $duration - 1 ))
- [ $duration -gt 1 ] && duration=$(( $duration - 1 ))
height=$(( $height + 3 )) # Add height for progress bar
$DIALOG \
--title "$DIALOG_TITLE" \
diff --git a/usr.sbin/bsdconfig/share/strings.subr b/usr.sbin/bsdconfig/share/strings.subr
index 487e061..e624fb5 100644
--- a/usr.sbin/bsdconfig/share/strings.subr
+++ b/usr.sbin/bsdconfig/share/strings.subr
@@ -110,7 +110,7 @@ f_sprintf()
# Example 2:
#
# limit=12 format="%s %s"
-# format_args=" 'doghouse' 'foxhound' "
+# format_args=" 'doghouse' 'fox' "
# # even more spaces added to illustrate escape-method
# f_vsnprintf foo $limit "$format" "$format_args" # foo=[doghouse fox]
#
diff --git a/usr.sbin/vigr/Makefile b/usr.sbin/vigr/Makefile
new file mode 100644
index 0000000..d71998b
--- /dev/null
+++ b/usr.sbin/vigr/Makefile
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+SCRIPTS= vigr
+MAN= vigr.8
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/vigr/vigr.8 b/usr.sbin/vigr/vigr.8
new file mode 100644
index 0000000..3fd582b
--- /dev/null
+++ b/usr.sbin/vigr/vigr.8
@@ -0,0 +1,71 @@
+.\"-
+.\" Copyright (c) 2014 Dag-Erling Smørgrav
+.\" 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$
+.\"
+.Dd December 14, 2014
+.Dt VIGR 8
+.Os
+.Sh NAME
+.Nm vigr
+.Nd edit the group file
+.Sh SYNOPSIS
+.Nm
+.Op Fl d Ar directory
+.Sh DESCRIPTION
+The
+.Nm
+utility makes a temporary copy of the group file, allows the user to
+edit it, then verifies that the edited file is valid before installing
+it.
+.Pp
+The following options are available:
+.Bl -tag -width Fl
+.It Fl d Ar directory
+Edit the group file in the specified directory instead of the default
+.Pa /etc/group .
+.El
+.Sh ENVIRONMENT
+.Bl -tag -width EDITOR
+.It Ev EDITOR
+The editor to use instead of
+.Xr vi 1 .
+.It Ev TMPDIR
+The directory in which to store the temporary copy of the group file.
+.El
+.Sh SEE ALSO
+.Xr group 5 ,
+.Xr chkgrp 8 ,
+.Xr vipw 8
+.Sh HISTORY
+The
+.Nm
+utility appeared in
+.Fx 11.0 .
+.Sh AUTHORS
+The
+.Nm
+utility and this manual page were written by
+.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
diff --git a/usr.sbin/vigr/vigr.sh b/usr.sbin/vigr/vigr.sh
new file mode 100644
index 0000000..c5dc65d
--- /dev/null
+++ b/usr.sbin/vigr/vigr.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+#-
+# Copyright (c) 2014 Dag-Erling Smørgrav
+# 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$
+#
+
+error() {
+ echo "$@" >&2
+ exit 1
+}
+
+usage() {
+ error "usage: vigr [-d dir]"
+}
+
+# Check arguments
+while getopts d: opt ; do
+ case $opt in
+ d)
+ etcdir="${OPTARG}"
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+
+# Look for the current group file
+grpfile="${etcdir:-/etc}/group"
+if [ ! -f "${grpfile}" ] ; then
+ error "Missing group file"
+fi
+
+# Create a secure temporary working directory
+tmpdir=$(mktemp -d -t vigr)
+if [ -z "${tmpdir}" -o ! -d "${tmpdir}" ] ; then
+ error "Unable to create the temporary directory"
+fi
+tmpfile="${tmpdir}/group"
+
+# Clean up on exit
+trap "exit 1" INT
+trap "rm -rf '${tmpdir}'" EXIT
+set -e
+
+# Make a copy of the group file for the user to edit
+cp "${grpfile}" "${tmpfile}"
+
+while :; do
+ # Let the user edit the file
+ ${EDITOR:-/usr/bin/vi} "${tmpfile}"
+
+ # If the result is valid, install it and exit
+ if chkgrp -q "${tmpfile}" ; then
+ install -b -m 0644 -C -S "${tmpfile}" "${grpfile}"
+ exit 0
+ fi
+
+ # If it is not, offer to re-edit
+ while :; do
+ echo -n "Re-edit the group file? "
+ read ans
+ case $ans in
+ [Yy]|[Yy][Ee][Ss])
+ break
+ ;;
+ [Nn]|[Nn][Oo])
+ exit 1
+ ;;
+ esac
+ done
+done
OpenPOWER on IntegriCloud