From 4b81cf3e63747b4f52bc7518ebd7716e64ef590e Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Mon, 10 Sep 2012 18:04:59 +0200 Subject: [PATCH] Noux: fix 'Vfs_io_channel::lseek()' calculations With this patch the 'Vfs_io_channel::lseek()' function takes the offset argument into account when calculating the new seek offset in the SEEK_CUR and SEEK_END cases. Fixes #352. --- ports/src/noux/vfs_io_channel.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ports/src/noux/vfs_io_channel.h b/ports/src/noux/vfs_io_channel.h index d4f91cf5a7..46225b7f22 100644 --- a/ports/src/noux/vfs_io_channel.h +++ b/ports/src/noux/vfs_io_channel.h @@ -157,8 +157,12 @@ namespace Noux { { switch (sysio->lseek_in.whence) { case Sysio::LSEEK_SET: _fh->_seek = sysio->lseek_in.offset; break; - case Sysio::LSEEK_CUR: break; - case Sysio::LSEEK_END: _fh->_seek = size(sysio); break; + case Sysio::LSEEK_CUR: _fh->_seek += sysio->lseek_in.offset; break; + case Sysio::LSEEK_END: + off_t offset = sysio->lseek_in.offset; + sysio->fstat_in.fd = sysio->lseek_in.fd; + _fh->_seek = size(sysio) + offset; + break; } sysio->lseek_out.offset = _fh->_seek; return true;