Skip to content

Commit

Permalink
stofuse: fix build on Darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
joonas-fi committed Apr 10, 2023
1 parent 647f111 commit ea0be71
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/stofuse/collectionadapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ func (a *changedFileInWorkdir) Setattr(ctx context.Context, req *fuse.SetattrReq
}
}

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

// TODO: use herbis times

Expand Down
13 changes: 13 additions & 0 deletions pkg/stofuse/os_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package stofuse

// os-specific abstractions (Darwin)

import (
"syscall"
"time"
)

// darwin doesn't seem to have field `Atim` in `syscall.Stat_t`
func accessTimeFromStatt(_ *syscall.Stat_t, modTime time.Time) time.Time {
return modTime
}
12 changes: 12 additions & 0 deletions pkg/stofuse/os_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package stofuse

// os-specific abstractions (Linux)

import (
"syscall"
"time"
)

func accessTimeFromStatt(stat *syscall.Stat_t, _ time.Time) time.Time {
return timespecToTime(stat.Atim)
}

0 comments on commit ea0be71

Please sign in to comment.