X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Fvfs%2Fmmap.c;h=b6d5c2d91921425bb8864cb04dd797e91776526a;hb=3c3c26b58055f511af5b7f0c3ab22e83961c775f;hp=3539f37c9755b4222178a60a5ff1248bbe687c19;hpb=e2744a459d1c63435d7348d0bfd0e4b92b0ec9f9;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/vfs/mmap.c b/KernelLand/Kernel/vfs/mmap.c index 3539f37c..b6d5c2d9 100644 --- a/KernelLand/Kernel/vfs/mmap.c +++ b/KernelLand/Kernel/vfs/mmap.c @@ -25,6 +25,7 @@ struct sVFS_MMapPageBlock // === PROTOTYPES === //void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, Uint64 Offset); void *VFS_MMap_Anon(void *Destination, size_t Length, Uint FlagsSet, Uint FlagsMask); +//int VFS_MUnmap(void *Addr, size_t Length); // === CODE === void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, Uint64 Offset) @@ -70,7 +71,7 @@ void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, // - Sorted list of 16 page blocks for( pb = h->Node->MMapInfo, prev = NULL; - pb && pb->BaseOffset + MMAP_PAGES_PER_BLOCK < pagenum; + pb && pb->BaseOffset + MMAP_PAGES_PER_BLOCK <= pagenum; prev = pb, pb = pb->Next ) ; @@ -97,6 +98,8 @@ void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD, // - Map (and allocate) pages while( npages -- ) { + assert( pagenum >= pb->BaseOffset ); + assert( pagenum - pb->BaseOffset < MMAP_PAGES_PER_BLOCK ); if( MM_GetPhysAddr( mapping_dest ) == 0 ) { if( pb->PhysAddrs[pagenum - pb->BaseOffset] == 0 )