Exemplo n.º 1
0
// Returns nil for invalid handles.
func (c *Server) getHandle(id fuse.HandleID) (shandle *serveHandle) {
	c.meta.Lock()
	defer c.meta.Unlock()
	if id < fuse.HandleID(len(c.handle)) {
		shandle = c.handle[uint(id)]
	}
	if shandle == nil {
		c.debug(missingHandle{
			Handle:    id,
			MaxHandle: fuse.HandleID(len(c.handle)),
		})
	}
	return
}
Exemplo n.º 2
0
func (o *OpenFileOp) toBazilfuseResponse() (bfResp interface{}) {
	resp := bazilfuse.OpenResponse{
		Handle: bazilfuse.HandleID(o.Handle),
	}
	bfResp = &resp

	return
}
Exemplo n.º 3
0
func (o *CreateFileOp) toBazilfuseResponse() (bfResp interface{}) {
	resp := bazilfuse.CreateResponse{
		OpenResponse: bazilfuse.OpenResponse{
			Handle: bazilfuse.HandleID(o.Handle),
		},
	}
	bfResp = &resp

	convertChildInodeEntry(&o.Entry, &resp.LookupResponse)

	return
}
Exemplo n.º 4
0
func (c *Server) saveHandle(handle Handle, nodeID fuse.NodeID) (id fuse.HandleID) {
	c.meta.Lock()
	shandle := &serveHandle{handle: handle, nodeID: nodeID}
	if n := len(c.freeHandle); n > 0 {
		id = c.freeHandle[n-1]
		c.freeHandle = c.freeHandle[:n-1]
		c.handle[id] = shandle
	} else {
		id = fuse.HandleID(len(c.handle))
		c.handle = append(c.handle, shandle)
	}
	c.meta.Unlock()
	return
}