| |
07-03-2009
|
#1 (permalink)
| | Linux User
Join Date: Mar 2009 Location: Mumbai, India
Posts: 493
| creating hard link to directory I have heard that creating hard link to a directory is not possible however when reading the man page of "ln" the "-d/-f" option says hard link directories ( super-user only). Thus this mean the super user i.e root can create hard link to directory and not a normal user , If yes then you . Even on specifying the above options I get a operation not permitted for a super user.
__________________
Only if I could understand the man pages 
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu
|
|
|
07-03-2009
|
#2 (permalink)
| | Linux Guru
Join Date: Apr 2009 Location: I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
Posts: 2,540
| You can only hard link files (and I would assume this also goes for directories) if the source and target are on the same file system. You cannot hard link a file on one device to a directory on another device or partition (different file system).
__________________
Sometimes, real fast is almost as good as real time.
|
| |
07-03-2009
|
#3 (permalink)
| | Linux User
Join Date: Jan 2007 Location: cleveland
Posts: 367
| from "man ln"
"-d, -F, --directory
allow the superuser to attempt to hard link directories (note: will
probably fail due to system restrictions, even for the superuser)"
__________________
the sun is new every day (heraclitus)
|
| |
07-03-2009
|
#4 (permalink)
| | Linux User
Join Date: Mar 2009 Location: Mumbai, India
Posts: 493
| hey thanks for replying
Rubberman have you tried making directory hard link ??? Quote:
Originally Posted by tpl from "man ln"
"-d, -F, --directory
allow the superuser to attempt to hard link directories (note: will
probably fail due to system restrictions, even for the superuser)" | Which distro are u using . I m using RHEL 4
__________________
Only if I could understand the man pages 
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu
|
| |
07-03-2009
|
#5 (permalink)
| | Linux Engineer
Join Date: Mar 2007 Location: The Netherlands
Posts: 826
| Quote: |
Originally Posted by vickey_20 Rubberman have you tried making directory hard link ??? | I may not be Rubberman, but I've tried it.
It cannot be done
But soft links work perfectly well.
__________________
Can't tell an OS by it's GUI
|
| |
07-03-2009
|
#6 (permalink)
| | Linux User
Join Date: Mar 2009 Location: Mumbai, India
Posts: 493
| but if it can't be done then why is there an intimation for the same in the man pages.
__________________
Only if I could understand the man pages 
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu
|
| |
07-03-2009
|
#7 (permalink)
| | Linux Engineer
Join Date: Mar 2007 Location: The Netherlands
Posts: 826
| Quote: |
Originally Posted by vickey_20 but if it can't be done then why is there an intimation for the same in the man pages. | Indicating that it will probably fail, even for root. Quote: |
Originally Posted by wikipedia Most modern operating systems don't allow hard links on directories to prevent endless recursion. A notable exception to this is Mac OS X v10.5 (Leopard). Symbolic links and NTFS junction points are generally used instead for this purpose.( source) |
__________________
Can't tell an OS by it's GUI
|
| |
07-03-2009
|
#8 (permalink)
| | Linux User
Join Date: Mar 2009 Location: Mumbai, India
Posts: 493
| ok got your point but it is not supposed to be there then why the heck is it metioned in the man pages in the first place. Are there any distribution of linux which support it , otherwise the presence of -d/f option doesn't make sense .
__________________
Only if I could understand the man pages 
Registered Linux user #492640
OS: RHEL4,5 ,RH 9,Ubuntu
|
| |
07-03-2009
|
#9 (permalink)
| | Linux Engineer
Join Date: Nov 2007 Location: Córdoba (Spain)
Posts: 1,495
| Well, I am not a master on fs's but...
First thing to note is that linux != ln, even more, ln is not part of linux.
The GNU tools might run in a different number of operating systems with a variety of kernels. This depends on many things, but mainly the game is between the kernel and the file system driver (for whatever fs you are using). So, that "ln" of "df" can do it, doesn't mean that "linux" necessarily support that feature. And even if that was possible in linux, it doesn't mean that your file system will support it at all (just like vfat doesn't support linux/unix permissions).
There are some interesting readings about this around: The Answer Gang 93: hard links hard links to directories [LWN.net]
The main problem with hardlinking directories is that when you make a hard link, there's no difference between the names of a given file or directory. And the file remains accessible until you delete the last one (unlike with symbolic links). This can confuse the programs that walk recursively the directory tree, who knows where our rm -rf could end. Unlike with symlinks, you don't have to deference anything, virtually, the directory is just there like if you created it with mkdir, and whatever hangs inside it will be recursed as well.
Symbolic links on the contrary are easily identifiable and avoidable to deference when needed.
You see that on the man page because simply no one has ever forbidden that, and posix don't say anything against that either. But I know of no OS/fs that actually implemented the feature (that doesn't mean it doesn't exist, maybe it does). It just means that the linux kernel and native fs's do not support it.
Any distro supporting this, if there's any at all, will have a patched kernel for sure. AND -more importantly- don't expect that a standard linux fs created with such a distro (if it exists at all) will be mountable/readable/portable to other -standard- linux OSes. At least not without a previoius fsck. |
| |
07-04-2009
|
#10 (permalink)
| | Linux Guru
Join Date: Apr 2009 Location: I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
Posts: 2,540
| Well, I tried it on my CentOS 5.3 and it fails with the error message "Operation not permitted". There may be linux versions that allow it, and it might be a factor of the file system in question. Don't know. Not sure I care.
So, why do you want a hard link to a directory?
__________________
Sometimes, real fast is almost as good as real time.
|
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |