func (r *fsRoot) Lookup(ctx context.Context, instance string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
	if instance == "README" {
		return r.NewInode(ctx, &readme{}, fs.StableAttr{}), fs.OK
	}
	r.sockLock.Lock()
	defer r.sockLock.Unlock()
	if _, _, _, _, err := proxy.ParseInstanceConnectionName(instance); err != nil {
		return nil, syscall.ENOENT
	}
	if ret, ok := r.links[instance]; ok {
		return ret.EmbeddedInode(), fs.OK
	}
	path := filepath.Join(r.tmpDir, instance)
	os.RemoveAll(path)  
	linkpath := path
	if r.client != nil {
		version, err := r.client.InstanceVersionContext(ctx, instance)
		if err != nil {
			logging.Errorf("Failed to get Instance version for %s: %v", instance, err)
			return nil, syscall.ENOENT
		}
		if strings.HasPrefix(strings.ToLower(version), "postgres") {
			if err := os.MkdirAll(path, 0755); err != nil {
				logging.Errorf("Failed to create path %s: %v", path, err)
				return nil, syscall.EIO
			}
			path = filepath.Join(linkpath, ".s.PGSQL.5432")
		}
	}
	sock, err := net.Listen("unix", path)
	if err != nil {
		logging.Errorf("couldn't listen at %q: %v", path, err)
		return nil, syscall.EEXIST
	}
	if err := os.Chmod(path, 0777|os.ModeSocket); err != nil {
		logging.Errorf("couldn't update permissions for socket file %q: %v; other users may be unable to connect", path, err)
	}
	go r.listenerLifecycle(sock, instance, path)
	ret := &symlink{path: linkpath}
	inode := r.NewInode(ctx, ret, fs.StableAttr{Mode: 0777 | fuse.S_IFLNK})
	r.links[instance] = ret
	r.closers = append(r.closers, sock)
	return inode, fs.OK
}
Lookup implements fs.NodeLookuper and handles all requests, either for the
README, or for a new connection to a Cloud SQL instance. When receiving a
request for a Cloud SQL instance, Lookup will return a symlink to a Unix
socket that provides connectivity to a remote instance.
package fuse
import (
	"bytes"
	"errors"
	"fmt"
	"io"
	"net"
	"os"
	"path/filepath"
	"strings"
	"sync"
	"syscall"
	"time"
	"github.com/GoogleCloudPlatform/cloudsql-proxy/logging"
	"github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/proxy"
	"github.com/hanwen/go-fuse/v2/fs"
	"github.com/hanwen/go-fuse/v2/fuse"
	"github.com/hanwen/go-fuse/v2/fuse/nodefs"
	"golang.org/x/net/context"
)
func Supported() bool {
	return true
}
func NewConnSrc(mountdir, tmpdir string, client *proxy.Client, connset *proxy.ConnSet) (<-chan proxy.Conn, io.Closer, error) {
	if err := os.MkdirAll(tmpdir, 0777); err != nil {
		return nil, nil, err
	}
	if connset == nil {
		connset = proxy.NewConnSet()
	}
	conns := make(chan proxy.Conn, 1)
	root := &fsRoot{
		tmpDir:  tmpdir,
		linkDir: mountdir,
		dst:     conns,
		links:   make(map[string]*symlink),
		connset: connset,
		client:  client,
	}
	srv, err := fs.Mount(mountdir, root, &fs.Options{
		MountOptions: fuse.MountOptions{AllowOther: true},
	})
	if err != nil {
		return nil, nil, fmt.Errorf("FUSE mount failed: %q: %v", mountdir, err)
	}
	closer := fuseCloser(func() error {
		err := srv.Unmount()  
		if err != nil {
			logging.Errorf("Unmount failed: %v", err)
		}
		return root.Close()
	})
	return conns, closer, nil
}
type fuseCloser func() error
func (fc fuseCloser) Close() error {
	return fc()
}
type symlink struct {
	fs.Inode
	path string
}
var _ fs.NodeReadlinker = &symlink{}
func (s *symlink) Readlink(ctx context.Context) ([]byte, syscall.Errno) {
	return []byte(s.path), fs.OK
}
type fsRoot struct {
	fs.Inode
	tmpDir string
	linkDir string
	client  *proxy.Client
	connset *proxy.ConnSet
	sockLock sync.Mutex
	links    map[string]*symlink
	closers []io.Closer
	sync.RWMutex
	dst chan<- proxy.Conn
}
var _ interface {
	fs.InodeEmbedder
	fs.NodeGetattrer
	fs.NodeLookuper
	fs.NodeReaddirer
} = &fsRoot{}
func (r *fsRoot) newConn(instance string, c net.Conn) {
	r.RLock()
	if ch := r.dst; ch != nil {
		ch <- proxy.Conn{Instance: instance, Conn: c}
	} else {
		logging.Errorf("Ignored new conn request to %q: system has been closed", instance)
	}
	r.RUnlock()
}
func (r *fsRoot) Close() error {
	r.Lock()
	if r.dst != nil {
		close(r.dst)
		r.dst = nil
	}
	r.Unlock()
	var errs bytes.Buffer
	r.sockLock.Lock()
	for _, c := range r.closers {
		if err := c.Close(); err != nil {
			fmt.Fprintln(&errs, err)
		}
	}
	r.sockLock.Unlock()
	if errs.Len() == 0 {
		return nil
	}
	logging.Errorf("Close %q: %v", r.linkDir, errs.String())
	return errors.New(errs.String())
}
func (r *fsRoot) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno {
	*out = fuse.AttrOut{Attr: fuse.Attr{
		Mode: 0555 | fuse.S_IFDIR,
	}}
	return fs.OK
}