mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-10 20:05:55 +02:00
implement GetFSType on openbsd with the correct statfs struct member (#3191)
This commit is contained in:
parent
c4431b6385
commit
27559d6636
2 changed files with 26 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
//go:build !windows && !freebsd
|
||||
//go:build !windows && !freebsd && !openbsd
|
||||
|
||||
package types
|
||||
|
||||
|
|
25
pkg/types/getfstype_openbsd.go
Normal file
25
pkg/types/getfstype_openbsd.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue