aboutgitcodelistschat:MatrixIRC
path: root/cooker/calls
diff options
context:
space:
mode:
Diffstat (limited to 'cooker/calls')
-rw-r--r--cooker/calls/fs.c190
-rw-r--r--cooker/calls/net.c92
2 files changed, 260 insertions, 22 deletions
diff --git a/cooker/calls/fs.c b/cooker/calls/fs.c
index 4135be9..29c653a 100644
--- a/cooker/calls/fs.c
+++ b/cooker/calls/fs.c
@@ -60,6 +60,7 @@ swapoff
#define _GNU_SOURCE
#include <sys/stat.h>
+#include <sys/xattr.h>
#include <fcntl.h>
#include <linux/limits.h>
@@ -200,10 +201,199 @@ static struct arg chown_args[] = {
{ 0 }
};
+static struct num xattr_flags[] = {
+ { "create", XATTR_CREATE },
+ { "replace", XATTR_REPLACE },
+ { 0 },
+};
+
+static struct arg fsetxattr_args[] = {
+ { 0,
+ {
+ "fd", INT, FD, 0, 0,
+ { 0 }
+ }
+ },
+ { 0,
+ {
+ "path", FDPATH, FD, 0, 0,
+ { 0 }
+ }
+ },
+ { 1,
+ {
+ "name", STRING, 0, 0,
+ XATTR_NAME_MAX,
+ { 0 }
+ }
+ },
+ { 2,
+ {
+ "value", STRING, WBUF, 0,
+ XATTR_SIZE_MAX,
+ { 0 }
+ }
+ },
+ { 3,
+ {
+ "size", LONG, 0, 0, 0,
+ { 0 }
+ }
+ },
+ { 4,
+ {
+ "flags", INT, FLAGS, 0, 0,
+ { .d_num = xattr_flags }
+ }
+ },
+ { 0 },
+};
+
+static struct arg fremovexattr_args[] = {
+ { 0,
+ {
+ "fd", INT, FD, 0, 0,
+ { 0 }
+ }
+ },
+ { 0,
+ {
+ "path", FDPATH, FD, 0, 0,
+ { 0 }
+ }
+ },
+ { 1,
+ {
+ "name", STRING, 0, 0,
+ XATTR_NAME_MAX,
+ { 0 }
+ }
+ },
+ { 0 },
+};
+
+/* enum fid_type copied (without comments) from include/linux/exportfs.h of
+ * Linux 6.9. Just copied and pasted like that? Is that an acceptable practice?
+ * Well then, let's say I _vendored_ it.
+ */
+enum fid_type {
+ FILEID_ROOT = 0,
+ FILEID_INO32_GEN = 1,
+ FILEID_INO32_GEN_PARENT = 2,
+ FILEID_BTRFS_WITHOUT_PARENT = 0x4d,
+ FILEID_BTRFS_WITH_PARENT = 0x4e,
+ FILEID_BTRFS_WITH_PARENT_ROOT = 0x4f,
+ FILEID_UDF_WITHOUT_PARENT = 0x51,
+ FILEID_UDF_WITH_PARENT = 0x52,
+ FILEID_NILFS_WITHOUT_PARENT = 0x61,
+ FILEID_NILFS_WITH_PARENT = 0x62,
+ FILEID_FAT_WITHOUT_PARENT = 0x71,
+ FILEID_FAT_WITH_PARENT = 0x72,
+ FILEID_INO64_GEN = 0x81,
+ FILEID_INO64_GEN_PARENT = 0x82,
+ FILEID_LUSTRE = 0x97,
+ FILEID_BCACHEFS_WITHOUT_PARENT = 0xb1,
+ FILEID_BCACHEFS_WITH_PARENT = 0xb2,
+ FILEID_KERNFS = 0xfe,
+ FILEID_INVALID = 0xff,
+};
+
+static struct num handle_types[] = {
+ { "root", FILEID_ROOT },
+ { "ino32_gen", FILEID_INO32_GEN },
+ { "ino32_gen_parent", FILEID_INO32_GEN_PARENT },
+ { "btrfs_with_parent", FILEID_BTRFS_WITH_PARENT },
+ { "btrfs_without_parent", FILEID_BTRFS_WITHOUT_PARENT },
+ { "udf_with_parent", FILEID_UDF_WITH_PARENT },
+ { "udf_without_parent", FILEID_UDF_WITHOUT_PARENT },
+ { "fat_with_parent", FILEID_FAT_WITH_PARENT },
+ { "fat_without_parent", FILEID_FAT_WITHOUT_PARENT },
+ { "ino64_gen", FILEID_INO64_GEN },
+ { "ino64_gen_parent", FILEID_INO64_GEN_PARENT },
+ { "lustre", FILEID_LUSTRE },
+ { "bcachefs_with_parent", FILEID_BCACHEFS_WITH_PARENT },
+ { "bcachefs_without_parent", FILEID_BCACHEFS_WITHOUT_PARENT },
+ { "kernfs", FILEID_KERNFS },
+ { "invalid", FILEID_INVALID },
+ { 0 },
+};
+
+static struct field file_handle[] = {
+ {
+ "handle_bytes", LONG, SIZE,
+ offsetof(struct file_handle, handle_bytes),
+ 0,
+ { .d_size = (intptr_t)&file_handle[2] },
+ },
+ {
+ "handle_type", INT, FLAGS,
+ offsetof(struct file_handle, handle_type),
+ 0,
+ { .d_num = handle_types },
+ },
+
+ {
+ "f_handle", STRING, 0,
+ offsetof(struct file_handle, f_handle),
+ MAX_HANDLE_SZ,
+ { 0 },
+ },
+ { 0 }
+};
+
+static struct num open_flags[] = {
+ { "rdonly", O_RDONLY },
+ { "wronly", O_WRONLY },
+ { "rdwr", O_RDWR },
+ { 0 },
+};
+
+static struct arg open_by_handle_at_args[] = {
+ { 0,
+ {
+ "mount", FDMOUNT, 0, 0,
+ 0,
+ { 0 }
+ }
+ },
+ { 0,
+ {
+ "mount_fd", INT, 0, 0,
+ 0,
+ { 0 }
+ }
+ },
+ { 1,
+ {
+ "handle", STRUCT, 0, 0,
+ sizeof(struct file_handle) + MAX_HANDLE_SZ,
+ { .d_struct = file_handle }
+ }
+ },
+ { 2,
+ {
+ "flags", INT, MASK | FLAGS, 0,
+ 0,
+ { .d_num = open_flags }
+ }
+ },
+ { 0 },
+};
+
struct call syscalls_fs[] = {
{ __NR_mknod, "mknod", mknod_args },
{ __NR_mknodat, "mknodat", mknodat_args },
+
{ __NR_chown, "chown", chown_args },
{ __NR_lchown, "lchown", chown_args },
+
+ { __NR_fsetxattr, "fsetxattr", fsetxattr_args },
+ /* fd, name, value, size, flags */
+
+ { __NR_fremovexattr, "fremovexattr", fremovexattr_args },
+ /* fd, name */
+
+ { __NR_open_by_handle_at, "open_by_handle_at", open_by_handle_at_args },
+
{ 0 },
};
diff --git a/cooker/calls/net.c b/cooker/calls/net.c
index 94b13cd..0688467 100644
--- a/cooker/calls/net.c
+++ b/cooker/calls/net.c
@@ -65,22 +65,23 @@ static struct num socket_flags[] = {
};
static struct num protocols[] = {
- { "ip", IPPROTO_IP },
- { "icmp", IPPROTO_ICMP },
- { "igmp", IPPROTO_IGMP },
- { "tcp", IPPROTO_TCP },
- { "udp", IPPROTO_UDP },
- { "ipv6", IPPROTO_IPV6 },
- { "gre", IPPROTO_GRE },
- { "esp", IPPROTO_ESP },
- { "ah", IPPROTO_AH },
- { "sctp", IPPROTO_SCTP },
- { "udplite", IPPROTO_UDPLITE },
- { "mpls", IPPROTO_MPLS },
- { "raw", IPPROTO_RAW },
- { "mptcp", IPPROTO_MPTCP },
+ { "ip", IPPROTO_IP },
+ { "icmp", IPPROTO_ICMP },
+ { "igmp", IPPROTO_IGMP },
+ { "tcp", IPPROTO_TCP },
+ { "udp", IPPROTO_UDP },
+ { "ipv6", IPPROTO_IPV6 },
+ { "gre", IPPROTO_GRE },
+ { "esp", IPPROTO_ESP },
+ { "ah", IPPROTO_AH },
+ { "sctp", IPPROTO_SCTP },
+ { "udplite", IPPROTO_UDPLITE },
+ { "mpls", IPPROTO_MPLS },
+ { "raw", IPPROTO_RAW },
+ { "mptcp", IPPROTO_MPTCP },
- { "nl_route", NETLINK_ROUTE },
+ { "nl_route", NETLINK_ROUTE },
+ { "nl_netfilter", NETLINK_NETFILTER },
{ 0 },
};
@@ -261,7 +262,7 @@ static struct num send_flags[] = {
static struct arg send_args[] = {
{ 0,
{
- "fd", INT, 0,
+ "fd", INT, FD,
0,
0,
{ 0 },
@@ -297,7 +298,7 @@ static struct arg send_args[] = {
static struct arg sendto_args[] = {
{ 0,
{
- "fd", INT, 0,
+ "fd", INT, FD,
0,
0,
{ 0 },
@@ -346,7 +347,7 @@ static struct arg sendto_args[] = {
{ 0 }
};
-static struct select sendmsg_name_select = {
+static struct select msg_name_select = {
&connect_family, { .d_num = connect_addr_select_family }
};
@@ -355,13 +356,13 @@ static struct field sendmsg_msghdr[] = {
"name", SELECT, 0,
offsetof(struct msghdr, msg_name),
sizeof(struct sockaddr_storage),
- { .d_select = &sendmsg_name_select },
+ { .d_select = &msg_name_select },
},
{
"namelen", LONG, SIZE,
offsetof(struct msghdr, msg_namelen),
0,
- { .d_size = (intptr_t)&sendmsg_name_select },
+ { .d_size = (intptr_t)&msg_name_select },
},
{
"iov", STRING, WBUF | IOV,
@@ -400,7 +401,7 @@ static struct field sendmsg_msghdr[] = {
static struct arg sendmsg_args[] = {
{ 0,
{
- "fd", INT, 0,
+ "fd", INT, FD,
0,
0,
{ 0 },
@@ -425,6 +426,53 @@ static struct arg sendmsg_args[] = {
{ 0 }
};
+static struct field recvmsg_msghdr[] = {
+ {
+ "name", SELECT, 0,
+ offsetof(struct msghdr, msg_name),
+ sizeof(struct sockaddr_storage),
+ { .d_select = &msg_name_select },
+ },
+ {
+ "namelen", LONG, SIZE,
+ offsetof(struct msghdr, msg_namelen),
+ 0,
+ { .d_size = (intptr_t)&msg_name_select },
+ },
+ {
+ "iov", STRING, RBUF | IOV,
+ offsetof(struct msghdr, msg_iov),
+ BUFSIZ,
+ { .d_iovlen = offsetof(struct msghdr, msg_iovlen) -
+ offsetof(struct msghdr, msg_iov) },
+ },
+ {
+ "iovlen", LONG, 0,
+ offsetof(struct msghdr, msg_iovlen),
+ 0,
+ { 0 },
+ },
+ {
+ "control", STRING, 0,
+ offsetof(struct msghdr, msg_control),
+ BUFSIZ,
+ { 0 },
+ },
+ {
+ "controllen", LONG, SIZE,
+ offsetof(struct msghdr, msg_controllen),
+ 0,
+ { 0 },
+ },
+ {
+ "flags", INT, 0,
+ offsetof(struct msghdr, msg_flags),
+ 0,
+ { 0 },
+ },
+ { 0 }
+};
+
static struct arg recvmsg_args[] = {
{ 0,
{
@@ -439,7 +487,7 @@ static struct arg recvmsg_args[] = {
"msg", STRUCT, 0,
0,
sizeof(struct msghdr),
- { .d_struct = sendmsg_msghdr },
+ { .d_struct = recvmsg_msghdr },
},
},
{ 2,