2015-05-28 11:38:08 -04:00
|
|
|
package zfs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-05-29 09:33:04 -04:00
|
|
|
"strings"
|
2015-05-28 11:38:08 -04:00
|
|
|
"syscall"
|
|
|
|
|
2015-07-28 22:58:50 -04:00
|
|
|
"github.com/Sirupsen/logrus"
|
2015-05-28 11:38:08 -04:00
|
|
|
"github.com/docker/docker/daemon/graphdriver"
|
|
|
|
)
|
|
|
|
|
|
|
|
func checkRootdirFs(rootdir string) error {
|
|
|
|
var buf syscall.Statfs_t
|
|
|
|
if err := syscall.Statfs(rootdir, &buf); err != nil {
|
|
|
|
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) {
|
2015-07-28 22:58:50 -04:00
|
|
|
logrus.Debugf("[zfs] 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]
|
|
|
|
}
|