From 0daddb9b0b115ed01c07e09502d45a23d0532bac Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 17 Apr 2017 14:32:12 -0400 Subject: sd_login: process: make GetCgroup public --- sd_login/systemd_cgroup.go | 11 ++++++++--- 1 file 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 -- cgit v1.1-4-g5e80