//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" // nonPersistentFilesystems returns the device ID of every mounted // filesystem that is not persistent, with its type: on Linux read from // mountInfoPath (see readMountInfo), and on any other system none. func nonPersistentFilesystems() (map[uint64]string, error) { if runtime.GOOS != goosLinux { return map[uint64]string{}, nil } f, err := os.Open(mountInfoPath) if err != nil { return nil, err } defer func() { _ = f.Close() }() devices, err := readMountInfo(f) if err != nil { return nil, fmt.Errorf("read %s: %w", mountInfoPath, err) } return devices, nil }