CMPS 105 Fall04: Systems Programming

Programming Assignment #3: Directory Copying


Remember: your programming assignment must be turned in online.


The Basics

The goal of this assignment is to get familiar with file I/O, recursive directory traversal and, of course, to gain more familiarity with systems programming, man, system calls, etc.

In this assignment, you are to implement a directory copying program. It will be called like this:

copydir foo bar

where "foo" is the name(or path) of the directory to be copied and "bar" is the name(or path) of the new directory that will be the copy of it. All the subdirectories should be recursively copied. If a symbolic link is encountered, copy it but do not follow it.


The Details

To implement your program, you will need the following system calls :creat(), open(), close(), read(), write(), opendir(), readdir(), mkdir(), chdir(), closedir(). You may not use fopen(), fclose(), etc.

Use the man pages to read up on how to use these functions. These are defined in section two of the manual, and have the same name as other commands or functions, so you should call man like this: "man -s2 open" to tell it to give you the open description from section 2.

You can use your code from assignment #2 for copying the files. Your code should be as efficient as possible.

Note: You must check and correctly handle all return values. This means that you need to read the man pages for each function to figure out what the possible return values are, what errors they indicate, and what you must do when you get that error.


What to turn in

Your code, a working makefile and your design document. In addition, include a README file to explain anything unusual to the TA — testing procedures, etc.

REMEMBER: Do not submit object files, assembler files, or executables. Every file in the submit directory that could be generated automatically by the compiler or assembler will result in a deduction from your programming assignment grade.