C Programming
C Programming
| Attribute | Value |
|---|---|
Goal |
Read and write systems-level C — file I/O, syscalls, memory, networking |
Interest Link |
Programming > C |
Status |
Phase 1 — stdio + syscall tracing (fopen, fgetc, EOF, strace, ftrace) |
Rationale |
Required for work. Understanding syscalls, kernel interfaces, and library functions. Man pages sections 2 (syscalls) and 3 (library) become primary documentation. Bridges gap between bash/Python scripting and systems programming. |
Approach |
Man pages as curriculum. Write small programs, compile with |
Primary Resources |
Man pages (sections 2, 3), "You Suck at Programming" channel, K&R (The C Programming Language) |
Documentation |
|
Curriculum
Phase 0: Environment & Compilation
| Topic | Description | Status |
|---|---|---|
Compiler setup |
|
✅ Done (2026-04-25) |
Man pages |
|
✅ Done (2026-04-25) |
Debugging tools |
|
✅ Done (2026-04-25) |
Phase 1: stdio — The Abstraction Layer
Based on "What is Actually EOF?" transcript. The f functions: fopen, fgetc, fclose, fprintf.
| Topic | Description | Status |
|---|---|---|
Hello World |
|
✅ Done (2026-04-26) |
Types and variables |
|
✅ Done (2026-04-26) |
File I/O (stdio) |
|
✅ Done (2026-04-26) |
EOF |
|
✅ Done (2026-04-26) |
Loops |
|
✅ Done (2026-04-26) |
Error checking |
|
✅ Done (2026-04-26) |
printf formatting |
|
✅ Done (2026-04-26) |
Hex reader |
Built simplified |
✅ Done (2026-04-26) |
Syscall tracing (strace) |
|
✅ Done (2026-04-27) |
Kernel tracing (ftrace) |
|
✅ Done (2026-04-27) |
Infrastructure tracing |
|
✅ Done (2026-04-27) |
Phase 2: Syscalls — The Raw Interface
One layer below stdio. open(), read(), close() — no buffering, no EOF constant.
| Topic | Description | Status |
|---|---|---|
File descriptors |
|
❌ Not started |
open / read / close |
|
❌ Not started |
Buffers |
|
❌ Not started |
EOF at syscall level |
No |
❌ Not started |
ssize_t |
Signed size type. |
❌ Not started |
Standard input |
File descriptor 0. No need to |
❌ Not started |
Ctrl+D |
Terminal flushes empty buffer → program reads 0 bytes → interprets as EOF. Ctrl+D doesn’t "send EOF." |
❌ Not started |
Phase 3: Headers & the Preprocessor
| Topic | Description | Status |
|---|---|---|
#include |
|
❌ Not started |
#define |
|
❌ Not started |
Header discovery |
|
❌ Not started |
Phase 4: Memory & Pointers
| Topic | Description | Status |
|---|---|---|
Pointers |
|
❌ Not started |
Arrays and buffers |
|
❌ Not started |
malloc / free |
Heap allocation. When stack isn’t enough. Memory leaks. |
❌ Not started |
Strings |
Null-terminated |
❌ Not started |
Phase 5: Networking (Work Application)
| Topic | Description | Status |
|---|---|---|
Sockets |
|
❌ Not started |
TCP client |
Connect to a server, send/receive data. RADIUS, syslog, REST — all TCP underneath. |
❌ Not started |
Structs |
|
❌ Not started |
select / poll / epoll |
Multiplexing I/O — handling multiple connections. How nginx/ISE work internally. |
❌ Not started |
Phase 6: Build Systems & Real Projects
| Topic | Description | Status |
|---|---|---|
Makefiles |
|
❌ Not started |
Multi-file projects |
|
❌ Not started |
Libraries |
Static ( |
❌ Not started |
Reading source |
Read coreutils source ( |
❌ Not started |
Phase 7: Bitwise Operations & Data Representation
The language of hardware, protocols, and kernel registers.
| Topic | Description | Status |
|---|---|---|
Bitwise operators |
|
❌ Not started |
Bit masks |
Extract fields from packed values. VLAN ID from 802.1Q tag ( |
❌ Not started |
Byte order |
Big-endian (network) vs little-endian (x86). |
❌ Not started |
Packed structs |
|
❌ Not started |
Hex arithmetic |
Add, subtract, AND/OR in hex. Subnet calculations in C. |
❌ Not started |
volatile |
Tells compiler "this value changes outside my code." Required for hardware registers, memory-mapped I/O, signal handlers. |
❌ Not started |
Phase 8: Raw Networking — Protocol Construction
Build the protocols you operate. Same packets your switches and ISE process.
| Topic | Description | Status |
|---|---|---|
Raw sockets |
|
❌ Not started |
Ethernet frame |
Build an Ethernet header in C: |
❌ Not started |
ARP |
Craft ARP requests/replies. Understand how switches learn MAC addresses. Build your own |
❌ Not started |
IP header |
Parse and construct IPv4 headers — version, IHL, TTL, protocol, checksum. |
❌ Not started |
TCP/UDP headers |
Parse transport headers. Understand port numbers as 2-byte fields. TCP flags as bitmask ( |
❌ Not started |
ICMP |
Build a ping program in raw C. ICMP echo request/reply. Checksum calculation. This is what |
❌ Not started |
Pcap parsing |
Read |
❌ Not started |
802.1Q VLAN tagging |
Parse and insert VLAN tags in Ethernet frames. 4-byte tag: TPID ( |
❌ Not started |
802.1X / EAP |
Parse EAP frames — EAPoL header, EAP packet structure. Understand what ISE receives when your workstation authenticates. |
❌ Not started |
Phase 9: Kernel Interfaces & Systems Programming
Talk to the kernel directly. Understand the systems you trace with ftrace.
| Topic | Description | Status |
|---|---|---|
Netlink sockets |
|
❌ Not started |
MAC table (FDB) |
Read the kernel’s forwarding database via netlink. |
❌ Not started |
ioctl |
|
❌ Not started |
/proc and /sys |
Read kernel state from C: |
❌ Not started |
Signal handling |
|
❌ Not started |
Process management |
|
❌ Not started |
mmap |
Memory-mapped files and shared memory. |
❌ Not started |
epoll (event-driven I/O) |
|
❌ Not started |
ftrace from C |
Read and write |
❌ Not started |
eBPF (intro) |
Write C programs that run inside the kernel. Packet filtering, tracing, security enforcement at wire speed. The future of AppArmor, firewalling, and observability. |
❌ Not started |
Phase 10: Security in C
Write secure code. Break insecure code. Understand what AppArmor protects against.
| Topic | Description | Status |
|---|---|---|
Buffer overflows |
Stack smashing, |
❌ Not started |
Format string attacks |
|
❌ Not started |
Integer overflows |
Signed/unsigned confusion. |
❌ Not started |
ASLR and PIE |
Address Space Layout Randomization. Position-Independent Executables. |
❌ Not started |
seccomp |
Restrict which syscalls a process can make. Write a seccomp filter in C. This is how Docker and Chrome sandbox processes. Complements AppArmor. |
❌ Not started |
Capabilities |
|
❌ Not started |
TLS in C |
OpenSSL’s C API — |
❌ Not started |
RADIUS packet |
Build a RADIUS Access-Request in C — shared secret, authenticator, AVPs. Send to ISE, parse Access-Accept. Understand every field in your MnT auth history. |
❌ Not started |
Phase 11: Embedded & Hardware (Optional Track)
Requires a microcontroller board. Different toolchain, no OS, no libc.
| Topic | Description | Status |
|---|---|---|
Cross-compilation |
|
❌ Not started |
GPIO |
Blink an LED. Read a button. Direct register manipulation — |
❌ Not started |
UART / Serial |
Send bytes between board and workstation. |
❌ Not started |
SPI / I2C |
Talk to sensors — temperature, accelerometer, OLED display. Master/slave protocols. Clock + data lines. |
❌ Not started |
Interrupts |
Hardware events trigger your C function — no polling. Timer interrupts, GPIO edge detection. How network cards signal "packet arrived." |
❌ Not started |
RTOS |
FreeRTOS task scheduling — multiple "threads" on a microcontroller with no MMU. Priority-based preemption. How IoT devices (your Philips FSE, TCP clocks) run firmware. |
❌ Not started |
Bare-metal TCP/IP |
lwIP or similar — TCP/IP stack without Linux. Understand every layer because you built it. This is how medical devices and industrial controllers network. |
❌ Not started |
| Board | Why | Cost |
|---|---|---|
Raspberry Pi Pico |
RP2040, great docs, C SDK, no Linux — true bare metal |
~$4 |
STM32 Nucleo-F446RE |
ARM Cortex-M4, industry standard, excellent HAL docs |
~$15 |
ESP32-DevKitC |
WiFi + Bluetooth, FreeRTOS built-in, IoT focus |
~$10 |
Resources
Video
-
"What is Actually EOF?" — You Suck at Programming (Dave)
-
Three abstraction layers: stdio → syscalls → bash heredocs
-
Transcript:
education/programming/c/eof-transcript.adoc -
Key insight: EOF is not a character, not a signal — it’s "read returned zero bytes"
-
Books
-
The C Programming Language (Kernighan & Ritchie, 2nd Ed.) — the original, still the best
-
C Programming: A Modern Approach (K.N. King, 2nd Ed.) — more accessible, covers C99
-
Expert C Programming: Deep C Secrets (van der Linden) — advanced, demystifies the weird parts
-
Unix Network Programming (W. Richard Stevens) — the bible for socket programming (Phase 5, 8)
-
Linux System Programming (Robert Love) — syscalls, file I/O, process management (Phase 2, 9)
-
Understanding the Linux Kernel (Bovet & Cesati) — kernel internals (Phase 9, 10)
-
Making Embedded Systems (Elecia White) — practical embedded C (Phase 11)
Man Pages (Primary Curriculum)
-
man 3 intro— introduction to library functions -
man 2 intro— introduction to system calls -
man 3 stdio— standard I/O overview -
man 3 fopen,man 3 fgetc,man 3 fclose— Phase 1 functions -
man 2 open,man 2 read,man 2 close,man 2 write— Phase 2 syscalls -
man 7 signal— signal handling concepts -
man 7 packet— raw packet sockets (Phase 8) -
man 7 netlink— kernel netlink interface (Phase 9) -
man 7 netdevice— network device ioctl (Phase 9) -
man 7 epoll— event-driven I/O (Phase 9) -
man 7 capabilities— Linux capabilities (Phase 10)
Online
-
Beej’s Guide to C Programming — excellent free guide
-
Beej’s Guide to Network Programming — C sockets (Phase 5, 8)
-
man7.org — Linux man pages online
-
Kernel documentation — ftrace, networking, eBPF
-
ftrace documentation — Rostedt’s tracing guide
-
eBPF.io — eBPF learning resources
-
Zero to Main — bare-metal ARM C from scratch
Key People
| Dennis Ritchie |
Created C and co-created Unix. K&R is his book. |
| Brian Kernighan |
Co-authored K&R. Coined "Hello, World." |
| Steven Rostedt |
Author of ftrace. Your kernel tracing infrastructure. |
| Robert Love |
Linux kernel developer, wrote the systems programming book. |
| W. Richard Stevens |
Wrote the networking bibles. Died in 1999. His books are still the standard. |
| Linus Torvalds |
Created Linux. Writes C daily. His code review emails are curriculum. |