...

Source file src/github.com/cybertec-postgresql/pgwatch/v6/internal/reaper/psutil_windows.go

Documentation: github.com/cybertec-postgresql/pgwatch/v6/internal/reaper

     1  package reaper
     2  
     3  import (
     4  	"os"
     5  	"syscall"
     6  )
     7  
     8  // GetPathUnderlyingDeviceID returns the volume serial number for the volume
     9  // that hosts the given path. This is the Windows equivalent of the Unix
    10  // device ID (Stat_t.Dev) and uniquely identifies the underlying disk volume.
    11  func GetPathUnderlyingDeviceID(path string) (uint64, error) {
    12  	f, err := os.Open(path)
    13  	if err != nil {
    14  		return 0, err
    15  	}
    16  	defer f.Close()
    17  
    18  	var info syscall.ByHandleFileInformation
    19  	if err = syscall.GetFileInformationByHandle(syscall.Handle(f.Fd()), &info); err != nil {
    20  		return 0, err
    21  	}
    22  	return uint64(info.VolumeSerialNumber), nil
    23  }
    24