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
ab3c91cd
Commit
ab3c91cd
authored
Mar 16, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Plain Diff
Fixed some permissions issues on Linux.
parents
6aaf89f9
27c8c0df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
15 deletions
+39
-15
file_system.go
file_system.go
+21
-0
samples/memfs/fs.go
samples/memfs/fs.go
+9
-13
samples/memfs/memfs_test.go
samples/memfs/memfs_test.go
+9
-2
No files found.
file_system.go
View file @
ab3c91cd
...
...
@@ -258,6 +258,27 @@ func init() {
// http://goo.gl/tvYyQt).
type
InodeAttributes
struct
{
Size
uint64
// The mode of the inode. This is exposed to the user in e.g. the result of
// fstat(2).
//
// The permissions bits of the mode are not necessarily respected by the FUSE
// kernel layer unless the file system is mounted with the
// 'default_permissions' option (cf. http://goo.gl/1LxOop).
//
// For example, in the case of mkdir:
//
// * (http://goo.gl/JkdxDI) sys_mkdirat calls inode_permission.
//
// * (...) inode_permission eventually calls do_inode_permission.
//
// * (http://goo.gl/aGCsmZ) calls i_op->permission, which is
// fuse_permission (cf. http://goo.gl/VZ9beH).
//
// * (http://goo.gl/5kqUKO) fuse_permission doesn't do anything at all for
// several code paths if FUSE_DEFAULT_PERMISSIONS is unset. In contrast,
// if that flag *is* set, then it calls generic_permission.
//
Mode
os
.
FileMode
// Time information. See `man 2 stat` for full details.
...
...
samples/memfs/fs.go
View file @
ab3c91cd
...
...
@@ -61,7 +61,13 @@ type memFS struct {
}
// Create a file system that stores data and metadata in memory.
//
// The supplied UID/GID pair will own the root inode. This file system does no
// permissions checking, and should therefore be mounted with the
// default_permissions option.
func
NewMemFS
(
uid
uint32
,
gid
uint32
,
clock
timeutil
.
Clock
)
fuse
.
FileSystem
{
// Set up the basic struct.
fs
:=
&
memFS
{
...
...
@@ -69,10 +75,11 @@ func NewMemFS(
inodes
:
make
([]
*
inode
,
fuse
.
RootInodeID
+
1
),
}
// Set up the root inode. Its ownership information will later be modified in
// Init.
// Set up the root inode.
rootAttrs
:=
fuse
.
InodeAttributes
{
Mode
:
0700
|
os
.
ModeDir
,
Uid
:
uid
,
Gid
:
gid
,
}
fs
.
inodes
[
fuse
.
RootInodeID
]
=
newInode
(
clock
,
rootAttrs
)
...
...
@@ -196,17 +203,6 @@ func (fs *memFS) Init(
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
}
...
...
samples/memfs/memfs_test.go
View file @
ab3c91cd
...
...
@@ -27,6 +27,7 @@ import (
"testing"
"time"
bazilfuse
"bazil.org/fuse"
"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fusetesting"
"github.com/jacobsa/fuse/samples/memfs"
...
...
@@ -111,8 +112,14 @@ func (t *MemFSTest) SetUp(ti *TestInfo) {
}
// Mount a file system.
fs
:=
memfs
.
NewMemFS
(
&
t
.
clock
)
if
t
.
mfs
,
err
=
fuse
.
Mount
(
mountPoint
,
fs
);
err
!=
nil
{
fs
:=
memfs
.
NewMemFS
(
currentUid
(),
currentGid
(),
&
t
.
clock
)
t
.
mfs
,
err
=
fuse
.
Mount
(
mountPoint
,
fs
,
bazilfuse
.
DefaultPermissions
())
if
err
!=
nil
{
panic
(
"Mount: "
+
err
.
Error
())
}
...
...
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