MCPcopy Create free account
hub / github.com/apache/nuttx / load_module

Function load_module

binfmt/binfmt_loadmodule.c:160–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158 ****************************************************************************/
159
160int 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

Callers 1

exec_internalFunction · 0.85

Calls 5

load_default_priorityFunction · 0.85
envpath_initFunction · 0.85
envpath_nextFunction · 0.85
load_absmoduleFunction · 0.85
envpath_releaseFunction · 0.85

Tested by

no test coverage detected