/* Returns -EINVAL if @maxargs is too large (maximum is six).  */
int task_current_syscall(struct task_struct *target, long *callno, unsigned long args[6], unsigned int maxargs, unsigned long *sp, unsigned long *pc)
/* Returns -EINVAL if @maxargs is too large (maximum is six).  */
int task_current_syscall(struct task_struct *target, long *callno, unsigned long args[6], unsigned int maxargs, unsigned long *sp, unsigned long *pc)
{
	long state;
	unsigned long ncsw;
	if (unlikely(maxargs > 6))
		return -EINVAL;
	if (target == current)
		return collect_syscall(target, callno, args, maxargs, sp, pc);
	state = target->state;
	if (unlikely(!state))
		return -EAGAIN;
	ncsw = wait_task_inactive(target, state);
	if (unlikely(!ncsw) ||
	    unlikely(collect_syscall(target, callno, args, maxargs, sp, pc)) ||
	    unlikely(wait_task_inactive(target, state) != ncsw))
		return -EAGAIN;
	return 0;
}