Debian Codegraph @

cmd/runtimetest/mount/mountinfo_solaris.go

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