diff --git a/archive/changes.go b/archive/changes.go index 9f16b76..f2ac2a3 100644 --- a/archive/changes.go +++ b/archive/changes.go @@ -143,7 +143,7 @@ func Changes(layers []string, rw string) ([]Change, error) { type FileInfo struct { parent *FileInfo name string - stat *system.Stat + stat *system.Stat_t children map[string]*FileInfo capability []byte added bool diff --git a/system/lstat.go b/system/lstat.go index 9ef82d5..6c1ed2e 100644 --- a/system/lstat.go +++ b/system/lstat.go @@ -6,7 +6,7 @@ import ( "syscall" ) -func Lstat(path string) (*Stat, error) { +func Lstat(path string) (*Stat_t, error) { s := &syscall.Stat_t{} err := syscall.Lstat(path, s) if err != nil { diff --git a/system/lstat_windows.go b/system/lstat_windows.go index 213a7c7..801e756 100644 --- a/system/lstat_windows.go +++ b/system/lstat_windows.go @@ -2,7 +2,7 @@ package system -func Lstat(path string) (*Stat, error) { +func Lstat(path string) (*Stat_t, error) { // should not be called on cli code path return nil, ErrNotSupportedPlatform } diff --git a/system/stat.go b/system/stat.go index 5d47494..186e852 100644 --- a/system/stat.go +++ b/system/stat.go @@ -4,7 +4,7 @@ import ( "syscall" ) -type Stat struct { +type Stat_t struct { mode uint32 uid uint32 gid uint32 @@ -13,30 +13,30 @@ type Stat struct { mtim syscall.Timespec } -func (s Stat) Mode() uint32 { +func (s Stat_t) Mode() uint32 { return s.mode } -func (s Stat) Uid() uint32 { +func (s Stat_t) Uid() uint32 { return s.uid } -func (s Stat) Gid() uint32 { +func (s Stat_t) Gid() uint32 { return s.gid } -func (s Stat) Rdev() uint64 { +func (s Stat_t) Rdev() uint64 { return s.rdev } -func (s Stat) Size() int64 { +func (s Stat_t) Size() int64 { return s.size } -func (s Stat) Mtim() syscall.Timespec { +func (s Stat_t) Mtim() syscall.Timespec { return s.mtim } -func (s Stat) GetLastModification() syscall.Timespec { +func (s Stat_t) GetLastModification() syscall.Timespec { return s.Mtim() } diff --git a/system/stat_linux.go b/system/stat_linux.go index 47cebef..072728d 100644 --- a/system/stat_linux.go +++ b/system/stat_linux.go @@ -4,11 +4,20 @@ import ( "syscall" ) -func fromStatT(s *syscall.Stat_t) (*Stat, error) { - return &Stat{size: s.Size, +func fromStatT(s *syscall.Stat_t) (*Stat_t, error) { + return &Stat_t{size: s.Size, mode: s.Mode, uid: s.Uid, gid: s.Gid, rdev: s.Rdev, 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) +} diff --git a/system/stat_unsupported.go b/system/stat_unsupported.go index c4d53e6..66323ee 100644 --- a/system/stat_unsupported.go +++ b/system/stat_unsupported.go @@ -6,8 +6,8 @@ import ( "syscall" ) -func fromStatT(s *syscall.Stat_t) (*Stat, error) { - return &Stat{size: s.Size, +func fromStatT(s *syscall.Stat_t) (*Stat_t, error) { + return &Stat_t{size: s.Size, mode: uint32(s.Mode), uid: s.Uid, gid: s.Gid, diff --git a/system/stat_windows.go b/system/stat_windows.go index 584e894..42d29d6 100644 --- a/system/stat_windows.go +++ b/system/stat_windows.go @@ -7,6 +7,11 @@ import ( "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") } + +func Stat(path string) (*Stat_t, error) { + // should not be called on cli code path + return nil, ErrNotSupportedPlatform +}