シェル芸botで、NAME_MAXが255なのに、作成できるファイル名の上限が242だというのを見かけたので調べて見たところ、どうもDockerで利用されているaufsではプレフィックスの関係からファイル名の長さが242に制限されるらしい。 以下、対象箇所の引用。

Since aufs has several filename prefixes reserved, the maximum filename length is shorter than ordinary 255. Actually 242 (defined as ${AUFS_MAX_NAMELEN}). This value should be specified as ’namlen=’ when you mount NFS. The name of the branch top directory has another limit. When you set the module parameter ’brs’ to 1 (default), then you can see the branch pathname via /sys/fs/aufs/si_XXX/brNNN. Here it is printed with its branch attributes such as ’=rw’ or ’=ro+wh’. Since all the sysfs entries have the size limit of 4096 bytes, the length of the branch path becomes shorter than 4096. Actually you can specify any branch with much longer names, but you will meet some troubles when you remount later because remounting runs the aufs mount helper internally and it tries reading /sys/fs/aufs/si_XXX/brNNN.

これを読む限り、「AUFS_MAX_NAMELEN」で242に定義されているらしい。