1*0a6a1f1dSLionel Sambuc# $NetBSD: t_rquotad.sh,v 1.4 2014/03/13 12:45:14 gson Exp $ 211be35a1SLionel Sambuc# 311be35a1SLionel Sambuc# Copyright (c) 2011 Manuel Bouyer 411be35a1SLionel Sambuc# All rights reserved. 511be35a1SLionel Sambuc# 611be35a1SLionel Sambuc# Redistribution and use in source and binary forms, with or without 711be35a1SLionel Sambuc# modification, are permitted provided that the following conditions 811be35a1SLionel Sambuc# are met: 911be35a1SLionel Sambuc# 1. Redistributions of source code must retain the above copyright 1011be35a1SLionel Sambuc# notice, this list of conditions and the following disclaimer. 1111be35a1SLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright 1211be35a1SLionel Sambuc# notice, this list of conditions and the following disclaimer in the 1311be35a1SLionel Sambuc# documentation and/or other materials provided with the distribution. 1411be35a1SLionel Sambuc# 1511be35a1SLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1611be35a1SLionel Sambuc# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 1711be35a1SLionel Sambuc# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1811be35a1SLionel Sambuc# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 1911be35a1SLionel Sambuc# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2011be35a1SLionel Sambuc# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2111be35a1SLionel Sambuc# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2211be35a1SLionel Sambuc# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2311be35a1SLionel Sambuc# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2411be35a1SLionel Sambuc# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2511be35a1SLionel Sambuc# POSSIBILITY OF SUCH DAMAGE. 2611be35a1SLionel Sambuc# 2711be35a1SLionel Sambucfor e in le be; do 2811be35a1SLionel Sambuc for v in 1; do 2911be35a1SLionel Sambuc for q in "user" "group" "both"; do 3011be35a1SLionel Sambuc test_case_root get_nfs_${e}_${v}_${q} get_nfs_quota \ 3111be35a1SLionel Sambuc "get NFS quota with ${q} enabled" ${e} ${v} ${q} 3211be35a1SLionel Sambuc done 3311be35a1SLionel Sambuc done 3411be35a1SLionel Sambucdone 3511be35a1SLionel Sambuc 3611be35a1SLionel Sambucget_nfs_quota() 3711be35a1SLionel Sambuc{ 3811be35a1SLionel Sambuc create_ffs $* 3911be35a1SLionel Sambuc local q=$3 4011be35a1SLionel Sambuc local expect 4111be35a1SLionel Sambuc 4211be35a1SLionel Sambuc case ${q} in 4311be35a1SLionel Sambuc user) 4411be35a1SLionel Sambuc expect=u 4511be35a1SLionel Sambuc ;; 4611be35a1SLionel Sambuc group) 4711be35a1SLionel Sambuc expect=g 4811be35a1SLionel Sambuc ;; 4911be35a1SLionel Sambuc both) 5011be35a1SLionel Sambuc expect="u g" 5111be35a1SLionel Sambuc ;; 5211be35a1SLionel Sambuc *) 5311be35a1SLionel Sambuc atf_fail "wrong quota type" 5411be35a1SLionel Sambuc ;; 5511be35a1SLionel Sambuc esac 5611be35a1SLionel Sambuc 5711be35a1SLionel Sambuc#start a a nfs server 5811be35a1SLionel Sambuc 5911be35a1SLionel Sambuc atf_check -s exit:0 rump_server -lrumpvfs -lrumpdev -lrumpnet \ 60*0a6a1f1dSLionel Sambuc -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 \ 61*0a6a1f1dSLionel Sambuc -lrumpnet_local -lrumpnet_shmif -lrumpdev_disk -lrumpfs_ffs \ 62*0a6a1f1dSLionel Sambuc -lrumpfs_nfs -lrumpfs_nfsserver \ 6311be35a1SLionel Sambuc -d key=/dk,hostpath=${IMG},size=host ${RUMP_SERVER} 6411be35a1SLionel Sambuc 6511be35a1SLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 create 6611be35a1SLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus 6711be35a1SLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 inet 10.1.1.1 6811be35a1SLionel Sambuc 6911be35a1SLionel Sambuc export RUMPHIJACK_RETRYCONNECT=die 7011be35a1SLionel Sambuc export LD_PRELOAD=/usr/lib/librumphijack.so 7111be35a1SLionel Sambuc 7211be35a1SLionel Sambuc atf_check -s exit:0 mkdir /rump/etc 7311be35a1SLionel Sambuc atf_check -s exit:0 mkdir /rump/export 7411be35a1SLionel Sambuc atf_check -s exit:0 mkdir -p /rump/var/run 7511be35a1SLionel Sambuc atf_check -s exit:0 mkdir -p /rump/var/db 7611be35a1SLionel Sambuc atf_check -s exit:0 touch /rump/var/db/mountdtab 7711be35a1SLionel Sambuc 7811be35a1SLionel Sambuc /bin/echo "/export -noresvport -noresvmnt 10.1.1.100" | \ 7911be35a1SLionel Sambuc dd of=/rump/etc/exports 2> /dev/null 8011be35a1SLionel Sambuc 8111be35a1SLionel Sambuc atf_check -s exit:0 -e ignore mount_ffs /dk /rump/export 8211be35a1SLionel Sambuc 8311be35a1SLionel Sambuc#set a quota limit (and check that we can read it back) 8411be35a1SLionel Sambuc for q in ${expect} ; do 8511be35a1SLionel Sambuc local id=$(id -${q}) 8611be35a1SLionel Sambuc atf_check -s exit:0 \ 8711be35a1SLionel Sambuc env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/export edquota -$q -s10k/20 -h40M/50k \ 8811be35a1SLionel Sambuc -t 2W/3D ${id} 8911be35a1SLionel Sambuc atf_check -s exit:0 \ 9011be35a1SLionel Sambuc-o "match:0 10 40960 2weeks 1 20 51200 3days" \ 9111be35a1SLionel Sambuc-o "match:Disk quotas for .*: $" \ 9211be35a1SLionel Sambuc env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/export quota -${q} -v 9311be35a1SLionel Sambuc done 9411be35a1SLionel Sambuc 9511be35a1SLionel Sambuc # start rpcbind. we want /var/run/rpcbind.sock 9611be35a1SLionel Sambuc export RUMPHIJACK='blanket=/var/run,socket=all' 9711be35a1SLionel Sambuc atf_check -s exit:0 rpcbind 9811be35a1SLionel Sambuc 9911be35a1SLionel Sambuc # ok, then we want mountd in the similar fashion 10011be35a1SLionel Sambuc export RUMPHIJACK='blanket=/var/run:/var/db:/export,socket=all,path=/rump,vfs=all' 10111be35a1SLionel Sambuc atf_check -s exit:0 mountd /rump/etc/exports 10211be35a1SLionel Sambuc 10311be35a1SLionel Sambuc # and nfs 10411be35a1SLionel Sambuc export RUMPHIJACK='blanket=/var/run,socket=all,vfs=all' 10511be35a1SLionel Sambuc atf_check -s exit:0 nfsd 10611be35a1SLionel Sambuc 10711be35a1SLionel Sambuc #finally, rpc.rquotad 10811be35a1SLionel Sambuc export RUMPHIJACK='blanket=/var/run:/export,vfs=getvfsstat,socket=all' 10911be35a1SLionel Sambuc atf_check -s exit:0 /usr/libexec/rpc.rquotad 11011be35a1SLionel Sambuc 11111be35a1SLionel Sambuc # now start a client server 11211be35a1SLionel Sambuc export RUMP_SERVER=unix://clientsock 11311be35a1SLionel Sambuc RUMP_SOCKETS_LIST="${RUMP_SOCKETS_LIST} clientsock" 11411be35a1SLionel Sambuc unset RUMPHIJACK 11511be35a1SLionel Sambuc unset LD_PRELOAD 11611be35a1SLionel Sambuc 11711be35a1SLionel Sambuc atf_check -s exit:0 rump_server -lrumpvfs -lrumpnet \ 11811be35a1SLionel Sambuc -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif -lrumpfs_nfs\ 11911be35a1SLionel Sambuc ${RUMP_SERVER} 12011be35a1SLionel Sambuc 12111be35a1SLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 create 12211be35a1SLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 linkstr shmbus 12311be35a1SLionel Sambuc atf_check -s exit:0 rump.ifconfig shmif0 inet 10.1.1.100 12411be35a1SLionel Sambuc 12511be35a1SLionel Sambuc export LD_PRELOAD=/usr/lib/librumphijack.so 12611be35a1SLionel Sambuc 12711be35a1SLionel Sambuc atf_check -s exit:0 mkdir /rump/mnt 12811be35a1SLionel Sambuc atf_check -s exit:0 mount_nfs 10.1.1.1:/export /rump/mnt 12911be35a1SLionel Sambuc 13011be35a1SLionel Sambuc #now try a quota(8) call 13111be35a1SLionel Sambuc export RUMPHIJACK='blanket=/mnt,socket=all,path=/rump,vfs=getvfsstat' 13211be35a1SLionel Sambuc for q in ${expect} ; do 13311be35a1SLionel Sambuc local id=$(id -${q}) 13411be35a1SLionel Sambuc atf_check -s exit:0 \ 13511be35a1SLionel Sambuc-o "match:/mnt 0 10 40960 1 20 51200 " \ 13611be35a1SLionel Sambuc-o "match:Disk quotas for .*: $" \ 13711be35a1SLionel Sambuc quota -${q} -v 13811be35a1SLionel Sambuc done 13911be35a1SLionel Sambuc 14011be35a1SLionel Sambuc unset LD_PRELOAD 14111be35a1SLionel Sambuc rump_quota_shutdown 14211be35a1SLionel Sambuc} 143