From 35541ebcd206bec514b14d25fabb63e32fb88747 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Fri, 18 Mar 2016 14:57:52 -0700 Subject: [PATCH] Add more information in the error messages when writing to a file This is helpful to debug "invalid argument" errors when writing to cgroup files Signed-off-by: Mrunal Patel --- libcontainer/cgroups/fs/apply_raw.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libcontainer/cgroups/fs/apply_raw.go b/libcontainer/cgroups/fs/apply_raw.go index 6def4ea54..114f002ec 100644 --- a/libcontainer/cgroups/fs/apply_raw.go +++ b/libcontainer/cgroups/fs/apply_raw.go @@ -351,7 +351,10 @@ func writeFile(dir, file, data string) error { if dir == "" { return fmt.Errorf("no such directory for %s.", file) } - return ioutil.WriteFile(filepath.Join(dir, file), []byte(data), 0700) + if err := ioutil.WriteFile(filepath.Join(dir, file), []byte(data), 0700); err != nil { + return fmt.Errorf("failed to write %v to %v: %v", data, file, err) + } + return nil } func readFile(dir, file string) (string, error) {