|
1 This patch adds the configure rules and the conditional compilation to |
|
2 allow the code to be compiled on Solaris 11, which uses a 2 argument |
|
3 version of getmntent() |
|
4 We have upstream support ticket #12 to track the Solaris port, available |
|
5 at: https://fedorahosted.org/mlocate/ticket/12 |
|
6 diff -rupN mlocate-0.25-htonll/configure.ac mlocate-0.25/configure.ac |
|
7 --- mlocate-0.25-htonll/configure.ac 2013-02-18 22:18:47.880624254 +0000 |
|
8 +++ mlocate-0.25/configure.ac 2013-02-18 22:38:01.215736074 +0000 |
|
9 @@ -55,6 +55,8 @@ AC_FUNC_GETMNTENT |
|
10 # Checks for system services. |
|
11 AC_SYS_LARGEFILE |
|
12 |
|
13 +gl_LIST_MOUNTED_FILE_SYSTEMS |
|
14 + |
|
15 AC_CACHE_CHECK([for mounted filesystem table in /proc], |
|
16 [mitr_cv_sys_proc_mounts], |
|
17 [mitr_cv_sys_proc_mounts=no |
|
18 diff -rupN mlocate-0.25-htonll/gnulib/m4/ls-mntd-fs.m4 mlocate-0.25/gnulib/m4/ls-mntd-fs.m4 |
|
19 --- mlocate-0.25-htonll/gnulib/m4/ls-mntd-fs.m4 1970-01-01 01:00:00.000000000 +0100 |
|
20 +++ mlocate-0.25/gnulib/m4/ls-mntd-fs.m4 2013-02-18 22:38:13.068889474 +0000 |
|
21 @@ -0,0 +1,337 @@ |
|
22 +#serial 26 |
|
23 +# How to list mounted file systems. |
|
24 + |
|
25 +# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software |
|
26 +# Foundation, Inc. |
|
27 +# |
|
28 +# This file is free software; the Free Software Foundation |
|
29 +# gives unlimited permission to copy and/or distribute it, |
|
30 +# with or without modifications, as long as this notice is preserved. |
|
31 + |
|
32 +dnl From Jim Meyering. |
|
33 +dnl |
|
34 +dnl This is not pretty. I've just taken the autoconf code and wrapped |
|
35 +dnl it in an AC_DEFUN and made some other fixes. |
|
36 +dnl |
|
37 + |
|
38 +# Replace Autoconf's AC_FUNC_GETMNTENT to work around a bug in Autoconf |
|
39 +# through Autoconf 2.59. We can remove this once we assume Autoconf 2.60 |
|
40 +# or later. |
|
41 +AC_DEFUN([AC_FUNC_GETMNTENT], |
|
42 +[# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4, |
|
43 +# -lseq on Dynix/PTX, -lgen on Unixware. |
|
44 +AC_SEARCH_LIBS(getmntent, [sun seq gen]) |
|
45 +AC_CHECK_FUNCS(getmntent) |
|
46 +]) |
|
47 + |
|
48 +# gl_LIST_MOUNTED_FILE_SYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) |
|
49 +AC_DEFUN([gl_LIST_MOUNTED_FILE_SYSTEMS], |
|
50 + [ |
|
51 +AC_CHECK_FUNCS(listmntent getmntinfo) |
|
52 +AC_CHECK_HEADERS_ONCE(sys/param.h sys/statvfs.h) |
|
53 + |
|
54 +# We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses |
|
55 +# NGROUPS (as the array dimension for a struct member) without a definition. |
|
56 +AC_CHECK_HEADERS(sys/ucred.h, [], [], [#include <grp.h>]) |
|
57 + |
|
58 +AC_CHECK_HEADERS(sys/mount.h, [], [], |
|
59 + [AC_INCLUDES_DEFAULT |
|
60 + [#if HAVE_SYS_PARAM_H |
|
61 + #include <sys/param.h> |
|
62 + #endif]]) |
|
63 + |
|
64 +AC_CHECK_HEADERS(mntent.h sys/fs_types.h) |
|
65 + getfsstat_includes="\ |
|
66 +$ac_includes_default |
|
67 +#if HAVE_SYS_PARAM_H |
|
68 +# include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */ |
|
69 +#endif |
|
70 +#if HAVE_SYS_UCRED_H |
|
71 +# include <grp.h> /* needed for definition of NGROUPS */ |
|
72 +# include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */ |
|
73 +#endif |
|
74 +#if HAVE_SYS_MOUNT_H |
|
75 +# include <sys/mount.h> |
|
76 +#endif |
|
77 +#if HAVE_SYS_FS_TYPES_H |
|
78 +# include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */ |
|
79 +#endif |
|
80 +" |
|
81 +AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes]) |
|
82 + |
|
83 +# Determine how to get the list of mounted file systems. |
|
84 +ac_list_mounted_fs= |
|
85 + |
|
86 +# If the getmntent function is available but not in the standard library, |
|
87 +# make sure LIBS contains the appropriate -l option. |
|
88 +AC_FUNC_GETMNTENT |
|
89 + |
|
90 +# This test must precede the ones for getmntent because Unicos-9 is |
|
91 +# reported to have the getmntent function, but its support is incompatible |
|
92 +# with other getmntent implementations. |
|
93 + |
|
94 +# NOTE: Normally, I wouldn't use a check for system type as I've done for |
|
95 +# `CRAY' below since that goes against the whole autoconf philosophy. But |
|
96 +# I think there is too great a chance that some non-Cray system has a |
|
97 +# function named listmntent to risk the false positive. |
|
98 + |
|
99 +if test -z "$ac_list_mounted_fs"; then |
|
100 + # Cray UNICOS 9 |
|
101 + AC_MSG_CHECKING([for listmntent of Cray/Unicos-9]) |
|
102 + AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent, |
|
103 + [fu_cv_sys_mounted_cray_listmntent=no |
|
104 + AC_EGREP_CPP(yes, |
|
105 + [#ifdef _CRAY |
|
106 +yes |
|
107 +#endif |
|
108 + ], [test $ac_cv_func_listmntent = yes \ |
|
109 + && fu_cv_sys_mounted_cray_listmntent=yes] |
|
110 + ) |
|
111 + ] |
|
112 + ) |
|
113 + AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent) |
|
114 + if test $fu_cv_sys_mounted_cray_listmntent = yes; then |
|
115 + ac_list_mounted_fs=found |
|
116 + AC_DEFINE(MOUNTED_LISTMNTENT, 1, |
|
117 + [Define if there is a function named listmntent that can be used to |
|
118 + list all mounted file systems. (UNICOS)]) |
|
119 + fi |
|
120 +fi |
|
121 + |
|
122 +if test -z "$ac_list_mounted_fs"; then |
|
123 + # AIX. |
|
124 + AC_MSG_CHECKING([for mntctl function and struct vmount]) |
|
125 + AC_CACHE_VAL(fu_cv_sys_mounted_vmount, |
|
126 + [AC_TRY_CPP([#include <fshelp.h>], |
|
127 + fu_cv_sys_mounted_vmount=yes, |
|
128 + fu_cv_sys_mounted_vmount=no)]) |
|
129 + AC_MSG_RESULT($fu_cv_sys_mounted_vmount) |
|
130 + if test $fu_cv_sys_mounted_vmount = yes; then |
|
131 + ac_list_mounted_fs=found |
|
132 + AC_DEFINE(MOUNTED_VMOUNT, 1, |
|
133 + [Define if there is a function named mntctl that can be used to read |
|
134 + the list of mounted file systems, and there is a system header file |
|
135 + that declares `struct vmount.' (AIX)]) |
|
136 + fi |
|
137 +fi |
|
138 + |
|
139 +if test $ac_cv_func_getmntent = yes; then |
|
140 + |
|
141 + # This system has the getmntent function. |
|
142 + # Determine whether it's the one-argument variant or the two-argument one. |
|
143 + |
|
144 + if test -z "$ac_list_mounted_fs"; then |
|
145 + # 4.3BSD, SunOS, HP-UX, Dynix, Irix |
|
146 + AC_MSG_CHECKING([for one-argument getmntent function]) |
|
147 + AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1, |
|
148 + [AC_TRY_COMPILE([ |
|
149 +/* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */ |
|
150 +#include <stdio.h> |
|
151 + |
|
152 +#include <mntent.h> |
|
153 +#if !defined MOUNTED |
|
154 +# if defined _PATH_MOUNTED /* GNU libc */ |
|
155 +# define MOUNTED _PATH_MOUNTED |
|
156 +# endif |
|
157 +# if defined MNT_MNTTAB /* HP-UX. */ |
|
158 +# define MOUNTED MNT_MNTTAB |
|
159 +# endif |
|
160 +# if defined MNTTABNAME /* Dynix. */ |
|
161 +# define MOUNTED MNTTABNAME |
|
162 +# endif |
|
163 +#endif |
|
164 +], |
|
165 + [ struct mntent *mnt = 0; char *table = MOUNTED; |
|
166 + if (sizeof mnt && sizeof table) return 0;], |
|
167 + fu_cv_sys_mounted_getmntent1=yes, |
|
168 + fu_cv_sys_mounted_getmntent1=no)]) |
|
169 + AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1) |
|
170 + if test $fu_cv_sys_mounted_getmntent1 = yes; then |
|
171 + ac_list_mounted_fs=found |
|
172 + AC_DEFINE(MOUNTED_GETMNTENT1, 1, |
|
173 + [Define if there is a function named getmntent for reading the list |
|
174 + of mounted file systems, and that function takes a single argument. |
|
175 + (4.3BSD, SunOS, HP-UX, Dynix, Irix)]) |
|
176 + fi |
|
177 + fi |
|
178 + |
|
179 + if test -z "$ac_list_mounted_fs"; then |
|
180 + # SVR4 |
|
181 + AC_MSG_CHECKING([for two-argument getmntent function]) |
|
182 + AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2, |
|
183 + [AC_EGREP_HEADER(getmntent, sys/mnttab.h, |
|
184 + fu_cv_sys_mounted_getmntent2=yes, |
|
185 + fu_cv_sys_mounted_getmntent2=no)]) |
|
186 + AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2) |
|
187 + if test $fu_cv_sys_mounted_getmntent2 = yes; then |
|
188 + ac_list_mounted_fs=found |
|
189 + AC_DEFINE(MOUNTED_GETMNTENT2, 1, |
|
190 + [Define if there is a function named getmntent for reading the list of |
|
191 + mounted file systems, and that function takes two arguments. (SVR4)]) |
|
192 + AC_CHECK_FUNCS(hasmntopt) |
|
193 + fi |
|
194 + fi |
|
195 + |
|
196 +fi |
|
197 + |
|
198 +if test -z "$ac_list_mounted_fs"; then |
|
199 + # DEC Alpha running OSF/1, and Apple Darwin 1.3. |
|
200 + # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h |
|
201 + |
|
202 + AC_MSG_CHECKING([for getfsstat function]) |
|
203 + AC_CACHE_VAL(fu_cv_sys_mounted_getfsstat, |
|
204 + [AC_TRY_LINK([ |
|
205 +#include <sys/types.h> |
|
206 +#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME |
|
207 +# define FS_TYPE(Ent) ((Ent).f_fstypename) |
|
208 +#else |
|
209 +# define FS_TYPE(Ent) mnt_names[(Ent).f_type] |
|
210 +#endif |
|
211 +]$getfsstat_includes |
|
212 +, |
|
213 + [struct statfs *stats; |
|
214 + int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); |
|
215 + char *t = FS_TYPE (*stats); ], |
|
216 + fu_cv_sys_mounted_getfsstat=yes, |
|
217 + fu_cv_sys_mounted_getfsstat=no)]) |
|
218 + AC_MSG_RESULT($fu_cv_sys_mounted_getfsstat) |
|
219 + if test $fu_cv_sys_mounted_getfsstat = yes; then |
|
220 + ac_list_mounted_fs=found |
|
221 + AC_DEFINE(MOUNTED_GETFSSTAT, 1, |
|
222 + [Define if there is a function named getfsstat for reading the |
|
223 + list of mounted file systems. (DEC Alpha running OSF/1)]) |
|
224 + fi |
|
225 +fi |
|
226 + |
|
227 +if test -z "$ac_list_mounted_fs"; then |
|
228 + # SVR3 |
|
229 + AC_MSG_CHECKING([for FIXME existence of three headers]) |
|
230 + AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp, |
|
231 + [AC_TRY_CPP([ |
|
232 +#include <sys/statfs.h> |
|
233 +#include <sys/fstyp.h> |
|
234 +#include <mnttab.h>], |
|
235 + fu_cv_sys_mounted_fread_fstyp=yes, |
|
236 + fu_cv_sys_mounted_fread_fstyp=no)]) |
|
237 + AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp) |
|
238 + if test $fu_cv_sys_mounted_fread_fstyp = yes; then |
|
239 + ac_list_mounted_fs=found |
|
240 + AC_DEFINE(MOUNTED_FREAD_FSTYP, 1, |
|
241 + [Define if (like SVR2) there is no specific function for reading the |
|
242 + list of mounted file systems, and your system has these header files: |
|
243 + <sys/fstyp.h> and <sys/statfs.h>. (SVR3)]) |
|
244 + fi |
|
245 +fi |
|
246 + |
|
247 +if test -z "$ac_list_mounted_fs"; then |
|
248 + # 4.4BSD and DEC OSF/1. |
|
249 + AC_MSG_CHECKING([for getmntinfo function]) |
|
250 + AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo, |
|
251 + [ |
|
252 + test "$ac_cv_func_getmntinfo" = yes \ |
|
253 + && fu_cv_sys_mounted_getmntinfo=yes \ |
|
254 + || fu_cv_sys_mounted_getmntinfo=no |
|
255 + ]) |
|
256 + AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo) |
|
257 + if test $fu_cv_sys_mounted_getmntinfo = yes; then |
|
258 + AC_MSG_CHECKING([whether getmntinfo returns statvfs structures]) |
|
259 + AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo2, |
|
260 + [ |
|
261 + AC_TRY_COMPILE([ |
|
262 +#if HAVE_SYS_PARAM_H |
|
263 +# include <sys/param.h> |
|
264 +#endif |
|
265 +#include <sys/types.h> |
|
266 +#if HAVE_SYS_MOUNT_H |
|
267 +# include <sys/mount.h> |
|
268 +#endif |
|
269 +#if HAVE_SYS_STATVFS_H |
|
270 +# include <sys/statvfs.h> |
|
271 +#endif |
|
272 +extern int getmntinfo (struct statfs **, int); |
|
273 + ], [], |
|
274 + [fu_cv_sys_mounted_getmntinfo2=no], |
|
275 + [fu_cv_sys_mounted_getmntinfo2=yes]) |
|
276 + ]) |
|
277 + AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo2]) |
|
278 + if test $fu_cv_sys_mounted_getmntinfo2 = no; then |
|
279 + ac_list_mounted_fs=found |
|
280 + AC_DEFINE(MOUNTED_GETMNTINFO, 1, |
|
281 + [Define if there is a function named getmntinfo for reading the |
|
282 + list of mounted file systems and it returns an array of |
|
283 + 'struct statfs'. (4.4BSD, Darwin)]) |
|
284 + else |
|
285 + ac_list_mounted_fs=found |
|
286 + AC_DEFINE(MOUNTED_GETMNTINFO2, 1, |
|
287 + [Define if there is a function named getmntinfo for reading the |
|
288 + list of mounted file systems and it returns an array of |
|
289 + 'struct statvfs'. (NetBSD 3.0)]) |
|
290 + fi |
|
291 + fi |
|
292 +fi |
|
293 + |
|
294 +if test -z "$ac_list_mounted_fs"; then |
|
295 + # Ultrix |
|
296 + AC_MSG_CHECKING([for getmnt function]) |
|
297 + AC_CACHE_VAL(fu_cv_sys_mounted_getmnt, |
|
298 + [AC_TRY_CPP([ |
|
299 +#include <sys/fs_types.h> |
|
300 +#include <sys/mount.h>], |
|
301 + fu_cv_sys_mounted_getmnt=yes, |
|
302 + fu_cv_sys_mounted_getmnt=no)]) |
|
303 + AC_MSG_RESULT($fu_cv_sys_mounted_getmnt) |
|
304 + if test $fu_cv_sys_mounted_getmnt = yes; then |
|
305 + ac_list_mounted_fs=found |
|
306 + AC_DEFINE(MOUNTED_GETMNT, 1, |
|
307 + [Define if there is a function named getmnt for reading the list of |
|
308 + mounted file systems. (Ultrix)]) |
|
309 + fi |
|
310 +fi |
|
311 + |
|
312 +if test -z "$ac_list_mounted_fs"; then |
|
313 + # BeOS |
|
314 + AC_CHECK_FUNCS(next_dev fs_stat_dev) |
|
315 + AC_CHECK_HEADERS(fs_info.h) |
|
316 + AC_MSG_CHECKING([for BEOS mounted file system support functions]) |
|
317 + if test $ac_cv_header_fs_info_h = yes \ |
|
318 + && test $ac_cv_func_next_dev = yes \ |
|
319 + && test $ac_cv_func_fs_stat_dev = yes; then |
|
320 + fu_result=yes |
|
321 + else |
|
322 + fu_result=no |
|
323 + fi |
|
324 + AC_MSG_RESULT($fu_result) |
|
325 + if test $fu_result = yes; then |
|
326 + ac_list_mounted_fs=found |
|
327 + AC_DEFINE(MOUNTED_FS_STAT_DEV, 1, |
|
328 + [Define if there are functions named next_dev and fs_stat_dev for |
|
329 + reading the list of mounted file systems. (BeOS)]) |
|
330 + fi |
|
331 +fi |
|
332 + |
|
333 +if test -z "$ac_list_mounted_fs"; then |
|
334 + # SVR2 |
|
335 + AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab]) |
|
336 + AC_CACHE_VAL(fu_cv_sys_mounted_fread, |
|
337 + [AC_TRY_CPP([#include <mnttab.h>], |
|
338 + fu_cv_sys_mounted_fread=yes, |
|
339 + fu_cv_sys_mounted_fread=no)]) |
|
340 + AC_MSG_RESULT($fu_cv_sys_mounted_fread) |
|
341 + if test $fu_cv_sys_mounted_fread = yes; then |
|
342 + ac_list_mounted_fs=found |
|
343 + AC_DEFINE(MOUNTED_FREAD, 1, |
|
344 + [Define if there is no specific function for reading the list of |
|
345 + mounted file systems. fread will be used to read /etc/mnttab. |
|
346 + (SVR2) ]) |
|
347 + fi |
|
348 +fi |
|
349 + |
|
350 +if test -z "$ac_list_mounted_fs"; then |
|
351 + AC_MSG_ERROR([could not determine how to read list of mounted file systems]) |
|
352 + # FIXME -- no need to abort building the whole package |
|
353 + # Can't build mountlist.c or anything that needs its functions |
|
354 +fi |
|
355 + |
|
356 +AS_IF([test $ac_list_mounted_fs = found], [$1], [$2]) |
|
357 + |
|
358 + ]) |
|
359 diff -rupN mlocate-0.25-htonll/src/updatedb.c mlocate-0.25/src/updatedb.c |
|
360 --- mlocate-0.25-htonll/src/updatedb.c 2011-12-11 23:13:18.000000000 +0000 |
|
361 +++ mlocate-0.25/src/updatedb.c 2013-02-18 22:37:53.812745988 +0000 |
|
362 @@ -36,7 +36,15 @@ Author: Miloslav Trmac <[email protected]> |
|
363 #include <sys/time.h> |
|
364 #include <unistd.h> |
|
365 |
|
366 +#if defined (MOUNTED_GETMNTENT1) |
|
367 #include <mntent.h> |
|
368 +#else |
|
369 +#if defined (MOUNTED_GETMNTENT2) |
|
370 +#include <sys/mnttab.h> |
|
371 +#else |
|
372 +#error "No valid getmntent() #include defined" |
|
373 +#endif |
|
374 +#endif |
|
375 #include "error.h" |
|
376 #include "fwriteerror.h" |
|
377 #include "obstack.h" |
|
378 @@ -53,7 +61,11 @@ Author: Miloslav Trmac <[email protected]> |
|
379 #ifdef PROC_MOUNTS_PATH |
|
380 #define MOUNT_TABLE_PATH PROC_MOUNTS_PATH |
|
381 #else |
|
382 +#ifdef _PATH_MOUNTED |
|
383 #define MOUNT_TABLE_PATH _PATH_MOUNTED |
|
384 +#else |
|
385 +#define MOUNT_TABLE_PATH MNTTAB |
|
386 +#endif |
|
387 #endif |
|
388 |
|
389 /* A directory entry in memory */ |
|
390 @@ -334,7 +346,21 @@ filesystem_is_excluded (const char *path |
|
391 static size_t type_size; /* = 0; */ |
|
392 |
|
393 FILE *f; |
|
394 +#if defined (MOUNTED_GETMNTENT1) |
|
395 struct mntent *me; |
|
396 +#else |
|
397 +#if defined (MOUNTED_GETMNTENT2) |
|
398 + struct mnttab me_local; |
|
399 + /* Convenience pointer */ |
|
400 + struct mnttab *me = &me_local; |
|
401 + /* Macro substitution to make the structure members correct */ |
|
402 +#define mnt_type mnt_fstype |
|
403 +#define mnt_dir mnt_mountp |
|
404 + /* setmntent() and endmntent() are undefined in this envonronment */ |
|
405 +#define setmntent(x,y) fopen(x,y) |
|
406 +#define endmntent(x) fclose(x) |
|
407 +#endif |
|
408 +#endif |
|
409 bool res; |
|
410 |
|
411 if (conf_debug_pruning != false) |
|
412 @@ -344,7 +370,13 @@ filesystem_is_excluded (const char *path |
|
413 f = setmntent (MOUNT_TABLE_PATH, "r"); |
|
414 if (f == NULL) |
|
415 goto err; |
|
416 +#if defined (MOUNTED_GETMNTENT1) |
|
417 while ((me = getmntent (f)) != NULL) |
|
418 +#else |
|
419 +#if defined (MOUNTED_GETMNTENT2) |
|
420 + while ((getmntent (f, me)) == 0) |
|
421 +#endif |
|
422 +#endif |
|
423 { |
|
424 char *p; |
|
425 size_t size; |
|
426 @@ -367,7 +399,6 @@ filesystem_is_excluded (const char *path |
|
427 dir = canonicalize_file_name (me->mnt_dir); |
|
428 if (dir == NULL) |
|
429 dir = me->mnt_dir; |
|
430 -#else |
|
431 /* Paths in /proc/self/mounts contain no symbolic links. Besides |
|
432 avoiding a few system calls, avoiding the realpath () avoids hangs |
|
433 if the filesystem is unavailable hard-mounted NFS. */ |