inodes are unique only in the file system, so at least the device and inode numbers are required to identify the file.
On the HFS + file system, the inode number is actually identical to the “Macintosh File Identifier”, and there is a special “/.vol” file system that allows you to find the directory using the device and inode.
Example:
$ cd /.vol/234881029/342711 $ pwd /Volumes/Data/tmpwork/test20/test20.xcodeproj $ stat . 234881029 342711 drwxr-xr-x 5 martin staff 0 170 ......
As you can see, 234881029 is the device number "/ Volumes / Data", 342711 is the inode number "tmpwork / test20 / test20.xcodeproj" inside this file system and
cd /.vol/<deviceNo>/<inodeNo>
transferred you directly to this folder. Now you can use getcwd() to determine the real path to this folder.
The "/.vol" file system is documented in the obsolete Technical Q & A QA1113 .
Disclaimer: I have only tried this on OS X 10.7, and I'm sure it works on older systems. I have no idea if you can rely on this feature in future versions of OS X. It is also very specific to HFS.
source share