Initial commit

This commit is contained in:
2026-01-19 01:51:08 +02:00
commit 2dbb7e5d7e
18 changed files with 1475 additions and 0 deletions

61
ffs/rootdir.go Normal file
View File

@@ -0,0 +1,61 @@
package ffs
import (
"context"
"fmt"
"syscall"
"bazil.org/fuse"
"bazil.org/fuse/fs"
)
///////////////////////////////////////////////////////////////////////////////////////////////////
// CONSTANTS //////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const ROOT_INODE = 1
///////////////////////////////////////////////////////////////////////////////////////////////////
// TYPE: RootDir //////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
type RootDir struct {
_attr fuse.Attr
_nodes map[string]TopLevelDir
}
func (d *RootDir) Attr(ctx context.Context, a *fuse.Attr) error {
*a = d._attr
return nil
}
func (d *RootDir) Lookup(ctx context.Context, name string) (fs.Node, error) {
if name == "." {
return d, nil
}
node, exists := d._nodes[name]
if exists {
fmt.Printf("[D] RootDir.Lookup('%v'): OK\n", name)
return node, nil
}
fmt.Printf("[D] RootDir.Lookup('%v'): ENOENT\n", name)
return nil, syscall.ENOENT
}
func (d *RootDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
fmt.Printf("[D] RootDir.ReadDirAll()\n")
items := make([]fuse.Dirent, len(d._nodes))
i := 0
for name, node := range d._nodes {
items[i] = fuse.Dirent{
Inode: node.GetAttr().Inode,
Name: name,
Type: fuse.DT_Dir,
}
i++
}
return items, nil
}