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
c81ae6d4
Commit
c81ae6d4
authored
Mar 03, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed permissions for the root.
parent
44901edc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
9 deletions
+38
-9
samples/memfs/fs.go
samples/memfs/fs.go
+30
-9
samples/memfs/inode.go
samples/memfs/inode.go
+8
-0
No files found.
samples/memfs/fs.go
View file @
c81ae6d4
...
...
@@ -57,9 +57,10 @@ func NewMemFS(
inodes
:
make
([]
*
inode
,
fuse
.
RootInodeID
+
1
),
}
// Set up the root inode.
// Set up the root inode. Its ownership information will later be modified in
// Init.
rootAttrs
:=
fuse
.
InodeAttributes
{
Mode
:
07
77
|
os
.
ModeDir
,
Mode
:
07
00
|
os
.
ModeDir
,
}
fs
.
inodes
[
fuse
.
RootInodeID
]
=
newInode
(
rootAttrs
)
...
...
@@ -70,6 +71,10 @@ func NewMemFS(
return
fs
}
////////////////////////////////////////////////////////////////////////
// Helpers
////////////////////////////////////////////////////////////////////////
func
(
fs
*
memFS
)
checkInvariants
()
{
// Check reserved inodes.
for
i
:=
0
;
i
<
fuse
.
RootInodeID
;
i
++
{
...
...
@@ -109,13 +114,6 @@ func (fs *memFS) checkInvariants() {
}
}
func
(
fs
*
memFS
)
Init
(
ctx
context
.
Context
,
req
*
fuse
.
InitRequest
)
(
resp
*
fuse
.
InitResponse
,
err
error
)
{
resp
=
&
fuse
.
InitResponse
{}
return
}
// Find the given inode and return it with its lock held. Panic if it doesn't
// exist.
//
...
...
@@ -171,6 +169,29 @@ func (fs *memFS) allocateInode(
return
}
////////////////////////////////////////////////////////////////////////
// FileSystem methods
////////////////////////////////////////////////////////////////////////
func
(
fs
*
memFS
)
Init
(
ctx
context
.
Context
,
req
*
fuse
.
InitRequest
)
(
resp
*
fuse
.
InitResponse
,
err
error
)
{
resp
=
&
fuse
.
InitResponse
{}
fs
.
mu
.
RLock
()
defer
fs
.
mu
.
RUnlock
()
// Update the root inode's ownership information to match the credentials of
// the mounting process.
root
:=
fs
.
getInodeForModifyingOrDie
(
fuse
.
RootInodeID
)
defer
root
.
mu
.
Unlock
()
root
.
attributes
.
Uid
=
req
.
Header
.
Uid
root
.
attributes
.
Gid
=
req
.
Header
.
Gid
return
}
func
(
fs
*
memFS
)
LookUpInode
(
ctx
context
.
Context
,
req
*
fuse
.
LookUpInodeRequest
)
(
resp
*
fuse
.
LookUpInodeResponse
,
err
error
)
{
...
...
samples/memfs/inode.go
View file @
c81ae6d4
...
...
@@ -59,6 +59,10 @@ type inode struct {
contents
[]
byte
// GUARDED_BY(mu)
}
////////////////////////////////////////////////////////////////////////
// Helpers
////////////////////////////////////////////////////////////////////////
func
newInode
(
attrs
fuse
.
InodeAttributes
)
(
in
*
inode
)
{
in
=
&
inode
{
dir
:
(
attrs
.
Mode
&
os
.
ModeDir
!=
0
),
...
...
@@ -112,6 +116,10 @@ func (inode *inode) checkInvariants() {
}
}
////////////////////////////////////////////////////////////////////////
// Public methods
////////////////////////////////////////////////////////////////////////
// Find an entry for the given child name and return its inode ID.
//
// REQUIRES: 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