@@ -16,6 +16,19 @@ import (
1616 "syscall"
1717)
1818
19+ // The sequence of syscalls for a happy path call to WriteFile looks like this:
20+ //
21+ // openat(AT_FDCWD, "dir", O_RDONLY|O_CLOEXEC|O_DIRECTORY) = 3
22+ // openat(AT_FDCWD, "dir/.file4057926228", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0600) = 6
23+ // fchmod(6, 0644) = 0
24+ // write(6, "hello world", 11) = 11
25+ // fsync(6) = 0
26+ // close(6) = 0
27+ // renameat(AT_FDCWD, "dir/.file4057926228", AT_FDCWD, "dir/file") = 0
28+ // fsync(3) = 0
29+ // close(3) = 0
30+ //
31+
1932// WriteFile behaves somewhat like [os.WriteFile], but it also syncs the file
2033// contents and the directory entry to disk before returning, and prevents
2134// partial writes from being visible.
@@ -78,6 +91,17 @@ func MkdirAll(path string, perm os.FileMode) (err error) {
7891 return Mkdir (path , perm )
7992}
8093
94+ // The sequence of syscalls for a happy path call to Mkdir looks like this:
95+ //
96+ // openat(AT_FDCWD, "dir1", O_RDONLY|O_CLOEXEC|O_DIRECTORY) = 3
97+ // mkdirat(AT_FDCWD, "dir1/dir2", 0755) = 0
98+ // openat(AT_FDCWD, "dir1/dir2", O_RDONLY|O_CLOEXEC) = 6
99+ // fsync(6) = 0
100+ // close(6) = 0
101+ // fsync(3) = 0
102+ // close(3) = 0
103+ //
104+
81105// Mkdir behaves like [os.Mkdir], but it also syncs the directory containing
82106// the created directory to disk.
83107func Mkdir (path string , perm os.FileMode ) (err error ) {
0 commit comments