Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
jacobsa-fuse
Commits
26ac0296
Commit
26ac0296
authored
Mar 02, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented inode.checkInvariants.
parent
0cbe7573
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
1 deletion
+34
-1
samples/memfs/inode.go
samples/memfs/inode.go
+34
-1
No files found.
samples/memfs/inode.go
View file @
26ac0296
...
@@ -4,6 +4,9 @@
...
@@ -4,6 +4,9 @@
package
memfs
package
memfs
import
(
import
(
"fmt"
"os"
"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseutil"
"github.com/jacobsa/fuse/fuseutil"
"github.com/jacobsa/gcloud/syncutil"
"github.com/jacobsa/gcloud/syncutil"
...
@@ -64,7 +67,37 @@ func newInode(dir bool) (in *inode) {
...
@@ -64,7 +67,37 @@ func newInode(dir bool) (in *inode) {
return
return
}
}
func
(
inode
*
inode
)
checkInvariants
()
func
(
inode
*
inode
)
checkInvariants
()
{
// No non-permission mode bits should be set besides os.ModeDir.
if
inode
.
attributes
.
Mode
&
^
(
os
.
ModePerm
|
os
.
ModeDir
)
!=
0
{
panic
(
fmt
.
Sprintf
(
"Unexpected mode: %v"
,
inode
.
attributes
.
Mode
))
}
// Check os.ModeDir.
if
inode
.
dir
!=
(
inode
.
attributes
.
Mode
&
os
.
ModeDir
==
os
.
ModeDir
)
{
panic
(
fmt
.
Sprintf
(
"Unexpected mode: %v"
,
inode
.
attributes
.
Mode
))
}
// Check directory-specific stuff.
if
inode
.
dir
{
if
inode
.
contents
!=
nil
{
panic
(
"Non-nil contents in a directory."
)
}
for
i
,
e
:=
range
inode
.
entries
{
if
e
.
Offset
!=
fuse
.
DirOffset
(
i
+
1
)
{
panic
(
fmt
.
Sprintf
(
"Unexpected offset: %v"
,
e
.
Offset
))
}
}
}
// Check file-specific stuff.
if
!
inode
.
dir
{
if
inode
.
entries
!=
nil
{
panic
(
"Non-nil entries in a file."
)
}
}
}
// Find an entry for the given child name and return its inode ID.
// Find an entry for the given child name and return its inode ID.
//
//
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment