-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[nodefs] Return real values for statvfs via __syscall_statfs64 #22631
Open
jeroenpf
wants to merge
14
commits into
emscripten-core:main
Choose a base branch
from
jeroenpf:fix-22607
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+94
−18
Open
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0896af7
Add statfs function to FS
jeroenpf 5770db8
Remove fsid and keep it hardcoded
jeroenpf a18edbe
Refactoring and add test
jeroenpf c3c0c5f
Fix statvfs test
jeroenpf d2e8f4c
Add test and fix cases where the default free inodes is larger than t…
jeroenpf 5adafc1
Remove unnecessary variable
jeroenpf d96e461
Remove old statfs addition
jeroenpf e7569a8
Add newline
jeroenpf 46de52e
Fix free inodes value and update test
jeroenpf d96eb8a
Update test/fs/test_nodefs_statfs.c
jeroenpf a9d68cd
refactor statfs
jeroenpf df511ea
Fix check for statfs on nodeops
jeroenpf 7601bd8
Rename statfs to statvfs and add a comment to explain assigning bsize…
jeroenpf 3a5a167
Fix test and use 2-space indentation
jeroenpf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <assert.h> | ||
#include <stdio.h> | ||
#include <sys/statvfs.h> | ||
#include <emscripten.h> | ||
|
||
void test_statfs(const char *path) { | ||
printf("Testing statfs for path: %s\n", path); | ||
struct statvfs st; | ||
int result = statvfs(path, &st); | ||
|
||
assert(result == 0 && "statvfs should succeed"); | ||
|
||
|
||
|
||
jeroenpf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Basic sanity checks | ||
assert(st.f_bsize > 0 && "Block size should be positive"); | ||
assert(st.f_blocks > 0 && "Total blocks should be positive"); | ||
assert(st.f_bfree <= st.f_blocks && "Free blocks should not exceed total blocks"); | ||
assert(st.f_bavail <= st.f_bfree && "Available blocks should not exceed free blocks"); | ||
assert(st.f_files > 0 && "Total inodes should be positive"); | ||
assert(st.f_ffree <= st.f_files && "Free inodes should not exceed total inodes"); | ||
} | ||
|
||
int main() { | ||
// Test the root filesystem (which should be MEMFS by default) | ||
test_statfs("/"); | ||
jeroenpf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Mount NODEFS and test it | ||
EM_ASM( | ||
FS.mkdir('/working'); | ||
FS.mount(NODEFS, { root: '.' }, '/working'); | ||
); | ||
jeroenpf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
test_statfs("/working"); | ||
|
||
puts("success"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
Also, so we really need to merge the defaults with the actual results? Are we expecting backends to only paritally fill the out the information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've applied the suggested changes.
The idea behind merging the defaults it to ensure that all the required fields are always set. In the case of Node, statfs does not return all of the information:
We could add the missing fields in the
node_ops.statfs
but it seemed appropriate to have the FS class ensure a valid response. Im happy to change it though, what do you think?