github.com/ld86/docker@v1.7.1-rc3/pkg/system/stat_linux.go (about)

     1  package system
     2  
     3  import (
     4  	"syscall"
     5  )
     6  
     7  // fromStatT converts a syscall.Stat_t type to a system.Stat_t type
     8  func fromStatT(s *syscall.Stat_t) (*Stat_t, error) {
     9  	return &Stat_t{size: s.Size,
    10  		mode: s.Mode,
    11  		uid:  s.Uid,
    12  		gid:  s.Gid,
    13  		rdev: s.Rdev,
    14  		mtim: s.Mtim}, nil
    15  }
    16  
    17  // Stat takes a path to a file and returns
    18  // a system.Stat_t type pertaining to that file.
    19  //
    20  // Throws an error if the file does not exist
    21  func Stat(path string) (*Stat_t, error) {
    22  	s := &syscall.Stat_t{}
    23  	if err := syscall.Stat(path, s); err != nil {
    24  		return nil, err
    25  	}
    26  	return fromStatT(s)
    27  }