summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <tschwinge@gnu.org>2006-06-15 13:54:08 +0000
committerThomas Schwinge <tschwinge@gnu.org>2006-06-15 13:54:08 +0000
commit95b1426fb75a5458ac15d28a04501327875fa58d (patch)
tree6bcf1cf32c301f45d81be034a2d2994de59c0606
parenta55e2129494c2559df9fb6534356a423c6de728c (diff)
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.
-rw-r--r--storeio/ChangeLog5
-rw-r--r--storeio/open.c19
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;