Next week, we will descending further down the system stack and introduce system calls, which are services or operations performed by the operating system kernel on our behalf. In particular, we will explore system calls related to I/O, files, and directories and discuss how many of the utilities we use every day are implemented.
The readings for Monday, April 9 are:
$ git checkout master # Make sure we are in master branch $ git pull --rebase # Make sure we are up-to-date with GitLab $ git checkout -b reading10 # Create reading10 branch and check it out $ cd reading10 # Go into reading10 folder # Download Reading 10 Makefile $ curl -LO https://gitlab.com/nd-cse-20289-sp18/cse-20289-sp18-assignments/raw/master/reading10/Makefile # Download, build, and execute tests $ make test
Record the answers to the following Reading 10 Quiz questions in your
#!/usr/bin/env python3 import os for name in os.listdir('.'): if os.path.isfile(name): print(name, os.path.getsize(name))
This should output something like this:
$ ./walk.py walk.c 844 test_walk.sh 1297 walk 14464 Makefile 565 README.md 22 answers.json 303 walk.py 136
$ make # Build walk program gcc -g -gdwarf-2 -Wall -Werror -std=gnu99 -o walk walk.c $ ./walk # Run walk program walk.c 844 test_walk.sh 1297 walk 14464 Makefile 565 README.md 22 answers.json 303 walk.py 136 $ make clean # Cleanup rm -f walk
Your program must:
Compile with no warnings (be sure to have
-Wall in your
Not contain any memory errors (as reported by [valgrind]).
Check if system calls fail (when appropriate).
Consider using the following system calls:
opendir: To open a directory.
readdir: To read one directory entry at a time.
stat: To read a file's metadata (including file size).
closedir: To close a directory.
To submit you work, follow the same process outlined in Reading 01:
$ git checkout master # Make sure we are in master branch $ git pull --rebase # Make sure we are up-to-date with GitLab $ git checkout -b reading10 # Create reading10 branch and check it out $ cd reading10 # Go into reading10 folder $ $EDITOR answers.json # Edit your answers.json file $ ../.scripts/submit.py # Check reading10 quiz Submitting reading10 assignment ... Submitting reading10 quiz ... Q1 0.50 Q2 0.50 Q3 1.00 Score 2.00 $ git add answers.json # Add answers.json to staging area $ git commit -m "Reading 10: Quiz" # Commit work $ $EDITOR walk.c # Edit source code $ make test # Build and Run tests Testing walk ... walk (syscalls) ... Success walk (output) ... Success walk (output w/ dir) ... Success walk (valgrind) ... Success Score 2.00 $ git add Makefile # Add Makefile to staging area $ git add walk.c # Add source code to staging area $ git commit -m "Reading 10: Code" # Commit work $ git push -u origin reading10 # Push branch to GitLab