kfusd/kfusd.c
static int fusd_fops_call_send(fusd_file_t *fusd_file_arg,
                               fusd_msg_t *fusd_msg, struct fusd_transaction **transaction)
{
	fusd_dev_t *fusd_dev;
	fusd_file_t *fusd_file;

	/* I check this just in case, shouldn't be necessary. */
	GET_FUSD_FILE_AND_DEV(fusd_file_arg, fusd_file, fusd_dev);

	/* make sure message is sane */
	if ((fusd_msg->data == NULL) != (fusd_msg->datalen == 0)) {
		RDEBUG(2, "fusd_fops_call: data pointer and datalen mismatch");
		return -EINVAL;
	}

	/* fill the rest of the structure */
	fusd_msg->parm.fops_msg.pid = current->pid;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
	fusd_msg->parm.fops_msg.uid = current_uid();
	fusd_msg->parm.fops_msg.gid = current_gid();
#endif
	fusd_msg->parm.fops_msg.flags = fusd_file->file->f_flags;
	fusd_msg->parm.fops_msg.offset = fusd_file->file->f_pos;
	fusd_msg->parm.fops_msg.device_info = fusd_dev->private_data;
	fusd_msg->parm.fops_msg.private_info = fusd_file->private_data;
	fusd_msg->parm.fops_msg.fusd_file = fusd_file;
	fusd_msg->parm.fops_msg.transid = atomic_inc_and_ret(&last_transid);

	/* set up certain state depending on if we expect a reply */
	switch (fusd_msg->cmd) {

		case FUSD_FOPS_CALL: /* common case */
			fusd_msg->parm.fops_msg.hint = fusd_file->index;

			break;

		case FUSD_FOPS_CALL_DROPREPLY:
			/* nothing needed */
			break;

		case FUSD_FOPS_NONBLOCK:
			fusd_msg->parm.fops_msg.hint = fusd_file->index;
			break;

		default:
			RDEBUG(0, "whoa - fusd_fops_call_send got msg with unknown cmd!");
			break;
	}

	if (transaction != NULL) {
		int retval;
		retval = fusd_add_transaction(fusd_file, fusd_msg->parm.fops_msg.transid, fusd_msg->subcmd,
		                              fusd_msg->parm.fops_msg.length, transaction);
		if (retval < 0)
			return retval;
	}

	/* now add the message to the device's outgoing queue! */
	return send_to_dev(fusd_dev, fusd_msg, 0);


	/* bizarre errors go straight here */
invalid_dev:
invalid_file:
	RDEBUG(0, "fusd_fops_call: got invalid device or file!!!!");
	return -EPIPE;
}
/*
 * fusd_fops_call_send: send a fusd_msg into userspace.
 *
 * NOTE - we are already holding the lock on fusd_file_arg when this
 * function is called, but NOT the lock on the fusd_dev
 */
send a fusd_msg into userspace.
NOTE - we are already holding the lock on fusd_file_arg when this
function is called, but NOT the lock on the fusd_dev
send a fusd_msg into userspace . NOTE - we are already holding the lock on fusd_file_arg when this function is called but NOT the lock on the fusd_dev
static int fusd_fops_call_send(fusd_file_t *fusd_file_arg,
                               fusd_msg_t *fusd_msg, struct fusd_transaction **transaction)
{
	fusd_dev_t *fusd_dev;
	fusd_file_t *fusd_file;
	GET_FUSD_FILE_AND_DEV(fusd_file_arg, fusd_file, fusd_dev);
	if ((fusd_msg->data == NULL) != (fusd_msg->datalen == 0)) {
		RDEBUG(2, "fusd_fops_call: data pointer and datalen mismatch");
		return -EINVAL;
	}
	fusd_msg->parm.fops_msg.pid = current->pid;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
	fusd_msg->parm.fops_msg.uid = current_uid();
	fusd_msg->parm.fops_msg.gid = current_gid();
#endif
	fusd_msg->parm.fops_msg.flags = fusd_file->file->f_flags;
	fusd_msg->parm.fops_msg.offset = fusd_file->file->f_pos;
	fusd_msg->parm.fops_msg.device_info = fusd_dev->private_data;
	fusd_msg->parm.fops_msg.private_info = fusd_file->private_data;
	fusd_msg->parm.fops_msg.fusd_file = fusd_file;
	fusd_msg->parm.fops_msg.transid = atomic_inc_and_ret(&last_transid);
	switch (fusd_msg->cmd) {
		case FUSD_FOPS_CALL: 
			fusd_msg->parm.fops_msg.hint = fusd_file->index;
			break;
		case FUSD_FOPS_CALL_DROPREPLY:
			break;
		case FUSD_FOPS_NONBLOCK:
			fusd_msg->parm.fops_msg.hint = fusd_file->index;
			break;
		default:
			RDEBUG(0, "whoa - fusd_fops_call_send got msg with unknown cmd!");
			break;
	}
	if (transaction != NULL) {
		int retval;
		retval = fusd_add_transaction(fusd_file, fusd_msg->parm.fops_msg.transid, fusd_msg->subcmd,
		                              fusd_msg->parm.fops_msg.length, transaction);
		if (retval < 0)
			return retval;
	}
	return send_to_dev(fusd_dev, fusd_msg, 0);
invalid_dev:
invalid_file:
	RDEBUG(0, "fusd_fops_call: got invalid device or file!!!!");
	return -EPIPE;
}
static int fusd_fops_call_send ( fusd_file_t * fusd_file_arg , fusd_msg_t * fusd_msg , struct fusd_transaction * * transaction ) { fusd_dev_t * fusd_dev ; fusd_file_t * fusd_file ; GET_FUSD_FILE_AND_DEV ( fusd_file_arg , fusd_file , fusd_dev ) ; if ( ( fusd_msg -> data == NULL ) != ( fusd_msg -> datalen == 0 ) ) { RDEBUG ( 2 , " " ) ; return - EINVAL ; } fusd_msg -> parm . fops_msg . pid = current -> pid ; #if LINUX_VERSION_CODE < KERNEL_VERSION ( 2 , 6 , 29 ) fusd_msg -> parm . fops_msg . uid = current_uid ( ) ; fusd_msg -> parm . fops_msg . gid = current_gid ( ) ; #endif fusd_msg -> parm . fops_msg . flags = fusd_file -> file -> f_flags ; fusd_msg -> parm . fops_msg . offset = fusd_file -> file -> f_pos ; fusd_msg -> parm . fops_msg . device_info = fusd_dev -> private_data ; fusd_msg -> parm . fops_msg . private_info = fusd_file -> private_data ; fusd_msg -> parm . fops_msg . fusd_file = fusd_file ; fusd_msg -> parm . fops_msg . transid = atomic_inc_and_ret ( & last_transid ) ; switch ( fusd_msg -> cmd ) { case FUSD_FOPS_CALL : fusd_msg -> parm . fops_msg . hint = fusd_file -> index ; break ; case FUSD_FOPS_CALL_DROPREPLY : break ; case FUSD_FOPS_NONBLOCK : fusd_msg -> parm . fops_msg . hint = fusd_file -> index ; break ; default : RDEBUG ( 0 , " " ) ; break ; } if ( transaction != NULL ) { int retval ; retval = fusd_add_transaction ( fusd_file , fusd_msg -> parm . fops_msg . transid , fusd_msg -> subcmd , fusd_msg -> parm . fops_msg . length , transaction ) ; if ( retval < 0 ) return retval ; } return send_to_dev ( fusd_dev , fusd_msg , 0 ) ; invalid_dev : invalid_file : RDEBUG ( 0 , " " ) ; return - EPIPE ; }
fusd_fops_call_send: send a fusd_msg into userspace.
fusd_fops_call_send : send a fusd_msg into userspace .
/* I check this just in case, shouldn't be necessary. */ /* make sure message is sane */ /* fill the rest of the structure */ /* set up certain state depending on if we expect a reply */ /* common case */ /* nothing needed */ /* now add the message to the device's outgoing queue! */ /* bizarre errors go straight here */