This is the mail archive of the
mailing list for the GCC project.
Breakage with [PATCH, libgfortran] PR60324 Handle arbitrarily long path names
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 22 May 2014 11:36:40 -0400 (EDT)
- Subject: Breakage with [PATCH, libgfortran] PR60324 Handle arbitrarily long path names
- Authentication-results: sourceware.org; auth=none
- References: <CAO9iq9GrALPvDLes3vkeMsULZYOV4fFtUTuLvEwP6vw+5G8=Kw at mail dot gmail dot com>
On Mon, 19 May 2014, Janne Blomqvist wrote:
> some systems such as GNU Hurd, don't define PATH_MAX at all, and on
> some other systems many syscalls apparently work for paths longer than
> PATH_MAX. Thus GFortran shouldn't truncate paths to PATH_MAX
> characters, but rather use heap allocated buffers limited only by the
> available memory. The attached patch implements this, with the
> exception of the backtrace functionality where we cannot use malloc
> since backtrace might be called from a signal handler.
> Regtested on x86_64-unknown-linux-gnu, Ok for trunk?
> 2014-05-19 Janne Blomqvist <firstname.lastname@example.org>
> PR libfortran/60324
> * config.h.in: Regenerated.
> * configure: Regenerated.
> * configure.ac (AC_CHECK_FUNCS_ONCE): Check for strnlen and
> * libgfortran.h (fc_strdup): New prototype.
> * runtime/string.c (strnlen): New fallback function.
> (strndup): New fallback function.
> (fc_strdup): New function.
> * io/close.c (st_close): Use fc_strdup.
> * io/open.c (new_unit): Likewise.
> (already_open): Likewise.
> * io/unit.c (filename_from_unit): Likewise.
> * io/unix.c (unpack_filename): Remove function.
> (regular_file): Rename to regular_file2, add path argument.
> (regular_file): New function calling regular_file2.
> (compare_file_filename): Use fc_strdup.
> (find_file): Likewise.
> (delete_file): Likewise.
> (file_exists): Likewise.
> (file_size): Likewise.
> (inquire_sequential): Likewise.
> (inquire_direct): Likewise.
> (inquire_formatted): Likewise.
> (inquire_access): Likewise.
> * io/unix.h (unpack_filename): Remove prototype.
> * runtime/main.c (please_free_exe_path_when_done): Change type to
> (store_exe_path): Use malloced buffer, grow as needed.
This patch broke build for newlib targets; you need AC_DEFINE
clauses for those in the "if-then"-leg where you patched the
"else"-leg. There's also a need for #include <stdlib.h> for the
malloc use in runtime/string.c.