CS FundamentalsHardGATE CS (PYQ pattern)
On a Unix file system with an empty directory /tmp/x (call it X), these commands run: mkdir X/a; mkdir X/a/b; mkdir X/a/c; touch X/a/f; ln X/a/f X/a/b/g; ln -s X/a/f X/h; rm X/a/f; rmdir X/a/c. Afterwards, what is the link count of directory X/a, what is the link count of the inode that X/a/b/g names, and what does opening X/h do?
- A. 4; 1; it fails because the symbolic link dangles
- B. 3; 2; it opens the file through g
- C. 2; 1; it opens the file because the inode still exists
- D. 3; 1; it fails because the symbolic link dangles
Correct answer: D. 3; 1; it fails because the symbolic link dangles
A directory's link count = its entry in the parent + its own '.' + one '..' per subdirectory: X/a has b left after c is removed, so 3 (4 before rmdir). The file had links f and g; rm removes f, leaving 1, so the data survives through g. The symbolic link stores the path X/a/f, which no longer exists, so it dangles even though the inode lives on.
More Operating Systems questions
- A process has 4 threads on a single CPU. Each thread computes for 10 ms, makes a blocking disk read that takes 30 ms, then computes for…
- A 4-level x86-64 style page table maps 4 KB pages through all four levels, 2 MB pages with the third-level entry as the leaf and 1 GB…
- A data TLB has 64 entries and the OS backs a 1.5 GB array with 2 MB pages. A program accesses array elements uniformly at random and…
- Reference string: 8, 6, 5, 3, 3, 1, 6, 8, 2, 6, 1, 7, 3, 8, 7, 3, 3, 4, 1, 2, 3, 2, 7, 2, 5, 4, 4, 7, 2, 5. What is the smallest number of…
- SRTF with processes (arrival, burst) in ms: P1 (0, 10), P2 (1, 6), P3 (2, 3), P4 (3, 8), P5 (5, 1), P6 (6, 2). Ties go to the earlier…
- Fixed priorities H > M > L, preemptive, one CPU. L arrives at 0: computes 2 ms, locks mutex m, computes 4 ms, unlocks, computes 1 ms. M…