bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] gnulib imports from coreutils for canon-host, human, xg


From: Bruno Haible
Subject: Re: [Bug-gnulib] gnulib imports from coreutils for canon-host, human, xgetcwd
Date: Thu, 18 Nov 2004 22:43:14 +0100
User-agent: KMail/1.5

Paul Eggert wrote:
> > Some platforms have a PATH_MAX value that is not a strong limit, but
> > rather a dummy value because many BSD applications don't even
> > compile if PATH_MAX does not exist.
>
> Ah, I didn't know that.  I thought PATH_MAX was supposed to be undefined
> in that case.

That's the way the Hurd did it - and they paid the price in form of numerous
application portability problems.

> Which implementations are these?

1) GNU/kFreeBSD
2) Linux, when using the "generic" getcwd() implementation from
   glibc/sysdeps/posix/getcwd.c 

For the attached program, I get

1) GNU/kFreeBSD
PATH_MAX = 1024
length: 4342
/tmp/0123....789

2) Linux with "generic" getcwd()
PATH_MAX = 4096
length: 4342
/tmp/0123....789

> It sounds to me like
> such implementations are broken anyway -- do we need to cater to them?)

It is a bit unfair to say that other implementations are broken, while we
are currently discussing a workaround to a Solaris bug!

> The autoconf test would be better.  I doubt whether the problem is
> limited to Sun; it's probably endemic to SVR4.

Yes, I agree.

Bruno

PS: The autoconf test could work somewhat like this:

  /* Get old current directory. */
  char currdir[PATH_MAX + 1];
  getcwd (currdir, PATH_MAX + 1);
  size_t currdir_len = strlen (currdir);
  /* Create deep directory hierarchy. */
  char name[] = "conftest.dir";
  size_t depth = PATH_MAX / (strlen (name) + 1) + 1;
  size_t i;
  for (int i = 0; i < depth; i++)
    {
      mkdir (name, 0777);
      chdir (name);
    }
  /* See what getcwd() returns. */
  size_t buffer_len = currdir_len + depth * (strlen (name) + 1);
  char *buffer = (char *) malloc (buffer_len + 1);
  if (getcwd (buffer, buffer_len + 1) == NULL && errno == ERANGE)
    exit (1);

Attachment: a.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]