-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement GetFSType on openbsd with the correct statfs struct member (#…
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//go:build !windows && !freebsd | ||
//go:build !windows && !freebsd && !openbsd | ||
|
||
package types | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |