From f08014213747cc9ac71d1dec170e416af3d4447e Mon Sep 17 00:00:00 2001 From: Iku Iwasa Date: Sat, 16 Jun 2018 15:48:45 +0900 Subject: [PATCH 1/2] Support NetBSD without fuse --- cmd/restic/cmd_mount.go | 1 + cmd/restic/integration_fuse_test.go | 1 + cmd/restic/integration_helpers_test.go | 2 +- internal/fs/stat_bsd.go | 2 +- internal/fs/stat_unix.go | 2 +- internal/fuse/blob_size_cache.go | 1 + internal/fuse/dir.go | 1 + internal/fuse/file.go | 1 + internal/fuse/file_test.go | 1 + internal/fuse/link.go | 1 + internal/fuse/meta_dir.go | 1 + internal/fuse/other.go | 1 + internal/fuse/root.go | 1 + internal/fuse/snapshots_dir.go | 1 + internal/restic/node_netbsd.go | 27 ++++++++++++++++++++++++++ internal/restic/node_test.go | 4 ++-- internal/restic/node_xattr.go | 1 + 17 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 internal/restic/node_netbsd.go diff --git a/cmd/restic/cmd_mount.go b/cmd/restic/cmd_mount.go index 8e21ce203..3e6382192 100644 --- a/cmd/restic/cmd_mount.go +++ b/cmd/restic/cmd_mount.go @@ -1,3 +1,4 @@ +// +build !netbsd // +build !openbsd // +build !solaris // +build !windows diff --git a/cmd/restic/integration_fuse_test.go b/cmd/restic/integration_fuse_test.go index 45a9d4eb0..57a57ae97 100644 --- a/cmd/restic/integration_fuse_test.go +++ b/cmd/restic/integration_fuse_test.go @@ -1,3 +1,4 @@ +// +build !netbsd // +build !openbsd // +build !solaris // +build !windows diff --git a/cmd/restic/integration_helpers_test.go b/cmd/restic/integration_helpers_test.go index d0450817d..d277184f2 100644 --- a/cmd/restic/integration_helpers_test.go +++ b/cmd/restic/integration_helpers_test.go @@ -66,7 +66,7 @@ func isSymlink(fi os.FileInfo) bool { func sameModTime(fi1, fi2 os.FileInfo) bool { switch runtime.GOOS { - case "darwin", "freebsd", "openbsd": + case "darwin", "freebsd", "openbsd", "netbsd": if isSymlink(fi1) && isSymlink(fi2) { return true } diff --git a/internal/fs/stat_bsd.go b/internal/fs/stat_bsd.go index 97c03bedc..62a258e64 100644 --- a/internal/fs/stat_bsd.go +++ b/internal/fs/stat_bsd.go @@ -1,4 +1,4 @@ -// +build freebsd darwin +// +build freebsd darwin netbsd package fs diff --git a/internal/fs/stat_unix.go b/internal/fs/stat_unix.go index 612898566..56c22f8bc 100644 --- a/internal/fs/stat_unix.go +++ b/internal/fs/stat_unix.go @@ -1,4 +1,4 @@ -// +build !windows,!darwin,!freebsd +// +build !windows,!darwin,!freebsd,!netbsd package fs diff --git a/internal/fuse/blob_size_cache.go b/internal/fuse/blob_size_cache.go index 87b2016a1..47599a820 100644 --- a/internal/fuse/blob_size_cache.go +++ b/internal/fuse/blob_size_cache.go @@ -1,3 +1,4 @@ +// +build !netbsd // +build !openbsd // +build !solaris // +build !windows diff --git a/internal/fuse/dir.go b/internal/fuse/dir.go index 654af21cf..f899a4313 100644 --- a/internal/fuse/dir.go +++ b/internal/fuse/dir.go @@ -1,3 +1,4 @@ +// +build !netbsd // +build !openbsd // +build !solaris // +build !windows diff --git a/internal/fuse/file.go b/internal/fuse/file.go index ff74ec73c..5fefd5e3e 100644 --- a/internal/fuse/file.go +++ b/internal/fuse/file.go @@ -1,3 +1,4 @@ +// +build !netbsd // +build !openbsd // +build !solaris // +build !windows diff --git a/internal/fuse/file_test.go b/internal/fuse/file_test.go index 7a1802f39..2909d6636 100644 --- a/internal/fuse/file_test.go +++ b/internal/fuse/file_test.go @@ -1,3 +1,4 @@ +// +build !netbsd // +build !openbsd // +build !solaris // +build !windows diff --git a/internal/fuse/link.go b/internal/fuse/link.go index 334568904..6772ac5f0 100644 --- a/internal/fuse/link.go +++ b/internal/fuse/link.go @@ -1,3 +1,4 @@ +// +build !netbsd // +build !openbsd // +build !solaris // +build !windows diff --git a/internal/fuse/meta_dir.go b/internal/fuse/meta_dir.go index e34aa77af..3271b3c29 100644 --- a/internal/fuse/meta_dir.go +++ b/internal/fuse/meta_dir.go @@ -1,3 +1,4 @@ +// +build !netbsd // +build !openbsd // +build !solaris // +build !windows diff --git a/internal/fuse/other.go b/internal/fuse/other.go index b0e368d87..b497087e6 100644 --- a/internal/fuse/other.go +++ b/internal/fuse/other.go @@ -1,3 +1,4 @@ +// +build !netbsd // +build !openbsd // +build !solaris // +build !windows diff --git a/internal/fuse/root.go b/internal/fuse/root.go index 27779a241..3ffa8a7ac 100644 --- a/internal/fuse/root.go +++ b/internal/fuse/root.go @@ -1,3 +1,4 @@ +// +build !netbsd // +build !openbsd // +build !solaris // +build !windows diff --git a/internal/fuse/snapshots_dir.go b/internal/fuse/snapshots_dir.go index f6fc42cad..3b7d428ae 100644 --- a/internal/fuse/snapshots_dir.go +++ b/internal/fuse/snapshots_dir.go @@ -1,3 +1,4 @@ +// +build !netbsd // +build !openbsd // +build !solaris // +build !windows diff --git a/internal/restic/node_netbsd.go b/internal/restic/node_netbsd.go new file mode 100644 index 000000000..b588a2b68 --- /dev/null +++ b/internal/restic/node_netbsd.go @@ -0,0 +1,27 @@ +package restic + +import "syscall" + +func (node Node) restoreSymlinkTimestamps(path string, utimes [2]syscall.Timespec) error { + return nil +} + +func (s statUnix) atim() syscall.Timespec { return s.Atimespec } +func (s statUnix) mtim() syscall.Timespec { return s.Mtimespec } +func (s statUnix) ctim() syscall.Timespec { return s.Ctimespec } + +// Getxattr retrieves extended attribute data associated with path. +func Getxattr(path, name string) ([]byte, error) { + return nil, nil +} + +// Listxattr retrieves a list of names of extended attributes associated with the +// given path in the file system. +func Listxattr(path string) ([]string, error) { + return nil, nil +} + +// Setxattr associates name and data together as an attribute of path. +func Setxattr(path, name string, data []byte) error { + return nil +} diff --git a/internal/restic/node_test.go b/internal/restic/node_test.go index 0b548323d..0e99b344e 100644 --- a/internal/restic/node_test.go +++ b/internal/restic/node_test.go @@ -210,7 +210,7 @@ func TestNodeRestoreAt(t *testing.T) { "%v: GID doesn't match (%v != %v)", test.Type, test.GID, n2.GID) if test.Type != "symlink" { // On OpenBSD only root can set sticky bit (see sticky(8)). - if runtime.GOOS != "openbsd" && test.Name == "testSticky" { + if runtime.GOOS != "openbsd" && runtime.GOOS != "netbsd" && test.Name == "testSticky" { rtest.Assert(t, test.Mode == n2.Mode, "%v: mode doesn't match (0%o != 0%o)", test.Type, test.Mode, n2.Mode) } @@ -228,7 +228,7 @@ func AssertFsTimeEqual(t *testing.T, label string, nodeType string, t1 time.Time // Go currently doesn't support setting timestamps of symbolic links on darwin and bsd if nodeType == "symlink" { switch runtime.GOOS { - case "darwin", "freebsd", "openbsd": + case "darwin", "freebsd", "openbsd", "netbsd": return } } diff --git a/internal/restic/node_xattr.go b/internal/restic/node_xattr.go index f6c95ac89..ea5ed8d3a 100644 --- a/internal/restic/node_xattr.go +++ b/internal/restic/node_xattr.go @@ -1,3 +1,4 @@ +// +build !netbsd // +build !openbsd // +build !solaris // +build !windows From 350761f1ba264189c82d192805e6b8ac26917629 Mon Sep 17 00:00:00 2001 From: Iku Iwasa Date: Sat, 16 Jun 2018 21:05:26 +0900 Subject: [PATCH 2/2] Add cross-compilation for netbsd/386 and netbsd/amd64 --- run_integration_tests.go | 1 + 1 file changed, 1 insertion(+) diff --git a/run_integration_tests.go b/run_integration_tests.go index 0908680d2..e2d8f4260 100644 --- a/run_integration_tests.go +++ b/run_integration_tests.go @@ -134,6 +134,7 @@ func (env *TravisEnvironment) Prepare() error { "darwin/386", "darwin/amd64", "freebsd/386", "freebsd/amd64", "openbsd/386", "openbsd/amd64", + "netbsd/386", "netbsd/amd64", "linux/arm", "freebsd/arm", }