//go:build !darwin package main import ( "fmt" "os" "runtime" ) // mountInfoPath is the file in which Linux lists the mounts the reading // process sees. const mountInfoPath = "/proc/self/mountinfo" // mountedFilesystems returns every mount point with the type of its // filesystem: on Linux read from mountInfoPath (see readMountInfo), and // on any other system none. func mountedFilesystems() (map[string]string, error) { if runtime.GOOS != goosLinux { return map[string]string{}, nil } f, err := os.Open(mountInfoPath) if err != nil { return nil, err } defer func() { _ = f.Close() }() mounts, err := readMountInfo(f) if err != nil { return nil, fmt.Errorf("read %s: %w", mountInfoPath, err) } return mounts, nil }