Added FUSE support #55

Merged
Elara6331 merged 65 commits from yannickulrich/itd:fuse into master 2023-03-25 22:23:52 +00:00
Showing only changes of commit a8dc017a48 - Show all commits

View File

@ -49,6 +49,7 @@ type ITNode struct {
Ino uint64 Ino uint64
lst []DirEntry lst []DirEntry
self DirEntry
path string path string
} }
@ -188,7 +189,10 @@ func (n *ITNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*
Mode: fuse.S_IFREG, Mode: fuse.S_IFREG,
Ino: inodemap[file.path], Ino: inodemap[file.path],
} }
operations := &ITNode{kind: 2, path: file.path} operations := &ITNode{
kind: 2, path: file.path,
self: file,
}
child := n.NewInode(ctx, operations, stable) child := n.NewInode(ctx, operations, stable)
return child, 0 return child, 0
} }
@ -214,6 +218,24 @@ func (fh *bytesFileHandle) Read(ctx context.Context, dest []byte, off int64) (fu
var _ = (fs.NodeOpener)((*ITNode)(nil)) var _ = (fs.NodeOpener)((*ITNode)(nil))
func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) { func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle, fuseFlags uint32, errno syscall.Errno) {
switch f.kind { switch f.kind {
case 2:
// FS file
fp, err := myfs.Open(f.path)
if err != nil {
return nil, 0, syscall.EROFS
}
buf := make([]byte, f.self.size);
nread, err := fp.Read(buf)
if err != nil || nread != int(f.self.size) {
return nil, 0, syscall.EROFS
}
fh = &bytesFileHandle{
content: buf,
}
return fh, fuse.FOPEN_DIRECT_IO, 0
case 3: case 3:
// Device file // Device file