0

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....)

Graza
  • 5,010
  • 6
  • 32
  • 37
  • How are you printing the inode, and is your app running 64-bit? (You can tell the latter by looking in Activity Monitor.) – Peter Hosey Aug 25 '09 at 20:29
  • @Peter: thanks for looking at this - I've updated the question to provide more details. Still can't figure out where to determine whether it's running in 64 bit mode, unless Kind:Intel provides a clue? – Graza Aug 25 '09 at 21:52
  • “Intel” is 32-bit. “Intel (64-bit)” is 64-bit. So you're displaying these numbers in your UI? – Peter Hosey Aug 25 '09 at 23:03
  • Yes, just using stock-standard Core Data Entity list-style view dropped down on the window in Interface Builder. – Graza Aug 25 '09 at 23:27

1 Answers1

1

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.

Ken
  • 12,933
  • 4
  • 29
  • 32
  • Hmm, good point - I had assumed there were no directory hard-links, but I'll check that out.... – Graza Aug 26 '09 at 07:31
  • That was it - where the number of file listings with the same inode was greater than the ref count, the number of inodes over all the folders the files were in was the same as the file inode's ref count. Thanks – Graza Aug 27 '09 at 00:41