Conversation
Yaxuan-w
left a comment
There was a problem hiding this comment.
Overall logic makes sense to me, lgtm so approved
JustinCappos
left a comment
There was a problem hiding this comment.
Looks great! Can you add a test for doing mkdir through a symlink?
|
Great starter! i think we can bundle the comments update for the syscall in this PR itself. |
Added the test for the same. |
| // Create a directory which will be referred to as originaldir | ||
| let fd = cage.open_syscall("/originaldir", O_CREAT | O_EXCL | O_WRONLY, S_IRWXA); | ||
| assert_eq!(cage.write_syscall(fd, str2cbuf("hi"), 2), 2); |
There was a problem hiding this comment.
This creates a file, not a directory, right?
There was a problem hiding this comment.
This creates a file, not a directory, right?
Sorry, my bad...I just rechecked the other references for this function call and it creates a file, not a directory. Updated the changes.
| parentdir.linkcount += 1; | ||
| parentdir.ctime = time; | ||
| parentdir.mtime = time; | ||
| // Here, update the ctime and mtime for the parent directory as well |
There was a problem hiding this comment.
Man pages for this call contain the update to the timestamps as well - https://docs.oracle.com/cd/E86824_01/html/E54765/mkdir-2.html
| assert_eq!(cage.mkdir_syscall("/parentdir/dir", S_IRWXA), 0); | ||
|
|
||
| // Get the stat data for the child directory and check for inode link count to be 3 initially | ||
| let mut statdata2 = StatData::default(); |
There was a problem hiding this comment.
Updated this test to verify the "link count" when a new directory is created.
| return syscall_error(Errno::ENOENT, "mkdir", "given path was null"); | ||
| } | ||
|
|
||
| // Get the absolute path |
There was a problem hiding this comment.
This is done to get the absolute path from the root directory of Lind so that we can trace the entire path and check for errors.
There was a problem hiding this comment.
okay, please explain why we need to do this to check for errors in the code comment.
I can tell you're getting the absolute path from the code, but don't know why you are getting it until you tell me...
There was a problem hiding this comment.
Got it, will update the comments.
There was a problem hiding this comment.
Updated the comments.
JustinCappos
left a comment
There was a problem hiding this comment.
Looks pretty good. I like the tests particularly. A few comments could be improved, but it mostly looks ready.
|
A brief intro and info about the arguments, Flags being used, purpose and return types above the function signature will make the documentation whole. you can refer to the man pages to add this, potentially also include any limitations and unsupported features we have today as a Note. other than that, everything looks good! |
Done, added relevant information before the system call and added more context inside the function call for better understanding. Couldn't find any limitations / unsupported features for now, but will update it once I find in future. |
Description
Fixes # (issue)
The following changes include the tests for the "mkdir" file system call under RustPosix.
The tests were added to cover all the possible scenarios that might happen when calling the file system_call
mkdir_syscall.Type of change
How Has This Been Tested?
Inorder to run the tests, we need to run
cargo test --libcommand inside thesafeposix-rustdirectory.All the tests are present under this directory:
lind_project/src/safeposix-rust/src/tests/fs_tests.rsut_lind_fs_mkdir_empty_directory()ut_lind_fs_mkdir_nonexisting_directory()ut_lind_fs_mkdir_existing_directory()ut_lind_fs_mkdir_invalid_modebits()ut_lind_fs_mkdir_success()ut_lind_fs_mkdir_using_symlink()Checklist: