

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Ligatti; Class: Operating Systems; Subject: Computer Programming; University: University of South Florida; Term: Fall 2006;
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Objectives
File permissions consist of three octal digits in a traditional Unix-like format. The first digit grants permissions for the file’s owner (the user in whose directory the file sits), the second digit grants permissions for the file owner’s group (a set of users to which the owner belongs), and the final digit grants permissions for the universe (i.e., all users). Each digit is the sum of at most three numbers: 4, 2, and 1, which correspond to read, write, and execute permissions, respectively. For example, the file permission 751 gives the file’s owner read, write, and execute permissions (because 7 = 4 + 2 + 1), the file owner’s group read and execute permissions (because 5 = 4 + 1), and the universe execute permission (because 1 = 1). As another example, the permission 600 grants the file’s owner permission to read and write the file (because 6 = 4 + 2) but grants no other permissions. All files carry a three-digit permission, and permissions do not get associated with directories. Only the owner u of a file f, and members of u’s current group (when the group is not group zero—see below for further explanation), may change the permissions for f. Again for simplicity, we assume that all files initially have a permission of 700, user u0 is logged in, and the group number for every user is set to zero to indicate that no user is in a group. If a user’s group number is 0, that user belongs to no group; if a user’s group number is greater than 0, that user does belong to a group that may have other members. A user can belong to at most one group. Group-membership information only gets modified through the add2group API method (the source code contains further documentation). Also, group names are static; if the file system is initialized to have m+1 groups then the group names are fixed: g0, g1, ...gm. We have provided a file sfs.c , available at http://www.cse.usf.edu/~ligatti/4600-06/as3/, which contains some global variable declarations, eight unimplemented API methods, and a sample main method (we will grade using a different main method). Your task is to implement the unimplemented methods. In doing so, you should use the provided global variables and create reasonable additional global variables and data structures as needed. The file sfs.c contains further documentation explaining the existing global variables and intended API functionality. You are responsible for implementing the following SFS methods according to the documentation provided in sfs.c : int sfs_init(int us, int ds, int fs, int gs) int add2group(int group_num) int chmod(int file_num, int owner_permission, int group_permission, int universe_permission) int fopen(int file_num, int mode) int su(int user_num) int cd(int user_num, int dir_num) void pwd() void whoami()