I have recursed a folder on a single volume, and retrieved a list of filenames, reference-counts and inode numbers, using
NSFileManager attributesOfItemAtPath
and NSDictionary fileSystemFileNumber and objectForKey:NSFileReferenceCount
For some reason I am getting results such as a reference count of 10, but a list of many more than 10 files with the same iNode number.
Of note is that I am not including SymLinks in my list, I'm only recording a file when [dict fileType] == NSFileTypeRegular
Any ideas why this might be the case?
Edit: @Peter Hosey, I'm writing the iNode and reference count as follows:
CLMFileManagedObj *clmf;
clmf = (CLMFileManagedObj *)[NSEntityDescription insertNewObjectForEntityForName:@"CLMFile" inManagedObjectContext:moc];
NSUInteger fsfn = [dict fileSystemFileNumber];
[clmf setValue:[NSNumber numberWithUnsignedInteger:fsfn] forKey:@"iNodeNumber"];
[clmf setValue:(NSNumber*)[dict objectForKey:NSFileReferenceCount] forKey:@"referenceCount"];
Note that the reason iNodeNumber and referenceCount are being written slightly differently is that [dict] offers a direct (NSUInteger)fileSystemFileNumber get-method, whereas the fileReferenceCount needs to be retrieved using keys (according to any help I could find on NSDictionary)
Both properties of the CLMFile entity are Int 64. From what I can tell, NSUInteger's type is dependent on whether running 32 or 64 bit mode, but [NSNumber numberWithUnsignedInteger] accepts NSUInteger as the argument, so I'd assume it deals with the number correctly in either mode.
I can't see where in Activity Monitor it says whether it's 32/64 bit. I'd assume whatever the default for XCode 3.1.3 projects are.
It's possible I'm missing something here, as I'm relatively new to Mac/Obj-C/XCode/Cocoa, so any help/pointers would be appreciated. Experienced programmer, but not in this environment (though learning as fast as I can....)
Are you looking at Time Machine backups? Are there directory hardlinks involved?
If directory A contains directories B1 and B2 which are hardlinked, a file with the same inode would be inside both B1 and B2, yet the ref count could be one.