From 9043fd9a81e1dfe5b40d0fabd45fa7fc9b235120 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Mon, 18 Aug 2008 11:51:49 +0200 Subject: - Remember to lseek to correct offset. - Fix a bug where SEEK_CUR was used instead of SEEK_SET. This was also the reason I didn't add lseek when reading a file in the first place, because i got buggy behaviour. So, using SEEK_SET corrected this. --- src/mfs_vnops.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mfs_vnops.c b/src/mfs_vnops.c index f1a0fcc..9af8a2f 100755 --- a/src/mfs_vnops.c +++ b/src/mfs_vnops.c @@ -167,7 +167,7 @@ static int mfs_read (const char *path, char *buf, size_t size, off_t offset, return (-ENOMEM); int fd = open(mfsrc, O_RDONLY); free(mfsrc); - lseek(fd, offset, SEEK_CUR); + lseek(fd, offset, SEEK_SET); bytes = read(fd, buf, size); close(fd); return (bytes); @@ -176,6 +176,7 @@ static int mfs_read (const char *path, char *buf, size_t size, off_t offset, fd = (int)fi->fh; if (fd < 0) return (-EIO); + lseek(fd, offset, SEEK_SET); bytes = read(fd, buf, size); return (bytes); @@ -200,7 +201,7 @@ static int mfs_write(const char *path, const char *buf, size_t size, return (-ENOMEM); int fd = open(mfsrc, O_WRONLY); free(mfsrc); - lseek(fd, offset, SEEK_CUR); + lseek(fd, offset, SEEK_SET); bytes = write(fd, buf, size); close(fd); return (bytes); -- cgit v1.2.3