Skip to content

Commit

Permalink
fs: avoid using unix.UTIME_OMIT on darwin
Browse files Browse the repository at this point in the history
Change-Id: I8f05010f64edaf1d41fdfca31ee4ae3079cd0ae3
  • Loading branch information
hanwen committed May 18, 2024
1 parent 087d70b commit dd7ef76
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/loopback.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ func (n *LoopbackNode) Setattr(ctx context.Context, f FileHandle, in *fuse.SetAt
atime, aok := in.GetATime()

if mok || aok {
ta := unix.Timespec{Nsec: unix.UTIME_OMIT}
tm := unix.Timespec{Nsec: unix.UTIME_OMIT}
ta := unix.Timespec{Nsec: unix_UTIME_OMIT}
tm := unix.Timespec{Nsec: unix_UTIME_OMIT}
var err error
if aok {
ta, err = unix.TimeToTimespec(atime)
Expand Down
2 changes: 2 additions & 0 deletions fs/loopback_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"time"
)

const unix_UTIME_OMIT = 0x0

// timeToTimeval - Convert time.Time to syscall.Timeval
//
// Note: This does not use syscall.NsecToTimespec because
Expand Down
2 changes: 2 additions & 0 deletions fs/loopback_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"golang.org/x/sys/unix"
)

const unix_UTIME_OMIT = unix.UTIME_OMIT

// FreeBSD has added copy_file_range(2) since FreeBSD 12. However,
// golang.org/x/sys/unix hasn't add corresponding syscall constant or
// wrap function. Here we define the syscall constant until sys/unix
Expand Down
2 changes: 2 additions & 0 deletions fs/loopback_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"golang.org/x/sys/unix"
)

const unix_UTIME_OMIT = unix.UTIME_OMIT

func doCopyFileRange(fdIn int, offIn int64, fdOut int, offOut int64,
len int, flags int) (uint32, syscall.Errno) {
count, err := unix.CopyFileRange(fdIn, &offIn, fdOut, &offOut, len, flags)
Expand Down

0 comments on commit dd7ef76

Please sign in to comment.