Roger L. Kraft

59000-01 - Programming Assignment 4

This assignment has two parts. The two parts are essentially Programming Exercises 4.16 and 4.20 from the end of Chapter 4 in the textbook (page 138). Please download this zip file. Be sure to review the homework grading criteria. This assignment is due Thursday, March 19.

Part 1: Do a slightly modified version of Programming Exercise 4.20 on page 138 of the textbook. Write a program called ls5.c that adds the -i option to your ls4.c program from Part 2 of Assignment 3. The syntax of your new command should be

        ls5 [-i] [-R] [DIRECTORY]...

Your are still implementing the "long" listing format. If there are no DIRECTORY arguments, your program should default to the current working directory. Let command-line options be used in any order and also let them be combined. So if your program is invoked with the command ls5 -iR (or with ls5 -Ri), then it should do a recursive directory listing of the current directory showing inode values. Here is the full syntax of your command.

        ls5 [-i | -R | -i -R | -R -i | -iR | -Ri] [DIRECTORY]...

In a Linux man page, this would be denoted this way.

    NAME

       ls5 - limited implementation of list directory contents

    SYNOPSIS

        ls5 [OPTION]... [DIRECTORY]...


    DESCRIPTION

        -i
           print the index number of each file

        -R
           list subdirectories recursively

Part 2: Do a slightly modified version of Programming Exercise 4.16 on page 138. Write a program mv.c that implements a simplified version of the mv command. The syntax of your command should be

        mv [-n] SOURCE    DEST
        mv [-n] SOURCE... DIRECTORY

Your program should move SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY. The -n option should implement "no-clobber".

Write a Makefile that builds your ls5.c and mv.c programs. 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 CS59000Hw4Surname.zip (where Surname is your last name) containing your C programs ls5.c and mv.c and your make file Makefile.

This assignment is due Thursday, March 19.