aboutgitcodelistschat:MatrixIRC
path: root/cooker/emit.c
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-06-07 14:07:23 +0200
committerAlice Frosi <afrosi@redhat.com>2023-06-07 15:35:59 +0200
commitb2e31a6e7493c56f923cb7d86f7a8a32940393ec (patch)
tree764d0d6e5853be5b1d99bd0207ffa8f382c4f7cb /cooker/emit.c
parent9812b2002de051f0051383365b2fb9863885bb60 (diff)
downloadseitan-b2e31a6e7493c56f923cb7d86f7a8a32940393ec.tar
seitan-b2e31a6e7493c56f923cb7d86f7a8a32940393ec.tar.gz
seitan-b2e31a6e7493c56f923cb7d86f7a8a32940393ec.tar.bz2
seitan-b2e31a6e7493c56f923cb7d86f7a8a32940393ec.tar.lz
seitan-b2e31a6e7493c56f923cb7d86f7a8a32940393ec.tar.xz
seitan-b2e31a6e7493c56f923cb7d86f7a8a32940393ec.tar.zst
seitan-b2e31a6e7493c56f923cb7d86f7a8a32940393ec.zip
seitan,cooker: op_resolvefd
ops: - update resolvefd with the description - add debug prints cooker: - add emit_resolvefd when match has type FDPATH
Diffstat (limited to 'cooker/emit.c')
-rw-r--r--cooker/emit.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/cooker/emit.c b/cooker/emit.c
index d0928e3..7b1b14d 100644
--- a/cooker/emit.c
+++ b/cooker/emit.c
@@ -164,6 +164,40 @@ void emit_load(struct gluten_ctx *g, struct gluten_offset dst,
}
/**
+ * emit_resolved() - Emit OP_RESOLVEFD instruction: resolve file descriptor with path
+ * @g: gluten context
+ * @fd: offset of the file descriptor value
+ * @path: offset of the path
+ * @path_size: size of the path
+ */
+void emit_resolvefd(struct gluten_ctx *g, struct gluten_offset fd,
+ struct gluten_offset path, size_t path_size)
+{
+ struct op *op = (struct op *)gluten_ptr(&g->g, g->ip);
+ struct op_resolvefd *resfd = &op->op.resfd;
+ struct gluten_offset o;
+ struct resolvefd_desc *desc;
+
+ op->type = OP_RESOLVEDFD;
+ o = gluten_ro_alloc(g, sizeof(struct resolvefd_desc));
+ desc = (struct resolvefd_desc *)gluten_ptr(&g->g, o);
+
+ desc->fd = fd;
+ desc->path = path;
+ desc->path_max = path_size;
+
+ resfd->desc = o;
+
+ debug(" %i: OP_RESOLVEDFD:", g->ip.offset);
+ debug(" \tfd: %s offset=%d", gluten_offset_name[fd.type], fd.offset);
+ debug(" \tpath: %s offset=%d size=%d", gluten_offset_name[path.type],
+ path.offset, path_size);
+
+ if (++g->ip.offset > INST_MAX)
+ die("Too many instructions");
+}
+
+/**
* emit_mask(): Emit OP_MASK instruction: mask and store
* @g: gluten context
* @type: Type of operands
@@ -422,7 +456,7 @@ static struct gluten_offset emit_data_do(struct gluten_ctx *g,
break;
case STRING:
strncpy(p, value->v_str, str_len);
- debug(" C#%i: (%s:%i) %s", g->cp.offset, type_str[type],
+ debug(" C#%i: (%s:%i) %s", ret.offset, type_str[type],
str_len, value->v_str);
break;
@@ -459,6 +493,11 @@ struct gluten_offset emit_data_or(struct gluten_ctx *g,
true);
}
+struct gluten_offset emit_seccomp_data(int index) {
+ struct gluten_offset o = { OFFSET_SECCOMP_DATA, index };
+ return o;
+}
+
static void gluten_link(struct gluten_ctx *g, enum jump_type type,
struct op *start)
{