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
5cf0f2b6
Commit
5cf0f2b6
authored
Mar 03, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored newInode.
parent
bb1539e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
samples/memfs/fs.go
samples/memfs/fs.go
+12
-4
samples/memfs/inode.go
samples/memfs/inode.go
+3
-5
No files found.
samples/memfs/fs.go
View file @
5cf0f2b6
...
@@ -58,7 +58,11 @@ func NewMemFS(
...
@@ -58,7 +58,11 @@ func NewMemFS(
}
}
// Set up the root inode.
// Set up the root inode.
fs
.
inodes
[
fuse
.
RootInodeID
]
=
newInode
(
0777
|
os
.
ModeDir
)
rootAttrs
:=
fuse
.
InodeAttributes
{
Mode
:
0777
|
os
.
ModeDir
,
}
fs
.
inodes
[
fuse
.
RootInodeID
]
=
newInode
(
rootAttrs
)
// Set up invariant checking.
// Set up invariant checking.
fs
.
mu
=
syncutil
.
NewInvariantMutex
(
fs
.
checkInvariants
)
fs
.
mu
=
syncutil
.
NewInvariantMutex
(
fs
.
checkInvariants
)
...
@@ -148,9 +152,9 @@ func (fs *memFS) getInodeForReadingOrDie(id fuse.InodeID) (inode *inode) {
...
@@ -148,9 +152,9 @@ func (fs *memFS) getInodeForReadingOrDie(id fuse.InodeID) (inode *inode) {
// EXCLUSIVE_LOCKS_REQUIRED(fs.mu)
// EXCLUSIVE_LOCKS_REQUIRED(fs.mu)
// EXCLUSIVE_LOCK_FUNCTION(inode.mu)
// EXCLUSIVE_LOCK_FUNCTION(inode.mu)
func
(
fs
*
memFS
)
allocateInode
(
func
(
fs
*
memFS
)
allocateInode
(
mode
os
.
FileMode
)
(
id
fuse
.
InodeID
,
inode
*
inode
)
{
attrs
fuse
.
InodeAttributes
)
(
id
fuse
.
InodeID
,
inode
*
inode
)
{
// Create and lock the inode.
// Create and lock the inode.
inode
=
newInode
(
mode
)
inode
=
newInode
(
attrs
)
inode
.
mu
.
Lock
()
inode
.
mu
.
Lock
()
// Re-use a free ID if possible. Otherwise mint a new one.
// Re-use a free ID if possible. Otherwise mint a new one.
...
@@ -238,7 +242,11 @@ func (fs *memFS) MkDir(
...
@@ -238,7 +242,11 @@ func (fs *memFS) MkDir(
defer
parent
.
mu
.
Unlock
()
defer
parent
.
mu
.
Unlock
()
// Allocate a child.
// Allocate a child.
childID
,
child
:=
fs
.
allocateInode
(
req
.
Mode
)
childAttrs
:=
fuse
.
InodeAttributes
{
Mode
:
req
.
Mode
,
}
childID
,
child
:=
fs
.
allocateInode
(
childAttrs
)
defer
child
.
mu
.
Unlock
()
defer
child
.
mu
.
Unlock
()
// Add an entry in the parent.
// Add an entry in the parent.
...
...
samples/memfs/inode.go
View file @
5cf0f2b6
...
@@ -59,12 +59,10 @@ type inode struct {
...
@@ -59,12 +59,10 @@ type inode struct {
contents
[]
byte
// GUARDED_BY(mu)
contents
[]
byte
// GUARDED_BY(mu)
}
}
func
newInode
(
mode
os
.
FileMode
)
(
in
*
inode
)
{
func
newInode
(
attrs
fuse
.
InodeAttributes
)
(
in
*
inode
)
{
in
=
&
inode
{
in
=
&
inode
{
dir
:
(
mode
&
os
.
ModeDir
!=
0
),
dir
:
(
attrs
.
Mode
&
os
.
ModeDir
!=
0
),
attributes
:
fuse
.
InodeAttributes
{
attributes
:
attrs
,
Mode
:
mode
,
},
}
}
in
.
mu
=
syncutil
.
NewInvariantMutex
(
in
.
checkInvariants
)
in
.
mu
=
syncutil
.
NewInvariantMutex
(
in
.
checkInvariants
)
...
...
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