3

1st I created both hardlink (HLINK) and softlink (SLINK) to a single file (A.DAT). As I know, SLINK has its own inode, and this inode will point to the inode of A.DAT. But HLINK does not have its own inode. when we create a hardlink it will directly point to the inode of the A.DAT.

So my QS here is when we are removing Original File (A.DAT), because of the existence of a hardlink (HLINK), the inode of A.DAT still be there in memory.But why we can not access this content by the SLINK, though SLINK's inode points to the inode which is still exist in the memory, whereas HLINK can access though it is pointing to the same inode.

Please help me understand this and correct me if i am wrong..

Thanks!!

1 Answer 1

7

SLINK has its own inode, and this inode will point to the inode of A.DAT.

No, it doesn't reference the inode at all. It points to the name of A.DAT. If the name is changed, the reference breaks.

This is why symlinks can work across filesystems. The inode (or whatever data structure is used) may not be visible, but the name is.

3
  • Thanks Bowl, but if we think a bit deep, for each file UNIX creates an inode, this inode points to some physical Location of memory from where we are retrieving the contains of it. Also i read it somewhere that symlink points to the inode of the original file. Thanks...but still want some more idea about the internal working of these linking.
    – PriB
    Jan 16, 2015 at 19:35
  • 1
    The part that is wrong is that the symlink doesn't point to the original file's inode. The symlink contains data (either within the pointer section of the inode or in a separate data block) and that data is simply the path that you see in ls -l output. There is no other inode location referenced.
    – BowlOfRed
    Jan 16, 2015 at 19:37
  • Oh..Ya, that might be.. the inode may contain the data (here is the path to the file A.DAT). Thank you!!
    – PriB
    Jan 16, 2015 at 19:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .