delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/01/31/15:19:00

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <3A787241.E62E33A7@cygnus.com>
Date: Wed, 31 Jan 2001 15:14:57 -0500
From: "J. Johnston" <jjohnstn AT cygnus DOT 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 AT cygwin DOT com>, newlib AT sources DOT redhat DOT com,
Andrej Borsenkow <Andrej DOT Borsenkow AT mow DOT siemens DOT ru>,
cygwin AT sources DOT redhat DOT com
Subject: Re: PATH_MAX and FILENAME_MAX
References: <000001c0877f$67915cf0$21c9ca95 AT mow DOT siemens DOT ru> <3A71804B DOT F2D7E82D AT yahoo DOT com> <3A71FAD8 DOT 671502E1 AT cygnus DOT com>
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019