You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
chmod
Modify behaviors: cannot setting 0o777 so set to 0o755 instead
Modify behaviors: The extra bits are special permission bits in native linux
close
Fix bug in fdtable array
mmap
Fix error return
Test fix: Native linux may default to treating the combination as one or the other.
Test fix: Native linux will return EINVAL when offset is negative or not in range.
Test fix: Native linux can mmap character device.
Test fix: Native linux require specific flags to open a dir.
Test fix: Native linux will return ENODEV when mapping a dir.
Test fix: The previous test cases created directories but did not remove them. Consequently, when subsequent test cases attempted to create directories with the same names, an error was thrown because the directories already existed. This fix ensures that the directories are properly removed after each test case, preventing these conflicts.
Modification: The test now checks for the generic error code (-1) before matching against EINVAL for invalid flag combinations.
Test fix: When handling memory-mapped files and syscalls like getdents_syscall that deal with directory entries stored in packed structures, accessing fields like d_off and d_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
Fix bug that we should first check if desired path exists in native
fchdir
Test fix: Native linux require specific flags to open a dir.
Fix bug that we should also updated the lind cwd (calling libc::cwd and then extract the working directory) after calling fchdir.
open
Fix the condition when opening large number of files
Fix the issue related to writing to directories:
Test fix: Ensure that when attempting to write to a directory with O_WRONLY, it returns EISDIR as expected.
Test fix: Ensure that opening a directory with O_RDONLY returns a valid file descriptor, and attempting to write to it results in EBADF.
Added cleanup to remove the directory after each test to prevent conflicts with subsequent tests.
Fix for handling st_nlink and st_size values in directory tests:
Test fix: The st_nlink value in ut_lind_fs_simple was adjusted to account for multiple subdirectories under /, ensuring accurate hard link counts.
Test fix: The st_size value for directories is now validated to be greater than or equal to the filesystem's block size (commonly 4096 bytes), instead of assuming a size of 0.
getdents_syscall
Test Fix: When calling getdents_syscall with a buffer size smaller than CLIPPED_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.
Modification: Changed the directory open flags from O_RDWR to O_RDONLY in the ut_lind_fs_getdents_bufsize_too_small test case, ensuring that the directory opens correctly and allows testing for the proper error behavior.
dup
Fix to handle bad file descriptor condition
dup2
Fix bug that might be caused by below. Soln: reserving STDIN / STDOUT / STDERR in lindrustinit by redirecting fd=0/1/2 to /dev/null
Sometimes the `ut_lind_fs_dup2` can succeed sometimes cannot, so I suspect the error caused by following:
Daemon Processes: Daemon processes or services that explicitly close standard file descriptors to run in the background may result in open returning 0
Fix to handle bad file descriptor condition
fcntl
Test fix: Use FD_CLOEXEC when setting and checking file descriptor flags with F_SETFD and F_GETFD.
Test fix: Change to use & to check if flag has been set, and O_RDONLY should be checked by using O_ACCMODE
Test fix: Fixed getdents_syscall handling when the file descriptor is out of range.
Set the file status flags to the value specified by arg.
File access mode (O_RDONLY, O_WRONLY, O_RDWR) and file
creation flags (i.e., O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC)
in arg are ignored. On Linux, this operation can change
only the O_APPEND, O_ASYNC, O_DIRECT, O_NOATIME, and
O_NONBLOCK flags
Test fix: F_SETFD, F_SETFL with negative value args will not cause fcntl return error.
Fix bug that op is F_DUPFD and arg is negative or is greater than the maximum allowable value.
Fix bug that op is F_DUPFD and the per-process limit on the number of open file descriptors has been reached.
Fix bug that
Duplicate the file descriptor fd using the lowest-numbered
available file descriptor greater than or equal to arg.
This is different from dup2(2), which uses exactly the
file descriptor specified
Test fix: We should do lseek first to put file position at beginning, because in native linux when we read from the end of the file it will return 0
EOF (End of File): This indicates that the end of the file has been reached. If reading from a regular file, this means there is no more data left to read.
ioctl
Test fix (exclusive): change ioctl_union to libc::ioctl
Test fix (exclusice): Those invalid argument(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...
Test fix: I suspect that The ioctl call first checks whether the file descriptor type supports the operation associated with the request code. If the file descriptor is of a type that does not handle the requested operation (such as a socket not supporting a terminal command), ENOTTY is returned.
link
Test fix (exclusive): because in rawposix we'll transfer relative path into absolute path, native linux will always return EPERM instead of ENOENT when passing null value.
unlink
Test fix (exclusive): because in rawposix we'll transfer relative path into absolute path, native linux will alway
s return EISDIR instead of ENOENT 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 of ENOENT when passing null value.
Test fix: In the condition: calling rmdir_syscall()on the child directory should return Directory does not allow write permission error because the directory cannot be removed if its parent directory does not allow write permission. Native linux will return EACCES instead of EPERM.
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
Fix for handling empty path: Modified mkdir_syscall to return ENOENT 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:
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:
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: