Re: quick question about filename length

Eric Sandeen
2009-05-16T17:04:33Z

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