mirror of
https://github.com/containers/podman.git
synced 2025-12-03 19:59:39 +08:00
Add support for image name history
We leverage the containers/storage image history tracking feature to show the previously used image names when running: `podman images --history` Signed-off-by: Sascha Grunert <sgrunert@suse.com>
This commit is contained in:
29
vendor/github.com/containers/storage/pkg/archive/archive.go
generated
vendored
29
vendor/github.com/containers/storage/pkg/archive/archive.go
generated
vendored
@@ -387,7 +387,10 @@ func fillGo18FileTypeBits(mode int64, fi os.FileInfo) int64 {
|
||||
// ReadSecurityXattrToTarHeader reads security.capability xattr from filesystem
|
||||
// to a tar header
|
||||
func ReadSecurityXattrToTarHeader(path string, hdr *tar.Header) error {
|
||||
capability, _ := system.Lgetxattr(path, "security.capability")
|
||||
capability, err := system.Lgetxattr(path, "security.capability")
|
||||
if err != nil && err != system.EOPNOTSUPP {
|
||||
return err
|
||||
}
|
||||
if capability != nil {
|
||||
hdr.Xattrs = make(map[string]string)
|
||||
hdr.Xattrs["security.capability"] = string(capability)
|
||||
@@ -395,6 +398,27 @@ func ReadSecurityXattrToTarHeader(path string, hdr *tar.Header) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReadUserXattrToTarHeader reads user.* xattr from filesystem to a tar header
|
||||
func ReadUserXattrToTarHeader(path string, hdr *tar.Header) error {
|
||||
xattrs, err := system.Llistxattr(path)
|
||||
if err != nil && err != system.EOPNOTSUPP {
|
||||
return err
|
||||
}
|
||||
for _, key := range xattrs {
|
||||
if strings.HasPrefix(key, "user.") {
|
||||
value, err := system.Lgetxattr(path, key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if hdr.Xattrs == nil {
|
||||
hdr.Xattrs = make(map[string]string)
|
||||
}
|
||||
hdr.Xattrs[key] = string(value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type tarWhiteoutConverter interface {
|
||||
ConvertWrite(*tar.Header, string, os.FileInfo) (*tar.Header, error)
|
||||
ConvertRead(*tar.Header, string) (bool, error)
|
||||
@@ -469,6 +493,9 @@ func (ta *tarAppender) addTarFile(path, name string) error {
|
||||
if err := ReadSecurityXattrToTarHeader(path, hdr); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ReadUserXattrToTarHeader(path, hdr); err != nil {
|
||||
return err
|
||||
}
|
||||
if ta.CopyPass {
|
||||
copyPassHeader(hdr)
|
||||
}
|
||||
|
||||
5
vendor/github.com/containers/storage/pkg/archive/changes.go
generated
vendored
5
vendor/github.com/containers/storage/pkg/archive/changes.go
generated
vendored
@@ -8,6 +8,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"syscall"
|
||||
@@ -263,6 +264,7 @@ type FileInfo struct {
|
||||
children map[string]*FileInfo
|
||||
capability []byte
|
||||
added bool
|
||||
xattrs map[string]string
|
||||
}
|
||||
|
||||
// LookUp looks up the file information of a file.
|
||||
@@ -331,7 +333,8 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {
|
||||
// breaks down is if some code intentionally hides a change by setting
|
||||
// back mtime
|
||||
if statDifferent(oldStat, oldInfo, newStat, info) ||
|
||||
!bytes.Equal(oldChild.capability, newChild.capability) {
|
||||
!bytes.Equal(oldChild.capability, newChild.capability) ||
|
||||
!reflect.DeepEqual(oldChild.xattrs, newChild.xattrs) {
|
||||
change := Change{
|
||||
Path: newChild.path(),
|
||||
Kind: ChangeModify,
|
||||
|
||||
22
vendor/github.com/containers/storage/pkg/archive/changes_linux.go
generated
vendored
22
vendor/github.com/containers/storage/pkg/archive/changes_linux.go
generated
vendored
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
@@ -83,7 +84,26 @@ func walkchunk(path string, fi os.FileInfo, dir string, root *FileInfo) error {
|
||||
return err
|
||||
}
|
||||
info.stat = stat
|
||||
info.capability, _ = system.Lgetxattr(cpath, "security.capability") // lgetxattr(2): fs access
|
||||
info.capability, err = system.Lgetxattr(cpath, "security.capability") // lgetxattr(2): fs access
|
||||
if err != nil && err != system.EOPNOTSUPP {
|
||||
return err
|
||||
}
|
||||
xattrs, err := system.Llistxattr(cpath)
|
||||
if err != nil && err != system.EOPNOTSUPP {
|
||||
return err
|
||||
}
|
||||
for _, key := range xattrs {
|
||||
if strings.HasPrefix(key, "user.") {
|
||||
value, err := system.Lgetxattr(cpath, key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info.xattrs == nil {
|
||||
info.xattrs = make(map[string]string)
|
||||
}
|
||||
info.xattrs[key] = string(value)
|
||||
}
|
||||
}
|
||||
parent.children[info.name] = info
|
||||
return nil
|
||||
}
|
||||
|
||||
41
vendor/github.com/containers/storage/pkg/system/xattrs_linux.go
generated
vendored
41
vendor/github.com/containers/storage/pkg/system/xattrs_linux.go
generated
vendored
@@ -1,6 +1,16 @@
|
||||
package system
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
import (
|
||||
"bytes"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const (
|
||||
// Operation not supported
|
||||
EOPNOTSUPP syscall.Errno = unix.EOPNOTSUPP
|
||||
)
|
||||
|
||||
// Lgetxattr retrieves the value of the extended attribute identified by attr
|
||||
// and associated with the given path in the file system.
|
||||
@@ -27,3 +37,32 @@ func Lgetxattr(path string, attr string) ([]byte, error) {
|
||||
func Lsetxattr(path string, attr string, data []byte, flags int) error {
|
||||
return unix.Lsetxattr(path, attr, data, flags)
|
||||
}
|
||||
|
||||
// Llistxattr lists extended attributes associated with the given path
|
||||
// in the file system.
|
||||
func Llistxattr(path string) ([]string, error) {
|
||||
var dest []byte
|
||||
|
||||
for {
|
||||
sz, err := unix.Llistxattr(path, dest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if sz > len(dest) {
|
||||
dest = make([]byte, sz)
|
||||
} else {
|
||||
dest = dest[:sz]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var attrs []string
|
||||
for _, token := range bytes.Split(dest, []byte{0}) {
|
||||
if len(token) > 0 {
|
||||
attrs = append(attrs, string(token))
|
||||
}
|
||||
}
|
||||
|
||||
return attrs, nil
|
||||
}
|
||||
|
||||
12
vendor/github.com/containers/storage/pkg/system/xattrs_unsupported.go
generated
vendored
12
vendor/github.com/containers/storage/pkg/system/xattrs_unsupported.go
generated
vendored
@@ -2,6 +2,13 @@
|
||||
|
||||
package system
|
||||
|
||||
import "syscall"
|
||||
|
||||
const (
|
||||
// Operation not supported
|
||||
EOPNOTSUPP syscall.Errno = syscall.Errno(0)
|
||||
)
|
||||
|
||||
// Lgetxattr is not supported on platforms other than linux.
|
||||
func Lgetxattr(path string, attr string) ([]byte, error) {
|
||||
return nil, ErrNotSupportedPlatform
|
||||
@@ -11,3 +18,8 @@ func Lgetxattr(path string, attr string) ([]byte, error) {
|
||||
func Lsetxattr(path string, attr string, data []byte, flags int) error {
|
||||
return ErrNotSupportedPlatform
|
||||
}
|
||||
|
||||
// Llistxattr is not supported on platforms other than linux.
|
||||
func Llistxattr(path string) ([]string, error) {
|
||||
return nil, ErrNotSupportedPlatform
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user