diff options
author | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2008-07-21 12:54:45 +0000 |
---|---|---|
committer | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2008-07-21 12:54:45 +0000 |
commit | e293d6482f82b5a8d779698e349ac08b93cb789f (patch) | |
tree | 790db7076f4f5e5942d37490672db923371e2f04 /api.c | |
parent | 3b9c8ce8dc1a25afb30104cd852856af4c3691a7 (diff) | |
download | libcg-e293d6482f82b5a8d779698e349ac08b93cb789f.tar.gz libcg-e293d6482f82b5a8d779698e349ac08b93cb789f.tar.xz libcg-e293d6482f82b5a8d779698e349ac08b93cb789f.zip |
libcgroup: Make libcgroup use rentrant functions
This patch converts functions which have reentrant versions to
use those versions.
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Paul Menage <menage@google.com>
Cc: Dan Smith <danms@us.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@109 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'api.c')
-rw-r--r-- | api.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -120,7 +120,7 @@ static int cgroup_test_subsys_mounted(const char *name) int cgroup_init() { FILE *proc_mount; - struct mntent *ent; + struct mntent *ent, *temp_ent; int found_mnt = 0; int ret = 0; static char *controllers[CG_CONTROLLER_MAX]; @@ -131,6 +131,8 @@ int cgroup_init() char *mntopt; int err; char *buf; + char mntent_buffer[4 * FILENAME_MAX]; + char *strtok_buffer; proc_cgroup = fopen("/proc/cgroups", "r"); @@ -164,11 +166,15 @@ int cgroup_init() return EIO; } - while ((ent = getmntent(proc_mount)) != NULL) { + temp_ent = (struct mntent *) malloc(sizeof(struct mntent)); + + while ((ent = getmntent_r(proc_mount, temp_ent, + mntent_buffer, + sizeof(mntent_buffer))) != NULL) { if (!strncmp(ent->mnt_type, "cgroup", strlen("cgroup"))) { for (i = 0; controllers[i] != NULL; i++) { mntopt = hasmntopt(ent, controllers[i]); - mntopt = strtok(mntopt, ","); + mntopt = strtok_r(mntopt, ",", &strtok_buffer); if (mntopt && strcmp(mntopt, controllers[i]) == 0) { dbg("matched %s:%s\n", mntopt, @@ -202,13 +208,17 @@ int cgroup_init() static int cg_test_mounted_fs() { FILE *proc_mount; - struct mntent *ent; + struct mntent *ent, *temp_ent; + char mntent_buff[4 * FILENAME_MAX]; proc_mount = fopen("/proc/mounts", "r"); if (proc_mount == NULL) { return -1; } - ent = getmntent(proc_mount); + + temp_ent = (struct mntent *) malloc(sizeof(struct mntent)); + ent = getmntent_r(proc_mount, temp_ent, mntent_buff, + sizeof(mntent_buff)); while (strcmp(ent->mnt_type, "cgroup") !=0) { ent = getmntent(proc_mount); |