| ... | ... |
@@ -582,7 +582,7 @@ func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) {
|
| 582 | 582 |
return nil, err |
| 583 | 583 |
} |
| 584 | 584 |
|
| 585 |
- if err := copyLxcStart(config.Root); err != nil {
|
|
| 585 |
+ if err := linkLxcStart(config.Root); err != nil {
|
|
| 586 | 586 |
return nil, err |
| 587 | 587 |
} |
| 588 | 588 |
g, err := NewGraph(path.Join(config.Root, "graph")) |
| ... | ... |
@@ -647,25 +647,21 @@ func (runtime *Runtime) Close() error {
|
| 647 | 647 |
return runtime.containerGraph.Close() |
| 648 | 648 |
} |
| 649 | 649 |
|
| 650 |
-func copyLxcStart(root string) error {
|
|
| 650 |
+func linkLxcStart(root string) error {
|
|
| 651 | 651 |
sourcePath, err := exec.LookPath("lxc-start")
|
| 652 | 652 |
if err != nil {
|
| 653 | 653 |
return err |
| 654 | 654 |
} |
| 655 | 655 |
targetPath := path.Join(root, "lxc-start-unconfined") |
| 656 |
- sourceFile, err := os.Open(sourcePath) |
|
| 657 |
- if err != nil {
|
|
| 658 |
- return err |
|
| 659 |
- } |
|
| 660 |
- defer sourceFile.Close() |
|
| 661 |
- targetFile, err := os.Create(targetPath) |
|
| 662 |
- if err != nil {
|
|
| 656 |
+ |
|
| 657 |
+ if _, err := os.Stat(targetPath); err != nil && !os.IsNotExist(err) {
|
|
| 663 | 658 |
return err |
| 659 |
+ } else if err == nil {
|
|
| 660 |
+ if err := os.Remove(targetPath); err != nil {
|
|
| 661 |
+ return err |
|
| 662 |
+ } |
|
| 664 | 663 |
} |
| 665 |
- defer targetFile.Close() |
|
| 666 |
- os.Chmod(targetPath, 0755) |
|
| 667 |
- _, err = io.Copy(targetFile, sourceFile) |
|
| 668 |
- return err |
|
| 664 |
+ return os.Symlink(sourcePath, targetPath) |
|
| 669 | 665 |
} |
| 670 | 666 |
|
| 671 | 667 |
// History is a convenience type for storing a list of containers, |