aboutgitcodelistschat:MatrixIRC
path: root/cooker/gluten.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2023-12-21 12:06:05 +0100
committerStefano Brivio <sbrivio@redhat.com>2023-12-21 12:45:36 +0100
commitbdbec30a849807fb5e6841a38cfe0d168e5962b9 (patch)
tree210949d96b4d764235c1c5b81ad2eebb61681f95 /cooker/gluten.c
parentc72c2493de8990c3a3b4780ec1429a3c359c121e (diff)
downloadseitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.tar
seitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.tar.gz
seitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.tar.bz2
seitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.tar.lz
seitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.tar.xz
seitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.tar.zst
seitan-bdbec30a849807fb5e6841a38cfe0d168e5962b9.zip
seitan: Add netlink, sendto()/sendmsg(), iovec handling, demo with routes
A bit rough at the moment, but it does the trick. Bonus: setsockopt() (with magic values only, not used in any demo yet). Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'cooker/gluten.c')
-rw-r--r--cooker/gluten.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/cooker/gluten.c b/cooker/gluten.c
index 4d3aea5..69c9384 100644
--- a/cooker/gluten.c
+++ b/cooker/gluten.c
@@ -146,6 +146,7 @@ void gluten_add_attr(struct gluten_ctx *g, enum attr_type type, intptr_t id,
union value gluten_get_attr(struct gluten_ctx *g, enum attr_type type,
intptr_t id)
{
+ union value missing = { 0 };
int i;
for (i = 0; i < ATTRS_MAX && g->attrs[i].type; i++) {
@@ -153,8 +154,8 @@ union value gluten_get_attr(struct gluten_ctx *g, enum attr_type type,
return g->attrs[i].v;
}
- die(" attribute '%p' not found", id);
- return g->attrs[0].v; /* Pro forma, not actually happening */
+ debug(" attribute '%p' not found", id);
+ return missing;
}
/**
@@ -163,8 +164,8 @@ union value gluten_get_attr(struct gluten_ctx *g, enum attr_type type,
*/
void gluten_init(struct gluten_ctx *g)
{
- g->ip.type = g->lr.type = g->mr.type = OFFSET_INSTRUCTION;
g->ip.offset = g->lr.offset = g->mr.offset = 0;
+ g->ip.type = g->lr.type = g->mr.type = OFFSET_INSTRUCTION;
g->dp.type = OFFSET_DATA;
g->cp.type = OFFSET_RO_DATA;
}
@@ -185,3 +186,12 @@ void gluten_write(struct gluten_ctx *g, const char *path)
close(fd);
}
+
+void gluten_relocation_add(struct gluten_ctx *g, struct gluten_offset offset)
+{
+ g->g.header.relocation[g->rel_count++] = offset;
+ debug(" Added relocation for %s: %u", gluten_offset_name[offset.type],
+ offset.offset);
+ if (g->rel_count >= 256)
+ die("Too many relocations");
+}