quick question about filename length

Eric Sandeen sandeen at sandeen.net
Sat May 16 12:04:40 CDT 2009


Chris Walker wrote:
> 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




More information about the xfs mailing list