CS380L: Advanced Operating Systems

Lab #2

User-level file system

The goal of this assignment is to create a user-level networked file system

Download and install FUSE. Write a simple networked file system. During the mount, you should specify the remote server name. Use a different physical machine for client and server. Make sure the remote system is one to which you can ssh. Whenever you get a request for a file, copy the entire file (using scp or sftp or libssh, hence the need for ssh access) from the remote server and cache it in /tmp or /var/tmp, then service the requests locally.  Copy modified files back when the file is closed. You may use rcp or another alternative to scp for the file transfer.

Compare your file system to NFS. Design an experiment that shows the performance advantage and disadvantage of this scheme relative to NFS.   We believe that you can find some scenario where your FS is significantly faster than NFS, and some other scenario where NFS is significantly faster. Therefore, it's fine to use different setups for NFS and your FUSE fs. Your writeup should contain at least one graph, but probably more.

Explain what FUSE calls you implement, and what you do for each call

Make sure your implementation can run the following program properly.  It is most useful if foo exists.  You should write and read the same number of bytes.

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>

main() {
   int fd0 = open("foo", O_RDWR);
   int fd1 = open("foo", O_RDONLY);
   char buf[100];
   buf[0] = 9;
   buf[1] = 81;
   buf[2] = 'A';
   buf[3] = 'q';
   buf[4] = '0';
   int nb0 = write(fd0, buf, 100);
   int nb1;
   nb1 = read(fd1, buf, 100);
   assert(buf[0] == 9);
   assert(buf[1] == 81);
   assert(buf[2] == 'A');
   assert(buf[3] == 'q');
   assert(buf[4] == '0');
   printf("Wrote %d, then %d bytes\n", nb0, nb1);
   return 0;

Please report how much time you spent on the lab.


If you use ssh/scp, you probably want to put your public key in your authorized_keys file or run ssh-agent so you aren't prompted for a password on every file system transaction.

You can use stat on the server to implement getattr, but you might want to consider a helper program to simplify parsing.

Here are some links that explain FUSE and even provide sample code.

If you don't have two machines under your control, we suggest you to use 2 CS machines:

System tools

These exercises are meant to introduce you to certain system tools that you might find useful.

A) Type the following lines (including newlines).  ^D means Ctrl-D.  Please hand in the file session_record, and describe what you learned from the experience.

script session_record

strace cat - > new_file

hi mom


B) Type the following lines. What kind of devices do you see listed?   Sometimes you can use this trick to debug a lack of audio output.  One program might hold /dev/dsp open while another program tries to write to it.  DO NOT hand in the output of this command.

lsof | grep /dev

C) Use ifconfig to figure out the name of the interface your machine is using to communicate externally (from now on this interface will be referred to as <eth0>).

Use tcpdump to start recording packets on <eth0> and write them to a file (<packetfile>).

Next execute sudo dhclient -r to release your machine's current DHCP lease.

Then use sudo dhclient <eth0>, and once this command completes stop recording packets. (You can repeat the process of releasing and reacquiring an address a few times if you would like.)

Next use tcpdump to inspect the packets you have recorded in <packetfile> (if you have trouble recording the packets from your system we have also provided this file: tcpdump.out) and answer the following questions:

Are DHCP messages sent over UDP or TCP?

What is the link-layer (e.g., Ethernet) address of your host? (Feel free to obscure the last couple bytes for privacy's sake)

What is the IP address of your DHCP server?

What is the purpose of the DHCP release message? Does the DHCP server issue an acknowledgment of receipt of the client's DHCP request? What would happen if the client's DHCP release message is lost?

NOTE: Some material in part C of this lab was borrowed from "Computer Networking: A Top Down Approach" by Ross and Kurose.

Your code is subject to visual inspection and should be clean and readable. Points will be deducted if your code is too hard to follow. Your code should follow best practices, for example avoiding arbitrary constants and checking error codes.