fix inode collision
This commit is contained in:
parent
caa030b03b
commit
70f269e25e
|
@ -8,6 +8,10 @@ import (
|
||||||
"github.com/hanwen/go-fuse/v2/fuse"
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
groupBaseInode = 1_000_000_000
|
||||||
|
)
|
||||||
|
|
||||||
type groupNode struct {
|
type groupNode struct {
|
||||||
fs.Inode
|
fs.Inode
|
||||||
param *FSParam
|
param *FSParam
|
||||||
|
@ -48,14 +52,14 @@ func (n *groupNode) Readdir(ctx context.Context) (fs.DirStream, syscall.Errno) {
|
||||||
for groupName, group := range groups {
|
for groupName, group := range groups {
|
||||||
entries = append(entries, fuse.DirEntry{
|
entries = append(entries, fuse.DirEntry{
|
||||||
Name: groupName,
|
Name: groupName,
|
||||||
Ino: group.GetGroupID(),
|
Ino: group.GetGroupID() + groupBaseInode,
|
||||||
Mode: fuse.S_IFDIR,
|
Mode: fuse.S_IFDIR,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
for repositoryName, repository := range repositories {
|
for repositoryName, repository := range repositories {
|
||||||
entries = append(entries, fuse.DirEntry{
|
entries = append(entries, fuse.DirEntry{
|
||||||
Name: repositoryName,
|
Name: repositoryName,
|
||||||
Ino: repository.GetRepositoryID(),
|
Ino: repository.GetRepositoryID() + repositoryBaseInode,
|
||||||
Mode: fuse.S_IFLNK,
|
Mode: fuse.S_IFLNK,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -78,7 +82,7 @@ func (n *groupNode) Lookup(ctx context.Context, name string, out *fuse.EntryOut)
|
||||||
group, found := groups[name]
|
group, found := groups[name]
|
||||||
if found {
|
if found {
|
||||||
attrs := fs.StableAttr{
|
attrs := fs.StableAttr{
|
||||||
Ino: group.GetGroupID(),
|
Ino: group.GetGroupID() + groupBaseInode,
|
||||||
Mode: fuse.S_IFDIR,
|
Mode: fuse.S_IFDIR,
|
||||||
}
|
}
|
||||||
groupNode, _ := newGroupNodeFromSource(group, n.param)
|
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]
|
repository, found := repositories[name]
|
||||||
if found {
|
if found {
|
||||||
attrs := fs.StableAttr{
|
attrs := fs.StableAttr{
|
||||||
Ino: repository.GetRepositoryID(),
|
Ino: repository.GetRepositoryID() + repositoryBaseInode,
|
||||||
Mode: fuse.S_IFLNK,
|
Mode: fuse.S_IFLNK,
|
||||||
}
|
}
|
||||||
repositoryNode, _ := newRepositoryNodeFromSource(repository, n.param)
|
repositoryNode, _ := newRepositoryNodeFromSource(repository, n.param)
|
||||||
|
|
|
@ -7,6 +7,10 @@ import (
|
||||||
"github.com/hanwen/go-fuse/v2/fs"
|
"github.com/hanwen/go-fuse/v2/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
repositoryBaseInode = 2_000_000_000
|
||||||
|
)
|
||||||
|
|
||||||
type repositoryNode struct {
|
type repositoryNode struct {
|
||||||
fs.Inode
|
fs.Inode
|
||||||
param *FSParam
|
param *FSParam
|
||||||
|
|
|
@ -80,7 +80,7 @@ func (n *rootNode) OnAdd(ctx context.Context) {
|
||||||
ctx,
|
ctx,
|
||||||
groupNode,
|
groupNode,
|
||||||
fs.StableAttr{
|
fs.StableAttr{
|
||||||
Ino: 0,
|
Ino: group.GetGroupID() + groupBaseInode,
|
||||||
Mode: fuse.S_IFDIR,
|
Mode: fuse.S_IFDIR,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue