Skip to content

Instantly share code, notes, and snippets.

@tomtastic
Last active September 25, 2019 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomtastic/9001d801622195d5cda67f57915ec502 to your computer and use it in GitHub Desktop.
Save tomtastic/9001d801622195d5cda67f57915ec502 to your computer and use it in GitHub Desktop.
#!/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
@tomtastic
Copy link
Author

Obviously, only use this for ZFS shares, it's going to fail if you're on ext3/4/xfs/btrfs/etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment