{"record":{"id":"cc282d80682c19b0","repo":"crowdsecurity/crowdsec","slug":"failed-to-get-filesystem-type-w-cc282d","errorCode":null,"errorMessage":"failed to get filesystem type: %w","messagePattern":"failed to get filesystem type: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/fsutil/getfstype_openbsd.go","lineNumber":15,"sourceCode":"//go:build openbsd\n\npackage fsutil\n\nimport (\n\t\"fmt\"\n\n\t\"golang.org/x/sys/unix\"\n)\n\nfunc GetFSType(path string) (string, error) {\n\tvar fsStat unix.Statfs_t\n\n\tif err := unix.Statfs(path, &fsStat); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get filesystem type: %w\", err)\n\t}\n\n\tbs := fsStat.F_fstypename\n\n\tb := make([]byte, len(bs))\n\tfor i, v := range bs {\n\t\tb[i] = byte(v)\n\t}\n\n\treturn string(b), nil\n}\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/fsutil/getfstype_openbsd.go#L1-L27","documentation":"GetFSType on OpenBSD resolves the filesystem type of a path via unix.Statfs. If the statfs syscall fails (path missing, permission denied, etc.), the raw syscall error is wrapped as 'failed to get filesystem type: %w' and returned.","triggerScenarios":"Calling GetFSType(path) where the path does not exist, is not accessible to the current user, or the kernel rejects the Statfs call.","commonSituations":"Checking a mount point that was unmounted or deleted before the call; running without permission to stat a directory; path typos.","solutions":["Verify the path exists and is accessible before calling GetFSType","Fix the path string (typos, stale paths)","Run with sufficient permissions to stat the target","Handle the wrapped error (os.IsNotExist / permission) at the call site"],"exampleFix":"// before\nfstype, err := GetFSType(mountPoint) // err if path gone\n// after\nif _, err := os.Stat(mountPoint); err != nil {\n    return fmt.Errorf(\"path %s unavailable: %w\", mountPoint, err)\n}\nfstype, err := GetFSType(mountPoint)","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(path); err != nil { return fmt.Errorf(\"cannot stat %s: %w\", path, err) }","typeGuard":null,"tryCatchPattern":"fstype, err := GetFSType(path)\nif err != nil {\n    var pe *fs.PathError\n    if errors.As(err, &pe) && errors.Is(pe.Err, fs.ErrNotExist) { /* handle missing path */ }\n    return err\n}","preventionTips":["Stat the path before calling GetFSType","Use absolute, verified paths","Handle fs.ErrNotExist and fs.ErrPermission explicitly"],"tags":["filesystem","openbsd","statfs"],"backgroundTag":"file-not-found","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}