From 2c9ae83ff93821ede2b8dfca2bb732ea18337fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Thu, 31 Aug 2006 10:42:32 +0000 Subject: [PATCH] improve error handling for copy_attributes : if nothing is read or an error happens on read, continue with next attribute, same for write. Also, use actual written byte count for looping. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18722 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/coreutils/src/copy.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bin/coreutils/src/copy.c b/src/bin/coreutils/src/copy.c index bd009fd2bc..f8d683b28a 100644 --- a/src/bin/coreutils/src/copy.c +++ b/src/bin/coreutils/src/copy.c @@ -164,15 +164,15 @@ copy_attributes(int fromFd, int toFd) ssize_t bytesRead, bytesWritten; bytesRead = fs_read_attr(fromFd, dirent->d_name, info.type, pos, buffer, sizeof(buffer)); - if (bytesRead < 0) - continue; + if (bytesRead <= 0) + break; bytesWritten = fs_write_attr(toFd, dirent->d_name, info.type, pos, buffer, bytesRead); - if (bytesWritten != bytesRead) - continue; + if (bytesWritten <= 0) + break; - pos += bytesRead; - info.size -= bytesRead; + pos += bytesWritten; + info.size -= bytesWritten; } }