Skip to content

Commit 97f1c68

Browse files
cjc25stapelberg
authored andcommitted
Simplify rootInode in the notify_inval sample
1 parent fb5c71e commit 97f1c68

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

samples/notify_inval/notify_inval.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ type notifyInvalInodeFS struct {
7777
const (
7878
currentTimeFilename = "current_time"
7979

80-
rootInode fuseops.InodeID = fuseops.RootInodeID
81-
currentTimeInode = rootInode + iota
80+
currentTimeInode = fuseops.RootInodeID + iota
8281
changingFnameInode
8382
)
8483

@@ -87,21 +86,21 @@ func (fs *notifyInvalInodeFS) invalidateInodes(oldTime time.Time) {
8786
if err := fs.notifier.InvalidateInode(currentTimeInode, 0, 0); err != nil {
8887
fmt.Printf("error invalidating current_time inode %v: %v\n", currentTimeInode, err)
8988
}
90-
if err := fs.notifier.InvalidateEntry(rootInode, currentTimeFilename); err != nil {
91-
fmt.Printf("error invalidating current_time entry %v for parent %v: %v\n", currentTimeFilename, rootInode, err)
89+
if err := fs.notifier.InvalidateEntry(fuseops.RootInodeID, currentTimeFilename); err != nil {
90+
fmt.Printf("error invalidating current_time entry %v for parent %v: %v\n", currentTimeFilename, fuseops.RootInodeID, err)
9291
}
9392

9493
if err := fs.notifier.InvalidateInode(changingFnameInode, 0, 0); err != nil {
9594
fmt.Printf("error invalidating dynamic filename inode %v: %v\n", changingFnameInode, err)
9695
}
97-
if err := fs.notifier.InvalidateEntry(rootInode, oldTime.Format(time.RFC3339)); err != nil {
98-
fmt.Printf("error invalidating dynamic filename entry for parent %v: %v\n", rootInode, err)
96+
if err := fs.notifier.InvalidateEntry(fuseops.RootInodeID, oldTime.Format(time.RFC3339)); err != nil {
97+
fmt.Printf("error invalidating dynamic filename entry for parent %v: %v\n", fuseops.RootInodeID, err)
9998
}
10099
}
101100

102101
func (fs *notifyInvalInodeFS) fillStat(ino fuseops.InodeID, attrs *fuseops.InodeAttributes) error {
103102
switch ino {
104-
case rootInode:
103+
case fuseops.RootInodeID:
105104
attrs.Nlink = 1
106105
attrs.Mode = 0555 | os.ModeDir
107106
case currentTimeInode:
@@ -118,7 +117,7 @@ func (fs *notifyInvalInodeFS) fillStat(ino fuseops.InodeID, attrs *fuseops.Inode
118117
}
119118

120119
func (fs *notifyInvalInodeFS) LookUpInode(ctx context.Context, op *fuseops.LookUpInodeOp) error {
121-
if op.Parent != rootInode {
120+
if op.Parent != fuseops.RootInodeID {
122121
return fuse.ENOENT
123122
}
124123

@@ -148,7 +147,7 @@ func (fs *notifyInvalInodeFS) GetInodeAttributes(ctx context.Context, op *fuseop
148147
}
149148

150149
func (fs *notifyInvalInodeFS) ReadDir(ctx context.Context, op *fuseops.ReadDirOp) error {
151-
if op.Inode != rootInode {
150+
if op.Inode != fuseops.RootInodeID {
152151
return fuse.ENOTDIR
153152
}
154153

@@ -174,7 +173,7 @@ func (fs *notifyInvalInodeFS) ReadDir(ctx context.Context, op *fuseops.ReadDirOp
174173
}
175174

176175
func (fs *notifyInvalInodeFS) OpenFile(ctx context.Context, op *fuseops.OpenFileOp) error {
177-
if op.Inode == rootInode {
176+
if op.Inode == fuseops.RootInodeID {
178177
return syscall.EISDIR
179178
}
180179
if op.Inode == changingFnameInode {

0 commit comments

Comments
 (0)