Serenity Operating System
at master 27 lines 868 B view raw
1/* 2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <AK/StringView.h> 8#include <Kernel/FileSystem/VirtualFileSystem.h> 9#include <Kernel/Process.h> 10 11namespace Kernel { 12 13ErrorOr<FlatPtr> Process::sys$mknod(Userspace<Syscall::SC_mknod_params const*> user_params) 14{ 15 VERIFY_NO_PROCESS_BIG_LOCK(this); 16 TRY(require_promise(Pledge::dpath)); 17 auto params = TRY(copy_typed_from_user(user_params)); 18 19 auto credentials = this->credentials(); 20 if (!credentials->is_superuser() && !is_regular_file(params.mode) && !is_fifo(params.mode) && !is_socket(params.mode)) 21 return EPERM; 22 auto path = TRY(get_syscall_path_argument(params.path)); 23 TRY(VirtualFileSystem::the().mknod(credentials, path->view(), params.mode & ~umask(), params.dev, current_directory())); 24 return 0; 25} 26 27}