| 150 | ****************************************************************************/ |
| 151 | |
| 152 | int exec_module(FAR struct binary_s *binp, |
| 153 | FAR const char *filename, FAR char * const *argv, |
| 154 | FAR char * const *envp, |
| 155 | FAR const posix_spawn_file_actions_t *actions, |
| 156 | FAR const posix_spawnattr_t *attr, |
| 157 | bool spawn) |
| 158 | { |
| 159 | FAR struct tcb_s *tcb; |
| 160 | #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) |
| 161 | FAR struct arch_addrenv_s *addrenv = &binp->addrenv->addrenv; |
| 162 | FAR void *vheap; |
| 163 | char name[PATH_MAX]; |
| 164 | #endif |
| 165 | FAR void *stackaddr = NULL; |
| 166 | pid_t pid; |
| 167 | int ret; |
| 168 | |
| 169 | /* Sanity checking */ |
| 170 | |
| 171 | #ifdef CONFIG_DEBUG_FEATURES |
| 172 | if (!binp || !binp->entrypt || binp->stacksize <= 0) |
| 173 | { |
| 174 | return -EINVAL; |
| 175 | } |
| 176 | #endif |
| 177 | |
| 178 | binfo("Executing %s\n", filename); |
| 179 | |
| 180 | /* Allocate a TCB for the new task. */ |
| 181 | |
| 182 | tcb = kmm_zalloc(sizeof(struct tcb_s)); |
| 183 | if (!tcb) |
| 184 | { |
| 185 | return -ENOMEM; |
| 186 | } |
| 187 | |
| 188 | ret = binfmt_copyargv(&argv, argv); |
| 189 | if (ret < 0) |
| 190 | { |
| 191 | goto errout_with_tcb; |
| 192 | } |
| 193 | |
| 194 | /* Make a copy of the environment here */ |
| 195 | |
| 196 | if (envp == NULL) |
| 197 | { |
| 198 | envp = environ; |
| 199 | } |
| 200 | |
| 201 | ret = binfmt_copyenv(&envp, envp); |
| 202 | if (ret < 0) |
| 203 | { |
| 204 | goto errout_with_args; |
| 205 | } |
| 206 | |
| 207 | ret = binfmt_copyactions(&actions, actions); |
| 208 | if (ret < 0) |
| 209 | { |
no test coverage detected