github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/daemon/images/image_unix.go (about) 1 //go:build linux || freebsd 2 // +build linux freebsd 3 4 package images // import "github.com/docker/docker/daemon/images" 5 6 import ( 7 "github.com/docker/docker/image" 8 "github.com/docker/docker/layer" 9 "github.com/sirupsen/logrus" 10 ) 11 12 // GetLayerFolders returns the layer folders from an image RootFS 13 func (i *ImageService) GetLayerFolders(img *image.Image, rwLayer layer.RWLayer) ([]string, error) { 14 // Windows specific 15 panic("not implemented") 16 } 17 18 // GetContainerLayerSize returns the real size & virtual size of the container. 19 func (i *ImageService) GetContainerLayerSize(containerID string) (int64, int64) { 20 var ( 21 sizeRw, sizeRootfs int64 22 err error 23 ) 24 25 // Safe to index by runtime.GOOS as Unix hosts don't support multiple 26 // container operating systems. 27 rwlayer, err := i.layerStore.GetRWLayer(containerID) 28 if err != nil { 29 logrus.Errorf("Failed to compute size of container rootfs %v: %v", containerID, err) 30 return sizeRw, sizeRootfs 31 } 32 defer i.layerStore.ReleaseRWLayer(rwlayer) 33 34 sizeRw, err = rwlayer.Size() 35 if err != nil { 36 logrus.Errorf("Driver %s couldn't return diff size of container %s: %s", 37 i.layerStore.DriverName(), containerID, err) 38 // FIXME: GetSize should return an error. Not changing it now in case 39 // there is a side-effect. 40 sizeRw = -1 41 } 42 43 if parent := rwlayer.Parent(); parent != nil { 44 sizeRootfs = parent.Size() 45 if sizeRw != -1 { 46 sizeRootfs += sizeRw 47 } 48 } 49 return sizeRw, sizeRootfs 50 }