Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to support WASI on Zephyr #3948

Open
wants to merge 3 commits into
base: dev/zephyr_file_socket
Choose a base branch
from

Conversation

srberard
Copy link
Contributor

@srberard srberard commented Dec 5, 2024

Fixed issues #3311.

@wenyongh I'm merging this to the branch created so that we can review and ensure all the items are addressed prior to merging back to main.

Fixed issues in os_renameat

Signed-off-by: Stephen Berard <[email protected]>
@srberard
Copy link
Contributor Author

srberard commented Dec 5, 2024

There is 1 testing failing above, but I don't believe it's related to this PR.

@lum1n0us
Copy link
Collaborator

lum1n0us commented Dec 6, 2024

There is 1 testing failing above, but I don't believe it's related to this PR.

It's not related. Don't be worried.


char *path = strdup(new_path);
if (path == NULL) {
return __WASI_ENOMEM;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In before, if strdup() returns NULL, ptr->path will be set to old_path instead of maintaining original value. But in after, it's not. So, is it on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the idea is that if strdup fails, we return an error and do not perform the rename.

return __WASI_ENOMEM;
}

free(ptr->path);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to be sure, IIUC, the core idea of this patch is to free(ptr->path) before assigning a new value. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core idea was to address the comments from @wenyongh (here)[https://github.com//pull/3633#discussion_r1732970108]. In the previous version, the strdup which was assigned directly to ptr->path without first freeing the old value. In this version, we strdup into a local variable and then do the free/rename if the operations succeed.

* To manage our file descriptors, we created a struct `zephyr_fs_desc` that
* represent a zephyr file descriptor and hold useful informations.
* We also created a file descriptor table to keep track of all the file
* To manage our file descriptors, we a struct `zephyr_fs_desc` is created that
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had better remove we ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed typo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants