Exemplo n.º 1
0
func main() {
	log.SetOutput(nullWriter{})
	flag.Parse()
	if flag.NArg() != 2 {
		fmt.Fprintln(os.Stderr, "usage: bundle addr dir")
		return
	}
	var err error
	fs, err = g9pc.Mount("tcp", flag.Arg(0), "")
	if err != nil {
		fmt.Fprintln(os.Stderr, "mount failed:", err)
		return
	}
	root := g9pc.NewNsFile(fs.Root.File())
	ns = &g9pc.Ns{Root: root, Dot: root}
	fmt.Println("mounted")
	dir := flag.Arg(1)
	if *old {
		go func() {
			oldwalk(dir)
			close(sum)
		}()
	} else {
		go func() {
			newwalk(dir, true)
			close(sum)
		}()
	}
	tot := int64(0)
	for n := range sum {
		tot += n
	}

	fmt.Printf("total: %d\n", tot)
}
Exemplo n.º 2
0
func main() {
	flag.Parse()

	naddr := *addr
	if strings.LastIndex(naddr, ":") == -1 {
		naddr = naddr + ":5640"
	}

	c, err := g9pc.Mount("tcp", naddr, "")
	if err != nil {
		log.Fatalf("error mounting %s: %v", naddr, err)
	}

	ns := new(g9pc.Ns)
	root, err := c.Walk("")
	if err != nil {
		log.Fatalf("error walking to /: %v", err)
	}
	ns.Root = g9pc.NewNsFile(root.File())
	ns.Dot = ns.Root

	if flag.NArg() > 0 {
		flags := flag.Args()
		for _, uc := range flags {
			cmd(ns, uc)
		}
	} else {
		interactive(ns)
	}

	return
}