mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +00: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);
|
u64 mmoffset = base % sysconf(_SC_PAGESIZE);
|
||||||
void* mmp = mmap(NULL, mmoffset + length, PROT_READ, MAP_SHARED, fd, base - mmoffset);
|
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 {
|
enum class ReadResult {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue