mirror of
https://github.com/vbatts/go-cgroup.git
synced 2024-11-27 02:45:39 +00:00
controller_data ought to be read-only
This commit is contained in:
parent
489e2f59f2
commit
c2855cec9b
2 changed files with 34 additions and 13 deletions
42
cg.go
42
cg.go
|
@ -449,22 +449,42 @@ int cgroup_walk_tree_begin(const char *controller, const char *base_path, int de
|
||||||
int *base_level);
|
int *base_level);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
// ControllerData is the information model for controllers available
|
||||||
Information model for Controllers available
|
|
||||||
*/
|
|
||||||
type ControllerData struct {
|
type ControllerData struct {
|
||||||
Name string
|
name string
|
||||||
Hierarchy int
|
hierarchy int
|
||||||
NumCgroups int
|
numCgroups int
|
||||||
Enabled int
|
enabled int
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name of the this controller
|
||||||
|
func (cd ControllerData) Name() string {
|
||||||
|
return cd.name
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hierarchy is the identification of the controller. Controllers with the same
|
||||||
|
// hierarchy ID are mounted together as one hierarchy. Controllers with ID 0
|
||||||
|
// are not currently mounted anywhere.
|
||||||
|
func (cd ControllerData) Hierarchy() int {
|
||||||
|
return cd.hierarchy
|
||||||
|
}
|
||||||
|
|
||||||
|
// NumCgroups is the number of cgroups
|
||||||
|
func (cd ControllerData) NumCgroups() int {
|
||||||
|
return cd.numCgroups
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enabled indicates whether or not this controller is enabled
|
||||||
|
func (cd ControllerData) Enabled() int {
|
||||||
|
return cd.enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
func fromCControllerData(cData C.struct_controller_data) ControllerData {
|
func fromCControllerData(cData C.struct_controller_data) ControllerData {
|
||||||
return ControllerData{
|
return ControllerData{
|
||||||
Name: C.GoString(&cData.name[0]),
|
name: C.GoString(&cData.name[0]),
|
||||||
Hierarchy: int(cData.hierarchy),
|
hierarchy: int(cData.hierarchy),
|
||||||
NumCgroups: int(cData.num_cgroups),
|
numCgroups: int(cData.num_cgroups),
|
||||||
Enabled: int(cData.enabled),
|
enabled: int(cData.enabled),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
main.go
5
main.go
|
@ -4,8 +4,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"."
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/vbatts/go-cgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -25,6 +26,6 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i := range ctls {
|
for i := range ctls {
|
||||||
fmt.Printf("Hierarchy=%d Enabled=%d NumCgroups=%d Name=%s\n", ctls[i].Hierarchy, ctls[i].Enabled, ctls[i].NumCgroups, ctls[i].Name)
|
fmt.Printf("Hierarchy=%d Enabled=%d NumCgroups=%d Name=%s\n", ctls[i].Hierarchy(), ctls[i].Enabled(), ctls[i].NumCgroups(), ctls[i].Name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue