github.com/vvnotw/moby@v1.13.1/daemon/getsize_unix.go (about) 1 // +build linux freebsd solaris 2 3 package daemon 4 5 import ( 6 "github.com/Sirupsen/logrus" 7 "github.com/docker/docker/container" 8 ) 9 10 // getSize returns the real size & virtual size of the container. 11 func (daemon *Daemon) getSize(container *container.Container) (int64, int64) { 12 var ( 13 sizeRw, sizeRootfs int64 14 err error 15 ) 16 17 if err := daemon.Mount(container); err != nil { 18 logrus.Errorf("Failed to compute size of container rootfs %s: %s", container.ID, err) 19 return sizeRw, sizeRootfs 20 } 21 defer daemon.Unmount(container) 22 23 sizeRw, err = container.RWLayer.Size() 24 if err != nil { 25 logrus.Errorf("Driver %s couldn't return diff size of container %s: %s", 26 daemon.GraphDriverName(), container.ID, err) 27 // FIXME: GetSize should return an error. Not changing it now in case 28 // there is a side-effect. 29 sizeRw = -1 30 } 31 32 if parent := container.RWLayer.Parent(); parent != nil { 33 sizeRootfs, err = parent.Size() 34 if err != nil { 35 sizeRootfs = -1 36 } else if sizeRw != -1 { 37 sizeRootfs += sizeRw 38 } 39 } 40 return sizeRw, sizeRootfs 41 }