I recently made a little hack hardlinks that takes a path (or inode) of a hardlinked file and lists the paths of all of its clones (including its own), provided it lives on an HFS volume. Usage is simple:
sudo hardlinks path
or
sudo hardlinks -c inode
You need to have the hfsdebug-lite binary Amit Singh provides installed for it to work, and if you're on a modern mac, you need to install the Rosetta tools from your MacOS X install disk to get hfsdebug to run. (That sudo is needed for hfsdebug to access the raw device of the volume -- after that, hfsdebug drops privileges to the nobody user.)
Source code:
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/zsh | |
# get hfsdebug-lite at http://www.osxbook.com/software/hfsdebug/ | |
parse-hfsdebug-path () { sed -n '/^ path /s/^.*://p' } | |
parse-hfsdebug-prev () { sed -n '/^ ownerID /s/^.* = \([0-9]*\).*/\1/p' } | |
parse-hfsdebug-next () { sed -n '/^ groupID /s/^.* = \([0-9]*\).*/\1/p' } | |
hardlinks () { | |
hfsdebug=$(whence hfsdebug-lite || whence hfsdebug) | |
stdout=$($hfsdebug "$@") | |
parse-hfsdebug-path <<<$stdout | |
prev=$(parse-hfsdebug-prev <<<$stdout) | |
next=$(parse-hfsdebug-next <<<$stdout) | |
while [[ "$prev" != "0" ]] ; do | |
stdout=$($hfsdebug -c $prev) | |
parse-hfsdebug-path <<<$stdout | |
prev=$(parse-hfsdebug-prev <<<$stdout) | |
done | |
while [[ "$next" != "0" ]] ; do | |
stdout=$($hfsdebug -c $next) | |
parse-hfsdebug-path <<<$stdout | |
next=$(parse-hfsdebug-next <<<$stdout) | |
done | |
} | |
hardlinks "$@" |