github.com/apcera/util@v0.0.0-20180322191801-7a50bc84ee48/tarhelper/utils_posixfs.go (about)

     1  // Copyright 2014 Apcera Inc. All rights reserved.
     2  
     3  // +build !windows
     4  
     5  package tarhelper
     6  
     7  import (
     8  	"archive/tar"
     9  	"os"
    10  	"syscall"
    11  )
    12  
    13  func osMknod(name string, mode uint32, dev int) error {
    14  	return syscall.Mknod(name, mode, dev)
    15  }
    16  
    17  func osDeviceNumbersForFileInfo(fi os.FileInfo) (int64, int64) {
    18  	if sys, ok := fi.Sys().(*syscall.Stat_t); ok {
    19  		return majordev(int64(sys.Rdev)), minordev(int64(sys.Rdev))
    20  	}
    21  	return 0, 0
    22  }
    23  
    24  func uidForFileInfo(fi os.FileInfo) int {
    25  	return int(fi.Sys().(*syscall.Stat_t).Uid)
    26  }
    27  
    28  func gidForFileInfo(fi os.FileInfo) int {
    29  	return int(fi.Sys().(*syscall.Stat_t).Gid)
    30  }
    31  
    32  func linkCountForFileInfo(fi os.FileInfo) uint {
    33  	return uint(fi.Sys().(*syscall.Stat_t).Nlink)
    34  }
    35  
    36  func inodeForFileInfo(fi os.FileInfo) uint64 {
    37  	return fi.Sys().(*syscall.Stat_t).Ino
    38  }
    39  
    40  // chmodTarEntry is used to adjust the file permissions used in tar header based
    41  // on the platform the archival is done.
    42  func chmodTarEntry(h *tar.Header) {
    43  }