You are expected to write a simple networked file system. The networked file system has a file server
and a file client. The file client and file server can run on different machines. The actual storage
performed at the file server. The file client connects to the file server and provides access to the storage
that is managed by the file server. The file client should be able to connect to multiple (more than one)
file servers simultaneously.
The file server is a combination of a TCP server and a file system. The file system is very much like the system developed in PA#2 (code for this section will be provided). You may modify certain function call patterns to facilitate the TCP server interfacing. The TCP server can be single-threaded version. The single-threaded TCP server has several limitations but it is acceptable for this assignment.
In the above configuration, the file server is started first. The file server uses the mksfs() from the
previous assignment to create a file system. It should be noted that mksfs() supports two modes. First, where the file system is created from scratch and second where an existing file system is opened. These two modes should be supported by the file [url removed, login to view] file client should support the following functions in the form of a C application programming interface.
void mount(char *filesys, char *host, int port)
// mounts the remote filesystem at filesys
void nfs_ls(char *filesys) // lists the files in the filesys
int nfs_fopen(char *filesys, char *name)
// opens the given file in the given filesystem
void nfs_fclose(int fileID) // closes the given file
void nfs_fwrite(int fileID,
char *buf, int length) // write buf characters into disk
void nfs_fread(int fileID,
char *buf, int length) // read characters from disk into buf
int nfs_remove(char *filesys, char *file)
The mount(char *filesys, char *host, int port) function connects to the remote file
server running on host at the given port number. It will mount the remote file system under the root
directory filesys. Let me explain what is meant by mount a bit. The file client does not have any
storage. When you execute the mount function, it connects to the remote file server (creates a TCP
connection). This connection is associated with a root directory. If any open or subsequent read/write
execute under this root directory, the commands are sent to the corresponding remote file server. The file
client does not do much except maintain the root directory to remote file server mapping. It sends all the
command requests to the remote file server and receives the replies and prints them as they are received.
By mapping one remote server to a root directory, a file client can connect to multiple remote file servers.
The nfs_ls(char *filesys) function lists the directory in the remote file server. The filesys
parameter is used to determine the remote file server that should be contacted. This function should work
independent of whether you have opened any remote file or not. However, this function should not work
if the remote server is not mounted.
The nfs_open(char *filesys, char *name) function opens the given filename at the remote
file server that is mounted on the given root directory. The file client just contacts the remote file server
and asks it to open the file. Because subsequent read, write, and close do not specify the root directory,
the file client needs to maintain a simple file descriptor table. The nfs_open function creates a file
descriptor entry in the local table when it successfully opens the remote file. This descriptor entry in the
local table is used by the subsequent reads and writes as noted below.
The void nfs_fwrite(int fileID, char *buf, int length) function looks up the local
file descriptor table to determine the remote server to contact. Once the remote file server is known, the
request is sent to that server. The local file descriptor table does not need to deal with file pointers. These
parameters should be handled by the file server using the file system you developed for PA#2.
The void nfs_fclose(int fileID) function closes the file. First it should ask the remote file
server to close the file. After it get the acknowledgement from the remote file server that the file has been
closed, it should remove the local file descriptor entry. The mount is unaffected by this operation it just
closes the open files.
The void nfs_remove(char *filesys, char *name) function removes the file in the remote
file server. It should check whether the given file is already opened by the program. If the file is already
open the remove request should fail.
2. Implementation strategy
First write a TCP client and server and debug it. Follow the class notes to see how a TCP client and
server can be developed. Once the TCP client and server are working, integrate the file system
components at the server and client.
You need to modify the file system tester to work with the networked file system. Demonstrate that
your file system can mount at least two remote file systems at the same time.
Được trao cho:
I have a vast experience writting network applications, keeping in mind my existing commitments, I will be able to write this for you in 4 or 5 days, for safe side expect it in 10 days.