X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/4440b8aa3fb0edb9626c8eaa4856d72f78c9e176..9533e15a7996c5e01fff60a754c39d4fae5461f6:/fileio.c diff --git a/fileio.c b/fileio.c index c39d6b02..e8eaa100 100644 --- a/fileio.c +++ b/fileio.c @@ -1,5 +1,6 @@ /* Copyright (C) Andrew Tridgell 1998 + Copyright (C) 2002 by Martin Pool This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,9 +37,9 @@ int sparse_end(int f) } -static int write_sparse(int f,char *buf,int len) +static int write_sparse(int f,char *buf,size_t len) { - int l1=0,l2=0; + size_t l1=0, l2=0; int ret; for (l1=0;l1 0) do_lseek(f,l2,SEEK_CUR); @@ -67,19 +69,22 @@ static int write_sparse(int f,char *buf,int len) return len; } - - -int write_file(int f,char *buf,int 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;