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
2f81df59
Commit
2f81df59
authored
May 08, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update mtime field in the cache for Open() and Truncate() calls.
This should fix Emacs save problems more robustly.
parent
7b4ae829
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
7 deletions
+39
-7
unionfs/unionfs.go
unionfs/unionfs.go
+9
-7
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+30
-0
No files found.
unionfs/unionfs.go
View file @
2f81df59
...
...
@@ -13,6 +13,7 @@ import (
"path/filepath"
"sync"
"strings"
"time"
)
// TODO(hanwen): is md5 sufficiently fast?
...
...
@@ -346,6 +347,7 @@ func (me *UnionFs) Truncate(path string, offset uint64) (code fuse.Status) {
}
if
code
.
Ok
()
{
r
.
attr
.
Size
=
int64
(
offset
)
r
.
attr
.
Mtime_ns
=
time
.
Nanoseconds
()
me
.
branchCache
.
Set
(
path
,
r
)
}
return
code
...
...
@@ -688,22 +690,22 @@ func (me *UnionFs) Rename(src string, dst string) (code fuse.Status) {
func
(
me
*
UnionFs
)
Open
(
name
string
,
flags
uint32
)
(
fuseFile
fuse
.
File
,
status
fuse
.
Status
)
{
r
:=
me
.
getBranch
(
name
)
branch
:=
r
.
branch
if
flags
&
fuse
.
O_ANYWRITE
!=
0
&&
r
.
branch
>
0
{
code
:=
me
.
Promote
(
name
,
r
)
if
code
!=
fuse
.
OK
{
return
nil
,
code
}
branch
=
0
r
.
branch
=
0
r
.
attr
.
Mtime_ns
=
time
.
Nanoseconds
()
me
.
branchCache
.
Set
(
name
,
r
)
}
return
me
.
fileSystems
[
branch
]
.
Open
(
name
,
uint32
(
flags
))
return
me
.
fileSystems
[
r
.
branch
]
.
Open
(
name
,
uint32
(
flags
))
}
func
(
me
*
UnionFs
)
Release
(
name
string
)
{
r
:=
me
.
getBranch
(
name
)
fresh
:=
me
.
getBranchAttrNoCache
(
name
)
r
.
attr
.
Size
=
fresh
.
attr
.
Size
me
.
branchCache
.
Set
(
name
,
r
)
// Refresh timestamps and size field.
me
.
branchCache
.
DropEntry
(
name
)
me
.
getBranch
(
name
)
}
func
(
me
*
UnionFs
)
Roots
()
(
result
[]
string
)
{
...
...
unionfs/unionfs_test.go
View file @
2f81df59
...
...
@@ -416,3 +416,33 @@ func TestCopyChmod(t *testing.T) {
t
.
Errorf
(
"uncached attr error %o"
,
fi
.
Mode
)
}
}
func
abs
(
dt
int64
)
int64
{
if
dt
>=
0
{
return
dt
}
return
-
dt
}
func
TestTruncateTimestamp
(
t
*
testing
.
T
)
{
t
.
Log
(
"TestTruncateTimestamp"
)
wd
,
state
:=
setupUfs
(
t
)
defer
state
.
Unmount
()
contents
:=
"hello"
fn
:=
wd
+
"/mount/y"
err
:=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
contents
),
0644
)
CheckSuccess
(
err
)
time
.
Sleep
(
0.2e9
)
truncTs
:=
time
.
Nanoseconds
()
err
=
os
.
Truncate
(
fn
,
3
)
CheckSuccess
(
err
)
fi
,
err
:=
os
.
Lstat
(
fn
)
CheckSuccess
(
err
)
if
abs
(
truncTs
-
fi
.
Mtime_ns
)
>
0.1e9
{
t
.
Error
(
"timestamp drift"
,
truncTs
,
fi
.
Mtime_ns
)
}
}
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