assert(diri);
assert(diri->inode.mode & INODE_MODE_DIR);
+ // add . and ..?
+ string dot(".");
+ contents[dot] = diri->inode;
+ if (diri != root) {
+ string dotdot("..");
+ contents[dotdot] = diri->dn->dir->parent_inode->inode;
+ }
+
if (!reply->get_dir_in().empty()) {
// only open dir if we're actually adding stuff to it!
Dir *dir = diri->open_dir();
for (list<InodeStat*>::const_iterator pin = reply->get_dir_in().begin();
pin != reply->get_dir_in().end();
++pin, ++pdn) {
- // count entries
+ if (*pdn == ".")
+ continue;
+
+ // count entries
res++;
// put in cache
// contents to caller too!
contents[*pdn] = in->inode;
}
+ if (dir->is_empty())
+ close_dir(dir);
}
- // add .. too?
- if (diri != root && diri->dn && diri->dn->dir) {
- Inode *parent = diri->dn->dir->parent_inode;
- contents[".."] = parent->inode;
- }
// FIXME: remove items in cache that weren't in my readdir?
// ***