Fixed inode.go.
parent
9c33490a6c
commit
eecd0fb964
|
@ -22,19 +22,12 @@ import (
|
||||||
|
|
||||||
"github.com/jacobsa/fuse/fuseops"
|
"github.com/jacobsa/fuse/fuseops"
|
||||||
"github.com/jacobsa/fuse/fuseutil"
|
"github.com/jacobsa/fuse/fuseutil"
|
||||||
"github.com/jacobsa/timeutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Common attributes for files and directories.
|
// Common attributes for files and directories.
|
||||||
//
|
//
|
||||||
// External synchronization is required.
|
// External synchronization is required.
|
||||||
type inode struct {
|
type inode struct {
|
||||||
/////////////////////////
|
|
||||||
// Dependencies
|
|
||||||
/////////////////////////
|
|
||||||
|
|
||||||
clock timeutil.Clock
|
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Mutable state
|
// Mutable state
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
|
@ -79,16 +72,14 @@ type inode struct {
|
||||||
// Create a new inode with the supplied attributes, which need not contain
|
// Create a new inode with the supplied attributes, which need not contain
|
||||||
// time-related information (the inode object will take care of that).
|
// time-related information (the inode object will take care of that).
|
||||||
func newInode(
|
func newInode(
|
||||||
clock timeutil.Clock,
|
|
||||||
attrs fuseops.InodeAttributes) (in *inode) {
|
attrs fuseops.InodeAttributes) (in *inode) {
|
||||||
// Update time info.
|
// Update time info.
|
||||||
now := clock.Now()
|
now := time.Now()
|
||||||
attrs.Mtime = now
|
attrs.Mtime = now
|
||||||
attrs.Crtime = now
|
attrs.Crtime = now
|
||||||
|
|
||||||
// Create the object.
|
// Create the object.
|
||||||
in = &inode{
|
in = &inode{
|
||||||
clock: clock,
|
|
||||||
attrs: attrs,
|
attrs: attrs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +217,7 @@ func (in *inode) AddChild(
|
||||||
var index int
|
var index int
|
||||||
|
|
||||||
// Update the modification time.
|
// Update the modification time.
|
||||||
in.attrs.Mtime = in.clock.Now()
|
in.attrs.Mtime = time.Now()
|
||||||
|
|
||||||
// No matter where we place the entry, make sure it has the correct Offset
|
// No matter where we place the entry, make sure it has the correct Offset
|
||||||
// field.
|
// field.
|
||||||
|
@ -260,7 +251,7 @@ func (in *inode) AddChild(
|
||||||
// REQUIRES: An entry for the given name exists.
|
// REQUIRES: An entry for the given name exists.
|
||||||
func (in *inode) RemoveChild(name string) {
|
func (in *inode) RemoveChild(name string) {
|
||||||
// Update the modification time.
|
// Update the modification time.
|
||||||
in.attrs.Mtime = in.clock.Now()
|
in.attrs.Mtime = time.Now()
|
||||||
|
|
||||||
// Find the entry.
|
// Find the entry.
|
||||||
i, ok := in.findChild(name)
|
i, ok := in.findChild(name)
|
||||||
|
@ -334,7 +325,7 @@ func (in *inode) WriteAt(p []byte, off int64) (n int, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the modification time.
|
// Update the modification time.
|
||||||
in.attrs.Mtime = in.clock.Now()
|
in.attrs.Mtime = time.Now()
|
||||||
|
|
||||||
// Ensure that the contents slice is long enough.
|
// Ensure that the contents slice is long enough.
|
||||||
newLen := int(off) + len(p)
|
newLen := int(off) + len(p)
|
||||||
|
@ -361,7 +352,7 @@ func (in *inode) SetAttributes(
|
||||||
mode *os.FileMode,
|
mode *os.FileMode,
|
||||||
mtime *time.Time) {
|
mtime *time.Time) {
|
||||||
// Update the modification time.
|
// Update the modification time.
|
||||||
in.attrs.Mtime = in.clock.Now()
|
in.attrs.Mtime = time.Now()
|
||||||
|
|
||||||
// Truncate?
|
// Truncate?
|
||||||
if size != nil {
|
if size != nil {
|
||||||
|
|
Loading…
Reference in New Issue