pathconf(, _PC_NAME_MAX) is too small for long Unicode filename on fat. 255 as max filename size on fat is Unicode UTF-16 characters. it's not byte size. When I try to read long Unicode file using readdir() or readdir_r() they return long string than pathconf(file_on_fat_fs, _PC_NAME_MAX). And readdir_r() causes buffer overflow when users determine buffer size using pathconf()'s result. Attached program is to test it. Please change PWD to a directory on fat FS, and run it. It create long Unicode filename in PWD, and call readdir_r().
Created attachment 27265 [details] test program
Created attachment 54142 [details] Fix f_namelen Sorry for long delay. Attached patch should fix this, and will included future kernel. But, I'm not pretty sure if there is no userland breakage (for now, I didn't found though). Let's see.
A patch referencing this bug report has been merged in v3.0-rc1: commit f68e542f3478147986a9c8958942ec649dc06201 Author: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Date: Tue Apr 12 21:08:39 2011 +0900 fat: Fix statfs->f_namelen