1
0
mirror of https://github.com/rancher/os.git synced 2025-08-30 21:26:09 +00:00
os/pkg/util/cutil.go
Olli Janatuinen f87c220f1b v2.0.0-beta7
- Docker 24.0.5
- Kernel 5.10.188
- System-docker 17.06.108
- System container images compresses with zstd instead of xz
- Added WSL2 support
- Include Hyper-V, ProxmoxVE and VMware tools to ISO
- Include apparmor tools to console
- Enable apparmor by default
- Remove experimental selinux support
- Include chroot command to initrd
2023-08-06 12:55:50 +00:00

40 lines
902 B
Go

//go:build linux
// +build linux
package util
/*
#cgo LDFLAGS: -lmount -lblkid -luuid
#include<blkid/blkid.h>
#include<libmount/libmount.h>
#include<stdlib.h>
#cgo pkg-config: libselinux libsepol
#include <selinux/selinux.h>
*/
import "C"
import (
"errors"
"unsafe"
)
// ResolveDevice this isn't reliable - blkid -L LABEL works more often :(
func ResolveDevice(spec string) string {
cSpec := C.CString(spec)
defer C.free(unsafe.Pointer(cSpec))
cString := C.blkid_evaluate_spec(cSpec, nil)
defer C.free(unsafe.Pointer(cString))
return C.GoString(cString)
}
func GetFsType(device string) (string, error) {
var ambi *C.int
cDevice := C.CString(device)
defer C.free(unsafe.Pointer(cDevice))
cString := C.mnt_get_fstype(cDevice, ambi, nil)
defer C.free(unsafe.Pointer(cString))
if cString != nil {
return C.GoString(cString), nil
}
return "", errors.New("Error while getting fstype")
}