1
0
mirror of https://github.com/rancher/os.git synced 2025-06-24 14:01:34 +00:00
os/util/cutil.go
Sven Dowideit f5230f1299 add integration tests for iso boot, install and then boot from disk.
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
2017-01-15 23:40:18 +00:00

38 lines
826 B
Go
Executable File

// +build linux
package util
/*
#cgo LDFLAGS: -lmount -lblkid -luuid
#include<blkid/blkid.h>
#include<libmount/libmount.h>
#include<stdlib.h>
*/
import "C"
import "unsafe"
import (
"errors"
)
// 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")
}