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
Levin Zimmermann
go-fuse
Commits
7b15acfb
Commit
7b15acfb
authored
Feb 13, 2019
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuse: add convenience functions for interpreting SetAttrIn
parent
e99f8487
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
37 deletions
+95
-37
fuse/nodefs/fsops.go
fuse/nodefs/fsops.go
+22
-37
fuse/types.go
fuse/types.go
+73
-0
No files found.
fuse/nodefs/fsops.go
View file @
7b15acfb
...
...
@@ -200,54 +200,39 @@ func (c *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse
node
:=
c
.
toInode
(
input
.
NodeId
)
var
f
File
if
input
.
Valid
&
fuse
.
FATTR_FH
!=
0
{
if
opened
:=
node
.
mount
.
getOpenedFile
(
input
.
F
h
);
opened
!=
nil
{
if
fh
,
ok
:=
input
.
GetFh
();
ok
{
if
opened
:=
node
.
mount
.
getOpenedFile
(
f
h
);
opened
!=
nil
{
f
=
opened
.
WithFlags
.
File
}
}
if
code
.
Ok
()
&&
input
.
Valid
&
fuse
.
FATTR_MODE
!=
0
{
permissions
:=
uint32
(
07777
)
&
input
.
Mode
if
permissions
,
ok
:=
input
.
GetMode
();
ok
{
code
=
node
.
fsInode
.
Chmod
(
f
,
permissions
,
&
input
.
Context
)
}
if
code
.
Ok
()
&&
(
input
.
Valid
&
(
fuse
.
FATTR_UID
|
fuse
.
FATTR_GID
)
!=
0
)
{
var
uid
uint32
=
^
uint32
(
0
)
// means "do not change" in chown(2)
var
gid
uint32
=
^
uint32
(
0
)
if
input
.
Valid
&
fuse
.
FATTR_UID
!=
0
{
uid
=
input
.
Uid
}
if
input
.
Valid
&
fuse
.
FATTR_GID
!=
0
{
gid
=
input
.
Gid
}
uid
,
uok
:=
input
.
GetUID
()
gid
,
gok
:=
input
.
GetUID
()
if
code
.
Ok
()
&&
(
uok
||
gok
)
{
code
=
node
.
fsInode
.
Chown
(
f
,
uid
,
gid
,
&
input
.
Context
)
}
if
code
.
Ok
()
&&
input
.
Valid
&
fuse
.
FATTR_SIZE
!=
0
{
code
=
node
.
fsInode
.
Truncate
(
f
,
input
.
Size
,
&
input
.
Context
)
if
sz
,
ok
:=
input
.
GetSize
();
code
.
Ok
()
&&
ok
{
code
=
node
.
fsInode
.
Truncate
(
f
,
sz
,
&
input
.
Context
)
}
if
code
.
Ok
()
&&
(
input
.
Valid
&
(
fuse
.
FATTR_ATIME
|
fuse
.
FATTR_MTIME
|
fuse
.
FATTR_ATIME_NOW
|
fuse
.
FATTR_MTIME_NOW
)
!=
0
)
{
now
:=
time
.
Now
()
var
atime
*
time
.
Time
var
mtime
*
time
.
Time
if
input
.
Valid
&
fuse
.
FATTR_ATIME
!=
0
{
if
input
.
Valid
&
fuse
.
FATTR_ATIME_NOW
!=
0
{
atime
=
&
now
}
else
{
t
:=
time
.
Unix
(
int64
(
input
.
Atime
),
int64
(
input
.
Atimensec
))
atime
=
&
t
}
}
atime
,
aok
:=
input
.
GetATime
()
mtime
,
mok
:=
input
.
GetMTime
()
if
code
.
Ok
()
&&
(
aok
||
mok
)
{
var
a
,
m
*
time
.
Time
if
input
.
Valid
&
fuse
.
FATTR_MTIME
!=
0
{
if
input
.
Valid
&
fuse
.
FATTR_MTIME_NOW
!=
0
{
mtime
=
&
now
}
else
{
t
:=
time
.
Unix
(
int64
(
input
.
Mtime
),
int64
(
input
.
Mtimensec
))
mtime
=
&
t
if
aok
{
a
=
&
atime
}
if
mok
{
m
=
&
mtime
}
code
=
node
.
fsInode
.
Utimens
(
f
,
a
time
,
mtime
,
&
input
.
Context
)
code
=
node
.
fsInode
.
Utimens
(
f
,
a
,
m
,
&
input
.
Context
)
}
if
!
code
.
Ok
()
{
...
...
fuse/types.go
View file @
7b15acfb
...
...
@@ -153,6 +153,79 @@ type SetAttrInCommon struct {
Unused5
uint32
}
func
(
s
*
SetAttrInCommon
)
GetFh
()
(
uint64
,
bool
)
{
if
s
.
Valid
&
FATTR_FH
!=
0
{
return
s
.
Fh
,
true
}
return
0
,
false
}
func
(
s
*
SetAttrInCommon
)
GetMode
()
(
uint32
,
bool
)
{
if
s
.
Valid
&
FATTR_MODE
!=
0
{
return
s
.
Mode
&
07777
,
true
}
return
0
,
false
}
func
(
s
*
SetAttrInCommon
)
GetUID
()
(
uint32
,
bool
)
{
if
s
.
Valid
&
FATTR_UID
!=
0
{
return
s
.
Uid
,
true
}
return
^
uint32
(
0
),
false
}
func
(
s
*
SetAttrInCommon
)
GetGID
()
(
uint32
,
bool
)
{
if
s
.
Valid
&
FATTR_GID
!=
0
{
return
s
.
Gid
,
true
}
return
^
uint32
(
0
),
false
}
func
(
s
*
SetAttrInCommon
)
GetSize
()
(
uint64
,
bool
)
{
if
s
.
Valid
&
FATTR_SIZE
!=
0
{
return
s
.
Size
,
true
}
return
0
,
false
}
func
(
s
*
SetAttrInCommon
)
GetMTime
()
(
time
.
Time
,
bool
)
{
var
t
time
.
Time
if
s
.
Valid
&
FATTR_MTIME
!=
0
{
if
s
.
Valid
&
FATTR_MTIME_NOW
!=
0
{
t
=
time
.
Now
()
}
else
{
t
=
time
.
Unix
(
int64
(
s
.
Mtime
),
int64
(
s
.
Mtimensec
))
}
return
t
,
true
}
return
t
,
false
}
func
(
s
*
SetAttrInCommon
)
GetATime
()
(
time
.
Time
,
bool
)
{
var
t
time
.
Time
if
s
.
Valid
&
FATTR_ATIME
!=
0
{
if
s
.
Valid
&
FATTR_ATIME_NOW
!=
0
{
t
=
time
.
Now
()
}
else
{
t
=
time
.
Unix
(
int64
(
s
.
Atime
),
int64
(
s
.
Atimensec
))
}
return
t
,
true
}
return
t
,
false
}
func
(
s
*
SetAttrInCommon
)
GetCTime
()
(
time
.
Time
,
bool
)
{
var
t
time
.
Time
if
s
.
Valid
&
FATTR_CTIME
!=
0
{
t
=
time
.
Unix
(
int64
(
s
.
Ctime
),
int64
(
s
.
Ctimensec
))
return
t
,
true
}
return
t
,
false
}
const
RELEASE_FLUSH
=
(
1
<<
0
)
type
ReleaseIn
struct
{
...
...
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