summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fc6f1e3)
raw | patch | inline | side by side (parent: fc6f1e3)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Sat, 25 Jul 2015 13:21:52 +0000 (15:21 +0200) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Thu, 26 Nov 2015 21:34:17 +0000 (22:34 +0100) |
configure.ac | patch | blob | history | |
src/utils_mount.c | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index 7b2296d0f56bf8ba5111f23f9145afe4c4db243c..bb62d8c6713b68bd57965685cbfa1f3ed858cdb2 100644 (file)
--- a/configure.ac
+++ b/configure.ac
AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
have_listmntent="no"
AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
+have_getmntent_r="no"
+AC_CHECK_FUNCS(getmntent_r, [have_getmntent_r="yes"])
have_getmntent="no"
AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
plugin_df="yes"
fi
+if test "x$c_cv_have_getmntent_r" = "xyes"
+then
+ plugin_df="yes"
+fi
+
# Df plugin: Check if we have either `statfs' or `statvfs' second.
if test "x$plugin_df" = "xyes"
then
diff --git a/src/utils_mount.c b/src/utils_mount.c
index b63a81ad29b44fe13c113ca8843a7abb701bcfbf..afeb39e1162af515ddac44dfda578b3a76c2cdb4 100644 (file)
--- a/src/utils_mount.c
+++ b/src/utils_mount.c
#warn "This version of `getmntent' hat not yet been implemented!"
/* #endif HAVE_SEQ_GETMNTENT */
+#elif HAVE_GETMNTENT_R
+static cu_mount_t *cu_mount_getmntent (void)
+{
+ FILE *fp;
+ struct mntent me;
+ char mntbuf[1024];
+
+ cu_mount_t *first = NULL;
+ cu_mount_t *last = NULL;
+ cu_mount_t *new = NULL;
+
+ DEBUG ("utils_mount: (void); COLLECTD_MNTTAB = %s", COLLECTD_MNTTAB);
+
+ if ((fp = setmntent (COLLECTD_MNTTAB, "r")) == NULL)
+ {
+ char errbuf[1024];
+ ERROR ("setmntent (%s): %s", COLLECTD_MNTTAB,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return (NULL);
+ }
+
+ while (getmntent_r (fp, &me, mntbuf, sizeof (mntbuf) ))
+ {
+ if ((new = malloc (sizeof (cu_mount_t))) == NULL)
+ break;
+ memset (new, '\0', sizeof (cu_mount_t));
+
+ /* Copy values from `struct mntent *' */
+ new->dir = sstrdup (me.mnt_dir);
+ new->spec_device = sstrdup (me.mnt_fsname);
+ new->type = sstrdup (me.mnt_type);
+ new->options = sstrdup (me.mnt_opts);
+ new->device = get_device_name (new->options);
+ new->next = NULL;
+
+ DEBUG ("utils_mount: new = {dir = %s, spec_device = %s, type = %s, options = %s, device = %s}",
+ new->dir, new->spec_device, new->type, new->options, new->device);
+
+ /* Append to list */
+ if (first == NULL)
+ {
+ first = new;
+ last = new;
+ }
+ else
+ {
+ last->next = new;
+ last = new;
+ }
+ }
+
+ endmntent (fp);
+
+ DEBUG ("utils_mount: return (0x%p)", (void *) first);
+
+ return (first);
+} /* HAVE_GETMNTENT_R */
+
#elif HAVE_ONE_GETMNTENT
static cu_mount_t *cu_mount_getmntent (void)
{