@@ -7,17 +7,11 @@ import (
77 "syscall"
88 "time"
99
10- "github.com/DataManager-Go/libdatamanager"
11- dmConfig "github.com/DataManager-Go/libdatamanager/config"
1210 "github.com/hanwen/go-fuse/v2/fs"
1311)
1412
1513type dmanagerRoot struct {
1614 fs.Inode
17-
18- mounter * Mounter
19- config * dmConfig.Config
20- libdm * libdatamanager.LibDM
2115}
2216
2317// implement the interfaces
@@ -30,14 +24,14 @@ var _ = (fs.NodeRmdirer)((*dmanagerRoot)(nil))
3024func (root * dmanagerRoot ) OnAdd (ctx context.Context ) {
3125 root .debug ("Init files" )
3226
33- userData , err := root . libdm . GetUserAttributeData ()
27+ err := data . loadUserAttributes ()
3428 if err != nil {
3529 log .Fatal (err )
3630 return
3731 }
3832
3933 // Loop Namespaces and add childs in as folders
40- for _ , namespace := range userData .Namespace {
34+ for _ , namespace := range data . userAttributes .Namespace {
4135 nsName := removeNSName (namespace .Name )
4236
4337 // reuse child
@@ -61,7 +55,10 @@ func (root *dmanagerRoot) OnAdd(ctx context.Context) {
6155 for _ , group := range namespace .Groups {
6256 gp := nsp .GetChild (group )
6357 if gp == nil {
64- gp = nsp .NewInode (ctx , & fs.Inode {}, fs.StableAttr {
58+ gp = nsp .NewInode (ctx , & groupInode {
59+ group : group ,
60+ namespace : namespace .Name ,
61+ }, fs.StableAttr {
6562 Mode : syscall .S_IFDIR ,
6663 })
6764
@@ -76,7 +73,7 @@ func (root *dmanagerRoot) OnAdd(ctx context.Context) {
7673
7774// Unlink if virtual file was unlinked
7875func (root * dmanagerRoot ) Rmdir (ctx context.Context , name string ) syscall.Errno {
79- namespace := addNSName (name , root .libdm .Config )
76+ namespace := addNSName (name , data .libdm .Config )
8077
8178 // wait 2 seconds to ensure, user didn't cancel
8279 select {
@@ -86,7 +83,7 @@ func (root *dmanagerRoot) Rmdir(ctx context.Context, name string) syscall.Errno
8683 }
8784
8885 // Do delete request
89- if _ , err := root .libdm .DeleteNamespace (namespace ); err != nil {
86+ if _ , err := data .libdm .DeleteNamespace (namespace ); err != nil {
9087 fmt .Println (err )
9188 return syscall .EFAULT
9289 }
@@ -103,12 +100,12 @@ func (root *dmanagerRoot) Rename(ctx context.Context, name string, newParent fs.
103100 }
104101
105102 // Get real namespace names
106- oldNSName := addNSName (name , root .libdm .Config )
107- newNSName := addNSName (newName , root .libdm .Config )
103+ oldNSName := addNSName (name , data .libdm .Config )
104+ newNSName := addNSName (newName , data .libdm .Config )
108105 root .debug ("rename namespace" , oldNSName , "->" , newNSName )
109106
110107 // Make rename request
111- _ , err := root .libdm .UpdateNamespace (oldNSName , newNSName )
108+ _ , err := data .libdm .UpdateNamespace (oldNSName , newNSName )
112109 if err != nil {
113110 fmt .Println (err )
114111 return syscall .ENONET
@@ -119,7 +116,7 @@ func (root *dmanagerRoot) Rename(ctx context.Context, name string, newParent fs.
119116}
120117
121118func (root * dmanagerRoot ) debug (arg ... interface {}) {
122- if root .mounter .Debug {
119+ if data .mounter .Debug {
123120 fmt .Println (arg ... )
124121 }
125122}
0 commit comments