Example #1
0
File: timefs.go Project: 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))
}
Example #2
0
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)
}
Example #3
0
func main() {
	var err error
	var s *srv.Fsrv
	flag.Parse()

	useragent = *aflag
	timeout = *tflag

	root = new(srv.File)

	err = root.Add(nil, "/", user, user, p.DMDIR|0666, root)
	if err != nil {
		goto error
	}

	cl = new(Clone)
	if err = cl.Add(root, "clone", user, user, 0666, cl); err != nil {
		goto error
	}

	ctl = new(RootCtl)
	if err = ctl.Add(root, "ctl", user, user, 0666, ctl); err != nil {
		goto error
	}

	s = srv.NewFileSrv(root)
	s.Debuglevel = *debug
	s.Start(s)
	s.Id = "webfs"

	err = s.StartNetListener("tcp", *addr)
	if err != nil {
		goto error
	}
	/*
		webfs := new(Webfs)
		webfs.useragent = "hjdicks"
		webfs.timeout = 10000
		webfs.Id = "webfs"
		webfs.Debuglevel = 1
		webfs.Start(webfs)
		err := webfs.StartNetListener("tcp", ":5640")
		if err != nil {
			goto error
		}*/

	return

error:
	log.Println(fmt.Sprintf("Error: %s", err))

}
Example #4
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))
}
Example #5
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))
}
Example #6
0
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)
}