The link system call in UNIX is called link (sfname tfname) :
Which of the following statements are true ?
(1) sfname and tfname have the same inode after the call.
(2) sfname and tfname have the same directory entry after the call.
(3) sfname is an existing file before the call.
(4) tfname is an existing file before the call.
MH SET - 2018, SET Exam - 2018,
Answer: A
The true statements are (1) and (3).
link(sfname, tfname) creates a new directory entry, tfname, pointing to the same inode as the existing file sfname, and increments the inode's link count. So after the call both names refer to the same inode (1), and sfname must already exist before the call (3).
Statement (2) is false: the call creates a second, separate directory entry, so the two names have different directory entries that share one inode. Statement (4) is false too: if tfname already exists the call fails, so any option containing (2) or (4) is wrong.
Please log in or register to report this question.