From 75e17a8908d52e32f5de85b90b74e156265c60c6 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Tue, 25 Jan 2011 17:22:47 -0800 Subject: [PATCH] sdcard: Fix readdir implementation so rewinddir will work correctly Fixes problem with "ls -R" in /mnt/sdcard BUG: 3309556 Change-Id: Ie2246585439116de3cb40f4005f3b44a0439f54c Signed-off-by: Mike Lockwood --- sdcard/sdcard.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c index 9bb9d4b57..0b8f656c5 100644 --- a/sdcard/sdcard.c +++ b/sdcard/sdcard.c @@ -845,13 +845,19 @@ void handle_fuse_request(struct fuse *fuse, struct fuse_in_header *hdr, void *da struct dirent *de; struct dirhandle *h = id_to_ptr(req->fh); TRACE("READDIR %p\n", h); + if (req->offset == 0) { + /* rewinddir() might have been called above us, so rewind here too */ + TRACE("calling rewinddir()\n"); + rewinddir(h->d); + } de = readdir(h->d); if (!de) { fuse_status(fuse, hdr->unique, 0); return; } fde->ino = FUSE_UNKNOWN_INO; - fde->off = 0; + /* increment the offset so we can detect when rewinddir() seeks back to the beginning */ + fde->off = req->offset + 1; fde->type = de->d_type; fde->namelen = strlen(de->d_name); memcpy(fde->name, de->d_name, fde->namelen + 1);