Mac File System - Knows Where Moved Files Are?

0

1

Maybe it's just me, but it seems like Mac OS knows where a file is even when it's moved. Does anybody know why this is?

Brett

Posted 2011-04-08T15:26:32.913

Reputation: 876

2Of course it does. You use Mac OS to move the file, after all. :) – user1686 – 2011-04-08T15:38:53.607

1

There are several ways to interpret this question. My answer to a question on Unix.SE is responsive to one of them, as it discusses the internals of traditional unix filesystems (which---tobylane notes below---HFS+ shares).

– dmckee --- ex-moderator kitten – 2011-04-08T17:13:11.957

Answers

5

In addition to the file's path, Mac OS aliases record several pieces of additional information: the file's unique ID, its parent directory ID, file size, [possibly creation time]; which are used to locate the most probable match in case of a broken link. I think most of the time a file is found by its unique ID, which does not change after a rename.

See also Alias (Mac OS) on Wikipedia.

user1686

Posted 2011-04-08T15:26:32.913

Reputation: 283 655

By the way, Windows is able to fix broken shortcuts in a very similar way (using an unique ID first, the file's timestamps and size if the ID lookup fails). – user1686 – 2011-04-08T15:43:50.407

5

The Mac file system is called HFS+. It uses inode numbers in a B-tree, with the physical and logical location (three parts in total). Metadata is in another b-tree, along with the data-forks.

So it knows what to expect in a place, knows of another way to refer to it, looks that up and there you go. It's like if someone moved house, you still have their mobile phone number to call.

tobylane

Posted 2011-04-08T15:26:32.913

Reputation: 1 271