Most nfs servers return READDIRPLUS entry cookies as the offset into the directory where the dirent starts.
This means that reading the directory is not impacted by changes to the directory and that BAD_COOKIE errors will never arise.
Think loops like
opendir()
while(readdir()){
unlink()
}
closedir()
Some nfs servers can not easily produce semantics similar to the above in which case the cleanup funciton that does a recursive delete using a loop semantically similar to the above.
Change how we traverse directories to instead work something like
opendir()
while(readdir()){
store dirent in list
}
closedir()
walk whole list {
unlink()
}
int ret = NFS3_OK;
data_t *fh;
entryplus3 *e, *last_e = NULL;
+ entryplus3 *entries = NULL;
+ entryplus3 *new_entry;
char *dir = NULL;
dir = strdup(name);
);
free(new_name);
- if (cb) {
- cb(e, private_data);
- }
+ new_entry = malloc(sizeof(entryplus3));
+ new_entry->name = strdup(e->name);
+ new_entry->name_attributes.post_op_attr_u.attributes.type = e->name_attributes.post_op_attr_u.attributes.type;
+ new_entry->nextentry = entries;
+ entries = new_entry;
}
if (READDIRPLUS3res->READDIRPLUS3res_u.resok.reply.eof == 0) {
goto again;
}
+ /* we have read all entries, now invoke the callback for all of them */
+ while (entries != NULL) {
+ e = entries;
+ entries = entries->nextentry;
+
+ if (cb) {
+ cb(e, private_data);
+ }
+
+ free(e->name);
+ free(e);
+ }
finished:
if (dir) {
{
struct cb_data *cbd;
nfsstat3 res;
-
+
cbd = malloc(sizeof(struct cb_data));
cbd->nfsio = op->child->private;