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
break;
}
fail_chown:
+ if (ret < 0) {
+ last_errno = errno;
+ ret = ECGOTHER;
+ }
return ret;
}
proc_mount = fopen("/proc/mounts", "r");
if (proc_mount == NULL) {
- return -1;
+ return 0;
}
temp_ent = (struct mntent *) malloc(sizeof(struct mntent));
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);