diff options
author | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2008-07-23 06:11:38 +0000 |
---|---|---|
committer | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2008-07-23 06:11:38 +0000 |
commit | 01ec61cea57eaf6c20cce540efc3fed08c416c07 (patch) | |
tree | ddb2321ee4bc19621d5bf0df1bf47b16830ec8a0 /api.c | |
parent | a8bbaacbc4bad239cb6ec6f791786e82b0a02760 (diff) | |
download | libcg-01ec61cea57eaf6c20cce540efc3fed08c416c07.tar.gz libcg-01ec61cea57eaf6c20cce540efc3fed08c416c07.tar.xz libcg-01ec61cea57eaf6c20cce540efc3fed08c416c07.zip |
libcgroup: Fix up rentrant functions patch.
Some errors were not handled, this patch handles those errors.
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@114 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'api.c')
-rw-r--r-- | api.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -175,16 +175,21 @@ int cgroup_init() proc_mount = fopen("/proc/mounts", "r"); if (proc_mount == NULL) { - ret = EIO; + ret = ECGFAIL; goto unlock_exit; } temp_ent = (struct mntent *) malloc(sizeof(struct mntent)); + if (!temp_ent) { + ret = ECGFAIL; + goto unlock_exit; + } + while ((ent = getmntent_r(proc_mount, temp_ent, mntent_buffer, sizeof(mntent_buffer))) != NULL) { - if (!strncmp(ent->mnt_type, "cgroup", strlen("cgroup"))) { + if (!strcmp(ent->mnt_type, "cgroup")) { for (i = 0; controllers[i] != NULL; i++) { mntopt = hasmntopt(ent, controllers[i]); mntopt = strtok_r(mntopt, ",", &strtok_buffer); @@ -234,11 +239,20 @@ static int cg_test_mounted_fs() } temp_ent = (struct mntent *) malloc(sizeof(struct mntent)); + if (!temp_ent) { + /* We just fail at the moment. */ + return 0; + } + ent = getmntent_r(proc_mount, temp_ent, mntent_buff, sizeof(mntent_buff)); + if (!ent) + return 0; + while (strcmp(ent->mnt_type, "cgroup") !=0) { - ent = getmntent(proc_mount); + ent = getmntent_r(proc_mount, temp_ent, mntent_buff, + sizeof(mntent_buff)); if (ent == NULL) return 0; } |