pkgsrc/sysutils/gentoo/patches/patch-ac
joerg b8724d8bc8 Add DragonFly support. Replace the static FILE magic with a different
(messy) magic, which doesn't relay on sizeof(FILE), but on two integer
variables having separate addresses and pointer casts not changing
this fact.
2006-06-20 20:41:22 +00:00

95 lines
3.1 KiB
Text

$NetBSD: patch-ac,v 1.4 2006/06/20 20:41:22 joerg Exp $
--- src/mntent_wrap.c.orig 2003-10-12 13:45:23.000000000 +0000
+++ src/mntent_wrap.c
@@ -92,7 +92,7 @@ gint mne_endmntent(FILE *filep)
return -1;
}
-#elif defined __OpenBSD__ || defined __FreeBSD__ || defined __NetBSD__ || (defined __osf__ && defined __alpha__)
+#elif defined __OpenBSD__ || defined __FreeBSD__ || defined __NetBSD__ || (defined __osf__ && defined __alpha__) || defined(__DragonFly__)
/* Here is the implementation for BSD and Alpha Tru64 systems. */
@@ -100,6 +100,9 @@ gint mne_endmntent(FILE *filep)
#include <sys/mount.h>
#include <sys/param.h>
#include <sys/ucred.h>
+#if defined(HAVE_STRUCT_STATVFS) && !defined(__DragonFly__)
+#include <sys/statvfs.h>
+#endif
/* A pointer to one of these is returned by mne_setmntent(), depending on which file
** name is given as an input. Note that on BSD systems, the system calls themselves
@@ -109,13 +112,18 @@ gint mne_endmntent(FILE *filep)
** of what kind of mount entries we're supposed to deal with. Since gentoo will
** pass a FILE pointer to mne_getmntent() anyway, it seems natural to use it.
*/
-static FILE f_fstab, f_mtab;
+static int f_stab_val, f_mtab_val;
+static FILE *f_fstab = (FILE *)&f_stab_val, *f_mtab = (FILE *)&f_mtab_val;
/* These are used when we're accessing the currently mounted filesystems, using
** a call to getmntinfo(). The mtab_pos and mtab_num integers are then used to
** keep track of where in the returned array of statfs structs we are.
*/
+#if defined(HAVE_STRUCT_STATVFS) && !defined(__DragonFly__)
+static struct statvfs *mtab = NULL;
+#else
static struct statfs *mtab = NULL;
+#endif
static guint mtab_pos = 0, mtab_num = 0;
/* 1999-05-09 - An attempt at a BSD implementation, after having received input from
@@ -132,28 +140,28 @@ FILE * mne_setmntent(const gchar *filena
if(strcmp(filename, "/etc/fstab") == 0) /* Looking for available filesystems? */
{
if(setfsent() == 1)
- return &f_fstab;
+ return f_fstab;
}
else if(strcmp(filename, "/proc/mtab") == 0) /* Looking for mounted filesystems? */
{
if((mtab_num = getmntinfo(&mtab, 0)) > 0)
{
mtab_pos = 0;
- return &f_mtab;
+ return f_mtab;
}
}
return NULL;
}
-/* 1999-05-09 - Get another entry of data, either about mounted (filep == &f_mtab) or available
-** (filep == &f_fstab) filesystems. Returns NULL when the respective data source
+/* 1999-05-09 - Get another entry of data, either about mounted (filep == f_mtab) or available
+** (filep == f_fstab) filesystems. Returns NULL when the respective data source
** is exhausted.
*/
const MntEnt * mne_getmntent(FILE *filep)
{
static MntEnt me;
- if(filep == &f_fstab)
+ if(filep == f_fstab)
{
struct fstab *ment;
@@ -164,7 +172,7 @@ const MntEnt * mne_getmntent(FILE *filep
return &me;
}
}
- else if(filep == &f_mtab)
+ else if(filep == f_mtab)
{
if(mtab_pos == mtab_num) /* Array exhausted? */
return NULL;
@@ -182,7 +190,7 @@ const MntEnt * mne_getmntent(FILE *filep
/* 1999-05-09 - Stop traversing mount/fs data. */
gint mne_endmntent(FILE *filep)
{
- if(filep == &f_fstab)
+ if(filep == f_fstab)
endfsent();
return 0;