github.com/cdoern/storage@v1.12.13/pkg/mount/mounter_solaris.go (about) 1 // +build solaris,cgo 2 3 package mount 4 5 import ( 6 "unsafe" 7 8 "golang.org/x/sys/unix" 9 ) 10 11 // #include <stdlib.h> 12 // #include <stdio.h> 13 // #include <sys/mount.h> 14 // int Mount(const char *spec, const char *dir, int mflag, 15 // char *fstype, char *dataptr, int datalen, char *optptr, int optlen) { 16 // return mount(spec, dir, mflag, fstype, dataptr, datalen, optptr, optlen); 17 // } 18 import "C" 19 20 func mount(device, target, mType string, flag uintptr, data string) error { 21 spec := C.CString(device) 22 dir := C.CString(target) 23 fstype := C.CString(mType) 24 _, err := C.Mount(spec, dir, C.int(flag), fstype, nil, 0, nil, 0) 25 C.free(unsafe.Pointer(spec)) 26 C.free(unsafe.Pointer(dir)) 27 C.free(unsafe.Pointer(fstype)) 28 return err 29 } 30 31 func unmount(target string, flag int) error { 32 err := unix.Unmount(target, flag) 33 return err 34 }