2018-02-05 21:05:59 +00:00
|
|
|
package zfs // import "github.com/docker/docker/daemon/graphdriver/zfs"
|
2015-05-28 15:38:08 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-05-29 13:33:04 +00:00
|
|
|
"strings"
|
2015-05-28 15:38:08 +00:00
|
|
|
|
|
|
|
"github.com/docker/docker/daemon/graphdriver"
|
2017-07-26 21:42:13 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2017-05-23 14:22:32 +00:00
|
|
|
"golang.org/x/sys/unix"
|
2015-05-28 15:38:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func checkRootdirFs(rootdir string) error {
|
2017-05-23 14:22:32 +00:00
|
|
|
var buf unix.Statfs_t
|
|
|
|
if err := unix.Statfs(rootdir, &buf); err != nil {
|
2015-05-28 15:38:08 +00:00
|
|
|
return fmt.Errorf("Failed to access '%s': %s", rootdir, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// on FreeBSD buf.Fstypename contains ['z', 'f', 's', 0 ... ]
|
|
|
|
if (buf.Fstypename[0] != 122) || (buf.Fstypename[1] != 102) || (buf.Fstypename[2] != 115) || (buf.Fstypename[3] != 0) {
|
2018-03-05 15:09:41 +00:00
|
|
|
logrus.WithField("storage-driver", "zfs").Debugf("no zfs dataset found for rootdir '%s'", rootdir)
|
2015-05-28 15:38:08 +00:00
|
|
|
return graphdriver.ErrPrerequisites
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2015-05-29 13:33:04 +00:00
|
|
|
|
|
|
|
func getMountpoint(id string) string {
|
|
|
|
maxlen := 12
|
|
|
|
|
|
|
|
// we need to preserve filesystem suffix
|
|
|
|
suffix := strings.SplitN(id, "-", 2)
|
|
|
|
|
|
|
|
if len(suffix) > 1 {
|
|
|
|
return id[:maxlen] + "-" + suffix[1]
|
|
|
|
}
|
|
|
|
|
|
|
|
return id[:maxlen]
|
|
|
|
}
|