Machine: i586
OS: interix5.2
Compiler: gcc 
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i586'
-DCONF_OSTYPE='interix5.2' -DCONF_MACHTYPE='i586-pc-interix5.2'
-DCONF_VENDOR='pc'
-DLOCALEDIR='/tools/snapshot/prefix-launcher-1pre.20071219/i586-pc-interix5.2/share/locale'
 -DPACKAGE='bash' 
-DLOCAL_PREFIX=/tools/snapshot/prefix-launcher-1pre.20071219/i586-pc-interix5.2 
-DSHELL -DHAVE_CONFIG_H -DNO_MAIN_ENV_ARG -DBROKEN_DIRENT_D_INO -D_POSIX_SOURCE 
  -I.  -I/tss/prefix-launcher-1pre.20071219/buildroot/bash/bash-3.2 
-I/tss/prefix-launcher-1pre.20071219/buildroot/bash/bash-3.2/include 
-I/tss/prefix-launcher-1pre.20071219/buildroot/bash/bash-3.2/lib   -g -O2
uname output: Interix pc312001 5.2 SP-9.0.3790.3034 x86
Intel_x86_Family6_Model15_Stepping6
Machine Type: i586-pc-interix5.2

Bash Version: 3.2 
Patch Level: 33
Release Status: release

Description:
    Bash uses getcwd-replacement if libc provides getcwd without the
    feature of allocating the buffer when called without one.
    This override is done in config-bot.h, with an exception for
    solaris already.
    Problem now is that getcwd-replacement does not work on Interix
    (SUA 5.2 here).
    Now there's only one source location in builtins/common.c really
    relying on getcwd(0,0) allocating the buffer.
    But even here is some conditional code on GETCWD_BROKEN.
    So why not simply don't require allocation-feature of getcwd at all
    and use getcwd-replacement only if libc does not provide one ?

Repeat-By:
    $ PWD= 
/tools/snapshot/prefix-launcher-1pre.20071219/i586-pc-interix5.2/bin/bash
    shell-init: error retrieving current directory: getcwd: cannot access 
parent directories: No such file or directory

Fix: (patch attached)
    builtins/common.c:
       Do not depend on getcwd() doing buffer allocation.
    config-bot.h:
       Ignore GETCWD_BROKEN, keep HAVE_GETCWD as is.
    Additionally, the check for GETCWD_BROKEN can be dropped
    from configure.in and aclocal.m4.

Thanks!

/haubi/
-- 
Michael Haubenwallner
Gentoo on a different level
diff -ru builtins/common.c builtins/common.c
--- builtins/common.c	Wed Dec 19 10:30:07 2007
+++ builtins/common.c	Wed Dec 19 10:34:58 2007
@@ -479,11 +479,8 @@
 
   if (the_current_working_directory == 0)
     {
-#if defined (GETCWD_BROKEN)
-      the_current_working_directory = getcwd (0, PATH_MAX);
-#else
-      the_current_working_directory = getcwd (0, 0);
-#endif
+      char *t = xmalloc(PATH_MAX);
+      the_current_working_directory = getcwd (t, PATH_MAX);
       if (the_current_working_directory == 0)
 	{
 	  fprintf (stderr, _("%s: error retrieving current directory: %s: %s\n"),
diff -ru config-bot.h config-bot.h
--- config-bot.h	Wed Dec 19 10:30:06 2007
+++ config-bot.h	Wed Dec 19 10:31:16 2007
@@ -70,14 +70,6 @@
 #  define TERMIOS_MISSING
 #endif
 
-/* If we have a getcwd(3), but one that does not dynamically allocate memory,
-   #undef HAVE_GETCWD so the replacement in getcwd.c will be built.  We do
-   not do this on Solaris, because their implementation of loopback mounts
-   breaks the traditional file system assumptions that getcwd uses. */
-#if defined (HAVE_GETCWD) && defined (GETCWD_BROKEN) && !defined (SOLARIS)
-#  undef HAVE_GETCWD
-#endif
-
 #if !defined (HAVE_DEV_FD) && defined (NAMED_PIPES_MISSING)
 #  undef PROCESS_SUBSTITUTION
 #endif
diff -ru configure.in configure.in
--- configure.in	Wed Dec 19 10:30:09 2007
+++ configure.in	Wed Dec 19 10:37:08 2007
@@ -894,9 +894,6 @@
 BASH_FUNC_OPENDIR_CHECK
 BASH_FUNC_ULIMIT_MAXFDS
 BASH_FUNC_GETENV
-if test "$ac_cv_func_getcwd" = "yes"; then
-BASH_FUNC_GETCWD
-fi
 BASH_FUNC_POSIX_SETJMP
 BASH_FUNC_STRCOLL
 
diff -ru aclocal.m4 aclocal.m4
--- aclocal.m4	Tue Sep 12 23:18:07 2006
+++ aclocal.m4	Wed Dec 19 10:37:33 2007
@@ -684,32 +684,6 @@
 fi
 ])
 
-AC_DEFUN(BASH_FUNC_GETCWD,
-[AC_MSG_CHECKING([if getcwd() will dynamically allocate memory])
-AC_CACHE_VAL(bash_cv_getcwd_malloc,
-[AC_TRY_RUN([
-#include <stdio.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-main()
-{
-	char	*xpwd;
-	xpwd = getcwd(0, 0);
-	exit (xpwd == 0);
-}
-], bash_cv_getcwd_malloc=yes, bash_cv_getcwd_malloc=no,
-   [AC_MSG_WARN(cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no)
-    bash_cv_getcwd_malloc=no]
-)])
-AC_MSG_RESULT($bash_cv_getcwd_malloc)
-if test $bash_cv_getcwd_malloc = no; then
-AC_DEFINE(GETCWD_BROKEN)
-AC_LIBOBJ(getcwd)
-fi
-])
-
 dnl
 dnl This needs BASH_CHECK_SOCKLIB, but since that's not called on every
 dnl system, we can't use AC_PREREQ

Reply via email to