2015-11-18 17:15:00 -05:00
|
|
|
package layer
|
|
|
|
|
|
|
|
import "io"
|
|
|
|
|
|
|
|
type mountedLayer struct {
|
|
|
|
name string
|
|
|
|
mountID string
|
|
|
|
initID string
|
|
|
|
parent *roLayer
|
|
|
|
path string
|
|
|
|
layerStore *layerStore
|
|
|
|
activityCount int
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ml *mountedLayer) cacheParent() string {
|
|
|
|
if ml.initID != "" {
|
|
|
|
return ml.initID
|
|
|
|
}
|
|
|
|
if ml.parent != nil {
|
|
|
|
return ml.parent.cacheID
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2015-11-25 19:39:54 -05:00
|
|
|
func (ml *mountedLayer) TarStream() (io.ReadCloser, error) {
|
2015-11-18 17:15:00 -05:00
|
|
|
archiver, err := ml.layerStore.driver.Diff(ml.mountID, ml.cacheParent())
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2015-11-25 19:39:54 -05:00
|
|
|
return archiver, nil
|
2015-11-18 17:15:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ml *mountedLayer) Path() (string, error) {
|
|
|
|
if ml.path == "" {
|
|
|
|
return "", ErrNotMounted
|
|
|
|
}
|
|
|
|
return ml.path, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ml *mountedLayer) Parent() Layer {
|
|
|
|
if ml.parent != nil {
|
|
|
|
return ml.parent
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return a nil interface instead of an interface wrapping a nil
|
|
|
|
// pointer.
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ml *mountedLayer) Size() (int64, error) {
|
|
|
|
return ml.layerStore.driver.DiffSize(ml.mountID, ml.cacheParent())
|
|
|
|
}
|