From: John Hodge Date: Fri, 28 Oct 2011 01:43:34 +0000 (+0800) Subject: Kernel/VFS - Fixed MMAP_MAP_ANONYMOUS not taking offset into account X-Git-Tag: rel0.14~184 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=2a8b49ac62c721023328ed75992f71ce7f2e49bf;p=tpg%2Facess2.git Kernel/VFS - Fixed MMAP_MAP_ANONYMOUS not taking offset into account --- diff --git a/Kernel/vfs/mmap.c b/Kernel/vfs/mmap.c index 729ab443..b5285af0 100644 --- a/Kernel/vfs/mmap.c +++ b/Kernel/vfs/mmap.c @@ -1,8 +1,11 @@ /* - * Acess2 VFS - * - Open, Close and ChDir + * Acess2 Kernel VFS + * - By John Hodge (thePowersGang) + * + * mmap.c + * - VFS_MMap support */ -#define DEBUG 0 +#define DEBUG 1 #include #include #include @@ -29,6 +32,9 @@ void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, ENTER("pDestHint iLength xProtection xFlags xFD XOffset", DestHint, Length, Protection, Flags, FD, Offset); + if( Flags & MMAP_MAP_ANONYMOUS ) + Offset = (tVAddr)DestHint & 0xFFF; + npages = ((Offset & (PAGE_SIZE-1)) + Length + (PAGE_SIZE - 1)) / PAGE_SIZE; pagenum = Offset / PAGE_SIZE; @@ -41,14 +47,19 @@ void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, if( Flags & MMAP_MAP_ANONYMOUS ) { size_t ofs = 0; + LOG("%i pages anonymous to %p", npages, mapping_dest); for( ; npages --; mapping_dest += PAGE_SIZE, ofs += PAGE_SIZE ) { if( MM_GetPhysAddr(mapping_dest) ) { // TODO: Set flags to COW if needed (well, if shared) MM_SetFlags(mapping_dest, MM_PFLAG_COW, MM_PFLAG_COW); + LOG("clear from %p, %i bytes", (void*)(mapping_base + ofs), + PAGE_SIZE - (mapping_base & (PAGE_SIZE-1)) + ); memset( (void*)(mapping_base + ofs), 0, PAGE_SIZE - (mapping_base & (PAGE_SIZE-1))); } else { + LOG("New empty page"); // TODO: Map a COW zero page instead if( !MM_Allocate(mapping_dest) ) { // TODO: Error