restic/internal/fs/node_linux.go
greatroar f967a33ccc fs: Use AT_FDCWD in Linux nodeRestoreSymlinkTimestamps
There's no need to open the containing directory. This is exactly what
syscall.UtimesNano does, except for the AT_SYMLINK_NOFOLLOW flag.
2024-10-19 11:29:35 +02:00

18 lines
434 B
Go

package fs
import (
"syscall"
"github.com/restic/restic/internal/errors"
"golang.org/x/sys/unix"
)
func nodeRestoreSymlinkTimestamps(path string, utimes [2]syscall.Timespec) error {
times := []unix.Timespec{
{Sec: utimes[0].Sec, Nsec: utimes[0].Nsec},
{Sec: utimes[1].Sec, Nsec: utimes[1].Nsec},
}
err := unix.UtimesNanoAt(unix.AT_FDCWD, path, times, unix.AT_SYMLINK_NOFOLLOW)
return errors.Wrap(err, "UtimesNanoAt")
}