11.10Shannken# $NetBSD: t_rquotad.sh,v 1.10 2023/05/28 08:17:00 hannken Exp $ 21.1Sbouyer# 31.1Sbouyer# Copyright (c) 2011 Manuel Bouyer 41.1Sbouyer# All rights reserved. 51.9Sriastrad# 61.1Sbouyer# Redistribution and use in source and binary forms, with or without 71.1Sbouyer# modification, are permitted provided that the following conditions 81.1Sbouyer# are met: 91.1Sbouyer# 1. Redistributions of source code must retain the above copyright 101.1Sbouyer# notice, this list of conditions and the following disclaimer. 111.1Sbouyer# 2. Redistributions in binary form must reproduce the above copyright 121.1Sbouyer# notice, this list of conditions and the following disclaimer in the 131.1Sbouyer# documentation and/or other materials provided with the distribution. 141.9Sriastrad# 151.1Sbouyer# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 161.1Sbouyer# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 171.1Sbouyer# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 181.1Sbouyer# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 191.1Sbouyer# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 201.1Sbouyer# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 211.1Sbouyer# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 221.1Sbouyer# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 231.1Sbouyer# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 241.1Sbouyer# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 251.1Sbouyer# POSSIBILITY OF SUCH DAMAGE. 261.1Sbouyer# 271.8Sgson 281.8Sgson# Like test_case_root() in ../ffs/ffs_common.sh, plus cleanup of both 291.8Sgson# rump servers. 301.8Sgson 311.8Sgsontest_case_rquotad() 321.8Sgson{ 331.8Sgson local name="${1}"; shift 341.8Sgson local check_function="${1}"; shift 351.8Sgson local descr="${1}"; shift 361.9Sriastrad 371.8Sgson atf_test_case "${name}" cleanup 381.8Sgson 391.8Sgson eval "${name}_head() { \ 401.8Sgson atf_set "descr" "${descr}" 411.8Sgson atf_set "require.user" "root" 421.8Sgson atf_set "timeout" "360" 431.8Sgson }" 441.8Sgson eval "${name}_body() { \ 451.8Sgson RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \ 461.8Sgson export RUMP_SERVER=unix://\${RUMP_SOCKET}; \ 471.8Sgson ${check_function} " "${@}" "; \ 481.8Sgson }" 491.8Sgson # Can't use RUMP_SOCKETS_LIST here because it is not set in 501.8Sgson # the cleanup shell. 511.8Sgson eval "${name}_cleanup() { \ 521.8Sgson for s in \${RUMP_SOCKET} clientsock; do \ 531.8Sgson RUMP_SERVER=unix://\${s} rump.halt 2>/dev/null || true; \ 541.8Sgson done; \ 551.8Sgson }" 561.8Sgson tests="${tests} ${name}" 571.8Sgson} 581.8Sgson 591.1Sbouyerfor e in le be; do 601.1Sbouyer for v in 1; do 611.1Sbouyer for q in "user" "group" "both"; do 621.8Sgson test_case_rquotad get_nfs_${e}_${v}_${q} get_nfs_quota \ 631.1Sbouyer "get NFS quota with ${q} enabled" ${e} ${v} ${q} 641.1Sbouyer done 651.1Sbouyer done 661.1Sbouyerdone 671.1Sbouyer 681.1Sbouyerget_nfs_quota() 691.1Sbouyer{ 701.2Sbouyer create_ffs $* 711.1Sbouyer local q=$3 721.1Sbouyer local expect 731.1Sbouyer 741.1Sbouyer case ${q} in 751.1Sbouyer user) 761.1Sbouyer expect=u 771.1Sbouyer ;; 781.1Sbouyer group) 791.1Sbouyer expect=g 801.1Sbouyer ;; 811.1Sbouyer both) 821.1Sbouyer expect="u g" 831.1Sbouyer ;; 841.1Sbouyer *) 851.1Sbouyer atf_fail "wrong quota type" 861.1Sbouyer ;; 871.1Sbouyer esac 881.1Sbouyer 891.6Smsaitoh#start a nfs server 901.1Sbouyer 911.1Sbouyer atf_check -s exit:0 rump_server -lrumpvfs -lrumpdev -lrumpnet \ 921.4Sgson -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 \ 931.4Sgson -lrumpnet_local -lrumpnet_shmif -lrumpdev_disk -lrumpfs_ffs \ 941.4Sgson -lrumpfs_nfs -lrumpfs_nfsserver \ 951.1Sbouyer -d key=/dk,hostpath=${IMG},size=host ${RUMP_SERVER} 961.1Sbouyer 971.1Sbouyer atf_check -s exit:0 rump.ifconfig shmif0 create 981.1Sbouyer atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus 991.1Sbouyer atf_check -s exit:0 rump.ifconfig shmif0 inet 10.1.1.1 1001.1Sbouyer 1011.1Sbouyer export RUMPHIJACK_RETRYCONNECT=die 1021.1Sbouyer export LD_PRELOAD=/usr/lib/librumphijack.so 1031.1Sbouyer 1041.1Sbouyer atf_check -s exit:0 mkdir /rump/etc 1051.1Sbouyer atf_check -s exit:0 mkdir /rump/export 1061.1Sbouyer atf_check -s exit:0 mkdir -p /rump/var/run 1071.1Sbouyer atf_check -s exit:0 mkdir -p /rump/var/db 1081.1Sbouyer atf_check -s exit:0 touch /rump/var/db/mountdtab 1091.1Sbouyer 1101.1Sbouyer /bin/echo "/export -noresvport -noresvmnt 10.1.1.100" | \ 1111.1Sbouyer dd of=/rump/etc/exports 2> /dev/null 1121.1Sbouyer 1131.10Shannken atf_check -s exit:0 -e ignore env RUMPHIJACK='path=/rump,blanket=/dk' \ 1141.10Shannken mount_ffs /dk /rump/export 1151.1Sbouyer 1161.1Sbouyer#set a quota limit (and check that we can read it back) 1171.1Sbouyer for q in ${expect} ; do 1181.1Sbouyer local id=$(id -${q}) 1191.1Sbouyer atf_check -s exit:0 \ 1201.1Sbouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/export edquota -$q -s10k/20 -h40M/50k \ 1211.1Sbouyer -t 2W/3D ${id} 1221.1Sbouyer atf_check -s exit:0 \ 1231.1Sbouyer-o "match:0 10 40960 2weeks 1 20 51200 3days" \ 1241.1Sbouyer-o "match:Disk quotas for .*: $" \ 1251.1Sbouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/export quota -${q} -v 1261.1Sbouyer done 1271.1Sbouyer 1281.1Sbouyer # start rpcbind. we want /var/run/rpcbind.sock 1291.1Sbouyer export RUMPHIJACK='blanket=/var/run,socket=all' 1301.1Sbouyer atf_check -s exit:0 rpcbind 1311.1Sbouyer 1321.1Sbouyer # ok, then we want mountd in the similar fashion 1331.1Sbouyer export RUMPHIJACK='blanket=/var/run:/var/db:/export,socket=all,path=/rump,vfs=all' 1341.1Sbouyer atf_check -s exit:0 mountd /rump/etc/exports 1351.1Sbouyer 1361.1Sbouyer # and nfs 1371.1Sbouyer export RUMPHIJACK='blanket=/var/run,socket=all,vfs=all' 1381.3Spgoyette atf_check -s exit:0 nfsd 1391.1Sbouyer 1401.1Sbouyer #finally, rpc.rquotad 1411.1Sbouyer export RUMPHIJACK='blanket=/var/run:/export,vfs=getvfsstat,socket=all' 1421.1Sbouyer atf_check -s exit:0 /usr/libexec/rpc.rquotad 1431.1Sbouyer 1441.1Sbouyer # now start a client server 1451.1Sbouyer export RUMP_SERVER=unix://clientsock 1461.1Sbouyer RUMP_SOCKETS_LIST="${RUMP_SOCKETS_LIST} clientsock" 1471.1Sbouyer unset RUMPHIJACK 1481.1Sbouyer unset LD_PRELOAD 1491.1Sbouyer 1501.7Sbad atf_check -s exit:0 rump_server -lrumpvfs -lrumpnet \ 1511.1Sbouyer -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif -lrumpfs_nfs\ 1521.1Sbouyer ${RUMP_SERVER} 1531.1Sbouyer 1541.1Sbouyer atf_check -s exit:0 rump.ifconfig shmif0 create 1551.1Sbouyer atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus 1561.1Sbouyer atf_check -s exit:0 rump.ifconfig shmif0 inet 10.1.1.100 1571.1Sbouyer 1581.1Sbouyer export LD_PRELOAD=/usr/lib/librumphijack.so 1591.1Sbouyer 1601.1Sbouyer atf_check -s exit:0 mkdir /rump/mnt 1611.1Sbouyer atf_check -s exit:0 mount_nfs 10.1.1.1:/export /rump/mnt 1621.1Sbouyer 1631.1Sbouyer #now try a quota(8) call 1641.1Sbouyer export RUMPHIJACK='blanket=/mnt,socket=all,path=/rump,vfs=getvfsstat' 1651.1Sbouyer for q in ${expect} ; do 1661.1Sbouyer local id=$(id -${q}) 1671.1Sbouyer atf_check -s exit:0 \ 1681.1Sbouyer-o "match:/mnt 0 10 40960 1 20 51200 " \ 1691.1Sbouyer-o "match:Disk quotas for .*: $" \ 1701.1Sbouyer quota -${q} -v 1711.1Sbouyer done 1721.1Sbouyer 1731.1Sbouyer unset LD_PRELOAD 1741.2Sbouyer rump_quota_shutdown 1751.1Sbouyer} 176