cleanup: run indent with the Linux Kernel style across all code

Over the years, the reiserfs kernel code has been gradually cleaned up
to be more readable. This patch does the same to the progs code.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
This commit is contained in:
Jeff Mahoney committed 2013-08-26 17:14:42 -04:00
1 parent b23d40f723
commit 47cff72748
51 files changed
+27279 -25108

No files matched your search

+191 -182
View File
@@ -6,106 +6,114 @@
#include "fsck.h"
#include "progbar.h"
struct tree_balance * cur_tb = 0;
struct tree_balance *cur_tb = 0;
void reiserfsck_paste_into_item (struct reiserfs_path *path, const char * body, int size)
void reiserfsck_paste_into_item(struct reiserfs_path *path, const char *body,
int size)
{
struct tree_balance tb;
init_tb_struct (&tb, fs, path, size);
if (fix_nodes (/*tb.transaction_handle,*/ M_PASTE, &tb, 0/*ih*/) != CARRY_ON)
//fix_nodes(options, tree_balance, ih_to_option, body_to_option)
die ("reiserfsck_paste_into_item: fix_nodes failed");
do_balance (/*tb.transaction_handle,*/ &tb, 0, body, M_PASTE, 0/*zero num*/);
struct tree_balance tb;
init_tb_struct(&tb, fs, path, size);
if (fix_nodes( /*tb.transaction_handle, */ M_PASTE, &tb, 0 /*ih */ ) !=
CARRY_ON)
//fix_nodes(options, tree_balance, ih_to_option, body_to_option)
die("reiserfsck_paste_into_item: fix_nodes failed");
do_balance( /*tb.transaction_handle, */ &tb, 0, body, M_PASTE,
0 /*zero num */ );
}
void reiserfsck_insert_item (struct reiserfs_path *path, struct item_head * ih, const char * body)
void reiserfsck_insert_item(struct reiserfs_path *path, struct item_head *ih,
const char *body)
{
struct tree_balance tb;
init_tb_struct (&tb, fs, path, IH_SIZE + get_ih_item_len(ih));
if (fix_nodes (/*tb.transaction_handle,*/ M_INSERT, &tb, ih/*, body*/) != CARRY_ON)
die ("reiserfsck_insert_item: fix_nodes failed");
do_balance (/*tb.transaction_handle,*/ &tb, ih, body, M_INSERT, 0/*zero num*/);
struct tree_balance tb;
init_tb_struct(&tb, fs, path, IH_SIZE + get_ih_item_len(ih));
if (fix_nodes
( /*tb.transaction_handle, */ M_INSERT, &tb,
ih /*, body */ ) != CARRY_ON)
die("reiserfsck_insert_item: fix_nodes failed");
do_balance( /*tb.transaction_handle, */ &tb, ih, body, M_INSERT,
0 /*zero num */ );
}
static void free_unformatted_nodes (struct item_head * ih, struct buffer_head * bh)
static void free_unformatted_nodes(struct item_head *ih, struct buffer_head *bh)
{
__u32 * punfm = (__u32 *)B_I_PITEM (bh, ih);
unsigned int i;
__u32 *punfm = (__u32 *) B_I_PITEM(bh, ih);
unsigned int i;
for (i = 0; i < I_UNFM_NUM (ih); i ++) {
__u32 unfm = d32_get (punfm, i);
if (unfm != 0) {
struct buffer_head * to_be_forgotten;
for (i = 0; i < I_UNFM_NUM(ih); i++) {
__u32 unfm = d32_get(punfm, i);
if (unfm != 0) {
struct buffer_head *to_be_forgotten;
to_be_forgotten = find_buffer (fs->fs_dev, unfm, fs->fs_blocksize);
if (to_be_forgotten) {
//atomic_inc(&to_be_forgotten->b_count);
to_be_forgotten->b_count ++;
bforget (to_be_forgotten);
}
to_be_forgotten =
find_buffer(fs->fs_dev, unfm, fs->fs_blocksize);
if (to_be_forgotten) {
//atomic_inc(&to_be_forgotten->b_count);
to_be_forgotten->b_count++;
bforget(to_be_forgotten);
}
reiserfs_free_block (fs, unfm);
reiserfs_free_block(fs, unfm);
}
}
}
}
void reiserfsck_delete_item (struct reiserfs_path *path, int temporary)
void reiserfsck_delete_item(struct reiserfs_path *path, int temporary)
{
struct tree_balance tb;
struct item_head * ih = PATH_PITEM_HEAD (path);
if (is_indirect_ih (ih) && !temporary)
free_unformatted_nodes (ih, PATH_PLAST_BUFFER (path));
struct tree_balance tb;
struct item_head *ih = PATH_PITEM_HEAD(path);
init_tb_struct (&tb, fs, path, -(IH_SIZE + get_ih_item_len(ih)));
if (is_indirect_ih(ih) && !temporary)
free_unformatted_nodes(ih, PATH_PLAST_BUFFER(path));
if (fix_nodes (/*tb.transaction_handle,*/ M_DELETE, &tb, 0/*ih*/) != CARRY_ON)
die ("reiserfsck_delete_item: fix_nodes failed");
do_balance (/*tb.transaction_handle,*/ &tb, 0, 0, M_DELETE, 0/*zero num*/);
init_tb_struct(&tb, fs, path, -(IH_SIZE + get_ih_item_len(ih)));
if (fix_nodes( /*tb.transaction_handle, */ M_DELETE, &tb, 0 /*ih */ ) !=
CARRY_ON)
die("reiserfsck_delete_item: fix_nodes failed");
do_balance( /*tb.transaction_handle, */ &tb, 0, 0, M_DELETE,
0 /*zero num */ );
}
void reiserfsck_cut_from_item (struct reiserfs_path *path, int cut_size)
void reiserfsck_cut_from_item(struct reiserfs_path *path, int cut_size)
{
struct tree_balance tb;
struct item_head * ih;
struct tree_balance tb;
struct item_head *ih;
if (cut_size >= 0)
die ("reiserfsck_cut_from_item: cut size == %d", cut_size);
if (cut_size >= 0)
die("reiserfsck_cut_from_item: cut size == %d", cut_size);
if (is_indirect_ih (ih = PATH_PITEM_HEAD (path))) {
struct buffer_head *bh = PATH_PLAST_BUFFER (path);
__u32 unfm_ptr = d32_get ((__u32 *)B_I_PITEM(bh, ih), I_UNFM_NUM (ih) - 1);
if (unfm_ptr != 0) {
struct buffer_head * to_be_forgotten;
if (is_indirect_ih(ih = PATH_PITEM_HEAD(path))) {
struct buffer_head *bh = PATH_PLAST_BUFFER(path);
__u32 unfm_ptr =
d32_get((__u32 *) B_I_PITEM(bh, ih), I_UNFM_NUM(ih) - 1);
if (unfm_ptr != 0) {
struct buffer_head *to_be_forgotten;
to_be_forgotten = find_buffer (fs->fs_dev, unfm_ptr, fs->fs_blocksize);
if (to_be_forgotten) {
//atomic_inc(&to_be_forgotten->b_count);
to_be_forgotten->b_count ++;
bforget (to_be_forgotten);
}
reiserfs_free_block (fs, unfm_ptr);
to_be_forgotten =
find_buffer(fs->fs_dev, unfm_ptr, fs->fs_blocksize);
if (to_be_forgotten) {
//atomic_inc(&to_be_forgotten->b_count);
to_be_forgotten->b_count++;
bforget(to_be_forgotten);
}
reiserfs_free_block(fs, unfm_ptr);
}
}
}
init_tb_struct(&tb, fs, path, cut_size);
init_tb_struct (&tb, fs, path, cut_size);
if (fix_nodes( /*tb.transaction_handle, */ M_CUT, &tb, 0) != CARRY_ON)
die("reiserfsck_cut_from_item: fix_nodes failed");
if (fix_nodes (/*tb.transaction_handle,*/ M_CUT, &tb, 0) != CARRY_ON)
die ("reiserfsck_cut_from_item: fix_nodes failed");
do_balance (/*tb.transaction_handle,*/ &tb, 0, 0, M_CUT, 0/*zero num*/);
do_balance( /*tb.transaction_handle, */ &tb, 0, 0, M_CUT,
0 /*zero num */ );
}
/* uget_rkey is utils clone of stree.c/get_rkey */
/*
struct reiserfs_key *uget_rkey (struct reiserfs_path *path)
@@ -143,147 +151,148 @@ struct reiserfs_key *uget_rkey (struct reiserfs_path *path)
}
*/
static unsigned long first_child (struct buffer_head * bh)
static unsigned long first_child(struct buffer_head *bh)
{
return get_dc_child_blocknr (B_N_CHILD (bh, 0));
return get_dc_child_blocknr(B_N_CHILD(bh, 0));
}
#if 0
static unsigned long last_child (struct buffer_head * bh)
static unsigned long last_child(struct buffer_head *bh)
{
return child_block_number (bh, node_item_number (bh));
return child_block_number(bh, node_item_number(bh));
}
#endif
static unsigned long get_child (int pos, struct buffer_head * parent)
static unsigned long get_child(int pos, struct buffer_head *parent)
{
if (pos == -1)
return -1;
if (pos == -1)
return -1;
if (pos > B_NR_ITEMS (parent))
die ("get_child: no child found, should not happen: %d of %d", pos, B_NR_ITEMS (parent));
return get_dc_child_blocknr (B_N_CHILD (parent, pos));
if (pos > B_NR_ITEMS(parent))
die("get_child: no child found, should not happen: %d of %d",
pos, B_NR_ITEMS(parent));
return get_dc_child_blocknr(B_N_CHILD(parent, pos));
}
static void print (int cur, int total)
static void print(int cur, int total)
{
if (fsck_quiet (fs))
return;
printf ("/%3d (of %3d)", cur, total);fflush (stdout);
if (fsck_quiet(fs))
return;
printf("/%3d (of %3d)", cur, total);
fflush(stdout);
}
/* erase /XXX(of XXX) */
static void erase (void)
static void erase(void)
{
if (fsck_quiet (fs))
return;
printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b");
printf (" ");
printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b");
fflush (stdout);
if (fsck_quiet(fs))
return;
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b");
printf(" ");
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
void pass_through_tree (reiserfs_filsys_t * fs, do_after_read_t action1,
do_on_full_path_t action2, int depth)
void pass_through_tree(reiserfs_filsys_t *fs, do_after_read_t action1,
do_on_full_path_t action2, int depth)
{
struct buffer_head * path[MAX_HEIGHT] = {0,};
int total[MAX_HEIGHT] = {0,};
int cur[MAX_HEIGHT] = {0,};
int h = 0;
unsigned long block = get_sb_root_block (fs->fs_ondisk_sb);
int problem;
struct spinner spinner;
struct buffer_head *path[MAX_HEIGHT] = { 0, };
int total[MAX_HEIGHT] = { 0, };
int cur[MAX_HEIGHT] = { 0, };
int h = 0;
unsigned long block = get_sb_root_block(fs->fs_ondisk_sb);
int problem;
struct spinner spinner;
spinner_init(&spinner, fsck_progress_file(fs));
spinner_init(&spinner, fsck_progress_file(fs));
if (block >= get_sb_block_count(fs->fs_ondisk_sb)
|| not_data_block(fs, block)) {
die("\nBad root block %lu. (--rebuild-tree did not complete)\n",
block);
}
if (block >= get_sb_block_count (fs->fs_ondisk_sb) || not_data_block (fs, block)) {
die ("\nBad root block %lu. (--rebuild-tree did not complete)\n", block);
}
while (1) {
problem = 0;
while ( 1 ) {
problem = 0;
if (path[h])
die("pass_through_tree: empty slot expected");
if (h)
print(cur[h - 1], total[h - 1]);
if (path[h])
die ("pass_through_tree: empty slot expected");
if (h)
print (cur[h - 1], total[h - 1]);
if (fs->fs_badblocks_bm
&& reiserfs_bitmap_test_bit(fs->fs_badblocks_bm, block)) {
fsck_log
("%s: block %lu specified in badblock list found in tree, whole subtree skipped\n",
__FUNCTION__, block);
fsck_data(fs)->check.bad_nodes++;
one_more_corruption(fs, FATAL);
if (fs->fs_badblocks_bm && reiserfs_bitmap_test_bit (fs->fs_badblocks_bm, block)) {
fsck_log ("%s: block %lu specified in badblock list found in tree, whole subtree skipped\n",
__FUNCTION__, block);
fsck_data (fs)->check.bad_nodes++;
one_more_corruption (fs, FATAL);
if (h == 0) {
brelse(path[h]);
path[h] = 0;
break;
}
problem = 1;
} else {
if (h == 0) {
brelse (path[h]);
path[h] = 0;
break;
}
problem = 1;
} else {
spinner_touch(&spinner);
path[h] = bread(fs->fs_dev, block, fs->fs_blocksize);
if (path[h] == 0)
/* FIXME: handle case when read failed */
die("pass_through_tree: unable to read %lu block on device 0x%x\n", block, fs->fs_dev);
spinner_touch(&spinner);
path[h] = bread (fs->fs_dev, block, fs->fs_blocksize);
if (path[h] == 0)
/* FIXME: handle case when read failed */
die ("pass_through_tree: unable to read %lu block on device 0x%x\n",
block, fs->fs_dev);
if (action1)
if ((problem = action1(fs, path, h))) {
fsck_log
(" the problem in the internal node occured (%lu), whole subtree is skipped\n",
path[h]->b_blocknr);
fsck_data(fs)->check.bad_nodes++;
if (action1)
if ((problem = action1 (fs, path, h))) {
fsck_log (" the problem in the internal node occured (%lu), whole subtree is skipped\n",
path[h]->b_blocknr);
fsck_data (fs)->check.bad_nodes++;
if (h == 0) {
brelse (path[h]);
path[h] = 0;
break;
}
if (h == 0) {
brelse(path[h]);
path[h] = 0;
break;
}
}
}
/* Time to stop. */
if (h == depth)
problem++;
if (problem || is_leaf_node(path[h])) {
if (!problem && action2)
action2(fs, path, h);
brelse(path[h]);
if (h)
erase();
while (h && (cur[h - 1] == total[h - 1] || problem)) {
problem = 0;
path[h] = 0;
h--;
brelse(path[h]);
if (h)
erase();
}
if (h == 0) {
path[h] = 0;
break;
}
block = get_child(cur[h - 1], path[h - 1]);
cur[h - 1]++;
path[h] = 0;
continue;
}
total[h] = B_NR_ITEMS(path[h]) + 1;
cur[h] = 1;
block = first_child(path[h]);
h++;
}
/* Time to stop. */
if (h == depth)
problem ++;
if (problem || is_leaf_node (path[h])) {
if (!problem && action2)
action2 (fs, path, h);
brelse (path[h]);
if (h)
erase ();
while (h && (cur[h-1] == total[h-1] || problem)) {
problem = 0;
path[h] = 0;
h --;
brelse (path[h]);
if (h)
erase ();
}
if (h == 0) {
path[h] = 0;
break;
}
block = get_child (cur[h - 1], path[h-1]);
cur[h - 1] ++;
path[h] = 0;
continue;
}
total[h] = B_NR_ITEMS (path[h]) + 1;
cur[h] = 1;
block = first_child (path[h]);
h ++;
}
spinner_clear(&spinner);
spinner_clear(&spinner);
}