Labs

Lab 1

Process Chains (Sec. 2.12, pp.68-70).

Lab 2

You should use system calls, e.g. stat(), described in chapter 3 as much as possible. Do not use system call "system()" as a short-cut to fork()-exec(). Only unix command allowed is "sort", i.e. do not use ls, cd, etc.

1. Write a program to change directory to a location, specified as command-line argument, then list the names of the files in alphabetical order after changing there. (Don't show a list if the directory change did not succeed:merely warn the user.) (name this program as lab2.1.c).

2. Write a program to read in a list of filenames from a file, a command-line argument, and then display which of the files are readable, writable, and/or executable, and which ones don't exist. (You can perform each test for each filename as you read them, or on the entire set of names when you've read them all. Don't forget to remove the newline at the end of each filename you read in.) (name this program as lab2.2.c)
Using C libray functions (e.g. scanf) may be simpler than using system call (e.g. read) in this step, since filenames of variable sizes.
You may extract the permission for the user and ignore the permissions for the group and others. The output format should be easy to understand.

3. Write a program to read in a list of filenames from a file, a command-line argument, and find the latest modified file among them. Print out the name of file and the age of that file in days. (name this file as lab2.3.c).
You may choose any time field, e.g. modification time, for this exercise.
 
 

Lab 3

Argument Arrays (Sec. 1.6, pp.25-26).
 

Lab 4

Parallel File Copy (Sec 9.6, pp.363-364).
 

Lab 5

Ping Server (Sec. 12.10, pp. 474-476).