#!/bin/sh

set -eu

# A mock of mount(8) for the ikvswitch unit tests: it fills the mount
# point with the fake switch rootfs from ${IKV_MOCK_ROOTFS}, which is
# what the script will then customize. Requires IKV_MOCK_ROOTFS to be
# set.

: "${IKV_MOCK_ROOTFS:?IKV_MOCK_ROOTFS must be set}"

# Simulated failure, for the cleanup trap test.
if [ -n "${IKV_MOCK_FAIL_MOUNT:-}" ] ; then
	echo "Simulated mount failure"
	exit 1
fi

cp -a "${IKV_MOCK_ROOTFS}/." "$2/"
