.sp 0.4i .ft B .tl 'CSCI-E28'Lecture 3'Outline' \l'6.5i' .nf .in +1i .ta 1i +1.5i \fBTopics\fR: Directories, File Attributes, Bits, File Operations \fBApproach\fR: Write our own versions of Unix programs \fBFeatured Commands\fR: ls, ls -l \fBMain Ideas\fR: A directory is a list of file names File attributes can be numerical values File attributes can be yes/no settings Bitwise operations ( |, & ) \fBAgenda\fR stdio fopen/getc/putc/fclose vs open/read/write/close .sp 6p ls1 opendir(), readdir(), closedir() not sorted, and does not support -l .sp 6p file attributes owner, dates, size, type, permissions look at chmod(), chown(), chgrp(), touch .sp 6p stat1 stat() system call .sp 6p stat2 coding yes-no attributes as bits binary, octal, bit operations .sp 6p ls2 combine ls1 and stat2 still not sorted, and what about ls -l filename \fBSections\fR 0. First, one more item about buffering: * people asked after class about using open,read,write,close vs fopen, getc, putc, fclose -- what's the difference? * Answer - the standard library adds buffering a FILE points to a struct containing a (a) ptr to a buffer, (b) some pointers to keep track of where we are, (c) file descriptor, (d) type of open(read/write/both) .sp 4p Thus, getc or fgets do what our utmplib do. The include file line 271 has the def 1. files have content AND properties 2. Using ls 3. A brief review of the Unix directory tree 4. Is this just like who? open, read, show, close 5. What is a directory? 6. Reading a directory 7. How close are we to a complete version of ls? 8. How do we add the -l option? 9. How does stat() work? 10. What info do we need from what stat tells us? 11. How do we decode the type and file permissions? 12. How do we convert uid to logname? 13. How do we convert gid to group? 14. Building stat2.c : format info just like ls -l 15. Can we combine stat2.c with ls1.c ?