]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup: Fix return values
authorDhaval Giani <dhaval@linux.vnet.ibm.com>
Sat, 21 Feb 2009 07:22:19 +0000 (07:22 +0000)
committerDhaval Giani <dhaval@linux.vnet.ibm.com>
Sat, 21 Feb 2009 07:22:19 +0000 (07:22 +0000)
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

api.c

diff --git a/api.c b/api.c
index 72f8c69ba6d074ae311532b4f4e5651903e4beda..91b26e00a64979a71d342c2a98df42912023cde3 100644 (file)
--- 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);