nfs4: Fix ReadDir() bug when skipping inodes
This commit is contained in:
@@ -801,6 +801,7 @@ Inode::ReadDir(void* _buffer, uint32 size, uint32* _count, uint64* cookie)
|
|||||||
cookie[1]--;
|
cookie[1]--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool overflow = false;
|
||||||
while (count < *_count && !eof) {
|
while (count < *_count && !eof) {
|
||||||
this_count = *_count - count;
|
this_count = *_count - count;
|
||||||
DirEntry* dirents;
|
DirEntry* dirents;
|
||||||
@@ -809,7 +810,7 @@ Inode::ReadDir(void* _buffer, uint32 size, uint32* _count, uint64* cookie)
|
|||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
uint32 i;
|
uint32 i, entries = 0;
|
||||||
for (i = 0; i < min_c(this_count, *_count - count); i++) {
|
for (i = 0; i < min_c(this_count, *_count - count); i++) {
|
||||||
struct dirent* de = reinterpret_cast<dirent*>(buffer + pos);
|
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;
|
const char* name = dirents[i].fName;
|
||||||
if (_FillDirEntry(de, id, name, pos, size) == B_BUFFER_OVERFLOW) {
|
if (_FillDirEntry(de, id, name, pos, size) == B_BUFFER_OVERFLOW) {
|
||||||
eof = true;
|
eof = true;
|
||||||
|
overflow = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos += de->d_reclen;
|
pos += de->d_reclen;
|
||||||
|
entries++;
|
||||||
}
|
}
|
||||||
delete[] dirents;
|
delete[] dirents;
|
||||||
count += i;
|
count += entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 0 && this_count > 0)
|
if (count == 0 && overflow)
|
||||||
return B_BUFFER_OVERFLOW;
|
return B_BUFFER_OVERFLOW;
|
||||||
|
|
||||||
*_count = count;
|
*_count = count;
|
||||||
|
|||||||
@@ -345,7 +345,8 @@ ReplyInterpreter::_DecodeAttrs(XDR::ReadStream& str, AttrValue** attrs,
|
|||||||
fsid.fMajor = stream.GetUHyper();
|
fsid.fMajor = stream.GetUHyper();
|
||||||
fsid.fMinor = 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++;
|
current++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user