github.com/nalind/docker@v1.5.0/pkg/archive/archive_unix.go (about) 1 // +build !windows 2 3 package archive 4 5 import ( 6 "errors" 7 "syscall" 8 9 "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" 10 ) 11 12 func setHeaderForSpecialDevice(hdr *tar.Header, ta *tarAppender, name string, stat interface{}) (nlink uint32, inode uint64, err error) { 13 s, ok := stat.(*syscall.Stat_t) 14 15 if !ok { 16 err = errors.New("cannot convert stat value to syscall.Stat_t") 17 return 18 } 19 20 nlink = uint32(s.Nlink) 21 inode = uint64(s.Ino) 22 23 // Currently go does not fil in the major/minors 24 if s.Mode&syscall.S_IFBLK == syscall.S_IFBLK || 25 s.Mode&syscall.S_IFCHR == syscall.S_IFCHR { 26 hdr.Devmajor = int64(major(uint64(s.Rdev))) 27 hdr.Devminor = int64(minor(uint64(s.Rdev))) 28 } 29 30 return 31 } 32 33 func major(device uint64) uint64 { 34 return (device >> 8) & 0xfff 35 } 36 37 func minor(device uint64) uint64 { 38 return (device & 0xff) | ((device >> 12) & 0xfff00) 39 }