aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/boot/rootgen.sh433
-rwxr-xr-xtools/boot/universe.sh36
-rw-r--r--tools/build/Makefile13
-rw-r--r--tools/build/cross-build/include/common/sys/types.h12
-rw-r--r--tools/build/cross-build/include/linux/strings.h40
-rwxr-xr-xtools/build/depend-cleanup.sh8
-rw-r--r--tools/build/mk/OptionalObsoleteFiles.inc108
-rw-r--r--tools/build/options/WITHOUT_DTRACE2
-rw-r--r--tools/build/options/WITHOUT_MACHDEP_OPTIMIZATIONS1
-rw-r--r--tools/diag/prtblknos/main.c6
-rw-r--r--tools/regression/netinet/ipdivert/ipdivert.c2
-rw-r--r--tools/regression/netinet/tcpstream/tcpstream.c2
-rw-r--r--tools/test/iconv/posix/posix.c16
-rw-r--r--tools/test/stress2/misc/all.exclude5
-rwxr-xr-xtools/test/stress2/misc/badcode3.sh7
-rwxr-xr-xtools/test/stress2/misc/fork2.sh135
-rwxr-xr-xtools/test/stress2/misc/fsck.sh4
-rwxr-xr-xtools/test/stress2/misc/fsck8.sh179
-rwxr-xr-xtools/test/stress2/misc/fsck9.sh168
-rwxr-xr-xtools/test/stress2/misc/gunion.sh7
-rwxr-xr-xtools/test/stress2/misc/gunion2.sh7
-rwxr-xr-xtools/test/stress2/misc/mount7.sh57
-rwxr-xr-xtools/test/stress2/misc/setrlimit.sh193
-rwxr-xr-xtools/test/stress2/misc/setrlimit2.sh118
-rwxr-xr-xtools/test/stress2/misc/signal2.sh53
-rwxr-xr-xtools/test/stress2/misc/sigreturn2.sh69
-rwxr-xr-xtools/test/stress2/misc/sigreturn3.sh182
-rwxr-xr-xtools/test/stress2/misc/sigreturn4.sh208
-rwxr-xr-xtools/test/stress2/misc/swap6.sh2
-rwxr-xr-xtools/test/stress2/misc/syzkaller29.sh2
-rwxr-xr-xtools/test/stress2/misc/syzkaller30.sh2
-rwxr-xr-xtools/test/stress2/misc/syzkaller61.sh319
-rwxr-xr-xtools/test/stress2/misc/syzkaller62.sh83
-rw-r--r--tools/test/stress2/testcases/swap/swap.c6
-rw-r--r--tools/tools/ether_reflect/ether_reflect.16
-rw-r--r--tools/tools/git/git-arc.sh52
-rw-r--r--tools/tools/netmap/pkt-gen.c19
-rw-r--r--tools/tools/netrate/tcpp/tcpp_server.c2
-rw-r--r--tools/uma/smrstress/smrstress.c1
39 files changed, 2189 insertions, 376 deletions
diff --git a/tools/boot/rootgen.sh b/tools/boot/rootgen.sh
index b61fff647b5c..06e8a1ec8245 100755
--- a/tools/boot/rootgen.sh
+++ b/tools/boot/rootgen.sh
@@ -7,23 +7,19 @@ iterations=50000
# The smallest FAT32 filesystem is 33292 KB
espsize=33292
-dev=vtbd0
#
# Builds all the bat-shit crazy combinations we support booting from,
# at least for amd64. It assume you have a ~sane kernel in /boot/kernel
# and copies that into the ~150MB root images we create (we create the du
-# size of the kernel + 20MB
+# size of the kernel + 20MB).
#
-# Sad panda sez: this runs as root, but could be userland if someone
-# creates userland geli and zfs tools.
+# Sad panda sez: this runs as root, but could be any user if someone
+# creates userland geli.
#
# This assumes an external program install-boot.sh which will install
# the appropriate boot files in the appropriate locations.
#
-# These images assume ${dev} will be the root image. We should likely
-# use labels, but we don't.
-#
# Assumes you've already rebuilt... maybe bad? Also maybe bad: the env
# vars should likely be conditionally set to allow better automation.
#
@@ -38,14 +34,20 @@ cpsys() {
(cd $src ; tar cf - .) | (cd $dst; tar xf -)
}
+ufs_fstab() {
+ dir=$1
+
+ cat > ${dir}/etc/fstab <<EOF
+/dev/ufs/root / ufs rw 1 1
+EOF
+}
+
mk_nogeli_gpt_ufs_legacy() {
src=$1
img=$2
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}p2 / ufs rw 1 1
-EOF
- makefs -t ffs -B little -s 200m ${img}.p2 ${src}
+ ufs_fstab ${src}
+ makefs -t ffs -B little -s 200m -o label=root ${img}.p2 ${src}
mkimg -s gpt -b ${src}/boot/pmbr \
-p freebsd-boot:=${src}/boot/gptboot \
-p freebsd-ufs:=${img}.p2 -o ${img}
@@ -56,11 +58,9 @@ mk_nogeli_gpt_ufs_uefi() {
src=$1
img=$2
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}p2 / ufs rw 1 1
-EOF
+ ufs_fstab ${src}
make_esp_file ${img}.p1 ${espsize} ${src}/boot/loader.efi
- makefs -t ffs -B little -s 200m ${img}.p2 ${src}
+ makefs -t ffs -B little -s 200m -o label=root ${img}.p2 ${src}
mkimg -s gpt \
-p efi:=${img}.p1 \
-p freebsd-ufs:=${img}.p2 -o ${img}
@@ -71,11 +71,9 @@ mk_nogeli_gpt_ufs_both() {
src=$1
img=$2
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}p3 / ufs rw 1 1
-EOF
+ ufs_fstab ${src}
make_esp_file ${img}.p1 ${espsize} ${src}/boot/loader.efi
- makefs -t ffs -B little -s 200m ${img}.p3 ${src}
+ makefs -t ffs -B little -s 200m -o label=root ${img}.p3 ${src}
# p1 is boot for uefi, p2 is boot for gpt, p3 is /
mkimg -b ${src}/boot/pmbr -s gpt \
-p efi:=${img}.p1 \
@@ -85,6 +83,23 @@ EOF
rm -f ${src}/etc/fstab
}
+# XXX should not assume host == target
+zfs_extra()
+{
+ src=$1
+ dst=$2
+
+ mkdir -p $dst
+ mkdir -p $dst/boot/kernel
+ cat > ${dst}/boot/loader.conf.local <<EOF
+cryptodev_load=YES
+zfs_load=YES
+EOF
+ cp /boot/kernel/acl_nfs4.ko ${dst}/boot/kernel/acl_nfs4.ko
+ cp /boot/kernel/cryptodev.ko ${dst}/boot/kernel/cryptodev.ko
+ cp /boot/kernel/zfs.ko ${dst}/boot/kernel/zfs.ko
+}
+
mk_nogeli_gpt_zfs_legacy() {
src=$1
img=$2
@@ -94,34 +109,17 @@ mk_nogeli_gpt_zfs_legacy() {
fs=$6
bios=$7
pool=nogeli-gpt-zfs-legacy
+ dst=$img.extra
- dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
- md=$(mdconfig -f ${img})
- gpart create -s gpt ${md}
- gpart add -t freebsd-boot -s 400k -a 4k ${md} # <= ~540k
- gpart add -t freebsd-zfs -l root $md
- # install-boot will make this bootable
- zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}p2
- zpool set bootfs=${pool} ${pool}
- zfs create -po mountpoint=/ ${pool}/ROOT/default
- # NB: The online guides go nuts customizing /var and other mountpoints here, no need
- cpsys ${src} ${mntpt}
- # need to make a couple of tweaks
- cat >> ${mntpt}/boot/loader.conf <<EOF
-cryptodev_load=YES
-zfs_load=YES
-EOF
- cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko
- cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko
- cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
- # end tweaks
- zfs umount -f ${pool}/ROOT/default
- zfs set mountpoint=none ${pool}/ROOT/default
- zpool set bootfs=${pool}/ROOT/default ${pool}
- zpool set autoexpand=on ${pool}
- zpool export ${pool}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
+ zfs_extra $src $dst
+ makefs -t zfs -s 200m \
+ -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
+ ${img}.p2 ${src} ${dst}
+ mkimg -b ${src}/boot/pmbr -s gpt \
+ -p freebsd-boot:=/boot/gptzfsboot \
+ -p freebsd-zfs:=${img}.p2 \
+ -o ${img}
+ rm -rf ${dst}
}
mk_nogeli_gpt_zfs_uefi() {
@@ -133,34 +131,18 @@ mk_nogeli_gpt_zfs_uefi() {
fs=$6
bios=$7
pool=nogeli-gpt-zfs-uefi
+ dst=$img.extra
- dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
- md=$(mdconfig -f ${img})
- gpart create -s gpt ${md}
- gpart add -t efi -s ${espsize}k -a 4k ${md}
- gpart add -t freebsd-zfs -l root $md
- # install-boot will make this bootable
- zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}p2
- zpool set bootfs=${pool} ${pool}
- zfs create -po mountpoint=/ ${pool}/ROOT/default
- # NB: The online guides go nuts customizing /var and other mountpoints here, no need
- cpsys ${src} ${mntpt}
- # need to make a couple of tweaks
- cat >> ${mntpt}/boot/loader.conf <<EOF
-cryptodev_load=YES
-zfs_load=YES
-EOF
- cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko
- cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko
- cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
- # end tweaks
- zfs umount -f ${pool}/ROOT/default
- zfs set mountpoint=none ${pool}/ROOT/default
- zpool set bootfs=${pool}/ROOT/default ${pool}
- zpool set autoexpand=on ${pool}
- zpool export ${pool}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
+ zfs_extra $src $dst
+ make_esp_file ${img}.p1 ${espsize} ${src}/boot/loader.efi
+ makefs -t zfs -s 200m \
+ -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
+ ${img}.p2 ${src} ${dst}
+ mkimg -b ${src}/boot/pmbr -s gpt \
+ -p efi:=${img}.p1 \
+ -p freebsd-zfs:=${img}.p2 \
+ -o ${img}
+ rm -rf ${dst}
}
mk_nogeli_gpt_zfs_both() {
@@ -172,45 +154,27 @@ mk_nogeli_gpt_zfs_both() {
fs=$6
bios=$7
pool=nogeli-gpt-zfs-both
+ dst=$img.extra
- dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
- md=$(mdconfig -f ${img})
- gpart create -s gpt ${md}
- gpart add -t efi -s ${espsize}k -a 4k ${md}
- gpart add -t freebsd-boot -s 400k -a 4k ${md} # <= ~540k
- gpart add -t freebsd-zfs -l root $md
- # install-boot will make this bootable
- zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}p3
- zpool set bootfs=${pool} ${pool}
- zfs create -po mountpoint=/ ${pool}/ROOT/default
- # NB: The online guides go nuts customizing /var and other mountpoints here, no need
- cpsys ${src} ${mntpt}
- # need to make a couple of tweaks
- cat >> ${mntpt}/boot/loader.conf <<EOF
-cryptodev_load=YES
-zfs_load=YES
-EOF
- cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko
- cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko
- cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
- # end tweaks
- zfs umount -f ${pool}/ROOT/default
- zfs set mountpoint=none ${pool}/ROOT/default
- zpool set bootfs=${pool}/ROOT/default ${pool}
- zpool set autoexpand=on ${pool}
- zpool export ${pool}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
+ zfs_extra $src $dst
+ make_esp_file ${img}.p2 ${espsize} ${src}/boot/loader.efi
+ makefs -t zfs -s 200m \
+ -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
+ ${img}.p3 ${src} ${dst}
+ mkimg -b ${src}/boot/pmbr -s gpt \
+ -p freebsd-boot:=/boot/gptzfsboot \
+ -p efi:=${img}.p2 \
+ -p freebsd-zfs:=${img}.p3 \
+ -o ${img}
+ rm -rf ${dst}
}
mk_nogeli_mbr_ufs_legacy() {
src=$1
img=$2
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}s1a / ufs rw 1 1
-EOF
- makefs -t ffs -B little -s 200m ${img}.s1a ${src}
+ ufs_fstab ${src}
+ makefs -t ffs -B little -s 200m -o label=root ${img}.s1a ${src}
mkimg -s bsd -b ${src}/boot/boot -p freebsd-ufs:=${img}.s1a -o ${img}.s1
mkimg -a 1 -s mbr -b ${src}/boot/boot0sio -p freebsd:=${img}.s1 -o ${img}
rm -f ${src}/etc/fstab
@@ -220,11 +184,9 @@ mk_nogeli_mbr_ufs_uefi() {
src=$1
img=$2
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}s2a / ufs rw 1 1
-EOF
+ ufs_fstab ${src}
make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi
- makefs -t ffs -B little -s 200m ${img}.s2a ${src}
+ makefs -t ffs -B little -s 200m -o label=root ${img}.s2a ${src}
mkimg -s bsd -p freebsd-ufs:=${img}.s2a -o ${img}.s2
mkimg -a 1 -s mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img}
rm -f ${src}/etc/fstab
@@ -234,11 +196,9 @@ mk_nogeli_mbr_ufs_both() {
src=$1
img=$2
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}s2a / ufs rw 1 1
-EOF
+ ufs_fstab ${src}
make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi
- makefs -t ffs -B little -s 200m ${img}.s2a ${src}
+ makefs -t ffs -B little -s 200m -o label=root ${img}.s2a ${src}
mkimg -s bsd -b ${src}/boot/boot -p freebsd-ufs:=${img}.s2a -o ${img}.s2
mkimg -a 2 -s mbr -b ${src}/boot/mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img}
rm -f ${src}/etc/fstab
@@ -254,35 +214,21 @@ mk_nogeli_mbr_zfs_legacy() {
bios=$7
pool=nogeli-mbr-zfs-legacy
- dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
- md=$(mdconfig -f ${img})
- gpart create -s mbr ${md}
- gpart add -t freebsd ${md}
- gpart set -a active -i 1 ${md}
- gpart create -s bsd ${md}s1
- gpart add -t freebsd-zfs ${md}s1
- # install-boot will make this bootable
- zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}s1a
- zpool set bootfs=${pool} ${pool}
- zfs create -po mountpoint=/ ${pool}/ROOT/default
- # NB: The online guides go nuts customizing /var and other mountpoints here, no need
- cpsys ${src} ${mntpt}
- # need to make a couple of tweaks
- cat >> ${mntpt}/boot/loader.conf <<EOF
-cryptodev_load=YES
-zfs_load=YES
-EOF
- cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko
- cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko
- cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
- # end tweaks
- zfs umount -f ${pool}/ROOT/default
- zfs set mountpoint=none ${pool}/ROOT/default
- zpool set bootfs=${pool}/ROOT/default ${pool}
- zpool set autoexpand=on ${pool}
- zpool export ${pool}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
+ zfs_extra $src $dst
+ makefs -t zfs -s 200m \
+ -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
+ ${img}.s1a ${src} ${dst}
+ # The old boot1/boot2 boot split is also used by zfs. We need to extract zfsboot1
+ # from this image. Since there's no room in the mbr format for the rest of the loader,
+ # it will load the zfsboot loader from the reserved for bootloader area of the ZFS volume
+ # being booted, hence the need to dd it into the raw img later.
+ # Please note: zfsboot only works with partition 'a' which must be the root
+ # partition / zfs volume
+ dd if=${src}/boot/zfsboot of=${dst}/zfsboot1 count=1
+ mkimg -s bsd -b ${dst}zfsboot1 -p freebsd-zfs:=${img}.s1a -o ${img}.s1
+ dd if=${src}/boot/zfsboot of=${img}.s1a skip=1 seek=1024
+ mkimg -a 1 -s mbr -b ${src}/boot/mbr -p freebsd:=${img}.s1 -o ${img}
+ rm -rf ${dst}
}
mk_nogeli_mbr_zfs_uefi() {
@@ -295,36 +241,14 @@ mk_nogeli_mbr_zfs_uefi() {
bios=$7
pool=nogeli-mbr-zfs-uefi
- dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
- md=$(mdconfig -f ${img})
- gpart create -s mbr ${md}
- gpart add -t efi -s ${espsize}k ${md}
- gpart add -t freebsd ${md}
- gpart set -a active -i 2 ${md}
- gpart create -s bsd ${md}s2
- gpart add -t freebsd-zfs ${md}s2
- # install-boot will make this bootable
- zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}s2a
- zpool set bootfs=${pool} ${pool}
- zfs create -po mountpoint=/ ${pool}/ROOT/default
- # NB: The online guides go nuts customizing /var and other mountpoints here, no need
- cpsys ${src} ${mntpt}
- # need to make a couple of tweaks
- cat >> ${mntpt}/boot/loader.conf <<EOF
-cryptodev_load=YES
-zfs_load=YES
-EOF
- cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko
- cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko
- cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
- # end tweaks
- zfs umount -f ${pool}/ROOT/default
- zfs set mountpoint=none ${pool}/ROOT/default
- zpool set bootfs=${pool}/ROOT/default ${pool}
- zpool set autoexpand=on ${pool}
- zpool export ${pool}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
+ zfs_extra $src $dst
+ make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi
+ makefs -t zfs -s 200m \
+ -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
+ ${img}.s2a ${src} ${dst}
+ mkimg -s bsd -b ${dst}zfsboot1 -p freebsd-zfs:=${img}.s2a -o ${img}.s2
+ mkimg -a 1 -s mbr -b ${src}/boot/mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img}
+ rm -rf ${dst}
}
mk_nogeli_mbr_zfs_both() {
@@ -337,36 +261,21 @@ mk_nogeli_mbr_zfs_both() {
bios=$7
pool=nogeli-mbr-zfs-both
- dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
- md=$(mdconfig -f ${img})
- gpart create -s mbr ${md}
- gpart add -t efi -s ${espsize}k ${md}
- gpart add -t freebsd ${md}
- gpart set -a active -i 2 ${md}
- gpart create -s bsd ${md}s2
- gpart add -t freebsd-zfs ${md}s2
- # install-boot will make this bootable
- zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}s2a
- zpool set bootfs=${pool} ${pool}
- zfs create -po mountpoint=/ ${pool}/ROOT/default
- # NB: The online guides go nuts customizing /var and other mountpoints here, no need
- cpsys ${src} ${mntpt}
- # need to make a couple of tweaks
- cat >> ${mntpt}/boot/loader.conf <<EOF
-cryptodev_load=YES
-zfs_load=YES
-EOF
- cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko
- cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko
- cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
- # end tweaks
- zfs umount -f ${pool}/ROOT/default
- zfs set mountpoint=none ${pool}/ROOT/default
- zpool set bootfs=${pool}/ROOT/default ${pool}
- zpool set autoexpand=on ${pool}
- zpool export ${pool}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
+ zfs_extra $src $dst
+ make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi
+ makefs -t zfs -s 200m \
+ -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
+ ${img}.s2a ${src} ${dst}
+ # The old boot1/boot2 boot split is also used by zfs. We need to extract zfsboot1
+ # from this image. Since there's no room in the mbr format for the rest of the loader,
+ # it will load the zfsboot loader from the reserved for bootloader area of the ZFS volume
+ # being booted, hence the need to dd it into the raw img later.
+ # Please note: zfsboot only works with partition 'a' which must be the root
+ # partition / zfs volume
+ dd if=${src}/boot/zfsboot of=${dst}/zfsboot1 count=1
+ mkimg -s bsd -b ${dst}zfsboot1 -p freebsd-zfs:=${img}.s2a -o ${img}.s2
+ dd if=${src}/boot/zfsboot of=${img}.s1a skip=1 seek=1024
+ mkimg -a 1 -s mbr -b ${src}/boot/mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img}
}
mk_geli_gpt_ufs_legacy() {
@@ -386,16 +295,14 @@ mk_geli_gpt_ufs_legacy() {
# install-boot will make this bootable
echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p2
echo ${passphrase} | geli attach -j - ${md}p2
- newfs /dev/${md}p2.eli
+ newfs -L root /dev/${md}p2.eli
mount /dev/${md}p2.eli ${mntpt}
cpsys ${src} ${mntpt}
# need to make a couple of tweaks
cat > ${mntpt}/boot/loader.conf <<EOF
geom_eli_load=YES
EOF
- cat > ${mntpt}/etc/fstab <<EOF
-/dev/${dev}p2.eli / ufs rw 1 1
-EOF
+ ufs_fstab ${mntpt}
cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko
# end tweaks
@@ -422,16 +329,14 @@ mk_geli_gpt_ufs_uefi() {
# install-boot will make this bootable
echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p2
echo ${passphrase} | geli attach -j - ${md}p2
- newfs /dev/${md}p2.eli
+ newfs -L root /dev/${md}p2.eli
mount /dev/${md}p2.eli ${mntpt}
cpsys ${src} ${mntpt}
# need to make a couple of tweaks
cat > ${mntpt}/boot/loader.conf <<EOF
geom_eli_load=YES
EOF
- cat > ${mntpt}/etc/fstab <<EOF
-/dev/${dev}p2.eli / ufs rw 1 1
-EOF
+ ufs_fstab ${mntpt}
cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko
# end tweaks
@@ -459,16 +364,14 @@ mk_geli_gpt_ufs_both() {
# install-boot will make this bootable
echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p3
echo ${passphrase} | geli attach -j - ${md}p3
- newfs /dev/${md}p3.eli
+ newfs -L root /dev/${md}p3.eli
mount /dev/${md}p3.eli ${mntpt}
cpsys ${src} ${mntpt}
# need to make a couple of tweaks
cat > ${mntpt}/boot/loader.conf <<EOF
geom_eli_load=YES
EOF
- cat > ${mntpt}/etc/fstab <<EOF
-/dev/${dev}p3.eli / ufs rw 1 1
-EOF
+ ufs_fstab ${mntpt}
cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko
# end tweaks
@@ -645,30 +548,7 @@ mk_geli_mbr_zfs_both() {
# u-boot
# powerpc
-mk_sparc64_nogeli_vtoc8_ufs_ofw() {
- src=$1
- img=$2
- mntpt=$3
- geli=$4
- scheme=$5
- fs=$6
- bios=$7
-
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}a / ufs rw 1 1
-EOF
- makefs -t ffs -B big -s 200m ${img} ${src}
- md=$(mdconfig -f ${img})
- # For non-native builds, ensure that geom_part(4) supports VTOC8.
- kldload geom_part_vtoc8.ko
- gpart create -s VTOC8 ${md}
- gpart add -t freebsd-ufs ${md}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
- rm -f ${src}/etc/fstab
-}
-
-qser="-serial telnet::4444,server -nographic"
+qser="-monitor telnet::4444,server,nowait -serial stdio -nographic"
# https://wiki.freebsd.org/QemuRecipes
# aarch64
@@ -687,13 +567,22 @@ qemu_aarch64_uefi()
# -netdev user,id=net0
}
+log_for()
+{
+ dir=$(dirname $1)
+ fn=$(basename $1 .sh)
+ echo $dir/$fn.log
+}
+
# Amd64 qemu
qemu_amd64_legacy()
{
img=$1
sh=$2
+ log=$(log_for $2)
- echo "qemu-system-x86_64 -m 256m --drive file=${img},format=raw ${qser}" > $sh
+ echo "echo -n $(basename $sh .sh):' '" > $sh
+ echo "(qemu-system-x86_64 -m 256m --drive file=${img},format=raw ${qser} | tee $log 2>&1 | grep -q SUCCESS) && echo legacy pass || echo legacy fail" >> $sh
chmod 755 $sh
}
@@ -701,8 +590,10 @@ qemu_amd64_uefi()
{
img=$1
sh=$2
+ log=$(log_for $2)
- echo "qemu-system-x86_64 -m 256m -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser}" > $sh
+ echo "echo -n $(basename $sh .sh):' '" > $sh
+ echo "(qemu-system-x86_64 -m 256m -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser} | tee $log 2>&1 | grep -q SUCCESS) && echo uefi pass || echo uefi fail" >> $sh
chmod 755 $sh
}
@@ -710,9 +601,12 @@ qemu_amd64_both()
{
img=$1
sh=$2
+ log=$(log_for $2)
- echo "qemu-system-x86_64 -m 256m --drive file=${img},format=raw ${qser}" > $sh
- echo "qemu-system-x86_64 -m 256m -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser}" >> $sh
+ echo "echo -n $(basename $sh .sh):' '" > $sh
+ echo "(qemu-system-x86_64 -m 256m --drive file=${img},format=raw ${qser} | tee $log 2>&1 | grep -q SUCCESS) && echo legacy pass || echo legacy fail" >> $sh
+ echo "echo -n $(basename $sh .sh):' '" >> $sh
+ echo "(qemu-system-x86_64 -m 256m -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser} | tee -a $log 2>&1 | grep -q SUCCESS) && echo uefi pass || echo uefi fail" >> $sh
chmod 755 $sh
}
@@ -761,6 +655,8 @@ make_one_image()
# Create sparse file and mount newly created filesystem(s) on it
img=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.img
sh=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.sh
+ echo "$sh" >> ${IMGDIR}/all.sh
+ echo date >> ${IMGDIR}/all.sh
echo "vvvvvvvvvvvvvv Creating $img vvvvvvvvvvvvvvv"
rm -f ${img}*
eval mk_${geli}_${scheme}_${fs}_${bios} ${DESTDIR} ${img} ${MNTPT} ${geli} ${scheme} ${fs} ${bios}
@@ -769,16 +665,10 @@ make_one_image()
echo "^^^^^^^^^^^^^^ Created $img ^^^^^^^^^^^^^^^"
}
-# mips
-# qemu-system-mips -kernel /path/to/rootfs/boot/kernel/kernel -nographic -hda /path/to/disk.img -m 2048
-
# Powerpc -- doesn't work but maybe it would enough for testing -- needs details
# powerpc64
# qemu-system-ppc64 -drive file=/path/to/disk.img,format=raw
-# sparc64
-# qemu-system-sparc64 -drive file=/path/to/disk.img,format=raw
-
# Misc variables
SRCTOP=$(make -v SRCTOP)
cd ${SRCTOP}/stand
@@ -796,6 +686,7 @@ cp /boot/kernel/kernel ${DESTDIR}/boot/kernel
echo -h -D -S115200 > ${DESTDIR}/boot.config
cat > ${DESTDIR}/boot/loader.conf <<EOF
comconsole_speed=115200
+autoboot_delay=0
EOF
# XXX
cp /boot/device.hints ${DESTDIR}/boot/device.hints
@@ -822,15 +713,20 @@ EOF
# If we were given exactly 5 args, go make that one image.
+rm -f ${IMGDIR}/all.sh
+echo date > ${IMGDIR}/all.sh
+chmod +x ${IMGDIR}/all.sh
+
if [ $# -eq 5 ]; then
make_one_image $*
+ echo ${IMGDIR}/all.sh
exit
fi
# OK. Let the games begin
for arch in amd64; do
- for geli in nogeli geli; do
+ for geli in nogeli; do # geli
for scheme in gpt mbr; do
for fs in ufs zfs; do
for bios in legacy uefi both; do
@@ -840,6 +736,8 @@ for arch in amd64; do
done
done
done
+ # We should also do a cd image for amd64 here
+echo ${IMGDIR}/all.sh
rmdir ${MNTPT}
@@ -852,39 +750,42 @@ for arch in i386; do
for scheme in gpt mbr; do
for fs in ufs zfs; do
for bios in legacy; do
+ # The legacy boot is shared with amd64 so those routines could
+ # likely be used here.
make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
done
done
done
done
done
+ # We should also do a cd image for i386 here
for arch in arm aarch64; do
+ geli=nogeli # I don't think geli boot works / is supported on arm
for scheme in gpt mbr; do
- fs=ufs
- for bios in uboot efi; do
- make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
- done
+ for fs in ufs zfs; do
+ bios=efi # Note: arm has some uboot support with ufs, what to do?
+ make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
+ done
done
done
-for arch in powerpc powerpc64; do
- for scheme in ppc-wtf; do
- fs=ufs
+# It's not clear that the nested looping paradigm is best for powerpc
+# due to its diversity.
+for arch in powerpc powerpc64 powerpc64le; do
+ geli=nogeli
+ for scheme in apm gpt; do
+ fs=ufs # zfs + gpt might be supported?
for bios in ofw uboot chrp; do
make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
done
done
done
-for arch in sparc64; do
- for geli in nogeli; do
- for scheme in vtoc8; do
- for fs in ufs; do
- for bios in ofw; do
- make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
- done
- done
- done
- done
+for arch in riscv; do
+ geli=nogeli
+ fs=ufs # Generic ZFS booting support with efi?
+ scheme=gpt
+ bios=efi
+ make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
done
diff --git a/tools/boot/universe.sh b/tools/boot/universe.sh
index a23678100705..6fcb496baf8c 100755
--- a/tools/boot/universe.sh
+++ b/tools/boot/universe.sh
@@ -3,13 +3,9 @@
# $FreeBSD$
#
-# Full list of all arches, but we only build a subset. All different mips add any
-# value, and there's a few others we just don't support.
+# Full list of all arches we don't build.
#
-# mips/mipsel mips/mips mips/mips64el mips/mips64 mips/mipsn32 \
-# mips/mipselhf mips/mipshf mips/mips64elhf mips/mips64hf \
-# powerpc/powerpc powerpc/powerpc64 powerpc/powerpcspe \
-# riscv/riscv64 riscv/riscv64sf
+# powerpc/powerpcspe riscv/riscv64sf arm/armv6
#
# This script is expected to be run in stand (though you could run it anywhere
# in the tree). It does a full clean build. For stand you can do all the archs in
@@ -45,7 +41,7 @@ dobuild()
echo "Fail (cleanup)"
continue
fi
- if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make ${opt} -j 20 all" \
+ if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make ${opt} -j 40 all" \
>> $lf 2>&1; then
echo "Fail (build)"
continue
@@ -58,6 +54,7 @@ cd $top/stand
# Build without forth
for i in \
+ arm64/aarch64 \
amd64/amd64 \
i386/i386 \
; do
@@ -67,6 +64,7 @@ done
# Build without GELI
for i in \
+ arm64/aarch64 \
amd64/amd64 \
i386/i386 \
; do
@@ -74,39 +72,29 @@ for i in \
dobuild $ta _.boot.${ta}.no_geli.log "WITHOUT_LOADER_GEIL=yes"
done
-# Default build for a goodly selection of architectures
+# Default build for a almost all architectures
for i in \
amd64/amd64 \
arm/armv7 \
arm64/aarch64 \
i386/i386 \
- mips/mips mips/mips64 \
- powerpc/powerpc powerpc/powerpc64 \
+ powerpc/powerpc \
+ powerpc/powerpc64 \
+ powerpc/powerpc64le \
+ riscv/riscv64 \
; do
ta=${i##*/}
dobuild $ta _.boot.${ta}.log ""
done
-# Default build for a goodly selection of architectures with Lua
-for i in \
- amd64/amd64 \
- arm/armv7 \
- arm64/aarch64 \
- i386/i386 \
- mips/mips mips/mips64 \
- powerpc/powerpc powerpc/powerpc64 \
- ; do
- ta=${i##*/}
- dobuild $ta _.boot.${ta}.lua.log "MK_LOADER_LUA=yes MK_FORTH=no"
-done
-
# Build w/o ZFS
for i in \
+ arm64/aarch64 \
amd64/amd64 \
i386/i386 \
; do
ta=${i##*/}
- dobuild $ta _.boot.${ta}.no_zfs.log "MK_ZFS=no"
+ dobuild $ta _.boot.${ta}.no_zfs.log "MK_LOADER_ZFS=no"
done
# Build with firewire
diff --git a/tools/build/Makefile b/tools/build/Makefile
index 00f5e3e45337..8c723e8be73c 100644
--- a/tools/build/Makefile
+++ b/tools/build/Makefile
@@ -153,6 +153,15 @@ SYSINCS+= ${SRCTOP}/sys/sys/nlist_aout.h
.if ${.MAKE.OS} != "FreeBSD"
.PATH: ${.CURDIR}/cross-build
+
+# Needed by our sys/types.h wrapper
+SYSINCS+= ${SRCTOP}/sys/sys/bitcount.h
+
+# macOS's bitstring lacks FreeBSD-specific additions used by makefs's ZFS code
+# and Linux doesn't have it at all.
+INCS+= ${SRCTOP}/include/bitstring.h
+SYSINCS+= ${SRCTOP}/sys/sys/bitstring.h
+
# dbopen() behaves differently on Linux and FreeBSD so we ensure that we
# bootstrap the FreeBSD db code. The cross-build headers #define dbopen() to
# __freebsd_dbopen() so that we don't ever use the host version
@@ -181,6 +190,8 @@ SRCS+= rpmatch.c
# On Linux, glibc does not provide strlcpy,strlcat or strmode.
.PATH: ${LIBC_SRCTOP}/string
SRCS+= strlcpy.c strlcat.c strmode.c
+# On Linux, glibc provides ffs* but not fls*
+SRCS+= fls.c flsl.c flsll.c
# Compile the fgetln/fgetwln/closefrom fallback code from libbsd:
SRCS+= fgetln_fallback.c fgetwln_fallback.c closefrom.c
CFLAGS.closefrom.c+= -DSTDC_HEADERS -DHAVE_SYS_DIR_H -DHAVE_DIRENT_H \
@@ -240,7 +251,7 @@ DISKINCS+= ${SRCTOP}/sys/sys/disk/bsd.h
# Needed to build config (since it uses libnv)
SYSINCS+= ${SRCTOP}/sys/sys/nv.h ${SRCTOP}/sys/sys/cnv.h \
- ${SRCTOP}/sys/sys/dnv.h
+ ${SRCTOP}/sys/sys/dnv.h ${SRCTOP}/sys/sys/nv_namespace.h
# Needed when bootstrapping ldd (since it uses DF_1_PIE)
SYSINCS+= ${SRCTOP}/sys/sys/elf32.h
diff --git a/tools/build/cross-build/include/common/sys/types.h b/tools/build/cross-build/include/common/sys/types.h
index 044ca6bed4f8..0bfe2bac2aea 100644
--- a/tools/build/cross-build/include/common/sys/types.h
+++ b/tools/build/cross-build/include/common/sys/types.h
@@ -68,4 +68,16 @@ typedef unsigned long cap_ioctl_t;
struct cap_rights;
typedef struct cap_rights cap_rights_t;
+
+/*
+ * make.py uses these headers during the bmake bootstrap on Linux only, at
+ * which point sys/bitcount.h won't yet exist, so don't include it there.
+ *
+ * TODO: Untangle this mess.
+ */
+#if __has_include(<sys/bitcount.h>)
+/* Needed for bitstring */
+#include <sys/bitcount.h>
+#endif
+
#endif
diff --git a/tools/build/cross-build/include/linux/strings.h b/tools/build/cross-build/include/linux/strings.h
new file mode 100644
index 000000000000..827ef23f1c82
--- /dev/null
+++ b/tools/build/cross-build/include/linux/strings.h
@@ -0,0 +1,40 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright 2022 Jessica Clarke <jrtc27@FreeBSD.org>
+ *
+ * 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$
+ */
+#pragma once
+#include <sys/cdefs.h>
+
+#include_next <strings.h>
+
+__BEGIN_DECLS
+
+int fls(int) __pure2;
+int flsl(long) __pure2;
+int flsll(long long) __pure2;
+
+__END_DECLS
diff --git a/tools/build/depend-cleanup.sh b/tools/build/depend-cleanup.sh
index 39b06b45d45f..35066ee7f921 100755
--- a/tools/build/depend-cleanup.sh
+++ b/tools/build/depend-cleanup.sh
@@ -90,3 +90,11 @@ fi
if [ "$MACHINE_ARCH" = "amd64" ]; then
clean_dep lib/libc bcmp c
fi
+
+# 20220524 68fe988a40ca kqueue_test binary replaced shell script
+if stat "$OBJTOP"/tests/sys/kqueue/libkqueue/*kqtest* \
+ "$OBJTOP"/tests/sys/kqueue/libkqueue/.depend.kqtest* >/dev/null 2>&1; then
+ echo "Removing old kqtest"
+ rm -f "$OBJTOP"/tests/sys/kqueue/libkqueue/.depend.* \
+ "$OBJTOP"/tests/sys/kqueue/libkqueue/*
+fi
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index 85257d41140c..1bcc0d2d80bc 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -178,6 +178,15 @@ OLD_FILES+=usr/share/man/man8/autounmountd.8.gz
OLD_DIRS+=etc/autofs
.endif
+.if ${MK_BEARSSL} == no
+OLD_FILES+=usr/lib/libbearssl.a
+OLD_FILES+=usr/lib/libbearssl.so
+OLD_LIBS+=usr/lib/libbearssl.so.5
+OLD_FILES+=usr/lib/libsecureboot.a
+OLD_FILES+=usr/lib/libsecureboot.so
+OLD_LIBS+=usr/lib/libsecureboot.so.5
+.endif
+
.if ${MK_BHYVE} == no
OLD_FILES+=usr/lib/libvmmapi.a
OLD_FILES+=usr/lib/libvmmapi.so
@@ -902,13 +911,9 @@ OLD_FILES+=usr/share/man/man4/ccd.4.gz
OLD_FILES+=usr/share/man/man8/ccdconfig.8.gz
.endif
-.if ${MK_CDDL} == no
-OLD_LIBS+=lib/libavl.so.2
+.if ${MK_DTRACE} == no
OLD_LIBS+=lib/libctf.so.2
OLD_LIBS+=lib/libdtrace.so.2
-OLD_LIBS+=lib/libnvpair.so.2
-OLD_LIBS+=lib/libumem.so.2
-OLD_LIBS+=lib/libuutil.so.2
OLD_FILES+=usr/bin/ctfconvert
OLD_FILES+=usr/bin/ctfdump
OLD_FILES+=usr/bin/ctfmerge
@@ -929,24 +934,12 @@ OLD_FILES+=usr/lib/dtrace/tcp.d
OLD_FILES+=usr/lib/dtrace/udp.d
OLD_FILES+=usr/lib/dtrace/udplite.d
OLD_FILES+=usr/lib/dtrace/unistd.d
-OLD_FILES+=usr/lib/libavl.a
-OLD_FILES+=usr/lib/libavl.so
-OLD_FILES+=usr/lib/libavl_p.a
OLD_FILES+=usr/lib/libctf.a
OLD_FILES+=usr/lib/libctf.so
OLD_FILES+=usr/lib/libctf_p.a
OLD_FILES+=usr/lib/libdtrace.a
OLD_FILES+=usr/lib/libdtrace.so
OLD_FILES+=usr/lib/libdtrace_p.a
-OLD_FILES+=usr/lib/libnvpair.a
-OLD_FILES+=usr/lib/libnvpair.so
-OLD_FILES+=usr/lib/libnvpair_p.a
-OLD_FILES+=usr/lib/libumem.a
-OLD_FILES+=usr/lib/libumem.so
-OLD_FILES+=usr/lib/libumem_p.a
-OLD_FILES+=usr/lib/libuutil.a
-OLD_FILES+=usr/lib/libuutil.so
-OLD_FILES+=usr/lib/libuutil_p.a
OLD_LIBS+=lib/libdtrace.so.2
OLD_FILES+=usr/libexec/dwatch/chmod
OLD_FILES+=usr/libexec/dwatch/errno
@@ -1080,6 +1073,10 @@ OLD_FILES+=etc/periodic/daily/404.status-zfs
OLD_FILES+=etc/periodic/daily/800.scrub-zfs
OLD_FILES+=etc/zfs/exports
OLD_DIRS+=etc/zfs
+OLD_LIBS+=lib/libavl.so.2
+OLD_LIBS+=lib/libnvpair.so.2
+OLD_LIBS+=lib/libumem.so.2
+OLD_LIBS+=lib/libuutil.so.2
OLD_LIBS+=lib/libzfs.so.2
OLD_LIBS+=lib/libzfs.so.3
OLD_LIBS+=lib/libzfs_core.so.2
@@ -1098,6 +1095,18 @@ OLD_FILES+=usr/lib/libbe.a
OLD_FILES+=usr/lib/libbe_p.a
OLD_FILES+=usr/lib/libbe.so
OLD_LIBS+=lib/libbe.so.1
+OLD_FILES+=usr/lib/libavl.a
+OLD_FILES+=usr/lib/libavl.so
+OLD_FILES+=usr/lib/libavl_p.a
+OLD_FILES+=usr/lib/libnvpair.a
+OLD_FILES+=usr/lib/libnvpair.so
+OLD_FILES+=usr/lib/libnvpair_p.a
+OLD_FILES+=usr/lib/libumem.a
+OLD_FILES+=usr/lib/libumem.so
+OLD_FILES+=usr/lib/libumem_p.a
+OLD_FILES+=usr/lib/libuutil.a
+OLD_FILES+=usr/lib/libuutil.so
+OLD_FILES+=usr/lib/libuutil_p.a
OLD_FILES+=usr/lib/libzfs.a
OLD_FILES+=usr/lib/libzfs.so
OLD_FILES+=usr/lib/libzfs_core.a
@@ -2088,6 +2097,11 @@ OLD_FILES+=usr/share/man/man8/strfile.8.gz
OLD_FILES+=usr/share/man/man8/unstr.8.gz
.endif
+.if ${MK_LLVM_BINUTILS} == no
+OLD_FILES+=usr/bin/objdump
+OLD_FILES+=usr/share/man/man1/objdump.1.gz
+.endif
+
.if ${MK_LLVM_COV} == no && !defined(WITH_PORT_BASE_GCC)
OLD_FILES+=usr/bin/gcov
OLD_FILES+=usr/share/man/man1/gcov.1.gz
@@ -2455,6 +2469,52 @@ OLD_FILES+=usr/bin/mkcsmapper
OLD_FILES+=usr/bin/mkesdb
OLD_FILES+=usr/include/_libiconv_compat.h
OLD_FILES+=usr/include/iconv.h
+OLD_LIBS+=usr/lib/i18n/libBIG5.so.5
+OLD_FILES+=usr/lib/i18n/libBIG5.so
+OLD_LIBS+=usr/lib/i18n/libDECHanyu.so.5
+OLD_FILES+=usr/lib/i18n/libDECHanyu.so
+OLD_LIBS+=usr/lib/i18n/libEUC.so.5
+OLD_FILES+=usr/lib/i18n/libEUC.so
+OLD_LIBS+=usr/lib/i18n/libEUCTW.so.5
+OLD_FILES+=usr/lib/i18n/libEUCTW.so
+OLD_LIBS+=usr/lib/i18n/libGBK2K.so.5
+OLD_FILES+=usr/lib/i18n/libGBK2K.so
+OLD_LIBS+=usr/lib/i18n/libHZ.so.5
+OLD_FILES+=usr/lib/i18n/libHZ.so
+OLD_LIBS+=usr/lib/i18n/libISO2022.so.5
+OLD_FILES+=usr/lib/i18n/libISO2022.so
+OLD_LIBS+=usr/lib/i18n/libJOHAB.so.5
+OLD_FILES+=usr/lib/i18n/libJOHAB.so
+OLD_LIBS+=usr/lib/i18n/libMSKanji.so.5
+OLD_FILES+=usr/lib/i18n/libMSKanji.so
+OLD_LIBS+=usr/lib/i18n/libUES.so.5
+OLD_FILES+=usr/lib/i18n/libUES.so
+OLD_LIBS+=usr/lib/i18n/libUTF1632.so.5
+OLD_FILES+=usr/lib/i18n/libUTF1632.so
+OLD_LIBS+=usr/lib/i18n/libUTF7.so.5
+OLD_FILES+=usr/lib/i18n/libUTF7.so
+OLD_LIBS+=usr/lib/i18n/libUTF8.so.5
+OLD_FILES+=usr/lib/i18n/libUTF8.so
+OLD_LIBS+=usr/lib/i18n/libVIQR.so.5
+OLD_FILES+=usr/lib/i18n/libVIQR.so
+OLD_LIBS+=usr/lib/i18n/libZW.so.5
+OLD_FILES+=usr/lib/i18n/libZW.so
+OLD_LIBS+=usr/lib/i18n/libiconv_none.so.5
+OLD_FILES+=usr/lib/i18n/libiconv_none.so
+OLD_LIBS+=usr/lib/i18n/libiconv_std.so.5
+OLD_FILES+=usr/lib/i18n/libiconv_std.so
+OLD_LIBS+=usr/lib/i18n/libmapper_646.so.5
+OLD_FILES+=usr/lib/i18n/libmapper_646.so
+OLD_LIBS+=usr/lib/i18n/libmapper_none.so.5
+OLD_FILES+=usr/lib/i18n/libmapper_none.so
+OLD_LIBS+=usr/lib/i18n/libmapper_parallel.so.5
+OLD_FILES+=usr/lib/i18n/libmapper_parallel.so
+OLD_LIBS+=usr/lib/i18n/libmapper_serial.so.5
+OLD_FILES+=usr/lib/i18n/libmapper_serial.so
+OLD_LIBS+=usr/lib/i18n/libmapper_std.so.5
+OLD_FILES+=usr/lib/i18n/libmapper_std.so
+OLD_LIBS+=usr/lib/i18n/libmapper_zone.so.5
+OLD_FILES+=usr/lib/i18n/libmapper_zone.so
OLD_FILES+=usr/share/man/man1/iconv.1.gz
OLD_FILES+=usr/share/man/man1/mkcsmapper.1.gz
OLD_FILES+=usr/share/man/man1/mkesdb.1.gz
@@ -2468,6 +2528,7 @@ OLD_FILES+=usr/share/man/man3/iconv_open.3.gz
OLD_FILES+=usr/share/man/man3/iconv_open_into.3.gz
OLD_FILES+=usr/share/man/man3/iconvctl.3.gz
OLD_FILES+=usr/share/man/man3/iconvlist.3.gz
+OLD_DIRS+=usr/lib/i18n
OLD_DIRS+=usr/share/i18n
OLD_DIRS+=usr/share/i18n/esdb
OLD_DIRS+=usr/share/i18n/esdb/ISO-2022
@@ -7673,7 +7734,9 @@ OLD_FILES+=etc/periodic/daily/440.status-mailq
OLD_FILES+=etc/periodic/daily/460.status-mail-rejects
OLD_FILES+=etc/periodic/daily/500.queuerun
OLD_FILES+=etc/rc.d/sendmail
+.if ${MK_MAILWRAPPER} == no
OLD_FILES+=bin/rmail
+.endif
OLD_FILES+=usr/bin/vacation
OLD_FILES+=usr/include/libmilter/mfapi.h
OLD_FILES+=usr/include/libmilter/mfdef.h
@@ -7756,12 +7819,14 @@ OLD_FILES+=usr/share/sendmail/cf/feature/access_db.m4
OLD_FILES+=usr/share/sendmail/cf/feature/allmasquerade.m4
OLD_FILES+=usr/share/sendmail/cf/feature/always_add_domain.m4
OLD_FILES+=usr/share/sendmail/cf/feature/authinfo.m4
+OLD_FILES+=usr/share/sendmail/cf/feature/blocklist_recipients.m4
OLD_FILES+=usr/share/sendmail/cf/feature/badmx.m4
OLD_FILES+=usr/share/sendmail/cf/feature/bcc.m4
OLD_FILES+=usr/share/sendmail/cf/feature/bestmx_is_local.m4
OLD_FILES+=usr/share/sendmail/cf/feature/bitdomain.m4
OLD_FILES+=usr/share/sendmail/cf/feature/blacklist_recipients.m4
OLD_FILES+=usr/share/sendmail/cf/feature/block_bad_helo.m4
+OLD_FILES+=usr/share/sendmail/cf/feature/check_cert_altnames.m4
OLD_FILES+=usr/share/sendmail/cf/feature/compat_check.m4
OLD_FILES+=usr/share/sendmail/cf/feature/conncontrol.m4
OLD_FILES+=usr/share/sendmail/cf/feature/delay_checks.m4
@@ -7804,6 +7869,7 @@ OLD_FILES+=usr/share/sendmail/cf/feature/relay_mail_from.m4
OLD_FILES+=usr/share/sendmail/cf/feature/require_rdns.m4
OLD_FILES+=usr/share/sendmail/cf/feature/smrsh.m4
OLD_FILES+=usr/share/sendmail/cf/feature/stickyhost.m4
+OLD_FILES+=usr/share/sendmail/cf/feature/tls_failures.m4
OLD_FILES+=usr/share/sendmail/cf/feature/tls_session_features.m4
OLD_FILES+=usr/share/sendmail/cf/feature/use_client_ptr.m4
OLD_FILES+=usr/share/sendmail/cf/feature/use_ct_file.m4
@@ -9607,6 +9673,14 @@ OLD_FILES+=usr/share/man/man8/lastlogin.8.gz
OLD_FILES+=usr/share/man/man8/utx.8.gz
.endif
+.if ${MK_VERIEXEC} == no
+OLD_FILES+=sbin/veriexec
+OLD_FILES+=usr/share/man/man8/veriexec.8.gz
+OLD_FILES+=usr/lib/libveriexec.a
+OLD_FILES+=usr/lib/libveriexec.so
+OLD_LIBS+=usr/lib/libveriexec.so.5
+.endif
+
.if ${MK_VI} == no
OLD_FILES+=etc/rc.d/virecover
OLD_FILES+=rescue/ex
diff --git a/tools/build/options/WITHOUT_DTRACE b/tools/build/options/WITHOUT_DTRACE
new file mode 100644
index 000000000000..7a246ee5ee3d
--- /dev/null
+++ b/tools/build/options/WITHOUT_DTRACE
@@ -0,0 +1,2 @@
+.\" $FreeBSD$
+Do not build DTrace framework kernel modules, libraries, and user commands.
diff --git a/tools/build/options/WITHOUT_MACHDEP_OPTIMIZATIONS b/tools/build/options/WITHOUT_MACHDEP_OPTIMIZATIONS
new file mode 100644
index 000000000000..1c596c998504
--- /dev/null
+++ b/tools/build/options/WITHOUT_MACHDEP_OPTIMIZATIONS
@@ -0,0 +1 @@
+Prefer machine-independent non-assembler code in libc and libm.
diff --git a/tools/diag/prtblknos/main.c b/tools/diag/prtblknos/main.c
index 25a717760922..65efa786b700 100644
--- a/tools/diag/prtblknos/main.c
+++ b/tools/diag/prtblknos/main.c
@@ -56,7 +56,6 @@ main(argc, argv)
char ibuf[64];
char *fsname, *filename;
ino_t inonum;
- int error;
filename = NULL;
if (argc == 2) {
@@ -83,7 +82,8 @@ main(argc, argv)
fsname = *++argv;
/* get the superblock. */
- if ((error = ufs_disk_fillout(&disk, fsname)) < 0)
+ if (ufs_disk_fillout_blank(&disk, fsname) == -1 ||
+ sbfind(&disk, 0) == -1)
err(1, "Cannot access file system superblock on %s", fsname);
fs = (struct fs *)&disk.d_sb;
@@ -99,7 +99,7 @@ main(argc, argv)
(void)printf("%s (inode #%jd): ", filename,
(intmax_t)inonum);
- if ((error = getinode(&disk, &dp, inonum)) < 0)
+ if (getinode(&disk, &dp, inonum) < 0)
warn("Read of inode %jd on %s failed: %s",
(intmax_t)inonum, fsname, disk.d_error);
diff --git a/tools/regression/netinet/ipdivert/ipdivert.c b/tools/regression/netinet/ipdivert/ipdivert.c
index 0d5849159a9a..37babd68f5f3 100644
--- a/tools/regression/netinet/ipdivert/ipdivert.c
+++ b/tools/regression/netinet/ipdivert/ipdivert.c
@@ -76,7 +76,7 @@ ipdivert_create(const char *test)
{
int s;
- s = socket(PF_INET, SOCK_RAW, IPPROTO_DIVERT);
+ s = socket(PF_DIVERT, SOCK_RAW, 0);
if (s < 0)
fail(test, "socket");
return (s);
diff --git a/tools/regression/netinet/tcpstream/tcpstream.c b/tools/regression/netinet/tcpstream/tcpstream.c
index c8fe9a3fe098..900197791a02 100644
--- a/tools/regression/netinet/tcpstream/tcpstream.c
+++ b/tools/regression/netinet/tcpstream/tcpstream.c
@@ -29,7 +29,7 @@
/*
* tcpstream sets up a simple TCP client and server, and then streams a
* predictable pseudo-random byte sequence through it using variable block
- * sizes. The intent is to to detect corruption of data in the TCP stream.
+ * sizes. The intent is to detect corruption of data in the TCP stream.
*/
#include <sys/types.h>
diff --git a/tools/test/iconv/posix/posix.c b/tools/test/iconv/posix/posix.c
index 7faed92416a3..3e813226fa5e 100644
--- a/tools/test/iconv/posix/posix.c
+++ b/tools/test/iconv/posix/posix.c
@@ -27,8 +27,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/param.h>
#include <sys/endian.h>
-#include <sys/types.h>
#include <err.h>
#include <errno.h>
@@ -66,18 +66,22 @@ static int
open_2(void)
{
iconv_t cd[MAX_LIMIT];
- int i, ret;
+ size_t i;
+ int ret;
errno = 0;
+ ret = 1;
for (i = 0; i < MAX_LIMIT; i++) {
cd[i] = iconv_open("ASCII", "UTF8");
- if (cd[i] == (iconv_t)-1)
+ if (cd[i] == (iconv_t)-1) {
+ if (errno == ENFILE || errno == EMFILE)
+ ret = 0;
+ cd[i] = NULL;
break;
+ }
}
- ret = (cd[i] == (iconv_t)-1) && ((errno == ENFILE) ||
- (errno == EMFILE)) ? 0 : 1;
- for (; i > 0; i--)
+ for (i = MIN(i, nitems(cd) - 1); i > 0; i--)
iconv_close(cd[i]);
return (ret);
}
diff --git a/tools/test/stress2/misc/all.exclude b/tools/test/stress2/misc/all.exclude
index 029a77b9b094..ec7909bc1de7 100644
--- a/tools/test/stress2/misc/all.exclude
+++ b/tools/test/stress2/misc/all.exclude
@@ -22,8 +22,6 @@ gnop8.sh Waiting for patch commit 20201214
gnop9.sh Waiting for patch commit 20201214
graid1_8.sh Known issue 20170909
graid1_9.sh panic: Bad effnlink 20180212
-gunion.sh Waiting for fix 20220308
-gunion2.sh Waiting for fix 20220308
ifconfig.sh Bug 253824 20210322
ifconfig2.sh https://people.freebsd.org/~pho/stress/log/log0051.txt 20210210
lockf5.sh Spinning threads seen 20160718
@@ -33,7 +31,7 @@ memguard2.sh Waiting for fix commit
memguard3.sh Waiting for fix commit
mlockall2.sh Unrecoverable OOM killing seen 20190203
mlockall7.sh Needs further investigation 20210123
-msetdomain.sh May change policy for random threads to to domainset_fixed 20210104
+msetdomain.sh May change policy for random threads to domainset_fixed 20210104
newfs4.sh watchdog fired. newbuf 20190225
nfs10.sh Double fault 20151013
nfs13.sh mount_nfs hangs in mntref 20191007
@@ -44,7 +42,6 @@ oom2.sh Hang in pfault 20180324
overcommit2.sh CAM stuck in vmwait seen 20200112
pageout.sh panic: handle_written_filepage: not started 20190218
pmc8.sh panic: [pmc,2749] (ri21, rc1) waiting too long for pmc to ... 20210621
-rename14.sh https://people.freebsd.org/~pho/stress/log/log0279.txt 20220415
sctp2.sh panic: Queues are not empty when handling SHUTDOWN-COMPLETE 20210211
sctp3.sh panic: Queues are not empty when handling SHUTDOWN-COMPLETE 20210211
sendfile25.sh WiP 20200611
diff --git a/tools/test/stress2/misc/badcode3.sh b/tools/test/stress2/misc/badcode3.sh
index e0a10d0074a4..61dce1cb82c3 100755
--- a/tools/test/stress2/misc/badcode3.sh
+++ b/tools/test/stress2/misc/badcode3.sh
@@ -39,13 +39,18 @@ mdconfig -a -t swap -s 1g -u $mdstart
newfs $newfs_flags md$mdstart > /dev/null
mount /dev/md$mdstart $mntpoint
chmod 777 $mntpoint
+export badcodeLOAD=100
+export RUNDIR=$mntpoint/stressX
+mkdir -p $RUNDIR
+chmod 0777 $RUNDIR
here=`pwd`
cd $mntpoint
(cd $here/../testcases/swap; ./swap -t 5m -i 20) &
sleep 2
while pgrep -q swap; do
- timeout 1m limits -c 0 $here/../testcases/badcode/badcode -t 1m -i 20
+ su $testuser -c \
+ "timeout 1m limits -c 0 $here/../testcases/badcode/badcode -t 1m -i 20"
done
wait
cd $here
diff --git a/tools/test/stress2/misc/fork2.sh b/tools/test/stress2/misc/fork2.sh
new file mode 100755
index 000000000000..894f44556a01
--- /dev/null
+++ b/tools/test/stress2/misc/fork2.sh
@@ -0,0 +1,135 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2022 Peter Holm
+#
+# 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.
+#
+
+# Regression test for D36069
+# thread_create(): call cpu_copy_thread() after td_pflags is zeroed
+
+# Seen before fix:
+# cc: error: unable to execute command: Segmentation fault (core dumped)
+# cc: error: linker command failed due to signal (use -v to see invocation)
+# Aug 9 18:27:47 freebsd-vm kernel: pid 32094 (ld.lld), jid 0, uid 0: exited on signal 11 (core dumped)
+
+. ../default.cfg
+[ `id -u` -ne 0 ] && echo "Must be root!" && exit 1
+
+dir=/tmp
+odir=`pwd`
+cd $dir
+sed '1,/^EOF/d' < $odir/$0 > $dir/fork2.c
+mycc -o fork2 -Wall -Wextra -O0 -g fork2.c || exit 1
+cd $odir
+
+set -e
+mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
+[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
+mdconfig -a -t swap -s 2g -u $mdstart
+bsdlabel -w md$mdstart auto
+newfs $newfs_flags md${mdstart}$part > /dev/null
+mount /dev/md${mdstart}$part $mntpoint
+set +e
+
+cd $mntpoint
+$dir/fork2
+s=$?
+pkill fork2
+[ -f fork2.core -a $s -eq 0 ] &&
+ { ls -l fork2.core; mv fork2.core $dir; s=1; }
+cd $odir
+
+for i in `jot 6`; do
+ mount | grep -q "on $mntpoint " || break
+ umount $mntpoint && break || sleep 10
+ [ $i -eq 6 ] &&
+ { echo FATAL; fstat -mf $mntpoint; exit 1; }
+done
+mdconfig -d -u $mdstart
+cd $dir
+mycc -o $dir/fork2 -Wall -Wextra -O0 -g $dir/fork2.c; s=$?
+rm -rf $dir/fork2 $dir/fork2.c
+exit $s
+
+EOF
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#include <machine/atomic.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+static volatile u_int *share;
+
+#define MX 5000
+#define RUNTIME (1 * 60)
+#define SYNC 0
+
+int
+main(void)
+{
+ pid_t pid;
+ size_t len;
+ time_t start;
+ int n;
+
+ len = PAGE_SIZE;
+ if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE,
+ MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED)
+ err(1, "mmap");
+
+ n = 0;
+ signal(SIGCHLD, SIG_IGN);
+ start = time(NULL);
+ while ((time(NULL) - start) < RUNTIME) {
+ while ((atomic_load_int(&share[SYNC])) > MX)
+ usleep(100);
+ n++;
+ pid = fork();
+ if (pid == -1)
+ err(1, "fork)");
+ if (pid == 0) {
+ atomic_add_int(&share[SYNC], 1);
+ while (atomic_load_int(&share[SYNC]) <= MX)
+ usleep(10000);
+ usleep(arc4random() % 1000);
+ atomic_add_int(&share[SYNC], -1);
+ raise(SIGHUP);
+ _exit(0);
+ }
+ }
+ atomic_add_int(&share[SYNC], MX * 2);
+ fprintf(stderr, "%d fork() calls\n", n);
+}
diff --git a/tools/test/stress2/misc/fsck.sh b/tools/test/stress2/misc/fsck.sh
index 826c31f733c3..972150dc6fac 100755
--- a/tools/test/stress2/misc/fsck.sh
+++ b/tools/test/stress2/misc/fsck.sh
@@ -86,13 +86,13 @@ chk() {
waccess=0
fsck_ffs -fy $1 > $log 2>&1
r=$?
- if grep -qE "Cannot find file system superblock|Superblock check-hash failed" $log; then
+ if grep -qiE "super-?block.*failed" $log; then
for b in $backups; do
echo "Using alternate SB $b"
asbs=$((asbs + 1))
fsck_ffs -b $b -fy $1 > $log 2>&1
r=$?
- grep -qE "Cannot find file system superblock|Superblock check-hash failed" $log ||
+ grep -qiE "super-?block.*failed" $log ||
break
done
usedasb=1
diff --git a/tools/test/stress2/misc/fsck8.sh b/tools/test/stress2/misc/fsck8.sh
new file mode 100755
index 000000000000..41f03bc3bece
--- /dev/null
+++ b/tools/test/stress2/misc/fsck8.sh
@@ -0,0 +1,179 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2022 Peter Holm <pho@FreeBSD.org>
+#
+# 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.
+#
+
+# fsck_ffs(8) disk image fuzz test. SB focus.
+
+# panic: wrong length 4098 for sectorsize 512
+# FreeBSD 14.0-CURRENT #0 main-n255602-51adf913e8815: Fri May 13 07:55:32 CEST 2022
+# pho@mercat1.netperf.freebsd.org:/usr/src/sys/amd64/compile/PHO
+
+. ../default.cfg
+
+[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
+
+cc -o /tmp/flip -Wall -Wextra -O2 ../tools/flip.c || exit 1
+
+set -e
+u1=$mdstart
+u2=$((mdstart + 1))
+mp1=${mntpoint}$u1
+mp2=${mntpoint}$u2
+mkdir -p $mp1 $mp2
+log=$mp1/fsck8.sh.log
+diskimage=$mp1/fsck8.sh.diskimage
+backup=/tmp/fsck8.sh.diskimage.`date +%Y%m%dT%H%M%S`.gz
+asbs=0
+cleans=0
+reruns=0
+waccess=0
+
+max=$((10 * 1024 * 1024))
+# UFS1 or UFS2 SU:
+[ `jot -r 1 0 1` -eq 0 ] && newfs_flags='-O 1' || newfs_flags='-O 2 -U'
+
+mount | grep "on $mp1 " | grep -q /dev/md && umount -f $mp1
+[ -c /dev/md$u1 ] && mdconfig -d -u $u1
+mdconfig -a -t swap -s 1g -u $u1
+newfs $newfs_flags -n /dev/md$u1 > /dev/null
+mount /dev/md$u1 $mp1
+
+[ -c /dev/md$u2 ] && mdconfig -d -u $u2
+dd if=/dev/zero of=$diskimage bs=$max count=1 status=none
+mdconfig -a -t vnode -f $diskimage -u $u2
+backups=`newfs -N $newfs_flags md$u2 | grep -A1 "super-block backups" | \
+ tail -1 | sed 's/,//g'`
+newfs $newfs_flags -n md$u2 > /dev/null
+mount /dev/md$u2 $mp2
+[ -d /usr/include/sys ] && cp -r /usr/include/sys $mp2
+umount $mp2
+set +e
+
+chk() {
+ local i
+
+ clean=0
+ rerun=0
+ waccess=0
+ timeout 5m fsck_ffs -fy $1 > $log 2>&1
+ r=$?
+ if grep -qiE "super-?block.*failed" $log; then
+ for b in $backups; do
+ echo "Using alternate SB $b"
+ asbs=$((asbs + 1))
+ fsck_ffs -b $b -fy $1 > $log 2>&1
+ r=$?
+ grep -qiE "super-?block.*failed" $log ||
+ break
+ done
+ usedasb=1
+ else
+ usedasb=0
+ fi
+ LANG=C egrep -q "[A-Z][A-Z]" $log && clean=0
+ grep -Eq "IS CLEAN|MARKED CLEAN" $log && clean=1
+ # For now regard a "was modified" as a cause for a rerun,
+ # disregarding the "clean" claim.
+ grep -Eq "WAS MODIFIED" $log && rerun=1
+ grep -q RERUN $log && rerun=1
+ grep -q "NO WRITE ACCESS" $log && waccess=1
+ [ $r -ne 0 -a $clean -eq 1 ] && echo "Exit code $r w/ clean == 1"
+}
+
+cd $mp1
+clean=0
+s=0
+start=`date +%s`
+while [ $((`date +%s` - start)) -lt 300 ]; do
+ mount /dev/md$u2 $mp2 || break
+ ls -lR $mp2 > /dev/null || { s=102; echo "ls failed"; break; }
+ touch $mp2/`jot -rc 8 a z | tr -d '\n'`
+ while mount | grep -q "on $mp2 "; do umount $mp2; done
+ echo * | grep -q core && break
+ sync
+ mdconfig -d -u $u2
+ # SBLOCK = 64k, SBLOCKSIZE = 8k
+ /tmp/flip -n 5 -s $(((64 + 8) * 1024)) $diskimage
+
+ sync
+ if [ `stat -f%z $diskimage` -gt $max ]; then
+ ls -lh $diskimage
+ truncate -s $max $diskimage
+ else
+ gzip < $diskimage > $backup
+ fi
+ fsync $backup
+ sync
+
+ for i in `jot 5`; do
+ [ $i -gt 2 ] && echo "fsck run #$i"
+ chk $diskimage
+ [ $rerun -eq 1 ] && { reruns=$((reruns + 1)); continue; }
+ [ $clean -eq 1 ] && { cleans=$((cleans + 1)); break; }
+ [ -f fsck_ffs.core ] &&
+ { cp -v $diskimage \
+ /tmp/fsck_ffs.core.diskimage.`date +%Y%m%dT%H%M%S`; break 2; }
+ done
+ [ $clean -ne 1 ] && break
+ mdconfig -a -t vnode -f $diskimage -u $u2
+ [ $r -ne 0 -a $clean -eq 1 ] &&
+ { echo "CLEAN && non zero exit code"; break; }
+ [ $clean -eq 1 ] && continue
+ [ $usedasb -eq 1 ] && { echo "Alt. SB failed"; s=104; }
+ [ $waccess -eq 1 ] && { echo "No write access"; s=105; }
+ break
+done
+sleep 2 # Wait for /dev to catch up
+[ -c /dev/md$u2 ] && r1=1 || r1=0
+for i in `jot 5`; do
+ mount | grep -q "on $mp2 " || break
+ umount $mp2 && break
+ sleep 2
+done
+mdconfig -d -u $u2 2>/dev/null # XXX when mount fails
+
+echo "$cleans cleans, $reruns reruns, $asbs alternate SBs."
+if [ $clean -ne 1 ]; then
+ echo "FS still not clean. Last fsck_ffs exit code was $r."
+ echo =================
+ cat $log
+ echo =================
+ cp -v $log /tmp
+ [ $s -eq 0 ] && s=106
+fi
+echo * | grep -q core && { ls -l *.core; cp -v $log /tmp; exit 106; } ||
+ rm -f $backup
+[ $s -eq 101 ] && rm -f $backup # mount error breakout
+cd /tmp
+for i in `jot 5`; do
+ umount $mp1 && break
+ sleep 2
+done
+mdconfig -d -u $u1
+rm -f /tmp/flip
+exit $s
diff --git a/tools/test/stress2/misc/fsck9.sh b/tools/test/stress2/misc/fsck9.sh
new file mode 100755
index 000000000000..4610e9da1fb8
--- /dev/null
+++ b/tools/test/stress2/misc/fsck9.sh
@@ -0,0 +1,168 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2022 Peter Holm <pho@FreeBSD.org>
+#
+# 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.
+#
+
+# fsck_ffs(8) false CLEAN claim scenario
+
+# https://people.freebsd.org/~pho/fsck9.sh.diskimage.20220716T150359.txt
+# https://people.freebsd.org/~pho/fsck9.sh.diskimage.20220716T150359.gz
+
+# https://people.freebsd.org/~pho/fsck9.sh.diskimage.20220716T172428.txt
+# https://people.freebsd.org/~pho/fsck9.sh.diskimage.20220716T172428.gz
+
+. ../default.cfg
+
+[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
+
+cc -o /tmp/flip -Wall -Wextra -O2 ../tools/flip.c || exit 1
+
+set -e
+u1=$mdstart
+u2=$((mdstart + 1))
+mp1=${mntpoint}$u1
+mp2=${mntpoint}$u2
+mkdir -p $mp1 $mp2
+log=$mp1/fsck9.sh.log
+diskimage=$mp1/fsck9.sh.diskimage
+backup=/tmp/fsck9.sh.diskimage.`date +%Y%m%dT%H%M%S`.gz
+cleans=0
+reruns=0
+
+max=$((10 * 1024 * 1024))
+newfs_flags='-U'
+
+mount | grep "on $mp1 " | grep -q /dev/md && umount -f $mp1
+[ -c /dev/md$u1 ] && mdconfig -d -u $u1
+mdconfig -a -t swap -s 1g -u $u1
+newfs $newfs_flags -n /dev/md$u1 > /dev/null
+mount /dev/md$u1 $mp1
+
+[ -c /dev/md$u2 ] && mdconfig -d -u $u2
+dd if=/dev/zero of=$diskimage bs=$max count=1 status=none
+mdconfig -a -t vnode -f $diskimage -u $u2
+backups=`newfs -N $newfs_flags md$u2 | grep -A1 "super-block backups" | \
+ tail -1 | sed 's/,//g'`
+newfs $newfs_flags -n md$u2 > /dev/null
+mount /dev/md$u2 $mp2
+[ -d /usr/include/sys ] && cp -r /usr/include/sys $mp2
+umount $mp2
+set +e
+
+chk() {
+ local i
+
+ clean=0
+ rerun=0
+ fsck_ffs -fy $1 > $log 2>&1
+ r=$?
+ if grep -qiE "super-?block.*failed" $log; then
+ for b in $backups; do
+ echo "fsck_ffs -b $b -fy $1"
+ fsck_ffs -b $b -fy $1 > $log 2>&1
+ r=$?
+ grep -qiE "super-?block.*failed" $log ||
+ break
+ echo "Checking next SB"
+ done
+ usedasb=1
+ else
+ usedasb=0
+ fi
+ LANG=C egrep -q "[A-Z][A-Z]" $log && clean=0
+ grep -Eq "IS CLEAN|MARKED CLEAN" $log && clean=1
+ grep -q RERUN $log && rerun=1
+ [ $r -ne 0 -a $clean -eq 1 ] && echo "Exit code $r w/ clean == 1"
+}
+
+cd $mp1
+clean=0
+s=0
+start=`date +%s`
+while [ $((`date +%s` - start)) -lt 300 ]; do
+ mount /dev/md$u2 $mp2 || break
+ if ! ls -lR $mp2 > /dev/null; then
+ s=102
+ echo "ls failed"; grep "core dumped" /var/log/messages | tail -1
+ break
+ fi
+ touch $mp2/`jot -rc 8 a z | tr -d '\n'`
+ while mount | grep -q "on $mp2 "; do umount $mp2; done
+ echo * | grep -q core && break
+ sync
+ mdconfig -d -u $u2
+ /tmp/flip -n 5 $diskimage
+
+ sync
+ if [ `stat -f%z $diskimage` -gt $max ]; then
+ ls -lh $diskimage
+ truncate -s $max $diskimage
+ else
+ gzip < $diskimage > $backup
+ fi
+ fsync $backup
+ sync
+
+ for i in `jot 5`; do
+ [ $i -gt 2 ] && echo "fsck run #$i"
+ chk $diskimage
+ [ $rerun -eq 1 ] && { reruns=$((reruns + 1)); continue; }
+ [ $clean -eq 1 ] && { cleans=$((cleans + 1)); break; }
+ [ -f fsck_ffs.core ] &&
+ { cp -v $diskimage \
+ /tmp/fsck_ffs.core.diskimage.`date +%Y%m%dT%H%M%S`; break 2; }
+ done
+ if [ $clean -eq 1 ]; then
+ fsck_ffs -fy $diskimage > $log 2>&1
+ if grep -q MODIFIED $log; then
+ echo "*** fsck of \"clean\" FS found more issues:"
+ cat $log
+ s=1
+ break
+ fi
+ fi
+ [ $clean -ne 1 ] && break
+ mdconfig -a -t vnode -f $diskimage -u $u2
+done
+sleep 2 # Wait for /dev to catch up
+[ -c /dev/md$u2 ] && r1=1 || r1=0
+for i in `jot 5`; do
+ mount | grep -q "on $mp2 " || break
+ umount $mp2 && break
+ sleep 2
+done
+mdconfig -d -u $u2 2>/dev/null # XXX when mount fails
+
+[ $s -eq 0 ] && rm -f $backup || echo "Preserved $backup due to status code $s"
+cd /tmp
+for i in `jot 5`; do
+ umount $mp1 && break
+ sleep 2
+done
+mdconfig -d -u $u1
+rm -f /tmp/flip
+exit $s
diff --git a/tools/test/stress2/misc/gunion.sh b/tools/test/stress2/misc/gunion.sh
index c7d376e5409e..e72979f2a39a 100755
--- a/tools/test/stress2/misc/gunion.sh
+++ b/tools/test/stress2/misc/gunion.sh
@@ -50,7 +50,10 @@ cp -r ../../stress2 $mp1
umount $mp1
mdconfig -a -t swap -s 5g -u $md2
-gunion create -v /dev/md$md2 /dev/md$md1
+set +e
+gunion create -v /dev/md$md2 /dev/md$md1; s=$?
+[ $s -ne 0 ] && echo "gunion create returned $s"
+set -e
mount /dev/md$md2-md$md1.union $mntpoint
export RUNDIR=$mntpoint/stressX
@@ -71,7 +74,7 @@ for i in `jot 6`; do
done
fsck_ffs -fyR /dev/md$md2-md$md1.union > $log 2>&1
grep -Eq "IS CLEAN|MARKED CLEAN" $log || { s=2; cat $log; }
-set +e
+set -e
gunion commit /dev/md$md2-md$md1.union
gunion list | egrep Block\|Current | egrep -v 0 && s=3
gunion destroy /dev/md$md2-md$md1.union
diff --git a/tools/test/stress2/misc/gunion2.sh b/tools/test/stress2/misc/gunion2.sh
index a8fe180c48af..2fa7fc451963 100755
--- a/tools/test/stress2/misc/gunion2.sh
+++ b/tools/test/stress2/misc/gunion2.sh
@@ -50,7 +50,10 @@ cp -r ../../stress2 $mp1
umount $mp1
mdconfig -a -t swap -s 5g -u $md2
-gunion create -v /dev/md$md2 /dev/md$md1
+set +e
+gunion create -v /dev/md$md2 /dev/md$md1; s=$?
+[ $s -ne 0 ] && echo "gunion create returned $s"
+set -e
mount /dev/md$md2-md$md1.union $mntpoint
export CTRLDIR=$mntpoint/stressX.control
@@ -79,7 +82,7 @@ testcases/swap/swap
"
export TESTPROGS=`echo $TESTPROGS | sed 's/\n/ /g'`
-set +e
+set -e
chmod 777 $mntpoint
su $testuser -c \
"(cd $mntpoint/stress2; ./testcases/run/run $TESTPROGS)"
diff --git a/tools/test/stress2/misc/mount7.sh b/tools/test/stress2/misc/mount7.sh
new file mode 100755
index 000000000000..7ba847797a51
--- /dev/null
+++ b/tools/test/stress2/misc/mount7.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2022 Peter Holm <pho@FreeBSD.org>
+#
+# 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.
+#
+
+# Another parallel mount(8) test scenario
+
+. ../default.cfg
+
+mounts=15
+
+../testcases/swap/swap -t 2m -i 20 &
+for i in `jot $mounts $mdstart`; do
+ mdconfig -a -s 50m -u $i
+ newfs -U /dev/md$i > /dev/null
+ mkdir -p $mntpoint$i
+ start=`date +%s`
+ while [ $((`date +%s` - start)) -lt 120 ]; do
+ mount /dev/md$i $mntpoint$i && cp /etc/passwd $mntpoint$i
+ while mount | grep -q " on $mntpoint$i "; do
+ umount $mntpoint$i > /dev/null 2>&1
+ done
+ done &
+ while [ $((`date +%s` - start)) -lt 120 ]; do
+ find $mntpoint$i -ls > /dev/null 2>&1
+ done &
+done
+wait
+
+for i in `jot $mounts $mdstart`; do
+ mdconfig -d -u $i
+ rmdir $mntpoint$i
+done
+exit $s
diff --git a/tools/test/stress2/misc/setrlimit.sh b/tools/test/stress2/misc/setrlimit.sh
new file mode 100755
index 000000000000..ea679f987510
--- /dev/null
+++ b/tools/test/stress2/misc/setrlimit.sh
@@ -0,0 +1,193 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2022 Peter Holm <pho@FreeBSD.org>
+#
+# 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.
+#
+
+[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
+
+# Test setrlimit() max file size and ftruncate()
+
+# Problem seen:
+# Testing UFS -O1
+# setrlimit: ftruncate(5413) did not fail. limit = 2791
+# Testing FFS -U
+# setrlimit: ftruncate(9956) did not fail. limit = 7880
+# Testing msdosfs
+# setrlimit: ftruncate(9033) did not fail. limit = 5884
+# Testing tmpfs
+# setrlimit: ftruncate(123) did not fail. limit = 86
+
+. ../default.cfg
+
+cat > /tmp/setrlimit.c <<EOF
+#include <sys/types.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static int signals;
+
+static void
+handler(int sig __unused)
+{
+#if defined(DEBUG)
+ fprintf(stderr, "Got signal SIGXFSZ\n");
+#endif
+ signals++;
+}
+
+void
+test(int argc, char *argv[])
+{
+ struct rlimit rlim;
+ rlim_t limit, sz;
+ struct sigaction act;
+ long pos;
+ int e, expected, fd;
+ char file[] = "setrlimit.file";
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s <FS size>\n", argv[0]);
+ exit(1);
+ }
+ expected = signals = 0;
+ sz = atol(argv[1]);
+ arc4random_buf(&limit, sizeof(limit));
+ if (limit < 0)
+ limit = -limit;
+ limit = limit % sz + 1;
+ rlim.rlim_cur = rlim.rlim_max = limit;
+ if (setrlimit(RLIMIT_FSIZE, &rlim) == -1)
+ err(1, "setrlimit(%ld)", limit);
+
+ act.sa_handler = handler;
+ act.sa_flags = 0;
+ sigemptyset(&act.sa_mask);
+ if (sigaction(SIGXFSZ, &act, NULL) != 0)
+ err(1, "sigaction");
+
+ if ((fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, DEFFILEMODE)) == -1)
+ err(1, "open(%s)", file);
+
+ e = 0;
+ arc4random_buf(&pos, sizeof(pos));
+ if (pos < 0)
+ pos = -pos;
+ pos = pos % (limit * 2);
+ if (pos > limit)
+ expected = 1;
+ if (ftruncate(fd, pos) == -1) {
+ e = errno;
+ if (pos <= limit)
+ errc(1, e, "ftruncate(%ld), limit = %ld", pos, limit);
+ } else {
+ if (pos > limit)
+ errx(1, "ftruncate(%ld) did not fail. limit = %ld", pos, limit);
+ }
+
+ if (lseek(fd, limit - 1, SEEK_SET) == -1)
+ err(1, "lseek(limit - 1)");
+ if (write(fd, "a", 1) != 1)
+ err(1, "write() at limit - 1. limit = %ld", limit);
+
+ if (write(fd, "b", 1) != -1)
+ err(1, "write() at limit. limit = %ld", limit);
+ expected++;
+
+ /* Partial write test. No signal is expected */
+ if (lseek(fd, limit - 1, SEEK_SET) == -1)
+ err(1, "lseek(limit - 1)");
+ if (write(fd, "12", 2) != 1)
+ err(1, "write() at limit - 1. limit = %ld", limit);
+
+ if (signals != expected)
+ errx(1, "Expected %d signals, got %d", expected, signals);
+
+ close(fd);
+ unlink(file);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int i;
+
+ for (i = 0; i < 100; i++)
+ test(argc, argv);
+
+}
+EOF
+
+here=`pwd`
+s=0
+cc -o /tmp/setrlimit -Wall -Wextra -O0 -g /tmp/setrlimit.c || exit 1
+
+mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
+[ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
+
+echo "Testing UFS -O1"
+mdconfig -t swap -s 1g -u $mdstart
+newfs -O1 /dev/md$mdstart > /dev/null
+mount /dev/md$mdstart $mntpoint
+cd $mntpoint; /tmp/setrlimit 10000 || s=1
+cd $here
+umount $mntpoint
+mdconfig -d -u $mdstart
+
+echo "Testing FFS -U"
+mdconfig -t swap -s 1g -u $mdstart
+newfs -U /dev/md$mdstart > /dev/null
+mount /dev/md$mdstart $mntpoint
+cd $mntpoint; /tmp/setrlimit 10000 || s=$((s + 2))
+cd $here
+umount $mntpoint
+mdconfig -d -u $mdstart
+
+echo "Testing msdosfs"
+mdconfig -t swap -s 1g -u $mdstart
+newfs_msdos -F 32 -b 8192 /dev/md$mdstart > /dev/null 2>&1
+mount -t msdosfs /dev/md$mdstart $mntpoint
+cd $mntpoint; /tmp/setrlimit 10000 || s=$((s + 4))
+cd $here
+umount $mntpoint
+mdconfig -d -u $mdstart
+
+echo "Testing tmpfs"
+mount -o size=20000 -t tmpfs dummy $mntpoint
+cd $mntpoint; /tmp/setrlimit 10000 || s=$((s + 8))
+cd $here
+umount $mntpoint
+
+rm -f /tmp/setrlimit /tmp/setrlimit.c
+exit $s
diff --git a/tools/test/stress2/misc/setrlimit2.sh b/tools/test/stress2/misc/setrlimit2.sh
new file mode 100755
index 000000000000..4f3015dedc44
--- /dev/null
+++ b/tools/test/stress2/misc/setrlimit2.sh
@@ -0,0 +1,118 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2022 Peter Holm <pho@FreeBSD.org>
+#
+# 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.
+#
+
+# Demonstrate that a mapped SHARED file can be updated past LIMIT_FSIZE
+
+# Kostik wrote:
+# This one should be reproducible when you
+# - have file larger than e.g. RLIMIT_FSIZE
+# - mmaped it without closing the file descriptor
+# - dirty its pages beyond the limit
+# - then unmap
+# - then close the file descriptor.
+
+[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
+
+. ../default.cfg
+
+cat > /tmp/setrlimit2.c <<EOF
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static int signals;
+
+static void
+handler(int sig __unused)
+{
+ signals++;
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct rlimit rlim;
+ struct sigaction act;
+ struct stat st;
+ size_t len;
+ int error, fd, ps;
+ char *file, *p;
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: %s <data file>\n", argv[0]);
+ exit(1);
+ }
+ act.sa_handler = handler;
+ act.sa_flags = 0;
+ sigemptyset(&act.sa_mask);
+ if (sigaction(SIGXFSZ, &act, NULL) != 0)
+ err(1, "sigaction");
+
+ file = argv[1];
+ ps = getpagesize();
+ if ((fd = open(file, O_RDWR)) == -1)
+ err(1, "open(%s)", file);
+ if ((error = fstat(fd, &st)) == -1)
+ err(1, "stat(%s)", file);
+ len = round_page(st.st_size);
+ if ((p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED)
+ err(1, "mmap");
+ rlim.rlim_cur = rlim.rlim_max = len / 2;;
+ if (setrlimit(RLIMIT_FSIZE, &rlim) == -1)
+ err(1, "setrlimit(%ld)", len / 2);
+
+ p[len / 2 + ps] = 'a';
+
+ if (munmap(p, len) == -1)
+ err(1, "unmap()");
+ close(fd);
+
+}
+EOF
+here=`pwd`
+cd /tmp
+mycc -o setrlimit2 -Wall -Wextra -O0 -g setrlimit2.c || exit 1
+data=/tmp/setrlimit2.data
+dd if=/dev/zero of=$data bs=1m count=1 status=none
+h1=`md5 < $data`
+
+./setrlimit2 $data
+
+h2=`md5 < $data`
+rm -f /tmp/setrlimit2 /tmp/setrlimit2.c
+[ $h1 = $h2 ] && exit 1 || exit 0
diff --git a/tools/test/stress2/misc/signal2.sh b/tools/test/stress2/misc/signal2.sh
new file mode 100755
index 000000000000..2cb0589f1dce
--- /dev/null
+++ b/tools/test/stress2/misc/signal2.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# Test scenario from:
+# Bug 265889 - sys.kern.basic_signal.trap_signal_test crashes bhyve in i386 VM
+# Test scenario by: Li-Wen Hsu <lwhsu@FreeBSD.org>
+
+cat > /tmp/signal2.c <<EOF
+#include <stdio.h>
+#include <signal.h>
+
+#include <machine/psl.h>
+#define SET_TRACE_FLAG(ucp) (ucp)->uc_mcontext.mc_eflags |= PSL_T
+#define CLR_TRACE_FLAG(ucp) (ucp)->uc_mcontext.mc_eflags &= ~PSL_T
+
+static volatile sig_atomic_t trap_signal_fired = 0;
+
+static void
+trap_sig_handler(int signo __unused, siginfo_t *info __unused, void *_ucp)
+{
+ ucontext_t *ucp = _ucp;
+
+ if (trap_signal_fired < 9) {
+ SET_TRACE_FLAG(ucp);
+ } else {
+ CLR_TRACE_FLAG(ucp);
+ }
+ trap_signal_fired++;
+}
+
+int main() {
+ struct sigaction sa = {
+ .sa_sigaction = trap_sig_handler,
+ .sa_flags = SA_SIGINFO,
+ };
+
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGTRAP, &sa, NULL);
+
+ raise(SIGTRAP);
+
+ printf("test\n");
+}
+EOF
+cc -o /tmp/signal2 -Wall -Wextra -O0 -m32 /tmp/signal2.c || exit 1
+
+/tmp/signal2; s=$?
+for i in `jot 30`; do
+ /tmp/signal2 &
+done > /dev/null
+wait
+
+rm -f /tmp/signal2 /tmp/signal2.c
+exit $s
diff --git a/tools/test/stress2/misc/sigreturn2.sh b/tools/test/stress2/misc/sigreturn2.sh
new file mode 100755
index 000000000000..610922a809ab
--- /dev/null
+++ b/tools/test/stress2/misc/sigreturn2.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2022 Peter Holm <pho@FreeBSD.org>
+#
+# 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.
+#
+
+# A sigreturn(2) syscall fuzzer
+
+# panic: vm_fault_lookup: fault on nofault entry, addr: 0
+# cpuid = 0
+# time = 1661248103
+# KDB: stack backtrace:
+# db_trace_self_wrapper(e,27e1dae0,27e1dae2,ffc07db8,c1f0490,...) at db_trace_self_wrapper+0x28/frame 0xffc07d24
+# vpanic(150b260,ffc07d60,ffc07d60,ffc07e20,12cb565,...) at vpanic+0xf4/frame 0xffc07d40
+# panic(150b260,14ec2f3,0,149349d,1430,...) at panic+0x14/frame 0xffc07d54
+# vm_fault(1e37000,0,4,0,0) at vm_fault+0x1725/frame 0xffc07e20
+# vm_fault_trap(1e37000,3b,4,0,0,0) at vm_fault_trap+0x52/frame 0xffc07e48
+# trap_pfault(3b,0,0) at trap_pfault+0x176/frame 0xffc07e94
+# trap(ffc07f6c,8,28,28,1915b000,...) at trap+0x2d9/frame 0xffc07f60
+# calltrap() at 0xffc031ef/frame 0xffc07f60
+# --- trap 0xc, eip = 0x3b, esp = 0xffc07fac, ebp = 0xffc0340c ---
+# (null)() at 0x3b/frame 0xffc0340c
+# KDB: enter: panic
+# [ thread pid 26126 tid 120029 ]
+# Stopped at kdb_enter+0x34: movl $0,kdb_why
+# db> x/s version
+# version: FreeBSD 14.0-CURRENT #0 ast-n257558-eb20af97a66-dirty: Mon Aug 22 17:53:22 CEST 2022
+# pho@mercat1.netperf.freebsd.org:/media/obj/var/tmp/deviant3/i386.i386/sys/PHO
+# db>
+
+inc=/usr/include/sys/syscall.h
+[ -f $inc ] || exit 0
+num=`awk '/SYS_sigreturn/ {print $NF}' < $inc`
+old=`grep -E 'sigreturn \*' < $inc | \
+ sed 's/.* \([0-9]\{1,3\}\) .*/\1/' | tr '\n' ' '`
+num="$num $old"
+
+start=`date +%s`
+while [ $((`date +%s` - start)) -lt 180 ]; do
+ for i in $num; do
+ echo "noswap=1 ./syscall4.sh $i"
+ noswap=1 ./syscall4.sh $i
+ done
+done
+
+exit 0
diff --git a/tools/test/stress2/misc/sigreturn3.sh b/tools/test/stress2/misc/sigreturn3.sh
new file mode 100755
index 000000000000..1070876539b6
--- /dev/null
+++ b/tools/test/stress2/misc/sigreturn3.sh
@@ -0,0 +1,182 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2022 Peter Holm <pho@FreeBSD.org>
+#
+# 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.
+#
+
+# Fatal trap -4186856: UNKNOWN while in kernel mode
+# cpuid = 1; apic id = 01
+# error code = 0xfbafcf8c
+# instruction pointer = 0x79e4:0x4
+# stack pointer = 0x28:0xffc0aff0
+# frame pointer = 0x28:0x204620d4
+# code segment = base 0x0, limit 0x0, type 0x0
+# = DPL 0, pres 0, def32 0, gran 0
+# processor eflags = trace trap, at 0x3b/frame 0xffc0340c
+# KDB: enter: panic
+# [ thread pid 15631 tid 114622 ]
+# Stopped at kdb_enter+0x34: movl $0,kdb_why
+# db>
+
+[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
+prog=sigreturn3
+
+cat > /tmp/$prog.c <<EOF
+#include <sys/types.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <libutil.h>
+#include <pthread.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define N 4096
+#define RUNTIME 120
+#define THREADS 1
+
+static uint32_t r[N];
+
+static void
+hand(int i __unused) { /* handler */
+ exit(1);
+}
+
+static void *
+churn(void *arg __unused)
+{
+ time_t start;
+
+ pthread_set_name_np(pthread_self(), __func__);
+ start = time(NULL);
+ while (time(NULL) - start < 10) {
+ arc4random_buf(r, sizeof(r));
+ usleep(100);
+ }
+ return(NULL);
+}
+
+static void *
+calls(void *arg __unused)
+{
+ time_t start;
+ int i;
+
+ start = time(NULL);
+ for (i = 0; time(NULL) - start < 10; i++) {
+ arc4random_buf(r, sizeof(r));
+ alarm(1);
+ syscall(SYS_sigreturn, r);
+ }
+
+ return (NULL);
+}
+
+int
+main(int argc, char **argv)
+{
+ struct passwd *pw;
+ struct rlimit limit;
+ pid_t pid;
+ pthread_t rp, cp[THREADS];
+ time_t start;
+ int e, j;
+
+ if ((pw = getpwnam("nobody")) == NULL)
+ err(1, "failed to resolve nobody");
+
+ if (getenv("USE_ROOT") && argc == 2)
+ fprintf(stderr, "Running syscall4 as root for %s.\n",
+ argv[1]);
+ else {
+ if (setgroups(1, &pw->pw_gid) ||
+ setegid(pw->pw_gid) || setgid(pw->pw_gid) ||
+ seteuid(pw->pw_uid) || setuid(pw->pw_uid))
+ err(1, "Can't drop privileges to \"nobody\"");
+ endpwent();
+ }
+
+ limit.rlim_cur = limit.rlim_max = 1000;
+#if defined(RLIMIT_NPTS)
+ if (setrlimit(RLIMIT_NPTS, &limit) < 0)
+ err(1, "setrlimit");
+#endif
+
+ signal(SIGALRM, hand);
+ signal(SIGILL, hand);
+ signal(SIGFPE, hand);
+ signal(SIGSEGV, hand);
+ signal(SIGBUS, hand);
+ signal(SIGURG, hand);
+ signal(SIGSYS, hand);
+ signal(SIGTRAP, hand);
+
+ if (daemon(1, 1) == -1)
+ err(1, "daemon()");
+
+ start = time(NULL);
+ while ((time(NULL) - start) < RUNTIME) {
+ if ((pid = fork()) == 0) {
+ if ((e = pthread_create(&rp, NULL, churn, NULL)) != 0)
+ errc(1, e, "pthread_create");
+ for (j = 0; j < THREADS; j++)
+ if ((e = pthread_create(&cp[j], NULL, calls,
+ NULL)) != 0)
+ errc(1, e, "pthread_create");
+ for (j = 0; j < THREADS; j++)
+ pthread_join(cp[j], NULL);
+
+ if ((e = pthread_kill(rp, SIGINT)) != 0)
+ errc(1, e, "pthread_kill");
+ if ((e = pthread_join(rp, NULL)) != 0)
+ errc(1, e, "pthread_join");
+ _exit(0);
+ }
+ waitpid(pid, NULL, 0);
+ }
+
+ return (0);
+}
+EOF
+
+cd /tmp
+cc -o $prog -Wall -Wextra -O0 $prog.c -lpthread || exit 1
+start=`date +%s`
+while [ $((`date +%s` - start)) -lt 300 ]; do
+ ./$prog > /dev/null 2>&1
+ date +%T
+done
+rm -f /tmp/$prog /tmp/$ptog.c /tmp/$prog.core
+exit 0
diff --git a/tools/test/stress2/misc/sigreturn4.sh b/tools/test/stress2/misc/sigreturn4.sh
new file mode 100755
index 000000000000..f7916dc3b1ee
--- /dev/null
+++ b/tools/test/stress2/misc/sigreturn4.sh
@@ -0,0 +1,208 @@
+#!/bin/sh
+
+# panic: vm_fault_lookup: fault on nofault entry, addr: 0
+# cpuid = 2
+# time = 1661698922
+# KDB: stack backtrace:
+# db_trace_self_wrapper(b,2931e740,2931e742,ffc0ddb8,190431,...) at db_trace_self_wrapper+0x28/frame 0xffc0dd24
+# vpanic(150acba,ffc0dd60,ffc0dd60,ffc0de20,12cc155,...) at vpanic+0xf4/frame 0xffc0dd40
+# panic(150acba,14ec1ab,0,146253d,1430,...) at panic+0x14/frame 0xffc0dd54
+# vm_fault(1e360c8,0,4,0,0) at vm_fault+0x1725/frame 0xffc0de20
+# vm_fault_trap(1e360c8,3b,4,0,0,0) at vm_fault_trap+0x52/frame 0xffc0de48
+# trap_pfault(3b,0,0) at trap_pfault+0x176/frame 0xffc0de94
+# trap(ffc0df6c,8,28,28,19156000,...) at trap+0x2d9/frame 0xffc0df60
+# calltrap() at 0xffc031ef/frame 0xffc0df60
+# --- trap 0xc, eip = 0x3b, esp = 0xffc0dfac, ebp = 0xffc0340c ---
+# (null)() at 0x3b/frame 0xffc0340c
+# KDB: enter: panic
+# [ thread pid 54680 tid 102765 ]
+# Stopped at kdb_enter+0x34: movl $0,kdb_why
+# db> x/s version
+# version: FreeBSD 14.0-CURRENT #0 main-n257606-9ea2716b775-dirty: Thu Aug 25 10:47:45 CEST 2022
+# pho@mercat1.netperf.freebsd.org:/media/ob
+# j/usr/src/i386.i386/sys/PHO\012
+# db> show proc
+# Process 54680 (date) at 0x28905d50:
+# state: NORMAL
+# uid: 0 gids: 0, 0, 5
+# parent: pid 785 at 0x26c14000
+# ABI: FreeBSD ELF32
+# flag: 0x10004002 flag2: 0
+# arguments: date +%s
+# reaper: 0x18c710a4 reapsubtree: 1
+# sigparent: 20
+# vmspace: 0x29332100
+# (map 0x29332100)
+# (map.pmap 0x29332174)
+# (pmap 0x293321b0)
+# threads: 1
+# 102765 Run CPU 2 date
+# db>
+
+[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
+prog=sigreturn4
+
+cat > /tmp/$prog.c <<EOF
+#include <sys/types.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/wait.h>
+
+#include <ucontext.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <libutil.h>
+#include <pthread.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define RUNTIME 120
+#define THREADS 1
+
+static void
+hand(int i __unused) { /* handler */
+ _exit(1);
+}
+
+static long
+random_long(long mi, long ma)
+{
+ return (arc4random() % (ma - mi + 1) + mi);
+}
+
+static void
+flip(void *ap, size_t len)
+{
+ unsigned char *cp;
+ int byte;
+ unsigned char bit, buf, mask, old __unused;
+
+ cp = (unsigned char *)ap;
+ byte = random_long(0, len);
+ bit = random_long(0,7);
+ mask = ~(1 << bit);
+ buf = cp[byte];
+ old = cp[byte];
+ buf = (buf & mask) | (~buf & ~mask);
+ cp[byte] = buf;
+}
+
+static void *
+churn(void *arg __unused)
+{
+ time_t start;
+
+ start = time(NULL);
+ while (time(NULL) - start < 10) {
+ usleep(100);
+ }
+ return(NULL);
+}
+
+static void *
+calls(void *arg __unused)
+{
+ time_t start;
+ ucontext_t uc;
+ int i, n;
+
+ start = time(NULL);
+ for (i = 0; time(NULL) - start < 10; i++) {
+ n = 0;
+ if (getcontext(&uc) == -1)
+ err(1, "getcontext");
+ n++;
+
+ if (n == 1) {
+ flip(&uc, sizeof(uc));
+ alarm(1);
+ if (sigreturn(&uc) == -1)
+ err(1, "sigreturn()");
+ } else
+ break;
+ }
+ return (NULL);
+}
+
+int
+main(int argc, char **argv)
+{
+ struct passwd *pw;
+ struct rlimit limit;
+ pid_t pid;
+ pthread_t rp, cp[THREADS];
+ time_t start;
+ int e, j;
+
+ if ((pw = getpwnam("nobody")) == NULL)
+ err(1, "failed to resolve nobody");
+
+ if (getenv("USE_ROOT") && argc == 2)
+ fprintf(stderr, "Running sigreturn4 as root for %s.\n",
+ argv[1]);
+ else {
+ if (setgroups(1, &pw->pw_gid) ||
+ setegid(pw->pw_gid) || setgid(pw->pw_gid) ||
+ seteuid(pw->pw_uid) || setuid(pw->pw_uid))
+ err(1, "Can't drop privileges to \"nobody\"");
+ endpwent();
+ }
+
+ limit.rlim_cur = limit.rlim_max = 1000;
+#if defined(RLIMIT_NPTS)
+ if (setrlimit(RLIMIT_NPTS, &limit) < 0)
+ err(1, "setrlimit");
+#endif
+
+ signal(SIGALRM, hand);
+ signal(SIGILL, hand);
+ signal(SIGFPE, hand);
+ signal(SIGSEGV, hand);
+ signal(SIGBUS, hand);
+ signal(SIGURG, hand);
+ signal(SIGSYS, hand);
+ signal(SIGTRAP, hand);
+
+ if (daemon(1, 1) == -1)
+ err(1, "daemon()");
+
+ start = time(NULL);
+ while ((time(NULL) - start) < RUNTIME) {
+ if ((pid = fork()) == 0) {
+ if ((e = pthread_create(&rp, NULL, churn, NULL)) != 0)
+ errc(1, e, "pthread_create");
+ for (j = 0; j < THREADS; j++)
+ if ((e = pthread_create(&cp[j], NULL, calls,
+ NULL)) != 0)
+ errc(1, e, "pthread_create");
+ for (j = 0; j < THREADS; j++)
+ pthread_join(cp[j], NULL);
+
+ if ((e = pthread_kill(rp, SIGINT)) != 0)
+ errc(1, e, "pthread_kill");
+ if ((e = pthread_join(rp, NULL)) != 0)
+ errc(1, e, "pthread_join");
+ _exit(0);
+ }
+ waitpid(pid, NULL, 0);
+ }
+
+ return (0);
+}
+EOF
+
+cd /tmp
+cc -o $prog -Wall -Wextra -O0 $prog.c -lpthread || exit 1
+start=`date +%s`
+while [ $((`date +%s` - start)) -lt 300 ]; do
+ ./$prog > /dev/null 2>&1
+ date +%T
+done
+rm -f /tmp/$prog /tmp/$ptog.c /tmp/$prog.core
+exit 0
diff --git a/tools/test/stress2/misc/swap6.sh b/tools/test/stress2/misc/swap6.sh
index 30a3fd8e703a..ee929ee79018 100755
--- a/tools/test/stress2/misc/swap6.sh
+++ b/tools/test/stress2/misc/swap6.sh
@@ -33,7 +33,7 @@
. ../default.cfg
[ `sysctl -n vm.swap_total` -eq 0 ] && exit 0
-min=5 # percent swap usage
+min=10 # percent swap usage
(cd ../testcases/swap; ./swap -t 10m -i 100 -l 100 -h > /dev/null) &
sleep 1
mx=0
diff --git a/tools/test/stress2/misc/syzkaller29.sh b/tools/test/stress2/misc/syzkaller29.sh
index bc5dc94768d0..8b67dd4e1283 100755
--- a/tools/test/stress2/misc/syzkaller29.sh
+++ b/tools/test/stress2/misc/syzkaller29.sh
@@ -26,7 +26,7 @@
# Fixed by r368116
-# May change policy for random threads to to domainset_fixed
+# May change policy for random threads to domainset_fixed
exit 0
. ../default.cfg
diff --git a/tools/test/stress2/misc/syzkaller30.sh b/tools/test/stress2/misc/syzkaller30.sh
index f798386a83d1..d159da78307c 100755
--- a/tools/test/stress2/misc/syzkaller30.sh
+++ b/tools/test/stress2/misc/syzkaller30.sh
@@ -29,7 +29,7 @@
# Fixed by r368462
-# May change policy for random threads to to domainset_fixed
+# May change policy for random threads to domainset_fixed
exit 0
. ../default.cfg
diff --git a/tools/test/stress2/misc/syzkaller61.sh b/tools/test/stress2/misc/syzkaller61.sh
new file mode 100755
index 000000000000..e150843dc380
--- /dev/null
+++ b/tools/test/stress2/misc/syzkaller61.sh
@@ -0,0 +1,319 @@
+#!/bin/sh
+
+# Seen:
+# [root@mercat1 /usr/src/tools/test/stress2/misc]# pgrep syzkaller61 | xargs procstat -k
+# PID TID COMM TDNAME KSTACK
+# 13332 106396 syzkaller61 - mi_switch thread_suspend_check ast_suspend ast_handler ast doreti_ast
+# 13332 560662 syzkaller61 - mi_switch sleepq_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep do_wait __umtx_op_wait_uint_private sys__umtx_op amd64_syscall fast_syscall_common
+# 13332 560776 syzkaller61 - mi_switch thread_suspend_switch thread_single fork1 sys_rfork amd64_syscall fast_syscall_common
+# 13662 356440 syzkaller61 - mi_switch thread_suspend_check ast_suspend ast_handler ast doreti_ast
+# 13662 561098 syzkaller61 - mi_switch sleepq_switch sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep do_wait __umtx_op_wait_uint_private sys__umtx_op amd64_syscall fast_syscall_common
+# 13662 561160 syzkaller61 - mi_switch thread_suspend_switch thread_single fork1 sys_rfork amd64_syscall fast_syscall_common
+# [root@mercat1 /usr/src/tools/test/stress2/misc]#
+
+[ `uname -p` != "amd64" ] && exit 0
+
+. ../default.cfg
+cat > /tmp/syzkaller61.c <<EOF
+// https://syzkaller.appspot.com/bug?id=00d8ca63243899ffb67b15ec93aee4ffa2f06637
+// autogenerated by syzkaller (https://github.com/google/syzkaller)
+// Reported-by: syzbot+647212368c3f32c6f13f@syzkaller.appspotmail.com
+
+#define _GNU_SOURCE
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <pthread.h>
+#include <pwd.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/endian.h>
+#include <sys/syscall.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+
+static __thread int clone_ongoing;
+static __thread int skip_segv;
+static __thread jmp_buf segv_env;
+
+static void segv_handler(int sig, siginfo_t* info, void* ctx __unused)
+{
+ if (__atomic_load_n(&clone_ongoing, __ATOMIC_RELAXED) != 0) {
+ exit(sig);
+ }
+ uintptr_t addr = (uintptr_t)info->si_addr;
+ const uintptr_t prog_start = 1 << 20;
+ const uintptr_t prog_end = 100 << 20;
+ int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0;
+ int valid = addr < prog_start || addr > prog_end;
+ if (sig == SIGBUS)
+ valid = 1;
+ if (skip && valid) {
+ _longjmp(segv_env, 1);
+ }
+ exit(sig);
+}
+
+static void install_segv_handler(void)
+{
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_sigaction = segv_handler;
+ sa.sa_flags = SA_NODEFER | SA_SIGINFO;
+ sigaction(SIGSEGV, &sa, NULL);
+ sigaction(SIGBUS, &sa, NULL);
+}
+
+#define NONFAILING(...) \
+ ({ \
+ int ok = 1; \
+ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \
+ if (_setjmp(segv_env) == 0) { \
+ __VA_ARGS__; \
+ } else \
+ ok = 0; \
+ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \
+ ok; \
+ })
+
+static void kill_and_wait(int pid, int* status)
+{
+ kill(pid, SIGKILL);
+ while (waitpid(-1, status, 0) != pid) {
+ }
+}
+
+static void sleep_ms(uint64_t ms)
+{
+ usleep(ms * 1000);
+}
+
+static uint64_t current_time_ms(void)
+{
+ struct timespec ts;
+ if (clock_gettime(CLOCK_MONOTONIC, &ts))
+ exit(1);
+ return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
+}
+
+static void thread_start(void* (*fn)(void*), void* arg)
+{
+ pthread_t th;
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ pthread_attr_setstacksize(&attr, 128 << 10);
+ int i = 0;
+ for (; i < 100; i++) {
+ if (pthread_create(&th, &attr, fn, arg) == 0) {
+ pthread_attr_destroy(&attr);
+ return;
+ }
+ if (errno == EAGAIN) {
+ usleep(50);
+ continue;
+ }
+ break;
+ }
+ exit(1);
+}
+
+typedef struct {
+ pthread_mutex_t mu;
+ pthread_cond_t cv;
+ int state;
+} event_t;
+
+static void event_init(event_t* ev)
+{
+ if (pthread_mutex_init(&ev->mu, 0))
+ exit(1);
+ if (pthread_cond_init(&ev->cv, 0))
+ exit(1);
+ ev->state = 0;
+}
+
+static void event_reset(event_t* ev)
+{
+ ev->state = 0;
+}
+
+static void event_set(event_t* ev)
+{
+ pthread_mutex_lock(&ev->mu);
+ if (ev->state)
+ exit(1);
+ ev->state = 1;
+ pthread_mutex_unlock(&ev->mu);
+ pthread_cond_broadcast(&ev->cv);
+}
+
+static void event_wait(event_t* ev)
+{
+ pthread_mutex_lock(&ev->mu);
+ while (!ev->state)
+ pthread_cond_wait(&ev->cv, &ev->mu);
+ pthread_mutex_unlock(&ev->mu);
+}
+
+static int event_isset(event_t* ev)
+{
+ pthread_mutex_lock(&ev->mu);
+ int res = ev->state;
+ pthread_mutex_unlock(&ev->mu);
+ return res;
+}
+
+static int event_timedwait(event_t* ev, uint64_t timeout)
+{
+ uint64_t start = current_time_ms();
+ uint64_t now = start;
+ pthread_mutex_lock(&ev->mu);
+ for (;;) {
+ if (ev->state)
+ break;
+ uint64_t remain = timeout - (now - start);
+ struct timespec ts;
+ ts.tv_sec = remain / 1000;
+ ts.tv_nsec = (remain % 1000) * 1000 * 1000;
+ pthread_cond_timedwait(&ev->cv, &ev->mu, &ts);
+ now = current_time_ms();
+ if (now - start > timeout)
+ break;
+ }
+ int res = ev->state;
+ pthread_mutex_unlock(&ev->mu);
+ return res;
+}
+
+struct thread_t {
+ int created, call;
+ event_t ready, done;
+};
+
+static struct thread_t threads[16];
+static void execute_call(int call);
+static int running;
+
+static void* thr(void* arg)
+{
+ struct thread_t* th = (struct thread_t*)arg;
+ for (;;) {
+ event_wait(&th->ready);
+ event_reset(&th->ready);
+ execute_call(th->call);
+ __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED);
+ event_set(&th->done);
+ }
+ return 0;
+}
+
+static void execute_one(void)
+{
+ int i, call, thread;
+ for (call = 0; call < 2; call++) {
+ for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0]));
+ thread++) {
+ struct thread_t* th = &threads[thread];
+ if (!th->created) {
+ th->created = 1;
+ event_init(&th->ready);
+ event_init(&th->done);
+ event_set(&th->done);
+ thread_start(thr, th);
+ }
+ if (!event_isset(&th->done))
+ continue;
+ event_reset(&th->done);
+ th->call = call;
+ __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED);
+ event_set(&th->ready);
+ event_timedwait(&th->done, 50);
+ break;
+ }
+ }
+ for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++)
+ sleep_ms(1);
+}
+
+static void execute_one(void);
+
+#define WAIT_FLAGS 0
+
+static void loop(void)
+{
+ int iter = 0;
+ for (;; iter++) {
+ int pid = fork();
+ if (pid < 0)
+ exit(1);
+ if (pid == 0) {
+ execute_one();
+ exit(0);
+ }
+ int status = 0;
+ uint64_t start = current_time_ms();
+ for (;;) {
+ if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid)
+ break;
+ sleep_ms(1);
+ if (current_time_ms() - start < 5000)
+ continue;
+ kill_and_wait(pid, &status);
+ break;
+ }
+ }
+}
+
+void execute_call(int call)
+{
+ switch (call) {
+ case 0:
+ NONFAILING(*(uint32_t*)0x20001f00 = 0x16);
+ NONFAILING(*(uint32_t*)0x20001f04 = 0);
+ NONFAILING(*(uint32_t*)0x20001f08 = 0);
+ NONFAILING(*(uint32_t*)0x20001f0c = 0);
+ NONFAILING(*(uint32_t*)0x20001f10 = 0);
+ NONFAILING(memset((void*)0x20001f14, 0, 60));
+ syscall(SYS_procctl, 0ul, 0, 6ul, 0x20001f00ul);
+ break;
+ case 1:
+ syscall(SYS_rfork, 0x85000ul);
+ break;
+ }
+}
+int main(void)
+{
+ syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x1012ul, -1, 0ul);
+ install_segv_handler();
+ loop();
+ return 0;
+}
+EOF
+mycc -o /tmp/syzkaller61 -Wall -Wextra -O0 /tmp/syzkaller61.c -lpthread ||
+ exit 1
+
+(cd ../testcases/swap; ./swap -t 3m -i 10 -l 100 > /dev/null 2>&1) &
+for i in `jot 300`; do
+ (cd /tmp; timeout -k 3s 2s ./syzkaller61) &
+ pids="$pids $!"
+done
+sleep 5
+pkill -9 syzkaller61 swap; sleep 1
+pgrep -q syzkaller61 && { pgrep syzkaller61 | xargs ps -lHp; exit 1; }
+for pid in $pids; do
+ wait $pid
+done
+while pkill swap; do :; done
+wait
+
+rm -rf /tmp/syzkaller61 /tmp/syzkaller61.c /tmp/syzkaller61.core \
+ /tmp/syzkaller.??????
+exit 0
diff --git a/tools/test/stress2/misc/syzkaller62.sh b/tools/test/stress2/misc/syzkaller62.sh
new file mode 100755
index 000000000000..aa2d33ebaf9e
--- /dev/null
+++ b/tools/test/stress2/misc/syzkaller62.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+# panic: Assertion sb->sb_hiwat >= sb->uxdg_cc failed at ../../../kern/uipc_usrreq.c:1099
+# cpuid = 9
+# time = 1660909804
+# KDB: stack backtrace:
+# db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe01401e7970
+# vpanic() at vpanic+0x151/frame 0xfffffe01401e79c0
+# panic() at panic+0x43/frame 0xfffffe01401e7a20
+# uipc_dgram_sbspace() at uipc_dgram_sbspace+0x51/frame 0xfffffe01401e7a30
+# uipc_sosend_dgram() at uipc_sosend_dgram+0x690/frame 0xfffffe01401e7ac0
+# sosend() at sosend+0x49/frame 0xfffffe01401e7af0
+# soo_write() at soo_write+0x43/frame 0xfffffe01401e7b20
+# filemon_close_log() at filemon_close_log+0xd5/frame 0xfffffe01401e7b90
+# filemon_dtr() at filemon_dtr+0x31/frame 0xfffffe01401e7bb0
+# devfs_destroy_cdevpriv() at devfs_destroy_cdevpriv+0xab/frame 0xfffffe01401e7bd0
+# devfs_close_f() at devfs_close_f+0x64/frame 0xfffffe01401e7c00
+# _fdrop() at _fdrop+0x1b/frame 0xfffffe01401e7c20
+# closef() at closef+0x1db/frame 0xfffffe01401e7cb0
+# fdescfree() at fdescfree+0x433/frame 0xfffffe01401e7d80
+# exit1() at exit1+0x4df/frame 0xfffffe01401e7df0
+# sys_exit() at sys_exit+0xd/frame 0xfffffe01401e7e00
+# amd64_syscall() at amd64_syscall+0x145/frame 0xfffffe01401e7f30
+# fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe01401e7f30
+# --- syscall (1, FreeBSD ELF64, sys_exit), rip = 0x82301d16a, rsp = 0x8209bf628, rbp = 0x8209bf640 ---
+# KDB: enter: panic
+# [ thread pid 2876 tid 100222 ]
+# Stopped at x32: movq $0,0x12a1323(%rip)
+# db> x/s version
+# version: FreeBSD 14.0-CURRENT #0 main-n257506-eed634d113d-dirty: Thu Aug 18 13:56:53 CEST 2022
+# pho@mercat1.netperf.freebsd.org:/usr/src/sys/amd64/compile/PHO\012
+# db>
+
+. ../default.cfg
+cat > /tmp/syzkaller62.c <<EOF
+// https://syzkaller.appspot.com/bug?id=582310beb894769fc836748eec49b8d2f905e5ef
+// autogenerated by syzkaller (https://github.com/google/syzkaller)
+// Reported-by: syzbot+6e8be1ec8d77578a3df4@syzkaller.appspotmail.com
+
+#define _GNU_SOURCE
+
+#include <pwd.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/endian.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff};
+
+int main(void)
+{
+ syscall(SYS_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x1012ul, -1, 0ul);
+ intptr_t res = 0;
+ memcpy((void*)0x20000040, "/dev/filemon\000", 13);
+ res = syscall(SYS_openat, 0xffffffffffffff9cul, 0x20000040ul, 0ul, 0ul);
+ if (res != -1)
+ r[0] = res;
+ res = syscall(SYS_socketpair, 1ul, 2ul, 0, 0x20000080ul);
+ if (res != -1)
+ r[1] = *(uint32_t*)0x20000084;
+ *(uint32_t*)0x200000c0 = r[1];
+ syscall(SYS_ioctl, r[0], 0xc0045301ul, 0x200000c0ul);
+ *(uint32_t*)0x20000040 = 3;
+ syscall(SYS_setsockopt, r[1], 0xffff, 0x1001, 0x20000040ul, 4ul);
+ return 0;
+}
+EOF
+mycc -o /tmp/syzkaller62 -Wall -Wextra -O0 /tmp/syzkaller62.c || exit 1
+
+kldstat | grep -q filemon || { kldload filemon.ko && loaded=1; }
+
+(cd /tmp; timeout -k 3s 2s ./syzkaller62)
+
+rm -rf /tmp/syzkaller62 /tmp/syzkaller62.c /tmp/syzkaller62.core \
+ /tmp/syzkaller.??????
+# Unload causes: Fatal trap 12: page fault while in kernel mode
+#[ $loaded ] && kldunload -f filemon.ko
+exit 0
diff --git a/tools/test/stress2/testcases/swap/swap.c b/tools/test/stress2/testcases/swap/swap.c
index 75bfe7856aed..c54605a4b0fe 100644
--- a/tools/test/stress2/testcases/swap/swap.c
+++ b/tools/test/stress2/testcases/swap/swap.c
@@ -155,10 +155,8 @@ test(void)
c[i] = 0;
i += page;
}
-#if 0
- if (op->hog != 1)
- usleep(1000);
-#endif
+ if (arc4random() % 100 < 10)
+ usleep(10000);
}
free((void *)c);
diff --git a/tools/tools/ether_reflect/ether_reflect.1 b/tools/tools/ether_reflect/ether_reflect.1
index 95fe60f762aa..e38e74d49f0a 100644
--- a/tools/tools/ether_reflect/ether_reflect.1
+++ b/tools/tools/ether_reflect/ether_reflect.1
@@ -42,7 +42,7 @@
The
.Nm
command implements a simple ethernet packet reflector using the
-.Xr PCAP 3
+.Xr pcap 3
library and
.Xr bpf 4 ,
the Berkeley Packet Filter.
@@ -96,8 +96,8 @@ Rewrite the destination address in each packet to 00:00:00:aa:bb:cc
before reflecting the packet.
.Sh SEE ALSO
.Xr tcpdump 1 ,
-.Xr bpf 2 ,
-.Xr pcap 4 ,
+.Xr bpf 4 ,
+.Xr pcap 3 ,
.Xr ifconfig 8
.Sh HISTORY
The
diff --git a/tools/tools/git/git-arc.sh b/tools/tools/git/git-arc.sh
index 835fbd91a7a1..22a13aa307bd 100644
--- a/tools/tools/git/git-arc.sh
+++ b/tools/tools/git/git-arc.sh
@@ -245,8 +245,6 @@ create_one_review()
return 1
fi
- git checkout -q "$commit"
-
msg=$(mktemp)
git show -s --format='%B' "$commit" > "$msg"
printf "\nTest Plan:\n" >> "$msg"
@@ -256,7 +254,8 @@ create_one_review()
printf "%s\n" "${subscribers}" >> "$msg"
yes | env EDITOR=true \
- arc diff --message-file "$msg" --never-apply-patches --create --allow-untracked $BROWSE HEAD~
+ arc diff --message-file "$msg" --never-apply-patches --create \
+ --allow-untracked $BROWSE --head "$commit" "${commit}~"
[ $? -eq 0 ] || err "could not create Phabricator diff"
if [ -n "$parent" ]; then
@@ -307,7 +306,7 @@ prompt()
local resp
if [ "$ASSUME_YES" ]; then
- return 1
+ return 0
fi
printf "\nDoes this look OK? [y/N] "
@@ -333,24 +332,6 @@ show_and_prompt()
prompt
}
-save_head()
-{
- local orig
-
- if ! orig=$(git symbolic-ref --short -q HEAD); then
- orig=$(git show -s --pretty=%H HEAD)
- fi
- SAVED_HEAD=$orig
-}
-
-restore_head()
-{
- if [ -n "$SAVED_HEAD" ]; then
- git checkout -q "$SAVED_HEAD"
- SAVED_HEAD=
- fi
-}
-
build_commit_list()
{
local chash _commits commits
@@ -382,9 +363,9 @@ gitarc__create()
l)
list=1
;;
- p)
- prev="$OPTARG"
- ;;
+ p)
+ prev="$OPTARG"
+ ;;
r)
reviewers="$OPTARG"
;;
@@ -410,7 +391,6 @@ gitarc__create()
doprompt=
fi
- save_head
for commit in ${commits}; do
if create_one_review "$commit" "$reviewers" "$subscribers" "$prev" \
"$doprompt"; then
@@ -419,7 +399,6 @@ gitarc__create()
prev=""
fi
done
- restore_head
}
gitarc__list()
@@ -524,7 +503,6 @@ gitarc__update()
local commit commits diff
commits=$(build_commit_list "$@")
- save_head
for commit in ${commits}; do
diff=$(commit2diff "$commit")
@@ -532,14 +510,12 @@ gitarc__update()
break
fi
- git checkout -q "$commit"
-
# The linter is stupid and applies patches to the working copy.
# This would be tolerable if it didn't try to correct "misspelled" variable
# names.
- arc diff --allow-untracked --never-apply-patches --update "$diff" HEAD~
+ arc diff --allow-untracked --never-apply-patches --update "$diff" \
+ --head "$commit" "${commit}~"
done
- restore_head
}
set -e
@@ -599,6 +575,16 @@ USAGE=
# shellcheck disable=SC1090
. "$git_sh_setup"
+# git commands use GIT_EDITOR instead of EDITOR, so try to provide consistent
+# behaviour. Ditto for PAGER. This makes git-arc play nicer with editor
+# plugins like vim-fugitive.
+if [ -n "$GIT_EDITOR" ]; then
+ EDITOR=$GIT_EDITOR
+fi
+if [ -n "$GIT_PAGER" ]; then
+ PAGER=$GIT_PAGER
+fi
+
# Bail if the working tree is unclean, except for "list" and "patch"
# operations.
case $verb in
@@ -613,6 +599,4 @@ if [ "$(git config --bool --get arc.browse 2>/dev/null || echo false)" != "false
BROWSE=--browse
fi
-trap restore_head EXIT INT
-
gitarc__"${verb}" "$@"
diff --git a/tools/tools/netmap/pkt-gen.c b/tools/tools/netmap/pkt-gen.c
index f43469cf7ad6..c6bae50188e2 100644
--- a/tools/tools/netmap/pkt-gen.c
+++ b/tools/tools/netmap/pkt-gen.c
@@ -1322,6 +1322,10 @@ ping_body(void *data)
return NULL;
}
+ if (targ->g->af == AF_INET6) {
+ D("Warning: ping-pong with IPv6 not supported");
+ }
+
bzero(&buckets, sizeof(buckets));
clock_gettime(CLOCK_REALTIME_PRECISE, &last_print);
now = last_print;
@@ -1504,6 +1508,11 @@ pong_body(void *data)
if (n > 0)
D("understood ponger %llu but don't know how to do it",
(unsigned long long)n);
+
+ if (targ->g->af == AF_INET6) {
+ D("Warning: ping-pong with IPv6 not supported");
+ }
+
while (!targ->cancel && (n == 0 || sent < n)) {
uint32_t txhead, txavail;
//#define BUSYWAIT
@@ -1547,7 +1556,15 @@ pong_body(void *data)
dpkt[3] = spkt[0];
dpkt[4] = spkt[1];
dpkt[5] = spkt[2];
+ /* swap source and destination IPv4 */
+ if (spkt[6] == htons(ETHERTYPE_IP)) {
+ dpkt[13] = spkt[15];
+ dpkt[14] = spkt[16];
+ dpkt[15] = spkt[13];
+ dpkt[16] = spkt[14];
+ }
txring->slot[txhead].len = slot->len;
+ //dump_payload(dst, slot->len, txring, txhead);
txhead = nm_ring_next(txring, txhead);
txavail--;
sent++;
@@ -2792,7 +2809,7 @@ tap_alloc(char *dev)
/* try to create the device */
if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ) {
- D("failed to to a TUNSETIFF: %s", strerror(errno));
+ D("failed to do a TUNSETIFF: %s", strerror(errno));
close(fd);
return err;
}
diff --git a/tools/tools/netrate/tcpp/tcpp_server.c b/tools/tools/netrate/tcpp/tcpp_server.c
index 0a79fbba5e30..eca2c3d469db 100644
--- a/tools/tools/netrate/tcpp/tcpp_server.c
+++ b/tools/tools/netrate/tcpp/tcpp_server.c
@@ -54,7 +54,7 @@
* Server side -- create a pool of processes, each listening on its own TCP
* port number for new connections. The first 8 bytes of each connection
* will be a network byte order length, then there will be that number of
- * bytes of data. We use non-blocking sockets with kqueue to to avoid the
+ * bytes of data. We use non-blocking sockets with kqueue to avoid the
* overhead of threading or more than one process per processor, which makes
* things a bit awkward when dealing with data we care about. As such, we
* read into a small character buffer which we then convert to a length once
diff --git a/tools/uma/smrstress/smrstress.c b/tools/uma/smrstress/smrstress.c
index 7e7ee4ea065c..2cf5f50ffae4 100644
--- a/tools/uma/smrstress/smrstress.c
+++ b/tools/uma/smrstress/smrstress.c
@@ -123,6 +123,7 @@ smrs_thread(void *arg)
else
smrs_read();
atomic_add_int(&smrs_completed, 1);
+ kthread_exit();
}
static void