|
@@ -16,12 +16,11 @@ import (
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"sync"
|
|
|
- "syscall"
|
|
|
"time"
|
|
|
- "unsafe"
|
|
|
|
|
|
winio "github.com/Microsoft/go-winio"
|
|
|
"github.com/Microsoft/go-winio/backuptar"
|
|
|
+ winiofs "github.com/Microsoft/go-winio/pkg/fs"
|
|
|
"github.com/Microsoft/go-winio/vhd"
|
|
|
"github.com/Microsoft/hcsshim"
|
|
|
"github.com/Microsoft/hcsshim/osversion"
|
|
@@ -100,7 +99,7 @@ type Driver struct {
|
|
|
func InitFilter(home string, options []string, _ idtools.IdentityMapping) (graphdriver.Driver, error) {
|
|
|
logrus.Debugf("WindowsGraphDriver InitFilter at %s", home)
|
|
|
|
|
|
- fsType, err := getFileSystemType(string(home[0]))
|
|
|
+ fsType, err := winiofs.GetFileSystemType(home)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
@@ -137,37 +136,6 @@ func InitFilter(home string, options []string, _ idtools.IdentityMapping) (graph
|
|
|
return d, nil
|
|
|
}
|
|
|
|
|
|
-// win32FromHresult is a helper function to get the win32 error code from an HRESULT
|
|
|
-func win32FromHresult(hr uintptr) uintptr {
|
|
|
- if hr&0x1fff0000 == 0x00070000 {
|
|
|
- return hr & 0xffff
|
|
|
- }
|
|
|
- return hr
|
|
|
-}
|
|
|
-
|
|
|
-// getFileSystemType obtains the type of a file system through GetVolumeInformation
|
|
|
-// https://msdn.microsoft.com/en-us/library/windows/desktop/aa364993(v=vs.85).aspx
|
|
|
-func getFileSystemType(drive string) (fsType string, hr error) {
|
|
|
- var (
|
|
|
- modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
|
|
- procGetVolumeInformation = modkernel32.NewProc("GetVolumeInformationW")
|
|
|
- buf = make([]uint16, 255)
|
|
|
- size = windows.MAX_PATH + 1
|
|
|
- )
|
|
|
- if len(drive) != 1 {
|
|
|
- hr = errors.New("getFileSystemType must be called with a drive letter")
|
|
|
- return
|
|
|
- }
|
|
|
- drive += `:\`
|
|
|
- n := uintptr(unsafe.Pointer(nil))
|
|
|
- r0, _, _ := syscall.Syscall9(procGetVolumeInformation.Addr(), 8, uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(drive))), n, n, n, n, n, uintptr(unsafe.Pointer(&buf[0])), uintptr(size), 0)
|
|
|
- if int32(r0) < 0 {
|
|
|
- hr = syscall.Errno(win32FromHresult(r0))
|
|
|
- }
|
|
|
- fsType = windows.UTF16ToString(buf)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
// String returns the string representation of a driver. This should match
|
|
|
// the name the graph driver has been registered with.
|
|
|
func (d *Driver) String() string {
|