File: chtimes_linux.go

package info (click to toggle)
golang-github-tonistiigi-fsutil 0.0~git20240424.91a3fc4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 664 kB
  • sloc: sh: 59; makefile: 5
file content (21 lines) | stat: -rw-r--r-- 423 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//go:build linux
// +build linux

package fsutil

import (
	"github.com/pkg/errors"
	"golang.org/x/sys/unix"
)

func chtimes(path string, un int64) error {
	var utimes [2]unix.Timespec
	utimes[0] = unix.NsecToTimespec(un)
	utimes[1] = utimes[0]

	if err := unix.UtimesNanoAt(unix.AT_FDCWD, path, utimes[0:], unix.AT_SYMLINK_NOFOLLOW); err != nil {
		return errors.Wrap(err, "failed call to UtimesNanoAt")
	}

	return nil
}