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
2cf18ad9
Commit
2cf18ad9
authored
Mar 03, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some build errors.
parent
ea2038ef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
samples/memfs/fs.go
samples/memfs/fs.go
+26
-4
samples/memfs/inode.go
samples/memfs/inode.go
+9
-0
No files found.
samples/memfs/fs.go
View file @
2cf18ad9
...
...
@@ -112,8 +112,23 @@ func (fs *memFS) Init(
return
}
// Find the supplied inode and return it with its lock held for reading. Panic
// if it doesn't exist.
// Find the given inode and return it with its lock held. Panic if it doesn't
// exist.
//
// SHARED_LOCKS_REQUIRED(fs.mu)
// EXCLUSIVE_LOCK_FUNCTION(inode.mu)
func
(
fs
*
memFS
)
getInodeForModifyingOrDie
(
id
fuse
.
InodeID
)
(
inode
*
inode
)
{
inode
=
fs
.
inodes
[
id
]
if
inode
==
nil
{
panic
(
fmt
.
Sprintf
(
"Unknown inode: %v"
,
id
))
}
inode
.
mu
.
Lock
()
return
}
// Find the given inode and return it with its lock held for reading. Panic if
// it doesn't exist.
//
// SHARED_LOCKS_REQUIRED(fs.mu)
// SHARED_LOCK_FUNCTION(inode.mu)
...
...
@@ -127,6 +142,13 @@ func (fs *memFS) getInodeForReadingOrDie(id fuse.InodeID) (inode *inode) {
return
}
// Allocate a new inode, assigning it an ID that is not in use. Return it with
// its lock held.
//
// EXCLUSIVE_LOCKS_REQUIRED(fs.mu)
// EXCLUSIVE_LOCK_FUNCTION(inode.mu)
func
(
fs
*
memFS
)
allocateInode
(
mode
os
.
FileMode
)
(
id
fuse
.
InodeID
,
inode
*
inode
)
func
(
fs
*
memFS
)
LookUpInode
(
ctx
context
.
Context
,
req
*
fuse
.
LookUpInodeRequest
)
(
resp
*
fuse
.
LookUpInodeResponse
,
err
error
)
{
...
...
@@ -193,7 +215,7 @@ func (fs *memFS) MkDir(
defer
fs
.
mu
.
Unlock
()
// Grab the parent, which we will update shortly.
parent
:=
fs
.
getInodeForModifying
(
req
.
Parent
)
parent
:=
fs
.
getInodeForModifying
OrDie
(
req
.
Parent
)
defer
parent
.
mu
.
Unlock
()
// Allocate a child.
...
...
@@ -201,7 +223,7 @@ func (fs *memFS) MkDir(
defer
child
.
mu
.
Unlock
()
// Add an entry in the parent.
parent
.
Add
Entry
(
childID
,
req
.
Name
,
fuseutil
.
DT_Directory
)
parent
.
Add
Child
(
childID
,
req
.
Name
,
fuseutil
.
DT_Directory
)
// Fill in the response.
resp
.
Entry
.
Attributes
=
child
.
attributes
...
...
samples/memfs/inode.go
View file @
2cf18ad9
...
...
@@ -134,6 +134,15 @@ func (inode *inode) LookUpChild(name string) (id fuse.InodeID, ok bool) {
return
}
// Add an entry for a child.
//
// REQUIRES: inode.dir
// EXCLUSIVE_LOCKS_REQUIRED(inode.mu)
func
(
inode
*
inode
)
AddChild
(
id
fuse
.
InodeID
,
name
string
,
dt
fuseutil
.
DirentType
)
// Serve a ReadDir request.
//
// REQUIRED: inode.dir
...
...
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