//go:build darwin package main import "golang.org/x/sys/unix" // mountedFilesystems returns every mount point with the type of its // filesystem, from the system's list of mounted filesystems. Where one // filesystem is mounted over another, the later one in the list counts. func mountedFilesystems() (map[string]string, error) { // The first call counts the filesystems, the second lists them. n, err := unix.Getfsstat(nil, unix.MNT_NOWAIT) if err != nil { return nil, err } list := make([]unix.Statfs_t, n) n, err = unix.Getfsstat(list, unix.MNT_NOWAIT) if err != nil { return nil, err } mounts := make(map[string]string, n) for _, st := range list[:n] { mounts[unix.ByteSliceToString(st.Mntonname[:])] = unix.ByteSliceToString(st.Fstypename[:]) } return mounts, nil }