// Serve serves the FUSE connection by making calls to the methods // of fs and the Nodes and Handles it makes available. It returns only // when the connection has been closed or an unexpected error occurs. func (s *Server) Serve(c *fuse.Conn) error { sc := serveConn{ fs: s.FS, debug: s.Debug, req: map[fuse.RequestID]*serveRequest{}, dynamicInode: GenerateDynamicInode, } if sc.debug == nil { sc.debug = fuse.Debug } if dyn, ok := sc.fs.(FSInodeGenerator); ok { sc.dynamicInode = dyn.GenerateInode } root, err := sc.fs.Root() if err != nil { return fmt.Errorf("cannot obtain root node: %v", syscall.Errno(err.(fuse.Errno)).Error()) } sc.node = append(sc.node, nil, &serveNode{inode: 1, node: root, refs: 1}) sc.handle = append(sc.handle, nil) for { req, err := c.ReadRequest() if err != nil { if err == io.EOF { break } return err } go sc.serve(req) } return nil }
// Serve serves the FUSE connection by making calls to the methods // of fs and the Nodes and Handles it makes available. It returns only // when the connection has been closed or an unexpected error occurs. func Serve(c *fuse.Conn, fs FS) error { sc := serveConn{} sc.req = map[fuse.RequestID]*serveRequest{} root, err := fs.Root() if err != nil { return fmt.Errorf("cannot obtain root node: %v", syscall.Errno(err.(fuse.Errno)).Error()) } sc.node = append(sc.node, nil, &serveNode{name: "/", node: root}) sc.handle = append(sc.handle, nil) for { req, err := c.ReadRequest() if err != nil { if err == io.EOF { break } return err } go sc.serve(fs, req) } return nil }