Assignment Task
Statement
Develop a few Unix systems utilities for process and filesystem management.
Objectives
Practicing Unix system calls, understanding Unix process and filesystem management
Description In this assignment, you will develop three simple Unix systems utilities (programs) for process and filesystem management: mytree.x, mytime.x, and mymtimes.x. The details of these utilities are described below:
- My tree.x: print files (and subdirectories) under a given directory in a tree-like format. Syntax: mytree.x [dir], where dir is an optional command parameter, which specifies the starting directory that the command will work on. If dir is not given, use the current working directory as the beginning directory. From the starting directory, mytree.x needs to descend to into subdirectories, if any such subdirectories exist. The output of mytree.x should be similar to that of the Unix command tree. That is, you should align the subdirectories and files based on their hierarchical positions in the filesystem. You can print the horizontal and vertical lines using concatenated "-" and "|", respectively, instead of real-lines as in the output of the Unix tree command. You do not need to sort the files and directories in the output as done in the Unix command tree. An example run of implemented mytree.x is given at the end of the assignment description.
- Mytime.x: run a command and track its running time. Syntax: mytime.x cmd [arguments], where cmd is the command to run, and the arguments are the optional command line arguments to the command cmd. The output of mytime.x should be similar to the Unix command time. At the minimum, mytime.x should report three values: 1) user CPU time; 2) system CPU time; and 3) elapsed wall-clock time for running the command cmd. There are different ways to implement this utility. As a starting point, you can read the manual pages of the Unix system calls wait, waitpid, wait3, wait4, getrusage, and times. You can assume that the "cmd" command-line argument of mytime.x is in one of the search paths included in the PATH environment variable.
- My times.x: report the hourly number of files modified in the last 24 hours. Syntax: mymtimes.x [dir], where dir is an optional command parameter, which specifies the beginning directory that mymtimes.x will work on. If dir is not given, use the current working directory. For the given beginning directory, this command will examine the last modification time of all the regular files (under the given directory and all the subdirectories, if any). It will group the files according to their last modification time into hourly time intervals in the last 24 hours, and report the number of files in each hourly time interval in the last 24 hours. An example run of mymtimes.x is provided at the end of the assignment description.
This Management has been solved by our PhD Experts at My Uni Paper.