github.com/artpar/rclone@v1.67.3/backend/local/read_device_unix.go (about)

     1  // Device reading functions
     2  
     3  //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
     4  
     5  package local
     6  
     7  import (
     8  	"os"
     9  	"syscall"
    10  
    11  	"github.com/artpar/rclone/fs"
    12  )
    13  
    14  // readDevice turns a valid os.FileInfo into a device number,
    15  // returning devUnset if it fails.
    16  func readDevice(fi os.FileInfo, oneFileSystem bool) uint64 {
    17  	if !oneFileSystem {
    18  		return devUnset
    19  	}
    20  	statT, ok := fi.Sys().(*syscall.Stat_t)
    21  	if !ok {
    22  		fs.Debugf(fi.Name(), "Type assertion fi.Sys().(*syscall.Stat_t) failed from: %#v", fi.Sys())
    23  		return devUnset
    24  	}
    25  	return uint64(statT.Dev) // nolint: unconvert
    26  }