Assignment 5

Read chapter 3 in Molay. Download the code from ch3.zip

  1. Modify ls2.c so that it works correctly when the name of the directory is given as a command-line argument.

  2. Modify ls2.c so it handles the suid, sgid, and sticky bits correctly. Read the man pages to make sure you handle all possible combinations.

  3. Modify ls2.c to support the -R option. This option lists the contents of a directory and all directories below it. See printdir.c for an example of recursive directory scan.

  4. Modify your ls program to compute the sum of the sizes of all the files in the current directory and then the total sum for all directories below it.

  5. Write a program to list only the files modified within the last n days. For example, if your program were called recent, you might use the command
        recent -10 ~
    
    to show the files in your home directory modified in the last 10 days.

  6. Write a filter program that reads a Quartus vector table file and outputs only time values corresponding to positive clock edges. You can specify a starting time and clock period (e.g. 30 ns start and 40 ns period). (see jsim1 project).

  7. Substitute the following code into QtHello2.cpp.
    void MyWidget::paintEvent( QPaintEvent *)
    {
    	QString s;
    	s.sprintf("Window Size\n(%d x %d)",width(),height());
    	QPainter p( this );
    	p.drawText(rect(),AlignCenter,s);
    }
    
    Note that the QString class has a member function that acts like sprintf, with the output going to the the QString object. The program now shows the window size and updates the value each time the screen is redrawn. Customize the program by adding your name as a third line, and show a screen shot of the result.

Reference

Bruce Molay, Understanding Unix/Linux Programming,
Pearson Prentice-Hall, 2003. ISBN 0-13-008396-8.


Maintained by John Loomis, last updated 29 Sept 2006