Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@sources.redhat.com>
List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@sources.redhat.com
Delivered-To: mailing list cygwin@sources.redhat.com
Message-ID: <3A787241.E62E33A7@cygnus.com>
Date: Wed, 31 Jan 2001 15:14:57 -0500
From: "J. Johnston" <jjohnstn@cygnus.com>
Organization: Red Hat Inc.
X-Mailer: Mozilla 4.7 [en] (X11; U; Linux 2.2.12-20 i686)
X-Accept-Language: en
MIME-Version: 1.0
To: Earnie Boyd <cygwin@cygwin.com>, newlib@sources.redhat.com,
        Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>,
        cygwin@sources.redhat.com
Subject: Re: PATH_MAX and FILENAME_MAX
References: <000001c0877f$67915cf0$21c9ca95@mow.siemens.ru> <3A71804B.F2D7E82D@yahoo.com> <3A71FAD8.671502E1@cygnus.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Note-from-DJ: This may be spam

"J. Johnston" wrote:
> 
> Earnie Boyd wrote:
> >
> > Andrej Borsenkow wrote:
> > >
> > > Doing something different, this caught my eyes:
> > >
> > > $ grep PATH_MAX /usr/include/*.h
> > > /usr/include/limits.h:#define PATH_MAX (260 - 1 /*NUL*/)
> > > /usr/include/limits.h:#define _POSIX_PATH_MAX           255
> > > /usr/include/stdio.h:#define    FILENAME_MAX    1024    /* must be <= PATH_MAX
> > > <sys/syslimits.h> */
> > > /usr/include/stdio.h:#define    L_tmpnam        1024    /* XXX must be ==
> > > PATH_MAX */
> > >
> > > So are comments misleading or FILENAME_MAX (and L_tmpnam) should be changed?
> > >
> >
> > The comments are correct.  This is a newlib issue.  I've CC'ed the
> > newlib list in my response.
> >
> 
> Actually, the comments are not quite correct.  Based on POSIX, the value FOPEN_MAX should
> be tied to STREAM_MAX, not OPEN_MAX.  The value of L_tmpnam should be <= PATH_MAX,
> like FILENAME_MAX.
> 
> As a solution, I have made a patch that adds the ability for config.h
> or the compiler to override the default values for FOPEN_MAX, FILENAME_MAX, and L_tmpnam.
> I have altered config.h for RTEMS and Cygwin to set the value of __FILENAME_MAX__
> appropriately.
> 
> Any comments/objections from Cygwin or RTEMS?
>

Patch has been checked in (minus comments).

-- Jeff J.
 
> Index: stdio.h
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/include/stdio.h,v
> retrieving revision 1.4
> diff -u -r1.4 stdio.h
> --- stdio.h     2000/05/30 17:18:05     1.4
> +++ stdio.h     2001/01/26 22:16:56
> @@ -90,9 +90,27 @@
>  #define        BUFSIZ  1024
>  #define        EOF     (-1)
> 
> -#define        FOPEN_MAX       20      /* must be <= OPEN_MAX <sys/syslimits.h> */
> -#define        FILENAME_MAX    1024    /* must be <= PATH_MAX <sys/syslimits.h> */
> -#define        L_tmpnam        1024    /* XXX must be == PATH_MAX */
> +/* FOPEN_MAX should equal STREAM_MAX */
> +#ifdef __FOPEN_MAX__
> +#define FOPEN_MAX      __FOPEN_MAX__
> +#else
> +#define        FOPEN_MAX       20
> +#endif
> +
> +/* FILENAME_MAX must be <= PATH_MAX */
> +#ifdef __FILENAME_MAX__
> +#define FILENAME_MAX    __FILENAME_MAX__
> +#else
> +#define        FILENAME_MAX    1024
> +#endif
> +
> +/* L_tmpnam must be <= PATH_MAX */
> +#ifdef __L_tmpnam__
> +#define L_tmpnam       __L_tmpnam__
> +#else
> +#define        L_tmpnam        FILENAME_MAX
> +#endif
> +
>  #ifndef __STRICT_ANSI__
>  #define P_tmpdir        "/tmp"
>  #endif
> Index: sys/config.h
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/include/sys/config.h,v
> retrieving revision 1.4
> diff -u -r1.4 config.h
> --- config.h    2000/08/01 20:51:51     1.4
> +++ config.h    2001/01/26 22:16:56
> @@ -127,11 +127,16 @@
> 
> 
>  #if defined(__CYGWIN32__) || defined(__CYGWIN__)
> +#define __FILENAME_MAX__ (260 - 1 /* NUL */)
>  #if defined(__INSIDE_CYGWIN__) || defined(_COMPILING_NEWLIB)
>  #define __IMPORT
>  #else
>  #define __IMPORT __declspec(dllimport)
>  #endif
> +#endif
> +
> +#if defined(__rtems__)
> +#define __FILENAME_MAX__ 255
>  #endif
> 
>  #ifndef __IMPORT

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

