MAXNAMELEN vs MAXNAMLEN
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > MAXNAMELEN vs MAXNAMLEN




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    MAXNAMELEN vs MAXNAMLEN  
Rich Teer


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:36 PM

Hi all,

I have a reconcilliation type of question.  <sys/param.h>
says this:

/*
* MAXPATHLEN defines the longest permissible path length,
* including the terminating null, after expanding symbolic links.
* MAXNAMELEN is the length (including the terminating null) of
* the longest permissible file (component) name.
*/
#define MAXPATHLEN  1024
#define MAXNAMELEN  256


Whereas <dirent.h> says this:

#define MAXNAMLEN   512     /* maximum filename length */


So, one header file claims that the maximum length of
a file name (i.e., pathname component) is 256 characters,
and another claims that it is 512.

Shouldn't these two values be the same?  I mean, how can
a UFS file system support 512 character file names when
the system itself is restricted to 256?  (Or am I missing
something here?)

TIA,

--
Rich Teer, SCNA, SCSA

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-online.net





[ Post a follow-up to this message ]



    Re: MAXNAMELEN vs MAXNAMLEN  
Casper H.S. Dik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:36 PM

Rich Teer <rich.teer@rite-group.com> writes:
quote:
>Whereas <dirent.h> says this:
quote:
>#define MAXNAMLEN 512 /* maximum filename length */
That seems to be internal to the library readdir implementation; still looks wrong, though.
quote:
>So, one header file claims that the maximum length of >a file name (i.e., pathname component) is 256 characters, >and another claims that it is 512.
quote:
>Shouldn't these two values be the same? I mean, how can >a UFS file system support 512 character file names when >the system itself is restricted to 256? (Or am I missing >something here?)
The actual supported maximum length is filesystem dependent and should be inquired using pathconf(file, _PC_NAME_MAX) Casper




[ Post a follow-up to this message ]



    Re: MAXNAMELEN vs MAXNAMLEN  
lvirden@yahoo.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-27-04 05:34 AM


According to Rich Teer  <rich.teer@rite-group.com>:
:  <sys/param.h>
:says this:
:
:#define MAXNAMELEN  256
:
:Whereas <dirent.h> says this:
:
:#define MAXNAMLEN   512     /* maximum filename length */
:

In case someone is interested, dirent.h says this:

#if defined(__EXTENSIONS__) || \
(!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))

#define MAXNAMLEN       512             /* maximum filename length */


So dirent.h is defining info for an extension or for code which
does not have POSIX_C_SOURCE or _XOPEN_SOURCE defined.

Since in most cases, these defines are not going to be present,
including the two header files will most often attempt to define
the same symbol with two different values...

Seems like a problem to me...
--
<URL: http://wiki.tcl.tk/ > In God we trust.
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:lvirden@yahoo.com > <URL: http://www.purl.org/NET/lvirden/ >





[ Post a follow-up to this message ]



    Re: MAXNAMELEN vs MAXNAMLEN  
Rich Teer


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-27-04 08:34 AM

On Tue, 27 Jan 2004 lvirden@yahoo.com wrote:
quote:
> In case someone is interested, dirent.h says this: > > #if defined(__EXTENSIONS__) || \ > (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) > > #define MAXNAMLEN 512 /* maximum filename length */ > > > So dirent.h is defining info for an extension or for code which > does not have POSIX_C_SOURCE or _XOPEN_SOURCE defined.
Yep.
quote:
> Since in most cases, these defines are not going to be present, > including the two header files will most often attempt to define > the same symbol with two different values...
Nope. MAXNAMLEN and MAXNAMELEN are two different symbols, not two the same with a typo! :-) Fortunately, I've received email from Sun engineers resolving this discrepancy. -- Rich Teer, SCNA, SCSA President, Rite Online Inc. Voice: +1 (250) 979-1638 URL: http://www.rite-online.net




[ Post a follow-up to this message ]



    Re: MAXNAMELEN vs MAXNAMLEN  
Frank Cusack


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-28-04 03:34 AM

On Tue, 27 Jan 2004 16:45:48 GMT Rich Teer <rich.teer@rite-group.com> wrote:
quote:
> Fortunately, I've received email from Sun engineers resolving > this discrepancy.
Fortunately for you, not for us! Spill it. /fc




[ Post a follow-up to this message ]



    Re: MAXNAMELEN vs MAXNAMLEN  
Rich Teer


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-28-04 09:35 AM

On Wed, 28 Jan 2004, Frank Cusack wrote:
quote:
> On Tue, 27 Jan 2004 16:45:48 GMT Rich Teer <rich.teer@rite-group.com> wrot e: > > Fortunately for you, not for us! Spill it.
My mistake: I didn't receive an email. I was thinking of Casper's posting a few days ago (it's on groups.google.com). Here's the gist of what he said: That seems to be internal to the library readdir implementation; still looks wrong, though. The actual supported maximum length is filesystem dependent and should be inquired using pathconf(file, _PC_NAME_MAX). HTH, -- Rich Teer, SCNA, SCSA President, Rite Online Inc. Voice: +1 (250) 979-1638 URL: http://www.rite-online.net




[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:25 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register