the most basic C program possible: main(){}
hello world
What is a system call?
Synchronously ask Linux to do something for you as a user program
Student examples: open, read, write, close
Use these with file descriptors to do file I/O without FILE *
Use man 2 xxx
to learn about system call xxx
Working with processes
Charlie demonstrated several system calls needed to complete P0
, with a focus on dealing with file descriptors
Take note that the struct stat
for a file contains a mode
field that specifies file permissions
Use the dup(2)
family to create unnamed pipes on your system
When working with C strings in the kernel, we recommend passing around a pointer and a length pair rather than relying on null-termination
While in userspace a buffer overflow is harmful, in the kernel it can be catastrophic to a system, and in a production environment, devastating to an organization
Note that file descriptors are integers that index into a table of file descriptions.
dup(2)
uses the file descriptor table to connect two file descriptors to each other.
While dup()
takes an fd to duplicate, dup2()
takes a second existing fd to overwrite as the other end of the pipe.