Testing untorn write on Linux
|
|
||
|---|---|---|
| src | init | |
| .gitignore | init | |
| atomic.c | ++ | |
| build.ninja | init | |
| build.zig | init | |
| build.zig.zon | init | |
| readme.md | ++ | |
| test.c | init | |
With the "reflink copy" feature of Linux, a process can automatically update a file without space overhead on COW filesystems like btrfs.
Is it slow? Yes, it makes several syscalls. Still, it should be correct.
How it works:
ioctl(dest, FICLONE, src)is atomic.fsynccommits data beforelinkat.linkatis atomic.
Run ninja to build.
Even with a better type system and a better syntax, one must still program syscalls like in C.
- Go's
syscall/unixpackage has everything. - Zig's
stdoffers the wrong syscall interface. Runzig build runto see what's wrong. - Hare does not have FICLONE.
Lesson about error handling: Use a generic error type like error, not integer set (Zig) or hyper-specific sets (Hare).
For shaky ground and assumptions used by databases: see my writing here.