diff options
author | Alice Frosi <afrosi@redhat.com> | 2023-09-01 10:16:36 +0200 |
---|---|---|
committer | Alice Frosi <afrosi@redhat.com> | 2023-09-01 10:37:04 +0200 |
commit | 59f7f7c241253293c25e001c9340f1deeb138311 (patch) | |
tree | 4be7c160cbec552f5d5d3dcd88e85c1b98407749 /cooker/call.c | |
parent | aecd6adbd2f5ce12437215fe2e64e004d28db86b (diff) | |
download | seitan-59f7f7c241253293c25e001c9340f1deeb138311.tar seitan-59f7f7c241253293c25e001c9340f1deeb138311.tar.gz seitan-59f7f7c241253293c25e001c9340f1deeb138311.tar.bz2 seitan-59f7f7c241253293c25e001c9340f1deeb138311.tar.lz seitan-59f7f7c241253293c25e001c9340f1deeb138311.tar.xz seitan-59f7f7c241253293c25e001c9340f1deeb138311.tar.zst seitan-59f7f7c241253293c25e001c9340f1deeb138311.zip |
cooker, seitan: add sched_setscheduler
The sched_setscheduler requires to set the pid of the process we want to
change the priority, this adds a new metadata for getting the target pid
at runtime.
Add a couple of syscalls for the scheduler in the string parsing.
Signed-off-by: Alice Frosi <afrosi@redhat.com>
Diffstat (limited to 'cooker/call.c')
-rw-r--r-- | cooker/call.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/cooker/call.c b/cooker/call.c index 173bdb4..a09194a 100644 --- a/cooker/call.c +++ b/cooker/call.c @@ -16,6 +16,15 @@ #include "parse.h" #include "util.h" +static bool is_metadata_obj(JSON_Object *metadata) +{ + if (!metadata) + return false; + return ((!json_object_get_string(metadata, "caller")) || + (!json_object_get_string(metadata, "set")) || + (!json_object_get_string(metadata, "get"))); +} + /* TODO: refactor and simplify this horrible function */ static union value parse_metadata(struct gluten_ctx *g, struct field *f, struct gluten_offset **base_offset, @@ -29,10 +38,12 @@ static union value parse_metadata(struct gluten_ctx *g, struct field *f, if ((tag = json_object_get_string(metadata, "caller"))) { debug(" args reference value at runtime '%s' with metadata %s", tag, tag); (*base_offset)->type = OFFSET_METADATA; - if (strcmp(tag, "uid") == 0) { + if (!strcmp(tag, "uid")) { (*base_offset)->offset = UID_TARGET; - } else if (strcmp(tag, "gid") == 0) { + } else if (!strcmp(tag, "gid")) { (*base_offset)->offset = GID_TARGET; + } else if (!strcmp(tag, "pid")) { + (*base_offset)->offset = PID_TARGET; } else { die(" unrecognized metadata tag: %s", tag); } @@ -151,9 +162,7 @@ static union value parse_field(struct gluten_ctx *g, struct arg *args, if (offset.type != OFFSET_NULL) offset.offset += f->offset; - - if (json_value_get_type(jvalue) == JSONObject && - (tmp1 = json_value_get_object(jvalue))) + if (!(tmp1 = json_value_get_object(jvalue)) && is_metadata_obj(tmp1)) v = parse_metadata(g, f, &base_offset, offset, tmp1, dry_run, add); if (v.v_num == 0) |