2020-01-19 06:41:05 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package vfs
|
|
|
|
|
2020-04-30 12:23:55 +00:00
|
|
|
import (
|
2021-05-27 18:14:12 +00:00
|
|
|
"errors"
|
2020-04-30 12:23:55 +00:00
|
|
|
"os"
|
|
|
|
"syscall"
|
2021-05-27 18:14:12 +00:00
|
|
|
|
|
|
|
"golang.org/x/sys/unix"
|
2020-04-30 12:23:55 +00:00
|
|
|
)
|
2020-01-19 06:41:05 +00:00
|
|
|
|
|
|
|
var (
|
|
|
|
defaultUID, defaultGID int
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
defaultUID = os.Getuid()
|
|
|
|
defaultGID = os.Getuid()
|
|
|
|
if defaultUID < 0 {
|
|
|
|
defaultUID = 65534
|
|
|
|
}
|
|
|
|
if defaultGID < 0 {
|
|
|
|
defaultGID = 65534
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-31 18:04:00 +00:00
|
|
|
func (fi FileInfo) getFileInfoSys() interface{} {
|
2020-01-19 06:41:05 +00:00
|
|
|
return &syscall.Stat_t{
|
|
|
|
Uid: uint32(defaultUID),
|
|
|
|
Gid: uint32(defaultGID)}
|
|
|
|
}
|
2021-05-27 18:14:12 +00:00
|
|
|
|
|
|
|
func isCrossDeviceError(err error) bool {
|
|
|
|
return errors.Is(err, unix.EXDEV)
|
|
|
|
}
|