This is to include the Go 1.11 fix
(https://github.com/containerd/continuity/pull/120).
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
| ... | ... |
@@ -116,7 +116,7 @@ google.golang.org/genproto 694d95ba50e67b2e363f3483057db5d4910c18f9 |
| 116 | 116 |
# containerd |
| 117 | 117 |
github.com/containerd/containerd b41633746ed4833f52c3c071e8edcfa2713e5677 |
| 118 | 118 |
github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c |
| 119 |
-github.com/containerd/continuity d3c23511c1bf5851696cba83143d9cbcd666869b |
|
| 119 |
+github.com/containerd/continuity 0377f7d767206f3a9e8881d0f02267b0d89c7a62 |
|
| 120 | 120 |
github.com/containerd/cgroups fe281dd265766145e943a034aa41086474ea6130 |
| 121 | 121 |
github.com/containerd/console 5d1b48d6114b8c9666f0c8b916f871af97b0a761 |
| 122 | 122 |
github.com/containerd/go-runc f271fa2021de855d4d918dbef83c5fe19db1bdd |
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"errors" |
| 7 | 7 |
"fmt" |
| 8 | 8 |
"os" |
| 9 |
- "path/filepath" |
|
| 10 | 9 |
"sort" |
| 11 | 10 |
|
| 12 | 11 |
"github.com/containerd/continuity/devices" |
| ... | ... |
@@ -26,18 +25,6 @@ func (d *driver) Mkfifo(path string, mode os.FileMode) error {
|
| 26 | 26 |
return devices.Mknod(path, mode, 0, 0) |
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 |
-// Lchmod changes the mode of an file not following symlinks. |
|
| 30 |
-func (d *driver) Lchmod(path string, mode os.FileMode) (err error) {
|
|
| 31 |
- if !filepath.IsAbs(path) {
|
|
| 32 |
- path, err = filepath.Abs(path) |
|
| 33 |
- if err != nil {
|
|
| 34 |
- return |
|
| 35 |
- } |
|
| 36 |
- } |
|
| 37 |
- |
|
| 38 |
- return sysx.Fchmodat(0, path, uint32(mode), sysx.AtSymlinkNofollow) |
|
| 39 |
-} |
|
| 40 |
- |
|
| 41 | 29 |
// Getxattr returns all of the extended attributes for the file at path p. |
| 42 | 30 |
func (d *driver) Getxattr(p string) (map[string][]byte, error) {
|
| 43 | 31 |
xattrs, err := sysx.Listxattr(p) |
| 44 | 32 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,19 @@ |
| 0 |
+package driver |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "os" |
|
| 4 |
+ |
|
| 5 |
+ "golang.org/x/sys/unix" |
|
| 6 |
+) |
|
| 7 |
+ |
|
| 8 |
+// Lchmod changes the mode of a file not following symlinks. |
|
| 9 |
+func (d *driver) Lchmod(path string, mode os.FileMode) error {
|
|
| 10 |
+ // On Linux, file mode is not supported for symlinks, |
|
| 11 |
+ // and fchmodat() does not support AT_SYMLINK_NOFOLLOW, |
|
| 12 |
+ // so symlinks need to be skipped entirely. |
|
| 13 |
+ if st, err := os.Stat(path); err == nil && st.Mode()&os.ModeSymlink != 0 {
|
|
| 14 |
+ return nil |
|
| 15 |
+ } |
|
| 16 |
+ |
|
| 17 |
+ return unix.Fchmodat(unix.AT_FDCWD, path, uint32(mode), 0) |
|
| 18 |
+} |
| 0 | 19 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,14 @@ |
| 0 |
+// +build darwin freebsd solaris |
|
| 1 |
+ |
|
| 2 |
+package driver |
|
| 3 |
+ |
|
| 4 |
+import ( |
|
| 5 |
+ "os" |
|
| 6 |
+ |
|
| 7 |
+ "golang.org/x/sys/unix" |
|
| 8 |
+) |
|
| 9 |
+ |
|
| 10 |
+// Lchmod changes the mode of a file not following symlinks. |
|
| 11 |
+func (d *driver) Lchmod(path string, mode os.FileMode) error {
|
|
| 12 |
+ return unix.Fchmodat(unix.AT_FDCWD, path, uint32(mode), unix.AT_SYMLINK_NOFOLLOW) |
|
| 13 |
+} |
| ... | ... |
@@ -10,8 +10,8 @@ type Usage struct {
|
| 10 | 10 |
|
| 11 | 11 |
// DiskUsage counts the number of inodes and disk usage for the resources under |
| 12 | 12 |
// path. |
| 13 |
-func DiskUsage(roots ...string) (Usage, error) {
|
|
| 14 |
- return diskUsage(roots...) |
|
| 13 |
+func DiskUsage(ctx context.Context, roots ...string) (Usage, error) {
|
|
| 14 |
+ return diskUsage(ctx, roots...) |
|
| 15 | 15 |
} |
| 16 | 16 |
|
| 17 | 17 |
// DiffUsage counts the numbers of inodes and disk usage in the |
| ... | ... |
@@ -24,7 +24,7 @@ func newInode(stat *syscall.Stat_t) inode {
|
| 24 | 24 |
} |
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
-func diskUsage(roots ...string) (Usage, error) {
|
|
| 27 |
+func diskUsage(ctx context.Context, roots ...string) (Usage, error) {
|
|
| 28 | 28 |
|
| 29 | 29 |
var ( |
| 30 | 30 |
size int64 |
| ... | ... |
@@ -37,6 +37,12 @@ func diskUsage(roots ...string) (Usage, error) {
|
| 37 | 37 |
return err |
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 |
+ select {
|
|
| 41 |
+ case <-ctx.Done(): |
|
| 42 |
+ return ctx.Err() |
|
| 43 |
+ default: |
|
| 44 |
+ } |
|
| 45 |
+ |
|
| 40 | 46 |
inoKey := newInode(fi.Sys().(*syscall.Stat_t)) |
| 41 | 47 |
if _, ok := inodes[inoKey]; !ok {
|
| 42 | 48 |
inodes[inoKey] = struct{}{}
|
| ... | ... |
@@ -8,7 +8,7 @@ import ( |
| 8 | 8 |
"path/filepath" |
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 |
-func diskUsage(roots ...string) (Usage, error) {
|
|
| 11 |
+func diskUsage(ctx context.Context, roots ...string) (Usage, error) {
|
|
| 12 | 12 |
var ( |
| 13 | 13 |
size int64 |
| 14 | 14 |
) |
| ... | ... |
@@ -21,6 +21,12 @@ func diskUsage(roots ...string) (Usage, error) {
|
| 21 | 21 |
return err |
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 |
+ select {
|
|
| 25 |
+ case <-ctx.Done(): |
|
| 26 |
+ return ctx.Err() |
|
| 27 |
+ default: |
|
| 28 |
+ } |
|
| 29 |
+ |
|
| 24 | 30 |
size += fi.Size() |
| 25 | 31 |
return nil |
| 26 | 32 |
}); err != nil {
|
| 27 | 33 |
deleted file mode 100644 |
| ... | ... |
@@ -1,18 +0,0 @@ |
| 1 |
-package sysx |
|
| 2 |
- |
|
| 3 |
-const ( |
|
| 4 |
- // AtSymlinkNoFollow defined from AT_SYMLINK_NOFOLLOW in <sys/fcntl.h> |
|
| 5 |
- AtSymlinkNofollow = 0x20 |
|
| 6 |
-) |
|
| 7 |
- |
|
| 8 |
-const ( |
|
| 9 |
- |
|
| 10 |
- // SYS_FCHMODAT defined from golang.org/sys/unix |
|
| 11 |
- SYS_FCHMODAT = 467 |
|
| 12 |
-) |
|
| 13 |
- |
|
| 14 |
-// These functions will be generated by generate.sh |
|
| 15 |
-// $ GOOS=darwin GOARCH=386 ./generate.sh chmod |
|
| 16 |
-// $ GOOS=darwin GOARCH=amd64 ./generate.sh chmod |
|
| 17 |
- |
|
| 18 |
-//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) |
| 19 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,25 +0,0 @@ |
| 1 |
-// mksyscall.pl -l32 chmod_darwin.go |
|
| 2 |
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT |
|
| 3 |
- |
|
| 4 |
-package sysx |
|
| 5 |
- |
|
| 6 |
-import ( |
|
| 7 |
- "syscall" |
|
| 8 |
- "unsafe" |
|
| 9 |
-) |
|
| 10 |
- |
|
| 11 |
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
|
| 12 |
- |
|
| 13 |
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
|
|
| 14 |
- var _p0 *byte |
|
| 15 |
- _p0, err = syscall.BytePtrFromString(path) |
|
| 16 |
- if err != nil {
|
|
| 17 |
- return |
|
| 18 |
- } |
|
| 19 |
- _, _, e1 := syscall.Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) |
|
| 20 |
- use(unsafe.Pointer(_p0)) |
|
| 21 |
- if e1 != 0 {
|
|
| 22 |
- err = errnoErr(e1) |
|
| 23 |
- } |
|
| 24 |
- return |
|
| 25 |
-} |
| 26 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,25 +0,0 @@ |
| 1 |
-// mksyscall.pl chmod_darwin.go |
|
| 2 |
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT |
|
| 3 |
- |
|
| 4 |
-package sysx |
|
| 5 |
- |
|
| 6 |
-import ( |
|
| 7 |
- "syscall" |
|
| 8 |
- "unsafe" |
|
| 9 |
-) |
|
| 10 |
- |
|
| 11 |
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
|
| 12 |
- |
|
| 13 |
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
|
|
| 14 |
- var _p0 *byte |
|
| 15 |
- _p0, err = syscall.BytePtrFromString(path) |
|
| 16 |
- if err != nil {
|
|
| 17 |
- return |
|
| 18 |
- } |
|
| 19 |
- _, _, e1 := syscall.Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) |
|
| 20 |
- use(unsafe.Pointer(_p0)) |
|
| 21 |
- if e1 != 0 {
|
|
| 22 |
- err = errnoErr(e1) |
|
| 23 |
- } |
|
| 24 |
- return |
|
| 25 |
-} |
| 26 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,17 +0,0 @@ |
| 1 |
-package sysx |
|
| 2 |
- |
|
| 3 |
-const ( |
|
| 4 |
- // AtSymlinkNoFollow defined from AT_SYMLINK_NOFOLLOW in <sys/fcntl.h> |
|
| 5 |
- AtSymlinkNofollow = 0x200 |
|
| 6 |
-) |
|
| 7 |
- |
|
| 8 |
-const ( |
|
| 9 |
- |
|
| 10 |
- // SYS_FCHMODAT defined from golang.org/sys/unix |
|
| 11 |
- SYS_FCHMODAT = 490 |
|
| 12 |
-) |
|
| 13 |
- |
|
| 14 |
-// These functions will be generated by generate.sh |
|
| 15 |
-// $ GOOS=freebsd GOARCH=amd64 ./generate.sh chmod |
|
| 16 |
- |
|
| 17 |
-//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) |
| 18 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,25 +0,0 @@ |
| 1 |
-// mksyscall.pl chmod_freebsd.go |
|
| 2 |
-// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT |
|
| 3 |
- |
|
| 4 |
-package sysx |
|
| 5 |
- |
|
| 6 |
-import ( |
|
| 7 |
- "syscall" |
|
| 8 |
- "unsafe" |
|
| 9 |
-) |
|
| 10 |
- |
|
| 11 |
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
|
| 12 |
- |
|
| 13 |
-func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
|
|
| 14 |
- var _p0 *byte |
|
| 15 |
- _p0, err = syscall.BytePtrFromString(path) |
|
| 16 |
- if err != nil {
|
|
| 17 |
- return |
|
| 18 |
- } |
|
| 19 |
- _, _, e1 := syscall.Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) |
|
| 20 |
- use(unsafe.Pointer(_p0)) |
|
| 21 |
- if e1 != 0 {
|
|
| 22 |
- err = errnoErr(e1) |
|
| 23 |
- } |
|
| 24 |
- return |
|
| 25 |
-} |
| 26 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,12 +0,0 @@ |
| 1 |
-package sysx |
|
| 2 |
- |
|
| 3 |
-import "syscall" |
|
| 4 |
- |
|
| 5 |
-const ( |
|
| 6 |
- // AtSymlinkNoFollow defined from AT_SYMLINK_NOFOLLOW in /usr/include/linux/fcntl.h |
|
| 7 |
- AtSymlinkNofollow = 0x100 |
|
| 8 |
-) |
|
| 9 |
- |
|
| 10 |
-func Fchmodat(dirfd int, path string, mode uint32, flags int) error {
|
|
| 11 |
- return syscall.Fchmodat(dirfd, path, mode, flags) |
|
| 12 |
-} |
| 13 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,11 +0,0 @@ |
| 1 |
-package sysx |
|
| 2 |
- |
|
| 3 |
-import "golang.org/x/sys/unix" |
|
| 4 |
- |
|
| 5 |
-const ( |
|
| 6 |
- AtSymlinkNofollow = unix.AT_SYMLINK_NOFOLLOW |
|
| 7 |
-) |
|
| 8 |
- |
|
| 9 |
-func Fchmodat(dirfd int, path string, mode uint32, flags int) error {
|
|
| 10 |
- return unix.Fchmodat(dirfd, path, mode, flags) |
|
| 11 |
-} |
| ... | ... |
@@ -8,7 +8,6 @@ package sysx |
| 8 | 8 |
//sys setxattr(path string, attr string, data []byte, flags int) (err error) |
| 9 | 9 |
//sys removexattr(path string, attr string, options int) (err error) |
| 10 | 10 |
//sys listxattr(path string, dest []byte, options int) (sz int, err error) |
| 11 |
-//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) |
|
| 12 | 11 |
|
| 13 | 12 |
const ( |
| 14 | 13 |
xattrNoFollow = 0x01 |