2018-02-05 16:05:59 -05:00
|
|
|
package zfs // import "github.com/docker/docker/daemon/graphdriver/zfs"
|
2015-05-28 11:38:08 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-05-29 09:33:04 -04:00
|
|
|
"strings"
|
2015-05-28 11:38:08 -04:00
|
|
|
|
|
|
|
"github.com/docker/docker/daemon/graphdriver"
|
2017-07-26 17:42:13 -04:00
|
|
|
"github.com/sirupsen/logrus"
|
2017-05-23 10:22:32 -04:00
|
|
|
"golang.org/x/sys/unix"
|
2015-05-28 11:38:08 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func checkRootdirFs(rootdir string) error {
|
2017-05-23 10:22:32 -04:00
|
|
|
var buf unix.Statfs_t
|
|
|
|
if err := unix.Statfs(rootdir, &buf); err != nil {
|
2015-05-28 11:38:08 -04: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 10:09:41 -05:00
|
|
|
logrus.WithField("storage-driver", "zfs").Debugf("no zfs dataset found for rootdir '%s'", rootdir)
|
2015-05-28 11:38:08 -04:00
|
|
|
return graphdriver.ErrPrerequisites
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2015-05-29 09:33:04 -04: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]
|
|
|
|
}
|