diff options
author | Ulf Lilleengen <lulf@pvv.ntnu.no> | 2008-08-18 11:51:49 +0200 |
---|---|---|
committer | Ulf Lilleengen <lulf@pvv.ntnu.no> | 2008-08-18 11:51:49 +0200 |
commit | 9043fd9a81e1dfe5b40d0fabd45fa7fc9b235120 (patch) | |
tree | fab5da40e84074d5f73c30f9d767436daa9ec4ca | |
parent | 7df9a3059a231c4bdab35eede75deab6fc6671c6 (diff) |
- 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.
-rwxr-xr-x | src/mfs_vnops.c | 5 |
1 files 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); |