[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-cpio] wrong handling of write(2) errors
From: |
Vasiliy Kulikov |
Subject: |
Re: [Bug-cpio] wrong handling of write(2) errors |
Date: |
Mon, 19 Sep 2011 22:14:05 +0400 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Hi Sergey,
On Mon, Sep 19, 2011 at 03:19 +0300, Sergey Poznyakoff wrote:
> @@ -136,13 +136,16 @@ disk_empty_output_buffer (int out_des)
> }
>
> if (sparse_flag)
> - bytes_written = sparse_write (out_des, output_buffer, output_size);
> + bytes_written = sparse_write (out_des, output_buffer, output_size,
> flush);
> else
> bytes_written = write (out_des, output_buffer, output_size);
>
> if (bytes_written != output_size)
> {
> - error (1, errno, _("write error"));
> + if (bytes_written == -1)
> + error (1, errno, _("write error"));
> + else
> + error (1, 0, _("write error: partial write"));
> }
> output_bytes += output_size;
> out_buff = output_buffer;
[...]
> +static ssize_t
> +sparse_write (int fildes, char *buf, size_t nbytes, bool flush)
> {
[...]
> + n = write (fildes, start_ptr, bytes);
> + if (n == -1)
> + return -1;
> + nwritten += n;
> + if (n < bytes)
> + return nwritten + seek_count;
Do we really want to alert in the case of a partial write? Probably it's
better to retry from the interrupted point as it is a fully valid case.
Of course 0 and -1 returned are good to propagate to the upper level (to
disk_empty_output_buffer()).
Thanks,
--
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments