MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / argscopy

Function argscopy

components/lwp/lwp.c:436–462  ·  view source on GitHub ↗

* @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

Source from the content-addressed store, hash-verified

434 * 4. Returns the auxiliary structure containing copied data
435 */
436struct 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.

Callers 1

lwp_execveFunction · 0.85

Calls 4

lwp_args_initFunction · 0.85
lwp_args_putFunction · 0.85
lwp_argscopyFunction · 0.85
lwp_args_detachFunction · 0.85

Tested by

no test coverage detected