Files
overlayfs/mergefs_unix.go
Matheus Sampaio Queiroga 7aaf3834da
Some checks failed
Golang test / go-test (ubuntu-latest) (push) Failing after 19s
Golang test / go-test (windows-latest) (push) Has been cancelled
Update mergefs
Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
2025-07-26 14:46:43 -03:00

36 lines
900 B
Go

//go:build unix
package overlayfs
import (
"errors"
"io/fs"
"os"
"path/filepath"
"syscall"
"time"
)
func (over Overlayfs) Utimens(name string, access, modification time.Time) error {
if !over.isPathInsideOverlay(name) {
return &fs.PathError{Op: "utimens", Path: name, Err: fs.ErrInvalid}
} else if !over.isRW() {
return &fs.PathError{Op: "utimens", Path: name, Err: fs.ErrPermission}
}
for layer := range over.Lower {
if _, err := os.Stat(filepath.Join(over.Lower[layer], name)); err == nil {
// Clone file to upper if not exists
if err := over.copyFileToUpperIfAbsent(name); err != nil && !errors.Is(err, fs.ErrNotExist) {
return rewriteName(name, err)
}
break
}
}
return rewriteName(name, syscall.Utimes(filepath.Join(over.Upper, name), []syscall.Timeval{
syscall.NsecToTimeval(access.UnixNano()),
syscall.NsecToTimeval(modification.UnixNano()),
}))
}