Unix Systems Programming: Lab 3

Due:           Wednesday, October 20, 2010 @ 5:00 pm;


PURPOSE AND RATIONALE

The purpose of this lab is to allow students to become comfortable with Unix file I/O operations, make and makefiles, and debugging.

PRIMARY RESOURCES:

FAQ (submission instructions and other useful stuff)
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. Before starting, please reviews lecture3 note carefully, for each part of lab, there is also specified reading assignment;
  3. Please pay attention to "DELIVERABLES" instruction in each part;
  4. Turn the lab assignment in by email to the grader by the due date above.
  5. Read "make and Makefile" session in Chaper 8 of BLP textbook if you're using that text.  Certainly refer to the online GNU documentation for GNU make.

LAB 3

  1. 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 (2 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

  2. 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

  3. MARKS DISTRIBUTION

    1. Excercise 1:
      • 8 points: implementation

      • 2 points: correct results after running the implementation


    2. Excercise 2:
      • 8 points: implementation

      • 2 points: correct results after running the implementation


    3. Correct Submission:
      • 3 points: correctly submitting parts 1,2
      • (Please see proper submission guidelines)
      • 2 point: code comments to show that you know what you are doing


      Total Marks: 25


    Atilla Soner Balkir