2001-08-16 Joel Sherrill <joel@OARcorp.com>

* libc/lseek.c: Modified after discussion with Eugeny S. Mints
	<jack@oktet.ru> to correct the behavior.  There were two mistakes.
	First, iop->offset was incorrectly set for SEEK_END.  Second,
	iop->offset should be left unmodified if there are errors.
	This modification attempts to fix both situations.
This commit is contained in:
Joel Sherrill
2001-08-17 13:18:01 +00:00
parent d62b0d5210
commit cc5c4ac6dd
3 changed files with 6 additions and 9 deletions

View File

@@ -68,14 +68,13 @@ off_t lseek(
*/ */
status = (*iop->handlers->lseek_h)( iop, offset, whence ); status = (*iop->handlers->lseek_h)( iop, offset, whence );
if ( !status ) if ( status == (off_t) -1 )
return 0; iop->offset = old_offset;
/* /*
* So if the operation failed, we have to restore iop->offset. * So if the operation failed, we have to restore iop->offset.
*/ */
iop->offset = old_offset;
return status; return status;
} }

View File

@@ -68,14 +68,13 @@ off_t lseek(
*/ */
status = (*iop->handlers->lseek_h)( iop, offset, whence ); status = (*iop->handlers->lseek_h)( iop, offset, whence );
if ( !status ) if ( status == (off_t) -1 )
return 0; iop->offset = old_offset;
/* /*
* So if the operation failed, we have to restore iop->offset. * So if the operation failed, we have to restore iop->offset.
*/ */
iop->offset = old_offset;
return status; return status;
} }

View File

@@ -68,14 +68,13 @@ off_t lseek(
*/ */
status = (*iop->handlers->lseek_h)( iop, offset, whence ); status = (*iop->handlers->lseek_h)( iop, offset, whence );
if ( !status ) if ( status == (off_t) -1 )
return 0; iop->offset = old_offset;
/* /*
* So if the operation failed, we have to restore iop->offset. * So if the operation failed, we have to restore iop->offset.
*/ */
iop->offset = old_offset;
return status; return status;
} }