summaryrefslogtreecommitdiff
path: root/Utility/libmounts.c
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-19 21:19:29 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-19 21:19:29 -0400
commit4bcc92abd72e060e073eaf0a9d988ae3a015d39c (patch)
treec3cb107b346ac8ed313675376be321f706193285 /Utility/libmounts.c
parentf768cddf3a7048334f76fff1a2c895b33fea18af (diff)
now working on OSX
While this seems to work fine when used in a simple program, when I load it in ghci, it segfaults about half the time. Don't know why, and seems ghci specific, but if I get reports of crashes, I'll need to look into that.
Diffstat (limited to 'Utility/libmounts.c')
-rw-r--r--Utility/libmounts.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/Utility/libmounts.c b/Utility/libmounts.c
index d29c6ee6a..be18fe0c2 100644
--- a/Utility/libmounts.c
+++ b/Utility/libmounts.c
@@ -34,6 +34,9 @@
#include "libmounts.h"
+#include <errno.h>
+#include <stdio.h>
+
#ifdef GETMNTENT
/* direct passthrough the getmntent */
FILE *mounts_start (void) {
@@ -47,7 +50,7 @@ struct mntent *mounts_next (FILE *fp) {
}
#endif
-#ifdef GETMNTINFOCALL
+#ifdef GETMNTINFO
/* getmntent emulation using getmntinfo */
FILE *mounts_start (void) {
return ((FILE *)0x1); /* dummy non-NULL FILE pointer, not used */
@@ -58,7 +61,7 @@ int mounts_end (FILE *fp) {
static struct mntent _mntent;
-static struct mntent *statfs_to_mntent (struct MNTINFOSTRUCT *mntbuf) {
+static struct mntent *statfs_to_mntent (struct statfs *mntbuf) {
_mntent.mnt_fsname = mntbuf->f_mntfromname;
_mntent.mnt_dir = mntbuf->f_mntonname;
_mntent.mnt_type = mntbuf->f_fstypename;
@@ -72,15 +75,16 @@ static struct mntent *statfs_to_mntent (struct MNTINFOSTRUCT *mntbuf) {
static int pos = -1;
static int mntsize = -1;
+struct statfs *mntbuf = NULL;
struct mntent *mounts_next (FILE *fp) {
- struct MNTINFOSTRUCT *mntbuf;
if (pos == -1 || mntsize == -1)
- mntsize = GETMNTINFOCALL(&mntbuf, MNT_NOWAIT);
+ mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
++pos;
if (pos == mntsize) {
pos = mntsize = -1;
+ mntbuf = NULL;
return NULL;
}