mirror of
https://github.com/restic/restic.git
synced 2025-01-03 13:45:20 +00:00
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:
parent
92de007900
commit
a1c8dac561
2 changed files with 26 additions and 2 deletions
4
node.go
4
node.go
|
@ -341,7 +341,7 @@ func (node *Node) isNewer(path string, fi os.FileInfo) bool {
|
||||||
|
|
||||||
if node.ModTime != fi.ModTime() ||
|
if node.ModTime != fi.ModTime() ||
|
||||||
node.ChangeTime != changeTime(extendedStat) ||
|
node.ChangeTime != changeTime(extendedStat) ||
|
||||||
node.Inode != inode ||
|
node.Inode != uint64(inode) ||
|
||||||
node.Size != size {
|
node.Size != size {
|
||||||
debug.Log("node.isNewer", "node %v is newer: timestamp, size or inode changed", path)
|
debug.Log("node.isNewer", "node %v is newer: timestamp, size or inode changed", path)
|
||||||
return true
|
return true
|
||||||
|
@ -396,7 +396,7 @@ func (node *Node) fillExtra(path string, fi os.FileInfo) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
node.Inode = stat.Ino
|
node.Inode = uint64(stat.Ino)
|
||||||
|
|
||||||
node.fillTimes(stat)
|
node.fillTimes(stat)
|
||||||
|
|
||||||
|
|
24
node_freebsd.go
Normal file
24
node_freebsd.go
Normal 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())
|
||||||
|
}
|
Loading…
Reference in a new issue