github.com/grailbio/base@v0.0.11/file/fsnodefuse/inode.go (about)

     1  package fsnodefuse
     2  
     3  import (
     4  	"github.com/grailbio/base/file/fsnode"
     5  	"github.com/grailbio/base/log"
     6  	"github.com/hanwen/go-fuse/v2/fs"
     7  )
     8  
     9  // setFSNode updates inode to be backed by fsNode.  The caller must ensure that
    10  // inode and fsNode are compatible:
    11  //  *dirInode <-> fsnode.Parent
    12  //  *regInode <-> fsnode.Leaf
    13  func setFSNode(inode *fs.Inode, fsNode fsnode.T) {
    14  	switch embed := inode.Operations().(type) {
    15  	case *dirInode:
    16  		embed.mu.Lock()
    17  		embed.n = fsNode.(fsnode.Parent)
    18  		embed.mu.Unlock()
    19  	case *regInode:
    20  		embed.mu.Lock()
    21  		embed.n = fsNode.(fsnode.Leaf)
    22  		embed.mu.Unlock()
    23  	default:
    24  		log.Panicf("unexpected inodeEmbedder: %T", embed)
    25  	}
    26  }