src/libruntime/mailbox.c
int nanvix_mailbox_write(int mbxid, const void *buf, size_t n)
{
	/* Invalid mailbox ID.*/
	if (!nanvix_mailbox_is_valid(mbxid))
		return (-EINVAL);

	/* Bad mailbox. */
	if (!nanvix_mailbox_is_used(mbxid))
		return (-EINVAL);

	/* Not the owner. */
	if (mailboxes[mbxid].owner != knode_get_num())
		return (-EPERM);

	/*  Invalid mailbox. */
	if (!nanvix_mailbox_is_wronly(mbxid))
		return (-EINVAL);

	/* Invalid buffer. */
	if (buf == NULL)
		return (-EINVAL);

	/* Write. */
	if (kmailbox_write(mailboxes[mbxid].fd, buf, n) < 0)
		return (-EINVAL);

	return (0);
}
/**
 * @todo TODO: provide a detailed description for this function.
 */
@todo TODO: provide a detailed description for this function.
@todo TODO : provide a detailed description for this function .
int nanvix_mailbox_write(int mbxid, const void *buf, size_t n)
{
	if (!nanvix_mailbox_is_valid(mbxid))
		return (-EINVAL);
	if (!nanvix_mailbox_is_used(mbxid))
		return (-EINVAL);
	if (mailboxes[mbxid].owner != knode_get_num())
		return (-EPERM);
	if (!nanvix_mailbox_is_wronly(mbxid))
		return (-EINVAL);
	if (buf == NULL)
		return (-EINVAL);
	if (kmailbox_write(mailboxes[mbxid].fd, buf, n) < 0)
		return (-EINVAL);
	return (0);
}
int nanvix_mailbox_write ( int mbxid , const void * buf , size_t n ) { if ( ! nanvix_mailbox_is_valid ( mbxid ) ) return ( - EINVAL ) ; if ( ! nanvix_mailbox_is_used ( mbxid ) ) return ( - EINVAL ) ; if ( mailboxes [ mbxid ] . owner != knode_get_num ( ) ) return ( - EPERM ) ; if ( ! nanvix_mailbox_is_wronly ( mbxid ) ) return ( - EINVAL ) ; if ( buf == NULL ) return ( - EINVAL ) ; if ( kmailbox_write ( mailboxes [ mbxid ] . fd , buf , n ) < 0 ) return ( - EINVAL ) ; return ( 0 ) ; }
@todo TODO: provide a detailed description for this function.
@todo TODO : provide a detailed description for this function .
/* Invalid mailbox ID.*/ /* Bad mailbox. */ /* Not the owner. */ /*  Invalid mailbox. */ /* Invalid buffer. */ /* Write. */