// Allocate a file handle, held by the kernel until Release func (sc *serveConn) open(req *fuse.OpenRequest) { // This will be cheap, Lookup always preceeds Open, so the cache is warm f, err := sc.db.FileByInode(uint64(req.Header.Node)) if err != nil { req.RespondError(fuse.ENOENT) return } var hId uint64 if !req.Flags.IsReadOnly() { // write access requested if *readOnly { // TODO: if allow_other, require uid == invoking uid to allow writes req.RespondError(fuse.EPERM) return } r, w := io.Pipe() // plumbing between WriteRequest and Drive go sc.updateInDrive(f.File, r) hId = sc.allocHandle(req.Header.Node, w) } else { hId = sc.allocHandle(req.Header.Node, nil) } resp := fuse.OpenResponse{Handle: fuse.HandleID(hId)} fuse.Debug(fmt.Sprintf("Open Response: %+v", resp)) req.Respond(&resp) }
func (f *fs) handleOpen(r *fuse.OpenRequest) { log.Println("Inside handleOpen") log.Println(r) resp := &fuse.OpenResponse{} // For now use the inode as the file handle resp.Handle = f.handles.newFileHandle(r.Node) log.Println(resp) r.Respond(resp) }