@@ -19,7 +19,6 @@ package cgroup1
1919import (
2020 "bufio"
2121 "fmt"
22- "io"
2322 "os"
2423 "path/filepath"
2524 "strconv"
@@ -180,49 +179,18 @@ func parseKV(raw string) (string, uint64, error) {
180179// etc.
181180//
182181// The resulting map does not have an element for cgroup v2 unified hierarchy.
183- // Use ParseCgroupFileUnified to get the unified path.
182+ // Use [cgroups. ParseCgroupFileUnified] to get the unified path.
184183func ParseCgroupFile (path string ) (map [string ]string , error ) {
185184 x , _ , err := ParseCgroupFileUnified (path )
186185 return x , err
187186}
188187
189188// ParseCgroupFileUnified returns legacy subsystem paths as the first value,
190189// and returns the unified path as the second value.
190+ //
191+ // Deprecated: use [cgroups.ParseCgroupFileUnified] instead .
191192func ParseCgroupFileUnified (path string ) (map [string ]string , string , error ) {
192- f , err := os .Open (path )
193- if err != nil {
194- return nil , "" , err
195- }
196- defer f .Close ()
197- return parseCgroupFromReaderUnified (f )
198- }
199-
200- func parseCgroupFromReaderUnified (r io.Reader ) (map [string ]string , string , error ) {
201- var (
202- cgroups = make (map [string ]string )
203- unified = ""
204- s = bufio .NewScanner (r )
205- )
206- for s .Scan () {
207- var (
208- text = s .Text ()
209- parts = strings .SplitN (text , ":" , 3 )
210- )
211- if len (parts ) < 3 {
212- return nil , unified , fmt .Errorf ("invalid cgroup entry: %q" , text )
213- }
214- for _ , subs := range strings .Split (parts [1 ], "," ) {
215- if subs == "" {
216- unified = parts [2 ]
217- } else {
218- cgroups [subs ] = parts [2 ]
219- }
220- }
221- }
222- if err := s .Err (); err != nil {
223- return nil , unified , err
224- }
225- return cgroups , unified , nil
193+ return cgroups .ParseCgroupFileUnified (path )
226194}
227195
228196func getCgroupDestination (subsystem string ) (string , error ) {
0 commit comments