/*
- * banalysis.c --- Analyze a filesystem for a block struct
+ * banalysis.c --- Analyze a filesystem by block
*
* Copyright (C) 1997 Theodore Ts'o. This file may be redistributed
* under the terms of the GNU Public License.
#include <sys/types.h>
#include <sys/time.h>
-#ifdef HAVE_LINUX_FS_H
-#include <linux/fs.h>
-#endif
#include <linux/ext2_fs.h>
#include "ext2fs/ext2fs.h"
struct process_block_struct {
struct ext2_block_analyzer_funcs *funcs;
struct ext2_inode_context *ctx;
- void *private;
+ void *priv_data;
};
-/*
- * This function returns 1 if the inode's block entries actually
- * contain block entries.
- */
-static int inode_has_valid_blocks(struct ext2_inode *inode)
-{
- /*
- * Only directories, regular files, and some symbolic links
- * have valid block entries.
- */
- if (!LINUX_S_ISDIR(inode->i_mode) && !LINUX_S_ISREG(inode->i_mode) &&
- !LINUX_S_ISLNK(inode->i_mode))
- return 0;
-
- /*
- * If the symbolic link is a "fast symlink", then the symlink
- * target is stored in the block entries.
- */
- if (LINUX_S_ISLNK (inode->i_mode) && inode->i_blocks == 0 &&
- inode->i_size < EXT2_N_BLOCKS * sizeof (unsigned long))
- return 0;
-
- return 1;
-}
-
static int process_block(ext2_filsys fs, blk_t *block_nr,
int blockcnt, blk_t ref_block,
- int ref_offset, void *private)
+ int ref_offset, void *priv_data)
{
- struct process_block_struct *pb = private;
+ struct process_block_struct *pb = priv_data;
blk_t new_block;
struct ext2_block_relocate_entry ent;
ref_offset = blockcnt;
new_block = pb->funcs->block_analyze(fs, *block_nr, ref_block,
- ref_offset, pb->ctx, pb->private);
+ ref_offset, pb->ctx, pb->priv_data);
if (new_block) {
ent.new = new_block;
ent.offset = ref_offset;
errcode_t ext2_block_analyze(ext2_filsys fs,
struct ext2_block_analyzer_funcs *funcs,
ext2_brel block_relocation_table,
- void *private)
+ void *priv_data)
{
ino_t ino;
struct ext2_inode inode;
return retval;
pb.funcs = funcs;
- pb.private = private;
+ pb.priv_data = priv_data;
pb.ctx = &ctx;
block_buf = malloc(fs->blocksize * 3);
retval = ext2fs_get_next_inode(scan, &ino, &inode);
if (retval)
return retval;
- ctx.ctx = private;
+ ctx.ctx = priv_data;
ctx.brel = block_relocation_table;
while (ino) {
if ((inode.i_links_count == 0) ||
- !inode_has_valid_blocks(&inode))
+ !ext2fs_inode_has_valid_blocks(&inode))
goto next;
ctx.ino = ino;
ctx.error = 0;
if (funcs->pre_analyze &&
- !(*funcs->pre_analyze)(fs, &ctx, private))
+ !(*funcs->pre_analyze)(fs, &ctx, priv_data))
goto next;
retval = ext2fs_block_iterate2(fs, ino, 0, block_buf,
return retval;
if (funcs->post_analyze)
- (funcs->post_analyze)(fs, &ctx, private);
+ (funcs->post_analyze)(fs, &ctx, priv_data);
next:
retval = ext2fs_get_next_inode(scan, &ino, &inode);
}
return 0;
}
+