Add solaris build support
Signed-off-by: Edward Pilatowicz <edward.pilatowicz@oracle.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"github.com/containerd/containerd/sys"
|
||||
"github.com/containerd/continuity/sysx"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sys/unix"
|
||||
@@ -22,7 +23,7 @@ func copyFileInfo(fi os.FileInfo, name string) error {
|
||||
}
|
||||
}
|
||||
|
||||
timespec := []unix.Timespec{unix.Timespec(st.Atim), unix.Timespec(st.Mtim)}
|
||||
timespec := []unix.Timespec{unix.Timespec(sys.StatAtime(st)), unix.Timespec(sys.StatMtime(st))}
|
||||
if err := unix.UtimesNanoAt(unix.AT_FDCWD, name, timespec, unix.AT_SYMLINK_NOFOLLOW); err != nil {
|
||||
return errors.Wrapf(err, "failed to utime %s", name)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build darwin freebsd
|
||||
// +build solaris darwin freebsd
|
||||
|
||||
package fs
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"github.com/containerd/containerd/sys"
|
||||
"github.com/containerd/continuity/sysx"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -23,7 +24,8 @@ func copyFileInfo(fi os.FileInfo, name string) error {
|
||||
}
|
||||
}
|
||||
|
||||
if err := syscall.UtimesNano(name, []syscall.Timespec{st.Atimespec, st.Mtimespec}); err != nil {
|
||||
timespec := []syscall.Timespec{sys.StatAtime(st), sys.StatMtime(st)}
|
||||
if err := syscall.UtimesNano(name, timespec); err != nil {
|
||||
return errors.Wrapf(err, "failed to utime %s", name)
|
||||
}
|
||||
|
||||
|
||||
26
fs/dtype_test.go
Normal file
26
fs/dtype_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package fs
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/containerd/containerd/testutil"
|
||||
)
|
||||
|
||||
func TestRequiresRootNOP(t *testing.T) {
|
||||
|
||||
// This is a dummy test case that exist to call
|
||||
// testutil.RequiresRoot() on non-linux platforms. This is
|
||||
// needed because the Makfile root-coverage tests target
|
||||
// determines which packages contain root test by grepping for
|
||||
// testutil.RequiresRoot. Within the fs package, the only test
|
||||
// that references this symbol is in dtype_linux_test.go, but
|
||||
// that file is only built on linux. Since the Makefile is not
|
||||
// go build tag aware it sees this file and then tries to run
|
||||
// the following command on all platforms: "go test ...
|
||||
// github.com/containerd/containerd/fs -test.root". On
|
||||
// non-linux platforms this fails because there are no tests in
|
||||
// the "fs" package that reference testutil.RequiresRoot. To
|
||||
// fix this problem we'll add a reference to this symbol below.
|
||||
|
||||
testutil.RequiresRoot(t)
|
||||
}
|
||||
Reference in New Issue
Block a user