#
# Dependencies of this sub-command
#
make_files_n_each_mntpnts_depends()
{
	echo ""
}

#
# Sub-command: make files on each mount points for each clients
#
subcmd_make_files_n_each_mntpnts()
{
	log_debug "subcmd_make_files_n_each_mntpnts"

	check_argc $# 5
	check_hostid any $HOSTID
	exec_remote_host_agent $HOSTID - systest::gfarm2fs::make_files_n_each_mntpnts "$@"
	[ $? -ne 0 ] && log_error "gfservice systest::gfarm2fs::make_files_n_each_mntpnts failed"

	log_debug "end subcmd_make_files_n_each_mntpnts"
}

#
# Dependencies of this sub-command agent
#
make_files_n_each_mntpnts_agent_depends()
{
	echo "systest::gfarm2fs::make_file"
	echo "systest::gfarm2fs::make_files"
}

#
# Sub-command: systest::gfarm2fs::make_files_n_each_mntpnts
# Make files in target dir on each mount points.
#
subcmd_make_files_n_each_mntpnts_agent()
{
	log_debug "subcmd_make_files_n_each_mntpnts_agent MNTDIR_PREFIX=$1" \
		"COUNT=$2 TARGET_DIR=$3"

	MNTDIR_PREFIX=$1
	COUNT=$2
	TARGET_DIR=$3
	shift 3

	PROCESS_LIST=""

	MNTDIR_PREFIX_ESC=`echo $MNTDIR_PREFIX | sed -e 's|/|\\\\/|g'`
	for I in `df|awk "/$MNTDIR_PREFIX_ESC/{print \\\$6}"|sort|head -$COUNT`; do
		make_files "$I/$PROGHOST/$I/$TARGET_DIR" "$@" &
		PROCESS_LIST="$PROCESS_LIST $!"
	done

	for PROCESS in $PROCESS_LIST; do
		wait $PROCESS
		[ $? -ne 0 ] && log_error "make_files_n_each_mntpnts failed"
	done

	log_debug "end subcmd_make_files_n_each_mntpnts_agent"
}
