libsffs, libvtreefs: fix getdents bug
Bad logic introduced as part of the fsdriver changes could cause getdents to terminate early in these libraries. Issue reported by r0ller. Change-Id: If450d5ea85e830584878d8a4ec0f00519355a353
This commit is contained in:
parent
75e18fe498
commit
f912036bae
2 changed files with 8 additions and 4 deletions
|
@ -98,7 +98,7 @@ ssize_t do_getdents(ino_t ino_nr, struct fsdriver_data *data, size_t bytes,
|
|||
* the "." entry, the second position is for the ".." entry, and the next
|
||||
* position numbers each represent a file in the directory.
|
||||
*/
|
||||
do {
|
||||
for (;;) {
|
||||
/* Determine which inode and name to use for this entry.
|
||||
* We have no idea whether the host will give us "." and/or "..",
|
||||
* so generate our own and skip those from the host.
|
||||
|
@ -165,7 +165,9 @@ ssize_t do_getdents(ino_t ino_nr, struct fsdriver_data *data, size_t bytes,
|
|||
|
||||
if (r < 0)
|
||||
return r;
|
||||
} while (r > 0);
|
||||
if (r == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return fsdriver_dentry_finish(&fsdentry);
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@ fs_getdents(ino_t ino_nr, struct fsdriver_data * data, size_t bytes,
|
|||
|
||||
fsdriver_dentry_init(&fsdentry, data, bytes, buf, bufsize);
|
||||
|
||||
do {
|
||||
for (;;) {
|
||||
/* Determine which inode and name to use for this entry. */
|
||||
pos = (*posp)++;
|
||||
|
||||
|
@ -287,7 +287,9 @@ fs_getdents(ino_t ino_nr, struct fsdriver_data * data, size_t bytes,
|
|||
IFTODT(child->i_stat.mode));
|
||||
if (r < 0)
|
||||
return r;
|
||||
} while (r > 0);
|
||||
if (r == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return fsdriver_dentry_finish(&fsdentry);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue