github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/internal/disk/type_windows.go (about) 1 //go:build windows 2 // +build windows 3 4 // Copyright (c) 2015-2021 MinIO, Inc. 5 // 6 // This file is part of MinIO Object Storage stack 7 // 8 // This program is free software: you can redistribute it and/or modify 9 // it under the terms of the GNU Affero General Public License as published by 10 // the Free Software Foundation, either version 3 of the License, or 11 // (at your option) any later version. 12 // 13 // This program is distributed in the hope that it will be useful 14 // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 // GNU Affero General Public License for more details. 17 // 18 // You should have received a copy of the GNU Affero General Public License 19 // along with this program. If not, see <http://www.gnu.org/licenses/>. 20 21 package disk 22 23 import ( 24 "path/filepath" 25 "syscall" 26 "unsafe" 27 ) 28 29 // GetVolumeInformation provides windows drive volume information. 30 var GetVolumeInformation = kernel32.NewProc("GetVolumeInformationW") 31 32 // getFSType returns the filesystem type of the underlying mounted filesystem 33 func getFSType(path string) string { 34 volumeNameSize, nFileSystemNameSize := uint32(260), uint32(260) 35 var lpVolumeSerialNumber uint32 36 var lpFileSystemFlags, lpMaximumComponentLength uint32 37 var lpFileSystemNameBuffer, volumeName [260]uint16 38 ps := syscall.StringToUTF16Ptr(filepath.VolumeName(path)) 39 40 // Extract values safely 41 // BOOL WINAPI GetVolumeInformation( 42 // _In_opt_ LPCTSTR lpRootPathName, 43 // _Out_opt_ LPTSTR lpVolumeNameBuffer, 44 // _In_ DWORD nVolumeNameSize, 45 // _Out_opt_ LPDWORD lpVolumeSerialNumber, 46 // _Out_opt_ LPDWORD lpMaximumComponentLength, 47 // _Out_opt_ LPDWORD lpFileSystemFlags, 48 // _Out_opt_ LPTSTR lpFileSystemNameBuffer, 49 // _In_ DWORD nFileSystemNameSize 50 // ); 51 52 _, _, _ = GetVolumeInformation.Call(uintptr(unsafe.Pointer(ps)), 53 uintptr(unsafe.Pointer(&volumeName)), 54 uintptr(volumeNameSize), 55 uintptr(unsafe.Pointer(&lpVolumeSerialNumber)), 56 uintptr(unsafe.Pointer(&lpMaximumComponentLength)), 57 uintptr(unsafe.Pointer(&lpFileSystemFlags)), 58 uintptr(unsafe.Pointer(&lpFileSystemNameBuffer)), 59 uintptr(nFileSystemNameSize)) 60 61 return syscall.UTF16ToString(lpFileSystemNameBuffer[:]) 62 }