func checkMountDestination(rootfs, dest string) error {
	if filepath.Clean(rootfs) == filepath.Clean(dest) {
		return fmt.Errorf("mounting into / is prohibited")
	}
	invalidDestinations := []string{
		"/proc",
	}
	for _, invalid := range invalidDestinations {
		path, err := filepath.Rel(filepath.Join(rootfs, invalid), dest)
		if err != nil {
			return err
		}
		if path == "." || !strings.HasPrefix(path, "..") {
			return fmt.Errorf("%q cannot be mounted because it is located inside %q", dest, invalid)
		}
	}
	return nil
}
func checkMountDestination(rootfs, dest string) error {
	if filepath.Clean(rootfs) == filepath.Clean(dest) {
		return fmt.Errorf("mounting into / is prohibited")
	}
	invalidDestinations := []string{
		"/proc",
	}
	for _, invalid := range invalidDestinations {
		path, err := filepath.Rel(filepath.Join(rootfs, invalid), dest)
		if err != nil {
			return err
		}
		if path == "." || !strings.HasPrefix(path, "..") {
			return fmt.Errorf("%q cannot be mounted because it is located inside %q", dest, invalid)
		}
	}
	return nil
}
func checkMountDestination ( rootfs , dest string ) error { if filepath . Clean ( rootfs ) == filepath . Clean ( dest ) { return fmt . Errorf ( " " ) } invalidDestinations := [ ] string { " " , } for _ , invalid := range invalidDestinations { path , err := filepath . Rel ( filepath . Join ( rootfs , invalid ) , dest ) if err != nil { return err } if path == " " || ! strings . HasPrefix ( path , " " ) { return fmt . Errorf ( " " , dest , invalid ) } } return nil }
// checkMountDestination checks to ensure that the mount destination is not over the
// top of /proc or /sys.
// dest is required to be an abs path and have any symlinks resolved before calling this function.
checkMountDestination checks to ensure that the mount destination is not over the top of / proc or / sys . dest is required to be an abs path and have any symlinks resolved before calling this function .