package sysfs
import (
"io/fs"
experimentalsys "github.com/tetratelabs/wazero/experimental/sys"
)
type ReadFS struct {
experimentalsys .FS
}
func (r *ReadFS ) OpenFile (path string , flag experimentalsys .Oflag , perm fs .FileMode ) (experimentalsys .File , experimentalsys .Errno ) {
switch flag & (experimentalsys .O_RDONLY | experimentalsys .O_WRONLY | experimentalsys .O_RDWR ) {
case experimentalsys .O_WRONLY , experimentalsys .O_RDWR :
if flag &experimentalsys .O_DIRECTORY != 0 {
return nil , experimentalsys .EISDIR
}
return nil , experimentalsys .ENOSYS
default :
}
f , errno := r .FS .OpenFile (path , flag , perm )
if errno != 0 {
return nil , errno
}
return &readFile {f }, 0
}
func (r *ReadFS ) Mkdir (path string , perm fs .FileMode ) experimentalsys .Errno {
return experimentalsys .EROFS
}
func (r *ReadFS ) Chmod (path string , perm fs .FileMode ) experimentalsys .Errno {
return experimentalsys .EROFS
}
func (r *ReadFS ) Rename (from , to string ) experimentalsys .Errno {
return experimentalsys .EROFS
}
func (r *ReadFS ) Rmdir (path string ) experimentalsys .Errno {
return experimentalsys .EROFS
}
func (r *ReadFS ) Link (_ , _ string ) experimentalsys .Errno {
return experimentalsys .EROFS
}
func (r *ReadFS ) Symlink (_ , _ string ) experimentalsys .Errno {
return experimentalsys .EROFS
}
func (r *ReadFS ) Unlink (path string ) experimentalsys .Errno {
return experimentalsys .EROFS
}
func (r *ReadFS ) Utimens (path string , atim , mtim int64 ) experimentalsys .Errno {
return experimentalsys .EROFS
}
var _ experimentalsys .File = (*readFile )(nil )
type readFile struct {
experimentalsys .File
}
func (r *readFile ) Write ([]byte ) (int , experimentalsys .Errno ) {
return 0 , r .writeErr ()
}
func (r *readFile ) Pwrite ([]byte , int64 ) (n int , errno experimentalsys .Errno ) {
return 0 , r .writeErr ()
}
func (r *readFile ) Truncate (int64 ) experimentalsys .Errno {
return r .writeErr ()
}
func (r *readFile ) Sync () experimentalsys .Errno {
return experimentalsys .EBADF
}
func (r *readFile ) Datasync () experimentalsys .Errno {
return experimentalsys .EBADF
}
func (r *readFile ) Utimens (int64 , int64 ) experimentalsys .Errno {
return experimentalsys .EBADF
}
func (r *readFile ) writeErr () experimentalsys .Errno {
if isDir , errno := r .IsDir (); errno != 0 {
return errno
} else if isDir {
return experimentalsys .EISDIR
}
return experimentalsys .EBADF
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .