du.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. Copyright The containerd Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package fs
  14. import "context"
  15. // Usage of disk information
  16. type Usage struct {
  17. Inodes int64
  18. Size int64
  19. }
  20. // DiskUsage counts the number of inodes and disk usage for the resources under
  21. // path.
  22. func DiskUsage(ctx context.Context, roots ...string) (Usage, error) {
  23. return diskUsage(ctx, roots...)
  24. }
  25. // DiffUsage counts the numbers of inodes and disk usage in the
  26. // diff between the 2 directories. The first path is intended
  27. // as the base directory and the second as the changed directory.
  28. func DiffUsage(ctx context.Context, a, b string) (Usage, error) {
  29. return diffUsage(ctx, a, b)
  30. }