github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/experimental/sys/unimplemented.go (about) 1 package sys 2 3 import ( 4 "io/fs" 5 6 "github.com/tetratelabs/wazero/sys" 7 ) 8 9 // UnimplementedFS is an FS that returns ENOSYS for all functions, 10 // This should be embedded to have forward compatible implementations. 11 type UnimplementedFS struct{} 12 13 // OpenFile implements FS.OpenFile 14 func (UnimplementedFS) OpenFile(path string, flag Oflag, perm fs.FileMode) (File, Errno) { 15 return nil, ENOSYS 16 } 17 18 // Lstat implements FS.Lstat 19 func (UnimplementedFS) Lstat(path string) (sys.Stat_t, Errno) { 20 return sys.Stat_t{}, ENOSYS 21 } 22 23 // Stat implements FS.Stat 24 func (UnimplementedFS) Stat(path string) (sys.Stat_t, Errno) { 25 return sys.Stat_t{}, ENOSYS 26 } 27 28 // Readlink implements FS.Readlink 29 func (UnimplementedFS) Readlink(path string) (string, Errno) { 30 return "", ENOSYS 31 } 32 33 // Mkdir implements FS.Mkdir 34 func (UnimplementedFS) Mkdir(path string, perm fs.FileMode) Errno { 35 return ENOSYS 36 } 37 38 // Chmod implements FS.Chmod 39 func (UnimplementedFS) Chmod(path string, perm fs.FileMode) Errno { 40 return ENOSYS 41 } 42 43 // Rename implements FS.Rename 44 func (UnimplementedFS) Rename(from, to string) Errno { 45 return ENOSYS 46 } 47 48 // Rmdir implements FS.Rmdir 49 func (UnimplementedFS) Rmdir(path string) Errno { 50 return ENOSYS 51 } 52 53 // Link implements FS.Link 54 func (UnimplementedFS) Link(_, _ string) Errno { 55 return ENOSYS 56 } 57 58 // Symlink implements FS.Symlink 59 func (UnimplementedFS) Symlink(_, _ string) Errno { 60 return ENOSYS 61 } 62 63 // Unlink implements FS.Unlink 64 func (UnimplementedFS) Unlink(path string) Errno { 65 return ENOSYS 66 } 67 68 // Utimens implements FS.Utimens 69 func (UnimplementedFS) Utimens(path string, atim, mtim int64) Errno { 70 return ENOSYS 71 } 72 73 // UnimplementedFile is a File that returns ENOSYS for all functions, 74 // except where no-op are otherwise documented. 75 // 76 // This should be embedded to have forward compatible implementations. 77 type UnimplementedFile struct{} 78 79 // Dev implements File.Dev 80 func (UnimplementedFile) Dev() (uint64, Errno) { 81 return 0, 0 82 } 83 84 // Ino implements File.Ino 85 func (UnimplementedFile) Ino() (sys.Inode, Errno) { 86 return 0, 0 87 } 88 89 // IsDir implements File.IsDir 90 func (UnimplementedFile) IsDir() (bool, Errno) { 91 return false, 0 92 } 93 94 // IsAppend implements File.IsAppend 95 func (UnimplementedFile) IsAppend() bool { 96 return false 97 } 98 99 // SetAppend implements File.SetAppend 100 func (UnimplementedFile) SetAppend(bool) Errno { 101 return ENOSYS 102 } 103 104 // Stat implements File.Stat 105 func (UnimplementedFile) Stat() (sys.Stat_t, Errno) { 106 return sys.Stat_t{}, ENOSYS 107 } 108 109 // Read implements File.Read 110 func (UnimplementedFile) Read([]byte) (int, Errno) { 111 return 0, ENOSYS 112 } 113 114 // Pread implements File.Pread 115 func (UnimplementedFile) Pread([]byte, int64) (int, Errno) { 116 return 0, ENOSYS 117 } 118 119 // Seek implements File.Seek 120 func (UnimplementedFile) Seek(int64, int) (int64, Errno) { 121 return 0, ENOSYS 122 } 123 124 // Readdir implements File.Readdir 125 func (UnimplementedFile) Readdir(int) (dirents []Dirent, errno Errno) { 126 return nil, ENOSYS 127 } 128 129 // Write implements File.Write 130 func (UnimplementedFile) Write([]byte) (int, Errno) { 131 return 0, ENOSYS 132 } 133 134 // Pwrite implements File.Pwrite 135 func (UnimplementedFile) Pwrite([]byte, int64) (int, Errno) { 136 return 0, ENOSYS 137 } 138 139 // Truncate implements File.Truncate 140 func (UnimplementedFile) Truncate(int64) Errno { 141 return ENOSYS 142 } 143 144 // Sync implements File.Sync 145 func (UnimplementedFile) Sync() Errno { 146 return 0 // not ENOSYS 147 } 148 149 // Datasync implements File.Datasync 150 func (UnimplementedFile) Datasync() Errno { 151 return 0 // not ENOSYS 152 } 153 154 // Utimens implements File.Utimens 155 func (UnimplementedFile) Utimens(int64, int64) Errno { 156 return ENOSYS 157 } 158 159 // Close implements File.Close 160 func (UnimplementedFile) Close() (errno Errno) { return }