1
0
Fork
You've already forked linux-atomic-write
0
Testing untorn write on Linux
Zig 72.9%
C 27.1%
2025年10月27日 22:53:25 +00:00
src init 2025年10月18日 01:16:52 +00:00
.gitignore init 2025年10月18日 01:16:52 +00:00
atomic.c ++ 2025年10月18日 16:48:36 +00:00
build.ninja init 2025年10月18日 01:16:52 +00:00
build.zig init 2025年10月18日 01:16:52 +00:00
build.zig.zon init 2025年10月18日 01:16:52 +00:00
readme.md ++ 2025年10月27日 22:53:25 +00:00
test.c init 2025年10月18日 01:16:52 +00:00

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.
  • fsync commits data before linkat.
  • linkat is 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/unix package has everything.
  • Zig's std offers the wrong syscall interface. Run zig build run to 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.