Skip to content

Commit d3ddb50

Browse files
committed
internal/durable: add strace samples
1 parent 9e58e82 commit d3ddb50

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

internal/durable/path.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
83107
func Mkdir(path string, perm os.FileMode) (err error) {

0 commit comments

Comments
 (0)