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:
parent
181593ba0b
commit
125f5b846c
@ -153,21 +153,28 @@ copy_attributes(int fromFd, int toFd)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user