Beispiel #1
0
func _err(num C.int) error {
	switch num {
	case 0:
		return nil
	case C.ECGEOF:
		return ECGEOF
	case C.ECGOTHER:
		return ECGOTHER
	case C.ECGROUPNOTEQUAL:
		return ECGROUPNOTEQUAL
	case C.ECGCONTROLLERNOTEQUAL:
		return ECGCONTROLLERNOTEQUAL
	}
	// There's a lot. We'll create them as they come
	return errors.New(C.GoString(C.cgroup_strerror(num)))
}
Beispiel #2
0
	}
	return controllers, nil
}

func GetSubSysMountPoint(controller string) (string, error) {
	var mp *C.char
	err := _err(C.cgroup_get_subsys_mount_point(C.CString(controller), &mp))
	if err != nil {
		return "", err
	}
	return C.GoString(mp), nil
}

var (
	// End-of-file for iterators
	ECGEOF                = errors.New(C.GoString(C.cgroup_strerror(C.ECGEOF)))
	ECGOTHER              = errors.New(C.GoString(C.cgroup_strerror(C.ECGOTHER)))
	ECGROUPNOTEQUAL       = errors.New(C.GoString(C.cgroup_strerror(C.ECGROUPNOTEQUAL)))
	ECGCONTROLLERNOTEQUAL = errors.New(C.GoString(C.cgroup_strerror(C.ECGCONTROLLERNOTEQUAL)))
)

/*
Return last errno, which caused ECGOTHER error.
*/
func LastError() error {
	return _err(C.cgroup_get_last_errno())
}

func _err(num C.int) error {
	switch num {
	case 0:
Beispiel #3
0
	}
	return controllers, nil
}

func GetSubSysMountPoint(controller string) (string, error) {
	var mp *C.char
	err := _err(C.cgroup_get_subsys_mount_point(C.CString(controller), &mp))
	if err != nil {
		return "", err
	}
	return C.GoString(mp), nil
}

// Various errors
var (
	ErrEOF                = errors.New(C.GoString(C.cgroup_strerror(C.ECGEOF)))
	ErrOTHER              = errors.New(C.GoString(C.cgroup_strerror(C.ECGOTHER)))
	ErrGroupNotEqual      = errors.New(C.GoString(C.cgroup_strerror(C.ECGROUPNOTEQUAL)))
	ErrControllerNotEqual = errors.New(C.GoString(C.cgroup_strerror(C.ECGCONTROLLERNOTEQUAL)))
)

// LastError returns last errno, which caused ErrOTHER error.
func LastError() error {
	return _err(C.cgroup_get_last_errno())
}

func _err(num C.int) error {
	switch num {
	case 0:
		return nil
	case C.ECGEOF: