diff --git a/test/quota/README.md b/test/quota/README.md index 601f62f..7a7372b 100644 --- a/test/quota/README.md +++ b/test/quota/README.md @@ -31,25 +31,28 @@ DQTSTA ## Linux handoff -When DOS prints that `DQTC` is waiting, set quotas for `NOPASSUSER`. `QUOTA` can -usually be set to 12 directly after the prepared directory was purged: +When DOS prints that `DQTC` is waiting, set quotas for `NOPASSUSER` with the +Linux helper. The helper reads the current `inuse4k` value on both volumes and +sets each limit to `inuse4k + 12`, which is the correct boundary for this smoke +even when old files or salvage/recycle remnants already exist. ```sh -./nwfs_ncpfs_userquota -S MARS -U SUPERVISOR -P 'zefuqUVe' \ - --volume QUOTA --object NOPASSUSER --type 1 --limit-4k 12 +./test/quota/dqt_linux_handoff.sh MARS SUPERVISOR 'zefuqUVe' ``` -For `SYS`, read the current usage and set the limit to `inuse4k + 12`, because -`NOPASSUSER` may already own files on SYS: +If the `nwfs_ncpfs_userquota` helper is not in `PATH`, point the script at the +built MARS-NWE test helper: ```sh -./nwfs_ncpfs_userquota -S MARS -U SUPERVISOR -P 'zefuqUVe' \ - --volume SYS --object NOPASSUSER --type 1 --get - -./nwfs_ncpfs_userquota -S MARS -U SUPERVISOR -P 'zefuqUVe' \ - --volume SYS --object NOPASSUSER --type 1 --limit-4k +NWFS_NCPFS_USERQUOTA=/home/mario/mars/mars-nwe-build/tests/nwfs/nwfs_ncpfs_userquota \ + ./test/quota/dqt_linux_handoff.sh MARS SUPERVISOR 'zefuqUVe' ``` +The helper updates both backends: + +- `QUOTA`: Linuxquota-authoritative volume, mapped as `Q:` in DOS. +- `SYS`: NWQUOTA metadata-authoritative volume, mapped as `F:` in DOS. + Then return to DOS and press `J`, `j`, `Y`, or `y`. ## DOS part 2 diff --git a/test/quota/dqt_linux_handoff.sh b/test/quota/dqt_linux_handoff.sh new file mode 100755 index 0000000..f38b9f4 --- /dev/null +++ b/test/quota/dqt_linux_handoff.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +set -euo pipefail + +SERVER=${1:-${DQT_SERVER:-MARS}} +ADMIN=${2:-${DQT_ADMIN:-SUPERVISOR}} +PASSWORD=${3:-${DQT_PASSWORD:-}} +QUOTA_VOL=${4:-${DQT_QUOTA_VOLUME:-QUOTA}} +SYS_VOL=${5:-${DQT_SYS_VOLUME:-SYS}} +OBJECT=${6:-${DQT_OBJECT:-NOPASSUSER}} +TYPE=${7:-${DQT_TYPE:-1}} +ALLOW4K=${8:-${DQT_ALLOW4K:-12}} + +if [ -z "$PASSWORD" ]; then + cat >&2 <<'USAGE' +usage: dqt_linux_handoff.sh SERVER ADMIN PASSWORD [QUOTA_VOL SYS_VOL OBJECT TYPE ALLOW4K] + +Example while DOS DQTC waits: + ./test/quota/dqt_linux_handoff.sh MARS SUPERVISOR 'zefuqUVe' + +Environment alternatives: + DQT_PASSWORD=... DQT_SERVER=MARS DQT_ADMIN=SUPERVISOR ./test/quota/dqt_linux_handoff.sh + +Optional: + NWFS_NCPFS_USERQUOTA=/path/to/nwfs_ncpfs_userquota +USAGE + exit 2 +fi + +TOOL=${NWFS_NCPFS_USERQUOTA:-} +if [ -z "$TOOL" ]; then + if command -v nwfs_ncpfs_userquota >/dev/null 2>&1; then + TOOL=$(command -v nwfs_ncpfs_userquota) + elif [ -x /home/mario/mars/mars-nwe-build/tests/nwfs/nwfs_ncpfs_userquota ]; then + TOOL=/home/mario/mars/mars-nwe-build/tests/nwfs/nwfs_ncpfs_userquota + else + echo "nwfs_ncpfs_userquota not found; set NWFS_NCPFS_USERQUOTA" >&2 + exit 2 + fi +fi + +quota_cmd() { + "$TOOL" -S "$SERVER" -U "$ADMIN" -P "$PASSWORD" \ + --volume "$1" --object "$OBJECT" --type "$TYPE" "$@" +} + +get_line() { + local volume=$1 + "$TOOL" -S "$SERVER" -U "$ADMIN" -P "$PASSWORD" \ + --volume "$volume" --object "$OBJECT" --type "$TYPE" --get +} + +get_inuse4k() { + local volume=$1 line + line=$(get_line "$volume") + printf '%s\n' "$line" >&2 + printf '%s\n' "$line" | sed -n 's/.*inuse4k=\([0-9][0-9]*\).*/\1/p' +} + +set_volume_limit() { + local volume=$1 inuse limit + inuse=$(get_inuse4k "$volume") + if [ -z "$inuse" ]; then + echo "could not parse inuse4k for volume $volume" >&2 + exit 1 + fi + limit=$((inuse + ALLOW4K)) + echo "setting $volume quota for $OBJECT type $TYPE: inuse4k=$inuse allow4k=$ALLOW4K limit4k=$limit" >&2 + "$TOOL" -S "$SERVER" -U "$ADMIN" -P "$PASSWORD" \ + --volume "$volume" --object "$OBJECT" --type "$TYPE" --limit-4k "$limit" + get_line "$volume" +} + +echo "# DOS quota handoff for $OBJECT type $TYPE" >&2 +echo "# server=$SERVER quota_volume=$QUOTA_VOL sys_volume=$SYS_VOL allow4k=$ALLOW4K" >&2 +set_volume_limit "$QUOTA_VOL" +set_volume_limit "$SYS_VOL" +echo "# return to DOS and press J/j/Y/y" >&2