This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATH_MAX and FILENAME_MAX


"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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]