Esempio n. 1
0
func main() {
	var err error

	flag.Parse()
	f, err := nullfs.NewNullFS(*debug)
	if err != nil {
		log.Fatalf("New NullFS failure: %v", err)
	}
	if err = f.StartNetListener("tcp", *addr); err != nil {
		log.Fatalf("Start failure: %v", err)
	}
}
Esempio n. 2
0
func BenchmarkAttach(b *testing.B) {
	var err error
	flag.Parse()
	n, err := nullfs.NewNullFS(*debug)
	if err != nil {
		b.Fatalf("could not start NullFS: %v", err)
	}
	n.Dotu = false
	n.Id = "nullfs"
	n.Start(n)

	b.Log("nullfs starting\n")
	l, err := net.Listen("unix", "")
	if err != nil {
		b.Fatalf("Can not start listener: %v", err)
	}
	srvAddr := l.Addr().String()
	b.Logf("Server is at %v", srvAddr)
	go func() {
		if err = n.StartListener(l); err != nil {
			b.Fatalf("Can not start listener: %v", err)
		}
	}()
	user := ninep.OsUsers.Uid2User(os.Geteuid())
	for i := 0; i < b.N; i++ {
		var conn net.Conn
		if conn, err = net.Dial("unix", srvAddr); err != nil {
			b.Fatalf("%v", err)
		} else {
			b.Logf("Got a conn, %v\n", conn)
		}

		clnt, err := Mount("unix", srvAddr, "/", 8192, user)
		if err != nil {
			b.Fatalf("Connect failed: %v\n", err)
		}

		clnt.Unmount()
	}
}