"Will Murnane" <[EMAIL PROTECTED]> wrote: > On Jan 30, 2008 1:34 AM, Carson Gaspar <[EMAIL PROTECTED]> wrote: > > If this is Sun's cp, file a bug. It's failing to notice that it didn't > > provide a large enough buffer to getdents(), so it only got partial results. > > > > Of course, the getdents() API is rather unfortunate. It appears the only > > safe algorithm is: > > > > while ((r = getdents(...)) > 0) { > > /* process results */ > > } > > if (r < 0) { > > /* handle error */ > > } > > > > You _always_ have to call it at least twice to be sure you've gotten > > everything. > In OpenSolaris, cp uses (indirectly) readdir(), not raw getdents(). > http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libcmd/common/cp.c#487 > which uses the build-a-linked-list code here: > http://src.opensolaris.org/source/xref/sfw/usr/src/cmd/coreutils/coreutils-6.7/lib/fts.c#913 > That code appears to error out and return incomplete results if a) the > filename is too long or b) an integer overflows. Christopher's > filenames are only 96 chars; could Unicode be involved somehow? b) > seems unlikely in the extreme. It still seems like a bug, but I don't > see where it is. I am only an egg ;-)
An interesting thought.... We of course need to know whether the user used /bin/cp or a "shadow implementation" from ksh93. I did never see any problems with star(1) and star(1)/libfind(3) are heavy readdir(3) users... Jörg -- EMail:[EMAIL PROTECTED] (home) Jörg Schilling D-13353 Berlin [EMAIL PROTECTED] (uni) [EMAIL PROTECTED] (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily _______________________________________________ zfs-discuss mailing list zfs-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/zfs-discuss