logical_disk: revert panic trigger on error (#1755)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2024-11-22 17:20:27 +01:00
committed by GitHub
parent 4534c2a6ae
commit a602d7be9d

View File

@@ -468,14 +468,17 @@ func getVolumeInfo(rootDrive string) (volumeInfo, error) {
// If rootDrive is a NTFS directory, convert it to a volume GUID.
if strings.Contains(volumePath, `\`) {
volumePathName, err := windows.UTF16PtrFromString(volumePath + `\`)
// GetVolumeNameForVolumeMountPoint expects a trailing backslash.
volumePath += `\`
volumePathName, err := windows.UTF16PtrFromString(volumePath)
if err != nil {
return volumeInfo{}, fmt.Errorf("could not convert rootDrive to volume path: %w", err)
return volumeInfo{}, fmt.Errorf("could not convert rootDrive to volume path %s: %w", volumePath, err)
}
volumeGUIDPtr := make([]uint16, 50)
if err := windows.GetVolumeNameForVolumeMountPoint(volumePathName, &volumeGUIDPtr[0], uint32(len(volumeGUIDPtr))); err != nil {
panic(fmt.Errorf("could not get volume GUID: %w", err))
return volumeInfo{}, fmt.Errorf("could not get volume GUID for volume %s: %w", volumePath, err)
}
volumePath = windows.UTF16ToString(volumeGUIDPtr)