示例#1
0
文件: main.go 项目: wkharold/noeqd
func serveStats() {
	var addrslice []string
	var err error
	var saddr string
	var sf *StatsFile
	var s *srv.Fsrv

	root, err := mkroot()
	if err != nil {
		goto error
	}

	sf = new(StatsFile)
	err = sf.Add(root, "stats", p.OsUsers.Uid2User(os.Geteuid()), nil, 0444, sf)
	if err != nil {
		goto error
	}

	s = srv.NewFileSrv(root)
	s.Dotu = true

	addrslice = strings.Split(*laddr, ":")
	saddr = fmt.Sprintf("%s:%d", addrslice[0], *sport)

	s.Start(s)
	err = s.StartNetListener("tcp", saddr)
	if err != nil {
		goto error
	}

error:
	log.Printf("Error: %s\n", err)
}
示例#2
0
文件: timefs.go 项目: 9nut/plan9
func main() {
	var err error
	var tm *Time
	var ntm *InfTime
	var s *srv.Fsrv
	var p9c net.Conn
	var ch chan bool
	var usr *user.User

	flag.Parse()
	root := new(srv.File)
	usr, err = user.Current()
	if err != nil {
		goto error
	}
	// log.Println("running as User: "******"/", UserNone(usr.Uid), nil, p.DMDIR|0555, nil)
	if err != nil {
		goto error
	}

	tm = new(Time)
	err = tm.Add(root, "time", UserNone(usr.Uid), nil, 0444, tm)
	if err != nil {
		goto error
	}
	ntm = new(InfTime)
	err = ntm.Add(root, "inftime", UserNone(usr.Uid), nil, 0444, ntm)
	if err != nil {
		goto error
	}

	s = srv.NewFileSrv(root)
	s.Dotu = false
	s.Upool = NoneUsers{}

	if *debug {
		s.Debuglevel = 1
	}
	if *debugall {
		s.Debuglevel = 2
	}

	log.Println("starting tree")
	s.Start(s)
	p9c, err = NewSrvConn(*addr)
	if err != nil {
		goto error
	}
	log.Println("starting")
	s.NewConn(p9c)
	<-ch
	return

error:
	log.Println(fmt.Sprintf("Error: %s", err))
}
示例#3
0
func main() {
	var err error
	var tm *Time
	var ntm *InfTime
	var s *srv.Fsrv

	flag.Parse()
	user := p.OsUsers.Uid2User(os.Geteuid())
	root := new(srv.File)
	err = root.Add(nil, "/", user, nil, p.DMDIR|0555, nil)
	if err != nil {
		goto error
	}

	tm = new(Time)
	err = tm.Add(root, "time", p.OsUsers.Uid2User(os.Geteuid()), nil, 0444, tm)
	if err != nil {
		goto error
	}
	ntm = new(InfTime)
	err = ntm.Add(root, "inftime", p.OsUsers.Uid2User(os.Geteuid()), nil, 0444, ntm)
	if err != nil {
		goto error
	}

	s = srv.NewFileSrv(root)
	s.Dotu = true

	if *debug {
		s.Debuglevel = 1
	}
	if *debugall {
		s.Debuglevel = 2
	}

	s.Start(s)
	err = s.StartNetListener("tcp", *addr)
	if err != nil {
		goto error
	}

	return

error:
	log.Println(fmt.Sprintf("Error: %s", err))
}
示例#4
0
func main() {
	var err error
	var cl *Clone
	var s *srv.Fsrv

	flag.Parse()
	user := p.OsUsers.Uid2User(os.Geteuid())
	root = new(srv.File)
	err = root.Add(nil, "/", user, nil, p.DMDIR|0777, nil)
	if err != nil {
		goto error
	}

	cl = new(Clone)
	err = cl.Add(root, "clone", p.OsUsers.Uid2User(os.Geteuid()), nil, 0444, cl)
	if err != nil {
		goto error
	}

	s = srv.NewFileSrv(root)
	s.Dotu = true

	if *debug {
		s.Debuglevel = 1
	}

	s.Start(s)
	err = s.StartNetListener("tcp", *addr)
	if err != nil {
		goto error
	}
	return

error:
	log.Println(fmt.Sprintf("Error: %s", err))
}
示例#5
0
文件: main.go 项目: wkharold/noeqd
func serve9p() {
	var cl *Clone
	var err error
	var s *srv.Fsrv
	var sf *StatsFile

	root, err = mkroot()
	if err != nil {
		goto error
	}

	cl = new(Clone)
	err = cl.Add(root, "clone", p.OsUsers.Uid2User(os.Geteuid()), nil, 0444, cl)
	if err != nil {
		goto error
	}

	sf = new(StatsFile)
	err = sf.Add(root, "stats", p.OsUsers.Uid2User(os.Geteuid()), nil, 0444, sf)
	if err != nil {
		goto error
	}

	s = srv.NewFileSrv(root)
	s.Dotu = true

	s.Start(s)
	err = s.StartNetListener("tcp", *laddr)
	if err != nil {
		goto error
	}
	return

error:
	log.Fatalf("Error serving 9p: %s\n", err)
}