On Thu, Apr 25, 2024 at 09:05:53PM +0200, Piotr Durlej wrote: > Handle short writes in cp(1)
OK bluhm@ > --- > bin/cp/utils.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/bin/cp/utils.c b/bin/cp/utils.c > index 347081151f2..40265fce7f7 100644 > --- a/bin/cp/utils.c > +++ b/bin/cp/utils.c > @@ -149,11 +149,16 @@ copy_file(FTSENT *entp, int exists) > wcount = lseek(to_fd, rcount, SEEK_CUR) == -1 ? > -1 : rcount; > else > wcount = write(to_fd, buf, rcount); > - if (rcount != wcount || wcount == -1) { > + if (wcount == -1) { > warn("%s", to.p_path); > rval = 1; > break; > } > + if (rcount != wcount) { > + warnx("%s: short write", to.p_path); > + rval = 1; > + break; > + } > } > if (skipholes && rcount != -1) > rcount = ftruncate(to_fd, lseek(to_fd, 0, SEEK_CUR)); > -- > 2.44.0