zfs_freebsd.go 884 B

123456789101112131415161718192021222324252627282930313233343536
  1. package zfs // import "github.com/docker/docker/daemon/graphdriver/zfs"
  2. import (
  3. "strings"
  4. "github.com/containerd/log"
  5. "github.com/docker/docker/daemon/graphdriver"
  6. "golang.org/x/sys/unix"
  7. )
  8. func checkRootdirFs(rootdir string) error {
  9. var buf unix.Statfs_t
  10. if err := unix.Statfs(rootdir, &buf); err != nil {
  11. return err
  12. }
  13. // on FreeBSD buf.Fstypename contains ['z', 'f', 's', 0 ... ]
  14. if (buf.Fstypename[0] != 122) || (buf.Fstypename[1] != 102) || (buf.Fstypename[2] != 115) || (buf.Fstypename[3] != 0) {
  15. log.G(ctx).WithField("storage-driver", "zfs").Debugf("no zfs dataset found for rootdir '%s'", rootdir)
  16. return graphdriver.ErrPrerequisites
  17. }
  18. return nil
  19. }
  20. const maxlen = 12
  21. func getMountpoint(id string) string {
  22. id, suffix, _ := strings.Cut(id, "-")
  23. id = id[:maxlen]
  24. if suffix != "" {
  25. // preserve filesystem suffix.
  26. id += "-" + suffix
  27. }
  28. return id
  29. }