Example #1
0
func cd(root, cwd client.Fid, cmdline string) (client.Fid, error) {
	path, absolute := parsepath(cmdline)

	f := cwd
	if absolute {
		f = root
	}

	f, qs, err := f.Walk(path)
	if err != nil {
		return cwd, err
	}

	if qs[len(qs)-1].Type != qp.QTDIR {
		return cwd, errors.New("not a directory")
	}

	cwd.Clunk()
	return f, nil
}
Example #2
0
func getConn(ctlfid, rootfid client.Fid, network string) (client.Fid, error) {
	if _, _, err := ctlfid.Open(qp.ORDWR); err != nil {
		return nil, fmt.Errorf("unable to open ctl file: %v", err)
	}

	b, err := ctlfid.ReadOnce(0, 1024)
	if err != nil {
		return nil, fmt.Errorf("unable to read conn path: %v", err)
	}

	rf, _, err := rootfid.Walk([]string{network, string(b)})
	if err != nil {
		return nil, fmt.Errorf("unable to go to conn %s: %v", network+"/"+string(b), err)
	}

	return rf, nil
}