DOCUMENTATION / V1.0.0 LTS
Release notes — v0.1.19
Reading a file that does not fit in the buffer
v0.1.18 let a ring 3 program read a file, but only in one go. A file bigger than the buffer was refused rather than truncated, and the reasoning was recorded at the time: a fragment the caller has no way to complete is worse than an error, because it is indistinguishable from a whole file.
That reasoning was sound and it pointed at what was missing. A partial read is only a loss if nobody remembers where it stopped. This release adds the thing that remembers.
user run cat now offers an 8-byte window for a 25-byte
file:
[syscall] open path=/tmp/lu.txt fd=0 ouverts=1
[syscall] read fd=0 bytes=8 depuis=0 vers=0x8000010ff0
[user] contenu-
[syscall] read fd=0 bytes=8 depuis=8 vers=0x8000010ff0
[user] lu-depui
[syscall] read fd=0 bytes=8 depuis=16 vers=0x8000010ff0
[user] s-anneau
[syscall] read fd=0 bytes=1 depuis=24 vers=0x8000010ff0
[user] 3
[syscall] read fd=0 fin de fichier
[syscall] close fd=0
[syscall] exit code=25
The exit code is the total the program counted itself. Reaching 25 through a window of 8 is only possible if each call resumes where the previous one stopped, so the number is produced by the cursor rather than asserted about it.
One way to read a file, not two
Keeping the 0.1.18 form of read alongside the new one
would have been purely additive and would have broken nothing. It was
rejected anyway: there would then be two boundaries that both write into
user memory, both validate a destination, and both have to be kept in
step forever. read takes a descriptor. That is the only
way.
The cost is visible and was accepted: every built-in program that reads had to be rewritten, and so did the assertions that watched them.
What a descriptor is here
src/fdtable.rs holds one task's table: four descriptors,
each carrying a 64-byte path and a cursor. The module knows nothing
about user memory, page tables or the filesystem — it allocates numbers
and moves cursors. That is what makes it verifiable off-target, and it
is why the host test count moves for the first time in two releases:
250 → 265.
Two decisions inside it are worth stating.
Numbers are handed out lowest-free-first, as under Unix, so a program that closes and reopens can predict what it gets.
The cursor saturates rather than wraps. A cursor returning to zero would make a program re-read the beginning of a file while believing it was advancing. That is a wrong answer delivered silently, which is worse than a refusal.
The counter-proof: a descriptor does not outlive its task
A descriptor is meaningful only relative to the task holding it. If the table were shared, the number 0 would name the same file for everyone. It is not shared — but there are only eight scheduler slots, and a slot is reused.
user run steal opens nothing and reads descriptor 0
immediately. It must be refused. To check that the refusal is caused by
the clearing of the table and not by luck, the clearing was removed from
spawn:
user_spawn program=steal id=10
[syscall] read fd=0 bytes=8 depuis=0 vers=0x8000010ff0
[syscall] exit code=8
It read eight bytes of a file it never named, opened by the previous
occupant of its slot, and exited with 8 instead of -7. The
line was restored and the assertion now watches it.
A second counter-proof, structural
Turning saturating_add into wrapping_add
makes structural check 17 fail. The marker is not decorative.
What was measured
| Claim | Measurement |
|---|---|
| A file is read past the buffer size | bytes=1 depuis=24 after three 8-byte reads,
exit code=25 |
| End of file is a value, not an error | [syscall] read fd=0 fin de fichier, return 0 |
| A destination still needs the W bit | read refuse: destination non inscriptible,
exit code=-2, page_fault_fatal=0 |
| A descriptor belongs to one task | read refuse: descripteur inconnu fd=0,
exit code=-7 |
| A missing path is refused at its own level | open refuse: chemin introuvable,
exit code=-5 |
| Nothing is inherited from a previous task | Without the clearing: bytes=8,
exit code=8 |
Ratchets: ring 3 assertion groups 22 → 23, structural checks 16 → 17, host tests 250 → 265, clippy budget unchanged at 0.
A mistake made and corrected during this release
The first version of cat jumped to its exit path without
loading the return register when open failed. The program
exited with 549755814011, which is
0x8000000000 + 123 — the address of its own path string,
still in rdi. The test caught it because it asserts the
exact refusal code rather than merely that the program stopped. An
assertion checking only that something was returned would have
passed.
What this release does not do
- A ring 3 program still cannot write a file.
- There is no user heap: a program has its stack and nothing else.
- A descriptor does not pin the file. The content is re-read on every call, so a file modified between two reads is seen in its current state, and a deleted one makes the next read fail. Holding a snapshot would let a program tie up as much heap as it can open files.
opendoes not deduplicate: opening the same path twice gives two independent cursors and reads the file twice.- Four descriptors per task, a 64-byte path, 1024 bytes per read.