github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/daemon/graphdriver/zfs/zfs_freebsd.go (about)

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