LFCS · Question #866
LFCS Question #866: Real Exam Question with Answer & Explanation
The correct answer is B: foo would be removed while bar would remain accessible.. Deleting the original file that has a hard link only removes one directory entry; the data remains accessible through the hard link until all links to the inode are removed.
Question
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?
Options
- Afoo and bar would both be removed.
- Bfoo would be removed while bar would remain accessible.
- Cfoo would be removed. bar would still exist but would be unusable.
- DBoth foo and bar would remain accessible.
- EThe user is prompted whether bar should be removed, too.
Explanation
Deleting the original file that has a hard link only removes one directory entry; the data remains accessible through the hard link until all links to the inode are removed.
Common mistakes.
- A. Hard links mean multiple names point to the same data; deleting one name does not remove all other names or the data itself, unless it's the last link.
- C.
barwould remain completely usable because it is just another name referencing the identical data blocks and inode asfoodid. - D.
foois explicitly stated as deleted, meaning its directory entry is removed from the filesystem. - E. Deleting a file with existing hard links simply decrements the link count on the inode; there is no prompt to remove other links.
Concept tested. Hard link persistence after original file deletion
Reference. https://man7.org/linux/man-pages/man7/symlink.7.html
Topics
Community Discussion
No community discussion yet for this question.