MCPcopy Create free account
hub / github.com/F-Stack/f-stack / exec_args_add_fname

Function exec_args_add_fname

freebsd/kern/kern_exec.c:1437–1467  ·  view source on GitHub ↗

* A set to functions to fill struct image args. * * NOTE: exec_args_add_fname() must be called (possibly with a NULL * fname) before the other functions. All exec_args_add_arg() calls must * be made before any exec_args_add_env() calls. exec_args_adjust_args() * may be called any time after exec_args_add_fname(). * * exec_args_add_fname() - install path to be executed * exec_args_add_arg

Source from the content-addressed store, hash-verified

1435 * allow new arguments to be prepended
1436 */
1437int
1438exec_args_add_fname(struct image_args *args, const char *fname,
1439 enum uio_seg segflg)
1440{
1441 int error;
1442 size_t length;
1443
1444 KASSERT(args->fname == NULL, ("fname already appended"));
1445 KASSERT(args->endp == NULL, ("already appending to args"));
1446
1447 if (fname != NULL) {
1448 args->fname = args->buf;
1449 error = segflg == UIO_SYSSPACE ?
1450 copystr(fname, args->fname, PATH_MAX, &length) :
1451 copyinstr(fname, args->fname, PATH_MAX, &length);
1452 if (error != 0)
1453 return (error == ENAMETOOLONG ? E2BIG : error);
1454 } else
1455 length = 0;
1456
1457 /* Set up for _arg_*()/_env_*() */
1458 args->endp = args->buf + length;
1459 /* begin_argv must be set and kept updated */
1460 args->begin_argv = args->endp;
1461 KASSERT(exec_map_entry_size - length >= ARG_MAX,
1462 ("too little space remaining for arguments %zu < %zu",
1463 exec_map_entry_size - length, (size_t)ARG_MAX));
1464 args->stringspace = ARG_MAX;
1465
1466 return (0);
1467}
1468
1469static int
1470exec_args_add_str(struct image_args *args, const char *str,

Callers 2

exec_copyin_argsFunction · 0.85
start_initFunction · 0.85

Calls 2

copystrFunction · 0.85
copyinstrFunction · 0.50

Tested by

no test coverage detected