- #!/bin/bash
- #
- # nfsv4_num_locking_fun1.sh - test whether locking via lock dirs or
- # flock(2) work if multiple NFS clients write to the same file
- #
- # For fcntl-lock(.exe) see
- # https://github.com/magnumripper/fcntl-lock/blob/master/fcntl-lock.c
- #
- # We use this to test the file locking of the CITI NFSv4 client for
- # Windows
- #
- # Written by Roland Mainz <roland.mainz@nrubsig.org>
- #
- typeset mode="$1"
- typeset cmd="$2"
- case "$mode" in
- 'lockdir')
- case "$cmd" in
- 'init' | 'reset')
- rm -f 'foo'
- [[ -d 'mylock' ]] && rmdir 'mylock'
- printf '0\n' >'foo'
- ;;
- 'worker')
- for ((i=0 ; i < 100 ; i++ )) ; do
- while ! mkdir mylock ; do sleep 5 ; done
- typeset -i x
- x=$( tail -n 1 foo )
- sleep 3 ; (( x++ ))
- echo "$x" >>foo
- rmdir mylock
- echo "WRITE $x"
- sleep 7
- done
- ;;
- *)
- printf $"%s: Unknown command %s.\n" "$0" "$cmd"
- exit 1
- ;;
- esac
- ;;
- 'fcntl-lock' | 'fcntl-lock.exe' | '/usr/bin/flock')
- export PATH="$PWD:$PATH"
- case "$cmd" in
- 'init' | 'reset')
- rm -f 'foo'
- rm -f 'mylockfile'
- touch 'mylockfile'
- printf '0\n' >'foo'
- ;;
- 'worker')
- for ((i=0 ; i < 100 ; i++ )) ; do
- $mode --exclusive 'mylockfile' bash -c \
- 'typeset -i x
- x=$( tail -n 1 foo )
- sleep 1 ; (( x++ ))
- echo "$x" >>"foo"
- echo "WRITE $x"
- sleep 0.5'
- done
- ;;
- *)
- printf $"%s: Unknown command %s.\n" "$0" "$cmd"
- exit 1
- ;;
- esac
- ;;
- *)
- printf $"%s: Unknown mode %s.\n" "$0" "$mode"
- exit 1
- ;;
- esac
- # EOF.
nfsv4_num_locking_fun1.sh
Posted by Anonymous on Wed 28th Jun 2023 13:28
raw | new post
view followups (newest first): nfsv4_num_locking_fun1.sh by Anonymous
modification of post by Anonymous (view diff)
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.