github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/daemon/graphdriver/zfs/zfs_freebsd.go (about)

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