diff options
-rw-r--r-- | Kernel/Process.cpp | 12 | ||||
-rw-r--r-- | Kernel/Process.h | 6 | ||||
-rw-r--r-- | Kernel/Syscalls/access.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/chdir.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/chmod.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/chown.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/chroot.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/execve.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/inode_watcher.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/keymap.cpp | 9 | ||||
-rw-r--r-- | Kernel/Syscalls/link.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/mkdir.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/mknod.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/module.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/mount.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/open.cpp | 4 | ||||
-rw-r--r-- | Kernel/Syscalls/readlink.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/realpath.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/rename.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/rmdir.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/stat.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/statvfs.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/unlink.cpp | 2 | ||||
-rw-r--r-- | Kernel/Syscalls/unveil.cpp | 13 | ||||
-rw-r--r-- | Kernel/Syscalls/utime.cpp | 2 |
25 files changed, 42 insertions, 42 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 28bf00063d..d55fbac717 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -434,19 +434,19 @@ Custody& Process::current_directory() return *m_cwd; } -KResultOr<String> Process::get_syscall_path_argument(const char* user_path, size_t path_length) const +KResultOr<NonnullOwnPtr<KString>> Process::get_syscall_path_argument(char const* user_path, size_t path_length) const { if (path_length == 0) return EINVAL; if (path_length > PATH_MAX) return ENAMETOOLONG; - auto copied_string = copy_string_from_user(user_path, path_length); - if (copied_string.is_null()) - return EFAULT; - return copied_string; + auto string_or_error = try_copy_kstring_from_user(user_path, path_length); + if (string_or_error.is_error()) + return string_or_error.error(); + return string_or_error.release_value(); } -KResultOr<String> Process::get_syscall_path_argument(const Syscall::StringArgument& path) const +KResultOr<NonnullOwnPtr<KString>> Process::get_syscall_path_argument(Syscall::StringArgument const& path) const { return get_syscall_path_argument(path.characters, path.length); } diff --git a/Kernel/Process.h b/Kernel/Process.h index acd1b14756..176bcd665d 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -546,12 +546,12 @@ private: KResultOr<siginfo_t> do_waitid(idtype_t idtype, int id, int options); - KResultOr<String> get_syscall_path_argument(const char* user_path, size_t path_length) const; - KResultOr<String> get_syscall_path_argument(Userspace<const char*> user_path, size_t path_length) const + KResultOr<NonnullOwnPtr<KString>> get_syscall_path_argument(const char* user_path, size_t path_length) const; + KResultOr<NonnullOwnPtr<KString>> get_syscall_path_argument(Userspace<const char*> user_path, size_t path_length) const { return get_syscall_path_argument(user_path.unsafe_userspace_ptr(), path_length); } - KResultOr<String> get_syscall_path_argument(const Syscall::StringArgument&) const; + KResultOr<NonnullOwnPtr<KString>> get_syscall_path_argument(const Syscall::StringArgument&) const; bool has_tracee_thread(ProcessID tracer_pid); diff --git a/Kernel/Syscalls/access.cpp b/Kernel/Syscalls/access.cpp index 8151b40e24..98d240b632 100644 --- a/Kernel/Syscalls/access.cpp +++ b/Kernel/Syscalls/access.cpp @@ -16,7 +16,7 @@ KResultOr<int> Process::sys$access(Userspace<const char*> user_path, size_t path auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) return path.error(); - return VFS::the().access(path.value(), mode, current_directory()); + return VFS::the().access(path.value()->view(), mode, current_directory()); } } diff --git a/Kernel/Syscalls/chdir.cpp b/Kernel/Syscalls/chdir.cpp index c85c4eb902..c0aff80211 100644 --- a/Kernel/Syscalls/chdir.cpp +++ b/Kernel/Syscalls/chdir.cpp @@ -17,7 +17,7 @@ KResultOr<int> Process::sys$chdir(Userspace<const char*> user_path, size_t path_ auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) return path.error(); - auto directory_or_error = VFS::the().open_directory(path.value(), current_directory()); + auto directory_or_error = VFS::the().open_directory(path.value()->view(), current_directory()); if (directory_or_error.is_error()) return directory_or_error.error(); m_cwd = *directory_or_error.value(); diff --git a/Kernel/Syscalls/chmod.cpp b/Kernel/Syscalls/chmod.cpp index 6e138c2fea..eb352c5fbd 100644 --- a/Kernel/Syscalls/chmod.cpp +++ b/Kernel/Syscalls/chmod.cpp @@ -17,7 +17,7 @@ KResultOr<int> Process::sys$chmod(Userspace<const char*> user_path, size_t path_ auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) return path.error(); - return VFS::the().chmod(path.value(), mode, current_directory()); + return VFS::the().chmod(path.value()->view(), mode, current_directory()); } KResultOr<int> Process::sys$fchmod(int fd, mode_t mode) diff --git a/Kernel/Syscalls/chown.cpp b/Kernel/Syscalls/chown.cpp index 4e0282c69b..bfb50a666a 100644 --- a/Kernel/Syscalls/chown.cpp +++ b/Kernel/Syscalls/chown.cpp @@ -27,7 +27,7 @@ KResultOr<int> Process::sys$chown(Userspace<const Syscall::SC_chown_params*> use auto path = get_syscall_path_argument(params.path); if (path.is_error()) return path.error(); - return VFS::the().chown(path.value(), params.uid, params.gid, current_directory()); + return VFS::the().chown(path.value()->view(), params.uid, params.gid, current_directory()); } } diff --git a/Kernel/Syscalls/chroot.cpp b/Kernel/Syscalls/chroot.cpp index 4d6a63747c..3313e86020 100644 --- a/Kernel/Syscalls/chroot.cpp +++ b/Kernel/Syscalls/chroot.cpp @@ -19,7 +19,7 @@ KResultOr<int> Process::sys$chroot(Userspace<const char*> user_path, size_t path auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) return path.error(); - auto directory_or_error = VFS::the().open_directory(path.value(), current_directory()); + auto directory_or_error = VFS::the().open_directory(path.value()->view(), current_directory()); if (directory_or_error.is_error()) return directory_or_error.error(); auto directory = directory_or_error.value(); diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 842202b889..394d70958e 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -920,7 +920,7 @@ KResultOr<int> Process::sys$execve(Userspace<const Syscall::SC_execve_params*> u auto path_arg = get_syscall_path_argument(params.path); if (path_arg.is_error()) return path_arg.error(); - path = path_arg.value(); + path = path_arg.value()->view(); } auto copy_user_strings = [](const auto& list, auto& output) { diff --git a/Kernel/Syscalls/inode_watcher.cpp b/Kernel/Syscalls/inode_watcher.cpp index 537301974f..6753f0c2d4 100644 --- a/Kernel/Syscalls/inode_watcher.cpp +++ b/Kernel/Syscalls/inode_watcher.cpp @@ -59,7 +59,7 @@ KResultOr<int> Process::sys$inode_watcher_add_watch(Userspace<const Syscall::SC_ if (path.is_error()) return path.error(); - auto custody_or_error = VFS::the().resolve_path(path.value(), current_directory()); + auto custody_or_error = VFS::the().resolve_path(path.value()->view(), current_directory()); if (custody_or_error.is_error()) return custody_or_error.error(); diff --git a/Kernel/Syscalls/keymap.cpp b/Kernel/Syscalls/keymap.cpp index f0ef269787..0ba64ae214 100644 --- a/Kernel/Syscalls/keymap.cpp +++ b/Kernel/Syscalls/keymap.cpp @@ -36,13 +36,12 @@ KResultOr<int> Process::sys$setkeymap(Userspace<const Syscall::SC_setkeymap_para return EFAULT; auto map_name = get_syscall_path_argument(params.map_name); - if (map_name.is_error()) { + if (map_name.is_error()) return map_name.error(); - } - if (map_name.value().length() > map_name_max_size) { + if (map_name.value()->length() > map_name_max_size) return ENAMETOOLONG; - } - HIDManagement::the().set_maps(character_map_data, map_name.value()); + + HIDManagement::the().set_maps(character_map_data, map_name.value()->view()); return 0; } diff --git a/Kernel/Syscalls/link.cpp b/Kernel/Syscalls/link.cpp index 49b05c3c17..13f8dc07d9 100644 --- a/Kernel/Syscalls/link.cpp +++ b/Kernel/Syscalls/link.cpp @@ -37,7 +37,7 @@ KResultOr<int> Process::sys$symlink(Userspace<const Syscall::SC_symlink_params*> auto linkpath = get_syscall_path_argument(params.linkpath); if (linkpath.is_error()) return linkpath.error(); - return VFS::the().symlink(target.value(), linkpath.value(), current_directory()); + return VFS::the().symlink(target.value()->view(), linkpath.value()->view(), current_directory()); } } diff --git a/Kernel/Syscalls/mkdir.cpp b/Kernel/Syscalls/mkdir.cpp index 28fb0c2114..8af8348543 100644 --- a/Kernel/Syscalls/mkdir.cpp +++ b/Kernel/Syscalls/mkdir.cpp @@ -16,6 +16,6 @@ KResultOr<int> Process::sys$mkdir(Userspace<const char*> user_path, size_t path_ auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) return path.error(); - return VFS::the().mkdir(path.value(), mode & ~umask(), current_directory()); + return VFS::the().mkdir(path.value()->view(), mode & ~umask(), current_directory()); } } diff --git a/Kernel/Syscalls/mknod.cpp b/Kernel/Syscalls/mknod.cpp index d354089b4a..5d3861c341 100644 --- a/Kernel/Syscalls/mknod.cpp +++ b/Kernel/Syscalls/mknod.cpp @@ -21,7 +21,7 @@ KResultOr<int> Process::sys$mknod(Userspace<const Syscall::SC_mknod_params*> use auto path = get_syscall_path_argument(params.path); if (path.is_error()) return path.error(); - return VFS::the().mknod(path.value(), params.mode & ~umask(), params.dev, current_directory()); + return VFS::the().mknod(path.value()->view(), params.mode & ~umask(), params.dev, current_directory()); } } diff --git a/Kernel/Syscalls/module.cpp b/Kernel/Syscalls/module.cpp index 8b1ad64833..1ab7dd2ef0 100644 --- a/Kernel/Syscalls/module.cpp +++ b/Kernel/Syscalls/module.cpp @@ -25,7 +25,7 @@ KResultOr<int> Process::sys$module_load(Userspace<const char*> user_path, size_t auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) return path.error(); - auto description_or_error = VFS::the().open(path.value(), O_RDONLY, 0, current_directory()); + auto description_or_error = VFS::the().open(path.value()->view(), O_RDONLY, 0, current_directory()); if (description_or_error.is_error()) return description_or_error.error(); auto& description = description_or_error.value(); diff --git a/Kernel/Syscalls/mount.cpp b/Kernel/Syscalls/mount.cpp index f9ad4ac934..917d6968b4 100644 --- a/Kernel/Syscalls/mount.cpp +++ b/Kernel/Syscalls/mount.cpp @@ -119,7 +119,7 @@ KResultOr<int> Process::sys$umount(Userspace<const char*> user_mountpoint, size_ if (mountpoint.is_error()) return mountpoint.error(); - auto custody_or_error = VFS::the().resolve_path(mountpoint.value(), current_directory()); + auto custody_or_error = VFS::the().resolve_path(mountpoint.value()->view(), current_directory()); if (custody_or_error.is_error()) return custody_or_error.error(); diff --git a/Kernel/Syscalls/open.cpp b/Kernel/Syscalls/open.cpp index 8af325ff89..4239839fd1 100644 --- a/Kernel/Syscalls/open.cpp +++ b/Kernel/Syscalls/open.cpp @@ -43,7 +43,7 @@ KResultOr<int> Process::sys$open(Userspace<const Syscall::SC_open_params*> user_ if (path.is_error()) return path.error(); - dbgln_if(IO_DEBUG, "sys$open(dirfd={}, path='{}', options={}, mode={})", dirfd, path.value(), options, mode); + dbgln_if(IO_DEBUG, "sys$open(dirfd={}, path='{}', options={}, mode={})", dirfd, path.value()->view(), options, mode); int fd = alloc_fd(); if (fd < 0) return fd; @@ -62,7 +62,7 @@ KResultOr<int> Process::sys$open(Userspace<const Syscall::SC_open_params*> user_ base = base_description->custody(); } - auto result = VFS::the().open(path.value(), options, mode & ~umask(), *base); + auto result = VFS::the().open(path.value()->view(), options, mode & ~umask(), *base); if (result.is_error()) return result.error(); auto description = result.value(); diff --git a/Kernel/Syscalls/readlink.cpp b/Kernel/Syscalls/readlink.cpp index 0305f55174..ad331a1033 100644 --- a/Kernel/Syscalls/readlink.cpp +++ b/Kernel/Syscalls/readlink.cpp @@ -23,7 +23,7 @@ KResultOr<int> Process::sys$readlink(Userspace<const Syscall::SC_readlink_params if (path.is_error()) return path.error(); - auto result = VFS::the().open(path.value(), O_RDONLY | O_NOFOLLOW_NOERROR, 0, current_directory()); + auto result = VFS::the().open(path.value()->view(), O_RDONLY | O_NOFOLLOW_NOERROR, 0, current_directory()); if (result.is_error()) return result.error(); auto description = result.value(); diff --git a/Kernel/Syscalls/realpath.cpp b/Kernel/Syscalls/realpath.cpp index c58b3443a8..5bbe29db7b 100644 --- a/Kernel/Syscalls/realpath.cpp +++ b/Kernel/Syscalls/realpath.cpp @@ -23,7 +23,7 @@ KResultOr<int> Process::sys$realpath(Userspace<const Syscall::SC_realpath_params if (path.is_error()) return path.error(); - auto custody_or_error = VFS::the().resolve_path(path.value(), current_directory()); + auto custody_or_error = VFS::the().resolve_path(path.value()->view(), current_directory()); if (custody_or_error.is_error()) return custody_or_error.error(); auto& custody = custody_or_error.value(); diff --git a/Kernel/Syscalls/rename.cpp b/Kernel/Syscalls/rename.cpp index 22fda00580..4aaea17db2 100644 --- a/Kernel/Syscalls/rename.cpp +++ b/Kernel/Syscalls/rename.cpp @@ -22,7 +22,7 @@ KResultOr<int> Process::sys$rename(Userspace<const Syscall::SC_rename_params*> u auto new_path = get_syscall_path_argument(params.new_path); if (new_path.is_error()) return new_path.error(); - return VFS::the().rename(old_path.value(), new_path.value(), current_directory()); + return VFS::the().rename(old_path.value()->view(), new_path.value()->view(), current_directory()); } } diff --git a/Kernel/Syscalls/rmdir.cpp b/Kernel/Syscalls/rmdir.cpp index 627c32536e..921871f441 100644 --- a/Kernel/Syscalls/rmdir.cpp +++ b/Kernel/Syscalls/rmdir.cpp @@ -16,7 +16,7 @@ KResultOr<int> Process::sys$rmdir(Userspace<const char*> user_path, size_t path_ auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) return path.error(); - return VFS::the().rmdir(path.value(), current_directory()); + return VFS::the().rmdir(path.value()->view(), current_directory()); } } diff --git a/Kernel/Syscalls/stat.cpp b/Kernel/Syscalls/stat.cpp index d75f6a677f..810daed284 100644 --- a/Kernel/Syscalls/stat.cpp +++ b/Kernel/Syscalls/stat.cpp @@ -47,7 +47,7 @@ KResultOr<int> Process::sys$stat(Userspace<const Syscall::SC_stat_params*> user_ return EINVAL; base = base_description->custody(); } - auto metadata_or_error = VFS::the().lookup_metadata(path.value(), *base, params.follow_symlinks ? 0 : O_NOFOLLOW_NOERROR); + auto metadata_or_error = VFS::the().lookup_metadata(path.value()->view(), *base, params.follow_symlinks ? 0 : O_NOFOLLOW_NOERROR); if (metadata_or_error.is_error()) return metadata_or_error.error(); stat statbuf; diff --git a/Kernel/Syscalls/statvfs.cpp b/Kernel/Syscalls/statvfs.cpp index 2f6d4d3553..5103567e2a 100644 --- a/Kernel/Syscalls/statvfs.cpp +++ b/Kernel/Syscalls/statvfs.cpp @@ -80,7 +80,7 @@ KResultOr<int> Process::sys$statvfs(Userspace<const Syscall::SC_statvfs_params*> if (path.is_error()) return path.error(); - return do_statvfs(path.value(), params.buf); + return do_statvfs(path.value()->view(), params.buf); } KResultOr<int> Process::sys$fstatvfs(int fd, statvfs* buf) diff --git a/Kernel/Syscalls/unlink.cpp b/Kernel/Syscalls/unlink.cpp index 8e8538d7c8..4eb5f99d35 100644 --- a/Kernel/Syscalls/unlink.cpp +++ b/Kernel/Syscalls/unlink.cpp @@ -16,7 +16,7 @@ KResultOr<int> Process::sys$unlink(Userspace<const char*> user_path, size_t path auto path = get_syscall_path_argument(user_path, path_length); if (path.is_error()) return path.error(); - return VFS::the().unlink(path.value(), current_directory()); + return VFS::the().unlink(path.value()->view(), current_directory()); } } diff --git a/Kernel/Syscalls/unveil.cpp b/Kernel/Syscalls/unveil.cpp index 9ccee90315..9e4257964c 100644 --- a/Kernel/Syscalls/unveil.cpp +++ b/Kernel/Syscalls/unveil.cpp @@ -32,11 +32,12 @@ KResultOr<int> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params*> u if (params.permissions.length > 5) return EINVAL; - auto path = get_syscall_path_argument(params.path); - if (path.is_error()) - return path.error(); + auto path_or_error = get_syscall_path_argument(params.path); + if (path_or_error.is_error()) + return path_or_error.error(); + auto& path = *path_or_error.value(); - if (path.value().is_empty() || path.value().characters()[0] != '/') + if (path.is_empty() || !path.view().starts_with('/')) return EINVAL; auto permissions = copy_string_from_user(params.permissions); @@ -74,11 +75,11 @@ KResultOr<int> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params*> u // If this case is encountered, the parent node of the path is returned and the custody of that inode is used instead. RefPtr<Custody> parent_custody; // Parent inode in case of ENOENT String new_unveiled_path; - auto custody_or_error = VFS::the().resolve_path_without_veil(path.value(), root_directory(), &parent_custody); + auto custody_or_error = VFS::the().resolve_path_without_veil(path.view(), root_directory(), &parent_custody); if (!custody_or_error.is_error()) { new_unveiled_path = custody_or_error.value()->absolute_path(); } else if (custody_or_error.error() == -ENOENT && parent_custody && (new_permissions & UnveilAccess::CreateOrRemove)) { - String basename = LexicalPath(path.value()).basename(); + String basename = LexicalPath(path.view()).basename(); new_unveiled_path = String::formatted("{}/{}", parent_custody->absolute_path(), basename); } else { // FIXME Should this be EINVAL? diff --git a/Kernel/Syscalls/utime.cpp b/Kernel/Syscalls/utime.cpp index 31c22d0468..f7ec599339 100644 --- a/Kernel/Syscalls/utime.cpp +++ b/Kernel/Syscalls/utime.cpp @@ -25,7 +25,7 @@ KResultOr<int> Process::sys$utime(Userspace<const char*> user_path, size_t path_ // Not a bug! buf = { now, now }; } - return VFS::the().utime(path.value(), current_directory(), buf.actime, buf.modtime); + return VFS::the().utime(path.value()->view(), current_directory(), buf.actime, buf.modtime); } } |