* @brief Sends a message through a communication channel. * * This system call is used to send a message through a specified communication channel identified * by the file descriptor `fd`. The message to be sent is provided in the `data` parameter. * It allows inter-process or inter-thread communication by transmitting the given message over * the open channel. * * @param[in] fd The fil
| 4143 | * to errors, data loss, or undefined behavior. |
| 4144 | */ |
| 4145 | sysret_t sys_channel_send(int fd, rt_channel_msg_t data) |
| 4146 | { |
| 4147 | rt_size_t ret = 0; |
| 4148 | rt_channel_msg_t kdata = RT_NULL; |
| 4149 | |
| 4150 | if (!lwp_user_accessable((void *)data, sizeof(*data))) |
| 4151 | { |
| 4152 | return -EFAULT; |
| 4153 | } |
| 4154 | |
| 4155 | kdata = kmem_get(sizeof(*data)); |
| 4156 | if (kdata == RT_NULL) |
| 4157 | return -ENOMEM; |
| 4158 | |
| 4159 | if (lwp_get_from_user(kdata, data, sizeof(*kdata)) != sizeof(*kdata)) |
| 4160 | { |
| 4161 | kmem_put(kdata); |
| 4162 | return -EFAULT; |
| 4163 | } |
| 4164 | |
| 4165 | ret = lwp_channel_send(FDT_TYPE_LWP, fd, kdata); |
| 4166 | |
| 4167 | kmem_put(kdata); |
| 4168 | |
| 4169 | return ret; |
| 4170 | } |
| 4171 | |
| 4172 | /** |
| 4173 | * @brief Sends a message through a communication channel and waits for a response with a timeout. |
nothing calls this directly
no test coverage detected