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

wasi: resets offsets in reopen #1866

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

yagehu
Copy link
Contributor

@yagehu yagehu commented Dec 12, 2023

This commit fixes fd_fdstat_set_flags resetting the fd offset due to it reopening the file every time. This fix gets the current offset before reopening and restore the offset with seek. This addresses #1865.

NB: A couple of existing tests are actually spec'd wrong. To fix, I introduced addition Seek calls before checking removing append flag.

Copy link
Contributor

@evacchi evacchi left a comment

Choose a reason for hiding this comment

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

as you can see, unfortunately this is failing on Windows

@yagehu yagehu force-pushed the yagehu/append-offset branch 2 times, most recently from f8af47b to 4ad7124 Compare December 12, 2023 21:19
@yagehu
Copy link
Contributor Author

yagehu commented Dec 12, 2023

as you can see, unfortunately this is failing on Windows

Fixed!

@yagehu yagehu requested a review from evacchi December 12, 2023 21:54
internal/sysfs/osfile.go Outdated Show resolved Hide resolved
This commit fixes `fd_fdstat_set_flags` resetting the fd offset due to
it reopening the file every time.  This fix gets the current offset
before reopening and restore the offset with seek.

Signed-off-by: Yage Hu <me@huyage.dev>
@evacchi
Copy link
Contributor

evacchi commented Dec 12, 2023

thanks!

@yagehu yagehu force-pushed the yagehu/append-offset branch from 4ad7124 to 7478b88 Compare December 12, 2023 22:19
@evacchi
Copy link
Contributor

evacchi commented Dec 12, 2023

I see you force-pushed new changes, let me know when the PR is in a stable state @yagehu ! :)

@evacchi evacchi self-requested a review December 12, 2023 22:20
@yagehu
Copy link
Contributor Author

yagehu commented Dec 12, 2023

I see you force-pushed new changes, let me know when the PR is in a stable state @yagehu ! :)

I'm done. Just a quick fix to avoid double IsDir calls. Thanks!

@mathetake mathetake changed the title Fix fd_fdstat_set_flags resetting offset wasi: resets offsets in reopen Dec 12, 2023
@mathetake mathetake merged commit f46d5b9 into tetratelabs:main Dec 12, 2023
53 checks passed
}

if !isDir {
offset, err = f.file.Seek(0, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe too late for a nit, but please constants for the whence: io.SeekStart, etc…

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, let's fix it in a follow up PR

gaukas pushed a commit to refraction-networking/wazero that referenced this pull request Dec 14, 2023
Signed-off-by: Yage Hu <me@huyage.dev>
@yagehu yagehu deleted the yagehu/append-offset branch June 5, 2024 19:23
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.

4 participants