From: J.W. Schultz Date: Thu, 22 May 2003 23:24:44 +0000 (+0000) Subject: Changed write file to cope with partial writes by looping X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/9533e15a7996c5e01fff60a754c39d4fae5461f6 Changed write file to cope with partial writes by looping until complete or errno is set. (John Van Essen) --- diff --git a/fileio.c b/fileio.c index 92631bc7..e8eaa100 100644 --- a/fileio.c +++ b/fileio.c @@ -69,19 +69,22 @@ static int write_sparse(int f,char *buf,size_t len) return len; } - - +/* + * write_file does not allow incomplete writes. It loops internally + * until len bytes are written or errno is set. + */ int write_file(int f,char *buf,size_t len) { int ret = 0; - if (!sparse_files) { - return write(f,buf,len); - } - while (len>0) { - int len1 = MIN(len, SPARSE_WRITE_SIZE); - int r1 = write_sparse(f, buf, len1); + int r1; + if (sparse_files) { + int len1 = MIN(len, SPARSE_WRITE_SIZE); + r1 = write_sparse(f, buf, len1); + } else { + r1 = write(f, buf, len); + } if (r1 <= 0) { if (ret > 0) return ret; return r1;