summaryrefslogtreecommitdiff
path: root/sysutils/fam/patches/patch-af
blob: f140904add4c03a3f5aa3d9582abb871072371cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
$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();