5 #include <linux/time.h>
22 static void sd_decrement_key(
struct cpu_key *
key)
26 set_cpu_key_k_offset(key, (loff_t)(~0ULL >> 1));
29 static int sd_is_left_mergeable(
struct reiserfs_key *key,
unsigned long bsize)
34 static char *print_time(
time_t t)
36 static char timebuf[256];
44 printk(
"\tmode | size | nlinks | first direct | mtime\n");
61 static void sd_check_item(
struct item_head *ih,
char *item)
68 int is_affected,
int insert_size)
76 int start_skip,
int end_skip)
78 BUG_ON(start_skip || end_skip);
101 "STATDATA, index %d, type 0x%x, %h",
106 .bytes_number = sd_bytes_number,
107 .decrement_key = sd_decrement_key,
108 .is_left_mergeable = sd_is_left_mergeable,
109 .print_item = sd_print_item,
110 .check_item = sd_check_item,
112 .create_vi = sd_create_vi,
113 .check_left = sd_check_left,
114 .check_right = sd_check_right,
115 .part_size = sd_part_size,
116 .unit_num = sd_unit_num,
117 .print_vi = sd_print_vi
129 static void direct_decrement_key(
struct cpu_key *key)
131 cpu_key_k_offset_dec(key);
132 if (cpu_key_k_offset(key) == 0)
136 static int direct_is_left_mergeable(
struct reiserfs_key *key,
139 int version = le_key_version(key);
140 return ((le_key_k_offset(version, key) & (bsize - 1)) != 1);
143 static void direct_print_item(
struct item_head *ih,
char *item)
154 static void direct_check_item(
struct item_head *ih,
char *item)
161 int is_affected,
int insert_size)
169 int start_skip,
int end_skip)
173 bytes = free - free % 8;
179 return direct_check_left(vi, free, 0, 0);
195 "DIRECT, index %d, type 0x%x, %h",
200 .bytes_number = direct_bytes_number,
201 .decrement_key = direct_decrement_key,
202 .is_left_mergeable = direct_is_left_mergeable,
203 .print_item = direct_print_item,
204 .check_item = direct_check_item,
206 .create_vi = direct_create_vi,
207 .check_left = direct_check_left,
208 .check_right = direct_check_right,
209 .part_size = direct_part_size,
210 .unit_num = direct_unit_num,
211 .print_vi = direct_print_vi
224 static void indirect_decrement_key(
struct cpu_key *key)
226 cpu_key_k_offset_dec(key);
227 if (cpu_key_k_offset(key) == 0)
232 static int indirect_is_left_mergeable(
struct reiserfs_key *key,
235 int version = le_key_version(key);
236 return (le_key_k_offset(version, key) != 1);
251 if (start == 0 &&
new == 0) {
255 if (start != 0 && (start + *len) ==
new) {
262 static void print_sequence(
__u32 start,
int len)
270 printk(
" %d(%d)", start, len);
273 static void indirect_print_item(
struct item_head *ih,
char *item)
288 print_sequence(prev, num);
292 print_sequence(prev, num);
296 static void indirect_check_item(
struct item_head *ih,
char *item)
303 int is_affected,
int insert_size)
311 int start_skip,
int end_skip)
321 return indirect_check_left(vi, free, 0, 0);
340 "INDIRECT, index %d, type 0x%x, %h",
345 .bytes_number = indirect_bytes_number,
346 .decrement_key = indirect_decrement_key,
347 .is_left_mergeable = indirect_is_left_mergeable,
348 .print_item = indirect_print_item,
349 .check_item = indirect_check_item,
351 .create_vi = indirect_create_vi,
352 .check_left = indirect_check_left,
353 .check_right = indirect_check_right,
354 .part_size = indirect_part_size,
355 .unit_num = indirect_unit_num,
356 .print_vi = indirect_print_vi
366 "bytes number is asked for direntry");
370 static void direntry_decrement_key(
struct cpu_key *key)
372 cpu_key_k_offset_dec(key);
373 if (cpu_key_k_offset(key) == 0)
377 static int direntry_is_left_mergeable(
struct reiserfs_key *key,
386 static void direntry_print_item(
struct item_head *ih,
char *item)
392 static char namebuf[80];
394 printk(
"\n # %-15s%-30s%-15s%-15s%-15s\n",
"Name",
395 "Key of pointed object",
"Hash",
"Gen number",
"Status");
404 if (name[namelen - 1] == 0)
407 if (namelen >
sizeof(namebuf) - 3) {
408 strncpy(namebuf + 1, name,
sizeof(namebuf) - 3);
409 namebuf[
sizeof(namebuf) - 2] =
'"';
410 namebuf[
sizeof(namebuf) - 1] = 0;
412 memcpy(namebuf + 1, name, namelen);
413 namebuf[namelen + 1] =
'"';
414 namebuf[namelen + 2] = 0;
417 printk(
"%d: %-15s%-15d%-15d%-15Ld%-15Ld(%s)\n",
422 (
de_hidden(deh)) ?
"HIDDEN" :
"VISIBLE");
426 static void direntry_check_item(
struct item_head *ih,
char *item)
438 #define DIRENTRY_VI_FIRST_DIRENTRY_ITEM 1
443 static inline int old_entry_num(
int is_affected,
int virtual_entry_num,
447 return virtual_entry_num;
451 return virtual_entry_num;
453 if (virtual_entry_num < pos_in_item)
454 return virtual_entry_num;
457 return virtual_entry_num + 1;
460 "vs-8015: old_entry_num: mode must be M_PASTE (mode = \'%c\'",
463 return virtual_entry_num - 1;
471 int is_affected,
int insert_size)
507 #ifdef CONFIG_REISERFS_CHECK
521 "insert_size==%d), invalid length of "
537 int start_skip,
int end_skip)
543 for (i = start_skip; i < dir_u->
entry_count - end_skip; i++) {
554 "free space %d, entry_count %d", free,
563 return entries ? : -1;
566 static int direntry_check_right(
struct virtual_item *vi,
int free)
587 return entries ? : -1;
602 to = from + count - 1;
604 for (i = from; i <= to; i++)
623 "DIRENTRY, index %d, type 0x%x, %h, flags 0x%x",
632 .bytes_number = direntry_bytes_number,
633 .decrement_key = direntry_decrement_key,
634 .is_left_mergeable = direntry_is_left_mergeable,
635 .print_item = direntry_print_item,
636 .check_item = direntry_check_item,
638 .create_vi = direntry_create_vi,
639 .check_left = direntry_check_left,
640 .check_right = direntry_check_right,
641 .part_size = direntry_part_size,
642 .unit_num = direntry_unit_num,
643 .print_vi = direntry_print_vi
652 "Invalid item type observed, run fsck ASAP");
656 static void errcatch_decrement_key(
struct cpu_key *key)
659 "Invalid item type observed, run fsck ASAP");
662 static int errcatch_is_left_mergeable(
struct reiserfs_key *key,
666 "Invalid item type observed, run fsck ASAP");
670 static void errcatch_print_item(
struct item_head *ih,
char *item)
673 "Invalid item type observed, run fsck ASAP");
676 static void errcatch_check_item(
struct item_head *ih,
char *item)
679 "Invalid item type observed, run fsck ASAP");
684 int is_affected,
int insert_size)
687 "Invalid item type observed, run fsck ASAP");
692 static int errcatch_check_left(
struct virtual_item *vi,
int free,
693 int start_skip,
int end_skip)
696 "Invalid item type observed, run fsck ASAP");
700 static int errcatch_check_right(
struct virtual_item *vi,
int free)
703 "Invalid item type observed, run fsck ASAP");
707 static int errcatch_part_size(
struct virtual_item *vi,
int first,
int count)
710 "Invalid item type observed, run fsck ASAP");
717 "Invalid item type observed, run fsck ASAP");
724 "Invalid item type observed, run fsck ASAP");
728 errcatch_bytes_number,
729 errcatch_decrement_key,
730 errcatch_is_left_mergeable,
736 errcatch_check_right,
745 #if ! (TYPE_STAT_DATA == 0 && TYPE_INDIRECT == 1 && TYPE_DIRECT == 2 && TYPE_DIRENTRY == 3)
746 #error Item types must use disk-format assigned values.
754 NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,