[TriLUG] question on maximum path length or file name

Jeremy Portzer jeremyp at pobox.com
Wed Jan 23 18:24:53 EST 2008


Alan Porter wrote:
>> I'm trying to figure out how long a filename can be or how deeply a file
>> can be nested in terms of the length of the path to get to it. A stat -f
>> / on my system tells me that Namelen equals 255. I assume that this
>> means a file cannot have a length of more that 255 characters but does
>> that include the path to get to that file? I haven't found anything of
>> help so far with google.
> 
> 
> On an ext2/ext3 filesystem, there is a limitation of the length of a
> single filename within a directory (since the directory is really just a
> table of names and inodes).
> 
> But there is no limitation on the entire path of the file (like the limit
> in DOS), since that information is really only stored in a hop-by-hop
> manner in the directories above the file.
> 
> Individual programs might have a limit on the number of characters in a
> file's complete path, but that is not a limitation of the filesystem
> itself.
> 
> Hope this helps.
> 

Alan is correct... I'll just add that from a practical point of view, 
some programs in the past have been limited to a path length of 1024 
characters.  This is probably not an issue in modern versions of common 
shells and utilities.  But if you want to make something completely 
portable and not have to worry about this for users using older tools, 
you may want to try to stay under 1024.

Also, if you're working in a cross-platform environment, where 
filesytems might be mounted from other operating systems, keep that in 
mind.  We have issues with Windows machines mounting certain filesystems 
in at $WORK due to long paths.  Usually when this happens we just tell 
them to get a real operating system.  But, YMMV on that response :-)

--Jeremy




More information about the TriLUG mailing list