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
5e88fbad
Commit
5e88fbad
authored
Mar 09, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'y/nodefs-cancel' into t
* y/nodefs-cancel: Y nodefs: Propagate context to File methods
parents
ee19aa4c
2275cf72
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
130 additions
and
134 deletions
+130
-134
fuse/nodefs/api.go
fuse/nodefs/api.go
+14
-14
fuse/nodefs/defaultfile.go
fuse/nodefs/defaultfile.go
+13
-13
fuse/nodefs/defaultnode.go
fuse/nodefs/defaultnode.go
+3
-3
fuse/nodefs/files.go
fuse/nodefs/files.go
+25
-25
fuse/nodefs/files_linux.go
fuse/nodefs/files_linux.go
+4
-4
fuse/nodefs/files_test.go
fuse/nodefs/files_test.go
+1
-1
fuse/nodefs/fsops.go
fuse/nodefs/fsops.go
+2
-2
fuse/nodefs/lockingfile.go
fuse/nodefs/lockingfile.go
+26
-26
fuse/nodefs/memnode.go
fuse/nodefs/memnode.go
+3
-3
fuse/pathfs/copy.go
fuse/pathfs/copy.go
+4
-4
fuse/pathfs/pathfs.go
fuse/pathfs/pathfs.go
+17
-22
fuse/test/fsetattr_test.go
fuse/test/fsetattr_test.go
+9
-9
unionfs/unionfs.go
unionfs/unionfs.go
+9
-8
No files found.
fuse/nodefs/api.go
View file @
5e88fbad
...
...
@@ -144,34 +144,34 @@ type File interface {
// the inner file here.
InnerFile
()
File
Read
(
dest
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
Write
(
data
[]
byte
,
off
int64
)
(
written
uint32
,
code
fuse
.
Status
)
Read
(
dest
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
Write
(
data
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
written
uint32
,
code
fuse
.
Status
)
// File locking
GetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
code
fuse
.
Status
)
SetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
SetLkw
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
GetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
SetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
SetLkw
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
// Flush is called for close() call on a file descriptor. In
// case of duplicated descriptor, it may be called more than
// once for a file.
Flush
()
fuse
.
Status
Flush
(
ctx
*
fuse
.
Context
)
fuse
.
Status
// This is called to before the file handle is forgotten. This
// method has no return value, so nothing can synchronizes on
// the call. Any cleanup that requires specific synchronization or
// could fail with I/O errors should happen in Flush instead.
Release
()
Fsync
(
flags
int
)
(
code
fuse
.
Status
)
Release
()
// XXX +ctx ?
Fsync
(
flags
int
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
// The methods below may be called on closed files, due to
// concurrency. In that case, you should return EBADF.
Truncate
(
size
uint64
)
fuse
.
Status
GetAttr
(
out
*
fuse
.
Attr
)
fuse
.
Status
Chown
(
uid
uint32
,
gid
uint32
)
fuse
.
Status
Chmod
(
perms
uint32
)
fuse
.
Status
Utimens
(
atime
*
time
.
Time
,
mtime
*
time
.
Time
)
fuse
.
Status
Allocate
(
off
uint64
,
size
uint64
,
mode
uint32
)
(
code
fuse
.
Status
)
Truncate
(
size
uint64
,
ctx
*
fuse
.
Context
)
fuse
.
Status
GetAttr
(
out
*
fuse
.
Attr
,
ctx
*
fuse
.
Context
)
fuse
.
Status
Chown
(
uid
uint32
,
gid
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
Chmod
(
perms
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
Utimens
(
atime
*
time
.
Time
,
mtime
*
time
.
Time
,
ctx
*
fuse
.
Context
)
fuse
.
Status
Allocate
(
off
uint64
,
size
uint64
,
mode
uint32
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
}
// Wrap a File return in this to set FUSE flags. Also used internally
...
...
fuse/nodefs/defaultfile.go
View file @
5e88fbad
...
...
@@ -29,27 +29,27 @@ func (f *defaultFile) String() string {
return
"defaultFile"
}
func
(
f
*
defaultFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
func
(
f
*
defaultFile
)
Read
(
buf
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
return
nil
,
fuse
.
ENOSYS
}
func
(
f
*
defaultFile
)
Write
(
data
[]
byte
,
off
int64
)
(
uint32
,
fuse
.
Status
)
{
func
(
f
*
defaultFile
)
Write
(
data
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
uint32
,
fuse
.
Status
)
{
return
0
,
fuse
.
ENOSYS
}
func
(
f
*
defaultFile
)
GetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
code
fuse
.
Status
)
{
func
(
f
*
defaultFile
)
GetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
f
*
defaultFile
)
SetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
defaultFile
)
SetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
f
*
defaultFile
)
SetLkw
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
defaultFile
)
SetLkw
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
f
*
defaultFile
)
Flush
()
fuse
.
Status
{
func
(
f
*
defaultFile
)
Flush
(
ctx
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
OK
}
...
...
@@ -57,30 +57,30 @@ func (f *defaultFile) Release() {
}
func
(
f
*
defaultFile
)
GetAttr
(
*
fuse
.
Attr
)
fuse
.
Status
{
func
(
f
*
defaultFile
)
GetAttr
(
_
*
fuse
.
Attr
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
ENOSYS
}
func
(
f
*
defaultFile
)
Fsync
(
flags
int
)
(
code
fuse
.
Status
)
{
func
(
f
*
defaultFile
)
Fsync
(
flags
int
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
f
*
defaultFile
)
Utimens
(
atime
*
time
.
Time
,
mtime
*
time
.
Time
)
fuse
.
Status
{
func
(
f
*
defaultFile
)
Utimens
(
atime
*
time
.
Time
,
mtime
*
time
.
Time
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
ENOSYS
}
func
(
f
*
defaultFile
)
Truncate
(
size
uint64
)
fuse
.
Status
{
func
(
f
*
defaultFile
)
Truncate
(
size
uint64
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
ENOSYS
}
func
(
f
*
defaultFile
)
Chown
(
uid
uint32
,
gid
uint32
)
fuse
.
Status
{
func
(
f
*
defaultFile
)
Chown
(
uid
uint32
,
gid
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
ENOSYS
}
func
(
f
*
defaultFile
)
Chmod
(
perms
uint32
)
fuse
.
Status
{
func
(
f
*
defaultFile
)
Chmod
(
perms
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
ENOSYS
}
func
(
f
*
defaultFile
)
Allocate
(
off
uint64
,
size
uint64
,
mode
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
defaultFile
)
Allocate
(
off
uint64
,
size
uint64
,
mode
uint32
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
fuse/nodefs/defaultnode.go
View file @
5e88fbad
...
...
@@ -128,7 +128,7 @@ func (n *defaultNode) ListXAttr(context *fuse.Context) (attrs []string, code fus
func
(
n
*
defaultNode
)
GetAttr
(
out
*
fuse
.
Attr
,
file
File
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
if
file
!=
nil
{
return
file
.
GetAttr
(
out
)
return
file
.
GetAttr
(
out
,
context
)
}
if
n
.
Inode
()
.
IsDir
()
{
out
.
Mode
=
fuse
.
S_IFDIR
|
0755
...
...
@@ -172,14 +172,14 @@ func (n *defaultNode) Fallocate(file File, off uint64, size uint64, mode uint32,
func
(
n
*
defaultNode
)
Read
(
file
File
,
dest
[]
byte
,
off
int64
,
context
*
fuse
.
Context
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
if
file
!=
nil
{
return
file
.
Read
(
dest
,
off
)
return
file
.
Read
(
dest
,
off
,
context
)
}
return
nil
,
fuse
.
ENOSYS
}
func
(
n
*
defaultNode
)
Write
(
file
File
,
data
[]
byte
,
off
int64
,
context
*
fuse
.
Context
)
(
written
uint32
,
code
fuse
.
Status
)
{
if
file
!=
nil
{
return
file
.
Write
(
data
,
off
)
return
file
.
Write
(
data
,
off
,
context
)
}
return
0
,
fuse
.
ENOSYS
}
fuse/nodefs/files.go
View file @
5e88fbad
...
...
@@ -30,7 +30,7 @@ func (f *dataFile) String() string {
return
fmt
.
Sprintf
(
"dataFile(%x)"
,
f
.
data
[
:
l
])
}
func
(
f
*
dataFile
)
GetAttr
(
out
*
fuse
.
Attr
)
fuse
.
Status
{
func
(
f
*
dataFile
)
GetAttr
(
out
*
fuse
.
Attr
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
out
.
Mode
=
fuse
.
S_IFREG
|
0644
out
.
Size
=
uint64
(
len
(
f
.
data
))
return
fuse
.
OK
...
...
@@ -43,7 +43,7 @@ func NewDataFile(data []byte) File {
return
f
}
func
(
f
*
dataFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
res
fuse
.
ReadResult
,
code
fuse
.
Status
)
{
func
(
f
*
dataFile
)
Read
(
buf
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
res
fuse
.
ReadResult
,
code
fuse
.
Status
)
{
end
:=
int
(
off
)
+
int
(
len
(
buf
))
if
end
>
len
(
f
.
data
)
{
end
=
len
(
f
.
data
)
...
...
@@ -64,7 +64,7 @@ func NewDevNullFile() File {
}
}
func
(
f
*
devNullFile
)
Allocate
(
off
uint64
,
size
uint64
,
mode
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
devNullFile
)
Allocate
(
off
uint64
,
size
uint64
,
mode
uint32
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
OK
}
...
...
@@ -72,23 +72,23 @@ func (f *devNullFile) String() string {
return
"devNullFile"
}
func
(
f
*
devNullFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
func
(
f
*
devNullFile
)
Read
(
buf
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
return
fuse
.
ReadResultData
(
nil
),
fuse
.
OK
}
func
(
f
*
devNullFile
)
Write
(
content
[]
byte
,
off
int64
)
(
uint32
,
fuse
.
Status
)
{
func
(
f
*
devNullFile
)
Write
(
content
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
uint32
,
fuse
.
Status
)
{
return
uint32
(
len
(
content
)),
fuse
.
OK
}
func
(
f
*
devNullFile
)
Flush
()
fuse
.
Status
{
func
(
f
*
devNullFile
)
Flush
(
ctx
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
OK
}
func
(
f
*
devNullFile
)
Fsync
(
flags
int
)
(
code
fuse
.
Status
)
{
func
(
f
*
devNullFile
)
Fsync
(
flags
int
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
OK
}
func
(
f
*
devNullFile
)
Truncate
(
size
uint64
)
(
code
fuse
.
Status
)
{
func
(
f
*
devNullFile
)
Truncate
(
size
uint64
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
OK
}
...
...
@@ -121,7 +121,7 @@ func (f *loopbackFile) String() string {
return
fmt
.
Sprintf
(
"loopbackFile(%s)"
,
f
.
File
.
Name
())
}
func
(
f
*
loopbackFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
res
fuse
.
ReadResult
,
code
fuse
.
Status
)
{
func
(
f
*
loopbackFile
)
Read
(
buf
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
res
fuse
.
ReadResult
,
code
fuse
.
Status
)
{
f
.
lock
.
Lock
()
// This is not racy by virtue of the kernel properly
// synchronizing the open/write/close.
...
...
@@ -130,7 +130,7 @@ func (f *loopbackFile) Read(buf []byte, off int64) (res fuse.ReadResult, code fu
return
r
,
fuse
.
OK
}
func
(
f
*
loopbackFile
)
Write
(
data
[]
byte
,
off
int64
)
(
uint32
,
fuse
.
Status
)
{
func
(
f
*
loopbackFile
)
Write
(
data
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
uint32
,
fuse
.
Status
)
{
f
.
lock
.
Lock
()
n
,
err
:=
f
.
File
.
WriteAt
(
data
,
off
)
f
.
lock
.
Unlock
()
...
...
@@ -143,7 +143,7 @@ func (f *loopbackFile) Release() {
f
.
lock
.
Unlock
()
}
func
(
f
*
loopbackFile
)
Flush
()
fuse
.
Status
{
func
(
f
*
loopbackFile
)
Flush
(
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
lock
.
Lock
()
// Since Flush() may be called for each dup'd fd, we don't
...
...
@@ -159,7 +159,7 @@ func (f *loopbackFile) Flush() fuse.Status {
return
fuse
.
ToStatus
(
err
)
}
func
(
f
*
loopbackFile
)
Fsync
(
flags
int
)
(
code
fuse
.
Status
)
{
func
(
f
*
loopbackFile
)
Fsync
(
flags
int
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
f
.
lock
.
Lock
()
r
:=
fuse
.
ToStatus
(
syscall
.
Fsync
(
int
(
f
.
File
.
Fd
())))
f
.
lock
.
Unlock
()
...
...
@@ -173,7 +173,7 @@ const (
F_OFD_SETLKW
=
38
)
func
(
f
*
loopbackFile
)
GetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
code
fuse
.
Status
)
{
func
(
f
*
loopbackFile
)
GetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
flk
:=
syscall
.
Flock_t
{}
lk
.
ToFlockT
(
&
flk
)
code
=
fuse
.
ToStatus
(
syscall
.
FcntlFlock
(
f
.
File
.
Fd
(),
F_OFD_GETLK
,
&
flk
))
...
...
@@ -181,11 +181,11 @@ func (f *loopbackFile) GetLk(owner uint64, lk *fuse.FileLock, flags uint32, out
return
}
func
(
f
*
loopbackFile
)
SetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
loopbackFile
)
SetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
f
.
setLock
(
owner
,
lk
,
flags
,
false
)
}
func
(
f
*
loopbackFile
)
SetLkw
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
loopbackFile
)
SetLkw
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
f
.
setLock
(
owner
,
lk
,
flags
,
true
)
}
...
...
@@ -219,7 +219,7 @@ func (f *loopbackFile) setLock(owner uint64, lk *fuse.FileLock, flags uint32, bl
}
}
func
(
f
*
loopbackFile
)
Truncate
(
size
uint64
)
fuse
.
Status
{
func
(
f
*
loopbackFile
)
Truncate
(
size
uint64
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
lock
.
Lock
()
r
:=
fuse
.
ToStatus
(
syscall
.
Ftruncate
(
int
(
f
.
File
.
Fd
()),
int64
(
size
)))
f
.
lock
.
Unlock
()
...
...
@@ -227,7 +227,7 @@ func (f *loopbackFile) Truncate(size uint64) fuse.Status {
return
r
}
func
(
f
*
loopbackFile
)
Chmod
(
mode
uint32
)
fuse
.
Status
{
func
(
f
*
loopbackFile
)
Chmod
(
mode
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
lock
.
Lock
()
r
:=
fuse
.
ToStatus
(
f
.
File
.
Chmod
(
os
.
FileMode
(
mode
)))
f
.
lock
.
Unlock
()
...
...
@@ -235,7 +235,7 @@ func (f *loopbackFile) Chmod(mode uint32) fuse.Status {
return
r
}
func
(
f
*
loopbackFile
)
Chown
(
uid
uint32
,
gid
uint32
)
fuse
.
Status
{
func
(
f
*
loopbackFile
)
Chown
(
uid
uint32
,
gid
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
lock
.
Lock
()
r
:=
fuse
.
ToStatus
(
f
.
File
.
Chown
(
int
(
uid
),
int
(
gid
)))
f
.
lock
.
Unlock
()
...
...
@@ -243,7 +243,7 @@ func (f *loopbackFile) Chown(uid uint32, gid uint32) fuse.Status {
return
r
}
func
(
f
*
loopbackFile
)
GetAttr
(
a
*
fuse
.
Attr
)
fuse
.
Status
{
func
(
f
*
loopbackFile
)
GetAttr
(
a
*
fuse
.
Attr
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
st
:=
syscall
.
Stat_t
{}
f
.
lock
.
Lock
()
err
:=
syscall
.
Fstat
(
int
(
f
.
File
.
Fd
()),
&
st
)
...
...
@@ -279,26 +279,26 @@ func (f *readOnlyFile) String() string {
return
fmt
.
Sprintf
(
"readOnlyFile(%s)"
,
f
.
File
.
String
())
}
func
(
f
*
readOnlyFile
)
Write
(
data
[]
byte
,
off
int64
)
(
uint32
,
fuse
.
Status
)
{
func
(
f
*
readOnlyFile
)
Write
(
data
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
uint32
,
fuse
.
Status
)
{
return
0
,
fuse
.
EPERM
}
func
(
f
*
readOnlyFile
)
Fsync
(
flag
int
)
(
code
fuse
.
Status
)
{
func
(
f
*
readOnlyFile
)
Fsync
(
flag
int
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
OK
}
func
(
f
*
readOnlyFile
)
Truncate
(
size
uint64
)
fuse
.
Status
{
func
(
f
*
readOnlyFile
)
Truncate
(
size
uint64
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
EPERM
}
func
(
f
*
readOnlyFile
)
Chmod
(
mode
uint32
)
fuse
.
Status
{
func
(
f
*
readOnlyFile
)
Chmod
(
mode
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
EPERM
}
func
(
f
*
readOnlyFile
)
Chown
(
uid
uint32
,
gid
uint32
)
fuse
.
Status
{
func
(
f
*
readOnlyFile
)
Chown
(
uid
uint32
,
gid
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
EPERM
}
func
(
f
*
readOnlyFile
)
Allocate
(
off
uint64
,
sz
uint64
,
mode
uint32
)
fuse
.
Status
{
func
(
f
*
readOnlyFile
)
Allocate
(
off
uint64
,
sz
uint64
,
mode
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
EPERM
}
fuse/nodefs/files_linux.go
View file @
5e88fbad
...
...
@@ -11,9 +11,9 @@ import (
"github.com/hanwen/go-fuse/v2/fuse"
)
func
(
f
*
loopbackFile
)
Allocate
(
off
uint64
,
sz
uint64
,
mode
uint32
)
fuse
.
Status
{
func
(
f
*
loopbackFile
)
Allocate
(
off
uint64
,
sz
uint64
,
mode
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
lock
.
Lock
()
err
:=
syscall
.
Fallocate
(
int
(
f
.
File
.
Fd
()),
mode
,
int64
(
off
),
int64
(
sz
))
err
:=
syscall
.
Fallocate
(
int
(
f
.
File
.
Fd
()),
mode
,
int64
(
off
),
int64
(
sz
))
// XXX cancel not propagated
f
.
lock
.
Unlock
()
if
err
!=
nil
{
return
fuse
.
ToStatus
(
err
)
...
...
@@ -22,12 +22,12 @@ func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status
}
// Utimens - file handle based version of loopbackFileSystem.Utimens()
func
(
f
*
loopbackFile
)
Utimens
(
a
*
time
.
Time
,
m
*
time
.
Time
)
fuse
.
Status
{
func
(
f
*
loopbackFile
)
Utimens
(
a
*
time
.
Time
,
m
*
time
.
Time
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
var
ts
[
2
]
syscall
.
Timespec
ts
[
0
]
=
fuse
.
UtimeToTimespec
(
a
)
ts
[
1
]
=
fuse
.
UtimeToTimespec
(
m
)
f
.
lock
.
Lock
()
err
:=
futimens
(
int
(
f
.
File
.
Fd
()),
&
ts
)
err
:=
futimens
(
int
(
f
.
File
.
Fd
()),
&
ts
)
// XXX cancel not propagated
f
.
lock
.
Unlock
()
return
fuse
.
ToStatus
(
err
)
}
fuse/nodefs/files_test.go
View file @
5e88fbad
...
...
@@ -26,7 +26,7 @@ func TestLoopbackFileUtimens(t *testing.T) {
f
:=
NewLoopbackFile
(
f2
)
utimensFn
:=
func
(
atime
*
time
.
Time
,
mtime
*
time
.
Time
)
fuse
.
Status
{
return
f
.
Utimens
(
atime
,
mtime
)
return
f
.
Utimens
(
atime
,
mtime
,
&
fuse
.
Context
{
Cancel
:
nil
}
)
}
testutil
.
TestLoopbackUtimens
(
t
,
path
,
utimensFn
)
}
fuse/nodefs/fsops.go
View file @
5e88fbad
...
...
@@ -28,7 +28,7 @@ func (c *rawBridge) Fsync(cancel <-chan struct{}, input *fuse.FsyncIn) fuse.Stat
opened
:=
node
.
mount
.
getOpenedFile
(
input
.
Fh
)
if
opened
!=
nil
{
return
opened
.
WithFlags
.
File
.
Fsync
(
int
(
input
.
FsyncFlags
))
return
opened
.
WithFlags
.
File
.
Fsync
(
int
(
input
.
FsyncFlags
)
,
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
}
)
}
return
fuse
.
ENOSYS
...
...
@@ -490,7 +490,7 @@ func (c *rawBridge) Flush(cancel <-chan struct{}, input *fuse.FlushIn) fuse.Stat
opened
:=
node
.
mount
.
getOpenedFile
(
input
.
Fh
)
if
opened
!=
nil
{
return
opened
.
WithFlags
.
File
.
Flush
()
return
opened
.
WithFlags
.
File
.
Flush
(
&
fuse
.
Context
{
Caller
:
input
.
Caller
,
Cancel
:
cancel
}
)
}
return
fuse
.
OK
}
...
...
fuse/nodefs/lockingfile.go
View file @
5e88fbad
...
...
@@ -36,40 +36,40 @@ func (f *lockingFile) String() string {
return
fmt
.
Sprintf
(
"lockingFile(%s)"
,
f
.
file
.
String
())
}
func
(
f
*
lockingFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
func
(
f
*
lockingFile
)
Read
(
buf
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
Read
(
buf
,
off
)
return
f
.
file
.
Read
(
buf
,
off
,
ctx
)
}
func
(
f
*
lockingFile
)
Write
(
data
[]
byte
,
off
int64
)
(
uint32
,
fuse
.
Status
)
{
func
(
f
*
lockingFile
)
Write
(
data
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
uint32
,
fuse
.
Status
)
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
Write
(
data
,
off
)
return
f
.
file
.
Write
(
data
,
off
,
ctx
)
}
func
(
f
*
lockingFile
)
Flush
()
fuse
.
Status
{
func
(
f
*
lockingFile
)
Flush
(
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
Flush
()
return
f
.
file
.
Flush
(
ctx
)
}
func
(
f
*
lockingFile
)
GetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
)
(
code
fuse
.
Status
)
{
func
(
f
*
lockingFile
)
GetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
GetLk
(
owner
,
lk
,
flags
,
out
)
return
f
.
file
.
GetLk
(
owner
,
lk
,
flags
,
out
,
ctx
)
}
func
(
f
*
lockingFile
)
SetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
lockingFile
)
SetLk
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
SetLk
(
owner
,
lk
,
flags
)
return
f
.
file
.
SetLk
(
owner
,
lk
,
flags
,
ctx
)
}
func
(
f
*
lockingFile
)
SetLkw
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
lockingFile
)
SetLkw
(
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
SetLkw
(
owner
,
lk
,
flags
)
return
f
.
file
.
SetLkw
(
owner
,
lk
,
flags
,
ctx
)
}
func
(
f
*
lockingFile
)
Release
()
{
...
...
@@ -78,44 +78,44 @@ func (f *lockingFile) Release() {
f
.
file
.
Release
()
}
func
(
f
*
lockingFile
)
GetAttr
(
a
*
fuse
.
Attr
)
fuse
.
Status
{
func
(
f
*
lockingFile
)
GetAttr
(
a
*
fuse
.
Attr
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
GetAttr
(
a
)
return
f
.
file
.
GetAttr
(
a
,
ctx
)
}
func
(
f
*
lockingFile
)
Fsync
(
flags
int
)
(
code
fuse
.
Status
)
{
func
(
f
*
lockingFile
)
Fsync
(
flags
int
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
Fsync
(
flags
)
return
f
.
file
.
Fsync
(
flags
,
ctx
)
}
func
(
f
*
lockingFile
)
Utimens
(
atime
*
time
.
Time
,
mtime
*
time
.
Time
)
fuse
.
Status
{
func
(
f
*
lockingFile
)
Utimens
(
atime
*
time
.
Time
,
mtime
*
time
.
Time
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
Utimens
(
atime
,
mtime
)
return
f
.
file
.
Utimens
(
atime
,
mtime
,
ctx
)
}
func
(
f
*
lockingFile
)
Truncate
(
size
uint64
)
fuse
.
Status
{
func
(
f
*
lockingFile
)
Truncate
(
size
uint64
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
Truncate
(
size
)
return
f
.
file
.
Truncate
(
size
,
ctx
)
}
func
(
f
*
lockingFile
)
Chown
(
uid
uint32
,
gid
uint32
)
fuse
.
Status
{
func
(
f
*
lockingFile
)
Chown
(
uid
uint32
,
gid
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
Chown
(
uid
,
gid
)
return
f
.
file
.
Chown
(
uid
,
gid
,
ctx
)
}
func
(
f
*
lockingFile
)
Chmod
(
perms
uint32
)
fuse
.
Status
{
func
(
f
*
lockingFile
)
Chmod
(
perms
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
Chmod
(
perms
)
return
f
.
file
.
Chmod
(
perms
,
ctx
)
}
func
(
f
*
lockingFile
)
Allocate
(
off
uint64
,
size
uint64
,
mode
uint32
)
(
code
fuse
.
Status
)
{
func
(
f
*
lockingFile
)
Allocate
(
off
uint64
,
size
uint64
,
mode
uint32
,
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
f
.
mu
.
Lock
()
defer
f
.
mu
.
Unlock
()
return
f
.
file
.
Allocate
(
off
,
size
,
mode
)
return
f
.
file
.
Allocate
(
off
,
size
,
mode
,
ctx
)
}
fuse/nodefs/memnode.go
View file @
5e88fbad
...
...
@@ -162,8 +162,8 @@ func (n *memNodeFile) InnerFile() File {
return
n
.
File
}
func
(
n
*
memNodeFile
)
Flush
()
fuse
.
Status
{
code
:=
n
.
File
.
Flush
()
func
(
n
*
memNodeFile
)
Flush
(
ctx
*
fuse
.
Context
)
fuse
.
Status
{
code
:=
n
.
File
.
Flush
(
ctx
)
if
!
code
.
Ok
()
{
return
code
...
...
@@ -205,7 +205,7 @@ func (n *memNode) GetAttr(fi *fuse.Attr, file File, context *fuse.Context) (code
func
(
n
*
memNode
)
Truncate
(
file
File
,
size
uint64
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
if
file
!=
nil
{
code
=
file
.
Truncate
(
size
)
code
=
file
.
Truncate
(
size
,
context
)
}
else
{
err
:=
os
.
Truncate
(
n
.
filename
(),
int64
(
size
))
code
=
fuse
.
ToStatus
(
err
)
...
...
fuse/pathfs/copy.go
View file @
5e88fbad
...
...
@@ -16,7 +16,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *fuse.
return
code
}
defer
src
.
Release
()
defer
src
.
Flush
()
defer
src
.
Flush
(
context
)
attr
,
code
:=
srcFs
.
GetAttr
(
srcFile
,
context
)
if
!
code
.
Ok
()
{
...
...
@@ -28,12 +28,12 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *fuse.
return
code
}
defer
dst
.
Release
()
defer
dst
.
Flush
()
defer
dst
.
Flush
(
context
)
buf
:=
make
([]
byte
,
128
*
(
1
<<
10
))
off
:=
int64
(
0
)
for
{
res
,
code
:=
src
.
Read
(
buf
,
off
)
res
,
code
:=
src
.
Read
(
buf
,
off
,
context
)
if
!
code
.
Ok
()
{
return
code
}
...
...
@@ -45,7 +45,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *fuse.
if
len
(
data
)
==
0
{
break
}
n
,
code
:=
dst
.
Write
(
data
,
off
)
n
,
code
:=
dst
.
Write
(
data
,
off
,
context
)
if
!
code
.
Ok
()
{
return
code
}
...
...
fuse/pathfs/pathfs.go
View file @
5e88fbad
...
...
@@ -404,7 +404,7 @@ func (n *pathInode) ListXAttr(context *fuse.Context) (attrs []string, code fuse.
}
func
(
n
*
pathInode
)
Flush
(
file
nodefs
.
File
,
openFlags
uint32
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
file
.
Flush
()
return
file
.
Flush
(
context
)
}
func
(
n
*
pathInode
)
OpenDir
(
context
*
fuse
.
Context
)
([]
fuse
.
DirEntry
,
fuse
.
Status
)
{
...
...
@@ -592,7 +592,7 @@ func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Cont
}
// If we have found an open file, try to fstat it.
if
file
!=
nil
{
code
=
file
.
GetAttr
(
out
)
code
=
file
.
GetAttr
(
out
,
context
)
if
code
.
Ok
()
{
return
code
}
...
...
@@ -629,7 +629,7 @@ func (n *pathInode) Chmod(file nodefs.File, perms uint32, context *fuse.Context)
// Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor
// to FUSE for fchmod. We still check because that may change in the future.
if
file
!=
nil
{
code
=
file
.
Chmod
(
perms
)
code
=
file
.
Chmod
(
perms
,
context
)
if
code
!=
fuse
.
ENOSYS
{
return
code
}
...
...
@@ -637,8 +637,7 @@ func (n *pathInode) Chmod(file nodefs.File, perms uint32, context *fuse.Context)
files
:=
n
.
Inode
()
.
Files
(
fuse
.
O_ANYWRITE
)
for
_
,
f
:=
range
files
{
// TODO - pass context
code
=
f
.
Chmod
(
perms
)
code
=
f
.
Chmod
(
perms
,
context
)
if
code
.
Ok
()
{
return
}
...
...
@@ -654,7 +653,7 @@ func (n *pathInode) Chown(file nodefs.File, uid uint32, gid uint32, context *fus
// Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor
// to FUSE for fchown. We still check because it may change in the future.
if
file
!=
nil
{
code
=
file
.
Chown
(
uid
,
gid
)
code
=
file
.
Chown
(
uid
,
gid
,
context
)
if
code
!=
fuse
.
ENOSYS
{
return
code
}
...
...
@@ -662,8 +661,7 @@ func (n *pathInode) Chown(file nodefs.File, uid uint32, gid uint32, context *fus
files
:=
n
.
Inode
()
.
Files
(
fuse
.
O_ANYWRITE
)
for
_
,
f
:=
range
files
{
// TODO - pass context
code
=
f
.
Chown
(
uid
,
gid
)
code
=
f
.
Chown
(
uid
,
gid
,
context
)
if
code
.
Ok
()
{
return
code
}
...
...
@@ -679,7 +677,7 @@ func (n *pathInode) Truncate(file nodefs.File, size uint64, context *fuse.Contex
// A file descriptor was passed in AND the filesystem implements the
// operation on the file handle. This the common case for ftruncate.
if
file
!=
nil
{
code
=
file
.
Truncate
(
size
)
code
=
file
.
Truncate
(
size
,
context
)
if
code
!=
fuse
.
ENOSYS
{
return
code
}
...
...
@@ -687,8 +685,7 @@ func (n *pathInode) Truncate(file nodefs.File, size uint64, context *fuse.Contex
files
:=
n
.
Inode
()
.
Files
(
fuse
.
O_ANYWRITE
)
for
_
,
f
:=
range
files
{
// TODO - pass context
code
=
f
.
Truncate
(
size
)
code
=
f
.
Truncate
(
size
,
context
)
if
code
.
Ok
()
{
return
code
}
...
...
@@ -703,7 +700,7 @@ func (n *pathInode) Utimens(file nodefs.File, atime *time.Time, mtime *time.Time
// Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor
// to FUSE for futimens. We still check because it may change in the future.
if
file
!=
nil
{
code
=
file
.
Utimens
(
atime
,
mtime
)
code
=
file
.
Utimens
(
atime
,
mtime
,
context
)
if
code
!=
fuse
.
ENOSYS
{
return
code
}
...
...
@@ -711,8 +708,7 @@ func (n *pathInode) Utimens(file nodefs.File, atime *time.Time, mtime *time.Time
files
:=
n
.
Inode
()
.
Files
(
fuse
.
O_ANYWRITE
)
for
_
,
f
:=
range
files
{
// TODO - pass context
code
=
f
.
Utimens
(
atime
,
mtime
)
code
=
f
.
Utimens
(
atime
,
mtime
,
context
)
if
code
.
Ok
()
{
return
code
}
...
...
@@ -725,7 +721,7 @@ func (n *pathInode) Utimens(file nodefs.File, atime *time.Time, mtime *time.Time
func
(
n
*
pathInode
)
Fallocate
(
file
nodefs
.
File
,
off
uint64
,
size
uint64
,
mode
uint32
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
if
file
!=
nil
{
code
=
file
.
Allocate
(
off
,
size
,
mode
)
code
=
file
.
Allocate
(
off
,
size
,
mode
,
context
)
if
code
.
Ok
()
{
return
code
}
...
...
@@ -733,8 +729,7 @@ func (n *pathInode) Fallocate(file nodefs.File, off uint64, size uint64, mode ui
files
:=
n
.
Inode
()
.
Files
(
fuse
.
O_ANYWRITE
)
for
_
,
f
:=
range
files
{
// TODO - pass context
code
=
f
.
Allocate
(
off
,
size
,
mode
)
code
=
f
.
Allocate
(
off
,
size
,
mode
,
context
)
if
code
.
Ok
()
{
return
code
}
...
...
@@ -745,35 +740,35 @@ func (n *pathInode) Fallocate(file nodefs.File, off uint64, size uint64, mode ui
func
(
n
*
pathInode
)
Read
(
file
nodefs
.
File
,
dest
[]
byte
,
off
int64
,
context
*
fuse
.
Context
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
if
file
!=
nil
{
return
file
.
Read
(
dest
,
off
)
return
file
.
Read
(
dest
,
off
,
context
)
}
return
nil
,
fuse
.
ENOSYS
}
func
(
n
*
pathInode
)
Write
(
file
nodefs
.
File
,
data
[]
byte
,
off
int64
,
context
*
fuse
.
Context
)
(
written
uint32
,
code
fuse
.
Status
)
{
if
file
!=
nil
{
return
file
.
Write
(
data
,
off
)
return
file
.
Write
(
data
,
off
,
context
)
}
return
0
,
fuse
.
ENOSYS
}
func
(
n
*
pathInode
)
GetLk
(
file
nodefs
.
File
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
out
*
fuse
.
FileLock
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
if
file
!=
nil
{
return
file
.
GetLk
(
owner
,
lk
,
flags
,
out
)
return
file
.
GetLk
(
owner
,
lk
,
flags
,
out
,
context
)
}
return
fuse
.
ENOSYS
}
func
(
n
*
pathInode
)
SetLk
(
file
nodefs
.
File
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
if
file
!=
nil
{
return
file
.
SetLk
(
owner
,
lk
,
flags
)
return
file
.
SetLk
(
owner
,
lk
,
flags
,
context
)
}
return
fuse
.
ENOSYS
}
func
(
n
*
pathInode
)
SetLkw
(
file
nodefs
.
File
,
owner
uint64
,
lk
*
fuse
.
FileLock
,
flags
uint32
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
if
file
!=
nil
{
return
file
.
SetLkw
(
owner
,
lk
,
flags
)
return
file
.
SetLkw
(
owner
,
lk
,
flags
,
context
)
}
return
fuse
.
ENOSYS
}
fuse/test/fsetattr_test.go
View file @
5e88fbad
...
...
@@ -29,7 +29,7 @@ func (f *MutableDataFile) String() string {
return
"MutableDataFile"
}
func
(
f
*
MutableDataFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
func
(
f
*
MutableDataFile
)
Read
(
buf
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
fuse
.
ReadResult
,
fuse
.
Status
)
{
end
:=
int
(
off
)
+
len
(
buf
)
if
end
>
len
(
f
.
data
)
{
end
=
len
(
f
.
data
)
...
...
@@ -38,7 +38,7 @@ func (f *MutableDataFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Sta
return
fuse
.
ReadResultData
(
f
.
data
[
off
:
end
]),
fuse
.
OK
}
func
(
f
*
MutableDataFile
)
Write
(
d
[]
byte
,
off
int64
)
(
uint32
,
fuse
.
Status
)
{
func
(
f
*
MutableDataFile
)
Write
(
d
[]
byte
,
off
int64
,
ctx
*
fuse
.
Context
)
(
uint32
,
fuse
.
Status
)
{
end
:=
int64
(
len
(
d
))
+
off
if
int
(
end
)
>
len
(
f
.
data
)
{
data
:=
make
([]
byte
,
len
(
f
.
data
),
end
)
...
...
@@ -51,7 +51,7 @@ func (f *MutableDataFile) Write(d []byte, off int64) (uint32, fuse.Status) {
return
uint32
(
end
-
off
),
fuse
.
OK
}
func
(
f
*
MutableDataFile
)
Flush
()
fuse
.
Status
{
func
(
f
*
MutableDataFile
)
Flush
(
ctx
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
OK
}
...
...
@@ -64,34 +64,34 @@ func (f *MutableDataFile) getAttr(out *fuse.Attr) {
out
.
Size
=
uint64
(
len
(
f
.
data
))
}
func
(
f
*
MutableDataFile
)
GetAttr
(
out
*
fuse
.
Attr
)
fuse
.
Status
{
func
(
f
*
MutableDataFile
)
GetAttr
(
out
*
fuse
.
Attr
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
GetAttrCalled
=
true
f
.
getAttr
(
out
)
return
fuse
.
OK
}
func
(
f
*
MutableDataFile
)
Utimens
(
atime
*
time
.
Time
,
mtime
*
time
.
Time
)
fuse
.
Status
{
func
(
f
*
MutableDataFile
)
Utimens
(
atime
*
time
.
Time
,
mtime
*
time
.
Time
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
Attr
.
SetTimes
(
atime
,
mtime
,
nil
)
return
fuse
.
OK
}
func
(
f
*
MutableDataFile
)
Truncate
(
size
uint64
)
fuse
.
Status
{
func
(
f
*
MutableDataFile
)
Truncate
(
size
uint64
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
data
=
f
.
data
[
:
size
]
return
fuse
.
OK
}
func
(
f
*
MutableDataFile
)
Chown
(
uid
uint32
,
gid
uint32
)
fuse
.
Status
{
func
(
f
*
MutableDataFile
)
Chown
(
uid
uint32
,
gid
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
Attr
.
Uid
=
uid
f
.
Attr
.
Gid
=
gid
return
fuse
.
OK
}
func
(
f
*
MutableDataFile
)
Chmod
(
perms
uint32
)
fuse
.
Status
{
func
(
f
*
MutableDataFile
)
Chmod
(
perms
uint32
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
Attr
.
Mode
=
(
f
.
Attr
.
Mode
&^
07777
)
|
perms
return
fuse
.
OK
}
func
(
f
*
MutableDataFile
)
Fsync
(
flags
int
)
fuse
.
Status
{
func
(
f
*
MutableDataFile
)
Fsync
(
flags
int
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
f
.
FsyncCalled
=
true
return
fuse
.
OK
}
...
...
unionfs/unionfs.go
View file @
5e88fbad
...
...
@@ -276,8 +276,9 @@ func (fs *unionFS) putDeletion(name string) (code fuse.Status) {
return
fuse
.
EPERM
}
defer
f
.
Release
()
defer
f
.
Flush
()
n
,
code
:=
f
.
Write
([]
byte
(
name
),
0
)
ctx
:=
&
fuse
.
Context
{
Cancel
:
nil
}
defer
f
.
Flush
(
ctx
)
n
,
code
:=
f
.
Write
([]
byte
(
name
),
0
,
ctx
)
if
int
(
n
)
!=
len
(
name
)
||
!
code
.
Ok
()
{
panic
(
fmt
.
Sprintf
(
"Error for writing %v: %v, %v (exp %v) %v"
,
name
,
marker
,
n
,
len
(
name
),
code
))
}
...
...
@@ -334,7 +335,7 @@ func (fs *unionFS) Promote(name string, srcResult branchResult, context *fuse.Co
uf
.
layer
=
0
f
:=
uf
.
File
uf
.
File
,
code
=
fs
.
fileSystems
[
0
]
.
Open
(
name
,
fileWrapper
.
OpenFlags
,
context
)
f
.
Flush
()
f
.
Flush
(
context
)
f
.
Release
()
}
}
...
...
@@ -949,7 +950,7 @@ func (fs *unionFS) DropSubFsCaches() {
if
code
.
Ok
()
&&
a
.
IsRegular
()
{
f
,
_
:=
fs
.
Open
(
_DROP_CACHE
,
uint32
(
os
.
O_WRONLY
),
nil
)
if
f
!=
nil
{
f
.
Flush
()
f
.
Flush
(
&
fuse
.
Context
{
Cancel
:
nil
}
)
f
.
Release
()
}
}
...
...
@@ -1028,8 +1029,8 @@ func (fs *unionFsFile) InnerFile() (file nodefs.File) {
// We can't hook on Release. Release has no response, so it is not
// ordered wrt any following calls.
func
(
fs
*
unionFsFile
)
Flush
()
(
code
fuse
.
Status
)
{
code
=
fs
.
File
.
Flush
()
func
(
fs
*
unionFsFile
)
Flush
(
ctx
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
code
=
fs
.
File
.
Flush
(
ctx
)
path
:=
fs
.
ufs
.
nodeFs
.
Path
(
fs
.
node
)
fs
.
ufs
.
branchCache
.
GetFresh
(
path
)
return
code
...
...
@@ -1039,8 +1040,8 @@ func (fs *unionFsFile) SetInode(node *nodefs.Inode) {
fs
.
node
=
node
}
func
(
fs
*
unionFsFile
)
GetAttr
(
out
*
fuse
.
Attr
)
fuse
.
Status
{
code
:=
fs
.
File
.
GetAttr
(
out
)
func
(
fs
*
unionFsFile
)
GetAttr
(
out
*
fuse
.
Attr
,
ctx
*
fuse
.
Context
)
fuse
.
Status
{
code
:=
fs
.
File
.
GetAttr
(
out
,
ctx
)
if
code
.
Ok
()
{
out
.
Mode
|=
0200
}
...
...
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