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
c3298a7a
Commit
c3298a7a
authored
Mar 02, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an inode invariant.
parent
e612c866
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
samples/memfs/inode.go
samples/memfs/inode.go
+8
-0
No files found.
samples/memfs/inode.go
View file @
c3298a7a
...
@@ -50,6 +50,7 @@ type inode struct {
...
@@ -50,6 +50,7 @@ type inode struct {
//
//
// INVARIANT: If dir is false, this is nil.
// INVARIANT: If dir is false, this is nil.
// INVARIANT: For each i, entries[i].Offset == i+1
// INVARIANT: For each i, entries[i].Offset == i+1
// INVARIANT: Contains no duplicate names.
entries
[]
fuseutil
.
Dirent
// GUARDED_BY(mu)
entries
[]
fuseutil
.
Dirent
// GUARDED_BY(mu)
// For files, the current contents of the file.
// For files, the current contents of the file.
...
@@ -91,10 +92,17 @@ func (inode *inode) checkInvariants() {
...
@@ -91,10 +92,17 @@ func (inode *inode) checkInvariants() {
panic
(
"Non-nil contents in a directory."
)
panic
(
"Non-nil contents in a directory."
)
}
}
childNames
:=
make
(
map
[
string
]
struct
{})
for
i
,
e
:=
range
inode
.
entries
{
for
i
,
e
:=
range
inode
.
entries
{
if
e
.
Offset
!=
fuse
.
DirOffset
(
i
+
1
)
{
if
e
.
Offset
!=
fuse
.
DirOffset
(
i
+
1
)
{
panic
(
fmt
.
Sprintf
(
"Unexpected offset: %v"
,
e
.
Offset
))
panic
(
fmt
.
Sprintf
(
"Unexpected offset: %v"
,
e
.
Offset
))
}
}
if
_
,
ok
:=
childNames
[
e
.
Name
];
ok
{
panic
(
fmt
.
Sprintf
(
"Duplicate name: %s"
,
e
.
Name
))
}
childNames
[
e
.
Name
]
=
struct
{}{}
}
}
}
}
...
...
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