This assignment has four parts. The four parts are Programming Exercises 3.11, 3.18, 3.13, and implementing touch
, from the end of Chapter 3 in the textbook (pages 105-106).
Please download this zip file.
Be sure to review the homework grading criteria.
This assignment is due Tuesday, March 3.
Part 1: As the book mentions on page 95, ls2 has a bug. Write a program called ls3.c
that fixes this bug. In the opening comment of your file ls3.c
, put an explanation of what caused the bug and what you did to fix it. (Don't write just two sentences. Write a detailed explanation of the bug and its solution.)
Part 2: Do a slightly modified version of Programming Exercise 3.18 on page 106 of the textbook. Modify your ls3.c
, and call it ls4.c
, so that it takes a command-line option -R
that means recursive directory listings (you are really implementing the command "ls -alR" since we are outputting directory listings in the long format).
Part 3: Do a slightly modified version of Programming Exercise 3.13 on page 106. Modify your program cp1a.c
(from Assignment 2), and call it cp2.c
, so that it implements copying files to a directory. The syntax of your command should be
cp2 [-n] SOURCE DEST cp2 [-n] SOURCE... DIRECTORY
Your program should copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY (notice that the second line is what's new).
Part 4: Write a simplified version of the touch command. The syntax for your command should be
touch FILE...
Your program should update the access and modification times of each FILE to the current time. Also, a FILE argument that does not exist is created empty. (Make sure your program fails with appropriate error messages. For example, if a user tries to touch a file that they do not have permission to modify.)
Write a Makefile
that builds your programs for the above four parts. Make sure your make file works correctly. I will compile your code using your make file. If it doesn't work, I won't be able to grade your assignment.
Turn in a zip file called CS59000Hw3Surname.zip
(where Surname
is your last name) containing your C programs ls3.c
, ls4.c
, cp2.c
, touch.c
, and your make file Makefile
.
This assignment is due Tuesday, March 3.