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
0ebbc3a5
Commit
0ebbc3a5
authored
Aug 18, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle setattr and getattr on open files too.
parent
f7de38df
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
17 deletions
+49
-17
fuse/fsetattr_test.go
fuse/fsetattr_test.go
+6
-10
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+10
-2
fuse/pathops.go
fuse/pathops.go
+13
-5
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+20
-0
No files found.
fuse/fsetattr_test.go
View file @
0ebbc3a5
...
...
@@ -3,7 +3,6 @@ package fuse
import
(
"fmt"
"log"
"json"
"os"
"syscall"
"testing"
...
...
@@ -152,28 +151,25 @@ func TestFSetAttr(t *testing.T) {
if
state
.
KernelSettings
()
.
Flags
&
CAP_FILE_OPS
==
0
{
log
.
Println
(
"Mount does not support file operations"
)
m
,
_
:=
json
.
Marshal
(
state
.
KernelSettings
())
log
.
Println
(
"Kernel settings: "
,
string
(
m
))
return
}
_
,
err
=
os
.
Lstat
(
fn
)
_
,
err
=
f
.
Stat
(
)
CheckSuccess
(
err
)
if
!
fs
.
file
.
GetAttrCalled
{
t
.
Error
(
"Should have called File.GetAttr"
)
}
err
=
os
.
Chmod
(
fn
,
024
)
err
=
f
.
Chmod
(
024
)
CheckSuccess
(
err
)
if
fs
.
file
.
FileInfo
.
Mode
&
07777
!=
024
{
t
.
Error
(
"chmod"
)
}
err
=
os
.
Chtimes
(
fn
,
100
,
101
)
err
=
os
.
Chtimes
(
fn
,
100
e3
,
101e3
)
CheckSuccess
(
err
)
if
fs
.
file
.
FileInfo
.
Atime_ns
!=
100
||
fs
.
file
.
FileInfo
.
Atime_ns
!=
101
{
t
.
Error
(
"Utimens"
)
if
fs
.
file
.
FileInfo
.
Atime_ns
!=
100
e3
||
fs
.
file
.
FileInfo
.
Mtime_ns
!=
101e3
{
t
.
Error
(
"Utimens"
,
fs
.
file
.
FileInfo
)
}
// TODO - test chown if run as root.
...
...
fuse/pathfilesystem.go
View file @
0ebbc3a5
...
...
@@ -648,8 +648,8 @@ func (me *FileSystemConnector) unsafeUnmountNode(node *inode) {
unmounted
.
fs
.
Unmount
()
}
func
(
me
*
FileSystemConnector
)
getOpenFileData
(
nodeid
uint64
,
fh
uint64
)
(
f
File
,
m
*
fileSystemMount
,
p
string
)
{
node
:
=
me
.
getInodeData
(
nodeid
)
func
(
me
*
FileSystemConnector
)
getOpenFileData
(
nodeid
uint64
,
fh
uint64
)
(
f
File
,
m
*
fileSystemMount
,
p
string
,
node
*
inode
)
{
node
=
me
.
getInodeData
(
nodeid
)
node
.
treeLock
.
RLock
()
defer
node
.
treeLock
.
RUnlock
()
...
...
@@ -666,6 +666,14 @@ func (me *FileSystemConnector) getOpenFileData(nodeid uint64, fh uint64) (f File
m
=
mount
p
=
path
}
if
f
==
nil
{
node
.
OpenFilesMutex
.
Lock
()
defer
node
.
OpenFilesMutex
.
Unlock
()
if
len
(
node
.
OpenFiles
)
>
0
{
f
=
node
.
OpenFiles
[
0
]
.
file
}
}
return
}
...
...
fuse/pathops.go
View file @
0ebbc3a5
...
...
@@ -98,9 +98,18 @@ func (me *FileSystemConnector) Forget(h *InHeader, input *ForgetIn) {
}
func
(
me
*
FileSystemConnector
)
GetAttr
(
header
*
InHeader
,
input
*
GetAttrIn
)
(
out
*
AttrOut
,
code
Status
)
{
fh
:=
uint64
(
0
)
if
input
.
Flags
&
FUSE_GETATTR_FH
!=
0
{
opened
:=
me
.
getOpenedFile
(
input
.
Fh
)
fi
,
err
:=
opened
.
file
.
GetAttr
()
fh
=
input
.
Fh
}
f
,
mount
,
fullPath
,
node
:=
me
.
getOpenFileData
(
header
.
NodeId
,
fh
)
if
mount
==
nil
&&
f
==
nil
{
return
nil
,
ENOENT
}
if
f
!=
nil
{
fi
,
err
:=
f
.
GetAttr
()
if
err
!=
OK
&&
err
!=
ENOSYS
{
return
nil
,
err
}
...
...
@@ -109,13 +118,12 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out
out
=
&
AttrOut
{}
CopyFileInfo
(
fi
,
&
out
.
Attr
)
out
.
Attr
.
Ino
=
header
.
NodeId
SplitNs
(
opened
.
fileSystemM
ount
.
options
.
AttrTimeout
,
&
out
.
AttrValid
,
&
out
.
AttrValidNsec
)
SplitNs
(
node
.
m
ount
.
options
.
AttrTimeout
,
&
out
.
AttrValid
,
&
out
.
AttrValidNsec
)
return
out
,
OK
}
}
fullPath
,
mount
,
_
:=
me
.
GetPath
(
header
.
NodeId
)
if
mount
==
nil
{
return
nil
,
ENOENT
}
...
...
@@ -192,7 +200,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
getAttrIn
.
Flags
|=
FUSE_GETATTR_FH
}
f
,
mount
,
fullPath
:=
me
.
getOpenFileData
(
header
.
NodeId
,
fh
)
f
,
mount
,
fullPath
,
_
:=
me
.
getOpenFileData
(
header
.
NodeId
,
fh
)
if
mount
==
nil
{
return
nil
,
ENOENT
}
...
...
unionfs/unionfs_test.go
View file @
0ebbc3a5
...
...
@@ -807,3 +807,23 @@ func TestDisappearing(t *testing.T) {
t
.
Fatal
(
"write should succeed"
,
err
)
}
}
func
TestDeletedGetAttr
(
t
*
testing
.
T
)
{
t
.
Log
(
"TestDeletedGetAttr"
)
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blabla"
),
0644
)
CheckSuccess
(
err
)
f
,
err
:=
os
.
Open
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
defer
f
.
Close
()
err
=
os
.
Remove
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
if
fi
,
err
:=
f
.
Stat
();
err
!=
nil
||
!
fi
.
IsRegular
()
{
t
.
Fatalf
(
"stat returned error or non-file: %v %v"
,
err
,
fi
)
}
}
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