From 8a3c3c477cd728aa46f59fa4d85402aae5b06fc8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Pierre=20Andr=C3=A9?= Date: Wed, 30 Sep 2015 08:18:13 +0200 Subject: [PATCH] Used incremental offsets when reading a directory in lowntfs-3g Using incremental offsets avoids misinterpreting readdir() as rewinddir(). It also makes possible to implement seekdir() [not done yet] --- src/lowntfs-3g.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c index 9a894df2..40004a41 100644 --- a/src/lowntfs-3g.c +++ b/src/lowntfs-3g.c @@ -170,6 +170,7 @@ typedef struct fill_item { typedef struct fill_context { struct fill_item *first; struct fill_item *last; + off_t off; fuse_req_t req; fuse_ino_t ino; BOOL filled; @@ -1052,7 +1053,7 @@ static int ntfs_fuse_filler(ntfs_fuse_fill_context_t *fill_ctx, sz = fuse_add_direntry(fill_ctx->req, ¤t->buf[current->off], current->bufsize - current->off, - filename, &st, current->off); + filename, &st, current->off + fill_ctx->off); if (!sz || ((current->off + sz) > current->bufsize)) { newone = (ntfs_fuse_fill_item_t*)ntfs_malloc (sizeof(ntfs_fuse_fill_item_t) @@ -1063,11 +1064,12 @@ static int ntfs_fuse_filler(ntfs_fuse_fill_context_t *fill_ctx, newone->next = (ntfs_fuse_fill_item_t*)NULL; current->next = newone; fill_ctx->last = newone; + fill_ctx->off += current->off; current = newone; sz = fuse_add_direntry(fill_ctx->req, current->buf, current->bufsize - current->off, - filename, &st, current->off); + filename, &st, fill_ctx->off); if (!sz) { errno = EIO; ntfs_log_error("Could not add a" @@ -1124,6 +1126,7 @@ static void ntfs_fuse_opendir(fuse_req_t req, fuse_ino_t ino, = (ntfs_fuse_fill_item_t*)NULL; fill->filled = FALSE; fill->ino = ino; + fill->off = 0; } fi->fh = (long)fill; } @@ -1192,6 +1195,7 @@ static void ntfs_fuse_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, fill->req = req; fill->first = first; fill->last = first; + fill->off = 0; ni = ntfs_inode_open(ctx->vol,INODE(ino)); if (!ni) err = -errno; -- 2.11.0