From adcde1988e48e17ec03e031031d5d1dd3f498852 Mon Sep 17 00:00:00 2001 From: Florian Weingarten Date: Wed, 29 Apr 2015 03:53:49 +0000 Subject: [PATCH] uint64(stat.Rdev) works on both platforms --- node.go | 4 ++-- node_darwin.go | 21 ++++++--------------- node_linux.go | 14 +++++--------- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/node.go b/node.go index 249edbb4a..45a6a9be0 100644 --- a/node.go +++ b/node.go @@ -373,9 +373,9 @@ func (node *Node) fillExtra(path string, fi os.FileInfo) error { case "symlink": node.LinkTarget, err = os.Readlink(path) case "dev": - node.fillDevice(stat) + node.Device = uint64(stat.Rdev) case "chardev": - node.fillDevice(stat) + node.Device = uint64(stat.Rdev) case "fifo": case "socket": default: diff --git a/node_darwin.go b/node_darwin.go index 183f6201d..1d4a22927 100644 --- a/node_darwin.go +++ b/node_darwin.go @@ -1,29 +1,15 @@ package restic import ( - "fmt" "os" - "os/user" - "strconv" "syscall" "time" - - "github.com/restic/restic/debug" ) func (node *Node) OpenForReading() (*os.File, error) { return os.Open(node.path) } -func (node *Node) fillTimes(stat *syscall.Stat_t) { - node.ChangeTime = time.Unix(stat.Ctimespec.Unix()) - node.AccessTime = time.Unix(stat.Atimespec.Unix()) -} - -func (node *Node) fillDevice(stat *syscall.Stat_t) { - node.Device = uint64(stat.Rdev) -} - func (node *Node) createDevAt(path string) error { return syscall.Mknod(path, syscall.S_IFBLK|0600, int(node.Device)) } @@ -36,6 +22,11 @@ func (node *Node) createFifoAt(path string) error { return syscall.Mkfifo(path, 0600) } -func changeTime(stat *syscall.Stat_t) time.Unix { +func changeTime(stat *syscall.Stat_t) time.Time { return time.Unix(stat.Ctimespec.Unix()) } + +func (node *Node) fillTimes(stat *syscall.Stat_t) { + node.ChangeTime = time.Unix(stat.Ctimespec.Unix()) + node.AccessTime = time.Unix(stat.Atimespec.Unix()) +} diff --git a/node_linux.go b/node_linux.go index c2b776be1..0be72c24b 100644 --- a/node_linux.go +++ b/node_linux.go @@ -14,15 +14,6 @@ func (node *Node) OpenForReading() (*os.File, error) { return file, err } -func (node *Node) fillTimes(stat *syscall.Stat_t) { - node.ChangeTime = time.Unix(stat.Ctim.Unix()) - node.AccessTime = time.Unix(stat.Atim.Unix()) -} - -func (node *Node) fillDevice(stat *syscall.Stat_t) { - node.Device = stat.Rdev -} - func (node *Node) createDevAt(path string) error { return syscall.Mknod(path, syscall.S_IFBLK|0600, int(node.Device)) } @@ -35,6 +26,11 @@ func (node *Node) createFifoAt(path string) error { return syscall.Mkfifo(path, 0600) } +func (node *Node) fillTimes(stat *syscall.Stat_t) { + node.ChangeTime = time.Unix(stat.Ctim.Unix()) + node.AccessTime = time.Unix(stat.Atim.Unix()) +} + func changeTime(stat *syscall.Stat_t) time.Time { return time.Unix(stat.Ctim.Unix()) }