Commit 03c3c9b9 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

UnionFs: implement Utimens.

parent 53e30f5e
......@@ -64,6 +64,7 @@ const (
FUSE_NOTIFY_CODE_MAX = 4
)
// Ugh - we should fold ns and secs together here.
type Attr struct {
Ino uint64
Size uint64
......
......@@ -342,6 +342,28 @@ func (me *UnionFs) Truncate(path string, offset uint64) (code fuse.Status) {
return me.fileSystems[0].Truncate(path, offset)
}
func (me *UnionFs) Utimens(name string, atime uint64, ctime uint64) (code fuse.Status) {
name = stripSlash(name)
r := me.getBranch(name)
code = r.code
if code == fuse.OK && r.branch > 0 {
code = me.Promote(name, r)
r.branch = 0
}
if code == fuse.OK {
code = me.fileSystems[0].Utimens(name, atime, ctime)
}
if code == fuse.OK {
r.attr.Atime = uint64(atime / 1e9)
r.attr.Atimensec = uint32(atime % 1e9)
r.attr.Ctime = uint64(ctime / 1e9)
r.attr.Ctimensec = uint32(ctime % 1e9)
me.branchCache.Set(name, r)
}
return code
}
func (me *UnionFs) Chmod(name string, mode uint32) (code fuse.Status) {
name = stripSlash(name)
r := me.getBranch(name)
......
......@@ -133,6 +133,23 @@ func TestSymlink(t *testing.T) {
}
}
func TestChtimes(t *testing.T) {
wd, state := setup(t)
defer state.Unmount()
writeToFile(wd+"/ro/file", "a")
err := os.Chtimes(wd + "/ro/file", 42e9, 43e9)
CheckSuccess(err)
err = os.Chtimes(wd + "/mount/file", 82e9, 83e9)
CheckSuccess(err)
fi, err := os.Lstat(wd +"/mount/file")
if fi.Atime_ns != 82e9 || fi.Ctime_ns != 83e9 {
t.Error("Incorrect timestamp", fi)
}
}
func TestChmod(t *testing.T) {
wd, state := setup(t)
defer state.Unmount()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment