func IsMountpoint(filename string) (bool, error) {
	return defaultInfo.isMountpoint(filename)
}
IsMountpoint returns true if the file is a mountpoint, with an error if
there was a problem reading the mountpoint information. Returns false
on every file with no error if the mounts file was not found.
package mountutils
import (
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
	"sync"
	"github.com/uber/makisu/lib/log"
)
type mountInfo struct {
	data       map[string]mountPoint
	init       sync.Once
	mountsFile string
}
type mountPoint struct {
	Source  string
	Target  string
	FSType  string
	Options string
}
var defaultInfo = &mountInfo{
	data:       map[string]mountPoint{},
	mountsFile: "/proc/mounts",
}
func newMountInfo() *mountInfo {
	return &mountInfo{
		data:       map[string]mountPoint{},
		mountsFile: "/proc/mounts",
	}
}
func (info *mountInfo) initialize() error {
	content, err := ioutil.ReadFile(info.mountsFile)
	if os.IsNotExist(err) {
		log.Debug("Skipping mountmanager init, /proc/mounts does not exist")
		return nil
	} else if err != nil {
		return fmt.Errorf("mountmanager initialize: %s", err)
	}
	lines := strings.Split(string(content), "\n")
	for _, line := range lines {
		if len(line) == 0 {
			continue
		}
		fields := strings.SplitN(line, " ", 4)
		if len(fields) < 4 {
			return fmt.Errorf("cannot parse mounts file %s", info.mountsFile)
		} else if fields[1] == "/" {
			continue
		}
		info.data[fields[1]] = mountPoint{
			Source:  fields[0],
			Target:  fields[1],
			FSType:  fields[2],
			Options: fields[3],
		}
	}
	return nil
}
func (info *mountInfo) isMountpoint(filename string) (bool, error) {
	var err error
	info.init.Do(func() { err = info.initialize() })
	if err != nil {
		return false, fmt.Errorf("ismount: %s", err)
	}
	_, found := info.data[filename]
	return found, nil
}
func (info *mountInfo) isMounted(filename string) (bool, error) {
	if mp, err := info.isMountpoint(filename); err != nil || mp {
		return mp, err
	}
	for path := range info.data {
		if path[len(path)-1] != '/' {
			path += "/"
		}
		if strings.HasPrefix(filename, path) {
			return true, nil
		}
	}
	return false, nil
}
func (info *mountInfo) containsMountpoint(filename string) (bool, error) {
	if mp, err := info.isMountpoint(filename); err != nil || mp {
		return mp, err
	}
	for path := range info.data {
		if path[len(path)-1] != '/' {
			path += "/"
		}
		if filepath.HasPrefix(path, filename) {
			return true, nil
		}
	}
	return false, nil
}