Skip to main content

Write-all with explicit partial progress

Download the lab archive. Extract c-write-contracts, read write_all.h and the README, then copy starter.c to solution.c. Use a POSIX host with C11 Clang/GCC (Linux, macOS or Linux through WSL). Implementation/evidence is 8–12 hours inside the 18–26-hour replacement package.

Contract​

Return status, accepted bytes, callback calls and error code. Positive short results advance by the actual count. -1/EINTR retries with unchanged offset; every call consumes budget. Zero progress returns STALLED. Other errors, including EAGAIN, return with the accepted prefix. No callback occurs for empty valid input. Invalid arguments or an impossible returned count are rejected. Each callback request is capped at 4096 bytes; callback/data validity remain caller obligations.

The helper borrows data, context and any descriptor. It does not close or reopen a stream. The deterministic tests do not invoke network services or touch user files.

cc -std=c11 -Wall -Wextra -Wpedantic -Werror solution.c check.c -o check
./check
cc -std=c11 -g -O1 -fsanitize=address,undefined -fno-sanitize-recover=all solution.c check.c -o checked
./checked

Select one implementation and retain assertions. Compare reference.c after an independent attempt. Unsupported instrumentation is not passed; obtain a supported run before claiming that evidence.

Evidence​

Predict and retain partial-write traces, a permanent failure after a chosen byte count, repeated EINTR, zero progress and budget exhaustion. Add a new schedule and show one relevant regression failing before repair. The suite checks 6,732 length/chunk/failure/interruption combinations plus focused edge cases. A small real-pipe check verifies ordinary output and EOF with owned-end cleanup; it is not a general large-stream design.

Submit output-prefix checks, compiler/diagnostic output, a descriptor ownership diagram, recovery limitations and help/source record. Pass IO1–IO6 and reuse the packet in the semester project.