[prev in list] [next in list] [prev in thread] [next in thread]
List: openbsd-bugs
Subject: Re: [PATCH 2/2] Handle short writes in cp(1)
From: Alexander Bluhm <bluhm () openbsd ! org>
Date: 2024-04-26 17:52:25
Message-ID: Zivp2WLXVuB2t33C () t430s ! bluhm ! invalid
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic