fs: renames internal syscallfs package to sysfs and notes RATIONALE (#1056)
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>
This commit is contained in:
2
Makefile
2
Makefile
@@ -218,7 +218,7 @@ check:
|
|||||||
# The following checks help ensure our platform-specific code used for system
|
# The following checks help ensure our platform-specific code used for system
|
||||||
# calls safely falls back on a platform unsupported by the compiler engine.
|
# calls safely falls back on a platform unsupported by the compiler engine.
|
||||||
# This makes sure the intepreter can be used. Most often the package that can
|
# This makes sure the intepreter can be used. Most often the package that can
|
||||||
# drift here is "platform" or "syscallfs":
|
# drift here is "platform" or "sysfs":
|
||||||
#
|
#
|
||||||
# Ensure we build on an arbitrary operating system
|
# Ensure we build on an arbitrary operating system
|
||||||
@GOARCH=amd64 GOOS=dragonfly go build ./...
|
@GOARCH=amd64 GOOS=dragonfly go build ./...
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/tetratelabs/wazero/experimental/logging"
|
"github.com/tetratelabs/wazero/experimental/logging"
|
||||||
gojs "github.com/tetratelabs/wazero/imports/go"
|
gojs "github.com/tetratelabs/wazero/imports/go"
|
||||||
"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
|
"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
|
||||||
"github.com/tetratelabs/wazero/internal/syscallfs"
|
"github.com/tetratelabs/wazero/internal/sysfs"
|
||||||
"github.com/tetratelabs/wazero/internal/version"
|
"github.com/tetratelabs/wazero/internal/version"
|
||||||
"github.com/tetratelabs/wazero/sys"
|
"github.com/tetratelabs/wazero/sys"
|
||||||
)
|
)
|
||||||
@@ -227,8 +227,8 @@ func doRun(args []string, stdOut io.Writer, stdErr logging.Writer, exit func(cod
|
|||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateMounts(mounts sliceFlag, stdErr logging.Writer, exit func(code int)) syscallfs.FS {
|
func validateMounts(mounts sliceFlag, stdErr logging.Writer, exit func(code int)) sysfs.FS {
|
||||||
fs := make([]syscallfs.FS, 0, len(mounts))
|
fs := make([]sysfs.FS, 0, len(mounts))
|
||||||
for _, mount := range mounts {
|
for _, mount := range mounts {
|
||||||
if len(mount) == 0 {
|
if len(mount) == 0 {
|
||||||
fmt.Fprintln(stdErr, "invalid mount: empty string")
|
fmt.Fprintln(stdErr, "invalid mount: empty string")
|
||||||
@@ -261,18 +261,18 @@ func validateMounts(mounts sliceFlag, stdErr logging.Writer, exit func(code int)
|
|||||||
host = abs
|
host = abs
|
||||||
}
|
}
|
||||||
|
|
||||||
next, err := syscallfs.NewDirFS(host, guest)
|
next, err := sysfs.NewDirFS(host, guest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(stdErr, "invalid mount: %v\n", err)
|
fmt.Fprintf(stdErr, "invalid mount: %v\n", err)
|
||||||
exit(1)
|
exit(1)
|
||||||
} else {
|
} else {
|
||||||
if readOnly {
|
if readOnly {
|
||||||
next = syscallfs.NewReadFS(next)
|
next = sysfs.NewReadFS(next)
|
||||||
}
|
}
|
||||||
fs = append(fs, next)
|
fs = append(fs, next)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if fs, err := syscallfs.NewRootFS(fs...); err != nil {
|
if fs, err := sysfs.NewRootFS(fs...); err != nil {
|
||||||
fmt.Fprintf(stdErr, "invalid mounts %v: %v\n", fs, err)
|
fmt.Fprintf(stdErr, "invalid mounts %v: %v\n", fs, err)
|
||||||
exit(1)
|
exit(1)
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ package writefs
|
|||||||
import (
|
import (
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
|
||||||
"github.com/tetratelabs/wazero/internal/syscallfs"
|
"github.com/tetratelabs/wazero/internal/sysfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewDirFS creates a writeable filesystem at the given path on the host
|
// NewDirFS creates a writeable filesystem at the given path on the host
|
||||||
@@ -35,6 +35,6 @@ import (
|
|||||||
// Do not attempt to use the result as a fs.FS, as it will panic. This is a
|
// Do not attempt to use the result as a fs.FS, as it will panic. This is a
|
||||||
// bridge to a future filesystem abstraction made for wazero.
|
// bridge to a future filesystem abstraction made for wazero.
|
||||||
func NewDirFS(hostDir string) (fs.FS, error) {
|
func NewDirFS(hostDir string) (fs.FS, error) {
|
||||||
// syscallfs.DirFS is intentionally internal as it is still evolving
|
// sysfs.DirFS is intentionally internal as it is still evolving
|
||||||
return syscallfs.NewDirFS(hostDir, "/")
|
return sysfs.NewDirFS(hostDir, "/")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/tetratelabs/wazero/api"
|
"github.com/tetratelabs/wazero/api"
|
||||||
"github.com/tetratelabs/wazero/internal/platform"
|
"github.com/tetratelabs/wazero/internal/platform"
|
||||||
"github.com/tetratelabs/wazero/internal/sys"
|
"github.com/tetratelabs/wazero/internal/sys"
|
||||||
"github.com/tetratelabs/wazero/internal/syscallfs"
|
"github.com/tetratelabs/wazero/internal/sysfs"
|
||||||
. "github.com/tetratelabs/wazero/internal/wasi_snapshot_preview1"
|
. "github.com/tetratelabs/wazero/internal/wasi_snapshot_preview1"
|
||||||
"github.com/tetratelabs/wazero/internal/wasm"
|
"github.com/tetratelabs/wazero/internal/wasm"
|
||||||
)
|
)
|
||||||
@@ -513,7 +513,7 @@ func fdReadOrPread(mod api.Module, params []uint64, isPread bool) Errno {
|
|||||||
var resultNread uint32
|
var resultNread uint32
|
||||||
if isPread {
|
if isPread {
|
||||||
offset := int64(params[3])
|
offset := int64(params[3])
|
||||||
reader = syscallfs.ReaderAtOffset(r.File, offset)
|
reader = sysfs.ReaderAtOffset(r.File, offset)
|
||||||
resultNread = uint32(params[4])
|
resultNread = uint32(params[4])
|
||||||
} else {
|
} else {
|
||||||
resultNread = uint32(params[3])
|
resultNread = uint32(params[3])
|
||||||
@@ -1039,7 +1039,7 @@ func fdWriteOrPwrite(mod api.Module, params []uint64, isPwrite bool) Errno {
|
|||||||
return ErrnoBadf
|
return ErrnoBadf
|
||||||
} else if isPwrite {
|
} else if isPwrite {
|
||||||
offset := int64(params[3])
|
offset := int64(params[3])
|
||||||
writer = syscallfs.WriterAtOffset(f.File, offset)
|
writer = sysfs.WriterAtOffset(f.File, offset)
|
||||||
resultNwritten = uint32(params[4])
|
resultNwritten = uint32(params[4])
|
||||||
} else {
|
} else {
|
||||||
writer = f.File.(io.Writer)
|
writer = f.File.(io.Writer)
|
||||||
@@ -1180,7 +1180,7 @@ func pathFilestatGetFn(_ context.Context, mod api.Module, params []uint64) Errno
|
|||||||
resultBuf := uint32(params[4])
|
resultBuf := uint32(params[4])
|
||||||
|
|
||||||
// Stat the file without allocating a file descriptor
|
// Stat the file without allocating a file descriptor
|
||||||
stat, err := syscallfs.StatPath(fsc.FS(), pathName)
|
stat, err := sysfs.StatPath(fsc.FS(), pathName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ToErrno(err)
|
return ToErrno(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
"github.com/tetratelabs/wazero/internal/fstest"
|
"github.com/tetratelabs/wazero/internal/fstest"
|
||||||
"github.com/tetratelabs/wazero/internal/leb128"
|
"github.com/tetratelabs/wazero/internal/leb128"
|
||||||
"github.com/tetratelabs/wazero/internal/sys"
|
"github.com/tetratelabs/wazero/internal/sys"
|
||||||
"github.com/tetratelabs/wazero/internal/syscallfs"
|
"github.com/tetratelabs/wazero/internal/sysfs"
|
||||||
"github.com/tetratelabs/wazero/internal/testing/require"
|
"github.com/tetratelabs/wazero/internal/testing/require"
|
||||||
. "github.com/tetratelabs/wazero/internal/wasi_snapshot_preview1"
|
. "github.com/tetratelabs/wazero/internal/wasi_snapshot_preview1"
|
||||||
"github.com/tetratelabs/wazero/internal/wasm"
|
"github.com/tetratelabs/wazero/internal/wasm"
|
||||||
@@ -719,7 +719,7 @@ func Test_fdPread_Errors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_fdPrestatGet(t *testing.T) {
|
func Test_fdPrestatGet(t *testing.T) {
|
||||||
testfs, err := syscallfs.NewDirFS(t.TempDir(), "/")
|
testfs, err := sysfs.NewDirFS(t.TempDir(), "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(testfs))
|
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(testfs))
|
||||||
@@ -806,7 +806,7 @@ func Test_fdPrestatGet_Errors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_fdPrestatDirName(t *testing.T) {
|
func Test_fdPrestatDirName(t *testing.T) {
|
||||||
testfs, err := syscallfs.NewDirFS(t.TempDir(), "/")
|
testfs, err := sysfs.NewDirFS(t.TempDir(), "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(testfs))
|
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(testfs))
|
||||||
@@ -2283,7 +2283,7 @@ func Test_fdWrite_Errors(t *testing.T) {
|
|||||||
|
|
||||||
func Test_pathCreateDirectory(t *testing.T) {
|
func Test_pathCreateDirectory(t *testing.T) {
|
||||||
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
||||||
fs, err := syscallfs.NewDirFS(tmpDir, "/")
|
fs, err := sysfs.NewDirFS(tmpDir, "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
||||||
@@ -2314,7 +2314,7 @@ func Test_pathCreateDirectory(t *testing.T) {
|
|||||||
|
|
||||||
func Test_pathCreateDirectory_Errors(t *testing.T) {
|
func Test_pathCreateDirectory_Errors(t *testing.T) {
|
||||||
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
||||||
fs, err := syscallfs.NewDirFS(tmpDir, "/")
|
fs, err := sysfs.NewDirFS(tmpDir, "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
||||||
@@ -2602,9 +2602,9 @@ func Test_pathLink(t *testing.T) {
|
|||||||
|
|
||||||
func Test_pathOpen(t *testing.T) {
|
func Test_pathOpen(t *testing.T) {
|
||||||
dir := t.TempDir() // open before loop to ensure no locking problems.
|
dir := t.TempDir() // open before loop to ensure no locking problems.
|
||||||
writeFS, err := syscallfs.NewDirFS(dir, "/")
|
writeFS, err := sysfs.NewDirFS(dir, "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
readFS := syscallfs.NewReadFS(writeFS)
|
readFS := sysfs.NewReadFS(writeFS)
|
||||||
|
|
||||||
fileName := "file"
|
fileName := "file"
|
||||||
fileContents := []byte("012")
|
fileContents := []byte("012")
|
||||||
@@ -2638,7 +2638,7 @@ func Test_pathOpen(t *testing.T) {
|
|||||||
expectedLog string
|
expectedLog string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "syscallfs.ReadFS",
|
name: "sysfs.ReadFS",
|
||||||
fs: readFS,
|
fs: readFS,
|
||||||
path: func(*testing.T) string { return fileName },
|
path: func(*testing.T) string { return fileName },
|
||||||
expected: func(t *testing.T, fsc *sys.FSContext) {
|
expected: func(t *testing.T, fsc *sys.FSContext) {
|
||||||
@@ -2650,7 +2650,7 @@ func Test_pathOpen(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.DirFS",
|
name: "sysfs.DirFS",
|
||||||
fs: writeFS,
|
fs: writeFS,
|
||||||
path: func(*testing.T) string { return fileName },
|
path: func(*testing.T) string { return fileName },
|
||||||
expected: func(t *testing.T, fsc *sys.FSContext) {
|
expected: func(t *testing.T, fsc *sys.FSContext) {
|
||||||
@@ -2662,7 +2662,7 @@ func Test_pathOpen(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.ReadFS FD_APPEND",
|
name: "sysfs.ReadFS FD_APPEND",
|
||||||
fs: readFS,
|
fs: readFS,
|
||||||
fdflags: FD_APPEND,
|
fdflags: FD_APPEND,
|
||||||
path: func(t *testing.T) (file string) { return appendName },
|
path: func(t *testing.T) (file string) { return appendName },
|
||||||
@@ -2673,7 +2673,7 @@ func Test_pathOpen(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.DirFS FD_APPEND",
|
name: "sysfs.DirFS FD_APPEND",
|
||||||
fs: writeFS,
|
fs: writeFS,
|
||||||
path: func(t *testing.T) (file string) { return appendName },
|
path: func(t *testing.T) (file string) { return appendName },
|
||||||
fdflags: FD_APPEND,
|
fdflags: FD_APPEND,
|
||||||
@@ -2693,7 +2693,7 @@ func Test_pathOpen(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.ReadFS O_CREAT",
|
name: "sysfs.ReadFS O_CREAT",
|
||||||
fs: readFS,
|
fs: readFS,
|
||||||
oflags: O_CREAT,
|
oflags: O_CREAT,
|
||||||
expectedErrno: ErrnoNosys,
|
expectedErrno: ErrnoNosys,
|
||||||
@@ -2704,7 +2704,7 @@ func Test_pathOpen(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.DirFS O_CREAT",
|
name: "sysfs.DirFS O_CREAT",
|
||||||
fs: writeFS,
|
fs: writeFS,
|
||||||
path: func(t *testing.T) (file string) { return "creat" },
|
path: func(t *testing.T) (file string) { return "creat" },
|
||||||
oflags: O_CREAT,
|
oflags: O_CREAT,
|
||||||
@@ -2725,7 +2725,7 @@ func Test_pathOpen(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.ReadFS O_CREAT O_TRUNC",
|
name: "sysfs.ReadFS O_CREAT O_TRUNC",
|
||||||
fs: readFS,
|
fs: readFS,
|
||||||
oflags: O_CREAT | O_TRUNC,
|
oflags: O_CREAT | O_TRUNC,
|
||||||
expectedErrno: ErrnoNosys,
|
expectedErrno: ErrnoNosys,
|
||||||
@@ -2736,7 +2736,7 @@ func Test_pathOpen(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.DirFS O_CREAT O_TRUNC",
|
name: "sysfs.DirFS O_CREAT O_TRUNC",
|
||||||
fs: writeFS,
|
fs: writeFS,
|
||||||
path: func(t *testing.T) (file string) { return path.Join(dirName, "O_CREAT-O_TRUNC") },
|
path: func(t *testing.T) (file string) { return path.Join(dirName, "O_CREAT-O_TRUNC") },
|
||||||
oflags: O_CREAT | O_TRUNC,
|
oflags: O_CREAT | O_TRUNC,
|
||||||
@@ -2757,7 +2757,7 @@ func Test_pathOpen(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.ReadFS O_DIRECTORY",
|
name: "sysfs.ReadFS O_DIRECTORY",
|
||||||
fs: readFS,
|
fs: readFS,
|
||||||
oflags: O_DIRECTORY,
|
oflags: O_DIRECTORY,
|
||||||
path: func(*testing.T) string { return dirName },
|
path: func(*testing.T) string { return dirName },
|
||||||
@@ -2772,7 +2772,7 @@ func Test_pathOpen(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.DirFS O_DIRECTORY",
|
name: "sysfs.DirFS O_DIRECTORY",
|
||||||
fs: writeFS,
|
fs: writeFS,
|
||||||
path: func(*testing.T) string { return dirName },
|
path: func(*testing.T) string { return dirName },
|
||||||
oflags: O_DIRECTORY,
|
oflags: O_DIRECTORY,
|
||||||
@@ -2787,7 +2787,7 @@ func Test_pathOpen(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.ReadFS O_TRUNC",
|
name: "sysfs.ReadFS O_TRUNC",
|
||||||
fs: readFS,
|
fs: readFS,
|
||||||
oflags: O_TRUNC,
|
oflags: O_TRUNC,
|
||||||
expectedErrno: ErrnoNosys,
|
expectedErrno: ErrnoNosys,
|
||||||
@@ -2798,7 +2798,7 @@ func Test_pathOpen(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.DirFS O_TRUNC",
|
name: "sysfs.DirFS O_TRUNC",
|
||||||
fs: writeFS,
|
fs: writeFS,
|
||||||
path: func(t *testing.T) (file string) { return "trunc" },
|
path: func(t *testing.T) (file string) { return "trunc" },
|
||||||
oflags: O_TRUNC,
|
oflags: O_TRUNC,
|
||||||
@@ -2893,7 +2893,7 @@ func writeFile(t *testing.T, tmpDir, file string, contents []byte) {
|
|||||||
|
|
||||||
func Test_pathOpen_Errors(t *testing.T) {
|
func Test_pathOpen_Errors(t *testing.T) {
|
||||||
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
||||||
fs, err := syscallfs.NewDirFS(tmpDir, "/")
|
fs, err := sysfs.NewDirFS(tmpDir, "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
||||||
@@ -3037,7 +3037,7 @@ func Test_pathReadlink(t *testing.T) {
|
|||||||
|
|
||||||
func Test_pathRemoveDirectory(t *testing.T) {
|
func Test_pathRemoveDirectory(t *testing.T) {
|
||||||
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
||||||
fs, err := syscallfs.NewDirFS(tmpDir, "/")
|
fs, err := sysfs.NewDirFS(tmpDir, "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
||||||
@@ -3070,7 +3070,7 @@ func Test_pathRemoveDirectory(t *testing.T) {
|
|||||||
|
|
||||||
func Test_pathRemoveDirectory_Errors(t *testing.T) {
|
func Test_pathRemoveDirectory_Errors(t *testing.T) {
|
||||||
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
||||||
fs, err := syscallfs.NewDirFS(tmpDir, "/")
|
fs, err := sysfs.NewDirFS(tmpDir, "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
||||||
@@ -3208,7 +3208,7 @@ func Test_pathSymlink(t *testing.T) {
|
|||||||
|
|
||||||
func Test_pathRename(t *testing.T) {
|
func Test_pathRename(t *testing.T) {
|
||||||
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
||||||
fs, err := syscallfs.NewDirFS(tmpDir, "/")
|
fs, err := sysfs.NewDirFS(tmpDir, "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
||||||
@@ -3252,7 +3252,7 @@ func Test_pathRename(t *testing.T) {
|
|||||||
|
|
||||||
func Test_pathRename_Errors(t *testing.T) {
|
func Test_pathRename_Errors(t *testing.T) {
|
||||||
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
||||||
fs, err := syscallfs.NewDirFS(tmpDir, "/")
|
fs, err := sysfs.NewDirFS(tmpDir, "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
||||||
@@ -3428,7 +3428,7 @@ func Test_pathRename_Errors(t *testing.T) {
|
|||||||
|
|
||||||
func Test_pathUnlinkFile(t *testing.T) {
|
func Test_pathUnlinkFile(t *testing.T) {
|
||||||
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
||||||
fs, err := syscallfs.NewDirFS(tmpDir, "/")
|
fs, err := sysfs.NewDirFS(tmpDir, "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
||||||
@@ -3461,7 +3461,7 @@ func Test_pathUnlinkFile(t *testing.T) {
|
|||||||
|
|
||||||
func Test_pathUnlinkFile_Errors(t *testing.T) {
|
func Test_pathUnlinkFile_Errors(t *testing.T) {
|
||||||
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
tmpDir := t.TempDir() // open before loop to ensure no locking problems.
|
||||||
fs, err := syscallfs.NewDirFS(tmpDir, "/")
|
fs, err := sysfs.NewDirFS(tmpDir, "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(fs))
|
||||||
@@ -3572,13 +3572,13 @@ func requireOpenFile(t *testing.T, tmpDir string, pathName string, data []byte,
|
|||||||
require.NoError(t, os.WriteFile(realPath, data, 0o600))
|
require.NoError(t, os.WriteFile(realPath, data, 0o600))
|
||||||
}
|
}
|
||||||
|
|
||||||
writeFS, err := syscallfs.NewDirFS(tmpDir, "/")
|
writeFS, err := sysfs.NewDirFS(tmpDir, "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
testFS := writeFS
|
testFS := writeFS
|
||||||
if readOnly {
|
if readOnly {
|
||||||
oflags = os.O_RDONLY
|
oflags = os.O_RDONLY
|
||||||
testFS = syscallfs.NewReadFS(testFS)
|
testFS = sysfs.NewReadFS(testFS)
|
||||||
}
|
}
|
||||||
|
|
||||||
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(testFS))
|
mod, r, log := requireProxyModule(t, wazero.NewModuleConfig().WithFS(testFS))
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/tetratelabs/wazero"
|
"github.com/tetratelabs/wazero"
|
||||||
"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
|
"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
|
||||||
"github.com/tetratelabs/wazero/internal/syscallfs"
|
"github.com/tetratelabs/wazero/internal/sysfs"
|
||||||
"github.com/tetratelabs/wazero/internal/testing/require"
|
"github.com/tetratelabs/wazero/internal/testing/require"
|
||||||
"github.com/tetratelabs/wazero/sys"
|
"github.com/tetratelabs/wazero/sys"
|
||||||
)
|
)
|
||||||
@@ -51,7 +51,7 @@ func Test_fdReaddir_ls(t *testing.T) {
|
|||||||
func testFdReaddirLs(t *testing.T, bin []byte) {
|
func testFdReaddirLs(t *testing.T, bin []byte) {
|
||||||
// TODO: make a subfs
|
// TODO: make a subfs
|
||||||
moduleConfig := wazero.NewModuleConfig().
|
moduleConfig := wazero.NewModuleConfig().
|
||||||
WithFS(syscallfs.Adapt(fstest.MapFS{
|
WithFS(sysfs.Adapt(fstest.MapFS{
|
||||||
"-": {},
|
"-": {},
|
||||||
"a-": {Mode: fs.ModeDir},
|
"a-": {Mode: fs.ModeDir},
|
||||||
"ab-": {},
|
"ab-": {},
|
||||||
@@ -87,7 +87,7 @@ ENOTDIR
|
|||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
testFS[strconv.Itoa(i)] = &fstest.MapFile{}
|
testFS[strconv.Itoa(i)] = &fstest.MapFile{}
|
||||||
}
|
}
|
||||||
config := wazero.NewModuleConfig().WithFS(syscallfs.Adapt(testFS, "/")).WithArgs("wasi", "ls", ".")
|
config := wazero.NewModuleConfig().WithFS(sysfs.Adapt(testFS, "/")).WithArgs("wasi", "ls", ".")
|
||||||
console := compileAndRun(t, config, bin)
|
console := compileAndRun(t, config, bin)
|
||||||
|
|
||||||
lines := strings.Split(console, "\n")
|
lines := strings.Split(console, "\n")
|
||||||
@@ -112,7 +112,7 @@ func Test_fdReaddir_stat(t *testing.T) {
|
|||||||
func testFdReaddirStat(t *testing.T, bin []byte) {
|
func testFdReaddirStat(t *testing.T, bin []byte) {
|
||||||
moduleConfig := wazero.NewModuleConfig().WithArgs("wasi", "stat")
|
moduleConfig := wazero.NewModuleConfig().WithArgs("wasi", "stat")
|
||||||
|
|
||||||
console := compileAndRun(t, moduleConfig.WithFS(syscallfs.Adapt(fstest.MapFS{}, "/")), bin)
|
console := compileAndRun(t, moduleConfig.WithFS(sysfs.Adapt(fstest.MapFS{}, "/")), bin)
|
||||||
|
|
||||||
// TODO: switch this to a real stat test
|
// TODO: switch this to a real stat test
|
||||||
require.Equal(t, `
|
require.Equal(t, `
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Failures found here should result in new tests in the appropriate package,
|
// Failures found here should result in new tests in the appropriate package,
|
||||||
// for example, gojs, syscallfs or wasi_snapshot_preview1.
|
// for example, gojs, sysfs or wasi_snapshot_preview1.
|
||||||
//
|
//
|
||||||
// This package must have no dependencies. Otherwise, compiling this with
|
// This package must have no dependencies. Otherwise, compiling this with
|
||||||
// TinyGo or `GOARCH=wasm GOOS=js` can become bloated or complicated.
|
// TinyGo or `GOARCH=wasm GOOS=js` can become bloated or complicated.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/tetratelabs/wazero/internal/gojs/goos"
|
"github.com/tetratelabs/wazero/internal/gojs/goos"
|
||||||
"github.com/tetratelabs/wazero/internal/platform"
|
"github.com/tetratelabs/wazero/internal/platform"
|
||||||
internalsys "github.com/tetratelabs/wazero/internal/sys"
|
internalsys "github.com/tetratelabs/wazero/internal/sys"
|
||||||
"github.com/tetratelabs/wazero/internal/syscallfs"
|
"github.com/tetratelabs/wazero/internal/sysfs"
|
||||||
"github.com/tetratelabs/wazero/internal/wasm"
|
"github.com/tetratelabs/wazero/internal/wasm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ func (jsfsStat) invoke(ctx context.Context, mod api.Module, args ...interface{})
|
|||||||
func syscallStat(mod api.Module, path string) (*jsSt, error) {
|
func syscallStat(mod api.Module, path string) (*jsSt, error) {
|
||||||
fsc := mod.(*wasm.CallContext).Sys.FS()
|
fsc := mod.(*wasm.CallContext).Sys.FS()
|
||||||
|
|
||||||
if stat, err := syscallfs.StatPath(fsc.FS(), path); err != nil {
|
if stat, err := sysfs.StatPath(fsc.FS(), path); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
return newJsSt(stat), nil
|
return newJsSt(stat), nil
|
||||||
@@ -278,7 +278,7 @@ func syscallRead(mod api.Module, fd uint32, offset interface{}, p []byte) (n uin
|
|||||||
var reader io.Reader = f.File
|
var reader io.Reader = f.File
|
||||||
|
|
||||||
if offset != nil {
|
if offset != nil {
|
||||||
reader = syscallfs.ReaderAtOffset(f.File, toInt64(offset))
|
reader = sysfs.ReaderAtOffset(f.File, toInt64(offset))
|
||||||
}
|
}
|
||||||
|
|
||||||
if nRead, e := reader.Read(p); e == nil || e == io.EOF {
|
if nRead, e := reader.Read(p); e == nil || e == io.EOF {
|
||||||
@@ -324,7 +324,7 @@ func syscallWrite(mod api.Module, fd uint32, offset interface{}, p []byte) (n ui
|
|||||||
if f, ok := fsc.LookupFile(fd); !ok {
|
if f, ok := fsc.LookupFile(fd); !ok {
|
||||||
err = syscall.EBADF
|
err = syscall.EBADF
|
||||||
} else if offset != nil {
|
} else if offset != nil {
|
||||||
writer = syscallfs.WriterAtOffset(f.File, toInt64(offset))
|
writer = sysfs.WriterAtOffset(f.File, toInt64(offset))
|
||||||
} else {
|
} else {
|
||||||
writer = f.File.(io.Writer)
|
writer = f.File.(io.Writer)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/tetratelabs/wazero/experimental/writefs"
|
"github.com/tetratelabs/wazero/experimental/writefs"
|
||||||
"github.com/tetratelabs/wazero/internal/fstest"
|
"github.com/tetratelabs/wazero/internal/fstest"
|
||||||
"github.com/tetratelabs/wazero/internal/platform"
|
"github.com/tetratelabs/wazero/internal/platform"
|
||||||
"github.com/tetratelabs/wazero/internal/syscallfs"
|
"github.com/tetratelabs/wazero/internal/sysfs"
|
||||||
"github.com/tetratelabs/wazero/internal/testing/require"
|
"github.com/tetratelabs/wazero/internal/testing/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ func Test_testfs(t *testing.T) {
|
|||||||
require.NoError(t, os.Mkdir(testfsDir, 0o700))
|
require.NoError(t, os.Mkdir(testfsDir, 0o700))
|
||||||
require.NoError(t, fstest.WriteTestFiles(testfsDir))
|
require.NoError(t, fstest.WriteTestFiles(testfsDir))
|
||||||
|
|
||||||
rootFS, err := syscallfs.NewDirFS(tmpDir, "/")
|
rootFS, err := sysfs.NewDirFS(tmpDir, "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
stdout, stderr, err := compileAndRun(testCtx, "testfs", wazero.NewModuleConfig().WithFS(rootFS))
|
stdout, stderr, err := compileAndRun(testCtx, "testfs", wazero.NewModuleConfig().WithFS(rootFS))
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tetratelabs/wazero/internal/platform"
|
"github.com/tetratelabs/wazero/internal/platform"
|
||||||
"github.com/tetratelabs/wazero/internal/syscallfs"
|
"github.com/tetratelabs/wazero/internal/sysfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -108,7 +108,7 @@ func (stdioFileInfo) IsDir() bool { return false }
|
|||||||
func (stdioFileInfo) Sys() interface{} { return nil }
|
func (stdioFileInfo) Sys() interface{} { return nil }
|
||||||
|
|
||||||
type lazyDir struct {
|
type lazyDir struct {
|
||||||
fs syscallfs.FS
|
fs sysfs.FS
|
||||||
f fs.File
|
f fs.File
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ type ReadDir struct {
|
|||||||
|
|
||||||
type FSContext struct {
|
type FSContext struct {
|
||||||
// fs is the root ("/") mount.
|
// fs is the root ("/") mount.
|
||||||
fs syscallfs.FS
|
fs sysfs.FS
|
||||||
|
|
||||||
// openedFiles is a map of file descriptor numbers (>=FdPreopen) to open files
|
// openedFiles is a map of file descriptor numbers (>=FdPreopen) to open files
|
||||||
// (or directories) and defaults to empty.
|
// (or directories) and defaults to empty.
|
||||||
@@ -210,15 +210,15 @@ type FSContext struct {
|
|||||||
// NewFSContext creates a FSContext with stdio streams and an optional
|
// NewFSContext creates a FSContext with stdio streams and an optional
|
||||||
// pre-opened filesystem.
|
// pre-opened filesystem.
|
||||||
//
|
//
|
||||||
// If `preopened` is not syscallfs.UnimplementedFS, it is inserted into
|
// If `preopened` is not sysfs.UnimplementedFS, it is inserted into
|
||||||
// the file descriptor table as FdPreopen.
|
// the file descriptor table as FdPreopen.
|
||||||
func NewFSContext(stdin io.Reader, stdout, stderr io.Writer, preopened syscallfs.FS) (fsc *FSContext, err error) {
|
func NewFSContext(stdin io.Reader, stdout, stderr io.Writer, preopened sysfs.FS) (fsc *FSContext, err error) {
|
||||||
fsc = &FSContext{fs: preopened}
|
fsc = &FSContext{fs: preopened}
|
||||||
fsc.openedFiles.Insert(stdinReader(stdin))
|
fsc.openedFiles.Insert(stdinReader(stdin))
|
||||||
fsc.openedFiles.Insert(stdioWriter(stdout, noopStdoutStat))
|
fsc.openedFiles.Insert(stdioWriter(stdout, noopStdoutStat))
|
||||||
fsc.openedFiles.Insert(stdioWriter(stderr, noopStderrStat))
|
fsc.openedFiles.Insert(stdioWriter(stderr, noopStderrStat))
|
||||||
|
|
||||||
if _, ok := preopened.(syscallfs.UnimplementedFS); ok {
|
if _, ok := preopened.(sysfs.UnimplementedFS); ok {
|
||||||
return fsc, nil
|
return fsc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +267,7 @@ func (s fileModeStat) IsDir() bool { return false }
|
|||||||
|
|
||||||
// FS returns the underlying filesystem. Any files that should be added to the
|
// FS returns the underlying filesystem. Any files that should be added to the
|
||||||
// table should be inserted via InsertFile.
|
// table should be inserted via InsertFile.
|
||||||
func (c *FSContext) FS() syscallfs.FS {
|
func (c *FSContext) FS() sysfs.FS {
|
||||||
return c.fs
|
return c.fs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"testing/fstest"
|
"testing/fstest"
|
||||||
|
|
||||||
"github.com/tetratelabs/wazero/internal/syscallfs"
|
"github.com/tetratelabs/wazero/internal/sysfs"
|
||||||
testfs "github.com/tetratelabs/wazero/internal/testing/fs"
|
testfs "github.com/tetratelabs/wazero/internal/testing/fs"
|
||||||
"github.com/tetratelabs/wazero/internal/testing/require"
|
"github.com/tetratelabs/wazero/internal/testing/require"
|
||||||
)
|
)
|
||||||
@@ -31,31 +31,31 @@ func TestNewFSContext(t *testing.T) {
|
|||||||
embedFS, err := fs.Sub(testdata, "testdata")
|
embedFS, err := fs.Sub(testdata, "testdata")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
dirfs, err := syscallfs.NewDirFS(".", "/")
|
dirfs, err := sysfs.NewDirFS(".", "/")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Test various usual configuration for the file system.
|
// Test various usual configuration for the file system.
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
fs syscallfs.FS
|
fs sysfs.FS
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "embed.FS",
|
name: "embed.FS",
|
||||||
fs: syscallfs.Adapt(embedFS, "/"),
|
fs: sysfs.Adapt(embedFS, "/"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.NewDirFS",
|
name: "sysfs.NewDirFS",
|
||||||
// Don't use "testdata" because it may not be present in
|
// Don't use "testdata" because it may not be present in
|
||||||
// cross-architecture (a.k.a. scratch) build containers.
|
// cross-architecture (a.k.a. scratch) build containers.
|
||||||
fs: dirfs,
|
fs: dirfs,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "syscallfs.NewReadFS",
|
name: "sysfs.NewReadFS",
|
||||||
fs: syscallfs.NewReadFS(dirfs),
|
fs: sysfs.NewReadFS(dirfs),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "fstest.MapFS",
|
name: "fstest.MapFS",
|
||||||
fs: syscallfs.Adapt(fstest.MapFS{}, "/"),
|
fs: sysfs.Adapt(fstest.MapFS{}, "/"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,10 +96,10 @@ func TestNewFSContext(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUnimplementedFSContext(t *testing.T) {
|
func TestUnimplementedFSContext(t *testing.T) {
|
||||||
testFS, err := NewFSContext(nil, nil, nil, syscallfs.UnimplementedFS{})
|
testFS, err := NewFSContext(nil, nil, nil, sysfs.UnimplementedFS{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
expected := &FSContext{fs: syscallfs.UnimplementedFS{}}
|
expected := &FSContext{fs: sysfs.UnimplementedFS{}}
|
||||||
expected.openedFiles.Insert(noopStdin)
|
expected.openedFiles.Insert(noopStdin)
|
||||||
expected.openedFiles.Insert(noopStdout)
|
expected.openedFiles.Insert(noopStdout)
|
||||||
expected.openedFiles.Insert(noopStderr)
|
expected.openedFiles.Insert(noopStderr)
|
||||||
@@ -109,12 +109,12 @@ func TestUnimplementedFSContext(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Closes opened files
|
// Closes opened files
|
||||||
require.Equal(t, &FSContext{fs: syscallfs.UnimplementedFS{}}, testFS)
|
require.Equal(t, &FSContext{fs: sysfs.UnimplementedFS{}}, testFS)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContext_Close(t *testing.T) {
|
func TestContext_Close(t *testing.T) {
|
||||||
testFS := syscallfs.Adapt(testfs.FS{"foo": &testfs.File{}}, "/")
|
testFS := sysfs.Adapt(testfs.FS{"foo": &testfs.File{}}, "/")
|
||||||
|
|
||||||
fsc, err := NewFSContext(nil, nil, nil, testFS)
|
fsc, err := NewFSContext(nil, nil, nil, testFS)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -139,7 +139,7 @@ func TestContext_Close(t *testing.T) {
|
|||||||
func TestContext_Close_Error(t *testing.T) {
|
func TestContext_Close_Error(t *testing.T) {
|
||||||
file := &testfs.File{CloseErr: errors.New("error closing")}
|
file := &testfs.File{CloseErr: errors.New("error closing")}
|
||||||
|
|
||||||
testFS := syscallfs.Adapt(testfs.FS{"foo": file}, "/")
|
testFS := sysfs.Adapt(testfs.FS{"foo": file}, "/")
|
||||||
|
|
||||||
fsc, err := NewFSContext(nil, nil, nil, testFS)
|
fsc, err := NewFSContext(nil, nil, nil, testFS)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tetratelabs/wazero/internal/platform"
|
"github.com/tetratelabs/wazero/internal/platform"
|
||||||
"github.com/tetratelabs/wazero/internal/syscallfs"
|
"github.com/tetratelabs/wazero/internal/sysfs"
|
||||||
"github.com/tetratelabs/wazero/sys"
|
"github.com/tetratelabs/wazero/sys"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ func (c *Context) Nanosleep(ns int64) {
|
|||||||
(*(c.nanosleep))(ns)
|
(*(c.nanosleep))(ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FS returns the possibly empty (syscallfs.UnimplementedFS) file system context.
|
// FS returns the possibly empty (sysfs.UnimplementedFS) file system context.
|
||||||
func (c *Context) FS() *FSContext {
|
func (c *Context) FS() *FSContext {
|
||||||
return c.fsc
|
return c.fsc
|
||||||
}
|
}
|
||||||
@@ -182,9 +182,9 @@ func NewContext(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if fs != nil {
|
if fs != nil {
|
||||||
sysCtx.fsc, err = NewFSContext(stdin, stdout, stderr, syscallfs.Adapt(fs, "/"))
|
sysCtx.fsc, err = NewFSContext(stdin, stdout, stderr, sysfs.Adapt(fs, "/"))
|
||||||
} else {
|
} else {
|
||||||
sysCtx.fsc, err = NewFSContext(stdin, stdout, stderr, syscallfs.UnimplementedFS{})
|
sysCtx.fsc, err = NewFSContext(stdin, stdout, stderr, sysfs.UnimplementedFS{})
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tetratelabs/wazero/internal/platform"
|
"github.com/tetratelabs/wazero/internal/platform"
|
||||||
"github.com/tetratelabs/wazero/internal/syscallfs"
|
"github.com/tetratelabs/wazero/internal/sysfs"
|
||||||
testfs "github.com/tetratelabs/wazero/internal/testing/fs"
|
testfs "github.com/tetratelabs/wazero/internal/testing/fs"
|
||||||
"github.com/tetratelabs/wazero/internal/testing/require"
|
"github.com/tetratelabs/wazero/internal/testing/require"
|
||||||
"github.com/tetratelabs/wazero/sys"
|
"github.com/tetratelabs/wazero/sys"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestContext_FS(t *testing.T) {
|
func TestContext_FS(t *testing.T) {
|
||||||
sysCtx := DefaultContext(syscallfs.UnimplementedFS{})
|
sysCtx := DefaultContext(sysfs.UnimplementedFS{})
|
||||||
|
|
||||||
fsc, err := NewFSContext(nil, nil, nil, syscallfs.UnimplementedFS{})
|
fsc, err := NewFSContext(nil, nil, nil, sysfs.UnimplementedFS{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, fsc, sysCtx.FS())
|
require.Equal(t, fsc, sysCtx.FS())
|
||||||
@@ -51,7 +51,7 @@ func TestDefaultSysContext(t *testing.T) {
|
|||||||
require.Equal(t, &ns, sysCtx.nanosleep)
|
require.Equal(t, &ns, sysCtx.nanosleep)
|
||||||
require.Equal(t, platform.NewFakeRandSource(), sysCtx.RandSource())
|
require.Equal(t, platform.NewFakeRandSource(), sysCtx.RandSource())
|
||||||
|
|
||||||
testFS := syscallfs.Adapt(testfs.FS{}, "/")
|
testFS := sysfs.Adapt(testfs.FS{}, "/")
|
||||||
expectedFS, _ := NewFSContext(nil, nil, nil, testFS)
|
expectedFS, _ := NewFSContext(nil, nil, nil, testFS)
|
||||||
|
|
||||||
expectedOpenedFiles := FileTable{}
|
expectedOpenedFiles := FileTable{}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@@ -155,7 +155,7 @@ func TestAdapt_TestFS(t *testing.T) {
|
|||||||
tc := tc
|
tc := tc
|
||||||
|
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
// Adapt a normal fs.FS to syscallfs.FS
|
// Adapt a normal fs.FS to sysfs.FS
|
||||||
testFS := Adapt(tc.fs, "/")
|
testFS := Adapt(tc.fs, "/")
|
||||||
|
|
||||||
// Adapt it back to fs.FS and run the tests
|
// Adapt it back to fs.FS and run the tests
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/fs"
|
"io/fs"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
//go:build !windows
|
//go:build !windows
|
||||||
|
|
||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import "syscall"
|
import "syscall"
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
package syscallfs
|
// Package sysfs includes a low-level filesystem interface and utilities needed
|
||||||
|
// for WebAssembly host functions (ABI) such as WASI and runtime.GOOS=js.
|
||||||
|
//
|
||||||
|
// The name sysfs was chosen because wazero's public API has a "sys" package,
|
||||||
|
// which was named after https://github.com/golang/sys.
|
||||||
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
@@ -423,7 +423,7 @@ func TestWriterAtOffset(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
fs FS
|
fs FS
|
||||||
}{
|
}{
|
||||||
{name: "syscallfs.dirFS", fs: dirFS},
|
{name: "sysfs.dirFS", fs: dirFS},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
@@ -490,7 +490,7 @@ func TestWriterAtOffset_empty(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
fs FS
|
fs FS
|
||||||
}{
|
}{
|
||||||
{name: "syscallfs.dirFS", fs: dirFS},
|
{name: "sysfs.dirFS", fs: dirFS},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package syscallfs
|
package sysfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
Reference in New Issue
Block a user