lk: teach crfs_readdir about dirents with multiple items
Alex Chiang
achiang at hp.com
Mon May 12 10:14:34 PDT 2008
Teach crfs_readdir about dirents with multiple items. The most
immediate, obvious change is that we now see both the dot and
dotdot entries during 'ls -alF'.
[root at canola crfs]# pwd
/mnt/crfs
[root at canola crfs]# ls -alF
total 5
drwxr-xr-x 1 root root 42 2008-05-12 11:14 ./
drwxr-xr-x 6 root root 4096 2008-05-01 17:23 ../
All tests in crfs test suite pass successfully.
Signed-off-by: Alex Chiang <achiang at hp.com>
---
diff -r 77848719c4ba lk/dir.c
--- a/lk/dir.c Tue Apr 22 14:03:17 2008 -0700
+++ b/lk/dir.c Fri May 09 23:59:43 2008 -0600
@@ -90,6 +90,7 @@ static int crfs_readdir(struct file *fil
struct crfs_key key;
struct crfs_key last;
struct crfs_meta_ref mref;
+ void *dent;
int done = 0;
int ret;
@@ -106,19 +107,28 @@ static int crfs_readdir(struct file *fil
break;
if (crfs_key_compare(mref.r_key, &last) <= 0) {
- ditem = mref.r_data;
- filp->f_pos = le64_to_cpu(mref.r_key->offset);
+ dent = mref.r_data;
- crfs_log("ent %.*s", le16_to_cpu(ditem->name_len),
- ditem->name);
+ while (dent < (mref.r_data + mref.r_bytes)) {
+ ditem = dent;
+ filp->f_pos = le64_to_cpu(mref.r_key->offset);
- done = filldir(dirent, ditem->name,
- le16_to_cpu(ditem->name_len),
- filp->f_pos,
- le64_to_cpu(ditem->location.objectid),
- crfs_filldir_type[ditem->type]);
- if (!done)
- filp->f_pos++;
+ crfs_log("ent %.*s",
+ le16_to_cpu(ditem->name_len),
+ ditem->name);
+
+ done = filldir(dirent, ditem->name,
+ le16_to_cpu(ditem->name_len),
+ filp->f_pos,
+ le64_to_cpu(ditem->location.objectid),
+ crfs_filldir_type[ditem->type]);
+
+ if (!done)
+ filp->f_pos++;
+
+ dent += sizeof(*ditem);
+ dent += le16_to_cpu(ditem->name_len);
+ }
} else
done = 1;
More information about the crfs-devel
mailing list