Re: Thread implementations...

Martin Mares (mj@atrey.karlin.mff.cuni.cz)
Thu, 25 Jun 1998 16:33:19 +0200


> This is almost copy (see my earlier posting). Unfortunately I
> thought long and hard about this last night, and copy does
> seem to be extremely subtle, particularly for error handling.
>
> eg. what do you do if the read fails with an error?
> what do you do if the read fails with EWOULDBLOCK?
> what do you do if the write fails with an error? - put back the data?
> what do you do if the write fails with EWOULDBLOCK? - check for
> this *before* doing the read?

Just return a status word containing INPUT_WOULDBLOCK, OUTPUT_WOULDBLOCK,
INPUT_ERROR and OUTPUT_ERROR flags and passing a pointer where to store
number of bytes copied or errno.

> Update to my previous posting. I think the prototype should be:
>
> ssize_t copy (int from_fd, int to_fd, size_t *nbytes);
>
> so the kernel can return the number of bytes actually
> copied in the event of an error. I'll try and implement
> this some time and see if it's workable.

It would be better to allow selecting offsets in both source and destination
files.

Have a nice fortnight

-- 
Martin `MJ' Mares   <mj@ucw.cz>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
"while (*p++ = *q++);"   -- Dennis M. Ritchie

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu