github.com/stevegt/moby@v1.13.1/pkg/mount/mounter_solaris.go (about)

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