// OpenFile opens a cgroup file in a given dir with given flags. // It is supposed to be used for cgroup files only, and returns // an error if the file is not a cgroup file. // // Arguments dir and file are joined together to form an absolute path // to a file being opened. func OpenFile(dir, file string, flags int) (*os.File, error) { … } // ReadFile reads data from a cgroup file in dir. // It is supposed to be used for cgroup files only. func ReadFile(dir, file string) (string, error) { … } // WriteFile writes data to a cgroup file in dir. // It is supposed to be used for cgroup files only. func WriteFile(dir, file, data string) error { … } // WriteFileByLine is the same as WriteFile, except if data contains newlines, // it is written line by line. func WriteFileByLine(dir, file, data string) error { … } const cgroupfsDir … const cgroupfsPrefix … var TestMode … var cgroupRootHandle … var prepOnce … var prepErr … var resolveFlags … func prepareOpenat2() error { … } func openFile(dir, file string, flags int) (*os.File, error) { … } var errNotCgroupfs … var openFallback … // openAndCheck is used when openat2(2) is not available. It checks the opened // file is on cgroupfs, returning an error otherwise. func openAndCheck(path string, flags int, mode os.FileMode) (*os.File, error) { … }