* @brief Copy process arguments and environment variables from kernel space to user space. * * @param[in] lwp Pointer to the light-weight process structure * @param[in] argc Argument count * @param[in] argv Argument vector * @param[in] envp Environment variables * * @return Pointer to the process auxiliary structure on success * RT_NULL if memory allocation fails or arguments init
| 434 | * 4. Returns the auxiliary structure containing copied data |
| 435 | */ |
| 436 | struct process_aux *argscopy(struct rt_lwp *lwp, int argc, char **argv, char **envp) |
| 437 | { |
| 438 | struct lwp_args_info ai; |
| 439 | rt_err_t error; |
| 440 | struct process_aux *ua; |
| 441 | const char **tail_argv[2] = {0}; |
| 442 | |
| 443 | error = lwp_args_init(&ai); |
| 444 | if (error) |
| 445 | { |
| 446 | return RT_NULL; |
| 447 | } |
| 448 | |
| 449 | if (argc > 0) |
| 450 | { |
| 451 | tail_argv[0] = (void *)argv[argc - 1]; |
| 452 | argv[argc - 1] = NULL; |
| 453 | lwp_args_put(&ai, (void *)argv, LWP_ARGS_TYPE_KARG); |
| 454 | lwp_args_put(&ai, (void *)tail_argv, LWP_ARGS_TYPE_KARG); |
| 455 | } |
| 456 | lwp_args_put(&ai, (void *)envp, LWP_ARGS_TYPE_KENVP); |
| 457 | |
| 458 | ua = lwp_argscopy(lwp, &ai); |
| 459 | lwp_args_detach(&ai); |
| 460 | |
| 461 | return ua; |
| 462 | } |
| 463 | |
| 464 | /** |
| 465 | * @brief Creates and starts a new LWP by loading and executing the specified executable file. |
no test coverage detected