On Tue, 2011-11-29 at 01:15 +0100, Svante Signell wrote:
> On Fri, 2011-11-25 at 08:48 +0100, Svante Signell wrote:
> > On Fri, 2011-11-25 at 07:52 +0100, Tollef Fog Heen wrote:
> > > ]] Svante Signell
> > >
> > > It's stuck upstream until somebody provides an updated patch which you
> > > could trivially have found out for yourself.
> >
> > Sorry, I did not look at the upstream ticket. I'll provide an updated
> > patch in due time.
>
> Attached is an updated patch for mlocate that might suit upstream
> better. It checks the availability of get_current_dir_name() and
> canonicalize_file_name() in configure.ac, and use these functions if
> they are available. Otherwise it falls back to the old PATH_MAX based
> solution.
Sorry for the noise, but the previous patch was freeing strings that
were never allocated. New patch attached, partially run tested under
GNU/Hurd.
Thanks!
diff -ur mlocate-0.23.1/configure.ac mlocate-0.23.1.modified/configure.ac
--- mlocate-0.23.1/configure.ac 2010-09-14 15:50:32.000000000 +0200
+++ mlocate-0.23.1.modified/configure.ac 2011-11-28 23:14:55.000000000 +0100
@@ -47,7 +47,7 @@
# Checks for library functions.
## getopt_long () availability should be checked here
-AC_CHECK_FUNCS_ONCE([fdopendir])
+AC_CHECK_FUNCS_ONCE([fdopendir get_current_dir_name canonicalize_file_name])
AC_FUNC_GETMNTENT
# Checks for system services.
diff -ur mlocate-0.23.1/src/conf.c mlocate-0.23.1.modified/src/conf.c
--- mlocate-0.23.1/src/conf.c 2008-06-29 23:53:33.000000000 +0200
+++ mlocate-0.23.1.modified/src/conf.c 2011-11-28 23:53:04.000000000 +0100
@@ -470,6 +470,13 @@
static char *
prepend_cwd (const char *path)
{
+#ifdef HAVE_GET_CURRENT_DIR_NAME
+ char *buf = NULL;
+ size_t len1, size2;
+
+ buf = get_current_dir_name();
+ if (buf == NULL)
+#else
char *buf, *res;
size_t size, len1, size2;
@@ -479,6 +486,7 @@
buf = x2realloc (buf, &size);
while ((res = getcwd (buf, size)) == NULL && errno == ERANGE);
if (res == NULL)
+#endif
error (EXIT_FAILURE, errno, _("can not get current working directory"));
len1 = strlen (buf);
size2 = strlen (path) + 1;
diff -ur mlocate-0.23.1/src/updatedb.c mlocate-0.23.1.modified/src/updatedb.c
--- mlocate-0.23.1/src/updatedb.c 2010-03-30 15:34:12.000000000 +0200
+++ mlocate-0.23.1.modified/src/updatedb.c 2011-11-29 11:13:55.000000000 +0100
@@ -379,9 +379,15 @@
if (hasmntopt (me, "bind") != NULL
&& strcmp (me->mnt_fsname, me->mnt_dir) != 0)
{
+#ifdef HAVE_CANONICALIZE_FILE_NAME
+ char *dir;
+
+ dir = canonicalize_file_name (me->mnt_dir);
+#else
char dbuf[PATH_MAX], *dir;
dir = realpath (me->mnt_dir, dbuf);
+#endif
if (dir == NULL)
dir = me->mnt_dir;
if (conf_debug_pruning != false)
@@ -489,9 +495,13 @@
{
char *dir;
#ifndef PROC_MOUNTS_PATH
+#ifdef HAVE_CANONICALIZE_FILE_NAME
+ dir = canonicalize_file_name (me->mnt_dir);
+#else
char dbuf[PATH_MAX];
dir = realpath (me->mnt_dir, dbuf);
+#endif
if (dir == NULL)
dir = me->mnt_dir;
#else