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
651984dc
Commit
651984dc
authored
Mar 03, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only mark as unlinked in rmdir.
parent
140bd188
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
samples/memfs/fs.go
samples/memfs/fs.go
+2
-3
samples/memfs/inode.go
samples/memfs/inode.go
+14
-0
No files found.
samples/memfs/fs.go
View file @
651984dc
...
...
@@ -332,9 +332,8 @@ func (fs *memFS) RmDir(
// Remove the entry within the parent.
parent
.
RemoveChild
(
req
.
Name
)
// TODO(jacobsa): Don't remove the child until it's forgotten. Can we get a
// failing test by continuing to read from an opened dir handle?
fs
.
deallocateInode
(
childID
)
// Mark the child as unlinked.
child
.
linkCount
--
return
}
...
...
samples/memfs/inode.go
View file @
651984dc
...
...
@@ -31,6 +31,13 @@ type inode struct {
mu
syncutil
.
InvariantMutex
// The number of times this inode is linked into a parent directory. This may
// be zero if the inode has been unlinked but not yet forgotten, because some
// process still has an open file handle.
//
// INVARIANT: linkCount >= 0
linkCount
int
// GUARDED_BY(mu)
// The current attributes of this inode.
//
// INVARIANT: No non-permission mode bits are set besides os.ModeDir
...
...
@@ -64,8 +71,10 @@ type inode struct {
// Helpers
////////////////////////////////////////////////////////////////////////
// Initially the link count is one.
func
newInode
(
attrs
fuse
.
InodeAttributes
)
(
in
*
inode
)
{
in
=
&
inode
{
linkCount
:
1
,
dir
:
(
attrs
.
Mode
&
os
.
ModeDir
!=
0
),
attributes
:
attrs
,
}
...
...
@@ -75,6 +84,11 @@ func newInode(attrs fuse.InodeAttributes) (in *inode) {
}
func
(
inode
*
inode
)
checkInvariants
()
{
// Check the link count.
if
inode
.
linkCount
<
0
{
panic
(
fmt
.
Sprintf
(
"Negative link count: %v"
,
inode
.
linkCount
))
}
// 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
))
...
...
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