mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
Tests: Unmap memory ranges on /dev/mem after testing mmap(2)
This commit is contained in:
parent
4ba9fa1a00
commit
1716105e73
1 changed files with 5 additions and 1 deletions
|
@ -23,7 +23,11 @@ static ALWAYS_INLINE bool mem_chunk(int fd, u64 base, u64 length)
|
|||
{
|
||||
u64 mmoffset = base % sysconf(_SC_PAGESIZE);
|
||||
void* mmp = mmap(NULL, mmoffset + length, PROT_READ, MAP_SHARED, fd, base - mmoffset);
|
||||
return mmp != MAP_FAILED;
|
||||
if (mmp == MAP_FAILED)
|
||||
return false;
|
||||
if (munmap(mmp, mmoffset + length) < 0)
|
||||
perror("munmap");
|
||||
return true;
|
||||
}
|
||||
|
||||
enum class ReadResult {
|
||||
|
|
Loading…
Add table
Reference in a new issue