implement GetFSType on openbsd with the correct statfs struct member (#3191)

This commit is contained in:
Robert Nagy 2024-08-27 12:41:53 +02:00 committed by GitHub
parent c4431b6385
commit 27559d6636
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View file

@ -1,4 +1,4 @@
//go:build !windows && !freebsd
//go:build !windows && !freebsd && !openbsd
package types

View file

@ -0,0 +1,25 @@
//go:build openbsd
package types
import (
"fmt"
"syscall"
)
func GetFSType(path string) (string, error) {
var fsStat syscall.Statfs_t
if err := syscall.Statfs(path, &fsStat); err != nil {
return "", fmt.Errorf("failed to get filesystem type: %w", err)
}
bs := fsStat.F_fstypename
b := make([]byte, len(bs))
for i, v := range bs {
b[i] = byte(v)
}
return string(b), nil
}