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
0cc2370b
Commit
0cc2370b
authored
Dec 29, 2010
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set timeouts on Lookups in pathfilesystem.go.
parent
65a00e12
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
7 deletions
+42
-7
examplelib/dummyfuse.go
examplelib/dummyfuse.go
+4
-0
examplelib/passthrough.go
examplelib/passthrough.go
+7
-0
fuse/misc.go
fuse/misc.go
+6
-0
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+22
-6
fuse/types.go
fuse/types.go
+3
-1
No files found.
examplelib/dummyfuse.go
View file @
0cc2370b
...
...
@@ -198,3 +198,7 @@ func (self *DummyPathFuse) Create(name string, flags uint32, mode uint32) (file
func
(
self
*
DummyPathFuse
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
self
*
DummyPathFuse
)
SetOptions
(
*
fuse
.
PathFileSystemConnectorOptions
)
{
}
examplelib/passthrough.go
View file @
0cc2370b
...
...
@@ -150,6 +150,12 @@ func (self *PassThroughFuse) Create(path string, flags uint32, mode uint32) (fus
return
&
PassThroughFile
{
file
:
f
},
fuse
.
OsErrorToFuseError
(
err
)
}
func
(
self
*
PassThroughFuse
)
SetOptions
(
options
*
fuse
.
PathFileSystemConnectorOptions
)
{
options
.
NegativeTimeout
=
100.0
options
.
AttrTimeout
=
100.0
options
.
EntryTimeout
=
100.0
}
////////////////////////////////////////////////////////////////
type
PassThroughFile
struct
{
...
...
@@ -251,3 +257,4 @@ func (self *PassThroughDir) ReleaseDir() {
func
(
self
*
PassThroughDir
)
FsyncDir
(
input
*
fuse
.
FsyncIn
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
fuse/misc.go
View file @
0cc2370b
...
...
@@ -10,6 +10,7 @@ import (
"time"
"fmt"
"path"
"math"
)
// Make a temporary directory securely.
...
...
@@ -206,3 +207,8 @@ func parseLittleEndian(b *bytes.Buffer, data interface{}) bool {
}
panic
(
fmt
.
Sprintf
(
"Cannot parse %v"
,
data
))
}
func
SplitNs
(
time
float64
,
secs
*
uint64
,
nsecs
*
uint32
)
{
*
nsecs
=
uint32
(
1e9
*
(
time
-
math
.
Trunc
(
time
)))
*
secs
=
uint64
(
math
.
Trunc
(
time
))
}
fuse/pathfilesystem.go
View file @
0cc2370b
...
...
@@ -47,6 +47,11 @@ func (self *inodeData) GetPath() string {
return
fullPath
}
type
PathFileSystemConnectorOptions
struct
{
EntryTimeout
float64
AttrTimeout
float64
NegativeTimeout
float64
}
type
PathFileSystemConnector
struct
{
fileSystem
PathFilesystem
...
...
@@ -67,6 +72,8 @@ type PathFileSystemConnector struct {
inodePathMap
map
[
string
]
*
inodeData
inodePathMapByInode
map
[
uint64
]
*
inodeData
nextFreeInode
uint64
options
PathFileSystemConnectorOptions
}
// Must be called with lock held.
...
...
@@ -204,7 +211,6 @@ func NewPathFileSystemConnector(fs PathFilesystem) (out *PathFileSystemConnector
out
=
new
(
PathFileSystemConnector
)
out
.
inodePathMap
=
make
(
map
[
string
]
*
inodeData
)
out
.
inodePathMapByInode
=
make
(
map
[
uint64
]
*
inodeData
)
out
.
fileSystem
=
fs
rootData
:=
new
(
inodeData
)
...
...
@@ -214,6 +220,12 @@ func NewPathFileSystemConnector(fs PathFilesystem) (out *PathFileSystemConnector
out
.
inodePathMapByInode
[
FUSE_ROOT_ID
]
=
rootData
out
.
nextFreeInode
=
FUSE_ROOT_ID
+
1
out
.
options
.
NegativeTimeout
=
0.0
out
.
options
.
AttrTimeout
=
1.0
out
.
options
.
EntryTimeout
=
1.0
fs
.
SetOptions
(
&
out
.
options
)
return
out
}
...
...
@@ -240,8 +252,14 @@ func (self *PathFileSystemConnector) Lookup(header *InHeader, name string) (out
fullPath
:=
path
.
Join
(
parent
.
GetPath
(),
name
)
attr
,
err
:=
self
.
fileSystem
.
GetAttr
(
fullPath
)
if
err
==
ENOENT
&&
self
.
options
.
NegativeTimeout
>
0.0
{
out
=
new
(
EntryOut
)
out
.
NodeId
=
0
SplitNs
(
self
.
options
.
NegativeTimeout
,
&
out
.
EntryValid
,
&
out
.
EntryValidNsec
)
return
out
,
OK
}
if
err
!=
OK
{
// TODO - set a EntryValid timeout on ENOENT.
return
nil
,
err
}
...
...
@@ -250,11 +268,9 @@ func (self *PathFileSystemConnector) Lookup(header *InHeader, name string) (out
out
=
new
(
EntryOut
)
out
.
NodeId
=
data
.
NodeId
out
.
Generation
=
1
// where to get the generation?
out
.
EntryValid
=
0
out
.
AttrValid
=
0
out
.
EntryValidNsec
=
0
out
.
AttrValidNsec
=
0
SplitNs
(
self
.
options
.
EntryTimeout
,
&
out
.
EntryValid
,
&
out
.
EntryValidNsec
)
SplitNs
(
self
.
options
.
AttrTimeout
,
&
out
.
AttrValid
,
&
out
.
AttrValidNsec
)
out
.
Attr
=
*
attr
return
out
,
OK
...
...
fuse/types.go
View file @
0cc2370b
...
...
@@ -580,5 +580,7 @@ type PathFilesystem interface {
Create
(
name
string
,
flags
uint32
,
mode
uint32
)
(
file
RawFuseFile
,
code
Status
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
// unimplemented: poll, ioctl, bmap.
// unimplemented: poll, ioctl, bmap.
SetOptions
(
*
PathFileSystemConnectorOptions
)
}
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