From 380c6390b74725586097218cfb2d63571010afdc Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Wed, 17 Sep 2008 11:03:42 +0300 Subject: [PATCH] Fixed 2 bugs with broken memfs read() read end page boundary was off by one. memcpy routine had an extra dereference for src ptr. modified: src/memfs/file.c --- tasks/fs0/src/memfs/file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tasks/fs0/src/memfs/file.c b/tasks/fs0/src/memfs/file.c index 8649a50..dad5fe0 100644 --- a/tasks/fs0/src/memfs/file.c +++ b/tasks/fs0/src/memfs/file.c @@ -82,13 +82,14 @@ int memfs_file_read_write(struct vnode *v, unsigned int pfn, if (!wr) { /* Find read boundaries from expected range and file's current range */ start = pfn < __pfn(v->size) ? pfn : __pfn(v->size); - end = pfn + npages < __pfn(v->size) ? pfn + npages : __pfn(v->size); + end = pfn + npages < __pfn(page_align_up(v->size)) + ? pfn + npages : __pfn(page_align_up(v->size)); count = end - start; /* Copy the data from inode blocks into page buffer */ for (int x = start, bufpage = 0; x < end; x++, bufpage++) memcpy(((void *)buf) + (bufpage * blocksize), - &i->block[x], blocksize); + i->block[x], blocksize); return (int)(count * blocksize); } else { /* Write-specific operations */ /* Is the write beyond current file size? */