Exemplo n.º 1
0
func main() {
	pm, err := rpc.DialPortmapper("tcp", "stora.local")
	if err != nil {
		log.Fatalf("unable to contact portmapper: %v", err)
	}
	// get MOUNT port
	m := rpc.Mapping{
		Prog: nfs.MOUNT_PROG,
		Vers: nfs.MOUNT_VERS,
		Prot: rpc.IPPROTO_TCP,
		Port: 0,
	}
	port, err := pm.Getport(m)
	if err != nil {
		log.Fatalf("unable to get MOUNT port: %v", err)
	}
	log.Println("MOUNT", port)
	defer pm.Close()
	mount, err := nfs.DialMount("tcp", fmt.Sprintf("stora.local:%d", port))
	if err != nil {
		log.Fatal("unable to dial MOUNT service: %v", err)
	}
	defer mount.Close()
	auth := &rpc.AUTH_UNIX{
		Stamp:       1,
		Machinename: "localhost",
		Uid:         0,
		Gid:         0,
	}
	v, err := mount.Mount("/export", auth.Auth())
	if err != nil {
		log.Fatalf("unable to mount volume: %v", err)
	}
	v.Unmount()
}
Exemplo n.º 2
0
func main() {
	pm, err := rpc.DialPortmapper("tcp", "stora.local")
	if err != nil {
		log.Fatalf("unable to connect to portmapper: %v", err)
	}
	mappings, err := pm.Dump()
	if err != nil {
		log.Fatalf("failed to call PORTMAP.DUMP: %v", err)
	}
	fmt.Println("program\tvers\tproto\tport")
	for _, m := range mappings {
		fmt.Printf("%d\t%d\t%d\t%d\n", m.Prog, m.Vers, m.Prot, m.Port)
	}
	pm.Close()
}
Exemplo n.º 3
0
func main() {
	pm, err := rpc.DialPortmapper("tcp", "stora.local")
	if err != nil {
		log.Fatalf("unable to contact portmapper: %v", err)
	}
	// get MOUNT port
	m := rpc.Mapping{
		Prog: nfs.MOUNT_PROG,
		Vers: nfs.MOUNT_VERS,
		Prot: rpc.IPPROTO_TCP,
		Port: 0,
	}
	port, err := pm.Getport(m)
	if err != nil {
		log.Fatalf("unable to get MOUNT port: %v", err)
	}
	log.Println("MOUNT", port)
	pm.Close()
	mount, err := nfs.DialMount("tcp", fmt.Sprintf("stora.local:%d", port))
	if err != nil {
		log.Fatal("unable to dial MOUNT service: %v", err)
	}
	mount.Close()
}