#!/sbin/openrc-run

start()
{
	ebegin "Mounting 9p sockets"

	for virtio in $(find /sys/bus/virtio/drivers/9pnet_virtio -name 'virtio*')	
	do
		TAG=$(cat $virtio/mount_tag)
		case $TAG in
		"socket")
			mkdir -p /Socket
			mount -t 9p -o trans=virtio,dfltuid=1001,dfltgid=50,version=9p2000,msize=32768 socket /Socket
			;;
		"plan9")
			mkdir -p /Mac
			mount -t 9p -o trans=virtio,dfltuid=1001,dfltgid=50,version=9p2000.u,msize=32768 plan9 /Mac
			;;
		"fuse")
			mkdir -p /Transfuse
			mkdir -p /Mac
			mount -t 9p -o trans=virtio,dfltuid=1001,dfltgid=50,version=9p2000,msize=32768 fuse /Transfuse
			;;
		"db")
			mkdir -p /Database
			mount -t 9p -o trans=virtio,dfltuid=1001,dfltgid=50,version=9p2000 db /Database
		esac

	done

        eend 0
}
