Computer Science 432/563
Operating Systems

Spring 2016, The College of Saint Rose

Lab 6: File Systems
Due: 11:59 PM, Wednesday, April 20, 2016

In this lab, you will learn about some details of file systems beyond what we have covered in class.

You may work alone or with a partner on this lab.

Create a file in your directory for this lab in which you will answer the questions scattered throughout the lab.

Standard Unix File Protection

Unix is a multi-user operating system, and you must authenticate to indicate "who you are" to a Unix system. A major reason for this is to facilitate file protection. File protection allows the creator of a file to decide who should be able to view a file, modify a file, or execute a file.

We will first consider the "standard" Unix file permission scheme, then look at the more flexible permissions provided with the AFS file system, such as that used by our SoS home directories.

Unix UIDs and GIDs

The files that a user is permitted to access are determined by the user's processes' user id (UID) and group id (GID). Each user on a Unix system is assigned a unique UID, which is a number associated with the login name, and can be part of one or more groups.

You can find out which UID is associated with your shell using the id command.

Question 1: What is the output of id on the book's Linux virtual machine we used early in the semester, on mogul.strose.edu, and on ascg.strose.edu?

User/Group/Other permissions

All files in a standard Unix filesystem have an owner, which should correspond to the UID of a valid user on the system, and a group. Each file or directory has a set of permissions that specify what kinds of operations on that file or directory are permitted for the owner, i.e., a process with the same UID as the file, for the group, i.e., a process whose GID is the same as the file, and for all other processes on the system.

To see a file's permissions, we use ls -l to obtain a long-format directory listing. Here are the first few lines printed when I do this on the /home/cs432/examples directory on ascg.strose.edu:

-> ls -l
total 144
drwxr-xr-x  2 terescoj  wheel   512 Feb  3 13:04 addingone
-rw-r--r--  1 terescoj  wheel   547 Feb  3 13:04 addingone.tar.gz
drwxr-xr-x  2 terescoj  wheel   512 Mar  1 15:24 everyother
-rw-r--r--  1 terescoj  wheel   941 Mar  1 15:24 everyother.tar.gz
drwxr-xr-x  2 terescoj  wheel   512 Mar  1 15:25 exec
-rw-r--r--  1 terescoj  wheel  1776 Mar  1 15:25 exec.tar.gz

Let's dissect this output. The total line indicates how many kilobytes of disk the files use. Each subsequent line provides information about a file. The first chunk of text specifies file permissions (more on this below). Next is the number of hard links to the file, which we discussed previously. Next are is the UID and GID of the file's owner. The rest is the size of the file in bytes, the date and time that the file was last modified, and the name of the file.

The file permission string starts with a single character indicating a file type, followed by three triples. The first triple specifies permissions for the owner, the next the permissions for the members of the group, and the last the permissions for all other users.

Question 2: What is the UID and GID of the files in your home folder on the book's Linux system, on mogul.strose.edu, and on ascg.strose.edu?

Each triple indicates whether a category of processes can do each of three operations:

The file type character is - for normal files, and d for directories.

Question 3: What other file types have we seen this semester? Hint: there are at least 2 we have seen but there are several others.

Each of the three successive triples specifies the read, write, and execute permissions. The letter is present if the permission is granted, and will be a - if not:

The meaning of protection is interpreted a bit differently for directories:

Changing the file protection

Only the owner of a file or the system administrator may change a file's protection. This is done with the chmod command. To specify the protection changes, you identify the class(es) of users whose permissions you wish to change:

Next you indicate if you want to add or remove permission:

Finally, you indicate which type of permission you are adding or removing, using r, w, and x. So, if you want to change your files so that nobody else can read or execute them, you would say:

    -> chmod go-rx *

Question 4: Create a new directory in your home directory on ascg.strose.edu. What permissions does it have?

Question 5: Change the permissions so only you can read the directory. Specify the chmod command you used and show the output of ls -l after making this change. Ask a classmate to verify that he cannot cd to your directory.

Read the man page for chmod's section about specifying an absolute mode. Ignore the part about the setuid bit, the setgid bit, and the sticky bit for now (we'll talk about those in class next week).

Question 6: What absolute mode is used to specify read-write access for the owner, read-only access for group and everyone?

Question 7: What absolute mode is used to specify read-write access for the owner, no access for group and everyone?

Question 8: What absolute mode is used to specify read-only access for the owner, no access for group and everyone?

Question 9: What absolute mode is used to specify all access for the owner, read-execute access for group and everyone?

Question 10: Change the permissions back to allow everyone to be able to change into the directory you made for these questions. Now create two files in the directory. What permissions do they have?

Question 11: Change the permissions of one of the files so only you have permission to read the file. Specify the chmod command you used and show the output of ls -l after making this change. Ask a classmate to verify that he can still see the contents of the file whose permissions you did not change but cannot see the contents of the one you did change.

Question 12: Change the permissions of the directory so that no one has write premission. What happens when you try to create a file in the directory?

Question 13: Change the permissions of the directory so that no one has read permission but you have execute permission. What happens when you try to cd to the directory? What happens when you try to ls its contents? What happens when you try to view the contents of a file in the directory?

Question 14: Change the permissions of the directory so it has read and write access for you, but not execute access. What happens when you try to cd to the directory? What happens when you try to ls its contents. What happens when you try to view the contents of a file in the directory?

User file-creation masks

Read the man page for bash and search for the paragraph about the umask builtin command. Cryptic, isn't it? Let's figure out what it's all about.

Question 15: What output does the builtin command "umask" produce for you on ascg.strose.edu?

Question 16: Create a file on ascg.strose.edu. What are the file's permissions?

Question 17: Now change your user file-creation mask using the command "umask 0" and create another file. What are the file's permissions? Create a directory. What are the directory's permissions?

Question 18: Now change your user file-creation mask using the command "umask 022" and create another file. What are the file's permissions? Create a directory. What are the directory's permissions?

Question 19: Now change your user file-creation mask using the command "umask 077" and create another file. What are the file's permissions? Create a directory. What are the directory's permissions?

Question 20: Now change your user file-creation mask using the command "umask 777" and create another file. What are the file's permissions? Create a directory. What are the directory's permissions?

Question 21: Explain briefly how the umask value affects the default permissions for files and directories you create.

The Latest in Filesystems

One of the big developments in filesystems over the last several years is the development of ZFS by Sun Microsystems, now Oracle, and the subsequent release of the ZFS project as open-source software. At least one final project group will be exploring another, even more recent, file system.

Read this presentation about ZFS.

Question 22: Briefly summarize what you believe are the most interesting aspects of ZFS. (4 points)

Submission and Evaluation

This lab will be graded out of 25 points (1 point per question except the last).

By 11:59 PM, Wednesday, April 20, 2016, submit your answers to the lab questions by email to terescoj AT strose.edu.