-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix OpenFile confusion of flags and permissions
OpenFile used to accept `fs.FileMode` twice, as in: ```go func (f *PosixFsys) OpenFile(path string, mode FileMode, perm FileMode) (*PosixFile, error) ``` The correct (or stdlib equivalent) signature is to accept an integer for the status flags and fs.FileMode for the permissions, as in: ```go func (f *PosixFsys) OpenFile(path string, flags int, perm fs.FileMode) (*PosixFile, error) ``` The OpenFile status flags are: File access: - O_RDONLY - open the file read-only. - O_WRONLY - open the file write-only. - O_RDWR - open the file read-write. File creation: - O_APPEND - append data to the file when writing. - O_CREATE - create a new file if none exists. - O_TRUNC - truncate the file if it exists - O_EXCL - used in conjunction with O_CREATE, file must not already exist. There's also O_SYNC but it is not implemented in rig, it's always sync. See https://pkg.go.dev/os#pkg-constants *Usage:* // Explanation of the flags: // - Create a new file if one doesn't exist // - Truncate an existing file if one exist (keeps // existing permissions) // - Open the file for writing fsys.OpenFile("/tmp/example", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, fs.FileMode(0644)) The `rigfs.FileMode` is now retired, you're now expected to use fs.FileMode from `"io/fs"`. Signed-off-by: Kimmo Lehto <[email protected]>
- Loading branch information
Showing
6 changed files
with
91 additions
and
85 deletions.
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
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