Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore unsupported derive types for GetVolumeInformation function #159

Merged
merged 1 commit into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions sigar_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,14 @@ func (self *FileSystemList) Get() error {
if err != nil {
return errors.Wrapf(err, "GetFilesystemType failed")
}

self.List = append(self.List, FileSystem{
DirName: drive,
DevName: drive,
TypeName: dt.String(),
SysTypeName: fsType,
})
if fsType != "" {
self.List = append(self.List, FileSystem{
DirName: drive,
DevName: drive,
TypeName: dt.String(),
SysTypeName: fsType,
})
}
}
return nil
}
Expand Down
10 changes: 10 additions & 0 deletions sys/windows/syscall_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ const (
PROCESS_VM_READ uint32 = 0x0010
)

// error codes for GetVolumeInformation function
const (
ERROR_INVALID_FUNCTION syscall.Errno = 1
ERROR_NOT_READY syscall.Errno = 21
)

// SizeOfRtlUserProcessParameters gives the size
// of the RtlUserProcessParameters struct.
const SizeOfRtlUserProcessParameters = unsafe.Sizeof(RtlUserProcessParameters{})
Expand Down Expand Up @@ -346,6 +352,10 @@ func GetFilesystemType(rootPathName string) (string, error) {

buffer := make([]uint16, MAX_PATH+1)
success, err := _GetVolumeInformation(rootPathNamePtr, nil, 0, nil, nil, nil, &buffer[0], MAX_PATH)
// check if CD-ROM or other type that is not supported in GetVolumeInformation function
if err == ERROR_NOT_READY || err == ERROR_INVALID_FUNCTION {
return "", nil
}
if !success {
return "", errors.Wrap(err, "GetVolumeInformationW failed")
}
Expand Down