| 158 | ****************************************************************************/ |
| 159 | |
| 160 | int load_module(FAR struct binary_s *bin, FAR const char *filename, |
| 161 | FAR const struct symtab_s *exports, int nexports) |
| 162 | { |
| 163 | int ret = -EINVAL; |
| 164 | |
| 165 | /* Verify that we were provided something to work with */ |
| 166 | |
| 167 | #ifdef CONFIG_DEBUG_FEATURES |
| 168 | if (bin && filename) |
| 169 | #endif |
| 170 | { |
| 171 | /* Set the default priority of the new program. */ |
| 172 | |
| 173 | ret = load_default_priority(bin); |
| 174 | if (ret < 0) |
| 175 | { |
| 176 | return ret; |
| 177 | } |
| 178 | |
| 179 | /* Were we given a relative path? Or an absolute path to the file to |
| 180 | * be loaded? Absolute paths start with '/'. |
| 181 | */ |
| 182 | |
| 183 | #ifdef CONFIG_LIBC_ENVPATH |
| 184 | if (filename[0] != '/') |
| 185 | { |
| 186 | FAR char *fullpath; |
| 187 | ENVPATH_HANDLE handle; |
| 188 | |
| 189 | ret = -ENOENT; |
| 190 | |
| 191 | /* Initialize to traverse the PATH variable */ |
| 192 | |
| 193 | handle = envpath_init("PATH"); |
| 194 | if (handle) |
| 195 | { |
| 196 | /* Get the next absolute file path */ |
| 197 | |
| 198 | while ((fullpath = envpath_next(handle, filename)) != NULL) |
| 199 | { |
| 200 | /* Try to load the file at this path */ |
| 201 | |
| 202 | ret = load_absmodule(bin, fullpath, exports, nexports); |
| 203 | |
| 204 | /* Free the allocated fullpath */ |
| 205 | |
| 206 | lib_free(fullpath); |
| 207 | |
| 208 | /* Break out of the loop with ret == OK on success */ |
| 209 | |
| 210 | if (ret == OK) |
| 211 | { |
| 212 | break; |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | /* Release the traversal handle */ |
| 217 |
no test coverage detected