[Haiku-commits] r31310 - haiku/trunk/src/bin/coreutils/src
stippi at mail.berlios.de
stippi at mail.berlios.de
Mon Jun 29 11:13:35 CEST 2009
Author: stippi
Date: 2009-06-29 11:13:33 +0200 (Mon, 29 Jun 2009)
New Revision: 31310
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31310&view=rev
Modified:
haiku/trunk/src/bin/coreutils/src/copy.c
Log:
The copy_attributes() loop made one iteration too much trying to read and
write 0 bytes after doing a successful copy of an attribute. Since
fs_write_attr() was actually ignoring the position argument, this would just
clobber attributes and truncate them back to 0 bytes. This was fixed in the
previous commit, however, it should be noted that if the buffer which
copy_attributes() uses were too small, writing attributes which live in the
"small data section" iteratively would not work because of a current BFS
limitation.
Modified: haiku/trunk/src/bin/coreutils/src/copy.c
===================================================================
--- haiku/trunk/src/bin/coreutils/src/copy.c 2009-06-29 09:08:43 UTC (rev 31309)
+++ haiku/trunk/src/bin/coreutils/src/copy.c 2009-06-29 09:13:33 UTC (rev 31310)
@@ -153,21 +153,28 @@
if (fs_stat_attr(fromFd, dirent->d_name, &info) != 0)
continue;
- while (info.size >= 0) {
+ while (true) {
ssize_t bytesRead, bytesWritten;
bytesRead = fs_read_attr(fromFd, dirent->d_name, info.type, pos,
buffer, sizeof(buffer));
- if (bytesRead < 0)
+ if (bytesRead < 0) {
+ fprintf(stderr, "error reading attribute '%s'", dirent->d_name);
break;
+ }
bytesWritten = fs_write_attr(toFd, dirent->d_name, info.type, pos,
buffer, bytesRead);
- if (bytesWritten != bytesRead || bytesRead == 0)
+ if (bytesWritten != bytesRead) {
+ fprintf(stderr, "error writing attribute '%s'", dirent->d_name);
break;
+ }
pos += bytesWritten;
info.size -= bytesWritten;
+
+ if (info.size <= 0)
+ break;
}
}
More information about the Haiku-commits
mailing list