Last active
September 25, 2019 11:38
-
-
Save tomtastic/9001d801622195d5cda67f57915ec502 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Used by Samba to grok ZFS free space | |
if [[ -n "$1" ]]; then | |
# Only ever return info for the current directory as Apple mounts only pass '.' ? | |
#P="$1" | |
P=$(pwd) | |
else | |
P=$(pwd) | |
fi | |
USED=$(( $(zfs get -o value -Hp used "$P" 2>/dev/null || echo 1) / 1024)) > /dev/null | |
AVAIL=$(( $(zfs get -o value -Hp available "$P" 2>/dev/null || echo 1) / 1024)) > /dev/null | |
TOTAL=$((USED+AVAIL)) > /dev/null | |
echo $TOTAL $AVAIL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Obviously, only use this for ZFS shares, it's going to fail if you're on ext3/4/xfs/btrfs/etc.