Conversation
|
Completed with the comments in the sys_call and added a few tests for it. But, still working on the remaining ones and will update the PR within some time once the other tests are completed. |
JustinCappos
left a comment
There was a problem hiding this comment.
Good first cut. A few minor changes requested.
| // Function Arguments | ||
| // The open_syscall() receives three arguments: | ||
| // 1. Path - This argument points to a pathname naming the file. | ||
| // For example: "/parentdir/file1" represents a file which will be either opened if existed or will be created at the given path. |
There was a problem hiding this comment.
| // For example: "/parentdir/file1" represents a file which will be either opened if existed or will be created at the given path. | |
| // For example: "/parentdir/file1" represents a file which will be either opened if it exists or will be created at the given path. |
| // Walk through the absolute path which returns a tuple consisting of inode number of file (if it exists), and inode number of parent (if it exists) | ||
| match metawalkandparent(truepath.as_path()) { | ||
| //If neither the file nor parent exists | ||
| // Case 1: When neither the file directory nor the parent directory exists |
There was a problem hiding this comment.
It's sort of weird to structure it like this because if the parent director doesn't exist, then the file clearly won't. Can you just check to make sure the parent dir exists and return an error otherwise?
There was a problem hiding this comment.
If you just want clarity the tuple check in match statement would just be (.., None) since the second field is the parent and the first field doesn't matter. Thought metawalkparent will always return (None, None) if the parent doesn't exist since like you said if we don't find a parent we obviously don't have the file.
|
@namanlalitnyu A few minor github things...
This isn't a huge problem here (you've done a nice job!), but I wanted to bring them up since they are top-of-mind) |
Sure professor, thanks for the suggestions. Will do that! |
| if let interface::RustHashEntry::Occupied(occ) = entry { | ||
| occ.remove_entry(); | ||
| } | ||
|
|
There was a problem hiding this comment.
remove this extra whitespace
There was a problem hiding this comment.
I checked, and there is not any extra whitespace here; it is just because of the indentation as the code section has moved inside the matching block.
| let entry = FILEOBJECTTABLE.entry(inodenum); | ||
| if let interface::RustHashEntry::Occupied(occ) = &entry { | ||
| occ.get().close().unwrap(); | ||
| // Doubt: Why are we removing the previous entry from the FileObjectTable and then inserting a new file with size 0. |
There was a problem hiding this comment.
This is hacky way to truncate since a new file will be size 0 instead of actually adjusting the filesize and pointer. I would comment that thats what were doing but also label it as a possible bug.
There was a problem hiding this comment.
Updated the comment.
rennergade
left a comment
There was a problem hiding this comment.
Two minor changes, should be able to get this merged today.
JustinCappos
left a comment
There was a problem hiding this comment.
Looks fine after the return values / panics in the comment block is updated.
| /// Upon successful completion of this call, a file descriptor is returned which points the file which is opened. | ||
| /// Otherwise, an error with a proper errorNumber and errorMessage is returned based on the different scenarios. | ||
| /// | ||
| /// for more detailed description of all the commands and return values, see |
There was a problem hiding this comment.
We don't cover all the cases of open though, do we? What errors are returned and which are not?
There was a problem hiding this comment.
No, we don't cover all the errors. Manpage has a lot of them mentioned which are remaining.
Updated the comments with error values and panics in the comment block. |
|
I think this looks ready. Good job! |
Description
Fixes # (issue)
The following changes include the tests and comments in the code for the "open_syscall" file system call under RustPosix.
The tests were added to cover all the possible scenarios that might happen when calling the file system_call
open_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_open_empty_directory()ut_lind_fs_open_nonexisting_parentdirectory_and_file()ut_lind_fs_open_existing_parentdirectory_and_nonexisting_file()ut_lind_fs_open_existing_file_without_flags()ut_lind_fs_open_existing_file_with_flags()ut_lind_fs_open_create_new_file_and_check_link_count()ut_lind_fs_open_existing_file_with_o_trunc_flag()ut_lind_fs_open_new_file_with_s_ifchar_flag()Checklist: