summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2008-08-01 08:59:27 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2008-08-01 08:59:27 +0200
commitf295acb556da2b7a5e3b270ea8d34ea058fe7dc9 (patch)
treea8e939e1133401ddd493f4f1fb0dfcd3257abd23 /fs
parentec1b86784d4c08f8f0897161e142745080625698 (diff)
downloadbarebox-f295acb556da2b7a5e3b270ea8d34ea058fe7dc9.tar.gz
barebox-f295acb556da2b7a5e3b270ea8d34ea058fe7dc9.tar.xz
lseek: return -1 for errors and check for that return value
We cannot check for < 0 in lseek, otherwise we get problems with files > 0x7fffffff Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/devfs.c4
-rw-r--r--fs/fs.c10
2 files changed, 8 insertions, 6 deletions
diff --git a/fs/devfs.c b/fs/devfs.c
index 12abc1829d..cd9bed2676 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -47,11 +47,11 @@ static int devfs_write(struct device_d *_dev, FILE *f, const void *buf, size_t s
static off_t devfs_lseek(struct device_d *_dev, FILE *f, off_t pos)
{
struct device_d *dev = f->inode;
- int ret;
+ off_t ret;
ret = dev_lseek(dev, pos);
- if (ret >= 0)
+ if (ret != -1)
f->pos = pos;
return ret;
diff --git a/fs/fs.c b/fs/fs.c
index 32fd802208..d0b008aca1 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -516,14 +516,16 @@ off_t lseek(int fildes, off_t offset, int whence)
struct device_d *dev;
struct fs_driver_d *fsdrv;
FILE *f = &files[fildes];
- ulong pos;
+ off_t pos;
errno = 0;
dev = f->dev;
fsdrv = (struct fs_driver_d *)dev->driver->type_data;
- if (!fsdrv->lseek)
- return -ENOSYS;
+ if (!fsdrv->lseek) {
+ errno = -ENOSYS;
+ return -1;
+ }
switch(whence) {
case SEEK_SET:
@@ -549,7 +551,7 @@ off_t lseek(int fildes, off_t offset, int whence)
out:
errno = -EINVAL;
- return errno;
+ return -1;
}
EXPORT_SYMBOL(lseek);