OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:01 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Hard Link
PostPosted: Wed Aug 08, 2007 12:48 am 
Offline
Member
Member
User avatar

Joined: Thu Jun 09, 2005 11:00 pm
Posts: 69
Location: Right here
On ext file system in Linux, why can't we create hard links to directories?
What could be the reason?

thanks.

(Haven't tried with other FS or maybe it is with *NIX. No idea.)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 12:51 am 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 6:06 pm
Posts: 1437
Location: Vancouver, BC, Canada
Hard links can have multiple "parents". If you're in a hard linked directory and type "cd ..", where should the new current directory be?

_________________
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 2:31 am 
Offline
Member
Member
User avatar

Joined: Thu Jun 09, 2005 11:00 pm
Posts: 69
Location: Right here
It's clear now. Thanks. :D


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 6:08 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
Even if that "cd .." is managed (e.g. you keep the full path somewhere in the kernel), hard links to directories turn your filesystem (usually a tree) into a graph -- which may contain cycles.

/home: mkdir foo
/home/foo: ln /home bar
/home: find -type d
/home
/home/foo
/home/foo/bar
/home/foo/bar/foo
/home/foo/bar/foo/bar ...

that would break most directory-crawling software existing. Generally speaking, allowing hard links to directories while preventing cycles to appear require something looking like a mark-and-sweep garbage collector ... not the kind of thing you'll love to have in the kernel FS driver :P

(more about it in Tanenbaum books)

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 10:10 am 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 11:33 pm
Posts: 3882
Location: Eindhoven
The only requirement is to check for the entire tree link to the top of the target location whether your item is in it. If not, you're not creating a cycle.

Of course, you have to add this to the move logic too.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 10:16 pm 
Offline
Member
Member
User avatar

Joined: Thu Jun 09, 2005 11:00 pm
Posts: 69
Location: Right here
Candy wrote:
The only requirement is to check for the entire tree link to the top of the target location whether your item is in it.


Is that even deterministic?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group