2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-26 06:46:34 +00:00

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":
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:

View File

@ -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())
}

View File

@ -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())
}