mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
cp's -T and --reflink=auto are only available on GNU coreutils
Docker-DCO-1.1-Signed-off-by: Kato Kazuyoshi <kato.kazuyoshi@gmail.com> (github: kzys)
This commit is contained in:
parent
f1ac8962f9
commit
733711481e
1 changed files with 18 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
package vfs
|
package vfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/daemon/graphdriver"
|
"github.com/dotcloud/docker/daemon/graphdriver"
|
||||||
"os"
|
"os"
|
||||||
|
@ -35,8 +36,24 @@ func (d *Driver) Cleanup() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isGNUcoreutils() bool {
|
||||||
|
if stdout, err := exec.Command("cp", "--version").Output(); err == nil {
|
||||||
|
return bytes.Contains(stdout, []byte("GNU coreutils"))
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func copyDir(src, dst string) error {
|
func copyDir(src, dst string) error {
|
||||||
if output, err := exec.Command("cp", "-aT", "--reflink=auto", src, dst).CombinedOutput(); err != nil {
|
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 fmt.Errorf("Error VFS copying directory: %s (%s)", err, output)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Add table
Reference in a new issue