/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include namespace Kernel { KResultOr Process::sys$lseek(int fd, Userspace userspace_offset, int whence) { REQUIRE_PROMISE(stdio); auto description = file_description(fd); if (!description) return EBADF; off_t offset; if (!copy_from_user(&offset, userspace_offset)) return EFAULT; auto seek_result = description->seek(offset, whence); if (seek_result.is_error()) return seek_result.error(); if (!copy_to_user(userspace_offset, &seek_result.value())) return EFAULT; return KSuccess; } }