Introduction

In this lab, you will embark on the actual file system implementation. In particular, you will start by getting the following FUSE operations to work: Recall that yfs has the following architecture.

We provide you with skeleton code for both the yfs and extent server modules above.

The yfs module implements the core file system logic. This module runs as a single process called yfs_client that supports a mountpoint on the local host. The code skeleton for this module consists of two pieces:

The Extent server acts as a centralized storage location for all the data representing your filesystem, much like a hard disk would. In later labs, you will serve the same file system contents on multiple hosts, each running its own yfs_client. The only way they can share data is by reading and writing the extent server. The extent server code skeleton consists of two pieces:

Getting started

First, use a computer with FUSE and the FUSE libraries installed (see the Lab Overview for details). Download the lab starter files from http://www.news.cs.nyu.edu/~jinyang/fa08/labs/yfs-lab2.tgz to the YFS directory that you created during Lab 1. Make sure to copy your lock server from the previous lab into the new Lab 2 directory:
% cd ~/yfs
% wget -nc http://www.news.cs.nyu.edu/~jinyang/fa08/labs/yfs-lab2.tgz
% rsync -av l1/* l2
% tar xzvf yfs-lab2.tgz
% make
To use YFS in this lab, you'll need start the extent server and yfs_client(s). If you are using the class machines, choose a port number that other students aren't using. For example, to run the extent server on port 3772, type this:
% cd yfs/l2
% ./extent_server 3772 &

Next, start the yfs_client process using three parameters: a unique mountpoint (that other students aren't using), the port number for the extent server, and the port number for the running lock server, which is not used in this lab. The mountpoint must be an empty directory that already exists. To start the yfs_client using mountpoint ./myfs and extent_server that listens on port 3772, type this:

% cd yfs/l2
% mkdir myfs
% ./yfs_client ./myfs 3772 3762 &

We provide you with the script start.sh to automatically start extent server and yfs_client and stop.sh to kill previously started processes. Actually, start.sh starts two yfs_clients with ./yfs1 and ./yfs2 mountpoints respectively. (In this lab, you should only be concerned with one yfs_client. The next lab will use both yfs_clients.) Thus, instead of typing in commands manually as before, you can simply do:

% cd ~/lab-2
% ./start.sh
% ./test-lab-2.pl ./yfs1
% ./stop.sh

The skeleton code implements only the GETATTR and STATFS operations, and so the file system you just mounted will not be useful at all. However, once you finish this lab, you should be able to run the Lab 2 tests successfully, which tests creating empty files, looking up names in a directory, and listing directory contents. Note: testing this lab on the command line using commands like touch will not work until you implement the SETATTR operation, which is not required until the next lab. For now, you should do your testing via the creat/open, lookup, and readdir system calls in a language like Perl, or simply use the provided test script.

Your Job

Your job is to implement the LOOKUP, CREATE/MKNOD, and READDIR FUSE operations in YFS. You must store the file system's contents in the extent server, so that in future labs you can share one file system among multiple servers. For our labs, it is ok to implement a simple extent server that stores data only in memory; this means that if you restart it, all the data previously stored will be lost.

When using FUSE on Linux, as in the official class programming environment (see here), files are created via the MKNOD operation. On other operating systems, FUSE uses the CREATE operation. You are encouraged, but not required, to structure your code such that either operation will work. However, we will only be testing your code on Linux, which means the MKNOD operation must work. Please note that under Linux kernel 2.6.15 and newer, (such as on the class machines) if both MKNOD and CREATE are implemented and passed as pointers to the fuseserver_oper structure, then CREATE will be used by FUSE. (So, if you pass a pointer to a CREATE hook, make sure it is implemented and works well.)

As before, if your server passes our tester on the official class programming environment, you are done. If you have questions about whether you have to implement specific pieces of file system functionality, then you should be guided by the tester: if you can pass the tests without implementing something, then you do not have to implement it. For example, you don't need to implement the exclusive create semantics of the CREATE/MKNOD operation. You may modify or add any files you like, other than the tester script and the rpc library.

Lab2 tester is the test-lab-2.pl script. Run it with your YFS mountpoint as the argument. Here's what a successful run of test-lab-2.pl looks like:

% ./test-lab-2.pl ./yfs1
create file-yyuvjztagkprvmxjnzrbczmvmfhtyxhwloulhggy-18674-0
create file-hcmaxnljdgbpirprwtuxobeforippbndpjtcxywf-18674-1
...
Passed all tests!
The tester creates lots of files with names like file-XXX-YYY-Z and checks that they appear in directory listings.

If test-lab-2.pl exits without printing "Passed all tests!", then it thinks something is wrong with your file server. For example, if you run test-lab-2.pl on the skeleton code we give you, you'll probably see an error message like this:

test-lab-2: cannot create /tmp/b/file-ddscdywqxzozdoabhztxexkvpaazvtmrmmvcoayp-21501-0 : Function not implemented

This error message appears because you have not yet assigned a method to handle the CREATE/MKNOD operation with FUSE. See the main() method in fuse.cc for examples on how to make this assignment.

Detailed Guidance

Handin procedure

Tar your l2/ files with the following commands:

cd ~/yfs/l2
make clean
cd ..
tar czvf yfs-lab2.tgz l2/ 
Go to submit site to upload yfs-lab2.tgz
For questions or comments, email dss-staff@cs.nyu.edu.