Hi Guennadi, > Hi Detlev > > On Mon, 12 Apr 2010, Detlev Zundel wrote: > >> Hi Guennadi, >> >> > On Fri, 9 Apr 2010, Anatolij Gustschin wrote: >> > >> >> Sometimes not all objects from the image directory are >> >> imported. Removing this dentry->d_name zero-termination >> >> seems to fix the problem. dentry->d_name is zero-terminated, >> >> no need to terminate it. >> > >> > Sorry, do not understand. The only possibility for this is if the name >> > doesn't fit, and then it overwrites following fields in dentry... So, I'm >> > hesitant to accept this fix. Can you verify exactly which cases fail? on >> > which files? >> >> Check include/linux/dirent.h and you will see >> >> char d_name[0]; >> >> The man-page for readdir(3) says: >> >> The only fields in the dirent structure that are mandated by POSIX.1 >> are: d_name[], of unspecified size, with at most NAME_MAX characters >> preceding the terminating null byte; and (as an XSI extension) d_ino. >> >> So the assignment indeed is a bad idea. It looks like >> sizeof(dentry->d_name) in the testprogram always evaluates to 256, >> although d_name is dynamically allocated. If you modify the testprogram >> to write a counter value instead of \0, you will notice that the >> substitutions scramble _subsequent_ entries in the list. >> >> All in all Anatolijs patch is a real bugfix. > > Cool, unfortunately, that's not what I have in my copy of > /usr/include/linux/dirent.h (at some point I will have to update my > etch...) nor in readdir(3). Sorry, I was referring to include/linux/dirent.h from a recent Linux kernel tree (e.g. [1]). > But yes, now I kind-of can understand the problem. (Kind-of, because I > still don't understand, why sizeof() returns a positive number, which > means, it too sees a definition other than d_name[0].) This definition is pulled in from the userspace /usr/include/bits/dirent.h but as the cited documentation (indirectly) states a sizeof() on it should not be used. > Funny it didn't appear in my tests, maybe also old ARM distro / > toolchain. Sure, will take this (will need some more time to review > the rest), I'd like to have a better comment though, Anatolij, you can > either propose one yourself, or I'll try to come up with something > without the words "seems to fix" in it;) Thanks Detlev [1] http://git.denx.de/?p=linux-2.6-denx.git;a=blob;f=include/linux/dirent.h;h=f072fb8d10a3268b402323c91b40be250872726a;hb=c8cb9c6ec0455ae7ce23dfad654f9b4ec8202fe1 -- .. most of the finest products of an applied mathematician's fancy must be rejected, as soon as they have been created, for the brutal but sufficient reason that they do not fit the facts. -- G. H. Hardy -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu@xxxxxxx -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html