File Copy Project

The Project

Write a C program to copy one file to another using C system calls. Assume that the input file is named test and the output file is named test.out. Your program should be able to copy files of any size, even those larger than computer memory. The only limit should be the disk space available on the system. Your program should use an internal buffer of size 2048 bytes. The project is just an exercise to familiarize you with developing programs in a Linux environment.

How do I get started?

The project is just about done for you. All you have to do is modify the program rw.c so it copies entire files instead of the first 10 bytes of a file. The program rw.c can be found under the computer codes on the OS course home page. The current version of rw.c requires that an empty file called test.out exist before the program is run. If test.out does not exist, you can create the file with the command touch test.out

Enhancing the Program

The program you are to write is a crude version of the cp command. If you want, extend your program so it looks more like the cp command. For example, modify the program so it can copy any given file to a named output file. Your program might be invoked as follows: rw {input file} {output file} where input file specifies the source file and ouput file specifies the name of the file to be written. The program should be able to create the output file if it does not exist.

What do I hand in?

(1) You must hand in a hard copy of the source code with your name in a comment on the first line. Please do not hand in any output. You can print your program in the Distributed Computing Lab (4301) with the command mpage -2 -f -P rw.c

(2) Leave a copy of your program in your directory in a file named rw.c The rw.c in your directory should be the same as the hard copy version that you hand in.

When is the project due?

The project is due Thursday, October 10. Projects will not be accepted after the due date.