storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/pkg/disk/type_windows.go (about) 1 //go:build windows 2 // +build windows 3 4 /* 5 * MinIO Cloud Storage, (C) 2015 MinIO, Inc. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 package disk 21 22 import ( 23 "path/filepath" 24 "syscall" 25 "unsafe" 26 ) 27 28 var ( 29 // GetVolumeInformation provides windows drive volume information. 30 GetVolumeInformation = kernel32.NewProc("GetVolumeInformationW") 31 ) 32 33 // getFSType returns the filesystem type of the underlying mounted filesystem 34 func getFSType(path string) string { 35 volumeNameSize, nFileSystemNameSize := uint32(260), uint32(260) 36 var lpVolumeSerialNumber uint32 37 var lpFileSystemFlags, lpMaximumComponentLength uint32 38 var lpFileSystemNameBuffer, volumeName [260]uint16 39 var ps = syscall.StringToUTF16Ptr(filepath.VolumeName(path)) 40 41 // Extract values safely 42 // BOOL WINAPI GetVolumeInformation( 43 // _In_opt_ LPCTSTR lpRootPathName, 44 // _Out_opt_ LPTSTR lpVolumeNameBuffer, 45 // _In_ DWORD nVolumeNameSize, 46 // _Out_opt_ LPDWORD lpVolumeSerialNumber, 47 // _Out_opt_ LPDWORD lpMaximumComponentLength, 48 // _Out_opt_ LPDWORD lpFileSystemFlags, 49 // _Out_opt_ LPTSTR lpFileSystemNameBuffer, 50 // _In_ DWORD nFileSystemNameSize 51 // ); 52 53 _, _, _ = GetVolumeInformation.Call(uintptr(unsafe.Pointer(ps)), 54 uintptr(unsafe.Pointer(&volumeName)), 55 uintptr(volumeNameSize), 56 uintptr(unsafe.Pointer(&lpVolumeSerialNumber)), 57 uintptr(unsafe.Pointer(&lpMaximumComponentLength)), 58 uintptr(unsafe.Pointer(&lpFileSystemFlags)), 59 uintptr(unsafe.Pointer(&lpFileSystemNameBuffer)), 60 uintptr(nFileSystemNameSize)) 61 62 return syscall.UTF16ToString(lpFileSystemNameBuffer[:]) 63 }