vendor: update github.com/containerd/continuity

Signed-off-by: Edward Pilatowicz <edward.pilatowicz@oracle.com>
This commit is contained in:
Edward Pilatowicz 2017-07-25 16:55:47 -07:00
parent 0fa76584f8
commit 47637f2aa2
29 changed files with 423 additions and 104 deletions

View File

@ -29,7 +29,7 @@ github.com/pkg/errors v0.8.0
github.com/opencontainers/go-digest 21dfd564fd89c944783d00d069f33e3e7123c448 github.com/opencontainers/go-digest 21dfd564fd89c944783d00d069f33e3e7123c448
golang.org/x/sys 739734461d1c916b6c72a63d7efda2b27edb369f https://github.com/golang/sys golang.org/x/sys 739734461d1c916b6c72a63d7efda2b27edb369f https://github.com/golang/sys
github.com/opencontainers/image-spec v1.0.0 github.com/opencontainers/image-spec v1.0.0
github.com/containerd/continuity 86cec1535a968310e7532819f699ff2830ed7463 github.com/containerd/continuity cf279e6ac893682272b4479d4c67fd3abf878b4e
golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c
github.com/BurntSushi/toml v0.2.0-21-g9906417 github.com/BurntSushi/toml v0.2.0-21-g9906417
github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0 github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0

View File

@ -10,10 +10,65 @@ metadata storage.
Please see https://github.com/opencontainers/specs/issues/11 for more details. Please see https://github.com/opencontainers/specs/issues/11 for more details.
## Building Proto Package ## Manifest Format
A continuity manifest encodes filesystem metadata in Protocol Buffers.
Please refer to [proto/manifest.proto](proto/manifest.proto).
## Usage
Build:
```console
$ make
```
Create a manifest (of this repo itself):
```console
$ ./bin/continuity build . > /tmp/a.pb
```
Dump a manifest:
```console
$ ./bin/continuity ls /tmp/a.pb
...
-rw-rw-r-- 270 B /.gitignore
-rw-rw-r-- 88 B /.mailmap
-rw-rw-r-- 187 B /.travis.yml
-rw-rw-r-- 359 B /AUTHORS
-rw-rw-r-- 11 kB /LICENSE
-rw-rw-r-- 1.5 kB /Makefile
...
-rw-rw-r-- 986 B /testutil_test.go
drwxrwxr-x 0 B /version
-rw-rw-r-- 478 B /version/version.go
```
Verify a manifest:
```console
$ ./bin/continuity verify . /tmp/a.pb
```
Break the directory and restore using the manifest:
```console
$ chmod 777 Makefile
$ ./bin/continuity verify . /tmp/a.pb
2017/06/23 08:00:34 error verifying manifest: resource "/Makefile" has incorrect mode: -rwxrwxrwx != -rw-rw-r--
$ ./bin/continuity apply . /tmp/a.pb
$ stat -c %a Makefile
664
$ ./bin/continuity verify . /tmp/a.pb
```
## Contribution Guide
### Building Proto Package
If you change the proto file you will need to rebuild the generated Go with `go generate`. If you change the proto file you will need to rebuild the generated Go with `go generate`.
``` ```console
go generate ./proto $ go generate ./proto
``` ```

View File

@ -9,6 +9,9 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/containerd/continuity/devices"
driverpkg "github.com/containerd/continuity/driver"
"github.com/containerd/continuity/pathdriver"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
) )
@ -35,7 +38,8 @@ type SymlinkPath func(root, linkname, target string) (string, error)
type ContextOptions struct { type ContextOptions struct {
Digester Digester Digester Digester
Driver Driver Driver driverpkg.Driver
PathDriver pathdriver.PathDriver
Provider ContentProvider Provider ContentProvider
} }
@ -43,7 +47,8 @@ type ContextOptions struct {
// Generally, all path qualified access and system considerations should land // Generally, all path qualified access and system considerations should land
// here. // here.
type context struct { type context struct {
driver Driver driver driverpkg.Driver
pathDriver pathdriver.PathDriver
root string root string
digester Digester digester Digester
provider ContentProvider provider ContentProvider
@ -58,14 +63,20 @@ func NewContext(root string) (Context, error) {
// NewContextWithOptions returns a Context associate with the root. // NewContextWithOptions returns a Context associate with the root.
func NewContextWithOptions(root string, options ContextOptions) (Context, error) { func NewContextWithOptions(root string, options ContextOptions) (Context, error) {
// normalize to absolute path // normalize to absolute path
root, err := filepath.Abs(filepath.Clean(root)) pathDriver := options.PathDriver
if pathDriver == nil {
pathDriver = pathdriver.LocalPathDriver
}
root = pathDriver.FromSlash(root)
root, err := pathDriver.Abs(pathDriver.Clean(root))
if err != nil { if err != nil {
return nil, err return nil, err
} }
driver := options.Driver driver := options.Driver
if driver == nil { if driver == nil {
driver, err = NewSystemDriver() driver, err = driverpkg.NewSystemDriver()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -92,6 +103,7 @@ func NewContextWithOptions(root string, options ContextOptions) (Context, error)
return &context{ return &context{
root: root, root: root,
driver: driver, driver: driver,
pathDriver: pathDriver,
digester: digester, digester: digester,
provider: options.Provider, provider: options.Provider,
}, nil }, nil
@ -158,7 +170,7 @@ func (c *context) Resource(p string, fi os.FileInfo) (Resource, error) {
} }
if fi.Mode()&os.ModeDevice != 0 { if fi.Mode()&os.ModeDevice != 0 {
deviceDriver, ok := c.driver.(DeviceInfoDriver) deviceDriver, ok := c.driver.(driverpkg.DeviceInfoDriver)
if !ok { if !ok {
log.Printf("device extraction not supported %s", fp) log.Printf("device extraction not supported %s", fp)
return nil, ErrNotSupported return nil, ErrNotSupported
@ -473,7 +485,7 @@ func (c *context) Apply(resource Resource) error {
} else if (fi.Mode() & os.ModeDevice) == 0 { } else if (fi.Mode() & os.ModeDevice) == 0 {
return fmt.Errorf("%q should be a device, but is not", resource.Path()) return fmt.Errorf("%q should be a device, but is not", resource.Path())
} else { } else {
major, minor, err := deviceInfo(fi) major, minor, err := devices.DeviceInfo(fi)
if err != nil { if err != nil {
return err return err
} }
@ -535,7 +547,7 @@ func (c *context) Apply(resource Resource) error {
// we only set xattres defined by resource but never remove. // we only set xattres defined by resource but never remove.
if _, ok := resource.(SymLink); ok { if _, ok := resource.(SymLink); ok {
lxattrDriver, ok := c.driver.(LXAttrDriver) lxattrDriver, ok := c.driver.(driverpkg.LXAttrDriver)
if !ok { if !ok {
return fmt.Errorf("unsupported symlink xattr for resource %q", resource.Path()) return fmt.Errorf("unsupported symlink xattr for resource %q", resource.Path())
} }
@ -543,7 +555,7 @@ func (c *context) Apply(resource Resource) error {
return err return err
} }
} else { } else {
xattrDriver, ok := c.driver.(XAttrDriver) xattrDriver, ok := c.driver.(driverpkg.XAttrDriver)
if !ok { if !ok {
return fmt.Errorf("unsupported xattr for resource %q", resource.Path()) return fmt.Errorf("unsupported xattr for resource %q", resource.Path())
} }
@ -560,7 +572,7 @@ func (c *context) Apply(resource Resource) error {
// the context. Otherwise identical to filepath.Walk, the path argument is // the context. Otherwise identical to filepath.Walk, the path argument is
// corrected to be contained within the context. // corrected to be contained within the context.
func (c *context) Walk(fn filepath.WalkFunc) error { func (c *context) Walk(fn filepath.WalkFunc) error {
return filepath.Walk(c.root, func(p string, fi os.FileInfo, err error) error { return c.pathDriver.Walk(c.root, func(p string, fi os.FileInfo, err error) error {
contained, err := c.contain(p) contained, err := c.contain(p)
return fn(contained, fi, err) return fn(contained, fi, err)
}) })
@ -569,7 +581,7 @@ func (c *context) Walk(fn filepath.WalkFunc) error {
// fullpath returns the system path for the resource, joined with the context // fullpath returns the system path for the resource, joined with the context
// root. The path p must be a part of the context. // root. The path p must be a part of the context.
func (c *context) fullpath(p string) (string, error) { func (c *context) fullpath(p string) (string, error) {
p = filepath.Join(c.root, p) p = c.pathDriver.Join(c.root, p)
if !strings.HasPrefix(p, c.root) { if !strings.HasPrefix(p, c.root) {
return "", fmt.Errorf("invalid context path") return "", fmt.Errorf("invalid context path")
} }
@ -580,19 +592,19 @@ func (c *context) fullpath(p string) (string, error) {
// contain cleans and santizes the filesystem path p to be an absolute path, // contain cleans and santizes the filesystem path p to be an absolute path,
// effectively relative to the context root. // effectively relative to the context root.
func (c *context) contain(p string) (string, error) { func (c *context) contain(p string) (string, error) {
sanitized, err := filepath.Rel(c.root, p) sanitized, err := c.pathDriver.Rel(c.root, p)
if err != nil { if err != nil {
return "", err return "", err
} }
// ZOMBIES(stevvooe): In certain cases, we may want to remap these to a // ZOMBIES(stevvooe): In certain cases, we may want to remap these to a
// "containment error", so the caller can decide what to do. // "containment error", so the caller can decide what to do.
return filepath.Join("/", filepath.Clean(sanitized)), nil return c.pathDriver.Join("/", c.pathDriver.Clean(sanitized)), nil
} }
// digest returns the digest of the file at path p, relative to the root. // digest returns the digest of the file at path p, relative to the root.
func (c *context) digest(p string) (digest.Digest, error) { func (c *context) digest(p string) (digest.Digest, error) {
f, err := c.driver.Open(filepath.Join(c.root, p)) f, err := c.driver.Open(c.pathDriver.Join(c.root, p))
if err != nil { if err != nil {
return "", err return "", err
} }
@ -606,7 +618,7 @@ func (c *context) digest(p string) (digest.Digest, error) {
// cannot have xattrs, nil will be returned. // cannot have xattrs, nil will be returned.
func (c *context) resolveXAttrs(fp string, fi os.FileInfo, base *resource) (map[string][]byte, error) { func (c *context) resolveXAttrs(fp string, fi os.FileInfo, base *resource) (map[string][]byte, error) {
if fi.Mode().IsRegular() || fi.Mode().IsDir() { if fi.Mode().IsRegular() || fi.Mode().IsDir() {
xattrDriver, ok := c.driver.(XAttrDriver) xattrDriver, ok := c.driver.(driverpkg.XAttrDriver)
if !ok { if !ok {
log.Println("xattr extraction not supported") log.Println("xattr extraction not supported")
return nil, ErrNotSupported return nil, ErrNotSupported
@ -616,7 +628,7 @@ func (c *context) resolveXAttrs(fp string, fi os.FileInfo, base *resource) (map[
} }
if fi.Mode()&os.ModeSymlink != 0 { if fi.Mode()&os.ModeSymlink != 0 {
lxattrDriver, ok := c.driver.(LXAttrDriver) lxattrDriver, ok := c.driver.(driverpkg.LXAttrDriver)
if !ok { if !ok {
log.Println("xattr extraction for symlinks not supported") log.Println("xattr extraction for symlinks not supported")
return nil, ErrNotSupported return nil, ErrNotSupported

View File

@ -0,0 +1,5 @@
package devices
import "fmt"
var ErrNotSupported = fmt.Errorf("not supported")

View File

@ -1,4 +1,4 @@
package continuity package devices
// from /usr/include/sys/types.h // from /usr/include/sys/types.h

View File

@ -0,0 +1,23 @@
// +build solaris,!cgo
//
// Implementing the functions below requires cgo support. Non-cgo stubs
// versions are defined below to enable cross-compilation of source code
// that depends on these functions, but the resultant cross-compiled
// binaries cannot actually be used. If the stub function(s) below are
// actually invoked they will cause the calling process to exit.
//
package devices
func getmajor(dev uint64) uint64 {
panic("getmajor() support requires cgo.")
}
func getminor(dev uint64) uint64 {
panic("getminor() support requires cgo.")
}
func makedev(major int, minor int) int {
panic("makedev() support requires cgo.")
}

View File

@ -1,4 +1,4 @@
package continuity package devices
// from /usr/include/sys/types.h // from /usr/include/sys/types.h

View File

@ -1,4 +1,4 @@
package continuity package devices
// from /usr/include/linux/kdev_t.h // from /usr/include/linux/kdev_t.h

View File

@ -0,0 +1,18 @@
// +build cgo
package devices
//#include <sys/mkdev.h>
import "C"
func getmajor(dev uint64) uint64 {
return uint64(C.major(C.dev_t(dev)))
}
func getminor(dev uint64) uint64 {
return uint64(C.minor(C.dev_t(dev)))
}
func makedev(major int, minor int) int {
return int(C.makedev(C.major_t(major), C.minor_t(minor)))
}

View File

@ -1,6 +1,6 @@
// +build linux darwin freebsd // +build linux darwin freebsd solaris
package continuity package devices
import ( import (
"fmt" "fmt"
@ -8,7 +8,7 @@ import (
"syscall" "syscall"
) )
func deviceInfo(fi os.FileInfo) (uint64, uint64, error) { func DeviceInfo(fi os.FileInfo) (uint64, uint64, error) {
sys, ok := fi.Sys().(*syscall.Stat_t) sys, ok := fi.Sys().(*syscall.Stat_t)
if !ok { if !ok {
return 0, 0, fmt.Errorf("cannot extract device from os.FileInfo") return 0, 0, fmt.Errorf("cannot extract device from os.FileInfo")
@ -18,7 +18,7 @@ func deviceInfo(fi os.FileInfo) (uint64, uint64, error) {
} }
// mknod provides a shortcut for syscall.Mknod // mknod provides a shortcut for syscall.Mknod
func mknod(p string, mode os.FileMode, maj, min int) error { func Mknod(p string, mode os.FileMode, maj, min int) error {
var ( var (
m = syscallMode(mode.Perm()) m = syscallMode(mode.Perm())
dev int dev int

View File

@ -1,4 +1,4 @@
package continuity package devices
import ( import (
"os" "os"
@ -6,6 +6,6 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
func deviceInfo(fi os.FileInfo) (uint64, uint64, error) { func DeviceInfo(fi os.FileInfo) (uint64, uint64, error) {
return 0, 0, errors.Wrap(ErrNotSupported, "cannot get device info on windows") return 0, 0, errors.Wrap(ErrNotSupported, "cannot get device info on windows")
} }

View File

@ -1,9 +1,13 @@
package continuity package driver
import ( import (
"fmt"
"io"
"os" "os"
) )
var ErrNotSupported = fmt.Errorf("not supported")
// Driver provides all of the system-level functions in a common interface. // Driver provides all of the system-level functions in a common interface.
// The context should call these with full paths and should never use the `os` // The context should call these with full paths and should never use the `os`
// package or any other package to access resources on the filesystem. This // package or any other package to access resources on the filesystem. This
@ -15,7 +19,12 @@ import (
// example, it is not required to wrap os.FileInfo to return correct paths for // example, it is not required to wrap os.FileInfo to return correct paths for
// the call to Name(). // the call to Name().
type Driver interface { type Driver interface {
Open(path string) (*os.File, error) // Note that Open() returns a File interface instead of *os.File. This
// is because os.File is a struct, so if Open was to return *os.File,
// the only way to fulfill the interface would be to call os.Open()
Open(path string) (File, error)
OpenFile(path string, flag int, perm os.FileMode) (File, error)
Stat(path string) (os.FileInfo, error) Stat(path string) (os.FileInfo, error)
Lstat(path string) (os.FileInfo, error) Lstat(path string) (os.FileInfo, error)
Readlink(p string) (string, error) Readlink(p string) (string, error)
@ -27,20 +36,22 @@ type Driver interface {
Lchown(path string, uid, gid int64) error Lchown(path string, uid, gid int64) error
Symlink(oldname, newname string) error Symlink(oldname, newname string) error
MkdirAll(path string, perm os.FileMode) error
RemoveAll(path string) error
// TODO(aaronl): These methods might move outside the main Driver // TODO(aaronl): These methods might move outside the main Driver
// interface in the future as more platforms are added. // interface in the future as more platforms are added.
Mknod(path string, mode os.FileMode, major int, minor int) error Mknod(path string, mode os.FileMode, major int, minor int) error
Mkfifo(path string, mode os.FileMode) error Mkfifo(path string, mode os.FileMode) error
}
// NOTE(stevvooe): We may want to actually include the path manipulation // File is the interface for interacting with files returned by continuity's Open
// functions here, as well. They have been listed below to make the // This is needed since os.File is a struct, instead of an interface, so it can't
// discovery process easier. // be used.
type File interface {
// Join(path ...string) string io.ReadWriteCloser
// IsAbs(string) bool io.Seeker
// Abs(string) (string, error) Readdir(n int) ([]os.FileInfo, error)
// Rel(base, target string) (string, error)
// Walk(string, filepath.WalkFunc) error
} }
func NewSystemDriver() (Driver, error) { func NewSystemDriver() (Driver, error) {
@ -90,12 +101,19 @@ type DeviceInfoDriver interface {
// such as xattrs, which can add support at compile time. // such as xattrs, which can add support at compile time.
type driver struct{} type driver struct{}
var _ Driver = &driver{} var _ File = &os.File{}
func (d *driver) Open(p string) (*os.File, error) { // LocalDriver is the exported Driver struct for convenience.
var LocalDriver Driver = &driver{}
func (d *driver) Open(p string) (File, error) {
return os.Open(p) return os.Open(p)
} }
func (d *driver) OpenFile(path string, flag int, perm os.FileMode) (File, error) {
return os.OpenFile(path, flag, perm)
}
func (d *driver) Stat(p string) (os.FileInfo, error) { func (d *driver) Stat(p string) (os.FileInfo, error) {
return os.Stat(p) return os.Stat(p)
} }
@ -134,3 +152,11 @@ func (d *driver) Lchown(name string, uid, gid int64) error {
func (d *driver) Symlink(oldname, newname string) error { func (d *driver) Symlink(oldname, newname string) error {
return os.Symlink(oldname, newname) return os.Symlink(oldname, newname)
} }
func (d *driver) MkdirAll(path string, perm os.FileMode) error {
return os.MkdirAll(path, perm)
}
func (d *driver) RemoveAll(path string) error {
return os.RemoveAll(path)
}

View File

@ -1,6 +1,6 @@
// +build linux darwin freebsd // +build linux darwin freebsd solaris
package continuity package driver
import ( import (
"errors" "errors"
@ -9,11 +9,12 @@ import (
"path/filepath" "path/filepath"
"sort" "sort"
"github.com/containerd/continuity/devices"
"github.com/containerd/continuity/sysx" "github.com/containerd/continuity/sysx"
) )
func (d *driver) Mknod(path string, mode os.FileMode, major, minor int) error { func (d *driver) Mknod(path string, mode os.FileMode, major, minor int) error {
return mknod(path, mode, major, minor) return devices.Mknod(path, mode, major, minor)
} }
func (d *driver) Mkfifo(path string, mode os.FileMode) error { func (d *driver) Mkfifo(path string, mode os.FileMode) error {
@ -22,7 +23,7 @@ func (d *driver) Mkfifo(path string, mode os.FileMode) error {
} }
// mknod with a mode that has ModeNamedPipe set creates a fifo, not a // mknod with a mode that has ModeNamedPipe set creates a fifo, not a
// device. // device.
return mknod(path, mode, 0, 0) return devices.Mknod(path, mode, 0, 0)
} }
// Lchmod changes the mode of an file not following symlinks. // Lchmod changes the mode of an file not following symlinks.
@ -117,5 +118,5 @@ func (d *driver) LSetxattr(path string, attrMap map[string][]byte) error {
} }
func (d *driver) DeviceInfo(fi os.FileInfo) (maj uint64, min uint64, err error) { func (d *driver) DeviceInfo(fi os.FileInfo) (maj uint64, min uint64, err error) {
return deviceInfo(fi) return devices.DeviceInfo(fi)
} }

View File

@ -1,4 +1,4 @@
package continuity package driver
import ( import (
"os" "os"

View File

@ -1,4 +1,4 @@
// +build linux darwin freebsd // +build linux darwin freebsd solaris
package continuity package continuity

View File

@ -0,0 +1,85 @@
package pathdriver
import (
"path/filepath"
)
// PathDriver provides all of the path manipulation functions in a common
// interface. The context should call these and never use the `filepath`
// package or any other package to manipulate paths.
type PathDriver interface {
Join(paths ...string) string
IsAbs(path string) bool
Rel(base, target string) (string, error)
Base(path string) string
Dir(path string) string
Clean(path string) string
Split(path string) (dir, file string)
Separator() byte
Abs(path string) (string, error)
Walk(string, filepath.WalkFunc) error
FromSlash(path string) string
ToSlash(path string) string
Match(pattern, name string) (matched bool, err error)
}
// pathDriver is a simple default implementation calls the filepath package.
type pathDriver struct{}
// LocalPathDriver is the exported pathDriver struct for convenience.
var LocalPathDriver PathDriver = &pathDriver{}
func (*pathDriver) Join(paths ...string) string {
return filepath.Join(paths...)
}
func (*pathDriver) IsAbs(path string) bool {
return filepath.IsAbs(path)
}
func (*pathDriver) Rel(base, target string) (string, error) {
return filepath.Rel(base, target)
}
func (*pathDriver) Base(path string) string {
return filepath.Base(path)
}
func (*pathDriver) Dir(path string) string {
return filepath.Dir(path)
}
func (*pathDriver) Clean(path string) string {
return filepath.Clean(path)
}
func (*pathDriver) Split(path string) (dir, file string) {
return filepath.Split(path)
}
func (*pathDriver) Separator() byte {
return filepath.Separator
}
func (*pathDriver) Abs(path string) (string, error) {
return filepath.Abs(path)
}
// Note that filepath.Walk calls os.Stat, so if the context wants to
// to call Driver.Stat() for Walk, they need to create a new struct that
// overrides this method.
func (*pathDriver) Walk(root string, walkFn filepath.WalkFunc) error {
return filepath.Walk(root, walkFn)
}
func (*pathDriver) FromSlash(path string) string {
return filepath.FromSlash(path)
}
func (*pathDriver) ToSlash(path string) string {
return filepath.ToSlash(path)
}
func (*pathDriver) Match(pattern, name string) (bool, error) {
return filepath.Match(pattern, name)
}

View File

@ -71,7 +71,9 @@ type Resource struct {
// for regular files. // for regular files.
Size uint64 `protobuf:"varint,7,opt,name=size" json:"size,omitempty"` Size uint64 `protobuf:"varint,7,opt,name=size" json:"size,omitempty"`
// Digest specifies the content digest of the target file. Only valid for // Digest specifies the content digest of the target file. Only valid for
// regular files. The strings are formatted as <alg>:<digest hex bytes>. // regular files. The strings are formatted in OCI style, i.e. <alg>:<encoded>.
// For detailed information about the format, please refer to OCI Image Spec:
// https://github.com/opencontainers/image-spec/blob/master/descriptor.md#digests-and-verification
// The digests are sorted in lexical order and implementations may choose // The digests are sorted in lexical order and implementations may choose
// which algorithms they prefer. // which algorithms they prefer.
Digest []string `protobuf:"bytes,8,rep,name=digest" json:"digest,omitempty"` Digest []string `protobuf:"bytes,8,rep,name=digest" json:"digest,omitempty"`

View File

@ -24,8 +24,8 @@ message Resource {
// user and group are not currently used but their field numbers have been // user and group are not currently used but their field numbers have been
// reserved for future use. As such, they are marked as deprecated. // reserved for future use. As such, they are marked as deprecated.
string user = 4 [deprecated=true]; string user = 4 [deprecated=true]; // "deprecated" stands for "reserved" here
string group = 5 [deprecated=true]; string group = 5 [deprecated=true]; // "deprecated" stands for "reserved" here
// Mode defines the file mode and permissions. We've used the same // Mode defines the file mode and permissions. We've used the same
// bit-packing from Go's os package, // bit-packing from Go's os package,
@ -40,7 +40,9 @@ message Resource {
uint64 size = 7; uint64 size = 7;
// Digest specifies the content digest of the target file. Only valid for // Digest specifies the content digest of the target file. Only valid for
// regular files. The strings are formatted as <alg>:<digest hex bytes>. // regular files. The strings are formatted in OCI style, i.e. <alg>:<encoded>.
// For detailed information about the format, please refer to OCI Image Spec:
// https://github.com/opencontainers/image-spec/blob/master/descriptor.md#digests-and-verification
// The digests are sorted in lexical order and implementations may choose // The digests are sorted in lexical order and implementations may choose
// which algorithms they prefer. // which algorithms they prefer.
repeated string digest = 8; repeated string digest = 8;

View File

@ -1,4 +1,4 @@
// +build linux darwin freebsd // +build linux darwin freebsd solaris
package continuity package continuity

View File

@ -0,0 +1,11 @@
package sysx
import "golang.org/x/sys/unix"
const (
AtSymlinkNofollow = unix.AT_SYMLINK_NOFOLLOW
)
func Fchmodat(dirfd int, path string, mode uint32, flags int) error {
return unix.Fchmodat(dirfd, path, mode, flags)
}

View File

@ -5,5 +5,7 @@ package sysx
// $ GOOS=linux GOARCH=amd64 ./generate.sh copy // $ GOOS=linux GOARCH=amd64 ./generate.sh copy
// $ GOOS=linux GOARCH=arm ./generate.sh copy // $ GOOS=linux GOARCH=arm ./generate.sh copy
// $ GOOS=linux GOARCH=arm64 ./generate.sh copy // $ GOOS=linux GOARCH=arm64 ./generate.sh copy
// $ GOOS=linux GOARCH=ppc64le ./generate.sh copy
// $ GOOS=linux GOARCH=s390x ./generate.sh copy
//sys CopyFileRange(fdin uintptr, offin *int64, fdout uintptr, offout *int64, len int, flags int) (n int, err error) //sys CopyFileRange(fdin uintptr, offin *int64, fdout uintptr, offout *int64, len int, flags int) (n int, err error)

View File

@ -0,0 +1,20 @@
// mksyscall.pl copy_linux.go
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package sysx
import (
"syscall"
"unsafe"
)
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func CopyFileRange(fdin uintptr, offin *int64, fdout uintptr, offout *int64, len int, flags int) (n int, err error) {
r0, _, e1 := syscall.Syscall6(SYS_COPY_FILE_RANGE, uintptr(fdin), uintptr(unsafe.Pointer(offin)), uintptr(fdout), uintptr(unsafe.Pointer(offout)), uintptr(len), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -0,0 +1,20 @@
// mksyscall.pl copy_linux.go
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package sysx
import (
"syscall"
"unsafe"
)
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func CopyFileRange(fdin uintptr, offin *int64, fdout uintptr, offout *int64, len int, flags int) (n int, err error) {
r0, _, e1 := syscall.Syscall6(SYS_COPY_FILE_RANGE, uintptr(fdin), uintptr(unsafe.Pointer(offin)), uintptr(fdout), uintptr(unsafe.Pointer(offout)), uintptr(len), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -0,0 +1,8 @@
package sysx
import (
"syscall"
)
// This should actually be a set that contains ENOENT and EPERM
const ENODATA = syscall.ENOENT

View File

@ -0,0 +1,7 @@
package sysx
const (
// SYS_COPYFILERANGE defined in Kernel 4.5+
// Number defined in /usr/include/asm/unistd_64.h
SYS_COPY_FILE_RANGE = 379
)

View File

@ -0,0 +1,7 @@
package sysx
const (
// SYS_COPYFILERANGE defined in Kernel 4.5+
// Number defined in /usr/include/asm/unistd_64.h
SYS_COPY_FILE_RANGE = 375
)

View File

@ -9,45 +9,4 @@ import (
// it is also not widely used. It is not exposed at all by the // it is also not widely used. It is not exposed at all by the
// Go syscall package, so we need to implement directly eventually. // Go syscall package, so we need to implement directly eventually.
var unsupported error = errors.New("extended attributes unsupported on FreeBSD") var unsupported = errors.New("extended attributes unsupported on FreeBSD")
// Listxattr calls syscall listxattr and reads all content
// and returns a string array
func Listxattr(path string) ([]string, error) {
return []string{}, nil
}
// Removexattr calls syscall removexattr
func Removexattr(path string, attr string) (err error) {
return unsupported
}
// Setxattr calls syscall setxattr
func Setxattr(path string, attr string, data []byte, flags int) (err error) {
return unsupported
}
// Getxattr calls syscall getxattr
func Getxattr(path, attr string) ([]byte, error) {
return []byte{}, nil
}
// LListxattr lists xattrs, not following symlinks
func LListxattr(path string) ([]string, error) {
return []string{}, nil
}
// LRemovexattr removes an xattr, not following symlinks
func LRemovexattr(path string, attr string) (err error) {
return unsupported
}
// LSetxattr sets an xattr, not following symlinks
func LSetxattr(path string, attr string, data []byte, flags int) (err error) {
return unsupported
}
// LGetxattr gets an xattr, not following symlinks
func LGetxattr(path, attr string) ([]byte, error) {
return []byte{}, nil
}

View File

@ -0,0 +1,12 @@
package sysx
import (
"errors"
)
// Initial stub version for Solaris. Solaris has a different
// syscall API from Darwin and Linux for extended attributes;
// it is also not widely used. It is not exposed at all by the
// Go syscall package, so we need to implement directly eventually.
var unsupported = errors.New("extended attributes unsupported on Solaris")

View File

@ -0,0 +1,44 @@
// +build freebsd solaris
package sysx
// Listxattr calls syscall listxattr and reads all content
// and returns a string array
func Listxattr(path string) ([]string, error) {
return []string{}, nil
}
// Removexattr calls syscall removexattr
func Removexattr(path string, attr string) (err error) {
return unsupported
}
// Setxattr calls syscall setxattr
func Setxattr(path string, attr string, data []byte, flags int) (err error) {
return unsupported
}
// Getxattr calls syscall getxattr
func Getxattr(path, attr string) ([]byte, error) {
return []byte{}, unsupported
}
// LListxattr lists xattrs, not following symlinks
func LListxattr(path string) ([]string, error) {
return []string{}, nil
}
// LRemovexattr removes an xattr, not following symlinks
func LRemovexattr(path string, attr string) (err error) {
return unsupported
}
// LSetxattr sets an xattr, not following symlinks
func LSetxattr(path string, attr string, data []byte, flags int) (err error) {
return unsupported
}
// LGetxattr gets an xattr, not following symlinks
func LGetxattr(path, attr string) ([]byte, error) {
return []byte{}, nil
}