Tests: Unmap memory ranges on /dev/mem after testing mmap(2)
This commit is contained in:
parent
4ba9fa1a00
commit
1716105e73
Notes:
sideshowbarker
2024-07-17 20:54:49 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/1716105e738 Pull-request: https://github.com/SerenityOS/serenity/pull/11895 Reviewed-by: https://github.com/IdanHo ✅
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