
To allow the querying of usage for snapshots, we define a new method on the snapshotter to query the resources in use by a single snapshot. Conversely, it can be said that if the snapshot was deleted, the reported amount of usage would be recovered. There are few problems with this model in the implementation of btrfs that need to be worked out. In btrfs, it is hard to resolve the amount of data usage with the use of quotas but these may report valuables that are incompatible with the model. Signed-off-by: Stephen J Day <stephen.day@docker.com>
34 lines
483 B
Go
34 lines
483 B
Go
// +build windows
|
|
|
|
package fs
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func diskUsage(roots ...string) (Usage, error) {
|
|
var (
|
|
size int64
|
|
)
|
|
|
|
// TODO(stevvooe): Support inodes (or equivalent) for windows.
|
|
|
|
for _, root := range roots {
|
|
if err := filepath.Walk(root, func(path string, fi os.FileInfo, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
size += fi.Size()
|
|
return nil
|
|
}); err != nil {
|
|
return Usage{}, err
|
|
}
|
|
}
|
|
|
|
return Usage{
|
|
Size: size,
|
|
}, nil
|
|
}
|