This change fixes a bug in lseek where the file cursor was always set to
the end of file on SEEK_END, ignoring any passed-in offset.
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
GitHub-Closes: #1602
_of_lock(of);
if (whence == SEEK_END) {
const struct uk_file *f = of->file;
+ ssize_t eof;
if (iolock)
uk_file_rlock(f);
- offset = fdio_get_eof(f);
+ eof = fdio_get_eof(f);
if (iolock)
uk_file_runlock(f);
+ if (eof >= 0)
+ offset += eof;
+ else
+ offset = eof;
} else if (whence == SEEK_CUR) {
offset += of->pos;
}