fix inode collision

This commit is contained in:
Massaki Archambault 2024-08-09 16:34:45 -04:00
parent caa030b03b
commit 70f269e25e
3 changed files with 13 additions and 5 deletions

View File

@ -8,6 +8,10 @@ import (
"github.com/hanwen/go-fuse/v2/fuse"
)
const (
groupBaseInode = 1_000_000_000
)
type groupNode struct {
fs.Inode
param *FSParam
@ -48,14 +52,14 @@ func (n *groupNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
for groupName, group := range groups {
entries = append(entries, fuse.DirEntry{
Name: groupName,
Ino: group.GetGroupID(),
Ino: group.GetGroupID() + groupBaseInode,
Mode: fuse.S_IFDIR,
})
}
for repositoryName, repository := range repositories {
entries = append(entries, fuse.DirEntry{
Name: repositoryName,
Ino: repository.GetRepositoryID(),
Ino: repository.GetRepositoryID() + repositoryBaseInode,
Mode: fuse.S_IFLNK,
})
}
@ -78,7 +82,7 @@ func (n *groupNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut)
group, found := groups[name]
if found {
attrs := fs.StableAttr{
Ino: group.GetGroupID(),
Ino: group.GetGroupID() + groupBaseInode,
Mode: fuse.S_IFDIR,
}
groupNode, _ := newGroupNodeFromSource(group, n.param)
@ -89,7 +93,7 @@ func (n *groupNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut)
repository, found := repositories[name]
if found {
attrs := fs.StableAttr{
Ino: repository.GetRepositoryID(),
Ino: repository.GetRepositoryID() + repositoryBaseInode,
Mode: fuse.S_IFLNK,
}
repositoryNode, _ := newRepositoryNodeFromSource(repository, n.param)

View File

@ -7,6 +7,10 @@ import (
"github.com/hanwen/go-fuse/v2/fs"
)
const (
repositoryBaseInode = 2_000_000_000
)
type repositoryNode struct {
fs.Inode
param *FSParam

View File

@ -80,7 +80,7 @@ func (n *rootNode) OnAdd(ctx context.Context) {
ctx,
groupNode,
fs.StableAttr{
Ino: 0,
Ino: group.GetGroupID() + groupBaseInode,
Mode: fuse.S_IFDIR,
},
)