Add node to build on freebsd.

Also note that inode is 32 bit in go freebsd stat struct. Assumed
to be 64bit in restic.
This commit is contained in:
Chris Howey 2015-05-05 18:06:36 -05:00
parent 92de007900
commit a1c8dac561
2 changed files with 26 additions and 2 deletions

View file

@ -341,7 +341,7 @@ func (node *Node) isNewer(path string, fi os.FileInfo) bool {
if node.ModTime != fi.ModTime() ||
node.ChangeTime != changeTime(extendedStat) ||
node.Inode != inode ||
node.Inode != uint64(inode) ||
node.Size != size {
debug.Log("node.isNewer", "node %v is newer: timestamp, size or inode changed", path)
return true
@ -396,7 +396,7 @@ func (node *Node) fillExtra(path string, fi os.FileInfo) error {
return nil
}
node.Inode = stat.Ino
node.Inode = uint64(stat.Ino)
node.fillTimes(stat)

24
node_freebsd.go Normal file
View file

@ -0,0 +1,24 @@
package restic
import (
"os"
"syscall"
"time"
)
func (node *Node) OpenForReading() (*os.File, error) {
file, err := os.OpenFile(node.path, os.O_RDONLY, 0)
if os.IsPermission(err) {
return os.OpenFile(node.path, os.O_RDONLY, 0)
}
return file, err
}
func (node *Node) fillTimes(stat *syscall.Stat_t) {
node.ChangeTime = time.Unix(stat.Ctimespec.Unix())
node.AccessTime = time.Unix(stat.Atimespec.Unix())
}
func changeTime(stat *syscall.Stat_t) time.Time {
return time.Unix(stat.Ctimespec.Unix())
}