1 $NetBSD: patch-af,v 1.3 2004/03/28 22:00:05 minskim Exp $
3 --- src/FileSystemTable.c++.orig 2003-01-18 14:18:12.000000000 +0000
4 +++ src/FileSystemTable.c++ 2004-11-08 17:08:21.655221000 +0000
6 // Temple Place - Suite 330, Boston MA 02111-1307, USA.
10 #include "FileSystemTable.h"
13 +#include "fam-mntent.h"
16 +#include <sys/param.h>
19 #include <sys/statvfs.h>
23 Cred::SuperUser.become_user();
24 +#if defined(HAVE_SYS_MNTTAB_H)
25 + FILE *mtab = fopen(mtab_name, "r");
27 FILE *mtab = setmntent(mtab_name, "r");
31 Log::error("couldn't open %s for reading", mtab_name);
36 +#if defined(HAVE_SYS_MNTTAB_H)
41 for (mntent *mp; ((mp = getmntent(mtab)) != NULL); )
44 +#if defined(HAVE_SYS_MNTTAB_H)
45 + struct mnttab ment, *mp;
47 + ret = getmntent(mtab, mp);
48 + FileSystem *fs = fs_by_name ? fs_by_name->find(mp->mnt_mountp) : NULL;
50 FileSystem *fs = fs_by_name ? fs_by_name->find(mp->mnt_dir) : NULL;
52 if (fs && fs->matches(*mp))
54 Log::debug("mtab: MATCH \"%s\" on \"%s\" using type <%s>",
55 +#if defined(HAVE_SYS_MNTTAB_H)
56 + mp->mnt_special, mp->mnt_mountp, mp->mnt_fstype);
58 + new_fs_by_name->insert(mp->mnt_mountp, fs);
59 + if (dismounted_fses.find(mp->mnt_mountp))
60 + dismounted_fses.remove(mp->mnt_mountp);
62 mp->mnt_fsname, mp->mnt_dir, mp->mnt_type);
64 new_fs_by_name->insert(mp->mnt_dir, fs);
65 if (dismounted_fses.find(mp->mnt_dir))
66 dismounted_fses.remove(mp->mnt_dir);
72 +#if defined(HAVE_SYS_MNTTAB_H)
73 + if ((!strcmp(mp->mnt_fstype, MNTTYPE_NFS)
75 if ((!strcmp(mp->mnt_type, MNTTYPE_NFS)
78 +#if defined(HAVE_SYS_MNTTAB_H)
79 + || !strcmp(mp->mnt_fstype, MNTTYPE_NFS2)
81 || !strcmp(mp->mnt_type, MNTTYPE_NFS2)
85 +#if defined(HAVE_SYS_MNTTAB_H)
86 + || !strcmp(mp->mnt_fstype, MNTTYPE_NFS3)
88 || !strcmp(mp->mnt_type, MNTTYPE_NFS3)
91 #if HAVE_MNTTYPE_CACHEFS
92 +#if defined(HAVE_SYS_MNTTAB_H)
93 + || !strcmp(mp->mnt_fstype, MNTTYPE_CACHEFS)
95 || !strcmp(mp->mnt_type, MNTTYPE_CACHEFS)
98 +#if defined(HAVE_SYS_MNTTAB_H)
99 + ) && strchr(mp->mnt_special, ':'))
101 ) && strchr(mp->mnt_fsname, ':'))
104 if(Log::get_level() == Log::DEBUG)
106 const char *mntopt = hasmntopt(mp, "dev");
107 if(mntopt == NULL) mntopt = "";
108 Log::debug("mtab: new NFS \"%s\" on \"%s\" %s using <%s>",
109 +#if defined(HAVE_SYS_MNTTAB_H)
110 + mp->mnt_special, mp->mnt_mountp, mntopt,
113 mp->mnt_fsname, mp->mnt_dir, mntopt,
118 fs = new NFSFileSystem(*mp);
119 @@ -155,24 +207,45 @@
122 Log::debug("mtab: new local \"%s\" on \"%s\"",
123 +#if defined(HAVE_SYS_MNTTAB_H)
124 + mp->mnt_special, mp->mnt_mountp);
126 mp->mnt_fsname, mp->mnt_dir);
129 fs = new LocalFileSystem(*mp);
131 +#if defined(HAVE_SYS_MNTTAB_H)
132 + new_fs_by_name->insert(mp->mnt_mountp, fs);
134 new_fs_by_name->insert(mp->mnt_dir, fs);
138 // Find parent filesystem.
140 +#if defined(HAVE_SYS_MNTTAB_H)
141 + FileSystem *parent = longest_prefix(mp->mnt_mountp);
143 FileSystem *parent = longest_prefix(mp->mnt_dir);
146 mount_parents.insert(parent->dir(), parent);
149 +#if defined(HAVE_SYS_MNTTAB_H)
150 + if (!strcmp(mp->mnt_mountp, "/"))
152 if (!strcmp(mp->mnt_dir, "/"))
156 +#if defined(HAVE_SYS_MNTTAB_H)
166 // create_fs_by_name initializes our "root" member variable.
168 { create_fs_by_name();
170 + /* there is no mtab "file" in BSD */
171 mtab_watcher = new InternalClient(mtab_name, mtab_event_handler, NULL);