summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2009-02-21 07:22:19 +0000
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2009-02-21 07:22:19 +0000
commite23bc23a1dbda8717d3c0bb86c45a3fffa4fd3a0 (patch)
tree2aa4d2a2ce03e727dded1e6651ddcf1c75dca2c2
parent6365861def7e6e0aef93e4a44637468c5c7ebc51 (diff)
downloadlibcg-e23bc23a1dbda8717d3c0bb86c45a3fffa4fd3a0.tar.gz
libcg-e23bc23a1dbda8717d3c0bb86c45a3fffa4fd3a0.tar.xz
libcg-e23bc23a1dbda8717d3c0bb86c45a3fffa4fd3a0.zip
libcgroup: Fix return values
From: Balbir Singh <balbir@linux.vnet.ibm.com> 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 <balbir@linux.vnet.ibm.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com> git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@334 4f4bb910-9a46-0410-90c8-c897d4f1cd53
-rw-r--r--api.c15
1 files changed, 11 insertions, 4 deletions
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);