diff options
| author | Ada Christine <adachristine18@gmail.com> | 2024-02-24 00:16:09 +0000 |
|---|---|---|
| committer | Ada Christine <adachristine18@gmail.com> | 2024-02-24 00:16:09 +0000 |
| commit | a8a62bdba61177342ae38274c8196bc7a7c46fa0 (patch) | |
| tree | 7147b2807cdc96716dde96c0807693ddd366ebb9 /kjarna/efi/file.c | |
| parent | aec58be40927ec0b2a0e6742396f880d52ce38b5 (diff) | |
kjarna runtime
Diffstat (limited to 'kjarna/efi/file.c')
| -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; |
