pkgsrc/sysutils/fam/patches/patch-af
sketch 97ff422b68 Various fixes/cleanups to get this package compiling on Solaris:
+ Use the mnttab(4) interface instead of mntent.
 + C++ syntax cleanups to appease the SunPro compiler.
 + Use MAXPATHLEN instead of NAME_MAX which can be unimplemented on strict
   POSIX systems.
 + Use POSIX inttypes.h if BSD types are not available.
 + RPC includes and C++ namespace fixes.
 + Use dirent(3) instead of older sys/dir.h interface.
 + Avoid `sun' namespace collision.

Patch based on the work of Robert Lillack and others, described in
http://mail-index.netbsd.org/tech-pkg/2004/08/20/0005.html and tested with
SunPro and gcc.
2004-11-19 12:35:22 +00:00

175 lines
4.5 KiB
Text

$NetBSD: patch-af,v 1.4 2004/11/19 12:35:22 sketch Exp $
--- src/FileSystemTable.c++.orig 2003-01-18 14:18:12.000000000 +0000
+++ src/FileSystemTable.c++ 2004-11-08 17:08:21.655221000 +0000
@@ -21,11 +21,13 @@
// Temple Place - Suite 330, Boston MA 02111-1307, USA.
#include <stddef.h>
+#include <stdio.h>
#include "FileSystemTable.h"
-#include <mntent.h>
+#include "fam-mntent.h"
#include <stdlib.h>
#include <string.h>
+#include <sys/param.h>
#if HAVE_STATVFS
#include <sys/statvfs.h>
@@ -106,7 +108,11 @@
// Read /etc/mtab.
Cred::SuperUser.become_user();
+#if defined(HAVE_SYS_MNTTAB_H)
+ FILE *mtab = fopen(mtab_name, "r");
+#else
FILE *mtab = setmntent(mtab_name, "r");
+#endif
if(mtab == NULL)
{
Log::error("couldn't open %s for reading", mtab_name);
@@ -114,40 +120,86 @@
return;
}
root = NULL;
+#if defined(HAVE_SYS_MNTTAB_H)
+ resetmnttab(mtab);
+ int ret = 0;
+ do
+#else
for (mntent *mp; ((mp = getmntent(mtab)) != NULL); )
+#endif
{
+#if defined(HAVE_SYS_MNTTAB_H)
+ struct mnttab ment, *mp;
+ mp = &ment;
+ ret = getmntent(mtab, mp);
+ FileSystem *fs = fs_by_name ? fs_by_name->find(mp->mnt_mountp) : NULL;
+#else
FileSystem *fs = fs_by_name ? fs_by_name->find(mp->mnt_dir) : NULL;
+#endif
if (fs && fs->matches(*mp))
{
Log::debug("mtab: MATCH \"%s\" on \"%s\" using type <%s>",
+#if defined(HAVE_SYS_MNTTAB_H)
+ mp->mnt_special, mp->mnt_mountp, mp->mnt_fstype);
+
+ new_fs_by_name->insert(mp->mnt_mountp, fs);
+ if (dismounted_fses.find(mp->mnt_mountp))
+ dismounted_fses.remove(mp->mnt_mountp);
+#else
mp->mnt_fsname, mp->mnt_dir, mp->mnt_type);
new_fs_by_name->insert(mp->mnt_dir, fs);
if (dismounted_fses.find(mp->mnt_dir))
dismounted_fses.remove(mp->mnt_dir);
+#endif
}
else
{
+#if defined(HAVE_SYS_MNTTAB_H)
+ if ((!strcmp(mp->mnt_fstype, MNTTYPE_NFS)
+#else
if ((!strcmp(mp->mnt_type, MNTTYPE_NFS)
+#endif
#if HAVE_MNTTYPE_NFS2
+#if defined(HAVE_SYS_MNTTAB_H)
+ || !strcmp(mp->mnt_fstype, MNTTYPE_NFS2)
+#else
|| !strcmp(mp->mnt_type, MNTTYPE_NFS2)
#endif
+#endif
#if HAVE_MNTTYPE_NFS3
+#if defined(HAVE_SYS_MNTTAB_H)
+ || !strcmp(mp->mnt_fstype, MNTTYPE_NFS3)
+#else
|| !strcmp(mp->mnt_type, MNTTYPE_NFS3)
#endif
+#endif
#if HAVE_MNTTYPE_CACHEFS
+#if defined(HAVE_SYS_MNTTAB_H)
+ || !strcmp(mp->mnt_fstype, MNTTYPE_CACHEFS)
+#else
|| !strcmp(mp->mnt_type, MNTTYPE_CACHEFS)
#endif
+#endif
+#if defined(HAVE_SYS_MNTTAB_H)
+ ) && strchr(mp->mnt_special, ':'))
+#else
) && strchr(mp->mnt_fsname, ':'))
+#endif
{
if(Log::get_level() == Log::DEBUG)
{
const char *mntopt = hasmntopt(mp, "dev");
if(mntopt == NULL) mntopt = "";
Log::debug("mtab: new NFS \"%s\" on \"%s\" %s using <%s>",
+#if defined(HAVE_SYS_MNTTAB_H)
+ mp->mnt_special, mp->mnt_mountp, mntopt,
+ mp->mnt_fstype);
+#else
mp->mnt_fsname, mp->mnt_dir, mntopt,
mp->mnt_type);
+#endif
}
fs = new NFSFileSystem(*mp);
@@ -155,24 +207,45 @@
else
{
Log::debug("mtab: new local \"%s\" on \"%s\"",
+#if defined(HAVE_SYS_MNTTAB_H)
+ mp->mnt_special, mp->mnt_mountp);
+#else
mp->mnt_fsname, mp->mnt_dir);
+#endif
fs = new LocalFileSystem(*mp);
}
+#if defined(HAVE_SYS_MNTTAB_H)
+ new_fs_by_name->insert(mp->mnt_mountp, fs);
+#else
new_fs_by_name->insert(mp->mnt_dir, fs);
+#endif
if (fs_by_name)
{
// Find parent filesystem.
+#if defined(HAVE_SYS_MNTTAB_H)
+ FileSystem *parent = longest_prefix(mp->mnt_mountp);
+#else
FileSystem *parent = longest_prefix(mp->mnt_dir);
+#endif
assert(parent);
mount_parents.insert(parent->dir(), parent);
}
}
+#if defined(HAVE_SYS_MNTTAB_H)
+ if (!strcmp(mp->mnt_mountp, "/"))
+#else
if (!strcmp(mp->mnt_dir, "/"))
+#endif
root = fs;
}
+#if defined(HAVE_SYS_MNTTAB_H)
+ while (ret != -1);
+ fclose(mtab);
+#else
endmntent(mtab);
+#endif
if(root == NULL)
{
@@ -255,7 +328,10 @@
// create_fs_by_name initializes our "root" member variable.
if (!fs_by_name)
{ create_fs_by_name();
+#if !defined(BSD)
+ /* there is no mtab "file" in BSD */
mtab_watcher = new InternalClient(mtab_name, mtab_event_handler, NULL);
+#endif
}
cr.become_user();