Last active
March 30, 2016 08:09
-
-
Save etam/934e4a3f7c93cb30907c to your computer and use it in GitHub Desktop.
btrfs resolve hardlinks
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 | |
if [[ ! -e "$1" ]]; then | |
echo "\"$1\" - no such file or directory" >&2 | |
exit 1 | |
fi | |
resolve_to_absolute() { | |
sudo btrfs inspect-internal inode-resolve -v $(stat -c "%i" "$1") $(stat -c "%m" "$1") | tail -n +2 | |
} | |
abs2rel_lines() { | |
tr \\n \\0 | xargs -0 -n 1 relpath | |
} | |
if [[ "${1:0:1}" == "/" ]]; then | |
resolve_to_absolute "$1" | |
else | |
resolve_to_absolute "$1" | abs2rel_lines | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment