item_ops.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. /*
  2. * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
  3. */
  4. #include <linux/time.h>
  5. #include "reiserfs.h"
  6. /*
  7. * this contains item handlers for old item types: sd, direct,
  8. * indirect, directory
  9. */
  10. /*
  11. * and where are the comments? how about saying where we can find an
  12. * explanation of each item handler method? -Hans
  13. */
  14. /* stat data functions */
  15. static int sd_bytes_number(struct item_head *ih, int block_size)
  16. {
  17. return 0;
  18. }
  19. static void sd_decrement_key(struct cpu_key *key)
  20. {
  21. key->on_disk_key.k_objectid--;
  22. set_cpu_key_k_type(key, TYPE_ANY);
  23. set_cpu_key_k_offset(key, (loff_t)(~0ULL >> 1));
  24. }
  25. static int sd_is_left_mergeable(struct reiserfs_key *key, unsigned long bsize)
  26. {
  27. return 0;
  28. }
  29. static char *print_time(time_t t)
  30. {
  31. static char timebuf[256];
  32. sprintf(timebuf, "%ld", t);
  33. return timebuf;
  34. }
  35. static void sd_print_item(struct item_head *ih, char *item)
  36. {
  37. printk("\tmode | size | nlinks | first direct | mtime\n");
  38. if (stat_data_v1(ih)) {
  39. struct stat_data_v1 *sd = (struct stat_data_v1 *)item;
  40. printk("\t0%-6o | %6u | %2u | %d | %s\n", sd_v1_mode(sd),
  41. sd_v1_size(sd), sd_v1_nlink(sd),
  42. sd_v1_first_direct_byte(sd),
  43. print_time(sd_v1_mtime(sd)));
  44. } else {
  45. struct stat_data *sd = (struct stat_data *)item;
  46. printk("\t0%-6o | %6llu | %2u | %d | %s\n", sd_v2_mode(sd),
  47. (unsigned long long)sd_v2_size(sd), sd_v2_nlink(sd),
  48. sd_v2_rdev(sd), print_time(sd_v2_mtime(sd)));
  49. }
  50. }
  51. static void sd_check_item(struct item_head *ih, char *item)
  52. {
  53. /* unused */
  54. }
  55. static int sd_create_vi(struct virtual_node *vn,
  56. struct virtual_item *vi,
  57. int is_affected, int insert_size)
  58. {
  59. vi->vi_index = TYPE_STAT_DATA;
  60. return 0;
  61. }
  62. static int sd_check_left(struct virtual_item *vi, int free,
  63. int start_skip, int end_skip)
  64. {
  65. BUG_ON(start_skip || end_skip);
  66. return -1;
  67. }
  68. static int sd_check_right(struct virtual_item *vi, int free)
  69. {
  70. return -1;
  71. }
  72. static int sd_part_size(struct virtual_item *vi, int first, int count)
  73. {
  74. BUG_ON(count);
  75. return 0;
  76. }
  77. static int sd_unit_num(struct virtual_item *vi)
  78. {
  79. return vi->vi_item_len - IH_SIZE;
  80. }
  81. static void sd_print_vi(struct virtual_item *vi)
  82. {
  83. reiserfs_warning(NULL, "reiserfs-16100",
  84. "STATDATA, index %d, type 0x%x, %h",
  85. vi->vi_index, vi->vi_type, vi->vi_ih);
  86. }
  87. static struct item_operations stat_data_ops = {
  88. .bytes_number = sd_bytes_number,
  89. .decrement_key = sd_decrement_key,
  90. .is_left_mergeable = sd_is_left_mergeable,
  91. .print_item = sd_print_item,
  92. .check_item = sd_check_item,
  93. .create_vi = sd_create_vi,
  94. .check_left = sd_check_left,
  95. .check_right = sd_check_right,
  96. .part_size = sd_part_size,
  97. .unit_num = sd_unit_num,
  98. .print_vi = sd_print_vi
  99. };
  100. /* direct item functions */
  101. static int direct_bytes_number(struct item_head *ih, int block_size)
  102. {
  103. return ih_item_len(ih);
  104. }
  105. /* FIXME: this should probably switch to indirect as well */
  106. static void direct_decrement_key(struct cpu_key *key)
  107. {
  108. cpu_key_k_offset_dec(key);
  109. if (cpu_key_k_offset(key) == 0)
  110. set_cpu_key_k_type(key, TYPE_STAT_DATA);
  111. }
  112. static int direct_is_left_mergeable(struct reiserfs_key *key,
  113. unsigned long bsize)
  114. {
  115. int version = le_key_version(key);
  116. return ((le_key_k_offset(version, key) & (bsize - 1)) != 1);
  117. }
  118. static void direct_print_item(struct item_head *ih, char *item)
  119. {
  120. int j = 0;
  121. /* return; */
  122. printk("\"");
  123. while (j < ih_item_len(ih))
  124. printk("%c", item[j++]);
  125. printk("\"\n");
  126. }
  127. static void direct_check_item(struct item_head *ih, char *item)
  128. {
  129. /* unused */
  130. }
  131. static int direct_create_vi(struct virtual_node *vn,
  132. struct virtual_item *vi,
  133. int is_affected, int insert_size)
  134. {
  135. vi->vi_index = TYPE_DIRECT;
  136. return 0;
  137. }
  138. static int direct_check_left(struct virtual_item *vi, int free,
  139. int start_skip, int end_skip)
  140. {
  141. int bytes;
  142. bytes = free - free % 8;
  143. return bytes ? : -1;
  144. }
  145. static int direct_check_right(struct virtual_item *vi, int free)
  146. {
  147. return direct_check_left(vi, free, 0, 0);
  148. }
  149. static int direct_part_size(struct virtual_item *vi, int first, int count)
  150. {
  151. return count;
  152. }
  153. static int direct_unit_num(struct virtual_item *vi)
  154. {
  155. return vi->vi_item_len - IH_SIZE;
  156. }
  157. static void direct_print_vi(struct virtual_item *vi)
  158. {
  159. reiserfs_warning(NULL, "reiserfs-16101",
  160. "DIRECT, index %d, type 0x%x, %h",
  161. vi->vi_index, vi->vi_type, vi->vi_ih);
  162. }
  163. static struct item_operations direct_ops = {
  164. .bytes_number = direct_bytes_number,
  165. .decrement_key = direct_decrement_key,
  166. .is_left_mergeable = direct_is_left_mergeable,
  167. .print_item = direct_print_item,
  168. .check_item = direct_check_item,
  169. .create_vi = direct_create_vi,
  170. .check_left = direct_check_left,
  171. .check_right = direct_check_right,
  172. .part_size = direct_part_size,
  173. .unit_num = direct_unit_num,
  174. .print_vi = direct_print_vi
  175. };
  176. /* indirect item functions */
  177. static int indirect_bytes_number(struct item_head *ih, int block_size)
  178. {
  179. return ih_item_len(ih) / UNFM_P_SIZE * block_size;
  180. }
  181. /* decrease offset, if it becomes 0, change type to stat data */
  182. static void indirect_decrement_key(struct cpu_key *key)
  183. {
  184. cpu_key_k_offset_dec(key);
  185. if (cpu_key_k_offset(key) == 0)
  186. set_cpu_key_k_type(key, TYPE_STAT_DATA);
  187. }
  188. /* if it is not first item of the body, then it is mergeable */
  189. static int indirect_is_left_mergeable(struct reiserfs_key *key,
  190. unsigned long bsize)
  191. {
  192. int version = le_key_version(key);
  193. return (le_key_k_offset(version, key) != 1);
  194. }
  195. /* printing of indirect item */
  196. static void start_new_sequence(__u32 * start, int *len, __u32 new)
  197. {
  198. *start = new;
  199. *len = 1;
  200. }
  201. static int sequence_finished(__u32 start, int *len, __u32 new)
  202. {
  203. if (start == INT_MAX)
  204. return 1;
  205. if (start == 0 && new == 0) {
  206. (*len)++;
  207. return 0;
  208. }
  209. if (start != 0 && (start + *len) == new) {
  210. (*len)++;
  211. return 0;
  212. }
  213. return 1;
  214. }
  215. static void print_sequence(__u32 start, int len)
  216. {
  217. if (start == INT_MAX)
  218. return;
  219. if (len == 1)
  220. printk(" %d", start);
  221. else
  222. printk(" %d(%d)", start, len);
  223. }
  224. static void indirect_print_item(struct item_head *ih, char *item)
  225. {
  226. int j;
  227. __le32 *unp;
  228. __u32 prev = INT_MAX;
  229. int num = 0;
  230. unp = (__le32 *) item;
  231. if (ih_item_len(ih) % UNFM_P_SIZE)
  232. reiserfs_warning(NULL, "reiserfs-16102", "invalid item len");
  233. printk("%d pointers\n[ ", (int)I_UNFM_NUM(ih));
  234. for (j = 0; j < I_UNFM_NUM(ih); j++) {
  235. if (sequence_finished(prev, &num, get_block_num(unp, j))) {
  236. print_sequence(prev, num);
  237. start_new_sequence(&prev, &num, get_block_num(unp, j));
  238. }
  239. }
  240. print_sequence(prev, num);
  241. printk("]\n");
  242. }
  243. static void indirect_check_item(struct item_head *ih, char *item)
  244. {
  245. /* unused */
  246. }
  247. static int indirect_create_vi(struct virtual_node *vn,
  248. struct virtual_item *vi,
  249. int is_affected, int insert_size)
  250. {
  251. vi->vi_index = TYPE_INDIRECT;
  252. return 0;
  253. }
  254. static int indirect_check_left(struct virtual_item *vi, int free,
  255. int start_skip, int end_skip)
  256. {
  257. int bytes;
  258. bytes = free - free % UNFM_P_SIZE;
  259. return bytes ? : -1;
  260. }
  261. static int indirect_check_right(struct virtual_item *vi, int free)
  262. {
  263. return indirect_check_left(vi, free, 0, 0);
  264. }
  265. /*
  266. * return size in bytes of 'units' units. If first == 0 - calculate
  267. * from the head (left), otherwise - from tail (right)
  268. */
  269. static int indirect_part_size(struct virtual_item *vi, int first, int units)
  270. {
  271. /* unit of indirect item is byte (yet) */
  272. return units;
  273. }
  274. static int indirect_unit_num(struct virtual_item *vi)
  275. {
  276. /* unit of indirect item is byte (yet) */
  277. return vi->vi_item_len - IH_SIZE;
  278. }
  279. static void indirect_print_vi(struct virtual_item *vi)
  280. {
  281. reiserfs_warning(NULL, "reiserfs-16103",
  282. "INDIRECT, index %d, type 0x%x, %h",
  283. vi->vi_index, vi->vi_type, vi->vi_ih);
  284. }
  285. static struct item_operations indirect_ops = {
  286. .bytes_number = indirect_bytes_number,
  287. .decrement_key = indirect_decrement_key,
  288. .is_left_mergeable = indirect_is_left_mergeable,
  289. .print_item = indirect_print_item,
  290. .check_item = indirect_check_item,
  291. .create_vi = indirect_create_vi,
  292. .check_left = indirect_check_left,
  293. .check_right = indirect_check_right,
  294. .part_size = indirect_part_size,
  295. .unit_num = indirect_unit_num,
  296. .print_vi = indirect_print_vi
  297. };
  298. /* direntry functions */
  299. static int direntry_bytes_number(struct item_head *ih, int block_size)
  300. {
  301. reiserfs_warning(NULL, "vs-16090",
  302. "bytes number is asked for direntry");
  303. return 0;
  304. }
  305. static void direntry_decrement_key(struct cpu_key *key)
  306. {
  307. cpu_key_k_offset_dec(key);
  308. if (cpu_key_k_offset(key) == 0)
  309. set_cpu_key_k_type(key, TYPE_STAT_DATA);
  310. }
  311. static int direntry_is_left_mergeable(struct reiserfs_key *key,
  312. unsigned long bsize)
  313. {
  314. if (le32_to_cpu(key->u.k_offset_v1.k_offset) == DOT_OFFSET)
  315. return 0;
  316. return 1;
  317. }
  318. static void direntry_print_item(struct item_head *ih, char *item)
  319. {
  320. int i;
  321. int namelen;
  322. struct reiserfs_de_head *deh;
  323. char *name;
  324. static char namebuf[80];
  325. printk("\n # %-15s%-30s%-15s%-15s%-15s\n", "Name",
  326. "Key of pointed object", "Hash", "Gen number", "Status");
  327. deh = (struct reiserfs_de_head *)item;
  328. for (i = 0; i < ih_entry_count(ih); i++, deh++) {
  329. namelen =
  330. (i ? (deh_location(deh - 1)) : ih_item_len(ih)) -
  331. deh_location(deh);
  332. name = item + deh_location(deh);
  333. if (name[namelen - 1] == 0)
  334. namelen = strlen(name);
  335. namebuf[0] = '"';
  336. if (namelen > sizeof(namebuf) - 3) {
  337. strncpy(namebuf + 1, name, sizeof(namebuf) - 3);
  338. namebuf[sizeof(namebuf) - 2] = '"';
  339. namebuf[sizeof(namebuf) - 1] = 0;
  340. } else {
  341. memcpy(namebuf + 1, name, namelen);
  342. namebuf[namelen + 1] = '"';
  343. namebuf[namelen + 2] = 0;
  344. }
  345. printk("%d: %-15s%-15d%-15d%-15lld%-15lld(%s)\n",
  346. i, namebuf,
  347. deh_dir_id(deh), deh_objectid(deh),
  348. GET_HASH_VALUE(deh_offset(deh)),
  349. GET_GENERATION_NUMBER((deh_offset(deh))),
  350. (de_hidden(deh)) ? "HIDDEN" : "VISIBLE");
  351. }
  352. }
  353. static void direntry_check_item(struct item_head *ih, char *item)
  354. {
  355. int i;
  356. struct reiserfs_de_head *deh;
  357. /* unused */
  358. deh = (struct reiserfs_de_head *)item;
  359. for (i = 0; i < ih_entry_count(ih); i++, deh++) {
  360. ;
  361. }
  362. }
  363. #define DIRENTRY_VI_FIRST_DIRENTRY_ITEM 1
  364. /*
  365. * function returns old entry number in directory item in real node
  366. * using new entry number in virtual item in virtual node
  367. */
  368. static inline int old_entry_num(int is_affected, int virtual_entry_num,
  369. int pos_in_item, int mode)
  370. {
  371. if (mode == M_INSERT || mode == M_DELETE)
  372. return virtual_entry_num;
  373. if (!is_affected)
  374. /* cut or paste is applied to another item */
  375. return virtual_entry_num;
  376. if (virtual_entry_num < pos_in_item)
  377. return virtual_entry_num;
  378. if (mode == M_CUT)
  379. return virtual_entry_num + 1;
  380. RFALSE(mode != M_PASTE || virtual_entry_num == 0,
  381. "vs-8015: old_entry_num: mode must be M_PASTE (mode = \'%c\'",
  382. mode);
  383. return virtual_entry_num - 1;
  384. }
  385. /*
  386. * Create an array of sizes of directory entries for virtual
  387. * item. Return space used by an item. FIXME: no control over
  388. * consuming of space used by this item handler
  389. */
  390. static int direntry_create_vi(struct virtual_node *vn,
  391. struct virtual_item *vi,
  392. int is_affected, int insert_size)
  393. {
  394. struct direntry_uarea *dir_u = vi->vi_uarea;
  395. int i, j;
  396. int size = sizeof(struct direntry_uarea);
  397. struct reiserfs_de_head *deh;
  398. vi->vi_index = TYPE_DIRENTRY;
  399. BUG_ON(!(vi->vi_ih) || !vi->vi_item);
  400. dir_u->flags = 0;
  401. if (le_ih_k_offset(vi->vi_ih) == DOT_OFFSET)
  402. dir_u->flags |= DIRENTRY_VI_FIRST_DIRENTRY_ITEM;
  403. deh = (struct reiserfs_de_head *)(vi->vi_item);
  404. /* virtual directory item have this amount of entry after */
  405. dir_u->entry_count = ih_entry_count(vi->vi_ih) +
  406. ((is_affected) ? ((vn->vn_mode == M_CUT) ? -1 :
  407. (vn->vn_mode == M_PASTE ? 1 : 0)) : 0);
  408. for (i = 0; i < dir_u->entry_count; i++) {
  409. j = old_entry_num(is_affected, i, vn->vn_pos_in_item,
  410. vn->vn_mode);
  411. dir_u->entry_sizes[i] =
  412. (j ? deh_location(&deh[j - 1]) : ih_item_len(vi->vi_ih)) -
  413. deh_location(&deh[j]) + DEH_SIZE;
  414. }
  415. size += (dir_u->entry_count * sizeof(short));
  416. /* set size of pasted entry */
  417. if (is_affected && vn->vn_mode == M_PASTE)
  418. dir_u->entry_sizes[vn->vn_pos_in_item] = insert_size;
  419. #ifdef CONFIG_REISERFS_CHECK
  420. /* compare total size of entries with item length */
  421. {
  422. int k, l;
  423. l = 0;
  424. for (k = 0; k < dir_u->entry_count; k++)
  425. l += dir_u->entry_sizes[k];
  426. if (l + IH_SIZE != vi->vi_item_len +
  427. ((is_affected
  428. && (vn->vn_mode == M_PASTE
  429. || vn->vn_mode == M_CUT)) ? insert_size : 0)) {
  430. reiserfs_panic(NULL, "vs-8025", "(mode==%c, "
  431. "insert_size==%d), invalid length of "
  432. "directory item",
  433. vn->vn_mode, insert_size);
  434. }
  435. }
  436. #endif
  437. return size;
  438. }
  439. /*
  440. * return number of entries which may fit into specified amount of
  441. * free space, or -1 if free space is not enough even for 1 entry
  442. */
  443. static int direntry_check_left(struct virtual_item *vi, int free,
  444. int start_skip, int end_skip)
  445. {
  446. int i;
  447. int entries = 0;
  448. struct direntry_uarea *dir_u = vi->vi_uarea;
  449. for (i = start_skip; i < dir_u->entry_count - end_skip; i++) {
  450. /* i-th entry doesn't fit into the remaining free space */
  451. if (dir_u->entry_sizes[i] > free)
  452. break;
  453. free -= dir_u->entry_sizes[i];
  454. entries++;
  455. }
  456. if (entries == dir_u->entry_count) {
  457. reiserfs_panic(NULL, "item_ops-1",
  458. "free space %d, entry_count %d", free,
  459. dir_u->entry_count);
  460. }
  461. /* "." and ".." can not be separated from each other */
  462. if (start_skip == 0 && (dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM)
  463. && entries < 2)
  464. entries = 0;
  465. return entries ? : -1;
  466. }
  467. static int direntry_check_right(struct virtual_item *vi, int free)
  468. {
  469. int i;
  470. int entries = 0;
  471. struct direntry_uarea *dir_u = vi->vi_uarea;
  472. for (i = dir_u->entry_count - 1; i >= 0; i--) {
  473. /* i-th entry doesn't fit into the remaining free space */
  474. if (dir_u->entry_sizes[i] > free)
  475. break;
  476. free -= dir_u->entry_sizes[i];
  477. entries++;
  478. }
  479. BUG_ON(entries == dir_u->entry_count);
  480. /* "." and ".." can not be separated from each other */
  481. if ((dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM)
  482. && entries > dir_u->entry_count - 2)
  483. entries = dir_u->entry_count - 2;
  484. return entries ? : -1;
  485. }
  486. /* sum of entry sizes between from-th and to-th entries including both edges */
  487. static int direntry_part_size(struct virtual_item *vi, int first, int count)
  488. {
  489. int i, retval;
  490. int from, to;
  491. struct direntry_uarea *dir_u = vi->vi_uarea;
  492. retval = 0;
  493. if (first == 0)
  494. from = 0;
  495. else
  496. from = dir_u->entry_count - count;
  497. to = from + count - 1;
  498. for (i = from; i <= to; i++)
  499. retval += dir_u->entry_sizes[i];
  500. return retval;
  501. }
  502. static int direntry_unit_num(struct virtual_item *vi)
  503. {
  504. struct direntry_uarea *dir_u = vi->vi_uarea;
  505. return dir_u->entry_count;
  506. }
  507. static void direntry_print_vi(struct virtual_item *vi)
  508. {
  509. int i;
  510. struct direntry_uarea *dir_u = vi->vi_uarea;
  511. reiserfs_warning(NULL, "reiserfs-16104",
  512. "DIRENTRY, index %d, type 0x%x, %h, flags 0x%x",
  513. vi->vi_index, vi->vi_type, vi->vi_ih, dir_u->flags);
  514. printk("%d entries: ", dir_u->entry_count);
  515. for (i = 0; i < dir_u->entry_count; i++)
  516. printk("%d ", dir_u->entry_sizes[i]);
  517. printk("\n");
  518. }
  519. static struct item_operations direntry_ops = {
  520. .bytes_number = direntry_bytes_number,
  521. .decrement_key = direntry_decrement_key,
  522. .is_left_mergeable = direntry_is_left_mergeable,
  523. .print_item = direntry_print_item,
  524. .check_item = direntry_check_item,
  525. .create_vi = direntry_create_vi,
  526. .check_left = direntry_check_left,
  527. .check_right = direntry_check_right,
  528. .part_size = direntry_part_size,
  529. .unit_num = direntry_unit_num,
  530. .print_vi = direntry_print_vi
  531. };
  532. /* Error catching functions to catch errors caused by incorrect item types. */
  533. static int errcatch_bytes_number(struct item_head *ih, int block_size)
  534. {
  535. reiserfs_warning(NULL, "green-16001",
  536. "Invalid item type observed, run fsck ASAP");
  537. return 0;
  538. }
  539. static void errcatch_decrement_key(struct cpu_key *key)
  540. {
  541. reiserfs_warning(NULL, "green-16002",
  542. "Invalid item type observed, run fsck ASAP");
  543. }
  544. static int errcatch_is_left_mergeable(struct reiserfs_key *key,
  545. unsigned long bsize)
  546. {
  547. reiserfs_warning(NULL, "green-16003",
  548. "Invalid item type observed, run fsck ASAP");
  549. return 0;
  550. }
  551. static void errcatch_print_item(struct item_head *ih, char *item)
  552. {
  553. reiserfs_warning(NULL, "green-16004",
  554. "Invalid item type observed, run fsck ASAP");
  555. }
  556. static void errcatch_check_item(struct item_head *ih, char *item)
  557. {
  558. reiserfs_warning(NULL, "green-16005",
  559. "Invalid item type observed, run fsck ASAP");
  560. }
  561. static int errcatch_create_vi(struct virtual_node *vn,
  562. struct virtual_item *vi,
  563. int is_affected, int insert_size)
  564. {
  565. reiserfs_warning(NULL, "green-16006",
  566. "Invalid item type observed, run fsck ASAP");
  567. /*
  568. * We might return -1 here as well, but it won't help as
  569. * create_virtual_node() from where this operation is called
  570. * from is of return type void.
  571. */
  572. return 0;
  573. }
  574. static int errcatch_check_left(struct virtual_item *vi, int free,
  575. int start_skip, int end_skip)
  576. {
  577. reiserfs_warning(NULL, "green-16007",
  578. "Invalid item type observed, run fsck ASAP");
  579. return -1;
  580. }
  581. static int errcatch_check_right(struct virtual_item *vi, int free)
  582. {
  583. reiserfs_warning(NULL, "green-16008",
  584. "Invalid item type observed, run fsck ASAP");
  585. return -1;
  586. }
  587. static int errcatch_part_size(struct virtual_item *vi, int first, int count)
  588. {
  589. reiserfs_warning(NULL, "green-16009",
  590. "Invalid item type observed, run fsck ASAP");
  591. return 0;
  592. }
  593. static int errcatch_unit_num(struct virtual_item *vi)
  594. {
  595. reiserfs_warning(NULL, "green-16010",
  596. "Invalid item type observed, run fsck ASAP");
  597. return 0;
  598. }
  599. static void errcatch_print_vi(struct virtual_item *vi)
  600. {
  601. reiserfs_warning(NULL, "green-16011",
  602. "Invalid item type observed, run fsck ASAP");
  603. }
  604. static struct item_operations errcatch_ops = {
  605. errcatch_bytes_number,
  606. errcatch_decrement_key,
  607. errcatch_is_left_mergeable,
  608. errcatch_print_item,
  609. errcatch_check_item,
  610. errcatch_create_vi,
  611. errcatch_check_left,
  612. errcatch_check_right,
  613. errcatch_part_size,
  614. errcatch_unit_num,
  615. errcatch_print_vi
  616. };
  617. #if ! (TYPE_STAT_DATA == 0 && TYPE_INDIRECT == 1 && TYPE_DIRECT == 2 && TYPE_DIRENTRY == 3)
  618. #error Item types must use disk-format assigned values.
  619. #endif
  620. struct item_operations *item_ops[TYPE_ANY + 1] = {
  621. &stat_data_ops,
  622. &indirect_ops,
  623. &direct_ops,
  624. &direntry_ops,
  625. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  626. &errcatch_ops /* This is to catch errors with invalid type (15th entry for TYPE_ANY) */
  627. };