Skip to content

Commit

Permalink
Merge pull request #186 from ukontainer/fix-darwin-utimes
Browse files Browse the repository at this point in the history
Fix darwin issues
  • Loading branch information
estesp committed Sep 10, 2021
2 parents 8bdabd6 + 16556d0 commit 2e0898a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
6 changes: 5 additions & 1 deletion AUTHORS
Expand Up @@ -12,8 +12,11 @@ Darren Stahl <darst@microsoft.com>
Derek McGowan <derek@mcg.dev>
Derek McGowan <derek@mcgstyle.net>
Edward Pilatowicz <edward.pilatowicz@oracle.com>
Fu Wei <fuweid89@gmail.com>
Hajime Tazaki <thehajime@gmail.com>
Ian Campbell <ijc@docker.com>
Ivan Markin <sw@nogoegst.net>
Jacob Blain Christen <jacob@rancher.com>
Justin Cormack <justin.cormack@docker.com>
Justin Cummins <sul3n3t@gmail.com>
Kasper Fabæch Brandt <poizan@poizan.dk>
Expand All @@ -23,10 +26,11 @@ Michael Crosby <michael@thepasture.io>
Michael Wan <zirenwan@gmail.com>
Mike Brown <brownwm@us.ibm.com>
Niels de Vos <ndevos@redhat.com>
Phil Estes <estesp@amazon.com>
Phil Estes <estesp@gmail.com>
Phil Estes <estesp@linux.vnet.ibm.com>
Samuel Karp <me@samuelkarp.com>
Sam Whited <sam@samwhited.com>
Samuel Karp <me@samuelkarp.com>
Sebastiaan van Stijn <github@gone.nl>
Shengjing Zhu <zhsj@debian.org>
Stephen J Day <stephen.day@docker.com>
Expand Down
42 changes: 42 additions & 0 deletions fs/copy_darwin.go
@@ -0,0 +1,42 @@
// +build darwin

/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package fs

import (
"os"
"syscall"

"github.com/pkg/errors"
"golang.org/x/sys/unix"
)

func copyDevice(dst string, fi os.FileInfo) error {
st, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return errors.New("unsupported stat type")
}
return unix.Mknod(dst, uint32(fi.Mode()), int(st.Rdev))
}

func utimesNano(name string, atime, mtime syscall.Timespec) error {
at := unix.NsecToTimespec(atime.Nano())
mt := unix.NsecToTimespec(mtime.Nano())
utimes := [2]unix.Timespec{at, mt}
return unix.UtimesNanoAt(unix.AT_FDCWD, name, utimes[0:], unix.AT_SYMLINK_NOFOLLOW)
}
@@ -1,4 +1,4 @@
// +build darwin openbsd solaris
// +build openbsd solaris

/*
Copyright The containerd Authors.
Expand Down
@@ -1,4 +1,4 @@
// +build freebsd
// +build freebsd darwin

/*
Copyright The containerd Authors.
Expand Down
2 changes: 1 addition & 1 deletion fs/du_cmd_unix_test.go
@@ -1,4 +1,4 @@
// +build !windows,!freebsd
// +build !windows,!freebsd,!darwin

/*
Copyright The containerd Authors.
Expand Down

0 comments on commit 2e0898a

Please sign in to comment.