From c1b8d9ca93ba2147202ae995f67f3752ff6eafcb Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Wed, 14 Jun 2023 14:06:10 +0200 Subject: demo: update demo --- demo/connect.hjson | 10 ++++++++-- demo/mknod.hjson | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/demo/connect.hjson b/demo/connect.hjson index 3bf0747..de4c119 100644 --- a/demo/connect.hjson +++ b/demo/connect.hjson @@ -1,7 +1,7 @@ [ - { /* connect to another path (/var/run/pr-helper.sock -> /tmp/demo.sock) */ + { /* connect to another path (/cool.sock -> /tmp/demo.sock) */ "match": [ - { "connect": { "addr": { "family": "unix", "path": "/var/run/pr-helper.sock" }, "fd": { "tag": "fd" } } } + { "connect": { "addr": { "family": "unix", "path": "/cool.sock" }, "fd": { "tag": "fd" } } } ], "call": [ { "socket": { "family": "unix", "type": "stream", "flags": 0, "protocol": 0 }, "ret": "new_fd" }, @@ -21,5 +21,11 @@ { "connect": { "addr": { "family": "unix", "path": "/error.sock" } } } ], "return": { "value": 0, "error": -1 } + }, + { /* Continue all the other connect syscall */ + "match": [ + { "connect": {} } + ], + "return": { "continue": true } } ] diff --git a/demo/mknod.hjson b/demo/mknod.hjson index 7055aee..40b5b8b 100644 --- a/demo/mknod.hjson +++ b/demo/mknod.hjson @@ -28,6 +28,6 @@ }, "context": { "mnt": "caller" } }, - "return": { "value": 0 } + "return": { "value": 0, "error": 0 } } ] -- cgit v1.2.3 From 7954fe5d9627defcb5f73194c60d992df4137c10 Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Wed, 14 Jun 2023 14:06:27 +0200 Subject: cooker: fix initialization and variable type --- cooker/emit.c | 2 -- cooker/parse.c | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cooker/emit.c b/cooker/emit.c index 1a7f3a9..8dc3e82 100644 --- a/cooker/emit.c +++ b/cooker/emit.c @@ -356,8 +356,6 @@ void emit_return(struct gluten_ctx *g, struct gluten_offset v, ret->desc = o; debug(" %i: OP_RETURN:", g->ip.offset); - debug(" \t val=(%s %d) errno=%d cont=%s", gluten_offset_name[v.type], - v.offset, error, cont ? "true" : "false"); if (++g->ip.offset > INST_MAX) die("Too many instructions"); diff --git a/cooker/parse.c b/cooker/parse.c index 46ca123..36c2649 100644 --- a/cooker/parse.c +++ b/cooker/parse.c @@ -98,7 +98,7 @@ static void handle_return(struct gluten_ctx *g, JSON_Value *value) struct gluten_offset data = NULL_OFFSET, error = NULL_OFFSET; JSON_Object *obj = json_value_get_object(value); union value vv = NO_VALUE, ve = NO_VALUE; - const char *tag_error, *tag_value; + const char *tag_error = NULL, *tag_value = NULL; JSON_Value *jvalue; bool cont = false; char buf[BUFSIZ]; @@ -108,8 +108,8 @@ static void handle_return(struct gluten_ctx *g, JSON_Value *value) jvalue = json_object_get_value(obj, "error"); if (json_value_get_type(jvalue) == JSONNumber) { - ve.v_u32 = json_value_get_number(jvalue); - error = emit_data(g, U32, sizeof(ve.v_u32), &ve); + ve.v_int = json_value_get_number(jvalue); + error = emit_data(g, INT, sizeof(ve.v_int), &ve); } else if ((tag_error = json_object_get_string(obj, "error"))) { error = gluten_get_tag(g, tag_error); } @@ -134,13 +134,13 @@ static void handle_return(struct gluten_ctx *g, JSON_Value *value) if (tag_value) n += snprintf(buf + n, BUFSIZ - n, "tag %s", tag_value); else - n += snprintf(buf + n, BUFSIZ - n, "%lu", vv.v_u64); + n += snprintf(buf + n, BUFSIZ - n, "%ld", vv.v_u64); n = snprintf(buf, BUFSIZ, " , error "); if (tag_error) n += snprintf(buf + n, BUFSIZ - n, "tag %s", tag_error); else - n += snprintf(buf + n, BUFSIZ - n, "%u", ve.v_u32); + n += snprintf(buf + n, BUFSIZ - n, "%d", ve.v_int); } else { snprintf(buf, BUFSIZ, " emit return: continue"); } -- cgit v1.2.3