Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-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
go-fuse
Commits
cf139fc4
Commit
cf139fc4
authored
Apr 28, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs: add Options.{UID,GID} for setting default owners
parent
f302529f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
0 deletions
+41
-0
fs/api.go
fs/api.go
+6
-0
fs/bridge.go
fs/bridge.go
+6
-0
fs/mem_test.go
fs/mem_test.go
+29
-0
No files found.
fs/api.go
View file @
cf139fc4
...
...
@@ -462,4 +462,10 @@ type Options struct {
// DefaultPermissions sets null file permissions to 755 (dirs)
// or 644 (other files.)
DefaultPermissions
bool
// If nonzero, replace default (zero) UID with the given UID
UID
uint32
// If nonzero, replace default (zero) GID with the given GID
GID
uint32
}
fs/bridge.go
View file @
cf139fc4
...
...
@@ -152,6 +152,12 @@ func (b *rawBridge) setAttr(out *fuse.Attr) {
out
.
Mode
|=
0111
}
}
if
b
.
options
.
UID
!=
0
&&
out
.
Uid
==
0
{
out
.
Uid
=
b
.
options
.
UID
}
if
b
.
options
.
GID
!=
0
&&
out
.
Gid
==
0
{
out
.
Gid
=
b
.
options
.
GID
}
}
func
(
b
*
rawBridge
)
setAttrTimeout
(
out
*
fuse
.
AttrOut
)
{
...
...
fs/mem_test.go
View file @
cf139fc4
...
...
@@ -38,6 +38,35 @@ func testMount(t *testing.T, root InodeEmbedder, opts *Options) (string, *fuse.S
}
}
func
TestDefaultOwner
(
t
*
testing
.
T
)
{
want
:=
"hello"
root
:=
&
Inode
{}
mntDir
,
_
,
clean
:=
testMount
(
t
,
root
,
&
Options
{
FirstAutomaticIno
:
1
,
OnAdd
:
func
(
ctx
context
.
Context
)
{
n
:=
root
.
EmbeddedInode
()
ch
:=
n
.
NewPersistentInode
(
ctx
,
&
MemRegularFile
{
Data
:
[]
byte
(
want
),
},
StableAttr
{})
n
.
AddChild
(
"file"
,
ch
,
false
)
},
UID
:
42
,
GID
:
43
,
})
defer
clean
()
var
st
syscall
.
Stat_t
if
err
:=
syscall
.
Lstat
(
mntDir
+
"/file"
,
&
st
);
err
!=
nil
{
t
.
Fatalf
(
"Lstat: %v"
,
err
)
}
else
if
st
.
Uid
!=
42
||
st
.
Gid
!=
43
{
t
.
Fatalf
(
"Got Lstat %d, %d want 42,43"
,
st
.
Uid
,
st
.
Gid
)
}
}
func
TestDataFile
(
t
*
testing
.
T
)
{
want
:=
"hello"
root
:=
&
Inode
{}
...
...
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