Add the methods to the Driver interface
to force the drivers to implement the methods
| ... | ... |
@@ -210,11 +210,7 @@ func (a *AufsDriver) Diff(id string) (archive.Archive, error) {
|
| 210 | 210 |
|
| 211 | 211 |
// Returns the size of the contents for the id |
| 212 | 212 |
func (a *AufsDriver) DiffSize(id string) (int64, error) {
|
| 213 |
- p, err := a.Get(id) |
|
| 214 |
- if err != nil {
|
|
| 215 |
- return -1, err |
|
| 216 |
- } |
|
| 217 |
- return utils.TreeSize(p) |
|
| 213 |
+ return utils.TreeSize(path.Join(a.rootPath(), "diff", id)) |
|
| 218 | 214 |
} |
| 219 | 215 |
|
| 220 | 216 |
func (a *AufsDriver) Changes(id string) ([]archive.Change, error) {
|
| ... | ... |
@@ -1479,10 +1479,13 @@ func validateID(id string) error {
|
| 1479 | 1479 |
|
| 1480 | 1480 |
// GetSize, return real size, virtual size |
| 1481 | 1481 |
func (container *Container) GetSize() (int64, int64) {
|
| 1482 |
- var sizeRw, sizeRootfs int64 |
|
| 1482 |
+ var ( |
|
| 1483 |
+ sizeRw, sizeRootfs int64 |
|
| 1484 |
+ err error |
|
| 1485 |
+ driver = container.runtime.driver |
|
| 1486 |
+ ) |
|
| 1483 | 1487 |
|
| 1484 |
- driver := container.runtime.driver |
|
| 1485 |
- sizeRw, err := driver.DiffSize(container.ID) |
|
| 1488 |
+ sizeRw, err = driver.DiffSize(container.ID) |
|
| 1486 | 1489 |
if err != nil {
|
| 1487 | 1490 |
utils.Errorf("Warning: driver %s couldn't return diff size of container %s: %s", driver, container.ID, err)
|
| 1488 | 1491 |
// FIXME: GetSize should return an error. Not changing it now in case |
| ... | ... |
@@ -2,6 +2,7 @@ package devmapper |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 |
+ "github.com/dotcloud/docker/archive" |
|
| 5 | 6 |
"github.com/dotcloud/docker/graphdriver" |
| 6 | 7 |
"os" |
| 7 | 8 |
"path" |
| ... | ... |
@@ -60,6 +61,14 @@ func (d *Driver) DiffSize(id string) (int64, error) {
|
| 60 | 60 |
return -1, fmt.Errorf("Not implemented")
|
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 |
+func (d *Driver) Diff(id string) (archive.Archive, error) {
|
|
| 64 |
+ return nil, fmt.Errorf("Not implemented)")
|
|
| 65 |
+} |
|
| 66 |
+ |
|
| 67 |
+func (d *Driver) Changes(id string) ([]archive.Change, error) {
|
|
| 68 |
+ return nil, fmt.Errorf("asdlfj)")
|
|
| 69 |
+} |
|
| 70 |
+ |
|
| 63 | 71 |
func (d *Driver) mount(id, mp string) error {
|
| 64 | 72 |
// Create the target directories if they don't exist |
| 65 | 73 |
if err := os.MkdirAll(mp, 0755); err != nil && !os.IsExist(err) {
|
| ... | ... |
@@ -17,16 +17,10 @@ type Driver interface {
|
| 17 | 17 |
Get(id string) (dir string, err error) |
| 18 | 18 |
|
| 19 | 19 |
DiffSize(id string) (bytes int64, err error) |
| 20 |
- |
|
| 21 |
- Cleanup() error |
|
| 22 |
-} |
|
| 23 |
- |
|
| 24 |
-type Changer interface {
|
|
| 20 |
+ Diff(id string) (archive.Archive, error) |
|
| 25 | 21 |
Changes(id string) ([]archive.Change, error) |
| 26 |
-} |
|
| 27 | 22 |
|
| 28 |
-type Differ interface {
|
|
| 29 |
- Diff(id string) (archive.Archive, error) |
|
| 23 |
+ Cleanup() error |
|
| 30 | 24 |
} |
| 31 | 25 |
|
| 32 | 26 |
var ( |
| ... | ... |
@@ -76,3 +76,11 @@ func (d *Driver) Get(id string) (string, error) {
|
| 76 | 76 |
func (d *Driver) DiffSize(id string) (int64, error) {
|
| 77 | 77 |
return -1, fmt.Errorf("Not implemented")
|
| 78 | 78 |
} |
| 79 |
+ |
|
| 80 |
+func (d *Driver) Diff(id string) (archive.Archive, error) {
|
|
| 81 |
+ return nil, fmt.Errorf("Not implemented)")
|
|
| 82 |
+} |
|
| 83 |
+ |
|
| 84 |
+func (d *Driver) Changes(id string) ([]archive.Change, error) {
|
|
| 85 |
+ return nil, fmt.Errorf("asdlfj)")
|
|
| 86 |
+} |
| ... | ... |
@@ -18,7 +18,6 @@ import ( |
| 18 | 18 |
"os" |
| 19 | 19 |
"os/exec" |
| 20 | 20 |
"path" |
| 21 |
- "path/filepath" |
|
| 22 | 21 |
"sort" |
| 23 | 22 |
"strings" |
| 24 | 23 |
"time" |
| ... | ... |
@@ -734,49 +733,13 @@ func (runtime *Runtime) Unmount(container *Container) error {
|
| 734 | 734 |
} |
| 735 | 735 |
|
| 736 | 736 |
func (runtime *Runtime) Changes(container *Container) ([]archive.Change, error) {
|
| 737 |
- if changer, ok := runtime.driver.(graphdriver.Changer); ok {
|
|
| 738 |
- return changer.Changes(container.ID) |
|
| 739 |
- } |
|
| 740 |
- cDir, err := runtime.driver.Get(container.ID) |
|
| 741 |
- if err != nil {
|
|
| 742 |
- return nil, fmt.Errorf("Error getting container rootfs %s from driver %s: %s", container.ID, container.runtime.driver, err)
|
|
| 743 |
- } |
|
| 744 |
- initDir, err := runtime.driver.Get(container.ID + "-init") |
|
| 745 |
- if err != nil {
|
|
| 746 |
- return nil, fmt.Errorf("Error getting container init rootfs %s from driver %s: %s", container.ID, container.runtime.driver, err)
|
|
| 747 |
- } |
|
| 748 |
- return archive.ChangesDirs(cDir, initDir) |
|
| 737 |
+ // FIXME: Remove Changes method from runtime |
|
| 738 |
+ return runtime.driver.Changes(container.ID) |
|
| 749 | 739 |
} |
| 750 | 740 |
|
| 751 | 741 |
func (runtime *Runtime) Diff(container *Container) (archive.Archive, error) {
|
| 752 |
- if differ, ok := runtime.driver.(graphdriver.Differ); ok {
|
|
| 753 |
- return differ.Diff(container.ID) |
|
| 754 |
- } |
|
| 755 |
- |
|
| 756 |
- changes, err := runtime.Changes(container) |
|
| 757 |
- if err != nil {
|
|
| 758 |
- return nil, err |
|
| 759 |
- } |
|
| 760 |
- |
|
| 761 |
- cDir, err := runtime.driver.Get(container.ID) |
|
| 762 |
- if err != nil {
|
|
| 763 |
- return nil, fmt.Errorf("Error getting container rootfs %s from driver %s: %s", container.ID, container.runtime.driver, err)
|
|
| 764 |
- } |
|
| 765 |
- |
|
| 766 |
- files := make([]string, 0) |
|
| 767 |
- deletions := make([]string, 0) |
|
| 768 |
- for _, change := range changes {
|
|
| 769 |
- if change.Kind == archive.ChangeModify || change.Kind == archive.ChangeAdd {
|
|
| 770 |
- files = append(files, change.Path) |
|
| 771 |
- } |
|
| 772 |
- if change.Kind == archive.ChangeDelete {
|
|
| 773 |
- base := filepath.Base(change.Path) |
|
| 774 |
- dir := filepath.Dir(change.Path) |
|
| 775 |
- deletions = append(deletions, filepath.Join(dir, ".wh."+base)) |
|
| 776 |
- } |
|
| 777 |
- } |
|
| 778 |
- |
|
| 779 |
- return archive.TarFilter(cDir, archive.Uncompressed, files, false, deletions) |
|
| 742 |
+ // FIXME: Remove Diff method from runtime |
|
| 743 |
+ return runtime.driver.Diff(container.ID) |
|
| 780 | 744 |
} |
| 781 | 745 |
|
| 782 | 746 |
func linkLxcStart(root string) error {
|