Skip to content

Commit

Permalink
config: rc[].argv[] -> rc[].args[]
Browse files Browse the repository at this point in the history
Makes it clear that these are the arguments, with going into C-land
semantics of argv.
  • Loading branch information
mato committed Dec 21, 2015
1 parent d5b8a82 commit 9ad7635
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app-tools/rumprun
Expand Up @@ -313,7 +313,7 @@ json_store_rc ()
bin=$1
shift
read line <<EOM
"rc": [ { "bin": "${bin}", "argv": $(json_array "$@") } ]
"rc": [ { "bin": "${bin}", "args": $(json_array "$@") } ]
EOM
json_append_ln $line
}
Expand Down
16 changes: 8 additions & 8 deletions doc/config.md
Expand Up @@ -34,19 +34,19 @@ not considered to be part of the configuration.

"rc": [
{
"bin" : <string>,
"argv" : [ <string>, ... ],
"runmode" : "& OR |" (optional)
"bin": <string>,
"args": [ <string>, ... ],
"runmode": "& OR |"
},
...
]

Each element of `rc` describes a single program, in the order in which they
are baked into the unikernel image.
Each element of `rc` describes a single program, **in the order in which they
are baked into the unikernel image**.

* _bin_: Passed to the corresponding program as `argv[0]`.
* _argv[]_: Passed to the corresponding program as `argv[1..N]`.
* _runmode_: Defines how the corresponding program will be invoked. _Optional_
* _bin_: The name of the program. Passed to the program as `argv[0]`.
* _args[]_: Arguments for the program. Passed to the program as `argv[1..N]`.
* _runmode_: Defines how the program will be invoked. _Optional_
* `&`: run program in background.
* `|`: pipe output of program to next defined program.
* _default_: run program in foreground and wait for it to exit successfully
Expand Down
28 changes: 14 additions & 14 deletions lib/librumprun_base/config.c
Expand Up @@ -147,22 +147,22 @@ handle_bin(jvalue *v, const char *loc)
{
struct rumprun_exec *rre;
char *binname;
jvalue *v_bin, *v_argv, *v_runmode, **v_arg;
jvalue *v_bin, *v_args, *v_runmode, **v_arg;
int rreflags;
size_t nargv;
size_t nargs;

jexpect(jobject, v, __func__);

/* process and validate data */
v_bin = v_argv = v_runmode = NULL;
v_bin = v_args = v_runmode = NULL;
for (jvalue **i = v->u.v; *i; ++i) {

if (strcmp((*i)->n, "bin") == 0) {
jexpect(jstring, *i, __func__);
v_bin = *i;
} else if (strcmp((*i)->n, "argv") == 0) {
} else if (strcmp((*i)->n, "args") == 0) {
jexpect(jarray, *i, __func__);
v_argv = *i;
v_args = *i;
} else if (strcmp((*i)->n, "runmode") == 0) {
jexpect(jstring, *i, __func__);
v_runmode = *i;
Expand Down Expand Up @@ -191,24 +191,24 @@ handle_bin(jvalue *v, const char *loc)
rreflags = 0;
}

nargv = 0;
if (v_argv) {
for (jvalue **i = v_argv->u.v; *i; ++i) {
nargs = 0;
if (v_args) {
for (jvalue **i = v_args->u.v; *i; ++i) {
jexpect(jstring, *i, __func__);
nargv++;
nargs++;
}
}

/* ok, we got everything. save into rumprun_exec structure */
rre = malloc(sizeof(*rre) + (2 + nargv) * sizeof(char *));
rre = malloc(sizeof(*rre) + (2 + nargs) * sizeof(char *));
if (rre == NULL)
err(1, "%s: malloc(rumprun_exec)", __func__);
rre->rre_flags = rreflags;
rre->rre_argc = 1 + nargv;
rre->rre_argc = 1 + nargs;
rre->rre_argv[0] = binname;
for (v_arg = v_argv->u.v, nargv = 1; *v_arg; ++v_arg, ++nargv) {
rre->rre_argv[nargv] = strdup((*v_arg)->u.s);
if (!rre->rre_argv[nargv])
for (v_arg = v_args->u.v, nargs = 1; *v_arg; ++v_arg, ++nargs) {
rre->rre_argv[nargs] = strdup((*v_arg)->u.s);
if (!rre->rre_argv[nargs])
err(1, "%s: strdup", __func__);
}
rre->rre_argv[rre->rre_argc] = NULL;
Expand Down

0 comments on commit 9ad7635

Please sign in to comment.