bug-coreutils
[Top][All Lists]
Advanced

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

Re: pwd vs. extremely long pathnames


From: Jim Meyering
Subject: Re: pwd vs. extremely long pathnames
Date: Fri, 28 Feb 2003 18:29:20 +0100

Samium Gromoff <address@hidden> wrote:
> On Fri, 28 Feb 2003 19:23:53 +0300
> Samium Gromoff <address@hidden> wrote:
>
>>      Given a quite long path (>4093 bytes), "pwd | wc -l" never produces a 
>> number more than
>>  4093.
>>      pwd from coreutils-4.5.7/glibc-2.3.1/linux-2.4.18 basically seems to 
>> cut the pathname.

Thank you for the report.
It looks like any program that uses getcwd (as pwd from GNU coreutils does)
will experience the same problem.  For directory pathnames longer than
PATH_MAX, getcwd is documented (Linux man page) to return only the first
PATH_MAX bytes of the name.

Here's a demonstration that uses Perl's getcwd.
This is Linux-2.4.19 using a `tmpfs' file system mounted on /t.
I see the same result using bash's builtin pwd and with coreutils' pwd.

  $ perl -MPOSIX -e '$i=0; do {mkdir "z",0700 or die "at depth $i: $!\n";
    chdir "z"} until (++$i == 3000); print getcwd'|wc -c
     4094

The result should be 6004.

I don't yet see a way around this.
I also tried both readlink and `ls -l' on /proc/self/cwd
with similar results.

It's probably best to avoid using getcwd altogether.

I've Cc'd address@hidden, since this limitation
does not appear in the description of getcwd.




reply via email to

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