diff options
-rw-r--r-- | storeio/ChangeLog | 5 | ||||
-rw-r--r-- | storeio/open.c | 19 |
2 files changed, 16 insertions, 8 deletions
diff --git a/storeio/ChangeLog b/storeio/ChangeLog index 75374a1e..e14aaed4 100644 --- a/storeio/ChangeLog +++ b/storeio/ChangeLog @@ -1,3 +1,8 @@ +2006-06-15 Thomas Schwinge <tschwinge@gnu.org> + + * open.c (open_seek): Seek into the correct direction for `SEEK_END'. + Return EINVAL if file pointer would become negative. + 2005-01-08 Marco Gerards <metgerards@student.han.nl> * storeio.c (trivfs_modify_stat): Don't initialize st_blocks. diff --git a/storeio/open.c b/storeio/open.c index b1013a94..805115ce 100644 --- a/storeio/open.c +++ b/storeio/open.c @@ -1,6 +1,6 @@ /* Per-open information for storeio - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 2006 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.ai.mit.edu> @@ -105,19 +105,22 @@ open_seek (struct open *open, off_t offs, int whence, off_t *new_offs) switch (whence) { - case SEEK_SET: - open->offs = offs; break; case SEEK_CUR: - open->offs += offs; break; + offs += open->offs; + goto check; case SEEK_END: - open->offs = open->dev->store->size - offs; break; + offs += open->dev->store->size; + case SEEK_SET: + check: + if (offs >= 0) + { + *new_offs = open->offs = offs; + break; + } default: err = EINVAL; } - if (! err) - *new_offs = open->offs; - mutex_unlock (&open->lock); return err; |