Review Request JDK-7119643: It is not possible to read files with a path longer than 2048 characters

Poonam Bajaj poonam.bajaj at
Mon Mar 24 02:55:07 UTC 2014

Hi Dmitry,

On 3/24/2014 12:49 AM, Dmitry Samersoff wrote:
> Poonam,
> 1.
> MAXPATHLEN == PATH_MAX and it's a system constant that comes from
> sys/param.h and linux/limits.h so current behavior of hotspot is
> absolutely correct.
> Moreover, we uses MAXPATHLEN in many places in os_*.cpp files, so this
> patch makes hotspot behavior inconsistent.
> Typical value of PATH_MAX is 4096 so it's unclean for me why we have
> problems with 2048 bytes file.
> We probably should check our reference build platform.
The purpose of this change is to revert back to the same behavior as it 
was before the  fix for 6348631 where we didn't have any path limitation 
in os::open() and os::stat() functions.

But yes, you are right. We have the following in sys/param.h and 
linux/limits.h for the maximum allowed path length on linux platforms:
#define PATH_MAX        4096    /* # chars in a path name including nul */

and MAXPATHLEN is also used in os_linux.cpp. So, if we have to insert 
the path limitation in os::open() and os::stat(), we should be using 
MAXPATHLEN at all the places in os_linux.cpp. Why was MAX_PATH defined 
and to a different value than MAXPATHLEN which is inconsistent with the 
linux definition?

> 2.
> Test could be a pure java.
Ok, will do.

> -Dmitry
> On 2014-03-21 16:52, Poonam Bajaj wrote:
>> Hi,
>> Review request for:
>> JDK-7119643<>: It is
>> not possible to read files with a path longer than 2048 characters
>> Problem and Fix: This bug is a regression from 6u29 and exists only on
>> Linux platform. With the fix for 6348631, a limit of MAX_PATH (2K) got
>> introduced on the file path length in the os::open() and os::stat()
>> functions in os_linux.cpp. These changes remove that limit. These
>> changes also add a regression test case to check that the files having
>> path longer than 2048 are read without any error.
>> Webrev:
>> This fix needs to go into 9, 8u, 7u and 6u.
>> Thanks,
>> Poonam

More information about the hotspot-runtime-dev mailing list