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
fa9a8c95
Commit
fa9a8c95
authored
May 16, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle .drop_cache in Truncate and GetXAttr too.
Add test.
parent
dc255238
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
3 deletions
+52
-3
unionfs/unionfs.go
unionfs/unionfs.go
+10
-2
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+42
-1
No files found.
unionfs/unionfs.go
View file @
fa9a8c95
...
...
@@ -6,11 +6,11 @@ import (
"github.com/hanwen/go-fuse/fuse"
"log"
"os"
"syscall"
"path"
"path/filepath"
"sync"
"strings"
"sync"
"syscall"
"time"
)
...
...
@@ -320,6 +320,10 @@ func (me *UnionFs) Symlink(pointedTo string, linkName string) (code fuse.Status)
}
func
(
me
*
UnionFs
)
Truncate
(
path
string
,
offset
uint64
)
(
code
fuse
.
Status
)
{
if
path
==
_DROP_CACHE
{
return
fuse
.
OK
}
r
:=
me
.
getBranch
(
path
)
if
r
.
branch
>
0
{
code
=
me
.
Promote
(
path
,
r
)
...
...
@@ -549,6 +553,10 @@ func (me *UnionFs) GetAttr(name string) (a *os.FileInfo, s fuse.Status) {
}
func
(
me
*
UnionFs
)
GetXAttr
(
name
string
,
attr
string
)
([]
byte
,
fuse
.
Status
)
{
if
name
==
_DROP_CACHE
{
return
nil
,
syscall
.
ENODATA
}
r
:=
me
.
getBranch
(
name
)
if
r
.
branch
>=
0
{
return
me
.
fileSystems
[
r
.
branch
]
.
GetXAttr
(
name
,
attr
)
...
...
unionfs/unionfs_test.go
View file @
fa9a8c95
...
...
@@ -456,7 +456,7 @@ func TestRemoveAll(t *testing.T) {
err
:=
os
.
Mkdir
(
wd
+
"/ro/dir"
,
0755
)
CheckSuccess
(
err
)
contents
:=
"hello"
fn
:=
wd
+
"/ro/dir/y"
err
=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
contents
),
0644
)
...
...
@@ -468,3 +468,44 @@ func TestRemoveAll(t *testing.T) {
}
}
func
Readdirnames
(
dir
string
)
([]
string
,
os
.
Error
)
{
f
,
err
:=
os
.
Open
(
dir
)
if
err
!=
nil
{
return
nil
,
err
}
defer
f
.
Close
()
return
f
.
Readdirnames
(
-
1
)
}
func
TestDropCache
(
t
*
testing
.
T
)
{
t
.
Log
(
"TestDropCache"
)
wd
,
clean
:=
setupUfs
(
t
)
defer
clean
()
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"bla"
),
0644
)
CheckSuccess
(
err
)
_
,
err
=
os
.
Lstat
(
wd
+
"/mount/.drop_cache"
)
CheckSuccess
(
err
)
names
,
err
:=
Readdirnames
(
wd
+
"/mount"
)
CheckSuccess
(
err
)
if
len
(
names
)
!=
1
||
names
[
0
]
!=
"file"
{
t
.
Fatal
(
"unexpected names"
,
names
)
}
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/file2"
,
[]
byte
(
"blabla"
),
0644
)
names2
,
err
:=
Readdirnames
(
wd
+
"/mount"
)
CheckSuccess
(
err
)
if
len
(
names2
)
!=
len
(
names
)
{
t
.
Fatal
(
"mismatch"
,
names2
)
}
err
=
ioutil
.
WriteFile
(
wd
+
"/mount/.drop_cache"
,
[]
byte
(
"does not matter"
),
0644
)
CheckSuccess
(
err
)
names2
,
err
=
Readdirnames
(
wd
+
"/mount"
)
if
len
(
names2
)
!=
2
{
t
.
Fatal
(
"mismatch 2"
,
names2
)
}
}
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