shithub: mycel

Download patch

ref: e2ac43435940ad220871216999ef036dc64c915d
parent: f74ef2d6fc0188c94e824879883a4e5477ca82fe
author: Philip Silva <philip.silva@protonmail.com>
date: Fri Oct 22 12:48:13 EDT 2021

Missing files

--- /dev/null
+++ b/js/js_plan9.go
@@ -1,0 +1,10 @@
+package js
+
+import (
+	"io"
+	"os"
+)
+
+func callGojaCtl() (rwc io.ReadWriteCloser, err error) {
+	return os.OpenFile("/mnt/goja/ctl", os.O_RDWR, 0600)
+}
--- /dev/null
+++ b/js/js_unix.go
@@ -1,0 +1,41 @@
+//go:build !plan9
+
+package js
+
+import (
+	"9fans.net/go/plan9"
+	"9fans.net/go/plan9/client"
+	"fmt"
+	"github.com/psilva261/opossum/logger"
+	"io"
+	"os/user"
+)
+
+var fsys *client.Fsys
+
+func dial() (err error) {
+	log.Infof("Init...")
+	conn, err := client.DialService("goja")
+	if err != nil {
+		log.Fatalf("dial: %v", err)
+	}
+	u, err := user.Current()
+	if err != nil {
+		return
+	}
+	un := u.Username
+	fsys, err = conn.Attach(nil, un, "")
+	if err != nil {
+		log.Fatalf("attach: %v", err)
+	}
+	return
+}
+
+func callGojaCtl() (rwc io.ReadWriteCloser, err error) {
+	if fsys == nil {
+		if err := dial(); err != nil {
+			return nil, fmt.Errorf("dial: %v", err)
+		}
+	}
+	return fsys.Open("ctl", plan9.ORDWR)
+}