CSE120, Fall 2005, Homework 4 Due: November 29, in class 1. [McKusick] [10 pts] Describe three benefits that NFS derives from being stateless. 2. [10 pts] Many Unix systems allow a filesystem to be mounted 'noatime'. Without this option (when 'noatime' isn't set), the filesystem updates the access time field for each file when it is accessed. Why might 'noatime' be useful - what's wrong with updating access times? 3. [Silberschatz] [10 pts] In what situations would using memory as a RAM disk be more useful than using it as a disk cache? 4. [McKusick] [10 pts] What is the difference between a logical block and a physical block? Why is this distinction important? 5. [McKusick] [15 pts] How can hard links be used to gain access to files that could not be accessed if a symbolic link were used instead? 6. [15 pts] It's often the case that we want only one copy of a server process running at a time. Suppose there is a server program, 'serverd', which, upon startup, has to check that there are no other 'serverd' instances running. To aid in this, we can use the Unix system call flock(), which allows the locking of a file (and allows exclusive locking via the LOCK_EX flag). Write pseudocode for 'serverd' that makes the appropriate system calls upon startup to ensure that only one 'serverd' instance is running at a time. (Suggestion: See the Unix manual pages for open() and flock().) 7. [15 pts] Devise a method to estimate the average seek latency of the disk using only unprivileged (non-superuser) user-space system calls on a Unix system. Use pseudocode if necessary. Assume that inode and block placement is random (across the disk), that the disk arm seeks at a uniform rate across the disk, and that the filesystem uses standard features such as file buffer caching. (You may ignore the fact that inner tracks hold fewer sectors than outer ones if you wish.) 8. [15 pts] Unix systems typically provide a tool, 'fsck', to check the filesystem for consistency. Suppose on a run of 'fsck' it says something like 'Inode 15563 ref count is 2, should be 1. Fix?', which indicates that inode 15563 has a real reference count of 1, but the inode says its reference count is 2. How might fsck have determined this? What sequence of events might have caused the filesystem to end up in such an inconsistent state?