Skip to content

Commit

Permalink
Merge pull request #159 from narph/dvd-fix
Browse files Browse the repository at this point in the history
Ignore unsupported derive types for GetVolumeInformation  function
  • Loading branch information
fearful-symmetry authored Mar 10, 2021
2 parents 7eca302 + c952eed commit 7016988
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
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

0 comments on commit 7016988

Please sign in to comment.