1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

archive: Detect file changes to capability bits

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
This commit is contained in:
Alexander Larsson 2014-01-17 10:51:59 +01:00
parent c8428d77fd
commit 87ca750cdc

View file

@ -1,6 +1,7 @@
package archive package archive
import ( import (
"bytes"
"code.google.com/p/go/src/pkg/archive/tar" "code.google.com/p/go/src/pkg/archive/tar"
"fmt" "fmt"
"github.com/dotcloud/docker/utils" "github.com/dotcloud/docker/utils"
@ -126,10 +127,11 @@ func Changes(layers []string, rw string) ([]Change, error) {
} }
type FileInfo struct { type FileInfo struct {
parent *FileInfo parent *FileInfo
name string name string
stat syscall.Stat_t stat syscall.Stat_t
children map[string]*FileInfo children map[string]*FileInfo
capability []byte
} }
func (root *FileInfo) LookUp(path string) *FileInfo { func (root *FileInfo) LookUp(path string) *FileInfo {
@ -200,7 +202,8 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {
oldStat.Rdev != newStat.Rdev || oldStat.Rdev != newStat.Rdev ||
// Don't look at size for dirs, its not a good measure of change // Don't look at size for dirs, its not a good measure of change
(oldStat.Size != newStat.Size && oldStat.Mode&syscall.S_IFDIR != syscall.S_IFDIR) || (oldStat.Size != newStat.Size && oldStat.Mode&syscall.S_IFDIR != syscall.S_IFDIR) ||
!sameFsTimeSpec(getLastModification(oldStat), getLastModification(newStat)) { !sameFsTimeSpec(getLastModification(oldStat), getLastModification(newStat)) ||
bytes.Compare(oldChild.capability, newChild.capability) != 0 {
change := Change{ change := Change{
Path: newChild.path(), Path: newChild.path(),
Kind: ChangeModify, Kind: ChangeModify,
@ -275,6 +278,8 @@ func collectFileInfo(sourceDir string) (*FileInfo, error) {
return err return err
} }
info.capability, _ = Lgetxattr(path, "security.capability")
parent.children[info.name] = info parent.children[info.name] = info
return nil return nil