crowdsecurity/crowdsec · error

failed to get filesystem type: %w

Error message

failed to get filesystem type: %w

What it means

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.

Source

Thrown at pkg/fsutil/getfstype_openbsd.go:15

//go:build openbsd

package fsutil

import (
	"fmt"

	"golang.org/x/sys/unix"
)

func GetFSType(path string) (string, error) {
	var fsStat unix.Statfs_t

	if err := unix.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
}

View on GitHub (pinned to 909b515798)

Solutions

  1. Verify the path exists and is accessible before calling GetFSType
  2. Fix the path string (typos, stale paths)
  3. Run with sufficient permissions to stat the target
  4. Handle the wrapped error (os.IsNotExist / permission) at the call site

Example fix

// before
fstype, err := GetFSType(mountPoint) // err if path gone
// after
if _, err := os.Stat(mountPoint); err != nil {
    return fmt.Errorf("path %s unavailable: %w", mountPoint, err)
}
fstype, err := GetFSType(mountPoint)
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Stat(path); err != nil { return fmt.Errorf("cannot stat %s: %w", path, err) }

Try / catch

fstype, err := GetFSType(path)
if err != nil {
    var pe *fs.PathError
    if errors.As(err, &pe) && errors.Is(pe.Err, fs.ErrNotExist) { /* handle missing path */ }
    return err
}

Prevention

When it happens

Trigger: Calling GetFSType(path) where the path does not exist, is not accessible to the current user, or the kernel rejects the Statfs call.

Common situations: Checking a mount point that was unmounted or deleted before the call; running without permission to stat a directory; path typos.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/cc282d80682c19b0. Report an issue: GitHub.