Whamcloud - gitweb
libext2fs: fix offset code in undo_write_tdb
[tools/e2fsprogs.git] / lib / ext2fs / dblist_dir.c
index c4ea584..864a3ca 100644 (file)
@@ -2,14 +2,14 @@
  * dblist_dir.c --- iterate by directory entry
  *
  * Copyright 1997 by Theodore Ts'o
- * 
+ *
  * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
+ * This file may be redistributed under the terms of the GNU Library
+ * General Public License, version 2.
  * %End-Header%
- * 
  */
 
+#include "config.h"
 #include <stdio.h>
 #if HAVE_UNISTD_H
 #include <unistd.h>
@@ -20,7 +20,7 @@
 #include "ext2_fs.h"
 #include "ext2fsP.h"
 
-static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry *db_info,
+static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry2 *db_info,
                       void *priv_data);
 
 errcode_t ext2fs_dblist_dir_iterate(ext2_dblist dblist,
@@ -45,33 +45,44 @@ errcode_t ext2fs_dblist_dir_iterate(ext2_dblist dblist,
        if (block_buf)
                ctx.buf = block_buf;
        else {
-               retval = ext2fs_get_mem(dblist->fs->blocksize,
-                                       (void **) &ctx.buf);
+               retval = ext2fs_get_mem(dblist->fs->blocksize, &ctx.buf);
                if (retval)
                        return retval;
        }
-       ctx.func = 0;
-       ctx.func2 = func;
+       ctx.func = func;
        ctx.priv_data = priv_data;
        ctx.errcode = 0;
 
-       retval = ext2fs_dblist_iterate(dblist, db_dir_proc, &ctx);
-       
+       retval = ext2fs_dblist_iterate2(dblist, db_dir_proc, &ctx);
+
        if (!block_buf)
-               ext2fs_free_mem((void **) &ctx.buf);
+               ext2fs_free_mem(&ctx.buf);
        if (retval)
                return retval;
        return ctx.errcode;
 }
 
-static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry *db_info,
+static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry2 *db_info,
                       void *priv_data)
 {
+       struct ext2_inode       inode;
        struct dir_context      *ctx;
+       int                     ret;
 
        ctx = (struct dir_context *) priv_data;
        ctx->dir = db_info->ino;
-       
-       return ext2fs_process_dir_block(fs, &db_info->blk,
-                                       db_info->blockcnt, 0, 0, priv_data);
+       ctx->errcode = 0;
+
+       ctx->errcode = ext2fs_read_inode(fs, ctx->dir, &inode);
+       if (ctx->errcode)
+               return DBLIST_ABORT;
+       if (inode.i_flags & EXT4_INLINE_DATA_FL)
+               ret = ext2fs_inline_data_dir_iterate(fs, ctx->dir, ctx);
+       else
+               ret = ext2fs_process_dir_block(fs, &db_info->blk,
+                                              db_info->blockcnt, 0, 0,
+                                              priv_data);
+       if ((ret & BLOCK_ABORT) && !ctx->errcode)
+               return DBLIST_ABORT;
+       return 0;
 }