Skip to content

Commit ea0be71

Browse files
committed
stofuse: fix build on Darwin
1 parent 647f111 commit ea0be71

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

pkg/stofuse/collectionadapter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ func (a *changedFileInWorkdir) Setattr(ctx context.Context, req *fuse.SetattrReq
471471
}
472472
}
473473

474-
existingATime := timespecToTime(existing.Sys().(*syscall.Stat_t).Atim)
474+
// some platforms don't support fetching access time.
475+
existingATime := accessTimeFromStatt(existing.Sys().(*syscall.Stat_t), existing.ModTime())
475476

476477
// TODO: use herbis times
477478

pkg/stofuse/os_darwin.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package stofuse
2+
3+
// os-specific abstractions (Darwin)
4+
5+
import (
6+
"syscall"
7+
"time"
8+
)
9+
10+
// darwin doesn't seem to have field `Atim` in `syscall.Stat_t`
11+
func accessTimeFromStatt(_ *syscall.Stat_t, modTime time.Time) time.Time {
12+
return modTime
13+
}

pkg/stofuse/os_linux.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package stofuse
2+
3+
// os-specific abstractions (Linux)
4+
5+
import (
6+
"syscall"
7+
"time"
8+
)
9+
10+
func accessTimeFromStatt(stat *syscall.Stat_t, _ time.Time) time.Time {
11+
return timespecToTime(stat.Atim)
12+
}

0 commit comments

Comments
 (0)