List all inodes, inumbers

Hello,


Is there any way to get a list of all inode numbers on a volume? I have a "find -x /Volumes/thedisk/* -exec stat {} \;" going but requires lots of CPU time. Seems like I should be able to look directly at the file allocation table...oh wait, that is DOS. This is on an HFS disk: /dev/disk0s2 on / (hfs, local, journaled)


B

MacBook Pro, Mac OS X (10.6.8)

Posted on Mar 22, 2012 12:17 PM

Reply
4 replies

Apr 2, 2017 9:08 PM in response to bernuli

ls -i and stat are not fast enough.


Camelot's suggestion using:


ls -R -i


should be as fast as 'find'. I got so focused on improving your 'find' in my reply, that I totally forgot that ls -R -i will effectively do the same thing, with less junk thrown in.


... so I can compare 2 sets of directories which both have hard links to the same file.


The


diff -r directory_1 directory_2


can do directory comparisons. Not sure if this is of interest or not. "man diff" will give you all the 'diff' options available.


I am surprised the inumbers can't simply be listed for direct access to a file rather than having find run through the hierarchy.


Unix file systems generally DO NOT allow accessing a file via their inode number. They often depend on access permissions in the parent, grandparent, great grandparent, etc... to control access to a file. By passing the file system name space and going directly to a file via the inode number would upset the security balance.


Of course every file system implementation is different, and it is always possible that a specific implementation has a file system specific ioctl() or fcntl() that can do that, but it is NOT a generic Unix feature, short of reading the raw disk, and parsing the file system on-disk structures (also a security violation, so only root or the owner of the file /dev/devicename is allowed to do that). fsck is one of those things that needs root access, and fsck actually has different flavors of fsck for different file system implementations


/sbin/fsck

/sbin/fsck_cs

/sbin/fsck_exfat

/sbin/fsck_hfs

/sbin/fsck_msdos

/sbin/fsck_udf


Some have the inodes scattered all over the place, some have them centrailized, some may have a table of inode pointers, etc.... Again, all implementation dependent. And unless the file system provides an API separate from the file system, generally speaking a user program cannot access a file via its inode number.


I work on Unix file systems during the day.

Mar 24, 2012 2:57 PM in response to Camelot

ls -i and stat are not fast enough. I would like to identify a file by inode so I can compare 2 sets of directories which both have hard links to the same file.


I am surprised the inumbers can't simply be listed for direct access to a file rather than having find run through the hierarchy.


fsck does something similar I think but won't be verbose about it.



B

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

List all inodes, inumbers

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.