diff options
Diffstat (limited to 'kjarna')
| -rw-r--r-- | kjarna/efi/file.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/kjarna/efi/file.c b/kjarna/efi/file.c index 12364e6..e9da83e 100644 --- a/kjarna/efi/file.c +++ b/kjarna/efi/file.c @@ -145,27 +145,44 @@ int efi_close(int fd) off_t efi_lseek(int fd, off_t offset, int whence) { - if (whence != SEEK_SET) + EFI_FILE_PROTOCOL *file = fd_to_file(fd); + + if (file == nullptr) { efi_errno = EFI_INVALID_PARAMETER; return -1; } - EFI_FILE_PROTOCOL *file = fd_to_file(fd); + off_t current = 0; - if (file == nullptr) + if (whence == SEEK_END) + { + efi_errno = file->SetPosition(file, (UINTN)-1); + } + + if (EFI_ERROR(efi_errno)) + { + return -1; + } + + if (whence == SEEK_CUR || whence == SEEK_END) + { + efi_errno = file->GetPosition(file, (UINTN *)¤t); + } + + if (EFI_ERROR(efi_errno)) { - efi_errno = EFI_INVALID_PARAMETER; return -1; } - efi_errno = file->SetPosition(file, (UINTN)offset); + efi_errno = file->SetPosition(file, (UINTN)(offset + current)); return !EFI_ERROR(efi_errno) ? offset : -1; } static ssize_t efi_console_read(EFI_SIMPLE_TEXT_INPUT_PROTOCOL *console, CHAR16 *buffer, size_t length) { + //TODO: implement user input (void)console; (void)buffer; efi_errno = EFI_INVALID_PARAMETER; |
