lseek: return -1 instead of -errno
The patch making errno a positive value has another bug: lseek was switched to return -errno instead of -1. This does not work since we can lseek we can address the whole 4G address space, have of which has a negative offset when interpreted as a signed integer. Let lseek return -1 on failure again instead. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
c46a841049
commit
831be2ecee
|
@ -48,7 +48,7 @@ static int file_crc(char* filename, ulong start, ulong size, ulong *crc,
|
||||||
|
|
||||||
if (start > 0) {
|
if (start > 0) {
|
||||||
ret = lseek(fd, start, SEEK_SET);
|
ret = lseek(fd, start, SEEK_SET);
|
||||||
if (ret < 0) {
|
if (ret == -1) {
|
||||||
perror("lseek");
|
perror("lseek");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,10 +122,10 @@ static int open_and_lseek(const char *filename, int mode, off_t pos)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
ret = lseek(fd, pos, SEEK_SET);
|
ret = lseek(fd, pos, SEEK_SET);
|
||||||
if (ret < 0) {
|
if (ret == -1) {
|
||||||
perror("lseek");
|
perror("lseek");
|
||||||
close(fd);
|
close(fd);
|
||||||
return ret;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
|
|
4
fs/fs.c
4
fs/fs.c
|
@ -732,13 +732,13 @@ off_t lseek(int fildes, off_t offset, int whence)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fsdrv->lseek(dev, f, pos);
|
return fsdrv->lseek(dev, f, pos);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (ret)
|
if (ret)
|
||||||
errno = -ret;
|
errno = -ret;
|
||||||
|
|
||||||
return ret;
|
return -1;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(lseek);
|
EXPORT_SYMBOL(lseek);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue