This is to include the Go 1.11 fix
(https://github.com/containerd/continuity/pull/120).
Again (see c64a2448d1f2b7ba680d).
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
| ... | ... |
@@ -117,7 +117,7 @@ google.golang.org/genproto 694d95ba50e67b2e363f3483057db5d4910c18f9 |
| 117 | 117 |
# containerd |
| 118 | 118 |
github.com/containerd/containerd v1.2.0-beta.2 |
| 119 | 119 |
github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c |
| 120 |
-github.com/containerd/continuity d3c23511c1bf5851696cba83143d9cbcd666869b |
|
| 120 |
+github.com/containerd/continuity c7c5070e6f6e090ab93b0a61eb921f2196fc3383 |
|
| 121 | 121 |
github.com/containerd/cgroups 5e610833b72089b37d0e615de9a92dfc043757c2 |
| 122 | 122 |
github.com/containerd/console c12b1e7919c14469339a5d38f2f8ed9b64a9de23 |
| 123 | 123 |
github.com/containerd/go-runc edcf3de1f4971445c42d61f20d506b30612aa031 |
| ... | ... |
@@ -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 {
|
| 0 | 3 |
deleted file mode 100644 |
| ... | ... |
@@ -1,10 +0,0 @@ |
| 1 |
-// Copyright 2014 The Go Authors. All rights reserved. |
|
| 2 |
-// Use of this source code is governed by a BSD-style |
|
| 3 |
-// license that can be found in the LICENSE file. |
|
| 4 |
- |
|
| 5 |
-// +build !gccgo |
|
| 6 |
- |
|
| 7 |
-#include "textflag.h" |
|
| 8 |
- |
|
| 9 |
-TEXT ·use(SB),NOSPLIT,$0 |
|
| 10 |
- RET |
| 11 | 1 |
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 |
-} |
| 12 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,37 +0,0 @@ |
| 1 |
-package sysx |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "syscall" |
|
| 5 |
- "unsafe" |
|
| 6 |
-) |
|
| 7 |
- |
|
| 8 |
-var _zero uintptr |
|
| 9 |
- |
|
| 10 |
-// use is a no-op, but the compiler cannot see that it is. |
|
| 11 |
-// Calling use(p) ensures that p is kept live until that point. |
|
| 12 |
-//go:noescape |
|
| 13 |
-func use(p unsafe.Pointer) |
|
| 14 |
- |
|
| 15 |
-// Do the interface allocations only once for common |
|
| 16 |
-// Errno values. |
|
| 17 |
-var ( |
|
| 18 |
- errEAGAIN error = syscall.EAGAIN |
|
| 19 |
- errEINVAL error = syscall.EINVAL |
|
| 20 |
- errENOENT error = syscall.ENOENT |
|
| 21 |
-) |
|
| 22 |
- |
|
| 23 |
-// errnoErr returns common boxed Errno values, to prevent |
|
| 24 |
-// allocations at runtime. |
|
| 25 |
-func errnoErr(e syscall.Errno) error {
|
|
| 26 |
- switch e {
|
|
| 27 |
- case 0: |
|
| 28 |
- return nil |
|
| 29 |
- case syscall.EAGAIN: |
|
| 30 |
- return errEAGAIN |
|
| 31 |
- case syscall.EINVAL: |
|
| 32 |
- return errEINVAL |
|
| 33 |
- case syscall.ENOENT: |
|
| 34 |
- return errENOENT |
|
| 35 |
- } |
|
| 36 |
- return e |
|
| 37 |
-} |
| ... | ... |
@@ -1,14 +1,56 @@ |
| 1 |
+// +build linux darwin |
|
| 2 |
+ |
|
| 1 | 3 |
package sysx |
| 2 | 4 |
|
| 3 | 5 |
import ( |
| 4 | 6 |
"bytes" |
| 5 |
- "fmt" |
|
| 6 | 7 |
"syscall" |
| 8 |
+ |
|
| 9 |
+ "golang.org/x/sys/unix" |
|
| 7 | 10 |
) |
| 8 | 11 |
|
| 9 |
-const defaultXattrBufferSize = 5 |
|
| 12 |
+// Listxattr calls syscall listxattr and reads all content |
|
| 13 |
+// and returns a string array |
|
| 14 |
+func Listxattr(path string) ([]string, error) {
|
|
| 15 |
+ return listxattrAll(path, unix.Listxattr) |
|
| 16 |
+} |
|
| 17 |
+ |
|
| 18 |
+// Removexattr calls syscall removexattr |
|
| 19 |
+func Removexattr(path string, attr string) (err error) {
|
|
| 20 |
+ return unix.Removexattr(path, attr) |
|
| 21 |
+} |
|
| 22 |
+ |
|
| 23 |
+// Setxattr calls syscall setxattr |
|
| 24 |
+func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
|
| 25 |
+ return unix.Setxattr(path, attr, data, flags) |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 28 |
+// Getxattr calls syscall getxattr |
|
| 29 |
+func Getxattr(path, attr string) ([]byte, error) {
|
|
| 30 |
+ return getxattrAll(path, attr, unix.Getxattr) |
|
| 31 |
+} |
|
| 10 | 32 |
|
| 11 |
-var ErrNotSupported = fmt.Errorf("not supported")
|
|
| 33 |
+// LListxattr lists xattrs, not following symlinks |
|
| 34 |
+func LListxattr(path string) ([]string, error) {
|
|
| 35 |
+ return listxattrAll(path, unix.Llistxattr) |
|
| 36 |
+} |
|
| 37 |
+ |
|
| 38 |
+// LRemovexattr removes an xattr, not following symlinks |
|
| 39 |
+func LRemovexattr(path string, attr string) (err error) {
|
|
| 40 |
+ return unix.Lremovexattr(path, attr) |
|
| 41 |
+} |
|
| 42 |
+ |
|
| 43 |
+// LSetxattr sets an xattr, not following symlinks |
|
| 44 |
+func LSetxattr(path string, attr string, data []byte, flags int) (err error) {
|
|
| 45 |
+ return unix.Lsetxattr(path, attr, data, flags) |
|
| 46 |
+} |
|
| 47 |
+ |
|
| 48 |
+// LGetxattr gets an xattr, not following symlinks |
|
| 49 |
+func LGetxattr(path, attr string) ([]byte, error) {
|
|
| 50 |
+ return getxattrAll(path, attr, unix.Lgetxattr) |
|
| 51 |
+} |
|
| 52 |
+ |
|
| 53 |
+const defaultXattrBufferSize = 5 |
|
| 12 | 54 |
|
| 13 | 55 |
type listxattrFunc func(path string, dest []byte) (int, error) |
| 14 | 56 |
|
| 15 | 57 |
deleted file mode 100644 |
| ... | ... |
@@ -1,71 +0,0 @@ |
| 1 |
-package sysx |
|
| 2 |
- |
|
| 3 |
-// These functions will be generated by generate.sh |
|
| 4 |
-// $ GOOS=darwin GOARCH=386 ./generate.sh xattr |
|
| 5 |
-// $ GOOS=darwin GOARCH=amd64 ./generate.sh xattr |
|
| 6 |
- |
|
| 7 |
-//sys getxattr(path string, attr string, dest []byte, pos int, options int) (sz int, err error) |
|
| 8 |
-//sys setxattr(path string, attr string, data []byte, flags int) (err error) |
|
| 9 |
-//sys removexattr(path string, attr string, options int) (err error) |
|
| 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 |
- |
|
| 13 |
-const ( |
|
| 14 |
- xattrNoFollow = 0x01 |
|
| 15 |
-) |
|
| 16 |
- |
|
| 17 |
-func listxattrFollow(path string, dest []byte) (sz int, err error) {
|
|
| 18 |
- return listxattr(path, dest, 0) |
|
| 19 |
-} |
|
| 20 |
- |
|
| 21 |
-// Listxattr calls syscall getxattr |
|
| 22 |
-func Listxattr(path string) ([]string, error) {
|
|
| 23 |
- return listxattrAll(path, listxattrFollow) |
|
| 24 |
-} |
|
| 25 |
- |
|
| 26 |
-// Removexattr calls syscall getxattr |
|
| 27 |
-func Removexattr(path string, attr string) (err error) {
|
|
| 28 |
- return removexattr(path, attr, 0) |
|
| 29 |
-} |
|
| 30 |
- |
|
| 31 |
-// Setxattr calls syscall setxattr |
|
| 32 |
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
|
| 33 |
- return setxattr(path, attr, data, flags) |
|
| 34 |
-} |
|
| 35 |
- |
|
| 36 |
-func getxattrFollow(path, attr string, dest []byte) (sz int, err error) {
|
|
| 37 |
- return getxattr(path, attr, dest, 0, 0) |
|
| 38 |
-} |
|
| 39 |
- |
|
| 40 |
-// Getxattr calls syscall getxattr |
|
| 41 |
-func Getxattr(path, attr string) ([]byte, error) {
|
|
| 42 |
- return getxattrAll(path, attr, getxattrFollow) |
|
| 43 |
-} |
|
| 44 |
- |
|
| 45 |
-func listxattrNoFollow(path string, dest []byte) (sz int, err error) {
|
|
| 46 |
- return listxattr(path, dest, xattrNoFollow) |
|
| 47 |
-} |
|
| 48 |
- |
|
| 49 |
-// LListxattr calls syscall listxattr with XATTR_NOFOLLOW |
|
| 50 |
-func LListxattr(path string) ([]string, error) {
|
|
| 51 |
- return listxattrAll(path, listxattrNoFollow) |
|
| 52 |
-} |
|
| 53 |
- |
|
| 54 |
-// LRemovexattr calls syscall removexattr with XATTR_NOFOLLOW |
|
| 55 |
-func LRemovexattr(path string, attr string) (err error) {
|
|
| 56 |
- return removexattr(path, attr, xattrNoFollow) |
|
| 57 |
-} |
|
| 58 |
- |
|
| 59 |
-// Setxattr calls syscall setxattr with XATTR_NOFOLLOW |
|
| 60 |
-func LSetxattr(path string, attr string, data []byte, flags int) (err error) {
|
|
| 61 |
- return setxattr(path, attr, data, flags|xattrNoFollow) |
|
| 62 |
-} |
|
| 63 |
- |
|
| 64 |
-func getxattrNoFollow(path, attr string, dest []byte) (sz int, err error) {
|
|
| 65 |
- return getxattr(path, attr, dest, 0, xattrNoFollow) |
|
| 66 |
-} |
|
| 67 |
- |
|
| 68 |
-// LGetxattr calls syscall getxattr with XATTR_NOFOLLOW |
|
| 69 |
-func LGetxattr(path, attr string) ([]byte, error) {
|
|
| 70 |
- return getxattrAll(path, attr, getxattrNoFollow) |
|
| 71 |
-} |
| 72 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,111 +0,0 @@ |
| 1 |
-// mksyscall.pl -l32 xattr_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 getxattr(path string, attr string, dest []byte, pos int, options int) (sz int, err error) {
|
|
| 14 |
- var _p0 *byte |
|
| 15 |
- _p0, err = syscall.BytePtrFromString(path) |
|
| 16 |
- if err != nil {
|
|
| 17 |
- return |
|
| 18 |
- } |
|
| 19 |
- var _p1 *byte |
|
| 20 |
- _p1, err = syscall.BytePtrFromString(attr) |
|
| 21 |
- if err != nil {
|
|
| 22 |
- return |
|
| 23 |
- } |
|
| 24 |
- var _p2 unsafe.Pointer |
|
| 25 |
- if len(dest) > 0 {
|
|
| 26 |
- _p2 = unsafe.Pointer(&dest[0]) |
|
| 27 |
- } else {
|
|
| 28 |
- _p2 = unsafe.Pointer(&_zero) |
|
| 29 |
- } |
|
| 30 |
- r0, _, e1 := syscall.Syscall6(syscall.SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), uintptr(pos), uintptr(options)) |
|
| 31 |
- use(unsafe.Pointer(_p0)) |
|
| 32 |
- use(unsafe.Pointer(_p1)) |
|
| 33 |
- sz = int(r0) |
|
| 34 |
- if e1 != 0 {
|
|
| 35 |
- err = errnoErr(e1) |
|
| 36 |
- } |
|
| 37 |
- return |
|
| 38 |
-} |
|
| 39 |
- |
|
| 40 |
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
|
| 41 |
- |
|
| 42 |
-func setxattr(path string, attr string, data []byte, flags int) (err error) {
|
|
| 43 |
- var _p0 *byte |
|
| 44 |
- _p0, err = syscall.BytePtrFromString(path) |
|
| 45 |
- if err != nil {
|
|
| 46 |
- return |
|
| 47 |
- } |
|
| 48 |
- var _p1 *byte |
|
| 49 |
- _p1, err = syscall.BytePtrFromString(attr) |
|
| 50 |
- if err != nil {
|
|
| 51 |
- return |
|
| 52 |
- } |
|
| 53 |
- var _p2 unsafe.Pointer |
|
| 54 |
- if len(data) > 0 {
|
|
| 55 |
- _p2 = unsafe.Pointer(&data[0]) |
|
| 56 |
- } else {
|
|
| 57 |
- _p2 = unsafe.Pointer(&_zero) |
|
| 58 |
- } |
|
| 59 |
- _, _, e1 := syscall.Syscall6(syscall.SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) |
|
| 60 |
- use(unsafe.Pointer(_p0)) |
|
| 61 |
- use(unsafe.Pointer(_p1)) |
|
| 62 |
- if e1 != 0 {
|
|
| 63 |
- err = errnoErr(e1) |
|
| 64 |
- } |
|
| 65 |
- return |
|
| 66 |
-} |
|
| 67 |
- |
|
| 68 |
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
|
| 69 |
- |
|
| 70 |
-func removexattr(path string, attr string, options int) (err error) {
|
|
| 71 |
- var _p0 *byte |
|
| 72 |
- _p0, err = syscall.BytePtrFromString(path) |
|
| 73 |
- if err != nil {
|
|
| 74 |
- return |
|
| 75 |
- } |
|
| 76 |
- var _p1 *byte |
|
| 77 |
- _p1, err = syscall.BytePtrFromString(attr) |
|
| 78 |
- if err != nil {
|
|
| 79 |
- return |
|
| 80 |
- } |
|
| 81 |
- _, _, e1 := syscall.Syscall(syscall.SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options)) |
|
| 82 |
- use(unsafe.Pointer(_p0)) |
|
| 83 |
- use(unsafe.Pointer(_p1)) |
|
| 84 |
- if e1 != 0 {
|
|
| 85 |
- err = errnoErr(e1) |
|
| 86 |
- } |
|
| 87 |
- return |
|
| 88 |
-} |
|
| 89 |
- |
|
| 90 |
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
|
| 91 |
- |
|
| 92 |
-func listxattr(path string, dest []byte, options int) (sz int, err error) {
|
|
| 93 |
- var _p0 *byte |
|
| 94 |
- _p0, err = syscall.BytePtrFromString(path) |
|
| 95 |
- if err != nil {
|
|
| 96 |
- return |
|
| 97 |
- } |
|
| 98 |
- var _p1 unsafe.Pointer |
|
| 99 |
- if len(dest) > 0 {
|
|
| 100 |
- _p1 = unsafe.Pointer(&dest[0]) |
|
| 101 |
- } else {
|
|
| 102 |
- _p1 = unsafe.Pointer(&_zero) |
|
| 103 |
- } |
|
| 104 |
- r0, _, e1 := syscall.Syscall6(syscall.SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)), uintptr(options), 0, 0) |
|
| 105 |
- use(unsafe.Pointer(_p0)) |
|
| 106 |
- sz = int(r0) |
|
| 107 |
- if e1 != 0 {
|
|
| 108 |
- err = errnoErr(e1) |
|
| 109 |
- } |
|
| 110 |
- return |
|
| 111 |
-} |
| 112 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,111 +0,0 @@ |
| 1 |
-// mksyscall.pl xattr_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 getxattr(path string, attr string, dest []byte, pos int, options int) (sz int, err error) {
|
|
| 14 |
- var _p0 *byte |
|
| 15 |
- _p0, err = syscall.BytePtrFromString(path) |
|
| 16 |
- if err != nil {
|
|
| 17 |
- return |
|
| 18 |
- } |
|
| 19 |
- var _p1 *byte |
|
| 20 |
- _p1, err = syscall.BytePtrFromString(attr) |
|
| 21 |
- if err != nil {
|
|
| 22 |
- return |
|
| 23 |
- } |
|
| 24 |
- var _p2 unsafe.Pointer |
|
| 25 |
- if len(dest) > 0 {
|
|
| 26 |
- _p2 = unsafe.Pointer(&dest[0]) |
|
| 27 |
- } else {
|
|
| 28 |
- _p2 = unsafe.Pointer(&_zero) |
|
| 29 |
- } |
|
| 30 |
- r0, _, e1 := syscall.Syscall6(syscall.SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), uintptr(pos), uintptr(options)) |
|
| 31 |
- use(unsafe.Pointer(_p0)) |
|
| 32 |
- use(unsafe.Pointer(_p1)) |
|
| 33 |
- sz = int(r0) |
|
| 34 |
- if e1 != 0 {
|
|
| 35 |
- err = errnoErr(e1) |
|
| 36 |
- } |
|
| 37 |
- return |
|
| 38 |
-} |
|
| 39 |
- |
|
| 40 |
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
|
| 41 |
- |
|
| 42 |
-func setxattr(path string, attr string, data []byte, flags int) (err error) {
|
|
| 43 |
- var _p0 *byte |
|
| 44 |
- _p0, err = syscall.BytePtrFromString(path) |
|
| 45 |
- if err != nil {
|
|
| 46 |
- return |
|
| 47 |
- } |
|
| 48 |
- var _p1 *byte |
|
| 49 |
- _p1, err = syscall.BytePtrFromString(attr) |
|
| 50 |
- if err != nil {
|
|
| 51 |
- return |
|
| 52 |
- } |
|
| 53 |
- var _p2 unsafe.Pointer |
|
| 54 |
- if len(data) > 0 {
|
|
| 55 |
- _p2 = unsafe.Pointer(&data[0]) |
|
| 56 |
- } else {
|
|
| 57 |
- _p2 = unsafe.Pointer(&_zero) |
|
| 58 |
- } |
|
| 59 |
- _, _, e1 := syscall.Syscall6(syscall.SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) |
|
| 60 |
- use(unsafe.Pointer(_p0)) |
|
| 61 |
- use(unsafe.Pointer(_p1)) |
|
| 62 |
- if e1 != 0 {
|
|
| 63 |
- err = errnoErr(e1) |
|
| 64 |
- } |
|
| 65 |
- return |
|
| 66 |
-} |
|
| 67 |
- |
|
| 68 |
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
|
| 69 |
- |
|
| 70 |
-func removexattr(path string, attr string, options int) (err error) {
|
|
| 71 |
- var _p0 *byte |
|
| 72 |
- _p0, err = syscall.BytePtrFromString(path) |
|
| 73 |
- if err != nil {
|
|
| 74 |
- return |
|
| 75 |
- } |
|
| 76 |
- var _p1 *byte |
|
| 77 |
- _p1, err = syscall.BytePtrFromString(attr) |
|
| 78 |
- if err != nil {
|
|
| 79 |
- return |
|
| 80 |
- } |
|
| 81 |
- _, _, e1 := syscall.Syscall(syscall.SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options)) |
|
| 82 |
- use(unsafe.Pointer(_p0)) |
|
| 83 |
- use(unsafe.Pointer(_p1)) |
|
| 84 |
- if e1 != 0 {
|
|
| 85 |
- err = errnoErr(e1) |
|
| 86 |
- } |
|
| 87 |
- return |
|
| 88 |
-} |
|
| 89 |
- |
|
| 90 |
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT |
|
| 91 |
- |
|
| 92 |
-func listxattr(path string, dest []byte, options int) (sz int, err error) {
|
|
| 93 |
- var _p0 *byte |
|
| 94 |
- _p0, err = syscall.BytePtrFromString(path) |
|
| 95 |
- if err != nil {
|
|
| 96 |
- return |
|
| 97 |
- } |
|
| 98 |
- var _p1 unsafe.Pointer |
|
| 99 |
- if len(dest) > 0 {
|
|
| 100 |
- _p1 = unsafe.Pointer(&dest[0]) |
|
| 101 |
- } else {
|
|
| 102 |
- _p1 = unsafe.Pointer(&_zero) |
|
| 103 |
- } |
|
| 104 |
- r0, _, e1 := syscall.Syscall6(syscall.SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)), uintptr(options), 0, 0) |
|
| 105 |
- use(unsafe.Pointer(_p0)) |
|
| 106 |
- sz = int(r0) |
|
| 107 |
- if e1 != 0 {
|
|
| 108 |
- err = errnoErr(e1) |
|
| 109 |
- } |
|
| 110 |
- return |
|
| 111 |
-} |
| 112 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,12 +0,0 @@ |
| 1 |
-package sysx |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "errors" |
|
| 5 |
-) |
|
| 6 |
- |
|
| 7 |
-// Initial stub version for FreeBSD. FreeBSD has a different |
|
| 8 |
-// syscall API from Darwin and Linux for extended attributes; |
|
| 9 |
-// it is also not widely used. It is not exposed at all by the |
|
| 10 |
-// Go syscall package, so we need to implement directly eventually. |
|
| 11 |
- |
|
| 12 |
-var unsupported = errors.New("extended attributes unsupported on FreeBSD")
|
| 13 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,44 +0,0 @@ |
| 1 |
-package sysx |
|
| 2 |
- |
|
| 3 |
-import "golang.org/x/sys/unix" |
|
| 4 |
- |
|
| 5 |
-// Listxattr calls syscall listxattr and reads all content |
|
| 6 |
-// and returns a string array |
|
| 7 |
-func Listxattr(path string) ([]string, error) {
|
|
| 8 |
- return listxattrAll(path, unix.Listxattr) |
|
| 9 |
-} |
|
| 10 |
- |
|
| 11 |
-// Removexattr calls syscall removexattr |
|
| 12 |
-func Removexattr(path string, attr string) (err error) {
|
|
| 13 |
- return unix.Removexattr(path, attr) |
|
| 14 |
-} |
|
| 15 |
- |
|
| 16 |
-// Setxattr calls syscall setxattr |
|
| 17 |
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
|
| 18 |
- return unix.Setxattr(path, attr, data, flags) |
|
| 19 |
-} |
|
| 20 |
- |
|
| 21 |
-// Getxattr calls syscall getxattr |
|
| 22 |
-func Getxattr(path, attr string) ([]byte, error) {
|
|
| 23 |
- return getxattrAll(path, attr, unix.Getxattr) |
|
| 24 |
-} |
|
| 25 |
- |
|
| 26 |
-// LListxattr lists xattrs, not following symlinks |
|
| 27 |
-func LListxattr(path string) ([]string, error) {
|
|
| 28 |
- return listxattrAll(path, unix.Llistxattr) |
|
| 29 |
-} |
|
| 30 |
- |
|
| 31 |
-// LRemovexattr removes an xattr, not following symlinks |
|
| 32 |
-func LRemovexattr(path string, attr string) (err error) {
|
|
| 33 |
- return unix.Lremovexattr(path, attr) |
|
| 34 |
-} |
|
| 35 |
- |
|
| 36 |
-// LSetxattr sets an xattr, not following symlinks |
|
| 37 |
-func LSetxattr(path string, attr string, data []byte, flags int) (err error) {
|
|
| 38 |
- return unix.Lsetxattr(path, attr, data, flags) |
|
| 39 |
-} |
|
| 40 |
- |
|
| 41 |
-// LGetxattr gets an xattr, not following symlinks |
|
| 42 |
-func LGetxattr(path, attr string) ([]byte, error) {
|
|
| 43 |
- return getxattrAll(path, attr, unix.Lgetxattr) |
|
| 44 |
-} |
| 8 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,12 +0,0 @@ |
| 1 |
-package sysx |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "errors" |
|
| 5 |
-) |
|
| 6 |
- |
|
| 7 |
-// Initial stub version for Solaris. Solaris has a different |
|
| 8 |
-// syscall API from Darwin and Linux for extended attributes; |
|
| 9 |
-// it is also not widely used. It is not exposed at all by the |
|
| 10 |
-// Go syscall package, so we need to implement directly eventually. |
|
| 11 |
- |
|
| 12 |
-var unsupported = errors.New("extended attributes unsupported on Solaris")
|
| ... | ... |
@@ -1,7 +1,14 @@ |
| 1 |
-// +build freebsd openbsd solaris |
|
| 1 |
+// +build !linux,!darwin |
|
| 2 | 2 |
|
| 3 | 3 |
package sysx |
| 4 | 4 |
|
| 5 |
+import ( |
|
| 6 |
+ "errors" |
|
| 7 |
+ "runtime" |
|
| 8 |
+) |
|
| 9 |
+ |
|
| 10 |
+var unsupported = errors.New("extended attributes unsupported on " + runtime.GOOS)
|
|
| 11 |
+ |
|
| 5 | 12 |
// Listxattr calls syscall listxattr and reads all content |
| 6 | 13 |
// and returns a string array |
| 7 | 14 |
func Listxattr(path string) ([]string, error) {
|
| ... | ... |
@@ -10,4 +10,4 @@ github.com/spf13/pflag 4c012f6dcd9546820e378d0bdda4d8fc772cdfea |
| 10 | 10 |
golang.org/x/crypto 9f005a07e0d31d45e6656d241bb5c0f2efd4bc94 |
| 11 | 11 |
golang.org/x/net a337091b0525af65de94df2eb7e98bd9962dcbe2 |
| 12 | 12 |
golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c |
| 13 |
-golang.org/x/sys 665f6529cca930e27b831a0d1dafffbe1c172924 |
|
| 13 |
+golang.org/x/sys 77b0e4315053a57ed2962443614bdb28db152054 |