small refactor*
This commit is contained in:
parent
b6b541e050
commit
24a4d30275
232 changed files with 2164 additions and 1906 deletions
server/pkg/go-nfs/file
17
server/pkg/go-nfs/file/file.go
Normal file
17
server/pkg/go-nfs/file/file.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package file
|
||||
|
||||
import "os"
|
||||
|
||||
type FileInfo struct {
|
||||
Nlink uint32
|
||||
UID uint32
|
||||
GID uint32
|
||||
Major uint32
|
||||
Minor uint32
|
||||
Fileid uint64
|
||||
}
|
||||
|
||||
// GetInfo extracts some non-standardized items from the result of a Stat call.
|
||||
func GetInfo(fi os.FileInfo) *FileInfo {
|
||||
return getInfo(fi)
|
||||
}
|
24
server/pkg/go-nfs/file/file_unix.go
Normal file
24
server/pkg/go-nfs/file/file_unix.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
//go:build darwin || dragonfly || freebsd || linux || nacl || netbsd || openbsd || solaris
|
||||
|
||||
package file
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func getInfo(info os.FileInfo) *FileInfo {
|
||||
fi := &FileInfo{}
|
||||
if s, ok := info.Sys().(*syscall.Stat_t); ok {
|
||||
fi.Nlink = uint32(s.Nlink)
|
||||
fi.UID = s.Uid
|
||||
fi.GID = s.Gid
|
||||
fi.Major = unix.Major(uint64(s.Rdev))
|
||||
fi.Minor = unix.Minor(uint64(s.Rdev))
|
||||
fi.Fileid = s.Ino
|
||||
return fi
|
||||
}
|
||||
return nil
|
||||
}
|
12
server/pkg/go-nfs/file/file_windows.go
Normal file
12
server/pkg/go-nfs/file/file_windows.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
//go:build windows
|
||||
|
||||
package file
|
||||
|
||||
import "os"
|
||||
|
||||
func getInfo(info os.FileInfo) *FileInfo {
|
||||
// https://godoc.org/golang.org/x/sys/windows#GetFileInformationByHandle
|
||||
// can be potentially used to populate Nlink
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue