github.com/giuseppe/storage@v1.12.13/drivers/zfs/zfs_freebsd.go (about) 1 package zfs 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/containers/storage/drivers" 8 "github.com/pkg/errors" 9 "github.com/sirupsen/logrus" 10 "golang.org/x/sys/unix" 11 ) 12 13 func checkRootdirFs(rootdir string) error { 14 var buf unix.Statfs_t 15 if err := unix.Statfs(rootdir, &buf); err != nil { 16 return fmt.Errorf("Failed to access '%s': %s", rootdir, err) 17 } 18 19 // on FreeBSD buf.Fstypename contains ['z', 'f', 's', 0 ... ] 20 if (buf.Fstypename[0] != 122) || (buf.Fstypename[1] != 102) || (buf.Fstypename[2] != 115) || (buf.Fstypename[3] != 0) { 21 logrus.WithField("storage-driver", "zfs").Debugf("no zfs dataset found for rootdir '%s'", rootdir) 22 return errors.Wrapf(graphdriver.ErrPrerequisites, "no zfs dataset found for rootdir '%s'", rootdir) 23 } 24 25 return nil 26 } 27 28 func getMountpoint(id string) string { 29 maxlen := 12 30 31 // we need to preserve filesystem suffix 32 suffix := strings.SplitN(id, "-", 2) 33 34 if len(suffix) > 1 { 35 return id[:maxlen] + "-" + suffix[1] 36 } 37 38 return id[:maxlen] 39 }