tabs, todo

master
Vitaliy Filippov 2014-01-07 17:06:21 +00:00
parent 553e1273ea
commit 46fc23e2d1
2 changed files with 23 additions and 28 deletions

50
bmove.c
View File

@ -1,6 +1,5 @@
/*
* bmove.c --- Move blocks around to make way for a particular
* filesystem structure.
* bmove.c --- Move blocks around to make way for a particular filesystem structure.
*
* Copyright (C) 1997 Theodore Ts'o.
*
@ -16,14 +15,14 @@
#include "bmove.h"
struct process_block_struct {
ext2_ino_t ino;
struct ext2_inode * inode;
ext2fs_block_bitmap reserve;
ext2fs_block_bitmap alloc_map;
errcode_t error;
char *buf;
int add_dir;
int flags;
ext2_ino_t ino;
struct ext2_inode *inode;
ext2fs_block_bitmap reserve;
ext2fs_block_bitmap alloc_map;
errcode_t error;
char *buf;
int add_dir;
int flags;
};
static int process_block(ext2_filsys fs, blk64_t *block_nr,
@ -31,9 +30,9 @@ static int process_block(ext2_filsys fs, blk64_t *block_nr,
int ref_offset, void *priv_data)
{
struct process_block_struct *pb;
errcode_t retval;
int ret;
blk64_t block, orig;
errcode_t retval;
int ret;
blk64_t block, orig;
pb = (struct process_block_struct *) priv_data;
block = orig = *block_nr;
@ -57,7 +56,7 @@ static int process_block(ext2_filsys fs, blk64_t *block_nr,
return BLOCK_ABORT;
}
} while (ext2fs_test_block_bitmap2(pb->reserve, block) ||
ext2fs_test_block_bitmap2(pb->alloc_map, block));
ext2fs_test_block_bitmap2(pb->alloc_map, block));
retval = io_channel_read_blk64(fs->io, orig, 1, pb->buf);
if (retval) {
@ -75,13 +74,12 @@ static int process_block(ext2_filsys fs, blk64_t *block_nr,
ret = BLOCK_CHANGED;
if (pb->flags & EXT2_BMOVE_DEBUG)
printf("ino=%u, blockcnt=%lld, %llu->%llu\n",
(unsigned) pb->ino, blockcnt,
(unsigned) pb->ino, blockcnt,
(unsigned long long) orig,
(unsigned long long) block);
}
if (pb->add_dir) {
retval = ext2fs_add_dir_block2(fs->dblist, pb->ino,
block, blockcnt);
retval = ext2fs_add_dir_block2(fs->dblist, pb->ino, block, blockcnt);
if (retval) {
pb->error = retval;
ret |= BLOCK_ABORT;
@ -95,12 +93,12 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs,
ext2fs_block_bitmap alloc_map,
int flags)
{
ext2_ino_t ino;
ext2_ino_t ino;
struct ext2_inode inode;
errcode_t retval;
errcode_t retval;
struct process_block_struct pb;
ext2_inode_scan scan;
char *block_buf;
ext2_inode_scan scan;
char *block_buf;
retval = ext2fs_open_inode_scan(fs, 0, &scan);
if (retval)
@ -136,18 +134,15 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs,
return retval;
while (ino) {
if ((inode.i_links_count == 0) ||
!ext2fs_inode_has_valid_blocks2(fs, &inode))
if ((inode.i_links_count == 0) || !ext2fs_inode_has_valid_blocks2(fs, &inode))
goto next;
pb.ino = ino;
pb.inode = &inode;
pb.add_dir = (LINUX_S_ISDIR(inode.i_mode) &&
flags & EXT2_BMOVE_GET_DBLIST);
pb.add_dir = (LINUX_S_ISDIR(inode.i_mode) && flags & EXT2_BMOVE_GET_DBLIST);
retval = ext2fs_block_iterate3(fs, ino, 0, block_buf,
process_block, &pb);
retval = ext2fs_block_iterate3(fs, ino, 0, block_buf, process_block, &pb);
if (retval)
return retval;
if (pb.error)
@ -160,4 +155,3 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs,
}
return 0;
}

View File

@ -21,6 +21,7 @@
*/
/**
* TODO fix reallocation for the case when inode tables for flex_bg do not fit into a single block group
* TODO bigalloc compatibility
* TODO write some tests: for inode moving (image with many files),
* for block moving, including extent blocks (one sparse file with many extents),