From 97ad05f786fe2be9196b2724a2d59e514055d89a Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Tue, 27 Sep 2011 08:50:09 +0200 Subject: [PATCH] libcgroup: fixed chmod cg_chmod_recursive_controller fts_read can return NULL in two cases. Either when we have visited all files in the hierarchy (when errno is set to 0) or when an error occured. We shouldn't set an error code in the first case obviously. Changelog since v1: - updated log message Signed-off-by: Jan Safranek Reviewed-by: Michal Hocko --- src/api.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api.c b/src/api.c index 09e6353e..28486b71 100644 --- a/src/api.c +++ b/src/api.c @@ -266,9 +266,11 @@ static int cg_chmod_recursive_controller(char *path, mode_t dir_mode, FTSENT *ent; ent = fts_read(fts); if (!ent) { - cgroup_dbg("fts_read failed\n"); - last_errno = errno; - final_ret = ECGOTHER; + if (errno != 0) { + cgroup_dbg("fts_read failed\n"); + last_errno = errno; + final_ret = ECGOTHER; + } break; } ret = cg_chmod_file(fts, ent, dir_mode, dirm_change, -- 2.47.2