Skip to content

Commit

Permalink
Merge pull request #8802 from jlhawn/vfs_copydir_use_archive_copywithtar
Browse files Browse the repository at this point in the history
Use archive.CopyWithTar in vfs.Create
  • Loading branch information
unclejack committed Oct 27, 2014
2 parents 55702ae + b6db23c commit 039f225
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions daemon/graphdriver/vfs/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path"

"github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/pkg/archive"
"github.com/docker/libcontainer/label"
)

Expand Down Expand Up @@ -46,21 +47,6 @@ func isGNUcoreutils() bool {
return false
}

func copyDir(src, dst string) error {
argv := make([]string, 0, 4)

if isGNUcoreutils() {
argv = append(argv, "-aT", "--reflink=auto", src, dst)
} else {
argv = append(argv, "-a", src+"/.", dst+"/.")
}

if output, err := exec.Command("cp", argv...).CombinedOutput(); err != nil {
return fmt.Errorf("Error VFS copying directory: %s (%s)", err, output)
}
return nil
}

func (d *Driver) Create(id, parent string) error {
dir := d.dir(id)
if err := os.MkdirAll(path.Dir(dir), 0700); err != nil {
Expand All @@ -80,7 +66,7 @@ func (d *Driver) Create(id, parent string) error {
if err != nil {
return fmt.Errorf("%s: %s", parent, err)
}
if err := copyDir(parentDir, dir); err != nil {
if err := archive.CopyWithTar(parentDir, dir); err != nil {
return err
}
return nil
Expand Down

0 comments on commit 039f225

Please sign in to comment.