Use the reentrant getmntent_r instead of getmntent
[fio.git] / cgroup.c
index 0e3a71ebbfa75f57c9980ff6ba5c990b972d0c50..de00d986eb05246b25e853c3af524149f1b53e22 100644 (file)
--- a/cgroup.c
+++ b/cgroup.c
@@ -4,6 +4,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <mntent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 #include "fio.h"
 #include "flist.h"
 #include "cgroup.h"
@@ -20,7 +22,8 @@ struct cgroup_member {
 static char *find_cgroup_mnt(struct thread_data *td)
 {
        char *mntpoint = NULL;
-       struct mntent *mnt;
+       struct mntent *mnt, dummy;
+       char buf[256] = {0};
        FILE *f;
 
        f = setmntent("/proc/mounts", "r");
@@ -29,7 +32,7 @@ static char *find_cgroup_mnt(struct thread_data *td)
                return NULL;
        }
 
-       while ((mnt = getmntent(f)) != NULL) {
+       while ((mnt = getmntent_r(f, &dummy, buf, sizeof(buf))) != NULL) {
                if (!strcmp(mnt->mnt_type, "cgroup") &&
                    strstr(mnt->mnt_opts, "blkio"))
                        break;