24h購物| | PChome| 登入
2005-01-06 12:46:53| 人氣223| 回應0 | 上一篇 | 下一篇

【Linux Discussion】Soft Link V.S. Hard Link?!

推薦 0 收藏 0 轉貼0 訂閱站台

終於看到一個對於 soft link 與 hard link 比較清楚的解釋
看起來這個觀念與 pass by value V.S. pass by reference 滿像的

*****************************************************************

A soft link is a pointer to a filename, and that filename is what points to an inode which has data and various other information. Because a soft link is a pointer to a filename, it can span file systems and when you delete the filename, the soft link is broken and the data is gone.

A hard link, however, points directly to an inode, not a filename. It points to the same inode as the file you're hard linking to. In a case like that, you can delete the original file, and still access the data through the hard link because the hard link is still a pointer to that inode. Because the hard link is a pointer to the inode, you can't span file systems. That's also why often hard links are considered security risks and only root can create them. Hard links mean that someone can delete a file they're trying to get rid of, but if there's a hard link to it hidden somewhere on the filesystem that data is still accessible.

An inode will remain in tact as long as there's something referencing it. If you do 'ls -il' you'll see the inode number and its reference count. You'll note with a hard link that that inode reference count will increase by 1. It won't with a soft link.


Article Source:
http://enterprise.linux.com/comments.pl?sid=34304&op=&threshold=0&commentsort=0&mode=thread&tid=89&pid=83574

Picture Source:
My colleague from the US office

台長: 小琪
人氣(223) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 社會萬象(時事、政論、公益、八卦、社會、宗教、超自然)

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文