summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-04-17 14:32:12 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-05-15 19:09:20 -0400
commit0daddb9b0b115ed01c07e09502d45a23d0532bac (patch)
tree0a1fca5df2f5efe3a4800b242e5bd9e869ff33d9
parent0b296562d46fe6a8af0ad50df08d3000f89867e1 (diff)
sd_login: process: make GetCgroup public
-rw-r--r--sd_login/systemd_cgroup.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/sd_login/systemd_cgroup.go b/sd_login/systemd_cgroup.go
index 29ff38f..6c64525 100644
--- a/sd_login/systemd_cgroup.go
+++ b/sd_login/systemd_cgroup.go
@@ -54,7 +54,7 @@ func cgVersion() uint {
return cgVersion_cache
}
-// getCgroup returns the cgroup path of the process, relative to the
+// GetCgroup returns the cgroup path of the process, relative to the
// root of the cgroup hierarchy.
//
// In cgroup v2, there is a only one cgroup hierarchy, so the behavior
@@ -78,7 +78,7 @@ func cgVersion() uint {
// come in if both "name=systemd" and "name=elogind" controllers
// exist. Systemd and elogind cannot be used together, so this isn't
// a concern.
-func (pid ProcessID) getCgroup() (_Cgroup, error) {
+func (pid ProcessID) GetCgroup() (string, error) {
cgVer := cgVersion()
cgroupFilename := fmt.Sprintf("/proc/%d/cgroup", pid)
@@ -108,7 +108,7 @@ func (pid ProcessID) getCgroup() (_Cgroup, error) {
hierarchy := parts[0]
controllers := parts[1]
- path := _Cgroup(parts[2])
+ path := parts[2]
switch cgVer {
case 1:
@@ -127,6 +127,11 @@ func (pid ProcessID) getCgroup() (_Cgroup, error) {
return "", unix.ENODATA
}
+func (pid ProcessID) getCgroup() (_Cgroup, error) {
+ cgroup, err := pid.GetCgroup()
+ return _Cgroup(cgroup), err
+}
+
// cgGetRootPath determines the cgroup that all other cgroups belong
// to. The common case is just "/", but it could be something else if
// we are inside of a container, but have a view of the entier cgroup