From 17899c0559511ecfcfab3248cdf18024b6850846 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Sat, 5 Oct 2024 12:01:34 +0200 Subject: [PATCH] Flock: container create command confusion rectified --- flock/container.c | 21 +++++++++++---------- flock/ctl.c | 34 +++++++++++++++++----------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/flock/container.c b/flock/container.c index bc61c1a7..dbf19fba 100644 --- a/flock/container.c +++ b/flock/container.c @@ -362,7 +362,7 @@ container_mainloop(int fd) SYSCALL(lstat, orig, &s); if (!(s.st_mode & S_IRWXO)) { - log(L_INFO "ignoring unusable device %s", e->d_name); +// log(L_INFO "ignoring unusable device %s", e->d_name); continue; } @@ -373,7 +373,7 @@ container_mainloop(int fd) case S_IFCHR: case S_IFBLK: case S_IFREG: - log(L_INFO "bindmounting device %s", e->d_name); +// log(L_INFO "bindmounting device %s", e->d_name); SYSCALL(close, SYSCALL(open, path, O_WRONLY | O_CREAT, 0666)); int me = mount(orig, mpnt, NULL, MS_BIND, NULL); if (me < 0) @@ -386,7 +386,8 @@ container_mainloop(int fd) break; default: - log(L_INFO "ignoring device %s", e->d_name); +// log(L_INFO "ignoring device %s", e->d_name); + break; } } } @@ -1004,7 +1005,7 @@ hcf_parse(byte *buf, int size) ctx->target_len = ctx->value; break; - case 3: /* workdir */ + case 3: /* basedir */ if (ctx->type != 3) CBOR_PARSER_ERROR("Expected string, got %u", ctx->type); @@ -1012,25 +1013,25 @@ hcf_parse(byte *buf, int size) CBOR_PARSER_ERROR("Variable length string not supported yet"); if (ccf.workdir) - CBOR_PARSER_ERROR("Duplicate argument 1 / workdir"); + CBOR_PARSER_ERROR("Duplicate argument 1 / basedir"); ASSERT_DIE(!ctx->target_buf); - ccf.workdir = ctx->target_buf = lp_alloc(ctx->lp, ctx->value + 1); + ccf.basedir = ctx->target_buf = lp_alloc(ctx->lp, ctx->value + 1); ctx->target_len = ctx->value; break; - case 4: /* basedir */ + case 4: /* workdir */ if (ctx->type != 3) CBOR_PARSER_ERROR("Expected string, got %u", ctx->type); if (ctx->tflags & CPT_VARLEN) CBOR_PARSER_ERROR("Variable length string not supported yet"); - if (ccf.basedir) - CBOR_PARSER_ERROR("Duplicate argument 1 / basedir"); + if (ccf.workdir) + CBOR_PARSER_ERROR("Duplicate argument 2 / workdir"); ASSERT_DIE(!ctx->target_buf); - ccf.basedir = ctx->target_buf = lp_alloc(ctx->lp, ctx->value + 1); + ccf.workdir = ctx->target_buf = lp_alloc(ctx->lp, ctx->value + 1); ctx->target_len = ctx->value; break; diff --git a/flock/ctl.c b/flock/ctl.c index 3c1232b5..4059208b 100644 --- a/flock/ctl.c +++ b/flock/ctl.c @@ -188,22 +188,7 @@ hcs_parse(struct hcs_parser_context *htx, const byte *buf, s64 size) htx->major_state = 501; break; - case 504: /* machine creation argument 2: workdir */ - if (ctx->type != 2) - CBOR_PARSER_ERROR("Expected bytestring, got %u", ctx->type); - - if (ctx->tflags & CPT_VARLEN) - CBOR_PARSER_ERROR("Variable length string not supported yet"); - - if (htx->cfg.container.workdir) - CBOR_PARSER_ERROR("Duplicate argument 2 / workdir"); - - ASSERT_DIE(!ctx->target_buf); - htx->cfg.container.workdir = ctx->target_buf = lp_alloc(ctx->lp, ctx->value + 1); - ctx->target_len = ctx->value; - break; - - case 505: /* machine creation argument 3: basedir */ + case 504: /* machine creation argument 2: basedir */ if (ctx->type != 2) CBOR_PARSER_ERROR("Expected bytestring, got %u", ctx->type); @@ -211,13 +196,28 @@ hcs_parse(struct hcs_parser_context *htx, const byte *buf, s64 size) CBOR_PARSER_ERROR("Variable length string not supported yet"); if (htx->cfg.container.basedir) - CBOR_PARSER_ERROR("Duplicate argument 3 / basedir"); + CBOR_PARSER_ERROR("Duplicate argument 2 / basedir"); ASSERT_DIE(!ctx->target_buf); htx->cfg.container.basedir = ctx->target_buf = lp_alloc(ctx->lp, ctx->value + 1); ctx->target_len = ctx->value; break; + case 505: /* machine creation argument 3: workdir */ + if (ctx->type != 2) + CBOR_PARSER_ERROR("Expected bytestring, got %u", ctx->type); + + if (ctx->tflags & CPT_VARLEN) + CBOR_PARSER_ERROR("Variable length string not supported yet"); + + if (htx->cfg.container.workdir) + CBOR_PARSER_ERROR("Duplicate argument 3 / workdir"); + + ASSERT_DIE(!ctx->target_buf); + htx->cfg.container.workdir = ctx->target_buf = lp_alloc(ctx->lp, ctx->value + 1); + ctx->target_len = ctx->value; + break; + case 601: /* machine shutdown argument */ if (ctx->type != 0) CBOR_PARSER_ERROR("Expected integer, got %u", ctx->type);