Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I just noticed that the link between .. and the parent dir is hardlink, they have the same inode number:

starpinker@host /home/starpinker/unix $ ls -ail
8200794 drwxrwxr-x 2 starpinker starpinker 4096 Aug 23 11:22 .
1409238 drwxrwxr-x 2 starpinker starpinker 4096 Aug 23 11:22 ..

where the inode number of /home/starpinker/unix is 8200794, and the inode number of /home/starpinker is exactly 1409238.

I have a question on this:

The hardlink cannot be create across different file systems. Then what if the parent directory and child directory are in different file systems? For example in my case, if the /home/starpinker and /home/starpinker/unix are in different file system, the unix is just a mount point, then will the link between /home/starpinker/unix/.. and /home/starpinker still be hardlink?

share|improve this question
    
Apparently so, I just checked with my Windows mount point and it has a normal hard link to the Linux / which is .. for it. Don't know how that works though. If you don't get an answer here after a while, try flagging for migration to U&L. The question is on topic on both sites and is more than welcome to stay here, there are just more hard core *nix experts on U&L. –  terdon Aug 31 '13 at 13:28
    
Thanks, @terdon, Can you revise your link? I follow the U&L link, but it seems incorrect. –  StarPinkER Aug 31 '13 at 13:49
    
unix.stackexchange.com But please don't post the same question there, either flag for migration, or delete this one. Also, as I said before, you can leave it here, it is on topic and there may well be someone who can answer for you. –  terdon Aug 31 '13 at 14:01
    
ok, thanks you @terdon. –  StarPinkER Aug 31 '13 at 14:04

1 Answer 1

Why is it a hardlink? Because it points to the parent directory. What else could it be, if not a link?

For the filesystem root directory, .. is still a hardlink – but it points to the directory itself, i.e. it's equivalent to .. The kernel's VFS layer (which manages mountpoints and filesystems) handles this special case and magically resolves /home/starpinker/unix/.. to /home/starpinker without actually looking at the filesystem.

(Also, I haven't researched this, but I think some filesystems don't really keep the . and .. links on disk, but present emulated ones instead. It wouldn't surprise me if the VFS layer actually did that for all .. links, not just the special case...)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.