This PR updates the ut_lind_fs_mmap_no_write test to properly handle the case where a file opened with O_RDONLY (read-only) is mapped with write permissions (PROT_WRITE). The previous implementation directly compared the result of mmap_syscall with -(Errno::EACCES as i32), which is incorrect. Instead, mmap_syscall typically returns -1 on failure, and the actual error code (EACCES) is stored in errno.
Changes:
Updated the test to check that mmap_syscall returns -1 upon failure.
Added a check to verify that errno is set to EACCES (Permission denied), which occurs when attempting to map a file with write permissions when it was opened in read-only mode.
Type of change
[x] Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
cargo test ut_lind_fs_mmap_no_write
Checklist:
[x] My code follows the style guidelines of this project
[x] I have commented my code, particularly in hard-to-understand areas
[x] My changes generate no new warnings
[x] I have added tests that prove my fix is effective or that my feature works
[x] Any dependent changes have been added to a pull request and/or merged in other modules (native-client, lind-glibc, lind-project)
Description
Fixes # (issue)
This PR updates the
ut_lind_fs_mmap_no_write
test to properly handle the case where a file opened withO_RDONLY
(read-only) is mapped with write permissions (PROT_WRITE
). The previous implementation directly compared the result ofmmap_syscall
with-(Errno::EACCES as i32)
, which is incorrect. Instead,mmap_syscall
typically returns-1
on failure, and the actual error code (EACCES
) is stored inerrno
.Changes:
mmap_syscall
returns-1
upon failure.errno
is set toEACCES
(Permission denied), which occurs when attempting to map a file with write permissions when it was opened in read-only mode.Type of change
How Has This Been Tested?
cargo test ut_lind_fs_mmap_no_write
Checklist: