-
Notifications
You must be signed in to change notification settings - Fork 266
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
fs: Adds tests to prove we allow fs.FS to create new files #1015
Conversation
78d1f76
to
ff511e8
Compare
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if flag == 0 || flag == os.O_RDONLY { |
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.
instead of masking here, we are verifying the errno on Write. seems to work e.g. flags are honored to prohibit writes.
// maskForReads masks the file with read-only interfaces used by wazero. | ||
// | ||
// This technique was adapted from similar code in zipkin-go. | ||
func maskForReads(f fs.File) fs.File { |
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.
this was moved as it is only used here now
Signed-off-by: Adrian Cole <adrian@tetrate.io>
ff511e8
to
fc8d2b1
Compare
This ensures those who cannot use
writefs.DirFS
can use afs.FS
implementation that creates or opens files as read/write. This does so by making a hacked fs.FS and testing it.This also removes type filtering to ensure hacked filesystems aren't accidentally masked. Instead we get more specific on error codes returned by functions such as
os.File.Write
.Note: This is meant to extend the life of fs.FS for custom implementations, though we expect eventually to have our own API. However, such an API will remain internal until at least the end of the month due to a lot of prerequisite work. See #1013 cc @wjam