Better stat functionality
This commit is contained in:
parent
148d9879d5
commit
eed33efdc8
2
dir.go
2
dir.go
@ -47,7 +47,7 @@ func newVersionedDir(node *versionedNode, inode uint64) *versionedDir {
|
|||||||
func (this versionedDir) Attr(attr *fuse.Attr) {
|
func (this versionedDir) Attr(attr *fuse.Attr) {
|
||||||
log.Printf("versionedDir::Attr: %s", this.node)
|
log.Printf("versionedDir::Attr: %s", this.node)
|
||||||
|
|
||||||
attr.Mode = this.node.info.Mode()
|
this.node.attr(attr)
|
||||||
attr.Inode = this.inode
|
attr.Inode = this.inode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
file.go
3
file.go
@ -41,9 +41,8 @@ func newVersionedFile(node *versionedNode, inode uint64) *versionedFile {
|
|||||||
func (this versionedFile) Attr(attr *fuse.Attr) {
|
func (this versionedFile) Attr(attr *fuse.Attr) {
|
||||||
log.Printf("versionedFile::Attr: %s", this.node)
|
log.Printf("versionedFile::Attr: %s", this.node)
|
||||||
|
|
||||||
attr.Mode = this.node.info.Mode()
|
this.node.attr(attr)
|
||||||
attr.Inode = this.inode
|
attr.Inode = this.inode
|
||||||
attr.Size = uint64(this.node.info.Size())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this versionedFile) ReadAll(ctx context.Context) ([]byte, error) {
|
func (this versionedFile) ReadAll(ctx context.Context) ([]byte, error) {
|
||||||
|
18
node.go
18
node.go
@ -23,8 +23,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bazil.org/fuse"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type versionedNode struct {
|
type versionedNode struct {
|
||||||
@ -39,6 +42,21 @@ func (this *versionedNode) rebasedPath() string {
|
|||||||
return this.ver.rebasePath(this.path)
|
return this.ver.rebasePath(this.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *versionedNode) attr(attr *fuse.Attr) {
|
||||||
|
stat := this.info.Sys().(*syscall.Stat_t)
|
||||||
|
|
||||||
|
attr.Size = uint64(this.info.Size())
|
||||||
|
attr.Blocks = uint64(stat.Blocks)
|
||||||
|
attr.Atime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
|
||||||
|
attr.Mtime = this.info.ModTime()
|
||||||
|
attr.Ctime = time.Unix(int64(stat.Ctim.Sec), int64(stat.Ctim.Nsec))
|
||||||
|
attr.Mode = this.info.Mode()
|
||||||
|
attr.Nlink = uint32(stat.Nlink)
|
||||||
|
attr.Uid = stat.Uid
|
||||||
|
attr.Gid = stat.Gid
|
||||||
|
attr.Rdev = uint32(stat.Rdev)
|
||||||
|
}
|
||||||
|
|
||||||
func (this *versionedNode) String() string {
|
func (this *versionedNode) String() string {
|
||||||
return fmt.Sprintf("%s (%s)", this.path, this.rebasedPath())
|
return fmt.Sprintf("%s (%s)", this.path, this.rebasedPath())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user