Unix Systems Programming: Lab 3

Due:           Ex1,2,3: Monday, October 27 @ 5:00 pm; Ex4 (Signal Handling) Friday, October 31 @ 5:00 pm.  Note that you have two weeks to do this lab.


PURPOSE AND RATIONALE

The purpose of this lab is to allow students to become comfortable with C compilation, static and shared libraries, Unix file I/O operations, make and makefiles, debugging, processes and signals.

PRIMARY RESOURCES:

FAQ (submission instructions and other useful stuffs)
You should refer to the required reading sections of the assigned texts in order to accomplish this lab.

If possible, you should ssh into the cluster to perform all lab activities. 

README

  1. If you are not in our course email list, please subscribe to the cspp51081 email list here: http://mailman.cs.uchicago.edu/mailman/listinfo/cspp51081 ;
  2. Although there are two weeks for this lab, please start this lab as earlier as possible;
  3. Before starting, please reviews lecture3 note and lecture4 note carefully, for each part of lab, there is also specified reading assignment;
  4. Please pay attention to "DELIVERABLES" instruction in each part;
  5. Turn the lab assignment in by email to the grader by the due date above.

LAB 3

  1. Build Static and Shared Libraries using a Makefile

    DELIVERABLES: see the submission faq

  2. Implement the stat command in C. Write a C program called my_stat that implements the default behavior of the UNIX stat command.  Your output should exactly match the default output of the stat command.  For instance:

    File: "/usr/bin/stat"
    Size: 7212          Blocks: 16         IO Block: 4096   Regular File
    Device: 303h/771d    Inode: 311082      Links: 1   
    Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
    Access: Wed Jul 10 23:00:30 2002
    Modify: Wed Aug  8 10:49:41 2001
    Change: Thu Apr  4 12:34:28 2002

    Hint: "man stat" and "man 2 stat".  Again, the output of your stat program with the option should match the output of the original stat program.  For those of you using Molay's text, you will find his discussion on the stat call on pages 82ff quite helpful in using the stat call and formatting the output correctly.

    For extra credit (5 points): Implement handling of any one of the following two flags:
    -L (follow Links)
    -c --format (implement a subset of 5 of the formatting options (your choice which 5))

    DELIVERABLES: your source file(s) (e.g., my_stat.c), a makefile, and a README as described in the submission faq

  3. Implement a simplified version of the UNIX program "cp" , which copies one file to another. Call the file filecopy.c.  This version copies only files, it does not permit the second argument to be a directory. We also ignore all options in command "filecopy".

    Please follow these steps:

    DELIVERABLES: your source file(s) (e.g., filecopy.c), a makefile, and a README as described in the submission faq

  4. Signal Handling

    Write a signal handler that catches the CTRL-C (SIGINT signal 2) and SIGUSR1 (signal 10) signals.   Your process should not by default exit on CTRL-C back to your shell.  You may want to look on the BLP example on signals, or Chapter 6 of Molay's text if you're using that.  The following requirements apply:

    Please following these steps to finish this part smoothly:

    DELIVERABLES: your source file(s) (e.g., my_sig.c), a makefile, and a README as described in the submission faq

    MARKS DISTRIBUTION

    1. Excercise 1:
      • 10 points: implementation

      • 3 points: correct results after running the implementation


    2. Excercise 2:
      • 10 points: implementation

      • 3 points: correct results after running the implementation


    3. Excercise 3:
      • 10 points: implementation

      • 3 points: correct results after running the implementation


    4. Excercise 4:
      • 10 points: implementation

      • 3 points: correct results after running the implementation


    5. Correct Submission:

    6. Total Marks: 55


    Atilla Soner Balkir