diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2000-06-15 01:55:58 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2000-06-15 01:55:58 +0000 |
commit | 53b3988d474435254a3b053a68bb24ce9e439295 (patch) | |
tree | f8da8e40f01f4ad02bbd76b8c9920749b118235f /fs/readdir.c | |
parent | b0cb48abe83d1a4389ea938bf624f8baa82c5047 (diff) |
Merge with 2.3.99-pre9.
Diffstat (limited to 'fs/readdir.c')
-rw-r--r-- | fs/readdir.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/fs/readdir.c b/fs/readdir.c index e6256636e..059ab391d 100644 --- a/fs/readdir.c +++ b/fs/readdir.c @@ -32,6 +32,53 @@ out: return res; } +int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir) +{ + int i; + struct dentry *dentry = filp->f_dentry; + + i = filp->f_pos; + switch (i) { + case 0: + if (filldir(dirent, ".", 1, i, dentry->d_inode->i_ino) < 0) + break; + i++; + filp->f_pos++; + /* fallthrough */ + case 1: + if (filldir(dirent, "..", 2, i, dentry->d_parent->d_inode->i_ino) < 0) + break; + i++; + filp->f_pos++; + /* fallthrough */ + default: { + struct list_head *list = dentry->d_subdirs.next; + + int j = i-2; + for (;;) { + if (list == &dentry->d_subdirs) + return 0; + if (!j) + break; + j--; + list = list->next; + } + + do { + struct dentry *de = list_entry(list, struct dentry, d_child); + + if (!d_unhashed(de) && de->d_inode) { + if (filldir(dirent, de->d_name.name, de->d_name.len, filp->f_pos, de->d_inode->i_ino) < 0) + break; + } + filp->f_pos++; + list = list->next; + } while (list != &dentry->d_subdirs); + } + } + return 0; +} + /* * Traditional linux readdir() handling.. * |