File: mountinfo_solaris.go

package info (click to toggle)
golang-github-opencontainers-runtime-tools 0.9.0%2Bgit20220423.g0105384-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,160 kB
  • sloc: sh: 558; makefile: 90
file content (38 lines) | stat: -rw-r--r-- 732 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//go:build solaris && cgo
// +build solaris,cgo

package mount

/*
#include <stdio.h>
#include <sys/mnttab.h>
*/
import "C"

import (
	"fmt"
)

func parseMountTable() ([]*Info, error) {
	mnttab := C.fopen(C.CString(C.MNTTAB), C.CString("r"))
	if mnttab == nil {
		return nil, fmt.Errorf("Failed to open %s", C.MNTTAB)
	}

	var out []*Info
	var mp C.struct_mnttab

	ret := C.getmntent(mnttab, &mp)
	for ret == 0 {
		var mountinfo Info
		mountinfo.Mountpoint = C.GoString(mp.mnt_mountp)
		mountinfo.Source = C.GoString(mp.mnt_special)
		mountinfo.Fstype = C.GoString(mp.mnt_fstype)
		mountinfo.Opts = C.GoString(mp.mnt_mntopts)
		out = append(out, &mountinfo)
		ret = C.getmntent(mnttab, &mp)
	}

	C.fclose(mnttab)
	return out, nil
}