Link Search Menu Expand Document

write_mbx_421

long write_mbx_421(const char __user *name, const unsigned char __user *data, unsigned long offset, unsigned long n);

Description

Copies up to n bytes from data to offset bytes into mailbox. You must validate here correct access to both user-space memory and kernel space memory. You must also verify that all the boundaries make sense. If the length and/or offset would result in a write outside the bounds of the memory available on a mailbox, you should return an error. There is no partial write.

Parameters

  • name: Same as create_mbx. Must refer to an existing mailbox
  • data: A user-space pointer to data to write to the mailbox
  • offset: How many bytes into the mailbox’s memory the data will be written
  • n: The length of data

Return

Returns the number of bytes written (which should be equal to the data length n) on success, and an appropriate error code on failure. Data or offsets with negative lengths or other invalid values shall be rejected as invalid and cause an appropriate error to be returned. If the offset plus the length of data exceeds the size of the mailbox -ENOSPC should be returned and the mailbox should not be modified.

In case of an error the function must return an appropriate error code as discussed in the system description.