It will help for us to rename earlier vs later, and syscallfs will be laborious, especially after we introduce an FSConfig type and need to declare a method name that differentiates from normal fs.FS. e.g. WithFS vs WithSysFS reads nicer than WithSyscallFS, and meanwhile sys is already a public package. Signed-off-by: Adrian Cole <adrian@tetrate.io>
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package sysfs
|
|
|
|
import (
|
|
"fmt"
|
|
"io/fs"
|
|
"syscall"
|
|
)
|
|
|
|
// UnimplementedFS is an FS that returns syscall.ENOSYS for all functions,
|
|
// This should be embedded to have forward compatible implementations.
|
|
type UnimplementedFS struct{}
|
|
|
|
// String implements fmt.Stringer
|
|
func (UnimplementedFS) String() string {
|
|
return "Unimplemented:/"
|
|
}
|
|
|
|
// Open implements the same method as documented on fs.FS
|
|
func (UnimplementedFS) Open(name string) (fs.File, error) {
|
|
panic(fmt.Errorf("unexpected to call fs.FS.Open(%s)", name))
|
|
}
|
|
|
|
// GuestDir implements FS.GuestDir
|
|
func (UnimplementedFS) GuestDir() string {
|
|
return "/"
|
|
}
|
|
|
|
// OpenFile implements FS.OpenFile
|
|
func (UnimplementedFS) OpenFile(path string, flag int, perm fs.FileMode) (fs.File, error) {
|
|
return nil, syscall.ENOSYS
|
|
}
|
|
|
|
// Mkdir implements FS.Mkdir
|
|
func (UnimplementedFS) Mkdir(path string, perm fs.FileMode) error {
|
|
return syscall.ENOSYS
|
|
}
|
|
|
|
// Rename implements FS.Rename
|
|
func (UnimplementedFS) Rename(from, to string) error {
|
|
return syscall.ENOSYS
|
|
}
|
|
|
|
// Rmdir implements FS.Rmdir
|
|
func (UnimplementedFS) Rmdir(path string) error {
|
|
return syscall.ENOSYS
|
|
}
|
|
|
|
// Unlink implements FS.Unlink
|
|
func (UnimplementedFS) Unlink(path string) error {
|
|
return syscall.ENOSYS
|
|
}
|
|
|
|
// Utimes implements FS.Utimes
|
|
func (UnimplementedFS) Utimes(path string, atimeNsec, mtimeNsec int64) error {
|
|
return syscall.ENOSYS
|
|
}
|