After successfully creating a hard link called bar to the ordinary file foo, foo is deleted from the filesystem. Which of the following describes the resulting situation?



A. foo and bar would both be removed.
B. foo would be removed while bar would remain accessible.
C. foo would be removed. bar would still exist but would be unusable.
D. Both foo and bar would remain accessible.
E. The user is prompted whether bar should be removed, too.

題解

實體連結(hard link)會在目錄的block下建立一個檔名連結,來指到同樣的inode。假設原先的「foo」檔案內容存在於block的第5個位置,「foo」檔案的實體連結(hard link)「bar」檔案建立時,會在「bar」檔案所在目錄的block下建立一個「bar」的檔名連結,並且將連結指向到「foo」檔案的inode。刪除「foo」檔案時,只會移除掉「foo」檔案所在目錄的檔名連結,並不會刪除掉「foo」檔案存在於block中的檔案內容或是inode,因此使用「bar」檔案還是可以藉由連結inode來存取到原先「foo」檔案的檔案內容。所以答案是選項B。