diff options
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/libmounts.c | 12 | ||||
-rw-r--r-- | Utility/libmounts.h | 16 |
2 files changed, 10 insertions, 18 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; } diff --git a/Utility/libmounts.h b/Utility/libmounts.h index 12f5564b5..b65978629 100644 --- a/Utility/libmounts.h +++ b/Utility/libmounts.h @@ -1,20 +1,9 @@ /* Include appropriate headers for the OS, and define what will be used. */ -#if defined(__APPLE__) +#if defined (__FreeBSD__) || defined (__APPLE__) # include <sys/param.h> # include <sys/ucred.h> # include <sys/mount.h> -/* In newer OSX versions, statfs64 is deprecated, in favor of statfs, - * which is 64 bit only with a build option -- but statfs64 still works, - * and this keeps older OSX also supported. */ -# define GETMNTINFOCALL getmntinfo64 -# define MNTINFOSTRUCT statfs64 -#else -#if defined (__FreeBSD__) -# include <sys/param.h> -# include <sys/ucred.h> -# include <sys/mount.h> -# define GETMNTINFOCALL getmntinfo64 -# define MNTINFOSTRUCT statfs64 +# define GETMNTINFO #else #if defined (__linux__) || defined (__FreeBSD_kernel__) /* Linux or Debian kFreeBSD */ @@ -25,7 +14,6 @@ # define UNKNOWN #endif #endif -#endif #include <stdio.h> |