Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / sysutils / fam / patches / patch-af
blobb3c7603b08ddcda309d84d116040088666b4aeda
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
5 @@ -21,11 +21,13 @@
6  //  Temple Place - Suite 330, Boston MA 02111-1307, USA.
7  
8  #include <stddef.h>
9 +#include <stdio.h>
10  #include "FileSystemTable.h"
12 -#include <mntent.h>
13 +#include "fam-mntent.h"
14  #include <stdlib.h>
15  #include <string.h>
16 +#include <sys/param.h>
18  #if HAVE_STATVFS
19  #include <sys/statvfs.h>
20 @@ -106,7 +108,11 @@
22      //  Read /etc/mtab.
23      Cred::SuperUser.become_user();
24 +#if defined(HAVE_SYS_MNTTAB_H)
25 +    FILE *mtab = fopen(mtab_name, "r");
26 +#else
27      FILE *mtab = setmntent(mtab_name, "r");
28 +#endif
29      if(mtab == NULL)
30      {
31          Log::error("couldn't open %s for reading", mtab_name);
32 @@ -114,40 +120,86 @@
33          return;
34      }
35      root = NULL;
36 +#if defined(HAVE_SYS_MNTTAB_H)
37 +    resetmnttab(mtab);
38 +    int ret = 0;
39 +    do
40 +#else
41      for (mntent *mp; ((mp = getmntent(mtab)) != NULL); )
42 +#endif
43      {
44 +#if defined(HAVE_SYS_MNTTAB_H)
45 +       struct mnttab ment, *mp;
46 +       mp = &ment;
47 +       ret = getmntent(mtab, mp);
48 +       FileSystem *fs = fs_by_name ? fs_by_name->find(mp->mnt_mountp) : NULL;
49 +#else
50         FileSystem *fs = fs_by_name ? fs_by_name->find(mp->mnt_dir) : NULL;
51 +#endif
52         if (fs && fs->matches(*mp))
53         {
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);
61 +#else
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);
67 +#endif
68         }
69         else
70         {
72 +#if defined(HAVE_SYS_MNTTAB_H)
73 +            if ((!strcmp(mp->mnt_fstype, MNTTYPE_NFS)
74 +#else
75              if ((!strcmp(mp->mnt_type, MNTTYPE_NFS)
76 +#endif
77  #if HAVE_MNTTYPE_NFS2
78 +#if defined(HAVE_SYS_MNTTAB_H)
79 +                || !strcmp(mp->mnt_fstype, MNTTYPE_NFS2)
80 +#else
81                  || !strcmp(mp->mnt_type, MNTTYPE_NFS2)
82  #endif
83 +#endif
84  #if HAVE_MNTTYPE_NFS3
85 +#if defined(HAVE_SYS_MNTTAB_H)
86 +                || !strcmp(mp->mnt_fstype, MNTTYPE_NFS3)
87 +#else
88                  || !strcmp(mp->mnt_type, MNTTYPE_NFS3)
89  #endif
90 +#endif
91  #if HAVE_MNTTYPE_CACHEFS
92 +#if defined(HAVE_SYS_MNTTAB_H)
93 +                || !strcmp(mp->mnt_fstype, MNTTYPE_CACHEFS)
94 +#else
95                  || !strcmp(mp->mnt_type, MNTTYPE_CACHEFS)
96  #endif
97 +#endif
98 +#if defined(HAVE_SYS_MNTTAB_H)
99 +                ) && strchr(mp->mnt_special, ':'))
100 +#else
101                  ) && strchr(mp->mnt_fsname, ':'))
102 +#endif
103              {
104                  if(Log::get_level() == Log::DEBUG)
105                  {
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,
111 +                               mp->mnt_fstype);
112 +#else
113                                mp->mnt_fsname, mp->mnt_dir, mntopt,
114                                 mp->mnt_type);
115 +#endif
116                  }
118                 fs = new NFSFileSystem(*mp);
119 @@ -155,24 +207,45 @@
120             else
121             {
122                 Log::debug("mtab: new local \"%s\" on \"%s\"",
123 +#if defined(HAVE_SYS_MNTTAB_H)
124 +                          mp->mnt_special, mp->mnt_mountp);
125 +#else
126                            mp->mnt_fsname, mp->mnt_dir);
127 +#endif
129                 fs = new LocalFileSystem(*mp);
130             }
131 +#if defined(HAVE_SYS_MNTTAB_H)
132 +           new_fs_by_name->insert(mp->mnt_mountp, fs);
133 +#else
134             new_fs_by_name->insert(mp->mnt_dir, fs);
135 +#endif
136             if (fs_by_name)
137             {
138                 // Find parent filesystem.
140 +#if defined(HAVE_SYS_MNTTAB_H)
141 +               FileSystem *parent = longest_prefix(mp->mnt_mountp);
142 +#else
143                 FileSystem *parent = longest_prefix(mp->mnt_dir);
144 +#endif
145                 assert(parent);
146                 mount_parents.insert(parent->dir(), parent);
147             }
148         }
149 +#if defined(HAVE_SYS_MNTTAB_H)
150 +       if (!strcmp(mp->mnt_mountp, "/"))
151 +#else
152         if (!strcmp(mp->mnt_dir, "/"))
153 +#endif
154             root = fs;
155      }
156 +#if defined(HAVE_SYS_MNTTAB_H)
157 +    while (ret != -1);
158 +    fclose(mtab);
159 +#else
160      endmntent(mtab);
161 +#endif
163      if(root == NULL)
164      {
165 @@ -255,7 +328,10 @@
166      //  create_fs_by_name initializes our "root" member variable.
167      if (!fs_by_name)
168      {   create_fs_by_name();
169 +#if !defined(BSD)
170 +        /* there is no mtab "file" in BSD */
171         mtab_watcher = new InternalClient(mtab_name, mtab_event_handler, NULL);
172 +#endif
173      }
175      cr.become_user();