Skip to content

Commit ea93dec

Browse files
committed
runtime: debug9p config option, always handle export9p requests
1 parent 4f55fdb commit ea93dec

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

cmd/wanix/serve.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func serveCmd() *cli.Command {
3232
var (
3333
listenAddr string
3434
bundle string
35-
export9p bool
3635
)
3736
cmd := &cli.Command{
3837
Usage: "serve [dir]",
@@ -81,10 +80,7 @@ func serveCmd() *cli.Command {
8180

8281
http.Handle("/.well-known/", http.NotFoundHandler())
8382
http.Handle("/.well-known/ethernet", ethernetHandler(vn))
84-
85-
if export9p {
86-
http.Handle("/.well-known/export9p", export9pHandler())
87-
}
83+
http.Handle("/.well-known/export9p", export9pHandler())
8884

8985
p9srv := p9.NewServer(p9kit.Attacher(dirfs, p9kit.WithXattrAttrStore()))
9086

@@ -116,7 +112,6 @@ func serveCmd() *cli.Command {
116112
}
117113
cmd.Flags().StringVar(&listenAddr, "listen", ":7654", "addr to serve on")
118114
cmd.Flags().StringVar(&bundle, "bundle", "", "default bundle to use")
119-
cmd.Flags().BoolVar(&export9p, "export9p", false, "export 9p server")
120115
return cmd
121116
}
122117

@@ -194,7 +189,7 @@ func export9pHandler() http.Handler {
194189
log.Fatal(err)
195190
}
196191
addr := l.Addr().(*net.TCPAddr).String()
197-
log.Println("* 9p export at", addr)
192+
log.Println("9p export on", addr)
198193

199194
for {
200195
c, err := l.Accept()

runtime/assets/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
const w = new WanixRuntime({
1212
helpers: true,
1313
export9p: queryParams.get('export9p') === 'true',
14+
debug9p: queryParams.get('debug9p') === 'true',
1415
wasm: queryParams.get('wasm') || "./wanix.wasm",
1516
bundle: queryParams.get('bundle') || "/shell/bundle.tgz",
1617
network: queryParams.get('network') || "ws://localhost:7654/.well-known/ethernet"

runtime/wasm/main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ func main() {
4949
root.Bind("#vm", "vm")
5050
root.Bind("#|", "#console")
5151

52+
// if err := root.Namespace().Bind(idbfs.New("test"), ".", "idbfs"); err != nil {
53+
// log.Fatal(err)
54+
// }
55+
5256
bundleBytes := inst.Get("_bundle")
5357
if !bundleBytes.IsUndefined() {
5458
jsBuf := js.Global().Get("Uint8Array").New(bundleBytes)
@@ -90,6 +94,7 @@ func main() {
9094

9195
go api.PortResponder(inst.Call("_portConn", inst.Get("_sys").Get("port1")), root)
9296

97+
// this is still a bit of a hack and wip
9398
export9p := inst.Get("config").Get("export9p")
9499
if export9p.IsUndefined() {
95100
export9p = js.ValueOf(false)
@@ -123,6 +128,11 @@ func main() {
123128

124129
inst.Call("_wasmReady")
125130

126-
virtio9p.Serve(root.Namespace(), inst, false)
131+
debug := inst.Get("config").Get("debug9p")
132+
if debug.IsUndefined() {
133+
debug = js.ValueOf(false)
134+
}
135+
136+
virtio9p.Serve(root.Namespace(), inst, debug.Bool())
127137

128138
}

0 commit comments

Comments
 (0)