MCPcopy
hub / github.com/perkeep/perkeep / Open

Method Open

pkg/fs/mut.go:666–693  ·  view source on GitHub ↗

Empirically: open for read: req.Flags == 0 open for append: req.Flags == 1 open for write: req.Flags == 1 open for read/write (+<) == 2 (bitmask? of?) open flags are O_WRONLY (1), O_RDONLY (0), or O_RDWR (2). and also bitmaks of O_SYMLINK (0x200000) maybe. (from fuse_filehandle_xlate_to_o

(ctx context.Context, req *fuse.OpenRequest, res *fuse.OpenResponse)

Source from the content-addressed store, hash-verified

664// bitmaks of O_SYMLINK (0x200000) maybe. (from
665// fuse_filehandle_xlate_to_oflags in macosx/kext/fuse_file.h)
666func (n *mutFile) Open(ctx context.Context, req *fuse.OpenRequest, res *fuse.OpenResponse) (fs.Handle, error) {
667 mutFileOpen.Incr()
668
669 Logger.Printf("mutFile.Open: %v: content: %v dir=%v flags=%v", n.permanode, n.content, req.Dir, req.Flags)
670 r, err := schema.NewFileReader(ctx, n.fs.fetcher, n.content)
671 if err != nil {
672 mutFileOpenError.Incr()
673 Logger.Printf("mutFile.Open: %v", err)
674 return nil, handleEIOorEINTR(err)
675 }
676
677 // Read-only.
678 if !isWriteFlags(req.Flags) {
679 mutFileOpenRO.Incr()
680 Logger.Printf("mutFile.Open returning read-only file")
681 n := &node{
682 fs: n.fs,
683 blobref: n.content,
684 }
685 return &nodeReader{n: n, fr: r}, nil
686 }
687
688 mutFileOpenRW.Incr()
689 Logger.Printf("mutFile.Open returning read-write filehandle")
690
691 defer r.Close()
692 return n.newHandle(r)
693}
694
695func (n *mutFile) Fsync(ctx context.Context, r *fuse.FsyncRequest) error {
696 // TODO(adg): in the fuse package, plumb through fsync to mutFileHandle

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
newHandleMethod · 0.95
NewFileReaderFunction · 0.92
handleEIOorEINTRFunction · 0.85
isWriteFlagsFunction · 0.85
PrintfMethod · 0.80
IncrMethod · 0.45

Tested by

no test coverage detected