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

WasmFS JS API: Implement allocate #19602

Merged
merged 13 commits into from
Jun 14, 2023

Conversation

jameshu15869
Copy link
Contributor

This PR implements allocate. I did not see any tests for FS.allocate, so added new ones to test_fs_js_api.c.

I also had to change the type of the __syscall_fallocate to use int64_t instead of uint64_t so that negative numbers would correctly throw error handling. With uint64_t setSize() would abort without an error code, since it was interpreting negative numbers incorrectly. Now, the syscall correctly returns an error code if either offset or length is negative.

@tlively tlively self-requested a review June 13, 2023 18:07
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Nice, and good find about the wrong types in that syscall.

test/fs/test_fs_js_api.c Show resolved Hide resolved
stat("/dir1", &rmdirStat);
assert(S_ISDIR(rmdirStat.st_mode));
stat("/dir2", &rmdirStat);
assert(S_ISDIR(rmdirStat.st_mode));
Copy link
Member

Choose a reason for hiding this comment

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

If the reason for the name change is to avoid a collision, another option is to add a scope,

{
   struct stat s;
  ..
}

But the more explicit name also seems good by itself, either sgtm.

Or, it might be nice to split up the tests into their own functions, as the new test here.

Copy link
Contributor Author

@jameshu15869 jameshu15869 Jun 13, 2023

Choose a reason for hiding this comment

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

There was some collision after merging in the other tests, but I did move each test to its own function in the utime PR after a suggestion from Sam, so the collision should be fixed (#19561). I was originally planning on changing the names back to struct stat s after the tests as individual functions are merged in.

@kripken kripken merged commit 9d706c7 into emscripten-core:main Jun 14, 2023
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.

2 participants