Sacramento State
Computer Engineering / Computer Science
CpE/CSc 159 Operating System Pragmatics (Fall 2016)

Phase 6   File System

Goals

  1. To expand and provide processes to a basic file system hosted by the OS kernel.

  2. In this phase the terminal process conducts a login dialogue and accept a few simple file-system type of shell commands:
    1. ls [path to a file or directory] - to mimic the unix command ls. If the optional path is not given, the root directory "/" is assumed.
    2. cat [directory path]filename - to mimic the unix shell command cat (concatenate). This command must be used in conjunction with a path to a file, e.g., "cat note.txt" or "cat www/hello.html." If no directory path ("www/") is given, the root directory is assumed to look for the file.
    3. logout - to logout (back to the login prompt). The password is set as "pizza." In case a terminal keyboard are missing certain keys, try to use numbers 11 for "ls," 222 for "cat," and "000000" for "logout." The files and directories are also represented by numbers. List the directory will show you their substitution numbers.

File System Service Calls

Similar to a standard file system query protocol, we will experiment four difference system calls.
  1. void Fstat(char *name, char *read_data): to query the attributes of a named object (file/directory), e.g., size, type, etc.; this syscall is used with two strings ("char" pointers) given as arguments. The first is the object name to "stat" (check) and the second will carry the information returned from the file system. The read data can be casted to an "attribute type" pointer to decipher information.
  2. int Fopen(char *name): To open the said named object for reading, this syscall is used. It returns a File Descriptor (FD) associated with the named object. A file descriptor has an I/O "buffer" assigned for sequential reading.
  3. void Fread(int FD, char *data_read): With the FD, the reading is usually conducted in a loop calling this syscall. Each successful "read" will fill the data from the file into a buffer of which the address is passed to the kernel. (This is not the same buffer the FD uses to the actual file storage.) As the EOF condition occurs, the "read" will be empty (preceeding with a null character).
  4. void Fclose(int FD): To close the file (FD), this syscall is used with the FD previously openned given as the argument.

Deliverables

    Turn your source code in on your designated folder on host Voyager as usual. Correct those places mentioned in the grading results derived from all previous phases. (Do not correct code of previous phases and resubmit. It is the new code that you are turning in that needs attention and correction!) Otherwise, deductions repeat.

Review Questions

  1. How would you incorporate device drivers of storage media to upgrade the file service to be a more realistic one?

  2. How can file services be converted into the duty of a process such as a file manager to handle? What can be the pros and cons in doing so, in terms of performance, organization, etc?