LFCS · Question #722
Creating a hard link to an ordinary file returns an error. What could be the reason for this?
The correct answer is E. The source and the target are on different filesystems. Hard links are constrained to a single filesystem because they reference inode numbers, which are unique identifiers only within a specific filesystem partition.
Question
Options
- AThe source file is hidden.
- BThe source file is read-only.
- CThe source file is a shell script.
- DThe source file is already a hard link.
- EThe source and the target are on different filesystems.
How the community answered
(40 responses)- A3% (1)
- C3% (1)
- E95% (38)
Why each option
Hard links are constrained to a single filesystem because they reference inode numbers, which are unique identifiers only within a specific filesystem partition.
A file's hidden attribute does not prevent the creation of a hard link to it, as the link mechanism operates on the file's underlying inode.
A read-only file can still have hard links created to it, as creating a link only adds a directory entry pointing to the existing inode, without modifying the file's content or permissions.
The type of file, such as a shell script, does not impose restrictions on creating hard links to it.
A file can have multiple hard links pointing to it; being an existing hard link does not prevent the creation of additional hard links.
Hard links operate by pointing directly to a file's inode number. Since inode numbers are unique only within a single filesystem, a hard link cannot refer to an inode on a different filesystem, thus attempting to do so will result in an error.
Concept tested: Hard link limitations across filesystems
Source: https://man7.org/linux/man-pages/man2/link.2.html
Topics
Community Discussion
No community discussion yet for this question.