github.com/olljanat/moby@v1.13.1/pkg/mount/mountinfo_solaris.go (about)

     1  // +build solaris,cgo
     2  
     3  package mount
     4  
     5  /*
     6  #include <stdio.h>
     7  #include <sys/mnttab.h>
     8  */
     9  import "C"
    10  
    11  import (
    12  	"fmt"
    13  )
    14  
    15  func parseMountTable() ([]*Info, error) {
    16  	mnttab := C.fopen(C.CString(C.MNTTAB), C.CString("r"))
    17  	if mnttab == nil {
    18  		return nil, fmt.Errorf("Failed to open %s", C.MNTTAB)
    19  	}
    20  
    21  	var out []*Info
    22  	var mp C.struct_mnttab
    23  
    24  	ret := C.getmntent(mnttab, &mp)
    25  	for ret == 0 {
    26  		var mountinfo Info
    27  		mountinfo.Mountpoint = C.GoString(mp.mnt_mountp)
    28  		mountinfo.Source = C.GoString(mp.mnt_special)
    29  		mountinfo.Fstype = C.GoString(mp.mnt_fstype)
    30  		mountinfo.Opts = C.GoString(mp.mnt_mntopts)
    31  		out = append(out, &mountinfo)
    32  		ret = C.getmntent(mnttab, &mp)
    33  	}
    34  
    35  	C.fclose(mnttab)
    36  	return out, nil
    37  }