From fb30aae90d7ae9985003537ea6b8164a8d281efe Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Wed, 17 Nov 2021 19:18:56 +0900 Subject: [PATCH] tarfs: throw EROFS on create --- kernel/vfs/tarfs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/vfs/tarfs.c b/kernel/vfs/tarfs.c index affb06a7..f547dc44 100644 --- a/kernel/vfs/tarfs.c +++ b/kernel/vfs/tarfs.c @@ -7,6 +7,7 @@ * of the NCSA / University of Illinois License - see LICENSE.md * Copyright (C) 2018 K. Lange */ +#include #include #include #include @@ -358,6 +359,10 @@ static ssize_t readlink_tarfs(fs_node_t * node, char * buf, size_t size) { } +static int create_ret_rofs(fs_node_t *parent, char *name, mode_t permission) { + return -EROFS; +} + static fs_node_t * file_from_ustar(struct tarfs * self, struct ustar * file, unsigned int offset) { fs_node_t * fs = malloc(sizeof(fs_node_t)); memset(fs, 0, sizeof(fs_node_t)); @@ -377,6 +382,7 @@ static fs_node_t * file_from_ustar(struct tarfs * self, struct ustar * file, uns fs->flags = FS_DIRECTORY; fs->readdir = readdir_tarfs; fs->finddir = finddir_tarfs; + fs->create = create_ret_rofs; } else if (file->type[0] == '1') { //debug_print(ERROR, "Hardlink detected"); /* go through file and find target, reassign inode to point to that */ @@ -479,6 +485,7 @@ static fs_node_t * tar_mount(const char * device, const char * mount_path) { root->mask = 0555; root->readdir = readdir_tar_root; root->finddir = finddir_tar_root; + root->create = create_ret_rofs; root->flags = FS_DIRECTORY; root->device = self;