Sample Homework Assignment

  1. (60 points) Extend the Linux kernel with a file snapshot facility using copy-on-write using VirtualPC. Instead of a commercial snapshot facility, where user files are automatically copied on a fixed schedule (say hourly), we want to use a copy-on-write semantics to keep an automatic backup of recently modified files. The idea is simple: When a write operation to a file is performed, a copy of the files (without the write modification) is created with a unique name. Of course, if a copy was created for each write, we soon would run out of disk space.
    A first refinement is modeled after the periodic snapshot facility. Snapshots are kept for 1, 2 and 4 hours, 1, 2 and 4 days, 1, 2 and 4 weeks. On the first write to an existing file, a copy of its old content becomes the 1 hour snapshot. Consecutive writes during the next 59 minutes do not result in a copy-on-write. If, after 60 or minutes (but less than 120 minutes), another write occurs, the 1 hour snapshot is promoted to be the 2 hour snapshot, and the new 1 hour snapshot becomes the copy-on-write before the current change takes effect. And so on. (Notice that, in the absence of a second write, the first snapshot may remain in the 1 hour slot. This is intentional to simplify the problem.)
    Specifically, snapshots should be created only for user directories (identified by a path name with a leading "/home/" string) and are put in directories
    $home/.snapshot/hour.1
    $home/.snapshot/hour.2
    $home/.snapshot/hour.4
    $home/.snapshot/day.1
    etc.
    
    No snapshots are generated for the .snapshot subdirectory. (Why?) Snapshots are put under the same relative paths into the proper directory, e.g.
    $home/.snapshot/hour.1/Mail/inbox
    
    is a snapshot of the file
    $home/Mail/inbox
    
    where $home may be /home/guest for a guest account.
    The assignment contains two parts. The first part is a simulation environment, which helps to identify problems without having to deal with the Linux kernel. The second part integrates the first part into the Linux kernel.