Tutorial Week 6

Questions

Files and file systems


Q1: Consider a file currently consisting of 100 records of 400 bytes. The filesystem uses fixed blocking, i.e. one 400 byte record is stored per 512 byte block. Assume that the file control block (and the index block, in the case of indexed allocation) is already in memory. Calculate how many disk I/O operations are required for contiguous, linked, and indexed (single-level) allocation strategies, if, for one record, the following conditions hold. In the contiguous-allocation case, assume that there is no room to grow at the beginning, but there is room to grow at the end of the file. Assume that the record information to be added is stored in memory.

  1. The record is added at the beginning.
  2. The record is added in the middle.
  3. The record is added at the end.
  4. The record is removed from the beginning.
  5. The record is removed from the middle.
  6. The record is removed from the end.


Q2: Old versions of UNIX allowed you to write to directories. Newer ones do not even allow the superuser to write to them? Why? Note that many unices allow you read directories.


Q3: What permissions would you have on the following files:

om:[/tmp]% ls -ld t* .
drwxrwxrwt    6 root     root         4096 May 21 12:19 .
-rw-rw----    1 nash     stud          216 May 18 18:59 t1
-rw--w----    1 nash     stud          260 May 18 18:59 t2
-rw-------    1 nash     stud          458 May 18 18:59 t3
-rwsrwsr-x    1 nash     stud          138 May 21 12:19 t4
-rwsrwxr-x    1 nash     stud          285 May 21 12:19 t5


Q4: Why is there VFS Layer in Unix?


Q5: How does choice of block size affect file system performance. You should consider both sequential and random access.


Q6: Why does Linux pre-allocate up to 8 blocks on a write to a file.


Q7: Linux uses a buffer cache to improve performance. What is the drawback of such a cache? In what scenario is it problematic? What alternative would be more appropriate where a buffer cache is inappropriate?