CSE271 Lab 9: Files and Directories (ls and touch)

Announcements

Collaborative Programming

touch

Writing ls

Task 2: Now that touch is complete, let's revisit ls and implement a simple version. You might review the notes from Monday, but in the end, we want to implement something like:

main()
    opendir()
    while ( readdir() )
       print d_name

    closedir()
    return 0
This version would only print out the names of files (e.g., as ls does, and not anything further).

Extending ls

Task 3: Now we can extend ls to work like ls -l works. A (working) version of ls is here (in case you have questions about task 2). This lab will help walk you through the necessary steps to extend it. Our goal, at the end, is to have an equivalent to ls -l.

How do we add -l to our ls?

How does stat() work?

How well should your ls -l work?

Where are type and permissions stored?

Bits and subfields

UIDs and GIDs

Converting UIDs


Last revised: 18 March 2009, Prof. Davison.