>Christopher Gorski wrote:
>
>> I noticed that the first calls in the "cp" and "ls" to getdents() return 
>> similar file lists, with the same values.
>> 
>> However, in the "ls", it makes a second call to getdents():
>
>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.

"cp" doesn't use getdents() but it uses readdir() instead; the whole 
buffer is hidden to it.

>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.


That's why you never use getdents but rather readdir() which hides this 
for you.

It appears that the off_t of the directory entries in the particular 
second read is > 2^32; so perhaps a cp which hasn't been compiled with
"handle large files" is being used?

Casper

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

Reply via email to