On Sat, 2011-04-16 at 22:40 +0400, Konstantin Khlebnikov wrote:
> It might be better to add an helper function, something like this:
> 
> static inline void shift_iovec(const struct iovec **iov, int *iovcnt,
>                              size_t nr, ssize_t *total, off_t *offset)
> {
>       while (nr >= (*iov)->iov_len) {
>               nr -= (*iov)->iov_len;
>               *total += (*iov)->iov_len;
>               *offset += (*iov)->iov_len;
>               *iovcnt--;
>               *iov++;
>       }
> }
> 
> ssize_t pwritev_in_full(int fd, const struct iovec *iov, int iovcnt, off_t 
> offset)
> {
>       ssize_t nr, total = 0;
> 
>       while (iovcnt) {
>               nr = xpwritev(fd, iov, iovcnt, offset);
>               if (nr < 0)
>                       return -1;
>               if (nr == 0) {
>                       errno = ENOSPC;
>                       return -1;
>               }
>               shift_iovec(&iov, &iovcnt, nr, &total, &offset);
>       }
> 
>       return total;
> }

Yup, Good idea - Let's do that.

Thanks!

-- 

Sasha.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to