Support changing mtime.
parent
1698f1604a
commit
a7d2944d2e
|
@ -281,7 +281,7 @@ func (fs *memFS) SetInodeAttributes(
|
||||||
defer inode.mu.Unlock()
|
defer inode.mu.Unlock()
|
||||||
|
|
||||||
// Handle the request.
|
// Handle the request.
|
||||||
inode.SetAttributes(req.Size, req.Mode)
|
inode.SetAttributes(req.Size, req.Mode, req.Mtime)
|
||||||
|
|
||||||
// Fill in the response.
|
// Fill in the response.
|
||||||
resp.Attributes = inode.attributes
|
resp.Attributes = inode.attributes
|
||||||
|
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/jacobsa/fuse"
|
"github.com/jacobsa/fuse"
|
||||||
"github.com/jacobsa/fuse/fuseutil"
|
"github.com/jacobsa/fuse/fuseutil"
|
||||||
|
@ -373,7 +374,10 @@ func (inode *inode) WriteAt(p []byte, off int64) (n int, err error) {
|
||||||
// Update attributes from non-nil parameters.
|
// Update attributes from non-nil parameters.
|
||||||
//
|
//
|
||||||
// EXCLUSIVE_LOCKS_REQUIRED(inode.mu)
|
// EXCLUSIVE_LOCKS_REQUIRED(inode.mu)
|
||||||
func (inode *inode) SetAttributes(size *uint64, mode *os.FileMode) {
|
func (inode *inode) SetAttributes(
|
||||||
|
size *uint64,
|
||||||
|
mode *os.FileMode,
|
||||||
|
mtime *time.Time) {
|
||||||
// Update the modification time.
|
// Update the modification time.
|
||||||
inode.attributes.Mtime = inode.clock.Now()
|
inode.attributes.Mtime = inode.clock.Now()
|
||||||
|
|
||||||
|
@ -397,4 +401,9 @@ func (inode *inode) SetAttributes(size *uint64, mode *os.FileMode) {
|
||||||
if mode != nil {
|
if mode != nil {
|
||||||
inode.attributes.Mode = *mode
|
inode.attributes.Mode = *mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change mtime?
|
||||||
|
if mtime != nil {
|
||||||
|
inode.attributes.Mtime = *mtime
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -968,7 +968,7 @@ func (t *MemFSTest) Chtimes() {
|
||||||
AssertEq(nil, err)
|
AssertEq(nil, err)
|
||||||
|
|
||||||
// Chtimes it.
|
// Chtimes it.
|
||||||
expectedMtime := time.Now().Add(123 * time.Millisecond)
|
expectedMtime := time.Now().Add(123 * time.Second).Round(time.Second)
|
||||||
err = os.Chtimes(fileName, time.Time{}, expectedMtime)
|
err = os.Chtimes(fileName, time.Time{}, expectedMtime)
|
||||||
AssertEq(nil, err)
|
AssertEq(nil, err)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue