cleanup: rename key and item_head accessors to more friendly names
This patch does a quick search and replace: B_N_PITEM_HEAD() -> item_head() B_N_PDELIM_KEY() -> internal_key() B_N_PKEY() -> leaf_key() B_N_PITEM() -> item_body() And the item_head version: B_I_PITEM() -> ih_item_body() I_ENTRY_COUNT() -> ih_entry_count() And the treepath variants: get_ih() -> tp_item_head() PATH_PITEM_HEAD() -> tp_item_head() get_item() -> tp_item_body() ... which makes the code much easier on the eyes. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
This commit is contained in:
1 parent
290bb8c378
commit
c1ff1d5d2d
28 files changed
+354
-355
No files matched your search
+23
-23
@@ -362,7 +362,7 @@ static int bad_stat_data(reiserfs_filsys_t *fs,
|
||||
return 0;
|
||||
/* Check this on semantic_check pass.
|
||||
|
||||
sd = (struct stat_data *)B_I_PITEM(bh,ih);
|
||||
sd = (struct stat_data *)ih_item_body(bh,ih);
|
||||
get_sd_nlink (ih, sd, &links);
|
||||
if (S_ISDIR(sd->sd_mode)) {
|
||||
if (links < 2) {
|
||||
@@ -403,7 +403,7 @@ static int bad_badblocks_item(reiserfs_filsys_t *fs, struct buffer_head *bh,
|
||||
struct item_head *ih)
|
||||
{
|
||||
__u32 i;
|
||||
__u32 *ind = (__u32 *) B_I_PITEM(bh, ih);
|
||||
__u32 *ind = (__u32 *) ih_item_body(bh, ih);
|
||||
|
||||
if (get_ih_item_len(ih) % 4) {
|
||||
fsck_log("%s: block %lu: item (%H) has bad length\n",
|
||||
@@ -477,7 +477,7 @@ static int bad_badblocks_item(reiserfs_filsys_t *fs, struct buffer_head *bh,
|
||||
static int bad_indirect_item(reiserfs_filsys_t *fs, struct buffer_head *bh,
|
||||
struct item_head *ih)
|
||||
{
|
||||
__u32 *ind = (__u32 *) B_I_PITEM(bh, ih);
|
||||
__u32 *ind = (__u32 *) ih_item_body(bh, ih);
|
||||
unsigned int i;
|
||||
|
||||
if (get_ih_item_len(ih) % 4) {
|
||||
@@ -585,7 +585,7 @@ static int bad_directory_item(reiserfs_filsys_t *fs,
|
||||
}
|
||||
|
||||
/* check name hashing */
|
||||
prev_name = B_I_PITEM(bh, ih) + get_ih_item_len(ih);
|
||||
prev_name = ih_item_body(bh, ih) + get_ih_item_len(ih);
|
||||
prev_off = 0;
|
||||
|
||||
for (i = 0; i < count; i++, deh++) {
|
||||
@@ -648,7 +648,7 @@ static int bad_item(reiserfs_filsys_t *fs, struct buffer_head *bh, int num)
|
||||
struct item_head *ih;
|
||||
int format;
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, num);
|
||||
ih = item_head(bh, num);
|
||||
|
||||
if ((get_ih_flags(ih)) != 0) {
|
||||
if (fsck_mode(fs) != FSCK_FIX_FIXABLE) {
|
||||
@@ -755,7 +755,7 @@ int bad_pair(reiserfs_filsys_t *fs, struct buffer_head *bh, int pos)
|
||||
{
|
||||
struct item_head *ih;
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, pos);
|
||||
ih = item_head(bh, pos);
|
||||
|
||||
if (comp_keys(&((ih - 1)->ih_key), &ih->ih_key) != -1) {
|
||||
if (fsck_mode(fs) != FSCK_REBUILD)
|
||||
@@ -841,15 +841,15 @@ static int bad_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
||||
if (bad_item(fs, bh, i)) {
|
||||
fsck_log
|
||||
("bad_leaf: block %lu, item %d: The corrupted item found "
|
||||
"(%H)\n", bh->b_blocknr, i, B_N_PITEM_HEAD(bh, i));
|
||||
"(%H)\n", bh->b_blocknr, i, item_head(bh, i));
|
||||
}
|
||||
|
||||
if (i && bad_pair(fs, bh, i)) {
|
||||
fsck_log
|
||||
("bad_leaf: block %lu, items %d and %d: The wrong order "
|
||||
"of items: %k, %k\n", bh->b_blocknr, i - 1, i,
|
||||
&B_N_PITEM_HEAD(bh, i - 1)->ih_key,
|
||||
&B_N_PITEM_HEAD(bh, i)->ih_key);
|
||||
&item_head(bh, i - 1)->ih_key,
|
||||
&item_head(bh, i)->ih_key);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -863,13 +863,13 @@ static int bad_internal(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
||||
for (i = 0; i <= B_NR_ITEMS(bh); i++) {
|
||||
if (i != B_NR_ITEMS(bh) && i != B_NR_ITEMS(bh) - 1)
|
||||
/* make sure that keys are in increasing order */
|
||||
if (comp_keys(B_N_PDELIM_KEY(bh, i),
|
||||
B_N_PDELIM_KEY(bh, i + 1)) != -1) {
|
||||
if (comp_keys(internal_key(bh, i),
|
||||
internal_key(bh, i + 1)) != -1) {
|
||||
fsck_log
|
||||
("%s: vpf-10320: block %lu, items %d and %d: The "
|
||||
"wrong order of items: %k, %k\n",
|
||||
__FUNCTION__, bh->b_blocknr, i, i + 1,
|
||||
B_N_PDELIM_KEY(bh, i), B_N_PDELIM_KEY(bh,
|
||||
internal_key(bh, i), internal_key(bh,
|
||||
i +
|
||||
1));
|
||||
|
||||
@@ -931,7 +931,7 @@ int internal_remove(struct buffer_head *bh, int pos)
|
||||
delete = (char *)B_N_CHILD(bh, pos + 2);
|
||||
memmove(delete - DC_SIZE, delete, bh->b_size - (delete - bh->b_data));
|
||||
|
||||
delete = (char *)B_N_PDELIM_KEY(bh, pos + 1);
|
||||
delete = (char *)internal_key(bh, pos + 1);
|
||||
memmove(delete - KEY_SIZE, delete, bh->b_size - (delete - bh->b_data));
|
||||
|
||||
nr = B_NR_ITEMS(bh) - 1;
|
||||
@@ -956,7 +956,7 @@ int leaf_fix_key_oid(struct buffer_head *bh, int pos, __u32 oid)
|
||||
if (B_NR_ITEMS(bh) < pos)
|
||||
return -1;
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, pos);
|
||||
ih = item_head(bh, pos);
|
||||
set_key_objectid(&ih->ih_key, oid);
|
||||
|
||||
mark_buffer_dirty(bh);
|
||||
@@ -1027,7 +1027,7 @@ static struct reiserfs_key *lkey(struct buffer_head **path, int h)
|
||||
while (h > 0) {
|
||||
pos = get_pos(path[h - 1], path[h]->b_blocknr);
|
||||
if (pos)
|
||||
return B_N_PDELIM_KEY(path[h - 1], pos - 1);
|
||||
return internal_key(path[h - 1], pos - 1);
|
||||
h--;
|
||||
}
|
||||
return 0;
|
||||
@@ -1041,7 +1041,7 @@ static struct reiserfs_key *rkey(struct buffer_head **path, int h)
|
||||
while (h > 0) {
|
||||
pos = get_pos(path[h - 1], path[h]->b_blocknr);
|
||||
if (pos != B_NR_ITEMS(path[h - 1]))
|
||||
return B_N_PDELIM_KEY(path[h - 1], pos);
|
||||
return internal_key(path[h - 1], pos);
|
||||
h--;
|
||||
}
|
||||
return 0;
|
||||
@@ -1067,19 +1067,19 @@ static int bad_path(reiserfs_filsys_t *fs, struct buffer_head **path, int h1)
|
||||
pos = get_pos(path[h - 1], path[h]->b_blocknr);
|
||||
|
||||
dk = lkey(path, h);
|
||||
if (dk && comp_keys(dk, B_N_PKEY(path[h], 0))) {
|
||||
if (dk && comp_keys(dk, leaf_key(path[h], 0))) {
|
||||
/* left delimiting key must be equal to the key of 0-th item in the
|
||||
node */
|
||||
fsck_log
|
||||
("bad_path: The left delimiting key %k of the node (%lu) must "
|
||||
"be equal to the first element's key %k within the node.\n",
|
||||
dk, path[h]->b_blocknr, B_N_PKEY(path[h], 0));
|
||||
dk, path[h]->b_blocknr, leaf_key(path[h], 0));
|
||||
one_more_corruption(fs, FATAL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dk = rkey(path, h);
|
||||
if (dk && comp_keys(dk, B_N_PKEY(path[h],
|
||||
if (dk && comp_keys(dk, leaf_key(path[h],
|
||||
get_blkh_nr_items(B_BLK_HEAD(path[h]))
|
||||
- 1)) != 1) {
|
||||
/* right delimiting key must be gt the key of the last item in the node */
|
||||
@@ -1088,7 +1088,7 @@ static int bad_path(reiserfs_filsys_t *fs, struct buffer_head **path, int h1)
|
||||
"be greater than the last (%d) element's key %k within the node.\n",
|
||||
dk, path[h]->b_blocknr,
|
||||
get_blkh_nr_items(B_BLK_HEAD(path[h])) - 1,
|
||||
B_N_PKEY(path[h],
|
||||
leaf_key(path[h],
|
||||
get_blkh_nr_items(B_BLK_HEAD(path[h])) - 1));
|
||||
one_more_corruption(fs, FATAL);
|
||||
return 1;
|
||||
@@ -1199,9 +1199,9 @@ static int clean_attributes_handler(reiserfs_filsys_t *fs,
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < B_NR_ITEMS(bh); i++) {
|
||||
if (is_stat_data_ih(B_N_PITEM_HEAD(bh, i)) &&
|
||||
get_ih_item_len(B_N_PITEM_HEAD(bh, i)) == SD_SIZE) {
|
||||
set_sd_v2_sd_attrs((struct stat_data *)B_N_PITEM(bh, i),
|
||||
if (is_stat_data_ih(item_head(bh, i)) &&
|
||||
get_ih_item_len(item_head(bh, i)) == SD_SIZE) {
|
||||
set_sd_v2_sd_attrs((struct stat_data *)item_body(bh, i),
|
||||
0);
|
||||
mark_buffer_dirty(bh);
|
||||
}
|
||||
|
||||
+8
-8
@@ -64,7 +64,7 @@ static __u64 _look_for_lost(reiserfs_filsys_t *fs, int link_lost_dirs)
|
||||
if (!fsck_quiet(fs))
|
||||
print_how_fast(leaves++, 0, 50, 0);
|
||||
|
||||
for (ih = get_ih(&path);
|
||||
for (ih = tp_item_head(&path);
|
||||
item_pos < get_blkh_nr_items(B_BLK_HEAD(bh));
|
||||
item_pos++, ih++, PATH_LAST_POSITION(&path)++) {
|
||||
if (is_item_reachable(ih))
|
||||
@@ -100,11 +100,11 @@ static __u64 _look_for_lost(reiserfs_filsys_t *fs, int link_lost_dirs)
|
||||
}
|
||||
|
||||
/* stat data marked "not having name" found */
|
||||
if (is_stat_data_ih(get_ih(&path)))
|
||||
if (is_stat_data_ih(tp_item_head(&path)))
|
||||
fix_obviously_wrong_sd_mode(&path);
|
||||
|
||||
is_it_dir =
|
||||
((not_a_directory(B_I_PITEM(bh, ih))) ? 0 : 1);
|
||||
((not_a_directory(ih_item_body(bh, ih))) ? 0 : 1);
|
||||
|
||||
if (is_it_dir) {
|
||||
struct reiserfs_key tmp_key;
|
||||
@@ -117,7 +117,7 @@ static __u64 _look_for_lost(reiserfs_filsys_t *fs, int link_lost_dirs)
|
||||
0xffffffff, TYPE_DIRENTRY);
|
||||
reiserfs_search_by_key_4(fs, &tmp_key,
|
||||
&tmp_path);
|
||||
tmp_ih = get_ih(&tmp_path);
|
||||
tmp_ih = tp_item_head(&tmp_path);
|
||||
tmp_ih--;
|
||||
if (not_of_one_file(&tmp_key, tmp_ih))
|
||||
reiserfs_panic("not directory found");
|
||||
@@ -227,11 +227,11 @@ static __u64 _look_for_lost(reiserfs_filsys_t *fs, int link_lost_dirs)
|
||||
&obj_key);
|
||||
|
||||
/* check_regular_file does not mark stat data reachable */
|
||||
mark_item_reachable(get_ih(&path),
|
||||
mark_item_reachable(tp_item_head(&path),
|
||||
get_bh(&path));
|
||||
|
||||
rebuild_check_regular_file(&path,
|
||||
get_item
|
||||
tp_item_body
|
||||
(&path),
|
||||
0
|
||||
/*reloc_ih */
|
||||
@@ -399,8 +399,8 @@ void pass_3a_look_for_lost(reiserfs_filsys_t *fs)
|
||||
reiserfs_panic
|
||||
("look_for_lost: The StatData of the 'lost+found' directory %K could not be found",
|
||||
&lost_found_dir_key);
|
||||
ih = get_ih(&path);
|
||||
sd = get_item(&path);
|
||||
ih = tp_item_head(&path);
|
||||
sd = tp_item_body(&path);
|
||||
get_sd_size(ih, sd, &sd_size);
|
||||
size += sd_size;
|
||||
blocks = dir_size2st_blocks(size);
|
||||
|
||||
+18
-18
@@ -245,8 +245,8 @@ static int verify_directory_item(reiserfs_filsys_t *fs, struct buffer_head *bh,
|
||||
char *direntries;
|
||||
#endif
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, item_num);
|
||||
item = B_I_PITEM(bh, ih);
|
||||
ih = item_head(bh, item_num);
|
||||
item = ih_item_body(bh, ih);
|
||||
deh = (struct reiserfs_de_head *)item;
|
||||
|
||||
if ((get_ih_entry_count(ih) >
|
||||
@@ -690,12 +690,12 @@ static void pass0_correct_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
||||
|
||||
/* Delete all safe links. */
|
||||
for (i = get_blkh_nr_items(B_BLK_HEAD(bh)) - 1; i >= 0; i--) {
|
||||
if (get_key_dirid(&B_N_PITEM_HEAD(bh, i)->ih_key) == ~(__u32) 0) {
|
||||
if (get_key_dirid(&item_head(bh, i)->ih_key) == ~(__u32) 0) {
|
||||
delete_item(fs, bh, i);
|
||||
}
|
||||
if (get_key_dirid(&B_N_PITEM_HEAD(bh, i)->ih_key) ==
|
||||
if (get_key_dirid(&item_head(bh, i)->ih_key) ==
|
||||
BADBLOCK_DIRID
|
||||
&& get_key_objectid(&B_N_PITEM_HEAD(bh, i)->ih_key) ==
|
||||
&& get_key_objectid(&item_head(bh, i)->ih_key) ==
|
||||
BADBLOCK_OBJID) {
|
||||
delete_item(fs, bh, i);
|
||||
}
|
||||
@@ -706,7 +706,7 @@ static void pass0_correct_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
||||
|
||||
start_again:
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, 0);
|
||||
ih = item_head(bh, 0);
|
||||
for (i = 0; i < (nr_items = get_blkh_nr_items(B_BLK_HEAD(bh)));
|
||||
i++, ih++) {
|
||||
|
||||
@@ -1484,7 +1484,7 @@ start_again:
|
||||
|
||||
file_format = get_ih_key_format(ih);
|
||||
|
||||
get_sd_mode(ih, B_N_PITEM(bh, i), &mode);
|
||||
get_sd_mode(ih, item_body(bh, i), &mode);
|
||||
symlnk = (S_ISLNK(mode) ? 1 : 0);
|
||||
; /*correct_stat_data (fs, bh, i); */
|
||||
} else if (!is_direntry_ih(ih) &&
|
||||
@@ -1506,8 +1506,8 @@ start_again:
|
||||
&& !not_of_one_file(&ih->ih_key, &(ih - 1)->ih_key)) {
|
||||
__u16 mode;
|
||||
|
||||
get_sd_mode(ih - 1, B_I_PITEM(bh, ih - 1), &mode);
|
||||
if (not_a_directory(B_I_PITEM(bh, ih - 1))
|
||||
get_sd_mode(ih - 1, ih_item_body(bh, ih - 1), &mode);
|
||||
if (not_a_directory(ih_item_body(bh, ih - 1))
|
||||
&& is_direntry_ih(ih)) {
|
||||
/* make SD mode SD of dir */
|
||||
fsck_log
|
||||
@@ -1516,10 +1516,10 @@ start_again:
|
||||
mode &= ~S_IFMT;
|
||||
mode |= S_IFDIR;
|
||||
fsck_log("(%M)\n", mode);
|
||||
set_sd_mode(ih - 1, B_I_PITEM(bh, ih - 1),
|
||||
set_sd_mode(ih - 1, ih_item_body(bh, ih - 1),
|
||||
&mode);
|
||||
dirty = 1;
|
||||
} else if (!not_a_directory(B_I_PITEM(bh, ih - 1))
|
||||
} else if (!not_a_directory(ih_item_body(bh, ih - 1))
|
||||
&& !is_direntry_ih(ih)) {
|
||||
/* make SD mode SD of regular file */
|
||||
fsck_log
|
||||
@@ -1528,11 +1528,11 @@ start_again:
|
||||
mode &= ~S_IFMT;
|
||||
mode |= S_IFREG;
|
||||
fsck_log("(%M)\n", mode);
|
||||
set_sd_mode(ih - 1, B_I_PITEM(bh, ih - 1),
|
||||
set_sd_mode(ih - 1, ih_item_body(bh, ih - 1),
|
||||
&mode);
|
||||
dirty = 1;
|
||||
}
|
||||
if (not_a_regfile(B_I_PITEM(bh, ih - 1))
|
||||
if (not_a_regfile(ih_item_body(bh, ih - 1))
|
||||
&& is_indirect_ih(ih)) {
|
||||
fsck_log
|
||||
("pass0: block %lu, item %d: The file %K has the wrong mode (%M), corrected to ",
|
||||
@@ -1540,7 +1540,7 @@ start_again:
|
||||
mode &= ~S_IFMT;
|
||||
mode |= S_IFREG;
|
||||
fsck_log("(%M)\n", mode);
|
||||
set_sd_mode(ih - 1, B_I_PITEM(bh, ih - 1),
|
||||
set_sd_mode(ih - 1, ih_item_body(bh, ih - 1),
|
||||
&mode);
|
||||
dirty = 1;
|
||||
}
|
||||
@@ -1607,7 +1607,7 @@ start_again:
|
||||
}
|
||||
}
|
||||
*/
|
||||
ind_item = (__u32 *) B_I_PITEM(bh, ih);
|
||||
ind_item = (__u32 *) ih_item_body(bh, ih);
|
||||
for (j = 0; j < (int)I_UNFM_NUM(ih); j++) {
|
||||
unfm_ptr = d32_get(ind_item, j);
|
||||
if (!unfm_ptr)
|
||||
@@ -1645,7 +1645,7 @@ start_again:
|
||||
}
|
||||
|
||||
/* mark all objectids in use */
|
||||
ih = B_N_PITEM_HEAD(bh, 0);
|
||||
ih = item_head(bh, 0);
|
||||
for (i = 0; i < get_blkh_nr_items(B_BLK_HEAD(bh)); i++, ih++) {
|
||||
struct reiserfs_de_head *deh;
|
||||
|
||||
@@ -1816,8 +1816,8 @@ int is_leaf_bad(struct buffer_head *bh)
|
||||
|
||||
assert(is_leaf_node(bh));
|
||||
|
||||
for (i = 0, ih = B_N_PITEM_HEAD(bh, 0); i < B_NR_ITEMS(bh); i++, ih++) {
|
||||
if (is_bad_item(bh, ih, B_I_PITEM(bh, ih))) {
|
||||
for (i = 0, ih = item_head(bh, 0); i < B_NR_ITEMS(bh); i++, ih++) {
|
||||
if (is_bad_item(bh, ih, ih_item_body(bh, ih))) {
|
||||
fsck_log
|
||||
("is_leaf_bad: block %lu, item %d: The corrupted item found (%H)\n",
|
||||
bh->b_blocknr, i, ih);
|
||||
|
||||
+10
-10
@@ -68,7 +68,7 @@ static void stat_data_in_tree(struct buffer_head *bh, struct item_head *ih)
|
||||
}
|
||||
#endif
|
||||
|
||||
zero_nlink(ih, B_I_PITEM(bh, ih));
|
||||
zero_nlink(ih, ih_item_body(bh, ih));
|
||||
}
|
||||
|
||||
static char *still_bad_unfm_ptr_to_string(int val)
|
||||
@@ -97,7 +97,7 @@ static void indirect_in_tree(struct buffer_head *bh, struct item_head *ih)
|
||||
__u32 unfm_ptr;
|
||||
int ret;
|
||||
|
||||
unp = (__u32 *) B_I_PITEM(bh, ih);
|
||||
unp = (__u32 *) ih_item_body(bh, ih);
|
||||
|
||||
for (i = 0; i < I_UNFM_NUM(ih); i++) {
|
||||
unfm_ptr = d32_get(unp, i);
|
||||
@@ -168,8 +168,8 @@ int balance_condition_fails(struct buffer_head *left, struct buffer_head *right)
|
||||
{
|
||||
if (B_FREE_SPACE(left) >= B_CHILD_SIZE(right) -
|
||||
(are_items_mergeable
|
||||
(B_N_PITEM_HEAD(left, B_NR_ITEMS(left) - 1),
|
||||
B_N_PITEM_HEAD(right, 0), left->b_size) ? IH_SIZE : 0))
|
||||
(item_head(left, B_NR_ITEMS(left) - 1),
|
||||
item_head(right, 0), left->b_size) ? IH_SIZE : 0))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -219,7 +219,7 @@ int balance_condition_2_fails(struct buffer_head *new,
|
||||
|
||||
if (B_FREE_SPACE(new) >= used_space -
|
||||
(are_items_mergeable
|
||||
(B_N_PITEM_HEAD(new, B_NR_ITEMS(new) - 1),
|
||||
(item_head(new, B_NR_ITEMS(new) - 1),
|
||||
(struct item_head *)right_dkey, new->b_size) ? IH_SIZE : 0))
|
||||
return 1;
|
||||
|
||||
@@ -230,7 +230,7 @@ static void get_max_buffer_key(struct buffer_head *bh, struct reiserfs_key *key)
|
||||
{
|
||||
struct item_head *ih;
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, B_NR_ITEMS(bh) - 1);
|
||||
ih = item_head(bh, B_NR_ITEMS(bh) - 1);
|
||||
copy_key(key, &(ih->ih_key));
|
||||
|
||||
if (is_direntry_key(key)) {
|
||||
@@ -276,7 +276,7 @@ static void try_to_insert_pointer_to_leaf(struct buffer_head *new_bh)
|
||||
return;
|
||||
}
|
||||
|
||||
first_bh_key = B_N_PKEY(new_bh, 0);
|
||||
first_bh_key = leaf_key(new_bh, 0);
|
||||
|
||||
/* try to find place in the tree for the first key of the coming node */
|
||||
ret_value = reiserfs_search_by_key_4(fs, first_bh_key, &path);
|
||||
@@ -287,7 +287,7 @@ static void try_to_insert_pointer_to_leaf(struct buffer_head *new_bh)
|
||||
get_max_buffer_key(new_bh, &last_bh_key);
|
||||
|
||||
bh = PATH_PLAST_BUFFER(&path);
|
||||
if (comp_keys(B_N_PKEY(bh, 0), &last_bh_key) ==
|
||||
if (comp_keys(leaf_key(bh, 0), &last_bh_key) ==
|
||||
1 /* first is greater */ ) {
|
||||
/* new buffer falls before the leftmost leaf */
|
||||
if (balance_condition_fails(new_bh, bh))
|
||||
@@ -344,7 +344,7 @@ static void pass1_correct_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
||||
__u32 unfm_ptr;
|
||||
int dirty = 0;
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, 0);
|
||||
ih = item_head(bh, 0);
|
||||
for (i = 0; i < B_NR_ITEMS(bh); i++, ih++) {
|
||||
if (is_direntry_ih(ih)) {
|
||||
struct reiserfs_de_head *deh;
|
||||
@@ -419,7 +419,7 @@ static void pass1_correct_leaf(reiserfs_filsys_t *fs, struct buffer_head *bh)
|
||||
continue;
|
||||
|
||||
/* correct indirect items */
|
||||
ind_item = (__u32 *) B_I_PITEM(bh, ih);
|
||||
ind_item = (__u32 *) ih_item_body(bh, ih);
|
||||
|
||||
for (j = 0; j < I_UNFM_NUM(ih); j++) {
|
||||
unfm_ptr = d32_get(ind_item, j);
|
||||
|
||||
+19
-19
@@ -157,9 +157,9 @@ void save_item(struct si **head, struct item_head *ih, char *item,
|
||||
struct si *save_and_delete_file_item(struct si *si, struct reiserfs_path *path)
|
||||
{
|
||||
struct buffer_head *bh = PATH_PLAST_BUFFER(path);
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
|
||||
save_item(&si, ih, B_I_PITEM(bh, ih), bh->b_blocknr);
|
||||
save_item(&si, ih, ih_item_body(bh, ih), bh->b_blocknr);
|
||||
|
||||
/* delete item temporary - do not free unformatted nodes */
|
||||
reiserfsck_delete_item(path, 1 /*temporary */ );
|
||||
@@ -194,7 +194,7 @@ int should_relocate(struct item_head *ih)
|
||||
break;
|
||||
}
|
||||
|
||||
path_ih = get_ih(&path);
|
||||
path_ih = tp_item_head(&path);
|
||||
if (not_of_one_file(&key, &(path_ih->ih_key))) {
|
||||
/* there are no more item with this key */
|
||||
pathrelse(&path);
|
||||
@@ -219,7 +219,7 @@ int should_relocate(struct item_head *ih)
|
||||
|
||||
/* ok, item found, but make sure that it is not a directory one */
|
||||
if ((is_stat_data_ih(path_ih)
|
||||
&& !not_a_directory(get_item(&path)))
|
||||
&& !not_a_directory(tp_item_body(&path)))
|
||||
|| (is_direntry_ih(path_ih))) {
|
||||
/* item of directory found. so, we have to relocate the file */
|
||||
pathrelse(&path);
|
||||
@@ -245,12 +245,12 @@ static void overwrite_stat_data(struct item_head *new_ih,
|
||||
__u16 new_mode, old_mode;
|
||||
|
||||
get_sd_mode(new_ih, new_item, &new_mode);
|
||||
get_sd_mode(get_ih(path), get_item(path), &old_mode);
|
||||
get_sd_mode(tp_item_head(path), tp_item_body(path), &old_mode);
|
||||
|
||||
if (S_ISREG(new_mode) && !S_ISREG(old_mode)) {
|
||||
/* in tree we have not regular file - overwrite its stat data
|
||||
with stat data of regular file */
|
||||
memcpy(get_item(path), new_item, get_ih_item_len(get_ih(path)));
|
||||
memcpy(tp_item_body(path), new_item, get_ih_item_len(tp_item_head(path)));
|
||||
mark_buffer_dirty(get_bh(path));
|
||||
return;
|
||||
}
|
||||
@@ -263,13 +263,13 @@ static void overwrite_stat_data(struct item_head *new_ih,
|
||||
|
||||
/* if coming stat data has newer mtime - use that */
|
||||
if (stat_data_v1(new_ih)) {
|
||||
if (st_mtime_v1(new_item) > st_mtime_v1(get_item(path))) {
|
||||
memcpy(get_item(path), new_item, SD_V1_SIZE);
|
||||
if (st_mtime_v1(new_item) > st_mtime_v1(tp_item_body(path))) {
|
||||
memcpy(tp_item_body(path), new_item, SD_V1_SIZE);
|
||||
mark_buffer_dirty(get_bh(path));
|
||||
}
|
||||
} else {
|
||||
if (st_mtime_v2(new_item) > st_mtime_v2(get_item(path))) {
|
||||
memcpy(get_item(path), new_item, SD_SIZE);
|
||||
if (st_mtime_v2(new_item) > st_mtime_v2(tp_item_body(path))) {
|
||||
memcpy(tp_item_body(path), new_item, SD_SIZE);
|
||||
mark_buffer_dirty(get_bh(path));
|
||||
}
|
||||
}
|
||||
@@ -305,7 +305,7 @@ static void put_sd_into_tree(struct item_head *new_ih, char *new_item)
|
||||
if (reiserfs_search_by_key_4(fs, &(new_ih->ih_key), &path) ==
|
||||
ITEM_FOUND) {
|
||||
/* this stat data is found */
|
||||
if (get_ih_key_format(get_ih(&path)) !=
|
||||
if (get_ih_key_format(tp_item_head(&path)) !=
|
||||
get_ih_key_format(new_ih)) {
|
||||
/* in tree stat data and a new one are of different
|
||||
formats */
|
||||
@@ -317,13 +317,13 @@ static void put_sd_into_tree(struct item_head *new_ih, char *new_item)
|
||||
is of V2 */
|
||||
fsck_log
|
||||
("found newer in the tree, mode (%M), insersion was skipped.\n",
|
||||
st_mode(get_item(&path)));
|
||||
st_mode(tp_item_body(&path)));
|
||||
pathrelse(&path);
|
||||
} else {
|
||||
/* the stat data in the tree is sd_v1 */
|
||||
fsck_log
|
||||
("older sd, mode (%M), is replaced with it.\n",
|
||||
st_mode(get_item(&path)));
|
||||
st_mode(tp_item_body(&path)));
|
||||
reiserfsck_delete_item(&path,
|
||||
0 /*not temporary */ );
|
||||
|
||||
@@ -402,15 +402,15 @@ static void put_stat_data_items(struct buffer_head *bh)
|
||||
int i;
|
||||
struct item_head *ih;
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, 0);
|
||||
ih = item_head(bh, 0);
|
||||
for (i = 0; i < B_NR_ITEMS(bh); i++, ih++) {
|
||||
|
||||
/* this check instead of saved_items */
|
||||
if (!is_stat_data_ih(ih)
|
||||
|| is_bad_item(bh, ih, B_I_PITEM(bh, ih))) {
|
||||
|| is_bad_item(bh, ih, ih_item_body(bh, ih))) {
|
||||
continue;
|
||||
}
|
||||
insert_item_separately(ih, B_I_PITEM(bh, ih),
|
||||
insert_item_separately(ih, ih_item_body(bh, ih),
|
||||
0 /*was in tree */ );
|
||||
}
|
||||
}
|
||||
@@ -420,14 +420,14 @@ static void put_not_stat_data_items(struct buffer_head *bh)
|
||||
int i;
|
||||
struct item_head *ih;
|
||||
|
||||
ih = B_N_PITEM_HEAD(bh, 0);
|
||||
ih = item_head(bh, 0);
|
||||
for (i = 0; i < B_NR_ITEMS(bh); i++, ih++) {
|
||||
|
||||
if (is_stat_data_ih(ih)
|
||||
|| is_bad_item(bh, ih, B_I_PITEM(bh, ih))) {
|
||||
|| is_bad_item(bh, ih, ih_item_body(bh, ih))) {
|
||||
continue;
|
||||
}
|
||||
insert_item_separately(ih, B_I_PITEM(bh, ih),
|
||||
insert_item_separately(ih, ih_item_body(bh, ih),
|
||||
0 /*was in tree */ );
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ void pass_4_check_unaccessed_items(void)
|
||||
if (!fsck_quiet(fs))
|
||||
print_how_fast(items++, 0, 50, 0);
|
||||
|
||||
for (i = get_item_pos(&path), ih = get_ih(&path);
|
||||
for (i = get_item_pos(&path), ih = tp_item_head(&path);
|
||||
i < B_NR_ITEMS(bh); i++, ih++) {
|
||||
if (!is_item_reachable(ih)) {
|
||||
PATH_LAST_POSITION(&path) = i;
|
||||
|
||||
+19
-19
@@ -102,7 +102,7 @@ static int check_check_regular_file(struct reiserfs_path *path, void *sd,
|
||||
int retval = OK;
|
||||
__u32 tmp_position;
|
||||
|
||||
ih = get_ih(path);
|
||||
ih = tp_item_head(path);
|
||||
|
||||
if (new_ih) {
|
||||
/* this objectid is used already */
|
||||
@@ -119,8 +119,8 @@ static int check_check_regular_file(struct reiserfs_path *path, void *sd,
|
||||
("check_check_regular_file: Could not find a StatData of "
|
||||
"the relocated file %K", &new_ih->ih_key);
|
||||
/* stat data is marked unreachable again due to relocation, fix that */
|
||||
ih = get_ih(path);
|
||||
sd = get_item(path);
|
||||
ih = tp_item_head(path);
|
||||
sd = tp_item_body(path);
|
||||
}
|
||||
|
||||
if (get_ih_item_len(ih) == SD_SIZE)
|
||||
@@ -208,8 +208,8 @@ static int check_check_regular_file(struct reiserfs_path *path, void *sd,
|
||||
}
|
||||
|
||||
bh = get_bh(path);
|
||||
ih = get_ih(path);
|
||||
sd = get_item(path);
|
||||
ih = tp_item_head(path);
|
||||
sd = tp_item_body(path);
|
||||
set_sd_size(ih, sd, &real_size);
|
||||
set_sd_blocks(ih, sd, &blocks);
|
||||
set_sd_mode(ih, sd, &mode);
|
||||
@@ -252,7 +252,7 @@ start_again:
|
||||
/* leaf containing directory item */
|
||||
bh = PATH_PLAST_BUFFER(&path);
|
||||
*pos_in_item = path.pos_in_item;
|
||||
*ih = *get_ih(&path);
|
||||
*ih = *tp_item_head(&path);
|
||||
deh = B_I_DEH(bh, ih);
|
||||
|
||||
/* position was not found for '.' or there is no '..' */
|
||||
@@ -362,7 +362,7 @@ start_again:
|
||||
|
||||
/* copy directory item to the temporary buffer */
|
||||
dir_item = getmem(get_ih_item_len(ih));
|
||||
memcpy(dir_item, B_I_PITEM(bh, ih), get_ih_item_len(ih));
|
||||
memcpy(dir_item, ih_item_body(bh, ih), get_ih_item_len(ih));
|
||||
|
||||
/* next item key */
|
||||
if (PATH_LAST_POSITION(&path) == (B_NR_ITEMS(bh) - 1) &&
|
||||
@@ -374,7 +374,7 @@ start_again:
|
||||
}
|
||||
|
||||
if (fsck_mode(fs) == FSCK_REBUILD)
|
||||
mark_item_reachable(get_ih(&path), bh);
|
||||
mark_item_reachable(tp_item_head(&path), bh);
|
||||
pathrelse(&path);
|
||||
|
||||
return dir_item;
|
||||
@@ -424,8 +424,8 @@ static int check_semantic_pass(struct reiserfs_key *key,
|
||||
}
|
||||
|
||||
/* stat data has been found */
|
||||
ih = get_ih(&path);
|
||||
sd = get_item(&path);
|
||||
ih = tp_item_head(&path);
|
||||
sd = tp_item_body(&path);
|
||||
|
||||
get_sd_nlink(ih, sd, &nlink);
|
||||
|
||||
@@ -522,7 +522,7 @@ static int check_semantic_pass(struct reiserfs_key *key,
|
||||
get_sd_mode(ih, sd, &mode);
|
||||
|
||||
dir_format =
|
||||
(get_ih_item_len(get_ih(&path)) ==
|
||||
(get_ih_item_len(tp_item_head(&path)) ==
|
||||
SD_SIZE) ? KEY_FORMAT_2 : KEY_FORMAT_1;
|
||||
|
||||
/* release path pointing to stat data */
|
||||
@@ -673,7 +673,7 @@ static int check_semantic_pass(struct reiserfs_key *key,
|
||||
|
||||
tmp_deh =
|
||||
B_I_DEH(get_bh(&path),
|
||||
get_ih(&path)) +
|
||||
tp_item_head(&path)) +
|
||||
path.pos_in_item;
|
||||
fsck_log
|
||||
("The directory %K pointing to %K (\"%.*s\") updated to point "
|
||||
@@ -735,8 +735,8 @@ static int check_semantic_pass(struct reiserfs_key *key,
|
||||
}
|
||||
|
||||
bh = get_bh(&path);
|
||||
ih = get_ih(&path);
|
||||
sd = get_item(&path);
|
||||
ih = tp_item_head(&path);
|
||||
sd = tp_item_body(&path);
|
||||
|
||||
set_sd_size(ih, sd, &dir_size);
|
||||
set_sd_blocks(ih, sd, &blocks);
|
||||
@@ -770,7 +770,7 @@ int check_safe_links()
|
||||
break;
|
||||
}
|
||||
|
||||
tmp_ih = get_ih(&safe_link_path);
|
||||
tmp_ih = tp_item_head(&safe_link_path);
|
||||
|
||||
if (get_key_dirid(&tmp_ih->ih_key) != (__u32) - 1 ||
|
||||
get_key_objectid(&tmp_ih->ih_key) == (__u32) - 1) {
|
||||
@@ -784,7 +784,7 @@ int check_safe_links()
|
||||
get_ih_item_len(tmp_ih));
|
||||
|
||||
set_key_dirid(&key,
|
||||
d32_get((__u32 *) get_item(&safe_link_path), 0));
|
||||
d32_get((__u32 *) tp_item_body(&safe_link_path), 0));
|
||||
set_key_objectid(&key, get_key_objectid(&tmp_ih->ih_key));
|
||||
if ((rkey = reiserfs_next_key(&safe_link_path)) == NULL)
|
||||
set_key_dirid(&safe_link_key, 0);
|
||||
@@ -803,7 +803,7 @@ int check_safe_links()
|
||||
("Invalid safe link %k: cannot find the pointed object (%K) - "
|
||||
"safe link was deleted\n", &tmp_ih->ih_key,
|
||||
&key);
|
||||
d32_put((__u32 *) get_item(&safe_link_path), 0,
|
||||
d32_put((__u32 *) tp_item_body(&safe_link_path), 0,
|
||||
0);
|
||||
pathrelse(&path);
|
||||
reiserfsck_delete_item(&safe_link_path, 0);
|
||||
@@ -811,7 +811,7 @@ int check_safe_links()
|
||||
}
|
||||
} else if (get_offset(&tmp_ih->ih_key) == 0x1) {
|
||||
/* Truncate */
|
||||
if (!not_a_directory(get_item(&path))) {
|
||||
if (!not_a_directory(tp_item_body(&path))) {
|
||||
/*truncate on directory should not happen */
|
||||
/*sware on check, delete on fix-fixable */
|
||||
if (fsck_mode(fs) == FSCK_CHECK) {
|
||||
@@ -826,7 +826,7 @@ int check_safe_links()
|
||||
"a directory (%K) - safe link was deleted\n",
|
||||
&tmp_ih->ih_key, &key);
|
||||
d32_put((__u32 *)
|
||||
get_item(&safe_link_path), 0,
|
||||
tp_item_body(&safe_link_path), 0,
|
||||
0);
|
||||
pathrelse(&path);
|
||||
reiserfsck_delete_item(&safe_link_path,
|
||||
|
||||
+31
-31
@@ -349,10 +349,10 @@ void relocate_dir(struct item_head *ih, int change_ih)
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_stat_data_ih(get_ih(&path)))
|
||||
if (is_stat_data_ih(tp_item_head(&path)))
|
||||
fix_obviously_wrong_sd_mode(&path);
|
||||
|
||||
path_ih = get_ih(&path);
|
||||
path_ih = tp_item_head(&path);
|
||||
if (not_of_one_file(&key, &(path_ih->ih_key))) {
|
||||
/* there are no more item with this key */
|
||||
pathrelse(&path);
|
||||
@@ -361,7 +361,7 @@ void relocate_dir(struct item_head *ih, int change_ih)
|
||||
|
||||
/* ok, item found, but make sure that it is not a directory one */
|
||||
if ((is_stat_data_ih(path_ih)
|
||||
&& not_a_directory(get_item(&path)))
|
||||
&& not_a_directory(tp_item_body(&path)))
|
||||
|| is_direct_ih(path_ih) || is_indirect_ih(path_ih)) {
|
||||
/* item of not a directory found. Leave it in the
|
||||
tree. FIXME: should not happen */
|
||||
@@ -427,7 +427,7 @@ int rebuild_check_regular_file(struct reiserfs_path *path, void *sd,
|
||||
retval = OK;
|
||||
|
||||
/* stat data of a file */
|
||||
ih = get_ih(path);
|
||||
ih = tp_item_head(path);
|
||||
bh = get_bh(path);
|
||||
|
||||
if (new_ih) {
|
||||
@@ -444,10 +444,10 @@ int rebuild_check_regular_file(struct reiserfs_path *path, void *sd,
|
||||
("%s: Could not find the StatData of the relocated file %k",
|
||||
__FUNCTION__, &(new_ih->ih_key));
|
||||
/* stat data is marked unreachable again due to relocation, fix that */
|
||||
ih = get_ih(path);
|
||||
ih = tp_item_head(path);
|
||||
bh = get_bh(path);
|
||||
mark_item_reachable(ih, bh);
|
||||
sd = get_item(path);
|
||||
sd = tp_item_body(path);
|
||||
|
||||
}
|
||||
|
||||
@@ -526,8 +526,8 @@ int rebuild_check_regular_file(struct reiserfs_path *path, void *sd,
|
||||
__FUNCTION__, &sd_ih.ih_key);
|
||||
|
||||
bh = get_bh(path);
|
||||
ih = get_ih(path);
|
||||
sd = get_item(path);
|
||||
ih = tp_item_head(path);
|
||||
sd = tp_item_body(path);
|
||||
set_sd_size(ih, sd, &real_size);
|
||||
set_sd_blocks(ih, sd, &blocks);
|
||||
set_sd_mode(ih, sd, &mode);
|
||||
@@ -570,7 +570,7 @@ static char *get_next_directory_item(struct reiserfs_key *key, /* on return this
|
||||
/* leaf containing directory item */
|
||||
bh = PATH_PLAST_BUFFER(&path);
|
||||
*pos_in_item = path.pos_in_item;
|
||||
*ih = *get_ih(&path);
|
||||
*ih = *tp_item_head(&path);
|
||||
deh = B_I_DEH(bh, ih);
|
||||
|
||||
/* make sure, that ".." exists as well */
|
||||
@@ -634,7 +634,7 @@ static char *get_next_directory_item(struct reiserfs_key *key, /* on return this
|
||||
|
||||
/* copy directory item to the temporary buffer */
|
||||
dir_item = getmem(get_ih_item_len(ih));
|
||||
memcpy(dir_item, B_I_PITEM(bh, ih), get_ih_item_len(ih));
|
||||
memcpy(dir_item, ih_item_body(bh, ih), get_ih_item_len(ih));
|
||||
|
||||
/* next item key */
|
||||
if (PATH_LAST_POSITION(&path) == (B_NR_ITEMS(bh) - 1) &&
|
||||
@@ -646,7 +646,7 @@ static char *get_next_directory_item(struct reiserfs_key *key, /* on return this
|
||||
}
|
||||
|
||||
if (fsck_mode(fs) == FSCK_REBUILD)
|
||||
mark_item_reachable(get_ih(&path), bh);
|
||||
mark_item_reachable(tp_item_head(&path), bh);
|
||||
pathrelse(&path);
|
||||
|
||||
return dir_item;
|
||||
@@ -677,38 +677,38 @@ int fix_obviously_wrong_sd_mode(struct reiserfs_path *path)
|
||||
|
||||
next_key = reiserfs_next_key(path);
|
||||
|
||||
if (!next_key || not_of_one_file(next_key, &get_ih(path)->ih_key))
|
||||
if (!next_key || not_of_one_file(next_key, &tp_item_head(path)->ih_key))
|
||||
return 0;
|
||||
|
||||
/* next item exists and of the same file. Fix the SD mode */
|
||||
|
||||
if (not_a_directory(get_item(path)) && is_direntry_key(next_key)) {
|
||||
if (not_a_directory(tp_item_body(path)) && is_direntry_key(next_key)) {
|
||||
/* make SD mode SD of dir */
|
||||
get_sd_mode(get_ih(path), get_item(path), &mode);
|
||||
get_sd_mode(tp_item_head(path), tp_item_body(path), &mode);
|
||||
fsck_log("The directory %K had wrong mode %M",
|
||||
&get_ih(path)->ih_key, mode);
|
||||
&tp_item_head(path)->ih_key, mode);
|
||||
|
||||
if (fsck_mode(fs) != FSCK_CHECK) {
|
||||
mode &= ~S_IFMT;
|
||||
mode |= S_IFDIR;
|
||||
fsck_log(" - corrected to %M\n", mode);
|
||||
set_sd_mode(get_ih(path), get_item(path), &mode);
|
||||
set_sd_mode(tp_item_head(path), tp_item_body(path), &mode);
|
||||
mark_buffer_dirty(get_bh(path));
|
||||
} else {
|
||||
fsck_log("\n");
|
||||
retval = 1;
|
||||
}
|
||||
} else if (!not_a_directory(get_item(path))
|
||||
} else if (!not_a_directory(tp_item_body(path))
|
||||
&& !is_direntry_key(next_key)) {
|
||||
/* make SD mode SD of regular file */
|
||||
get_sd_mode(get_ih(path), get_item(path), &mode);
|
||||
fsck_log("The file %K had wrong mode %M", &get_ih(path)->ih_key,
|
||||
get_sd_mode(tp_item_head(path), tp_item_body(path), &mode);
|
||||
fsck_log("The file %K had wrong mode %M", &tp_item_head(path)->ih_key,
|
||||
mode);
|
||||
if (fsck_mode(fs) != FSCK_CHECK) {
|
||||
mode &= ~S_IFMT;
|
||||
mode |= S_IFREG;
|
||||
fsck_log(" - corrected to %M\n", mode);
|
||||
set_sd_mode(get_ih(path), get_item(path), &mode);
|
||||
set_sd_mode(tp_item_head(path), tp_item_body(path), &mode);
|
||||
mark_buffer_dirty(get_bh(path));
|
||||
} else {
|
||||
fsck_log("\n");
|
||||
@@ -769,8 +769,8 @@ start_again: /* when directory was relocated */
|
||||
|
||||
/* stat data has been found */
|
||||
bh = get_bh(&path);
|
||||
ih = get_ih(&path);
|
||||
sd = get_item(&path);
|
||||
ih = tp_item_head(&path);
|
||||
sd = tp_item_body(&path);
|
||||
|
||||
/* */
|
||||
get_sd_nlink(ih, sd, &nlink);
|
||||
@@ -877,7 +877,7 @@ start_again: /* when directory was relocated */
|
||||
*/
|
||||
|
||||
dir_format =
|
||||
(get_ih_item_len(get_ih(&path)) ==
|
||||
(get_ih_item_len(tp_item_head(&path)) ==
|
||||
SD_SIZE) ? KEY_FORMAT_2 : KEY_FORMAT_1;
|
||||
/* save stat data's size and st_blocks */
|
||||
get_sd_size(ih, sd, &saved_size);
|
||||
@@ -1005,7 +1005,7 @@ start_again: /* when directory was relocated */
|
||||
|
||||
tmp_deh =
|
||||
B_I_DEH(get_bh(&path),
|
||||
get_ih(&path)) +
|
||||
tp_item_head(&path)) +
|
||||
path.pos_in_item;
|
||||
fsck_log
|
||||
("The entry %K (\"%.*s\") in directory %K updated to point to ",
|
||||
@@ -1060,8 +1060,8 @@ start_again: /* when directory was relocated */
|
||||
key);
|
||||
|
||||
bh = get_bh(&path);
|
||||
ih = get_ih(&path);
|
||||
sd = get_item(&path);
|
||||
ih = tp_item_head(&path);
|
||||
sd = tp_item_body(&path);
|
||||
|
||||
set_sd_size(ih, sd, &dir_size);
|
||||
set_sd_blocks(ih, sd, &blocks);
|
||||
@@ -1164,7 +1164,7 @@ static void make_sure_lost_found_exists(reiserfs_filsys_t *fs)
|
||||
lost_found_dir_format =
|
||||
create_dir_sd(fs, &path, &lost_found_dir_key, modify_item);
|
||||
else {
|
||||
struct item_head *ih = get_ih(&path);
|
||||
struct item_head *ih = tp_item_head(&path);
|
||||
|
||||
if (!is_stat_data_ih(ih))
|
||||
reiserfs_panic("It must be lost+found's stat data %k\n",
|
||||
@@ -1172,7 +1172,7 @@ static void make_sure_lost_found_exists(reiserfs_filsys_t *fs)
|
||||
|
||||
fix_obviously_wrong_sd_mode(&path);
|
||||
|
||||
if (not_a_directory(get_item(&path))) {
|
||||
if (not_a_directory(tp_item_body(&path))) {
|
||||
fsck_progress
|
||||
("\"/lost+found\" exists, but it is not a directory, \
|
||||
lost files will not be linked\n");
|
||||
@@ -1182,7 +1182,7 @@ static void make_sure_lost_found_exists(reiserfs_filsys_t *fs)
|
||||
}
|
||||
|
||||
lost_found_dir_format =
|
||||
(get_ih_item_len(get_ih(&path)) ==
|
||||
(get_ih_item_len(tp_item_head(&path)) ==
|
||||
SD_SIZE) ? KEY_FORMAT_2 : KEY_FORMAT_1;
|
||||
|
||||
pathrelse(&path);
|
||||
@@ -1209,8 +1209,8 @@ static void make_sure_lost_found_exists(reiserfs_filsys_t *fs)
|
||||
__FUNCTION__);
|
||||
|
||||
bh = get_bh(&path);
|
||||
ih = get_ih(&path);
|
||||
sd = get_item(&path);
|
||||
ih = tp_item_head(&path);
|
||||
sd = tp_item_body(&path);
|
||||
|
||||
get_sd_size(ih, sd, &sd_size);
|
||||
sd_size += item_len;
|
||||
|
||||
+33
-33
@@ -35,7 +35,7 @@ static unsigned long indirect_to_direct(struct reiserfs_path *path, __u64 len,
|
||||
int symlink)
|
||||
{
|
||||
struct buffer_head *bh = PATH_PLAST_BUFFER(path);
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
__u32 unfm_ptr;
|
||||
struct buffer_head *unfm_bh = 0;
|
||||
struct item_head ins_ih;
|
||||
@@ -57,7 +57,7 @@ static unsigned long indirect_to_direct(struct reiserfs_path *path, __u64 len,
|
||||
TYPE_DIRECT);
|
||||
|
||||
// we do not know what length this item should be
|
||||
unfm_ptr = d32_get((__u32 *) get_item(path), I_UNFM_NUM(ih) - 1);
|
||||
unfm_ptr = d32_get((__u32 *) tp_item_body(path), I_UNFM_NUM(ih) - 1);
|
||||
if (unfm_ptr && (unfm_bh = bread(bh->b_dev, unfm_ptr, bh->b_size))) {
|
||||
/* we can read the block */
|
||||
buf = unfm_bh->b_data;
|
||||
@@ -137,10 +137,10 @@ int delete_N_items_after_key(struct reiserfs_key *start_key,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (is_stat_data_ih(get_ih(&path)))
|
||||
if (is_stat_data_ih(tp_item_head(&path)))
|
||||
fix_obviously_wrong_sd_mode(&path);
|
||||
|
||||
rkey = &(get_ih(&path))->ih_key;
|
||||
rkey = &(tp_item_head(&path))->ih_key;
|
||||
if (not_of_one_file(start_key, rkey)) {
|
||||
/* there are no more item with this key */
|
||||
pathrelse(&path);
|
||||
@@ -150,7 +150,7 @@ int delete_N_items_after_key(struct reiserfs_key *start_key,
|
||||
copy_key(start_key, rkey);
|
||||
/* ok, item found, but make sure that it is not a directory one */
|
||||
if ((is_stat_data_key(rkey)
|
||||
&& !not_a_directory(get_item(&path)))
|
||||
&& !not_a_directory(tp_item_body(&path)))
|
||||
|| (is_direntry_key(rkey))) {
|
||||
if (skip_dir_items) {
|
||||
/* item of directory found. Leave it in the tree */
|
||||
@@ -225,7 +225,7 @@ int are_file_items_correct(struct item_head *sd_ih, void *sd, __u64 * size,
|
||||
|
||||
switch (retval) {
|
||||
case POSITION_FOUND:
|
||||
/**/ ih = PATH_PITEM_HEAD(&path);
|
||||
/**/ ih = tp_item_head(&path);
|
||||
|
||||
if (ih_was_tail(ih)) {
|
||||
was_tail = 1;
|
||||
@@ -377,7 +377,7 @@ int are_file_items_correct(struct item_head *sd_ih, void *sd, __u64 * size,
|
||||
i++) {
|
||||
__u32 *ind =
|
||||
(__u32 *)
|
||||
get_item(&path);
|
||||
tp_item_body(&path);
|
||||
|
||||
if (d32_get(ind, i) !=
|
||||
0)
|
||||
@@ -414,7 +414,7 @@ int are_file_items_correct(struct item_head *sd_ih, void *sd, __u64 * size,
|
||||
pathrelse(&path);
|
||||
} else {
|
||||
__u32 *ind =
|
||||
(__u32 *) get_item(&path);
|
||||
(__u32 *) tp_item_body(&path);
|
||||
/* DEBUG message.
|
||||
fsck_log ("are_file_items_correct: The indirect item is converted back to direct %K\n", &ih->ih_key);
|
||||
*/
|
||||
@@ -592,9 +592,9 @@ void rewrite_file(struct item_head *ih, int should_relocate,
|
||||
static int make_file_writeable(struct buffer_head *bh, int pos)
|
||||
/* struct item_head * sd_ih, void * sd */
|
||||
{
|
||||
struct item_head *sd_ih = B_N_PITEM_HEAD(bh, pos);
|
||||
struct item_head *sd_ih = item_head(bh, pos);
|
||||
struct item_head sd_ih_copy;
|
||||
struct stat_data *sd = (struct stat_data *)B_N_PITEM(bh, pos);
|
||||
struct stat_data *sd = (struct stat_data *)item_body(bh, pos);
|
||||
struct stat_data sd_copy;
|
||||
__u64 size;
|
||||
__u32 blocks;
|
||||
@@ -738,12 +738,12 @@ static unsigned long block_to_start(struct reiserfs_path *path)
|
||||
__u32 blk;
|
||||
|
||||
bh = PATH_PLAST_BUFFER(path);
|
||||
ih = PATH_PITEM_HEAD(path);
|
||||
ih = tp_item_head(path);
|
||||
if (get_offset(&ih->ih_key) == 1 || PATH_LAST_POSITION(path) == 0)
|
||||
return bh->b_blocknr;
|
||||
|
||||
ih--;
|
||||
blk = d32_get((__u32 *) B_I_PITEM(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||
blk = d32_get((__u32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||
return (blk ? blk : bh->b_blocknr);
|
||||
}
|
||||
|
||||
@@ -756,7 +756,7 @@ static void direct2indirect2(unsigned long unfm, struct reiserfs_path *path)
|
||||
int copied = 0;
|
||||
int file_format;
|
||||
|
||||
ih = PATH_PITEM_HEAD(path);
|
||||
ih = tp_item_head(path);
|
||||
copy_key(&key, &(ih->ih_key));
|
||||
|
||||
file_format = key_format(&key);
|
||||
@@ -777,12 +777,12 @@ static void direct2indirect2(unsigned long unfm, struct reiserfs_path *path)
|
||||
do {
|
||||
__u64 len;
|
||||
|
||||
ih = PATH_PITEM_HEAD(path);
|
||||
ih = tp_item_head(path);
|
||||
|
||||
len = get_bytes_number(ih, fs->fs_blocksize);
|
||||
|
||||
memcpy(unbh->b_data + copied,
|
||||
B_I_PITEM(PATH_PLAST_BUFFER(path), ih), len);
|
||||
ih_item_body(PATH_PLAST_BUFFER(path), ih), len);
|
||||
|
||||
// save_unfm_overwriting (unbh->b_blocknr, ih);
|
||||
copied += len;
|
||||
@@ -813,7 +813,7 @@ static void direct2indirect2(unsigned long unfm, struct reiserfs_path *path)
|
||||
mark_ih_was_tail(&insih);
|
||||
reiserfsck_insert_item(path, &insih, (const char *)&(ni));
|
||||
} else {
|
||||
ih = PATH_PITEM_HEAD(path);
|
||||
ih = tp_item_head(path);
|
||||
|
||||
if (!is_indirect_ih(ih))
|
||||
reiserfs_panic
|
||||
@@ -837,7 +837,7 @@ static void direct2indirect2(unsigned long unfm, struct reiserfs_path *path)
|
||||
brelse(unbh);
|
||||
|
||||
if (usearch_by_position(fs, &key, file_format, path) != POSITION_FOUND
|
||||
|| !is_indirect_ih(PATH_PITEM_HEAD(path)))
|
||||
|| !is_indirect_ih(tp_item_head(path)))
|
||||
reiserfs_panic
|
||||
("direct2indirect: The data %k, which are supposed to be converted, are not found",
|
||||
&key);
|
||||
@@ -856,7 +856,7 @@ static int append_to_unformatted_node(struct item_head *comingih,
|
||||
int zero_number;
|
||||
|
||||
bh = PATH_PLAST_BUFFER(path);
|
||||
unfm_ptr = d32_get((__u32 *) B_I_PITEM(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||
unfm_ptr = d32_get((__u32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||
|
||||
/* append to free space of the last unformatted node of indirect item ih */
|
||||
free_space =
|
||||
@@ -896,7 +896,7 @@ static int append_to_unformatted_node(struct item_head *comingih,
|
||||
/*if (unfm_ptr == 0 || unfm_ptr >= SB_BLOCK_COUNT (fs)) { */
|
||||
unbh = reiserfsck_get_new_buffer(bh->b_blocknr);
|
||||
memset(unbh->b_data, 0, unbh->b_size);
|
||||
d32_put((__u32 *) B_I_PITEM(bh, ih), I_UNFM_NUM(ih) - 1,
|
||||
d32_put((__u32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1,
|
||||
unbh->b_blocknr);
|
||||
/*mark_block_unformatted (unbh->b_blocknr); */
|
||||
mark_buffer_dirty(bh);
|
||||
@@ -927,7 +927,7 @@ int reiserfsck_append_file(struct item_head *comingih, char *item, int pos,
|
||||
__u32 *ni;
|
||||
struct buffer_head *unbh;
|
||||
int retval;
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
__u32 bytes_number;
|
||||
int i, count = 0;
|
||||
|
||||
@@ -1002,11 +1002,11 @@ int reiserfsck_append_file(struct item_head *comingih, char *item, int pos,
|
||||
long long int must_there_be_a_hole(struct item_head *comingih,
|
||||
struct reiserfs_path *path)
|
||||
{
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
|
||||
if (is_direct_ih(ih)) {
|
||||
direct2indirect2(0, path);
|
||||
ih = PATH_PITEM_HEAD(path);
|
||||
ih = tp_item_head(path);
|
||||
}
|
||||
|
||||
path->pos_in_item = I_UNFM_NUM(ih);
|
||||
@@ -1026,7 +1026,7 @@ int reiserfs_append_zero_unfm_ptr(struct reiserfs_path *path,
|
||||
__u32 *ni;
|
||||
long long int count;
|
||||
|
||||
if (is_direct_ih(PATH_PITEM_HEAD(path)))
|
||||
if (is_direct_ih(tp_item_head(path)))
|
||||
/* convert direct item to indirect */
|
||||
direct2indirect2(0, path);
|
||||
|
||||
@@ -1055,9 +1055,9 @@ static int overwrite_by_direct_item(struct item_head *comingih, char *item,
|
||||
__u64 coming_len = get_bytes_number(comingih, fs->fs_blocksize);
|
||||
|
||||
bh = PATH_PLAST_BUFFER(path);
|
||||
ih = PATH_PITEM_HEAD(path);
|
||||
ih = tp_item_head(path);
|
||||
|
||||
unfm_ptr = d32_get((__u32 *) B_I_PITEM(bh, ih), path->pos_in_item);
|
||||
unfm_ptr = d32_get((__u32 *) ih_item_body(bh, ih), path->pos_in_item);
|
||||
unbh = 0;
|
||||
|
||||
if (unfm_ptr != 0 && unfm_ptr < get_sb_block_count(fs->fs_ondisk_sb)) {
|
||||
@@ -1070,7 +1070,7 @@ static int overwrite_by_direct_item(struct item_head *comingih, char *item,
|
||||
if (unfm_ptr == 0 || unfm_ptr >= get_sb_block_count(fs->fs_ondisk_sb)) {
|
||||
if ((unbh = reiserfsck_get_new_buffer(bh->b_blocknr)) != NULL) {
|
||||
memset(unbh->b_data, 0, unbh->b_size);
|
||||
d32_put((__u32 *) B_I_PITEM(bh, ih), path->pos_in_item,
|
||||
d32_put((__u32 *) ih_item_body(bh, ih), path->pos_in_item,
|
||||
unbh->b_blocknr);
|
||||
mark_buffer_dirty(bh);
|
||||
} else {
|
||||
@@ -1156,12 +1156,12 @@ static int overwrite_by_indirect_item(struct item_head *comingih,
|
||||
int *pos_in_coming_item)
|
||||
{
|
||||
struct buffer_head *bh = PATH_PLAST_BUFFER(path);
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
int written;
|
||||
__u32 *item_in_tree;
|
||||
int src_unfm_ptrs, dest_unfm_ptrs, to_copy, i, dirty = 0;
|
||||
|
||||
item_in_tree = (__u32 *) B_I_PITEM(bh, ih) + path->pos_in_item;
|
||||
item_in_tree = (__u32 *) ih_item_body(bh, ih) + path->pos_in_item;
|
||||
coming_item += *pos_in_coming_item;
|
||||
|
||||
dest_unfm_ptrs = I_UNFM_NUM(ih) - path->pos_in_item;
|
||||
@@ -1207,7 +1207,7 @@ static int reiserfsck_overwrite_file(struct item_head *comingih, char *item,
|
||||
{
|
||||
__u32 unfm_ptr;
|
||||
int written = 0;
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
|
||||
if (not_of_one_file(ih, &(comingih->ih_key)))
|
||||
reiserfs_panic
|
||||
@@ -1278,8 +1278,8 @@ check_again:
|
||||
}
|
||||
|
||||
/*SD found */
|
||||
file_format = get_ih_key_format(get_ih(&path));
|
||||
get_sd_mode(get_ih(&path), get_item(&path), &mode);
|
||||
file_format = get_ih_key_format(tp_item_head(&path));
|
||||
get_sd_mode(tp_item_head(&path), tp_item_body(&path), &mode);
|
||||
|
||||
if (file_format != get_ih_key_format(ih)) {
|
||||
/* Not for symlinks and not for items which should be relocted. */
|
||||
@@ -1332,7 +1332,7 @@ check_again:
|
||||
there is no item between wamted offset and SD, insert first item */
|
||||
if (retval == POSITION_NOT_FOUND &&
|
||||
(PATH_LAST_POSITION(&path) >= B_NR_ITEMS(get_bh(&path)) ||
|
||||
get_offset(&get_ih(&path)->ih_key) > get_offset(&key)))
|
||||
get_offset(&tp_item_head(&path)->ih_key) > get_offset(&key)))
|
||||
retval = FILE_NOT_FOUND;
|
||||
|
||||
if (retval == DIRECTORY_FOUND)
|
||||
@@ -1361,7 +1361,7 @@ check_again:
|
||||
if (retval == POSITION_NOT_FOUND) {
|
||||
|
||||
if (is_direct_ih(ih)) {
|
||||
mark_ih_was_tail(get_ih(&path));
|
||||
mark_ih_was_tail(tp_item_head(&path));
|
||||
mark_buffer_dirty(get_bh(&path));
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -40,7 +40,7 @@ void reiserfsck_insert_item(struct reiserfs_path *path, struct item_head *ih,
|
||||
|
||||
static void free_unformatted_nodes(struct item_head *ih, struct buffer_head *bh)
|
||||
{
|
||||
__u32 *punfm = (__u32 *) B_I_PITEM(bh, ih);
|
||||
__u32 *punfm = (__u32 *) ih_item_body(bh, ih);
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < I_UNFM_NUM(ih); i++) {
|
||||
@@ -64,7 +64,7 @@ static void free_unformatted_nodes(struct item_head *ih, struct buffer_head *bh)
|
||||
void reiserfsck_delete_item(struct reiserfs_path *path, int temporary)
|
||||
{
|
||||
struct tree_balance tb;
|
||||
struct item_head *ih = PATH_PITEM_HEAD(path);
|
||||
struct item_head *ih = tp_item_head(path);
|
||||
|
||||
if (is_indirect_ih(ih) && !temporary)
|
||||
free_unformatted_nodes(ih, PATH_PLAST_BUFFER(path));
|
||||
@@ -87,10 +87,10 @@ void reiserfsck_cut_from_item(struct reiserfs_path *path, int 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))) {
|
||||
if (is_indirect_ih(ih = tp_item_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);
|
||||
d32_get((__u32 *) ih_item_body(bh, ih), I_UNFM_NUM(ih) - 1);
|
||||
if (unfm_ptr != 0) {
|
||||
struct buffer_head *to_be_forgotten;
|
||||
|
||||
@@ -143,7 +143,7 @@ struct reiserfs_key *uget_rkey (struct reiserfs_path *path)
|
||||
|
||||
// Return delimiting key if position in the parent is not the last one.
|
||||
if (pos != B_NR_ITEMS (bh))
|
||||
return B_N_PDELIM_KEY(bh, pos);
|
||||
return internal_key(bh, pos);
|
||||
}
|
||||
|
||||
// there is no right delimiting key
|
||||
|
||||
Reference in new issue
Block a user