* @brief Logs a message to the system logging mechanism. * * This system call writes a log message to the system log for diagnostic or informational purposes. * The message is specified by the `log` parameter, and its size is given by the `size` parameter. * The logging mechanism is typically used for tracking system events, debugging, or reporting errors. * * @param[in] log A pointer to t
| 4407 | * logging system is properly initialized before invoking this function. |
| 4408 | */ |
| 4409 | sysret_t sys_log(const char* log, int size) |
| 4410 | { |
| 4411 | char *klog = RT_NULL; |
| 4412 | rt_device_t console = RT_NULL; |
| 4413 | |
| 4414 | if (!lwp_user_accessable((void *)log, size)) |
| 4415 | return -EFAULT; |
| 4416 | |
| 4417 | klog = kmem_get(size); |
| 4418 | if (klog == RT_NULL) |
| 4419 | { |
| 4420 | return -ENOMEM; |
| 4421 | } |
| 4422 | |
| 4423 | if (lwp_get_from_user((void *)klog, (void *)log, size) != size) |
| 4424 | { |
| 4425 | kmem_put(klog); |
| 4426 | return -EINVAL; |
| 4427 | } |
| 4428 | |
| 4429 | console = rt_console_get_device(); |
| 4430 | |
| 4431 | if (console && __sys_log_enable) |
| 4432 | { |
| 4433 | rt_device_write(console, -1, klog, size); |
| 4434 | } |
| 4435 | |
| 4436 | kmem_put(klog); |
| 4437 | |
| 4438 | return 0; |
| 4439 | } |
| 4440 | |
| 4441 | /** |
| 4442 | * @brief Retrieves information about a file or directory. |
nothing calls this directly
no test coverage detected