Make utils_daemon and volumes cross-platform compileable.
Signed-off-by: Rik Nijessen <riknijessen@gmail.com>
This commit is contained in:
parent
718f112173
commit
a5e54d5788
7 changed files with 30 additions and 16 deletions
|
@ -143,7 +143,7 @@ func Changes(layers []string, rw string) ([]Change, error) {
|
||||||
type FileInfo struct {
|
type FileInfo struct {
|
||||||
parent *FileInfo
|
parent *FileInfo
|
||||||
name string
|
name string
|
||||||
stat *system.Stat
|
stat *system.Stat_t
|
||||||
children map[string]*FileInfo
|
children map[string]*FileInfo
|
||||||
capability []byte
|
capability []byte
|
||||||
added bool
|
added bool
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Lstat(path string) (*Stat, error) {
|
func Lstat(path string) (*Stat_t, error) {
|
||||||
s := &syscall.Stat_t{}
|
s := &syscall.Stat_t{}
|
||||||
err := syscall.Lstat(path, s)
|
err := syscall.Lstat(path, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
package system
|
package system
|
||||||
|
|
||||||
func Lstat(path string) (*Stat, error) {
|
func Lstat(path string) (*Stat_t, error) {
|
||||||
// should not be called on cli code path
|
// should not be called on cli code path
|
||||||
return nil, ErrNotSupportedPlatform
|
return nil, ErrNotSupportedPlatform
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Stat struct {
|
type Stat_t struct {
|
||||||
mode uint32
|
mode uint32
|
||||||
uid uint32
|
uid uint32
|
||||||
gid uint32
|
gid uint32
|
||||||
|
@ -13,30 +13,30 @@ type Stat struct {
|
||||||
mtim syscall.Timespec
|
mtim syscall.Timespec
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Stat) Mode() uint32 {
|
func (s Stat_t) Mode() uint32 {
|
||||||
return s.mode
|
return s.mode
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Stat) Uid() uint32 {
|
func (s Stat_t) Uid() uint32 {
|
||||||
return s.uid
|
return s.uid
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Stat) Gid() uint32 {
|
func (s Stat_t) Gid() uint32 {
|
||||||
return s.gid
|
return s.gid
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Stat) Rdev() uint64 {
|
func (s Stat_t) Rdev() uint64 {
|
||||||
return s.rdev
|
return s.rdev
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Stat) Size() int64 {
|
func (s Stat_t) Size() int64 {
|
||||||
return s.size
|
return s.size
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Stat) Mtim() syscall.Timespec {
|
func (s Stat_t) Mtim() syscall.Timespec {
|
||||||
return s.mtim
|
return s.mtim
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Stat) GetLastModification() syscall.Timespec {
|
func (s Stat_t) GetLastModification() syscall.Timespec {
|
||||||
return s.Mtim()
|
return s.Mtim()
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,20 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func fromStatT(s *syscall.Stat_t) (*Stat, error) {
|
func fromStatT(s *syscall.Stat_t) (*Stat_t, error) {
|
||||||
return &Stat{size: s.Size,
|
return &Stat_t{size: s.Size,
|
||||||
mode: s.Mode,
|
mode: s.Mode,
|
||||||
uid: s.Uid,
|
uid: s.Uid,
|
||||||
gid: s.Gid,
|
gid: s.Gid,
|
||||||
rdev: s.Rdev,
|
rdev: s.Rdev,
|
||||||
mtim: s.Mtim}, nil
|
mtim: s.Mtim}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Stat(path string) (*Stat_t, error) {
|
||||||
|
s := &syscall.Stat_t{}
|
||||||
|
err := syscall.Stat(path, s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return fromStatT(s)
|
||||||
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func fromStatT(s *syscall.Stat_t) (*Stat, error) {
|
func fromStatT(s *syscall.Stat_t) (*Stat_t, error) {
|
||||||
return &Stat{size: s.Size,
|
return &Stat_t{size: s.Size,
|
||||||
mode: uint32(s.Mode),
|
mode: uint32(s.Mode),
|
||||||
uid: s.Uid,
|
uid: s.Uid,
|
||||||
gid: s.Gid,
|
gid: s.Gid,
|
||||||
|
|
|
@ -7,6 +7,11 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func fromStatT(s *syscall.Win32FileAttributeData) (*Stat, error) {
|
func fromStatT(s *syscall.Win32FileAttributeData) (*Stat_t, error) {
|
||||||
return nil, errors.New("fromStatT should not be called on windows path")
|
return nil, errors.New("fromStatT should not be called on windows path")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Stat(path string) (*Stat_t, error) {
|
||||||
|
// should not be called on cli code path
|
||||||
|
return nil, ErrNotSupportedPlatform
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue