From c38fccbc867019d6c063be1c1d8137edfe52f8de Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Wed, 7 Jun 2023 23:02:23 +0200 Subject: mknod/mknodat values, initial support for MASK flag, OP_BITWISE Signed-off-by: Stefano Brivio --- cooker/calls/fs.c | 63 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 12 deletions(-) (limited to 'cooker/calls') diff --git a/cooker/calls/fs.c b/cooker/calls/fs.c index cfc0091..469dd88 100644 --- a/cooker/calls/fs.c +++ b/cooker/calls/fs.c @@ -58,13 +58,44 @@ swapoff #include #include -#include +#define _GNU_SOURCE #include +#include #include #include "../cooker.h" #include "../calls.h" +static struct num modes[] = { + { "S_ISUID", S_ISUID }, + { "S_ISGID", S_ISGID }, + { "S_IRWXU", S_IRWXU }, + { "S_IRUSR", S_IRUSR }, + { "S_IWUSR", S_IWUSR }, + { "S_IXUSR", S_IXUSR }, + { "S_IRWXG", S_IRWXG }, + { "S_IRGRP", S_IRGRP }, + { "S_IWGRP", S_IWGRP }, + { "S_IXGRP", S_IXGRP }, + { "S_IRWXO", S_IRWXO }, + { "S_IROTH", S_IROTH }, + { "S_IWOTH", S_IWOTH }, + { "S_IXOTH", S_IXOTH }, + { "S_ISVTX", S_ISVTX }, + { 0 }, +}; + +static struct num types[] = { + { "S_IFSOCK", S_IFSOCK }, + { "S_IFLNK", S_IFLNK }, + { "S_IFREG", S_IFREG }, + { "S_IFBLK", S_IFBLK }, + { "S_IFDIR", S_IFDIR }, + { "S_IFCHR", S_IFCHR }, + { "S_IFIFO", S_IFIFO }, + { 0 }, +}; + static struct arg mknod_args[] = { { 0, { @@ -75,9 +106,16 @@ static struct arg mknod_args[] = { }, { 1, { - "mode", U32 /* TODO */, 0, + "mode", INT, FLAGS | MASK, 0, 0, - { 0 /* TODO */ }, + { .d_num = modes }, + } + }, + { 1, + { + "type", INT, FLAGS | MASK, + 0, 0, + { .d_num = types }, } }, { 2, @@ -98,13 +136,7 @@ static struct arg mknod_args[] = { }; static struct arg mknodat_args[] = { - { 0, - { - "dirfd", UNDEF, 0, - 0, 1 /* TODO: PATH_MAX */, - { 0 } - } - }, + /* No dirfd: we only support absolute paths at the moment */ { 1, { "path", STRING, 0, @@ -114,9 +146,16 @@ static struct arg mknodat_args[] = { }, { 2, { - "mode", UNDEF /* TODO */, FLAGS, + "mode", INT, FLAGS | MASK, + 0, 0, + { .d_num = modes }, + } + }, + { 2, + { + "type", INT, FLAGS | MASK, 0, 0, - { 0 /* TODO */ }, + { .d_num = types }, } }, { 3, -- cgit v1.2.3