-
-
Save hypevhs/b3ec8652e5daaddd21b0c5eefba83d10 to your computer and use it in GitHub Desktop.
dfree for samba that treats ZFS as a special case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# vim: set et ts=2 sw=2: | |
# changes: run through shellcheck, fixing several bugs | |
set -euo pipefail | |
HERE="$(realpath "$1")" | |
if findmnt --noheadings --output FSTYPE --target "$HERE" | grep -Pq '^zfs$'; then | |
echo "dfree: $HERE is zfs" >&2 | |
USED_BYTES=$(zfs get -o value -Hp used "$HERE") | |
AVAIL_BYTES=$(zfs get -o value -Hp available "$HERE") | |
USED=$((USED_BYTES/1024)) | |
AVAIL=$((AVAIL_BYTES/1024)) | |
TOTAL=$((USED+AVAIL)) | |
echo "$TOTAL $AVAIL" | |
else | |
echo "dfree: $HERE is NOT zfs" >&2 | |
df -k --output=size,avail "$HERE" | tail -1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment