Whamcloud - gitweb
Comment out ext2_find_first_bit_set and ext2fs_find_next_bit_set
[tools/e2fsprogs.git] / lib / ext2fs / dblist_dir.c
1 /*
2  * dblist_dir.c --- iterate by directory entry
3  *
4  * Copyright 1997 by Theodore Ts'o
5  * 
6  * %Begin-Header%
7  * This file may be redistributed under the terms of the GNU Public
8  * License.
9  * %End-Header%
10  * 
11  */
12
13 #include <stdio.h>
14 #if HAVE_UNISTD_H
15 #include <unistd.h>
16 #endif
17 #include <string.h>
18 #include <time.h>
19
20 #include "ext2_fs.h"
21 #include "ext2fsP.h"
22
23 static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry *db_info,
24                        void *priv_data);
25
26 errcode_t ext2fs_dblist_dir_iterate(ext2_dblist dblist,
27                                     int flags,
28                                     char        *block_buf,
29                                     int (*func)(ext2_ino_t dir,
30                                                 int     entry,
31                                                 struct ext2_dir_entry *dirent,
32                                                 int     offset,
33                                                 int     blocksize,
34                                                 char    *buf,
35                                                 void    *priv_data),
36                                     void *priv_data)
37 {
38         errcode_t               retval;
39         struct dir_context      ctx;
40
41         EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
42
43         ctx.dir = 0;
44         ctx.flags = flags;
45         if (block_buf)
46                 ctx.buf = block_buf;
47         else {
48                 retval = ext2fs_get_mem(dblist->fs->blocksize,
49                                         (void **) &ctx.buf);
50                 if (retval)
51                         return retval;
52         }
53         ctx.func = 0;
54         ctx.func2 = func;
55         ctx.priv_data = priv_data;
56         ctx.errcode = 0;
57
58         retval = ext2fs_dblist_iterate(dblist, db_dir_proc, &ctx);
59         
60         if (!block_buf)
61                 ext2fs_free_mem((void **) &ctx.buf);
62         if (retval)
63                 return retval;
64         return ctx.errcode;
65 }
66
67 static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry *db_info,
68                        void *priv_data)
69 {
70         struct dir_context      *ctx;
71
72         ctx = (struct dir_context *) priv_data;
73         ctx->dir = db_info->ino;
74         
75         return ext2fs_process_dir_block(fs, &db_info->blk,
76                                         db_info->blockcnt, 0, 0, priv_data);
77 }