Skip to contentSkip to conversation

quick question about filename length

DISCUSSION Chris Walker 4 participants 5 messages May 16, 2009

lore
Share & tools
lore
#1 lore raw
Quoted 10 lines · Chris Walker

Hello,

I see that
#define MAXNAMELEN 256

Is this the maximum length of the filename with full path? Or is this just the name of the file?

Many thanks!
Chris

/*
* MAXNAMELEN is the length (including the terminating null) of
* the longest permissible file (component) name.
*/
#define MAXNAMELEN 256

"component" means path component. So just the name of the file or dir in the path.

See also how it's used in xfs_vn_lookup() for example:

        if (dentry->d_name.len >= MAXNAMELEN)
                return ERR_PTR(-ENAMETOOLONG);

a dentry is one component of the path, not the entire path.

-Eric

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw

Thanks for you quick reply, Eric.

I have a user who is having filenames (path+filename) cut off at 255 characters midway through a simulation -- but the problem must be elsewhere

Thanks again,
Chris

Quoted 21 lines · Eric Sandeen
Quoted 10 lines · Chris Walker

Hello,

I see that
#define MAXNAMELEN  256

Is this the maximum length of the filename with full path?  Or is this just the name of the file?

Many thanks!
Chris

/*
 * MAXNAMELEN is the length (including the terminating null) of
 * the longest permissible file (component) name.
 */
#define MAXNAMELEN      256

"component" means path component.  So just the name of the file or dir in the path.

Quoted 9 lines

See also how it's used in xfs_vn_lookup() for example:

       if (dentry->d_name.len >= MAXNAMELEN)
               return ERR_PTR(-ENAMETOOLONG);

a dentry is one component of the path, not the entire path.

-Eric

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
Quoted 5 lines · Chris Walker

Thanks for you quick reply, Eric.

I have a user who is having filenames (path+filename) cut off at 255 characters midway through a simulation -- but the problem must be elsewhere

XFS doesn't actually see the whole filename in normal operation (except for copying out the data out of symbolic links), as the resolution to
individual components is done by the VFS. Long file name should work
just fine on Linux and do in my test. Maybe some buffer is sized using incorrect in userspace?

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw

Am Samstag 16 Mai 2009 schrieb Christoph Hellwig:

Quoted 7 lines · Chris Walker
Quoted 5 lines

Thanks for you quick reply, Eric.

I have a user who is having filenames (path+filename) cut off at 255 characters midway through a simulation -- but the problem must be elsewhere

Quoted 5 lines

XFS doesn't actually see the whole filename in normal operation (except for copying out the data out of symbolic links), as the resolution to
individual components is done by the VFS. Long file name should work
just fine on Linux and do in my test. Maybe some buffer is sized using incorrect in userspace?

And while a link name itself also can't be longer than about 256 characters (I only tested 250 and 260), a link can point to a longer path ;-):

martin@shambhala:~/Zeit> mkdir -p
$(ruby -e 'puts "1234567890"*25')/$(ruby -e 'puts "1234567890"*25') martin@shambhala:~/Zeit> ln -s
$(ruby -e 'puts "1234567890"*25')/$(ruby -e 'puts "1234567890"*25') testlink
martin@shambhala:~/Zeit> ls -l testlink
lrwxrwxrwx 1 martin martin 501 16. Mai 23:40 testlink -> 12345678901234567890123456789012345678901234567890123456789[...] martin@shambhala:~/Zeit> (df -hT . | grep -q xfs) && echo "Is XFS" Is XFS

Signature · 7 lines
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA  B82F 991B EAAC A599 84C7

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs