Пример #1
0
func (c *ClientConn) attach(fc *plan9.Fcall) *plan9.Fcall {
	fc.Type = plan9.Rattach
	fc.Iounit = c.iounit
	fref, _ := c.createFileRef(c.explorer.Root(), FTDIR, 0)
	fc.Qid = fref.Qid
	c.bindFid(fc.Fid, fc.Qid.Path)
	return fc
}
Пример #2
0
func (c *ClientConn) open(fc *plan9.Fcall) *plan9.Fcall {
	fc.Type = plan9.Ropen
	if fref, has := c.fidRef(fc.Fid); has {
		err := c.explorer.Open(fref.Path, FileMode(fc.Mode))
		if err != nil {
			return c.unexpectedErr(fc, err)
		}
		fc.Iounit = c.iounit
		fc.Qid = fref.Qid
		return fc
	}
	return c.invalidFidErr(fc)
}
Пример #3
0
func (c *ClientConn) create(fc *plan9.Fcall) *plan9.Fcall {
	fc.Type = plan9.Rcreate
	if fref, have := c.fidRef(fc.Fid); have {
		file := File{Name: fc.Name}
		file.Type = FileType(fc.Mode)
		path, err := c.explorer.Create(fref.Path, file, uint32(fc.Perm))
		if err != nil {
			return c.unexpectedErr(fc, err)
		}
		cref, err := c.createFileRef(path, file.Type, 0)
		if err != nil {
			return c.unexpectedErr(fc, err)
		}
		fc.Iounit = c.iounit
		fc.Qid = cref.Qid
		c.unbindFid(fc.Fid)
		c.bindFid(fc.Fid, cref.Path)
		return fc
	}
	return c.invalidFidErr(fc)
}