nfs4: Fix ReadDir() bug when skipping inodes

This commit is contained in:
Pawel Dziepak
2012-06-29 02:14:59 +02:00
parent a90b62049a
commit 47c4ae3751
2 changed files with 8 additions and 4 deletions
@@ -801,6 +801,7 @@ Inode::ReadDir(void* _buffer, uint32 size, uint32* _count, uint64* cookie)
cookie[1]--;
}
bool overflow = false;
while (count < *_count && !eof) {
this_count = *_count - count;
DirEntry* dirents;
@@ -809,7 +810,7 @@ Inode::ReadDir(void* _buffer, uint32 size, uint32* _count, uint64* cookie)
if (result != B_OK)
return result;
uint32 i;
uint32 i, entries = 0;
for (i = 0; i < min_c(this_count, *_count - count); i++) {
struct dirent* de = reinterpret_cast<dirent*>(buffer + pos);
@@ -828,16 +829,18 @@ Inode::ReadDir(void* _buffer, uint32 size, uint32* _count, uint64* cookie)
const char* name = dirents[i].fName;
if (_FillDirEntry(de, id, name, pos, size) == B_BUFFER_OVERFLOW) {
eof = true;
overflow = true;
break;
}
pos += de->d_reclen;
entries++;
}
delete[] dirents;
count += i;
count += entries;
}
if (count == 0 && this_count > 0)
if (count == 0 && overflow)
return B_BUFFER_OVERFLOW;
*_count = count;
@@ -345,7 +345,8 @@ ReplyInterpreter::_DecodeAttrs(XDR::ReadStream& str, AttrValue** attrs,
fsid.fMajor = stream.GetUHyper();
fsid.fMinor = stream.GetUHyper();
values[current].fData.fPointer = new FilesystemId(fsid);
values[current].fData.fPointer = malloc(sizeof(fsid));
memcpy(values[current].fData.fPointer, &fsid, sizeof(fsid));
current++;
}