Tracking Modifications and Findings During Test Suite Porting -- RawPOSIX #49
Labels
documentation
Improvements or additions to documentation
good first issue
Good for newcomers
RawPOSIX
RawPOSIX related issue
Description:
This issue is to document all the changes and discoveries made while porting the test suite from RustPOSIX to RawPOSIX. Below are the current modifications and fixes identified:
Current Status
chmod
close
mmap
getdents_syscall
that deal with directory entries stored in packed structures, accessing fields liked_off
andd_reclen
directly can result in alignment issues on architectures that enforce strict memory alignment. To prevent runtime errors, the fields from packed structures are copied into local variables before they are used. This approach avoids accessing misaligned memory directly, ensuring the program remains stable across different platforms.chdir
fchdir
open
O_WRONLY
, it returnsEISDIR
as expected.O_RDONLY
returns a valid file descriptor, and attempting to write to it results inEBADF
.st_nlink
andst_size
values in directory tests:st_nlink
value inut_lind_fs_simple
was adjusted to account for multiple subdirectories under/
, ensuring accurate hard link counts.st_size
value for directories is now validated to be greater than or equal to the filesystem's block size (commonly4096
bytes), instead of assuming a size of0
.getdents_syscall
getdents_syscall
with a buffer size smaller thanCLIPPED_DIRENT_SIZE
, the test should ensure that the appropriate error (EINVAL
) is returned. The current behavior was returning an incorrect file descriptor error (EBADF
) due to opening the directory with incorrect flags.O_RDWR
toO_RDONLY
in theut_lind_fs_getdents_bufsize_too_small
test case, ensuring that the directory opens correctly and allows testing for the proper error behavior.dup
dup2
STDIN / STDOUT / STDERR
inlindrustinit
by redirecting fd=0/1/2 to/dev/null
fcntl
FD_CLOEXEC
when setting and checking file descriptor flags withF_SETFD
andF_GETFD
.&
to check if flag has been set, andO_RDONLY
should be checked by usingO_ACCMODE
lseek
first to put file position at beginning, because in native linux when we read from the end of the file it will return 0ioctl
FIONBIO
) will success in native linux (ArchLinux)[https://stackoverflow.com/a/1151077/22572322]
...but these behaved inconsistently between systems, and even within the same system...
link
EPERM
instead ofENOENT
when passing null value.unlink
s return
EISDIR
instead ofENOENT
when passing null value.rmdir
Test fix (exclusive): because in rawposix we'll transfer relative path into absolute path, native linux will alway
s return
ENOTEMPTY
instead ofENOENT
when passing null value.Test fix: In the condition: calling
rmdir_syscall()
on the child directory should returnDirectory does not allow write permission
error because the directory cannot be removed if its parent directory does not allow write permission. Native linux will returnEACCES
instead ofEPERM
.Test fix: changing all directory name into test-specific, because native
mkdir
will return error when directory has been created before.Test fix:
rmdir
can succeed even if the directory has restrictive permissions because rmdir doesn't require write permissions on the directory itself; it requires write and execute permissions on the parent directory of the target directory.Test fix: bug related to mkdir in rustposix but not in native linux, so changing test to correct version.
mkdir
mkdir_syscall
to returnENOENT
for an empty path, ensuring compliance with expected behavior when no directory name is provided. Previously, this scenario returned an incorrect error code.The text was updated successfully, but these errors were encountered: