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 ;-)

Will
_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to