Assignment 3: du Extended, or dux
The existing du command gives usage information about directories, but little about their structure. It does not even use simple indentation to show the structure of the directory and its subdirectories.
Your dux command will report the number of blocks contained in all files and (recursively) directories within each directory and file specified by the directory name arguments. If no directory name arguments are given, the current directory is used.
For dux, you need only provide a subset of du's options:
dux [-ahsLit] [name ...]
-a (all) Causes an output line to be generated for each file and directory. If neither -s nor -a is specified, output is generated only for each directory. Note that -a and -s cannot both be specified in the same command.
-h (help) Produce a brief usage message for dux.
-s (summary) Causes only the total for each of the specified name arguments to be given. If neither -s nor -a is specified, an output line is generated for each directory only. Note that -a and -s cannot both be specified at once.
-L (Link) Causes dux to follow symbolic links. When -L is specified, dux reports the size of the target of the symbolic link instead of the link itself. If the symbolic link points to a directory when -L is specified, dux recursively descends the directory just as it does for normal directories.
-t (tree) Use "tree" format, as defined below.
-in (indent) Use an indent of n characters instead of the default.
In addition to supporting only du's asL options, you will add the -t (tree) option and the optional -in (indent), where n is an integer from 2 to 8 (with default value 2 if -i is omitted). For example, the command:
dux -i3t ~/cst8204
might produce output of the directory names like:
For directory /home/wxyz0001/cst8204:
8 assign1
8 assign2
24 labs
8 lab1
...
Notes:
Note that dux must accept multiple directory names in its command line arguments.
All options always precede all directory names.
The options -a and -s cannot be used on the same command.
The -in option can only be used if -t is also given.
No intermediate files may be used. All dux work must be done in memory.
You may not use the system() or popen() functions, or any equivalent.
You can create a small test structure of files and subdirectories for all testing (no more 4 levels deep and perhaps 3 across).
You must use a make file and include its listing in your submission.
Deliverables:
You will hand it in as defined in the Submission Standards and other material by 12:00 noon on Thursday, 19 March.