From e23bc23a1dbda8717d3c0bb86c45a3fffa4fd3a0 Mon Sep 17 00:00:00 2001 From: Dhaval Giani Date: Sat, 21 Feb 2009 07:22:19 +0000 Subject: libcgroup: Fix return values From: Balbir Singh Impact: Bug fix, fix incorrect return values This patch fixes incorrect return value of -1 being returned from some call sites. Please review, comment. printf's are ugly, so they've been converted to dbg. Signed-off-by: Balbir Singh Signed-off-by: Dhaval Giani git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@334 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- api.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'api.c') diff --git a/api.c b/api.c index 72f8c69..91b26e0 100644 --- a/api.c +++ b/api.c @@ -138,6 +138,10 @@ static int cg_chown_file(FTS *fts, FTSENT *ent, uid_t owner, gid_t group) break; } fail_chown: + if (ret < 0) { + last_errno = errno; + ret = ECGOTHER; + } return ret; } @@ -680,7 +684,7 @@ static int cg_test_mounted_fs() proc_mount = fopen("/proc/mounts", "r"); if (proc_mount == NULL) { - return -1; + return 0; } temp_ent = (struct mntent *) malloc(sizeof(struct mntent)); @@ -937,15 +941,18 @@ static int cg_mkdir_p(const char *path) i = j; ret = chdir(wd); if (ret) { - printf("could not chdir to child directory (%s)\n", wd); + dbg("could not chdir to child directory (%s)\n", wd); break; } free(wd); } while (real_path[i]); ret = chdir(buf); - if (ret) - printf("could not go back to old directory (%s)\n", cwd); + if (ret) { + last_errno = errno; + ret = ECGOTHER; + dbg("could not go back to old directory (%s)\n", cwd); + } done: free(real_path); -- cgit