github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/daemon/graphdriver/driver_solaris.go (about) 1 // +build solaris,cgo 2 3 package graphdriver 4 5 /* 6 #include <sys/statvfs.h> 7 #include <stdlib.h> 8 9 static inline struct statvfs *getstatfs(char *s) { 10 struct statvfs *buf; 11 int err; 12 buf = (struct statvfs *)malloc(sizeof(struct statvfs)); 13 err = statvfs(s, buf); 14 return buf; 15 } 16 */ 17 import "C" 18 import ( 19 "path/filepath" 20 "unsafe" 21 22 "github.com/Sirupsen/logrus" 23 ) 24 25 const ( 26 // FsMagicZfs filesystem id for Zfs 27 FsMagicZfs = FsMagic(0x2fc12fc1) 28 ) 29 30 var ( 31 // Slice of drivers that should be used in an order 32 priority = []string{ 33 "zfs", 34 } 35 36 // FsNames maps filesystem id to name of the filesystem. 37 FsNames = map[FsMagic]string{ 38 FsMagicZfs: "zfs", 39 } 40 ) 41 42 // GetFSMagic returns the filesystem id given the path. 43 func GetFSMagic(rootpath string) (FsMagic, error) { 44 return 0, nil 45 } 46 47 // Mounted checks if the given path is mounted as the fs type 48 //Solaris supports only ZFS for now 49 func Mounted(fsType FsMagic, mountPath string) (bool, error) { 50 51 cs := C.CString(filepath.Dir(mountPath)) 52 buf := C.getstatfs(cs) 53 54 // on Solaris buf.f_basetype contains ['z', 'f', 's', 0 ... ] 55 if (buf.f_basetype[0] != 122) || (buf.f_basetype[1] != 102) || (buf.f_basetype[2] != 115) || 56 (buf.f_basetype[3] != 0) { 57 logrus.Debugf("[zfs] no zfs dataset found for rootdir '%s'", mountPath) 58 C.free(unsafe.Pointer(buf)) 59 return false, ErrPrerequisites 60 } 61 62 C.free(unsafe.Pointer(buf)) 63 C.free(unsafe.Pointer(cs)) 64 return true, nil 65 }