# HG changeset patch # User Rainer Müller # Date 1269225248 -3600 # Mon Mar 22 03:34:08 2010 +0100 # Node ID 1e336459edba3afa48273143f532357666169d34 # Parent f6d25b571dcd77a1909539658777bdf55131e156 Use gnulib mountlist This adds support for systems without getmntent(3) by using the mountlist module from gnulib. diff -r f6d25b571dcd -r 1e336459edba gnulib/m4/gnulib-cache.m4 --- a/gnulib/m4/gnulib-cache.m4 Mon Aug 30 22:42:31 2010 +0000 +++ b/gnulib/m4/gnulib-cache.m4 Mon Mar 22 03:34:08 2010 +0100 @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2007 Free Software Foundation, Inc. +# Copyright (C) 2002-2009 Free Software Foundation, Inc. # # This file is free software, distributed under the terms of the GNU # General Public License. As a special exception to the GNU General @@ -15,11 +15,31 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=admin --no-libtool --macro-prefix=gl canonicalize-lgpl config-h d-type error fnmatch-gnu fwriteerror getopt gettext-h mbsstr mempcpy obstack progname safe-read stat-time strchrnul timespec verify xalloc +# gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=tests --aux-dir=admin --no-libtool --macro-prefix=gl canonicalize-lgpl config-h d-type error fnmatch-gnu fwriteerror getopt gettext-h mbsstr mempcpy mountlist obstack progname safe-read stat-time strchrnul timespec verify xalloc # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) -gl_MODULES([canonicalize-lgpl config-h d-type error fnmatch-gnu fwriteerror getopt gettext-h mbsstr mempcpy obstack progname safe-read stat-time strchrnul timespec verify xalloc]) +gl_MODULES([ + canonicalize-lgpl + config-h + d-type + error + fnmatch-gnu + fwriteerror + getopt + gettext-h + mbsstr + mempcpy + mountlist + obstack + progname + safe-read + stat-time + strchrnul + timespec + verify + xalloc +]) gl_AVOID([]) gl_SOURCE_BASE([gnulib/lib]) gl_M4_BASE([gnulib/m4]) diff -r f6d25b571dcd -r 1e336459edba src/updatedb.c --- a/src/updatedb.c Mon Aug 30 22:42:31 2010 +0000 +++ b/src/updatedb.c Mon Mar 22 03:34:08 2010 +0100 @@ -36,7 +36,11 @@ #include #include +#ifdef HAVE_GETMNTENT #include +#else +#include "mountlist.h" +#endif #include "error.h" #include "fwriteerror.h" #include "obstack.h" @@ -50,11 +54,13 @@ #include "db.h" #include "lib.h" +#ifdef HAVE_GETMNTENT #ifdef PROC_MOUNTS_PATH #define MOUNT_TABLE_PATH PROC_MOUNTS_PATH #else #define MOUNT_TABLE_PATH _PATH_MOUNTED #endif +#endif /* A directory entry in memory */ struct entry @@ -338,6 +344,7 @@ /* $PRUNE_BIND_MOUNTS handling */ +#ifdef HAVE_GETMNTENT /* Known bind mount paths */ static struct string_list bind_mount_paths; /* = { 0, }; */ @@ -363,6 +370,7 @@ obstack_free (&bind_mount_paths_obstack, bind_mount_paths_mark); bind_mount_paths_mark = obstack_alloc (&bind_mount_paths_obstack, 0); bind_mount_paths.len = 0; + f = setmntent (_PATH_MOUNTED, "r"); if (f == NULL) goto err; @@ -438,6 +446,7 @@ rebuild_bind_mount_paths (); last_path_mounted_mtime = get_stat_mtime (&st); } +#endif /* $PRUNEFS handling */ @@ -459,46 +468,65 @@ static char *type; /* = NULL; */ static size_t type_size; /* = 0; */ +#if HAVE_GETMNTENT FILE *f; struct mntent *me; +#else + struct mount_entry *me; +#endif bool res; if (conf_debug_pruning != false) /* This is debuging output, don't mark anything for translation */ fprintf (stderr, "Checking whether filesystem `%s' is excluded:\n", path); res = false; + +#ifdef HAVE_GETMNTENT f = setmntent (MOUNT_TABLE_PATH, "r"); if (f == NULL) goto err; while ((me = getmntent (f)) != NULL) +#else + me = read_file_system_list(true); + while (me != NULL) +#endif { char *p; size_t size; - + char *me_dir; + char *me_type; +#ifdef HAVE_GETMNTENT + me_dir = me->mnt_dir; + me_type = me->mnt_type; +#else + me_dir = me->me_mountdir; + me_type = me->me_type; +#endif if (conf_debug_pruning != false) /* This is debuging output, don't mark anything for translation */ - fprintf (stderr, " `%s', type `%s'\n", me->mnt_dir, me->mnt_type); - size = strlen (me->mnt_type) + 1; + fprintf (stderr, " `%s', type `%s'\n", me_dir, me_type); + + size = strlen (me_type) + 1; while (size > type_size) type = x2realloc (type, &type_size); - memcpy (type, me->mnt_type, size); + memcpy (type, me_type, size); for (p = type; *p != 0; p++) *p = toupper((unsigned char)*p); if (bsearch (type, conf_prunefs.entries, conf_prunefs.len, sizeof (*conf_prunefs.entries), cmp_string_pointer) != NULL) { char *dir; -#ifndef PROC_MOUNTS_PATH +#if !defined(PROC_MOUNTS_PATH) || !defined(HAVE_GETMNTENT) char dbuf[PATH_MAX]; - dir = realpath (me->mnt_dir, dbuf); + dir = realpath (me_dir, dbuf); if (dir == NULL) - dir = me->mnt_dir; + dir = me_dir; #else /* Paths in /proc/self/mounts contain no symbolic links. Besides avoiding a few system calls, avoiding the realpath () avoids hangs if the filesystem is unavailable hard-mounted NFS. */ - dir = me->mnt_dir; + dir = me_dir; #endif if (conf_debug_pruning != false) /* This is debuging output, don't mark anything for translation */ @@ -511,7 +539,9 @@ } } err_f: +#ifdef HAVE_GETMNTENT endmntent (f); +#endif err: if (conf_debug_pruning != false) /* This is debuging output, don't mark anything for translation */ @@ -836,6 +866,7 @@ fprintf (stderr, "Skipping `%s': in prunepaths\n", path); goto err; } +#ifdef HAVE_GETMNTENT if (conf_prune_bind_mounts != false && is_bind_mount (path)) { if (conf_debug_pruning != false) @@ -843,6 +874,7 @@ fprintf (stderr, "Skipping `%s': bind mount\n", path); goto err; } +#endif if (bsearch (relative, conf_prunenames.entries, conf_prunenames.len, sizeof (*conf_prunenames.entries), cmp_string_pointer) != NULL) { @@ -1066,7 +1098,9 @@ bindtextdomain (PACKAGE_NAME, LOCALEDIR); textdomain (PACKAGE_NAME); conf_prepare (argc, argv); +#ifdef HAVE_GETMNTENT init_bind_mount_paths (); +#endif lock_file_fd = old_db_open (); if (lock_file_fd != -1) { # HG changeset patch # User Rainer Müller # Date 1269875033 -7200 # Mon Mar 29 17:03:53 2010 +0200 # Node ID e0134018d116b6a734b4fc088b3a37a83e496454 # Parent 1e336459edba3afa48273143f532357666169d34 Advance mount_entry pointer diff -r 1e336459edba -r e0134018d116 src/updatedb.c --- a/src/updatedb.c Mon Mar 22 03:34:08 2010 +0100 +++ b/src/updatedb.c Mon Mar 29 17:03:53 2010 +0200 @@ -537,6 +537,7 @@ goto err_f; } } + me = me->me_next; } err_f: #ifdef HAVE_GETMNTENT