CSE 120 Winter 2002 Homework 4

Due 6 June 2002 

Problem 1

The Unix file system supports multiple names for a file, called links. According to the Unix documentation, a link is:

    ... an additional directory entry ... to a file or directory.  Any number of links can be assigned to a file.  The
    number of links does not affect other file attributes such as size, protections, data, etc.

There are two kinds of links: hard links and symbolic links. Again, according to the Unix documentation:

    A hard link (the default) is a standard directory entry just like the one made when the file was created.  ...  To
    remove a file, all hard links to it must be  removed, including  the  name by which it was first created; removing
    the last hard link releases the inode associated with the file.
    ...
    A symbolic link, made with  the -s option,  is  a  special directory entry that points to another named file. ...  In
    fact, you can create a symbolic link that points to a file that is currently absent from the file system; removing  the
    file that it points to does not affect or alter the symbolic link itself.

Why are both symbolic links and hard links useful? Give a scenario where a hard link would be used instead of a symbolic link, and a scenario where a symbolic link would be used instead of a hard link.


Problem 2

Consider a file system that uses a FAT.
  1. Explain how the FAT is modified when a block is added to the end of a file. In particular, which entries of the FAT are changed and which pages of the FAT are written to disk?
  2. Does the time and the order in which modified FAT pages are written to disk matter? In particular, consider the state of the FAT were the computer to crash at an inopportune time.

Problem 3

The shell line
echo hello > foo
creates a file foo (assuming that it doesn't exist), opens the file, writes the string "hello" to the file, and closes the file.
  1. How many file blocks are directly written as a result of this execution? Which blocks are they?
  2. What metadata is modified by the execution of this shell line?
  3. Give an instance of a reliability-induced synchronosu write that will be generated during the execution of this shell line.
  4. Explain what benefit, if any, the inode cache gives during the execution of this shell line.
  5. If you were designing a file system, you would need to decide whether the close operation would flush cached data blocks of that file. What are the benefits and drawbacks of doing so?

last edited 30 May 2002 by kam