[PATCH] FUSE: readdir fixes

From: Miklos Szeredi
Date: Fri Apr 01 2005 - 16:36:16 EST


This patch correctly sets f_pos in readdir. The offset passed from
userspace is now the offset of the next entry. Needs at least libfuse
2.3-pre2 to work properly.

Zero lengh filenames are also disallowed.

Signed-off-by: Miklos Szeredi <miklos@xxxxxxxxxx>

diff -rup linux-2.6.12-rc1-mm4/fs/fuse/dir.c linux-fuse/fs/fuse/dir.c
--- linux-2.6.12-rc1-mm4/fs/fuse/dir.c 2005-03-31 21:52:18.000000000 +0200
+++ linux-fuse/fs/fuse/dir.c 2005-04-01 22:49:25.000000000 +0200
@@ -477,19 +477,19 @@ static int parse_dirfile(char *buf, size
struct fuse_dirent *dirent = (struct fuse_dirent *) buf;
size_t reclen = FUSE_DIRENT_SIZE(dirent);
int over;
- if (dirent->namelen > FUSE_NAME_MAX)
+ if (!dirent->namelen || dirent->namelen > FUSE_NAME_MAX)
return -EIO;
if (reclen > nbytes)
break;

over = filldir(dstbuf, dirent->name, dirent->namelen,
- dirent->off, dirent->ino, dirent->type);
+ file->f_pos, dirent->ino, dirent->type);
if (over)
break;

buf += reclen;
- file->f_pos += reclen;
nbytes -= reclen;
+ file->f_pos = dirent->off;
}

return 0;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/