以前沒有仔細想過這個問題,看鳥哥的網站也沒有寫得很清楚.
不過沒關係,自己來研究!!
hard link 不能跨 file system 比較好懂,
對於目錄的限制就複雜一點!
最近終於搞懂了.
假設你在
/home/abc下面建一個目錄叫
xyz
/home/abc/xyz下又hard link 一個目錄 ghi指向 /home/abc 這個目錄
那麼你在 du /home/abc 這個目錄計算它的大小時會發生什麼事??
呵呵,無窮迴圈..
http://unix.stackexchange.com/questions/22394/why-...
不過事實上, 每個目錄都有「..」這個指向它老爸的 hard link directory.
這個目錄 「..」 的 inode和它老爸一樣,也就是你兒子等於你爸爸...= =
這是屬於特殊情況.
--------------------------------------
另外一個原因是
If hard links to directories were allowed, which one of the multiple parents should .. point to? That is one compelling reason why hardlinks to directories are not allowed.
也就是你建立一個 hard link目錄 /home/jacky/xyz_hd 指向 /home/abc/xyz
那麼 xyz 和 xyz_hd 下面的隱目錄「..」要指向誰???
這兩部份也就是維基百科講的
http://en.wikipedia.org/wiki/Hard_link#Limitations...
To prevent loops in the filesystem, and to keep the interpretation of .. (parent directory) consistent, many modern operating systems do not allow hard links to directories.
所以其實 系統是可以有 hard link directory的,也就是「.」和「..」
但是為了防止以上兩種情況,就不讓使用者自己建了.
- Apr 13 Mon 2015 13:26
Linux裡面hard link對於目錄的限制
close
全站熱搜
留言列表
發表留言