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. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31310 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -153,21 +153,28 @@ copy_attributes(int fromFd, int toFd)
|
|||||||
if (fs_stat_attr(fromFd, dirent->d_name, &info) != 0)
|
if (fs_stat_attr(fromFd, dirent->d_name, &info) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
while (info.size >= 0) {
|
while (true) {
|
||||||
ssize_t bytesRead, bytesWritten;
|
ssize_t bytesRead, bytesWritten;
|
||||||
|
|
||||||
bytesRead = fs_read_attr(fromFd, dirent->d_name, info.type, pos,
|
bytesRead = fs_read_attr(fromFd, dirent->d_name, info.type, pos,
|
||||||
buffer, sizeof(buffer));
|
buffer, sizeof(buffer));
|
||||||
if (bytesRead < 0)
|
if (bytesRead < 0) {
|
||||||
|
fprintf(stderr, "error reading attribute '%s'", dirent->d_name);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
bytesWritten = fs_write_attr(toFd, dirent->d_name, info.type, pos,
|
bytesWritten = fs_write_attr(toFd, dirent->d_name, info.type, pos,
|
||||||
buffer, bytesRead);
|
buffer, bytesRead);
|
||||||
if (bytesWritten != bytesRead || bytesRead == 0)
|
if (bytesWritten != bytesRead) {
|
||||||
|
fprintf(stderr, "error writing attribute '%s'", dirent->d_name);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
pos += bytesWritten;
|
pos += bytesWritten;
|
||||||
info.size -= bytesWritten;
|
info.size -= bytesWritten;
|
||||||
|
|
||||||
|
if (info.size <= 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user