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
c13cb759
Commit
c13cb759
authored
May 09, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GetXAttr() to CachingFileSystem.
parent
45317e97
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
1 deletion
+28
-1
unionfs/cachingfs.go
unionfs/cachingfs.go
+28
-1
No files found.
unionfs/cachingfs.go
View file @
c13cb759
...
...
@@ -4,15 +4,23 @@ import (
"fmt"
"github.com/hanwen/go-fuse/fuse"
"os"
"strings"
)
var
_
=
fmt
.
Println
const
_XATTRSEP
=
"@XATTR@"
type
attrResponse
struct
{
*
os
.
FileInfo
fuse
.
Status
}
type
xattrResponse
struct
{
data
[]
byte
fuse
.
Status
}
type
dirResponse
struct
{
entries
[]
fuse
.
DirEntry
fuse
.
Status
...
...
@@ -30,6 +38,7 @@ type CachingFileSystem struct {
attributes
*
TimedCache
dirs
*
TimedCache
links
*
TimedCache
xattr
*
TimedCache
}
func
readDir
(
fs
fuse
.
FileSystem
,
name
string
)
*
dirResponse
{
...
...
@@ -53,7 +62,16 @@ func readDir(fs fuse.FileSystem, name string) *dirResponse {
func
getAttr
(
fs
fuse
.
FileSystem
,
name
string
)
*
attrResponse
{
a
,
code
:=
fs
.
GetAttr
(
name
)
return
&
attrResponse
{
FileInfo
:
a
,
FileInfo
:
a
,
Status
:
code
,
}
}
func
getXAttr
(
fs
fuse
.
FileSystem
,
nameAttr
string
)
*
xattrResponse
{
ns
:=
strings
.
Split
(
nameAttr
,
_XATTRSEP
,
2
)
a
,
code
:=
fs
.
GetXAttr
(
ns
[
0
],
ns
[
1
])
return
&
xattrResponse
{
data
:
a
,
Status
:
code
,
}
}
...
...
@@ -72,6 +90,9 @@ func NewCachingFileSystem(fs fuse.FileSystem, ttlNs int64) *CachingFileSystem {
c
.
attributes
=
NewTimedCache
(
func
(
n
string
)
interface
{}
{
return
getAttr
(
fs
,
n
)
},
ttlNs
)
c
.
dirs
=
NewTimedCache
(
func
(
n
string
)
interface
{}
{
return
readDir
(
fs
,
n
)
},
ttlNs
)
c
.
links
=
NewTimedCache
(
func
(
n
string
)
interface
{}
{
return
readLink
(
fs
,
n
)
},
ttlNs
)
c
.
xattr
=
NewTimedCache
(
func
(
n
string
)
interface
{}
{
return
getXAttr
(
fs
,
n
)
},
ttlNs
)
return
c
}
...
...
@@ -80,6 +101,12 @@ func (me *CachingFileSystem) GetAttr(name string) (*os.FileInfo, fuse.Status) {
return
r
.
FileInfo
,
r
.
Status
}
func
(
me
*
CachingFileSystem
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
fuse
.
Status
)
{
key
:=
name
+
_XATTRSEP
+
attr
r
:=
me
.
xattr
.
Get
(
key
)
.
(
*
xattrResponse
)
return
r
.
data
,
r
.
Status
}
func
(
me
*
CachingFileSystem
)
Readlink
(
name
string
)
(
string
,
fuse
.
Status
)
{
r
:=
me
.
attributes
.
Get
(
name
)
.
(
*
linkResponse
)
return
r
.
linkContent
,
r
.
Status
...
...
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