uint64(stat.Rdev) works on both platforms

This commit is contained in:
Florian Weingarten 2015-04-29 03:53:49 +00:00
parent 6ba11d8fb7
commit adcde1988e
3 changed files with 13 additions and 26 deletions

View File

@ -373,9 +373,9 @@ func (node *Node) fillExtra(path string, fi os.FileInfo) error {
case "symlink": case "symlink":
node.LinkTarget, err = os.Readlink(path) node.LinkTarget, err = os.Readlink(path)
case "dev": case "dev":
node.fillDevice(stat) node.Device = uint64(stat.Rdev)
case "chardev": case "chardev":
node.fillDevice(stat) node.Device = uint64(stat.Rdev)
case "fifo": case "fifo":
case "socket": case "socket":
default: default:

View File

@ -1,29 +1,15 @@
package restic package restic
import ( import (
"fmt"
"os" "os"
"os/user"
"strconv"
"syscall" "syscall"
"time" "time"
"github.com/restic/restic/debug"
) )
func (node *Node) OpenForReading() (*os.File, error) { func (node *Node) OpenForReading() (*os.File, error) {
return os.Open(node.path) 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 { func (node *Node) createDevAt(path string) error {
return syscall.Mknod(path, syscall.S_IFBLK|0600, int(node.Device)) 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) 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()) 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())
}

View File

@ -14,15 +14,6 @@ func (node *Node) OpenForReading() (*os.File, error) {
return file, err 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 { func (node *Node) createDevAt(path string) error {
return syscall.Mknod(path, syscall.S_IFBLK|0600, int(node.Device)) 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) 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 { func changeTime(stat *syscall.Stat_t) time.Time {
return time.Unix(stat.Ctim.Unix()) return time.Unix(stat.Ctim.Unix())
} }