This file is indexed.

/usr/include/reiser4/plugin.h is in libreiser4-dev 1.1.0-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
/* Copyright (C) 2001-2005 by Hans Reiser, licensing governed by
   reiser4progs/COPYING.
   
   plugin.h -- reiser4 plugin known types and macros. */

#ifndef REISER4_PLUGIN_H
#define REISER4_PLUGIN_H

#include <aal/libaal.h>

/* Leaf and twig levels. */
#define LEAF_LEVEL			1
#define TWIG_LEVEL			(LEAF_LEVEL + 1)

/* Master related stuff like magic and offset in bytes. These are used by both
   plugins and library itself. */
#define REISER4_MASTER_MAGIC		("ReIsEr4")
#define REISER4_MASTER_OFFSET		(65536)
#define REISER4_MASTER_BLOCKNR(blksize)	(REISER4_MASTER_OFFSET/blksize)

/* The same for fs stat block. */
#define REISER4_STATUS_BLOCKNR(blksize)	(REISER4_MASTER_BLOCKNR(blksize) + 5)
#define REISER4_STATUS_MAGIC		("ReiSeR4StATusBl")

/* Where the backup starts. */
#define REISER4_BACKUP_START(blksize)	(REISER4_MASTER_BLOCKNR(blksize) + 6)

/* Root key locality and objectid. This is actually defined in oid plugin,
   but hardcoded here to exclude oid plugin from the minimal mode at all,
   nothing but these oids is needed there. */
#define REISER4_ROOT_LOCALITY		(0x29)
#define REISER4_ROOT_OBJECTID		(0x2a)

/* Macros for hole and unallocated extents. Used by both plugins (extent40) and
   library itself. */
#define EXTENT_HOLE_UNIT		(0)
#define EXTENT_UNALLOC_UNIT		(1)

/* Defining the types for disk structures. All types like f32_t are fake ones
   and needed to avoid gcc-2.95.x bug with size of typedefined aligned types. */
typedef uint8_t  f8_t;  typedef f8_t  d8_t  __attribute__((aligned(1)));
typedef uint16_t f16_t; typedef f16_t d16_t __attribute__((aligned(2)));
typedef uint32_t f32_t; typedef f32_t d32_t __attribute__((aligned(4)));
typedef uint64_t f64_t; typedef f64_t d64_t __attribute__((aligned(8)));

/* Basic reiser4 types used by both library and plugins. */
typedef uint32_t rid_t;
typedef uint64_t oid_t;

/* Type for position in node (item and unit component). */
typedef struct pos {
	uint32_t item;
	uint32_t unit;
} pos_t;

#define POS_INIT(p, i, u) \
        (p)->item = i, (p)->unit = u

/* Lookup return values. */
enum lookup {
	PRESENT                 = 1,
	ABSENT                  = 0,
};

typedef int64_t lookup_t;

#define PLUG_MAX_DESC	64
#define PLUG_MAX_LABEL	22

/* Plugin id, type and group. */
typedef struct plug_ident {
	rid_t id;
	uint8_t group;
	uint8_t type;
} plug_ident_t;

struct reiser4_plug {
	/* Plugin id. This will be used for looking for a plugin. */
	plug_ident_t id;

#ifndef ENABLE_MINIMAL
	/* Plugin label (name). */
	const char label[PLUG_MAX_LABEL];
	
	/* Short plugin description. */
	const char desc[PLUG_MAX_DESC];
#endif
};

/*
 * This should be incremented in every release which adds one
 * or more new plugins.
 * NOTE: Make sure that respective marco is also incremented in
 * the new release of reiser4 kernel module.
 */
#define PLUGIN_LIBRARY_VERSION 1

/* Known by library plugin types. */
typedef enum reiser4_plug_type {
	OBJECT_PLUG_TYPE        = 0x0,
	ITEM_PLUG_TYPE          = 0x1,
	NODE_PLUG_TYPE          = 0x2,
	HASH_PLUG_TYPE          = 0x3,
	FIBRE_PLUG_TYPE		= 0x4,
	POLICY_PLUG_TYPE        = 0x5,
	SDEXT_PLUG_TYPE         = 0x6,
	FORMAT_PLUG_TYPE        = 0x7,

	/* These are not plugins in the kernel. */
	OID_PLUG_TYPE           = 0x8,
	ALLOC_PLUG_TYPE         = 0x9,
	JOURNAL_PLUG_TYPE       = 0xa,
	KEY_PLUG_TYPE           = 0xb,

	COMPRESS_PLUG_TYPE	= 0xc,
	CMODE_PLUG_TYPE		= 0xd,
	CRYPTO_PLUG_TYPE	= 0xf,
	DIGEST_PLUG_TYPE	= 0xe,
	CLUSTER_PLUG_TYPE	= 0x10,
	
	/* Not really a plugin, at least in progs, but a value that 
	   needs to be checked only. */
	PARAM_PLUG_TYPE		= 0x12,
	LAST_PLUG_TYPE
} reiser4_plug_type_t;

/* Known object plugin ids. */
enum reiser4_object_plug_id {
	OBJECT_REG40_ID         = 0x0,
	OBJECT_DIR40_ID		= 0x1,
	OBJECT_SYM40_ID		= 0x2,
	OBJECT_SPL40_ID	        = 0x3,
	OBJECT_CCREG40_ID	= 0x4,
	OBJECT_LAST_ID
};

/* Known object groups. */
enum reiser4_object_group {
	REG_OBJECT		= 0x0,
	DIR_OBJECT		= 0x1,
	SYM_OBJECT		= 0x2,
	SPL_OBJECT		= 0x3,
	LAST_OBJECT
};

/* Known item plugin ids. */
enum reiser4_item_plug_id {
	ITEM_STAT40_ID		= 0x0,
	ITEM_SDE40_ID	        = 0x1,
	ITEM_CDE40_ID	        = 0x2,
	ITEM_NODEPTR40_ID	= 0x3,
	ITEM_ACL40_ID		= 0x4,
	ITEM_EXTENT40_ID	= 0x5,
	ITEM_PLAIN40_ID		= 0x6,
	ITEM_CTAIL40_ID		= 0x7,
	ITEM_BLACKBOX40_ID	= 0x8,
	ITEM_LAST_ID
};

/* Known item groups. */
enum reiser4_item_group {
	STAT_ITEM		= 0x0,
	PTR_ITEM		= 0x1,
	DIR_ITEM		= 0x2,
	TAIL_ITEM		= 0x3,
	EXTENT_ITEM		= 0x4,
	SAFE_LINK_ITEM		= 0x5,
	CTAIL_ITEM		= 0x6,
	BLACK_BOX_ITEM		= 0x7,
	LAST_ITEM
};

extern const char *reiser4_igname[];
extern const char *reiser4_slink_name[];

/* Known node plugin ids. */
enum reiser4_node_plug_id {
	NODE_REISER40_ID        = 0x0,
	NODE_REISER41_ID        = 0x1,
	NODE_LAST_ID
};

/* Known hash plugin ids. */
enum reiser4_hash_plug_id {
	HASH_RUPASOV_ID		= 0x0,
	HASH_R5_ID		= 0x1,
	HASH_TEA_ID		= 0x2,
	HASH_FNV1_ID		= 0x3,
	HASH_DEG_ID             = 0x4,
	HASH_LAST_ID
};

/* Know tail policy plugin ids. */
enum reiser4_tail_plug_id {
	TAIL_NEVER_ID		= 0x0,
	TAIL_ALWAYS_ID		= 0x1,
	TAIL_SMART_ID		= 0x2,
	TAIL_LAST_ID
};

/* Known stat data extension plugin ids. */
enum reiser4_sdext_plug_id {
	SDEXT_LW_ID	        = 0x0,
	SDEXT_UNIX_ID		= 0x1,
	SDEXT_LT_ID             = 0x2,
	SDEXT_SYMLINK_ID	= 0x3,
	SDEXT_PSET_ID		= 0x4,
	SDEXT_FLAGS_ID          = 0x5,
	SDEXT_CAPS_ID		= 0x6,
	SDEXT_CRYPTO_ID		= 0x7,
	SDEXT_HSET_ID		= 0x8,
	SDEXT_LAST_ID
};

/* Known format plugin ids. */
enum reiser4_format_plug_id {
	FORMAT_REISER40_ID	= 0x0,
	FORMAT_LAST_ID
};

/* Known oid allocator plugin ids. */
enum reiser4_oid_plug_id {
	OID_REISER40_ID		= 0x0,
	OID_LAST_ID
};

/* Known block allocator plugin ids. */
enum reiser4_alloc_plug_id {
	ALLOC_REISER40_ID	= 0x0,
	ALLOC_LAST_ID
};

/* Known journal plugin ids. */
enum reiser4_journal_plug_id {
	JOURNAL_REISER40_ID	= 0x0,
	JOURNAL_LAST_ID
};

/* Known key plugin ids. All these plugins are virtual in the sense they not
   exist in kernel and needed in reiser4progs because we need them working with
   both keys policy (large and short) without recompiling. */
enum reiser4_key_plug_id {
	KEY_SHORT_ID		= 0x0,
	KEY_LARGE_ID		= 0x1,
	KEY_LAST_ID
};

typedef struct reiser4_plug reiser4_plug_t;

enum reiser4_fibre_plug_id {
	FIBRE_LEXIC_ID		= 0x0,
	FIBRE_DOT_O_ID		= 0x1,
	FIBRE_EXT_1_ID		= 0x2,
	FIBRE_EXT_3_ID		= 0x3,
	FIBRE_LAST_ID
};

/* Known permission plugin ids. */
enum reiser4_perm_plug_id {
	PERM_RWX_ID		= 0x0,
	PERM_LAST_ID
};

enum reiser4_compress_plug_id {
	COMPRESS_LZO1_ID	= 0x0,
	COMPRESS_GZIP1_ID	= 0x1,
	COMPRESS_LAST_ID
};

#define reiser4_compressed(id) (((id) / 2 * 2 == (id)))

enum reiser4_crypto_id {
	CRYPTO_NONE_ID = 0x0,
	CRYPTO_LAST_ID
};

enum reiser4_compress_mode_id {
	CMODE_NONE_ID	= 0x0,
	CMODE_LATTD_ID	= 0x1,
	CMODE_ULTIM_ID	= 0x2,
	CMODE_FORCE_ID	= 0x3,
	CMODE_CONVX_ID	= 0x4,
	CMODE_LAST_ID
};

enum reiser4_cluster_id {
	CLUSTER_64K_ID	= 0x0,
	CLUSTER_32K_ID	= 0x1,
	CLUSTER_16K_ID	= 0x2,
	CLUSTER_8K_ID	= 0x3,
	CLUSTER_4K_ID	= 0x4,
	CLUSTER_LAST_ID
};

enum reiser4_digest_id {
	DIGEST_NONE_ID = 0x0,
	DIGEST_LAST_ID
};

#define INVAL_PTR	        ((void *)-1)
#define INVAL_PID	        ((rid_t)~0)

typedef struct reiser4_key reiser4_key_t;

/* Known key types. */
typedef enum key_type {
	KEY_FILENAME_TYPE       = 0x0,
	KEY_STATDATA_TYPE       = 0x1,
	KEY_ATTRNAME_TYPE       = 0x2,
	KEY_ATTRBODY_TYPE       = 0x3,
	KEY_FILEBODY_TYPE       = 0x4,
	KEY_LAST_TYPE
} key_type_t;

/* Tree Plugin SET index. */
enum reiser4_tset_id {
	TSET_REGFILE	= 0x0,
	TSET_DIRFILE	= 0x1,
	TSET_SYMFILE	= 0x2,
	TSET_SPLFILE	= 0x3,

	TSET_KEY	= 0x4,
#ifndef ENABLE_MINIMAL
	TSET_NODE	= 0x5,
	TSET_NODEPTR	= 0x6,
#endif
	TSET_LAST
};

/* Object Plugin SET index. */
enum reiser4_pset_id {
	PSET_OBJ	= 0x0,
	PSET_DIR	= 0x1,
	PSET_PERM	= 0x2,
	PSET_POLICY	= 0x3,
	PSET_HASH	= 0x4,
	PSET_FIBRE	= 0x5,
	PSET_STAT	= 0x6,
	PSET_DIRITEM	= 0x7,
	PSET_CRYPTO	= 0x8,
	PSET_DIGEST	= 0x9,
	PSET_COMPRESS	= 0xa,
	PSET_CMODE	= 0xb,
	PSET_CLUSTER	= 0xc,
	PSET_CREATE	= 0xd,
	
	PSET_STORE_LAST,
	
	/* These are not stored on disk in the current implementation. */
#ifndef ENABLE_MINIMAL
	PSET_TAIL	= PSET_STORE_LAST,
	PSET_EXTENT	= PSET_STORE_LAST + 1,
	PSET_CTAIL	= PSET_STORE_LAST + 2,
#endif
	PSET_LAST
};

#define reiser4_psobj(obj) \
	((reiser4_object_plug_t *)(obj)->info.pset.plug[PSET_OBJ])

#define reiser4_pspolicy(obj) \
	((reiser4_policy_plug_t *)(obj)->info.pset.plug[PSET_POLICY])

#define reiser4_pshash(obj) \
	((reiser4_hash_plug_t *)(obj)->info.pset.plug[PSET_HASH])

#define reiser4_psfibre(obj) \
	((reiser4_fibre_plug_t *)(obj)->info.pset.plug[PSET_FIBRE])

#define reiser4_psstat(obj) \
	((reiser4_item_plug_t *)(obj)->info.pset.plug[PSET_STAT])

#define reiser4_psdiren(obj) \
	((reiser4_item_plug_t *)(obj)->info.pset.plug[PSET_DIRITEM])

#define reiser4_pscrypto(obj) \
	((unsigned long)(obj)->info.pset.plug[PSET_CRYPTO])

#define reiser4_pscompress(obj) \
	((reiser4_plug_t *)(obj)->info.pset.plug[PSET_COMPRESS])

#define reiser4_pscmode(obj) \
	((reiser4_plug_t *)(obj)->info.pset.plug[PSET_CMODE])

#define reiser4_pscluster(obj) \
	((reiser4_cluster_plug_t *)(obj)->info.pset.plug[PSET_CLUSTER])

#define reiser4_pstail(obj) \
	((reiser4_item_plug_t *)(obj)->info.pset.plug[PSET_TAIL])

#define reiser4_psextent(obj) \
	((reiser4_item_plug_t *)(obj)->info.pset.plug[PSET_EXTENT])

#define reiser4_psctail(obj) \
	((reiser4_item_plug_t *)(obj)->info.pset.plug[PSET_CTAIL])

/* Known print options for key. */
enum print_options {
	PO_DEFAULT              = 0x0,
	PO_INODE                = 0x1,
	PO_UNIT_OFFSETS         = 0x2
};

#ifndef ENABLE_MINIMAL
enum reiser4_plugin_flag {
	PF_CRC = 0x0,
	PF_LAST
};
#endif

typedef struct tree_entity {
	/* Plugin SET. Set of plugins needed for the reiser4progs work.
	   Consists of tree-specific plugins and object-specific plugins. */
	reiser4_plug_t *tset[TSET_LAST];
	reiser4_plug_t *pset[PSET_LAST];
	uint64_t param_mask;
} tree_entity_t;

typedef struct reiser4_node reiser4_node_t;
typedef struct reiser4_place reiser4_place_t;

typedef struct reiser4_key_plug reiser4_key_plug_t;
typedef struct reiser4_item_plug reiser4_item_plug_t;
typedef struct reiser4_node_plug reiser4_node_plug_t;
typedef struct reiser4_hash_plug reiser4_hash_plug_t;
typedef struct reiser4_fibre_plug reiser4_fibre_plug_t;
typedef struct reiser4_sdext_plug reiser4_sdext_plug_t;
typedef struct reiser4_format_plug reiser4_format_plug_t;
typedef struct reiser4_oid_plug reiser4_oid_plug_t;
typedef struct reiser4_alloc_plug reiser4_alloc_plug_t;
typedef struct reiser4_journal_plug reiser4_journal_plug_t;

/* Opaque types describing reiser4 objects, like format, block allocator, etc
   created by plugins themselves, within the library. */
#define DEFINE_ENT(TYPE)			\
typedef struct reiser4_ ## TYPE ## _ent {	\
	reiser4_ ## TYPE ## _plug_t *plug;	\
} reiser4_ ## TYPE ## _ent_t;

DEFINE_ENT(format);
DEFINE_ENT(journal);
DEFINE_ENT(oid);
DEFINE_ENT(alloc);

#define place_blknr(place) ((place)->node->block->nr)
#define place_item_pos(place) ((place)->pos.item)
#define place_blksize(place) ((place)->node->block->size)

/* Type for key which is used both by library and plugins. */
struct reiser4_key {
	reiser4_key_plug_t *plug;
	d64_t body[4];
#ifndef ENABLE_MINIMAL
	uint32_t adjust;
#endif
};

/* Tree coord struct. */
struct reiser4_place {
	/* Item/unit pos and node it lies in. These fields should be always
	   initialized in a @place instance. */
	pos_t pos;
	reiser4_node_t *node;

	/* Item header stuff. There are item body pointer, length, flags, key
	   and plugin used in item at @pos. These fields are initialized in node
	   method fetch() and stored here to make work with them simpler. */
	void *body;
	uint32_t len;

	/* First unit offset within the item. Used by item internal code only. 
	   Useful to minimize the code (e.g. tail, ctail). */
	uint32_t off;
	
	reiser4_key_t key;
	reiser4_item_plug_t *plug;
};

enum node_flags {
	NF_HEARD_BANSHEE  = 1 << 0,
	NF_LAST
};

/* Reiser4 in-memory node structure. */
struct reiser4_node {
	/* Node plugin. */
	reiser4_node_plug_t *plug;

	/* Block node lies in. */
	aal_block_t *block;

	/* Reference to tree if node is attached to tree. Sometimes node needs
	   access tree and tree functions. */
	tree_entity_t *tree;
	
	/* Place in parent node. */
	reiser4_place_t p;

	/* Reference to left neighbour. It is used for establishing silbing
	   links among nodes in memory tree cache. */
	reiser4_node_t *left;

	/* Reference to right neighbour. It is used for establishing silbing
	   links among nodes in memory tree cache. */
	reiser4_node_t *right;
	
	/* Usage counter to prevent releasing used nodes. */
	signed int counter;

	/* Key plugin. */
	reiser4_key_plug_t *kplug;

	/* Key policy. Optimisation to not call key->bodysize all the time. */
	uint8_t keypol;
	
	/* Node state flags. */
	uint32_t state;

#ifndef ENABLE_MINIMAL
	/* Different node flags. */
	uint32_t flags;
	
	/* Applications using this library sometimes need to embed information
	   into the objects of our library for their own use. */
	void *data;
#endif
};

/* This is an info that sdext plugins need. E.g. digest is needed to sdext_crc 
   plugin to proceed. */
typedef struct stat_info {
	uint16_t mode;
#ifndef ENABLE_MINIMAL
	reiser4_plug_t *digest;
#endif
} stat_info_t;

/* Stat data extension entity. */
typedef struct stat_entity {
	reiser4_sdext_plug_t *plug;
	reiser4_place_t *place;
	uint32_t offset;
	stat_info_t info;
} stat_entity_t;

#define stat_body(stat) ((char *)(stat)->place->body + (stat)->offset)

/* Shift flags control shift process */
enum shift_flags {
	/* Allows to try to make shift from the passed node to left neighbour
	   node. */
	SF_ALLOW_LEFT    = 1 << 0,

	/* Allows to try to make shift from the passed node to right neighbour
	   node. */
	SF_ALLOW_RIGHT   = 1 << 1,

	/* Allows to move insert point to one of neighbour nodes during
	   shift. */
	SF_MOVE_POINT    = 1 << 2,

	/* Care about the insert point, shift only till this point. If not 
	   given, as much data as fit the destination node will be shifted. */
	SF_UPDATE_POINT  = 1 << 3,

	/* Controls if shift allowed to merge border items or only whole items
	   may be shifted. Needed for repair code in order to disable merge of
	   checked item and not checked one. */
	SF_ALLOW_MERGE   = 1 << 4,

	/* Controls if shift allowed to allocate new nodes during making
	   space. This is needed sometimes if there is not enough of free space
	   in existent nodes (one insert point points to and its neighbours)*/
	SF_ALLOW_ALLOC   = 1 << 5,

	SF_ALLOW_PACK    = 1 << 6,

	/* Hold (do not leave) the current position (pointed by place->pos). */
	SF_HOLD_POS      = 1 << 7
};

#define SF_DEFAULT					   \
	(SF_ALLOW_LEFT | SF_ALLOW_RIGHT | SF_ALLOW_ALLOC | \
	 SF_ALLOW_MERGE | SF_MOVE_POINT | SF_ALLOW_PACK)

typedef struct shift_hint {
	/* Flag which shows that we need create an item before we will move
	   units into it. That is because node does not contain any items at all
	   or border items are not mergeable. Set and used by shift code. */
	int create;

	/* Shows, that one of neighbour nodes has changed its leftmost key and
	   internal tree should be updated. */
	int update;

	/* Item count and unit count which will be moved. */
	uint32_t items_number;
	uint32_t units_number;

	/* Used for internal shift purposes. */
	uint32_t items_bytes;
	uint32_t units_bytes;

	/* Shift control flags (left shift, move insert point, merge, etc) and
	   shift result flags. The result flags are needed for determining for
	   example was insert point moved to the corresponding neighbour or
	   not. Of course we might use control flags for that, but it would led
	   us to write a lot of useless stuff for saving control flags before
	   modifying it. */
	uint32_t control;
	uint32_t result;

	/* Insert point. It will be modified during shift. */
	pos_t pos;
} shift_hint_t;

/* Different hints used for getting data to/from corresponding objects. */
typedef struct ptr_hint {    
	uint64_t start;
	uint64_t width;
} ptr_hint_t;

typedef struct ctail_hint {
	uint8_t shift;
} ctail_hint_t;

typedef struct sdhint_unix {
	uint32_t uid;
	uint32_t gid;
	uint32_t atime;
	uint32_t mtime;
	uint32_t ctime;
	uint32_t rdev;
	uint64_t bytes;
} sdhint_unix_t;

typedef struct sdhint_lw {
	uint16_t mode;
	uint32_t nlink;
	uint64_t size;
} sdhint_lw_t;

typedef struct sdhint_lt {
	uint32_t atime;
	uint32_t mtime;
	uint32_t ctime;
} sdhint_lt_t;

typedef struct sdhint_flags {
	uint32_t flags;
} sdhint_flags_t;

typedef struct reiser4_pset {
	/* Set of initialized fields. */
	uint64_t plug_mask;
	reiser4_plug_t *plug[PSET_LAST];
} reiser4_pset_t;

typedef reiser4_pset_t sdhint_plug_t;

#ifndef ENABLE_MINIMAL
typedef struct sdhint_crypto {
	uint16_t keylen;
	uint16_t signlen;
	uint8_t  sign[128];
} sdhint_crypto_t;
#endif

/* These fields should be changed to what proper description of needed
   extensions. */
typedef struct stat_hint {
	/* Extensions mask */
	uint64_t extmask;
    
	/* Stat data extensions */
	void *ext[SDEXT_LAST_ID];
} stat_hint_t;

typedef enum entry_type {
	ET_NAME	= 0,
	ET_SPCL	= 1,
	ET_LAST
} entry_type_t;

/* Object info struct contains the main information about a reiser4
   object. These are: its key, parent key and coord of first item. */
typedef struct object_info {
	reiser4_pset_t pset;
	reiser4_pset_t hset;
	
	tree_entity_t *tree;
	reiser4_place_t start;
	reiser4_key_t object;
	reiser4_key_t parent;
} object_info_t;

/* Object hint. It is used to bring all about object information to object
   plugin to create appropriate object by it. */
typedef struct object_hint {
	/* Additional mode to be masked to stat data mode. This is
	   needed for special files, but mat be used somewhere else. */
	uint32_t mode;
	
	/* rdev field for special file. Nevertheless, it is stored
	   inside special file stat data field, we put it to @body
	   definition, because it is the special file essence. */
	uint64_t rdev;
	
	/* SymLink name or CRC key. */
	char *str;
} object_hint_t;

/* Reiser4 file structure (regular file, directory, symlinks, etc) */
typedef struct reiser4_object {
	/* Info about the object, stat data place, object and parent keys and
	   pointer to the instance of internal libreiser4 tree for modiying
	   purposes. It is passed by reiser4 library during initialization of
	   the file instance. */
	object_info_t info;

	/* Current body item coord stored here */
	reiser4_place_t body;

	/* Current position in the reg file */
	reiser4_key_t position;

#ifndef ENABLE_MINIMAL
	/* File body plugin is use. */
	reiser4_item_plug_t *body_plug;
#endif
} reiser4_object_t;

/* Bits for entity state field. For now here is only "dirty" bit, but possible
   and other ones. */
enum entity_state {
	ENTITY_DIRTY = 0
};

/* Type for region enumerating callback functions. */
typedef errno_t (*region_func_t) (uint64_t, uint64_t, void *);

/* Type for on-place functions. */
typedef errno_t (*place_func_t) (reiser4_place_t *, void *);

/* Type for on-node functions. */
typedef errno_t (*node_func_t) (reiser4_node_t *, void *);

/* Function definitions for enumeration item metadata and data. */
typedef errno_t (*layout_func_t) (void *, region_func_t, void *);

#define REISER4_MIN_BLKSIZE (512)
#define REISER4_MAX_BLKSIZE (8192)

typedef struct entry_hint {
	/* Entry metadata size. Filled by rem_entry and add_entry. */
	uint16_t len;
	
	/* Tree coord entry lies at. Filled by dir plugin's lookup. */
	reiser4_place_t place;

	/* Entry key within the current directory */
	reiser4_key_t offset;

	/* The stat data key of the object entry points to */
	reiser4_key_t object;

	/* Entry type (name or special), filled by readdir */
	uint8_t type;

	/* Name of entry */
	char name[REISER4_MAX_BLKSIZE];

#ifndef ENABLE_MINIMAL
	/* Hook called onto each create item during write flow. */
	place_func_t place_func;

	/* Related opaque data. May be used for passing something to
	   region_func() and place_func(). */
	void *data;
#endif
} entry_hint_t;

#ifndef ENABLE_MINIMAL
typedef enum slink_type {
	SL_UNLINK,   /* safe-link for unlink */
	SL_TRUNCATE, /* safe-link for truncate */
	SL_E2T,      /* safe-link for extent->tail conversion */
	SL_T2E,      /* safe-link for tail->extent conversion */
	SL_LAST
} slink_type_t;

typedef struct slink_hint {
	/* Key of StatData the link points to. */
	reiser4_key_t key;
	
	/* The size to be truncated. */
	uint64_t size;

	slink_type_t type;
} slink_hint_t;
#endif

/* This structure contains fields which describe an item or unit to be inserted
   into the tree. This is used for all tree modification purposes like
   insertitem, or write some file data. */ 
typedef struct trans_hint {
	/* Overhead of data to be inserted. This is needed for the case when we
	   insert directory item and tree should know how much space should be
	   prepared in the tree (ohd + len), but we don't need overhead for
	   updating stat data bytes field. Set by estimate. */
	uint32_t overhead;
	
	/* Length of the data to be inserted/removed. Set by prep methods. */
	int32_t len;

	/* Value needed for updating bytes field in stat data. Set by
	   estimate. */
	uint64_t bytes;

	/* This is opaque pointer to item type specific information. */
	void *specific;

	/* Count of items/units to be inserted into the tree. */
	uint64_t count;

	/* The key of item/unit to be inserted. */
	reiser4_key_t offset;

	/* Max real key. Set by estimate and needed for file body items. */
	reiser4_key_t maxkey;

	/* Flags specific for the insert (raw for now), set at prepare stage. */
	uint16_t insert_flags;

	/* Shift flags for shift operation. */
	uint32_t shift_flags;
	
	/* Count of handled blocks in the first and the last extent unit. */
	uint64_t head, tail;

	/* Hash table unformatted blocks lie in. Needed for extent code. */
	aal_hash_table_t *blocks;
	
	/* Plugin to be used for working with item. */
	reiser4_item_plug_t *plug;

	/* Hook, which lets know, that passed block region is removed. Used for
	   releasing unformatted blocks during tail converion, or for merging
	   extents, etc. */
	region_func_t region_func;

	/* Hook called onto each create item during write flow. */
	place_func_t place_func;

	/* Related opaque data. May be used for passing something to
	   region_func() and place_func(). */
	void *data;
} trans_hint_t;

/* This structure contains related to tail conversion. */
typedef struct conv_hint {
	/* New bytes value */
	uint64_t bytes;

	/* Bytes to be converted. */
	uint64_t count;
	
	/* File will be converted starting from this key. */
	reiser4_key_t offset;
	
	/* Plugin item will be converted to. */
	reiser4_item_plug_t *plug;

	/* Callback function caled onto each new created item during tail
	   conversion. */
	place_func_t place_func;

	/* The flag if the hole should be inserted if there is nothing 
	   to read. Could be useful for recovery when there could be a 
	   gap between 2 items. */
	bool_t ins_hole;
} conv_hint_t;

typedef struct coll_hint {
	uint8_t type;
	void *specific;
} coll_hint_t;

/* Lookup bias. */
typedef enum lookup_bias {
	/* Find for read, the match should be exact. */
	FIND_EXACT              = 1,
	/* Find for insert, the match should not be exaact. */
	FIND_CONV               = 2
} lookup_bias_t;

typedef lookup_t (*coll_func_t) (tree_entity_t *, 
				 reiser4_place_t *, 
				 coll_hint_t *);

/* Hint to be used when looking for data in tree. */
typedef struct lookup_hint {
	/* Key to be found. */
	reiser4_key_t *key;

	/* Tree level lookup should stop on. */
	uint8_t level;

#ifndef ENABLE_MINIMAL
	/* Function for modifying position during lookup in some way needed by
	   caller. Key collisions may be handler though this. */
	coll_func_t collision;

	/* Data needed by @lookup_func. */
	coll_hint_t *hint;
#endif
} lookup_hint_t;

#ifndef ENABLE_MINIMAL
typedef struct repair_hint {
	int64_t len;
	uint8_t mode;
} repair_hint_t;

enum reiser4_backuper {
	BK_MASTER	= 0x0,
	BK_FORMAT	= 0x1,
	BK_PSET		= 0x2,
	BK_LAST		= 0x3
};

typedef struct backup_hint {
	aal_block_t block;
	uint16_t off[BK_LAST + 1];

	/* Fields below are used by check_backup. */
	
	/* Block count. */
	uint64_t blocks;

	/* Matched block count. */
	uint64_t count;
	uint64_t total;

	uint32_t version;
} backup_hint_t;

#endif

enum format_hint_mask {
	PM_POLICY	= 0x0,
	PM_KEY		= 0x1
};

typedef struct format_hint {
	uint64_t blocks;
	uint32_t blksize;
	rid_t policy;
	rid_t key;
	rid_t node;

	/* For repair purposes. Set plugin types that are overridden 
	   in the profile here, they must be set in the format plugin
	   check_struct. If bit is not set, plugins given with the above 
	   hints are merely hints. */
	uint64_t mask;
} format_hint_t;

struct reiser4_key_plug {
	reiser4_plug_t p;
	
	/* Function for dermining is key contains direntry name hashed or
	   not? */
	int (*hashed) (reiser4_key_t *);

	/* Returns minimal key for this key-format */
	reiser4_key_t *(*minimal) (void);
    
	/* Returns maximal key for this key-format */
	reiser4_key_t *(*maximal) (void);

	/* Returns key size for particular key-format */
	uint32_t (*bodysize) (void);

	/* Compares two keys by comparing its all components. This function
	   accepts not key entities, but key bodies. This is needed in order to
	   avoid memory copying in some cases. For instance when we look into
	   node and try to find position by key, we prefer to pass to comraw()
	   pointers to key bodies, than to copy tjem to new created key
	   entities. */
	int (*compraw) (void *, void *);

	/* Compares two keys by comparing its all components. */
	int (*compfull) (reiser4_key_t *, reiser4_key_t *);

	/* Compares two keys by comparing locality and objectid. */
	int (*compshort) (reiser4_key_t *, reiser4_key_t *);
	
	/* Builds generic key (statdata, file body, etc). That is build key by
	   all its components. */
	errno_t (*build_generic) (reiser4_key_t *, key_type_t,
				  uint64_t, uint64_t, uint64_t, uint64_t);

	/* Builds key used for directory entries access. It uses name and hash
	   plugin to build hash and put it to key offset component. */
	void (*build_hashed) (reiser4_key_t *, reiser4_hash_plug_t *,
			      reiser4_fibre_plug_t *, uint64_t, 
			      uint64_t, char *);
	
#ifndef ENABLE_MINIMAL
	
	/* Gets/sets key type (minor in reiser4 notation). */	
	void (*set_type) (reiser4_key_t *, key_type_t);
	key_type_t (*get_type) (reiser4_key_t *);

	/* Gets/sets key full objectid */
	void (*set_fobjectid) (reiser4_key_t *, uint64_t);
	uint64_t (*get_fobjectid) (reiser4_key_t *);
	
	/* Gets/sets key locality. */
	void (*set_locality) (reiser4_key_t *, uint64_t);
#endif
	uint64_t (*get_locality) (reiser4_key_t *);
	
	/* Gets/sets key locality. */
	void (*set_ordering) (reiser4_key_t *, uint64_t);
	uint64_t (*get_ordering) (reiser4_key_t *);
    
	/* Gets/sets key objectid. */
	void (*set_objectid) (reiser4_key_t *, uint64_t);
	uint64_t (*get_objectid) (reiser4_key_t *);

	/* Gets/sets key offset */
	void (*set_offset) (reiser4_key_t *, uint64_t);
	uint64_t (*get_offset) (reiser4_key_t *);

	/* Extracts name from passed key. */
	char *(*get_name) (reiser4_key_t *, char *);

#ifndef ENABLE_MINIMAL
	/* Gets/sets directory key hash */
	void (*set_hash) (reiser4_key_t *, uint64_t);
	uint64_t (*get_hash) (reiser4_key_t *);
	
	/* Prints key into specified buffer */
	void (*print) (reiser4_key_t *, aal_stream_t *, uint16_t);

	/* Check key body for validness. */
	errno_t (*check_struct) (reiser4_key_t *);
#endif
};


typedef struct reiser4_object_plug {
	reiser4_plug_t p;
	
	/* Loads object stat data to passed hint. */
	errno_t (*stat) (reiser4_object_t *, stat_hint_t *);

#ifndef ENABLE_MINIMAL
	/* These methods change @nlink value of passed @entity. */
	errno_t (*link) (reiser4_object_t *);
	errno_t (*unlink) (reiser4_object_t *);
	bool_t (*linked) (reiser4_object_t *);

	/* Establish parent child relationship. */
	errno_t (*attach) (reiser4_object_t *, reiser4_object_t *);
	errno_t (*detach) (reiser4_object_t *, reiser4_object_t *);

	/* Inherits from the parent object. */
	errno_t (*inherit) (object_info_t *, object_info_t *);
	
	/* Creates new file with passed parent and object keys. */
	errno_t (*create) (reiser4_object_t *, object_hint_t *);

	/* Delete file body and stat data if any. */
	errno_t (*clobber) (reiser4_object_t *);

	/* Writes the data to file from passed buffer. */
	int64_t (*write) (reiser4_object_t *, void *, uint64_t);

	/* Directory specific methods */
	errno_t (*add_entry) (reiser4_object_t *, entry_hint_t *);
	errno_t (*rem_entry) (reiser4_object_t *, entry_hint_t *);
	errno_t (*build_entry) (reiser4_object_t *, entry_hint_t *);
	
	/* Truncates file at current offset onto passed units. */
	errno_t (*truncate) (reiser4_object_t *, uint64_t);

	/* Function for going through all metadata blocks specfied file
	   occupied. It is needed for accessing file's metadata. */
	errno_t (*metadata) (reiser4_object_t *, place_func_t, void *);
	
	/* Function for going through the all data blocks specfied file
	   occupies. It is needed for the purposes like data fragmentation
	   measuring, etc. */
	errno_t (*layout) (reiser4_object_t *, region_func_t, void *);

	/* Converts file body to item denoted by @plug. */
	errno_t (*convert) (reiser4_object_t *, reiser4_item_plug_t *plug);
	
	/* Checks and recover the structure of the object. */
	errno_t (*check_struct) (reiser4_object_t *, place_func_t, 
				 void *, uint8_t);
	
	/* Checks attach of the @object to the @parent. */
	errno_t (*check_attach) (reiser4_object_t *, reiser4_object_t *,
				 place_func_t, void *, uint8_t);
	
	/* Realizes if the object can be of this plugin and can be recovered as
	   a such. */
	errno_t (*recognize) (reiser4_object_t *);
	
	/* Creates the fake object by the gived @info. Needed to recover "/" and
	   "lost+found" direcories if their SD are broken. */
	errno_t (*fake) (reiser4_object_t *);
#endif
	
	/* Change current position to passed value. */
	errno_t (*seek) (reiser4_object_t *, uint64_t);
	
	/* Opens file with specified key */
	errno_t (*open) (reiser4_object_t *);

	/* Closes previously opened or created directory. */
	void (*close) (reiser4_object_t *);

	/* Resets internal position. */
	errno_t (*reset) (reiser4_object_t *);
   
	/* Returns current position in directory. */
	uint64_t (*offset) (reiser4_object_t *);

	/* Makes lookup inside file */
	lookup_t (*lookup) (reiser4_object_t *, char *, entry_hint_t *);

	/* Finds actual file stat data (used in symlinks). */
	errno_t (*follow) (reiser4_object_t *, reiser4_key_t *,
			   reiser4_key_t *);

	/* Reads the data from file to passed buffer. */
	int64_t (*read) (reiser4_object_t *, void *, uint64_t);

	/* Directory read method. */
	int32_t (*readdir) (reiser4_object_t *, entry_hint_t *);

	/* Return current position in directory. */
	errno_t (*telldir) (reiser4_object_t *, reiser4_key_t *);

	/* Change current position in directory. */
	errno_t (*seekdir) (reiser4_object_t *, reiser4_key_t *);

#ifndef ENABLE_MINIMAL
	uint64_t sdext_mandatory;
	uint64_t sdext_unknown;
#endif
} reiser4_object_plug_t;

typedef struct item_balance_ops {
	/* Returns unit count in item passed place point to. */
	uint32_t (*units) (reiser4_place_t *);
	
	/* Makes lookup for passed key. */
	lookup_t (*lookup) (reiser4_place_t *, lookup_hint_t *,
			    lookup_bias_t);
	
#ifndef ENABLE_MINIMAL
	/* Merges two neighbour items in the same node. Returns space released
	   Needed for fsck. */
	int32_t (*merge) (reiser4_place_t *, reiser4_place_t *);
	
	/* Checks if items mergeable, that is if unit of one item can belong to
	   another one. Returns 1 if so, 0 otherwise. */
	int (*mergeable) (reiser4_place_t *, reiser4_place_t *);

	/* Estimates shift operation. */
	errno_t (*prep_shift) (reiser4_place_t *, reiser4_place_t *, shift_hint_t *);
	
	/* Performs shift of units from passed @src item to @dst item. */
	errno_t (*shift_units) (reiser4_place_t *, reiser4_place_t *, shift_hint_t *);

	/* Set the key of a particular unit of the item. */
	errno_t (*update_key) (reiser4_place_t *, reiser4_key_t *);
	
	/* Get the max real key which is stored in the item. */
	errno_t (*maxreal_key) (reiser4_place_t *, reiser4_key_t *);

	/* Collision handler item method. */
	lookup_t (*collision) (reiser4_place_t *, coll_hint_t *);
#endif

	/* Get the key of a particular unit of the item. */
	errno_t (*fetch_key) (reiser4_place_t *, reiser4_key_t *);

	/* Get the max key which could be stored in the item of this type. */
	errno_t (*maxposs_key) (reiser4_place_t *, reiser4_key_t *);

	/* Gets the overhead for the item creation. */
	uint16_t (*overhead) ();
	
	/* Initialize the item-specific place info. */
	void (*init) (reiser4_place_t *);
} item_balance_ops_t;

typedef struct item_object_ops {
	/* Reads passed amount of bytes from the item. */
	int64_t (*read_units) (reiser4_place_t *, trans_hint_t *);
		
	/* Fetches one or more units at passed @place to passed hint. */
	int64_t (*fetch_units) (reiser4_place_t *, trans_hint_t *);

#ifndef ENABLE_MINIMAL
	/* Estimates write operation. */
	errno_t (*prep_write) (reiser4_place_t *, trans_hint_t *);

	/* Writes data to item. */
	int64_t (*write_units) (reiser4_place_t *, trans_hint_t *);

	/* Estimates insert operation. */
	errno_t (*prep_insert) (reiser4_place_t *, trans_hint_t *);

	/* Inserts some amount of units described by passed hint into passed
	   item denoted by place. */
	int64_t (*insert_units) (reiser4_place_t *, trans_hint_t *);

	/* Removes specified unit from the item. */
	errno_t (*remove_units) (reiser4_place_t *, trans_hint_t *);

	/* Updates unit at passed place by data from passed hint. */
	int64_t (*update_units) (reiser4_place_t *, trans_hint_t *);

	/* Cuts out some amount of data */
	int64_t (*trunc_units) (reiser4_place_t *, trans_hint_t *);

	/* Goes through all blocks item points to. */
	errno_t (*layout) (reiser4_place_t *, region_func_t, void *);
		
	/* Gets the size of the data item keeps. */
	uint64_t (*size) (reiser4_place_t *);
	
	/* Gets the amount of bytes data item keeps takes on the disk. */
	uint64_t (*bytes) (reiser4_place_t *);
#endif
} item_object_ops_t;

#ifndef ENABLE_MINIMAL
typedef struct item_repair_ops {
	/* Estimate merge operation. */
	errno_t (*prep_insert_raw) (reiser4_place_t *, trans_hint_t *);

	/* Copies some amount of units from @src to @dst with partial
	   overwritting. */
	errno_t (*insert_raw) (reiser4_place_t *, trans_hint_t *);

	/* Checks the item structure. */
	errno_t (*check_struct) (reiser4_place_t *, repair_hint_t *);
	
	/* Does some specific actions if a block the item points to is wrong. */
	errno_t (*check_layout) (reiser4_place_t *, repair_hint_t *,
				 region_func_t, void *);

	errno_t (*pack) (reiser4_place_t *, aal_stream_t *);
	errno_t (*unpack) (reiser4_place_t *, aal_stream_t *);
} item_repair_ops_t;

typedef struct item_debug_ops {
	/* Prints item into specified buffer. */
	void (*print) (reiser4_place_t *, aal_stream_t *, uint16_t);
} item_debug_ops_t;
#endif

struct reiser4_item_plug {
	reiser4_plug_t p;
	
	item_object_ops_t *object;
	item_balance_ops_t *balance;
#ifndef ENABLE_MINIMAL
	item_debug_ops_t *debug;
	item_repair_ops_t *repair;
#endif
};

/* Stat data extension plugin */
struct reiser4_sdext_plug {
	reiser4_plug_t p;
	
#ifndef ENABLE_MINIMAL
	/* Initialize stat data extension data at passed pointer. */
	errno_t (*init) (stat_entity_t *, void *);
	
	/* Prints stat data extension data into passed buffer. */
	void (*print) (stat_entity_t *, aal_stream_t *, uint16_t);

	/* Checks sd extension content. */
	errno_t (*check_struct) (stat_entity_t *, repair_hint_t *);
#endif
	/* Obtain the needed info for the futher stat data traverse. */
	void (*info) (stat_entity_t *);
	
	/* Reads stat data extension data. */
	errno_t (*open) (stat_entity_t *, void *);

	/* Returns length of the extension. */
	uint32_t (*length) (stat_entity_t *, void *);
};

/* Node plugin operates on passed block. It doesn't any initialization, so it
   hasn't close method and all its methods accepts first argument aal_block_t,
   not initialized previously hypothetic instance of node. */
struct reiser4_node_plug {
	reiser4_plug_t p;
	
#ifndef ENABLE_MINIMAL
	/* Get node state flags and set them back. */
	uint32_t (*get_state) (reiser4_node_t *);
	void (*set_state) (reiser4_node_t *, uint32_t);

	/* Performs shift of items and units. */
	errno_t (*shift) (reiser4_node_t *, reiser4_node_t *, 
			  shift_hint_t *);

	/* Fuses two neighbour items in passed node at passed positions. */
	errno_t (*merge) (reiser4_node_t *, pos_t *, pos_t *);
    
	/* Checks thoroughly the node structure and fixes what needed. */
	errno_t (*check_struct) (reiser4_node_t *, uint8_t);

	/* Packing/unpacking metadata. */
	reiser4_node_t *(*unpack) (aal_block_t *, 
				   reiser4_key_plug_t *, 
				   aal_stream_t *);
	
	errno_t (*pack) (reiser4_node_t *, aal_stream_t *);

	/* Prints node into given buffer. */
	void (*print) (reiser4_node_t *, aal_stream_t *,
		       uint32_t, uint32_t, uint16_t);
    
	/* Returns node overhead. */
	uint16_t (*overhead) (reiser4_node_t *);

	/* Returns node max possible space. */
	uint16_t (*maxspace) (reiser4_node_t *);
    
	/* Returns free space in the node. */
	uint16_t (*space) (reiser4_node_t *);

	/* Inserts item at specified pos. */
	errno_t (*insert) (reiser4_node_t *, pos_t *,
			   trans_hint_t *);
    
	/* Writes data to the node. */
	int64_t (*write) (reiser4_node_t *, pos_t *,
			  trans_hint_t *);

	/* Truncate item at passed pos. */
	int64_t (*trunc) (reiser4_node_t *, pos_t *,
			  trans_hint_t *);

	/* Removes item/unit at specified pos. */
	errno_t (*remove) (reiser4_node_t *, pos_t *,
			   trans_hint_t *);

	/* Shrinks node without calling any item methods. */
	errno_t (*shrink) (reiser4_node_t *, pos_t *,
			   uint32_t, uint32_t);

	/* Merge 2 items -- insert/overwrite @src_entity parts to
	   @dst_entity. */
	errno_t (*insert_raw) (reiser4_node_t *, pos_t *, 
			       trans_hint_t *);

	/* Copies items from @src_entity to @dst_entity. */
	errno_t (*copy) (reiser4_node_t *, pos_t *,
			 reiser4_node_t *, pos_t *,
			 uint32_t);
	
	/* Expands node (makes space) at passed pos. */
	errno_t (*expand) (reiser4_node_t *, pos_t *,
			   uint32_t, uint32_t);

	/* Updates key at passed pos by passed key. */
	errno_t (*set_key) (reiser4_node_t *, pos_t *,
			    reiser4_key_t *);

	void (*set_level) (reiser4_node_t *, uint8_t);
	void (*set_mstamp) (reiser4_node_t *, uint32_t);
	void (*set_fstamp) (reiser4_node_t *, uint64_t);

	/* Get mkfs and flush stamps */
	uint32_t (*get_mstamp) (reiser4_node_t *);
    	uint64_t (*get_fstamp) (reiser4_node_t *);
	
	/* Get/set item flags. */
	void (*set_flags) (reiser4_node_t *, uint32_t, uint16_t);
	uint16_t (*get_flags) (reiser4_node_t *, uint32_t);

	/* Saves node to device */
	errno_t (*sync) (reiser4_node_t *);

	/* Initializes node with passed block and key plugin. */
	reiser4_node_t *(*init) (aal_block_t *, uint8_t , 
				 reiser4_key_plug_t *);
#endif
	/* Open the node on the given block with the given key plugin. */
	reiser4_node_t *(*open) (aal_block_t *, reiser4_key_plug_t *);
	
	/* Destroys the node entity. */
	errno_t (*fini) (reiser4_node_t *);

	/* Fetches item data to passed @place */
	errno_t (*fetch) (reiser4_node_t *, pos_t *,
			  reiser4_place_t *);
	
	/* Returns item count */
	uint32_t (*items) (reiser4_node_t *);
    
	/* Makes lookup inside node by specified key */
	lookup_t (*lookup) (reiser4_node_t *, lookup_hint_t *, 
			    lookup_bias_t, pos_t *);
    
	/* Gets/sets key at pos */
	errno_t (*get_key) (reiser4_node_t *, pos_t *,
			    reiser4_key_t *);

	/* Return node level. */
	uint8_t (*get_level) (reiser4_node_t *);
};

/* Hash plugin operations. */
struct reiser4_hash_plug {
	reiser4_plug_t p;
	
	uint64_t (*build) (unsigned char *, uint32_t);
};

struct reiser4_fibre_plug {
	reiser4_plug_t p;
	
	uint8_t (*build) (char *, uint32_t);
};

/* Disk-format plugin */
struct reiser4_format_plug {
	reiser4_plug_t p;
	
#ifndef ENABLE_MINIMAL
	/* Called during filesystem creating. It forms format-specific super
	   block, initializes plugins and calls their create method. */
	reiser4_format_ent_t *(*create) (aal_device_t *, format_hint_t *);

	/* Save the important permanent info about the format into the stream 
	   to be backuped on the fs & check this info. */
	errno_t (*backup) (reiser4_format_ent_t *, backup_hint_t *);
	errno_t (*check_backup) (backup_hint_t *);

	/* Regenerate the format instance by the backup. */
	reiser4_format_ent_t *(*regenerate) (aal_device_t *, backup_hint_t *);
	
	/* Save format data to device. */
	errno_t (*sync) (reiser4_format_ent_t *);

	/* Change entity state (dirty, etc) */
	uint32_t (*get_state) (reiser4_format_ent_t *);
	void (*set_state) (reiser4_format_ent_t *, uint32_t);

	/* Format pack/unpack methods. */
	reiser4_format_ent_t *(*unpack) (aal_device_t *, uint32_t, aal_stream_t *);
	errno_t (*pack) (reiser4_format_ent_t *, aal_stream_t *);
	
	/* Update only fields which can be changed after journal replay in
	   memory to avoid second checking. */
	errno_t (*update) (reiser4_format_ent_t *);
	    
	/* Prints all useful information about the format */
	void (*print) (reiser4_format_ent_t *, aal_stream_t *, uint16_t);
    
	void (*set_len) (reiser4_format_ent_t *, uint64_t);
	void (*set_root) (reiser4_format_ent_t *, uint64_t);
	void (*set_free) (reiser4_format_ent_t *, uint64_t);
	void (*set_stamp) (reiser4_format_ent_t *, uint32_t);
	void (*set_policy) (reiser4_format_ent_t *, rid_t);
	void (*set_height) (reiser4_format_ent_t *, uint16_t);

	/* Return plugin ids for journal, block allocator, oid allocator
	   and node components. */
	rid_t (*journal_pid) (reiser4_format_ent_t *);
	rid_t (*alloc_pid) (reiser4_format_ent_t *);
	rid_t (*oid_pid) (reiser4_format_ent_t *);
	rid_t (*node_pid) (reiser4_format_ent_t *);

	/* Format enumerator function. */
	errno_t (*layout) (reiser4_format_ent_t *, region_func_t, void *);

	/* Basic consistency checks */
	errno_t (*valid) (reiser4_format_ent_t *);

	/* Check format-specific super block for validness. */
	errno_t (*check_struct) (reiser4_format_ent_t *, backup_hint_t *, 
				 format_hint_t *, uint8_t);
	
	/* get the format version. */
	uint32_t (*version) (reiser4_format_ent_t *);
#endif
	/* Returns the key plugin id. */
	rid_t (*key_pid) (reiser4_format_ent_t *);
	
	/* Called during filesystem opening (mounting). It reads format-specific
	   super block and initializes plugins suitable for this format. */
	reiser4_format_ent_t *(*open) (aal_device_t *, uint32_t);
    
	/* Closes opened or created previously filesystem. Frees all assosiated
	   memory. */
	void (*close) (reiser4_format_ent_t *);

	/* Get tree root block number from format. */
	uint64_t (*get_root) (reiser4_format_ent_t *);

	/* Get tree height from format. */
	uint16_t (*get_height) (reiser4_format_ent_t *);

#ifndef ENABLE_MINIMAL
	/* Gets start of the filesystem. */
	uint64_t (*start) (reiser4_format_ent_t *);

	/* Format length in blocks. */
	uint64_t (*get_len) (reiser4_format_ent_t *);

	/* Number of free blocks. */
	uint64_t (*get_free) (reiser4_format_ent_t *);

	/* Return mkfs stamp. */
	uint32_t (*get_stamp) (reiser4_format_ent_t *);

	/* Return policy (tail, extents, etc). */
	rid_t (*get_policy) (reiser4_format_ent_t *);

	/* Returns area where oid data lies in */
	void (*oid_area) (reiser4_format_ent_t *, void **, uint32_t *);
#endif
};

#ifndef ENABLE_MINIMAL
struct reiser4_oid_plug {
	reiser4_plug_t p;
	
	/* Opens oid allocator on passed format entity. */
	reiser4_oid_ent_t *(*open) (reiser4_format_ent_t *);

	/* Closes passed instance of oid allocator */
	void (*close) (reiser4_oid_ent_t *);
    
	/* Creates oid allocator on passed format entity. */
	reiser4_oid_ent_t *(*create) (reiser4_format_ent_t *);

	/* Synchronizes oid allocator */
	errno_t (*sync) (reiser4_oid_ent_t *);

	errno_t (*layout) (reiser4_oid_ent_t *,
			   region_func_t, void *);

	/* Entity state functions. */
	uint32_t (*get_state) (reiser4_oid_ent_t *);
	void (*set_state) (reiser4_oid_ent_t *, uint32_t);

	/* Sets/gets next object id */
	oid_t (*get_next) (reiser4_oid_ent_t *);
	void (*set_next) (reiser4_oid_ent_t *, oid_t);

	/* Gets next object id */
	oid_t (*allocate) (reiser4_oid_ent_t *);

	/* Releases passed object id */
	void (*release) (reiser4_oid_ent_t *, oid_t);
    
	/* Gets/sets the number of used object ids */
	uint64_t (*get_used) (reiser4_oid_ent_t *);
	void (*set_used) (reiser4_oid_ent_t *, uint64_t);
    
	/* Returns the number of free object ids */
	uint64_t (*free) (reiser4_oid_ent_t *);

	/* Prints oid allocator data */
	void (*print) (reiser4_oid_ent_t *, aal_stream_t *, uint16_t);

	/* Makes check for validness */
	errno_t (*valid) (reiser4_oid_ent_t *);
	
	/* Root locality and objectid and lost+found objectid. */
	oid_t (*root_locality) ();
	oid_t (*root_objectid) ();
	oid_t (*lost_objectid) ();
	oid_t (*slink_locality) ();
};

struct reiser4_alloc_plug {
	reiser4_plug_t p;
	
	/* Functions for create and open block allocator. */
	reiser4_alloc_ent_t *(*open) (aal_device_t *, uint32_t, uint64_t);
	reiser4_alloc_ent_t *(*create) (aal_device_t *, uint32_t, uint64_t);

	/* Closes block allocator. */
	void (*close) (reiser4_alloc_ent_t *);

	/* Saves block allocator data to desired device. */
	errno_t (*sync) (reiser4_alloc_ent_t *);

	/* Make dirty and clean functions. */
	uint32_t (*get_state) (reiser4_alloc_ent_t *);
	void (*set_state) (reiser4_alloc_ent_t *, uint32_t);
	
	/* Format pack/unpack methods. */
	errno_t (*pack) (reiser4_alloc_ent_t *, aal_stream_t *);
	reiser4_alloc_ent_t *(*unpack) (aal_device_t *, uint32_t, aal_stream_t *);
	
	/* Assign the bitmap to the block allocator */
	errno_t (*assign) (reiser4_alloc_ent_t *, void *);

	/* Extract block allocator data into passed bitmap */
	errno_t (*extract) (reiser4_alloc_ent_t *, void *);
	
	/* Returns number of used blocks */
	uint64_t (*used) (reiser4_alloc_ent_t *);

	/* Returns number of unused blocks */
	uint64_t (*free) (reiser4_alloc_ent_t *);

	/* Checks blocks allocator on validness */
	errno_t (*valid) (reiser4_alloc_ent_t *);
	
	/* Checks blocks allocator on validness */
	errno_t (*check_struct) (reiser4_alloc_ent_t *, uint8_t mode);

	/* Prints block allocator data */
	void (*print) (reiser4_alloc_ent_t *, aal_stream_t *, uint16_t);

	/* Calls func for each block in block allocator */
	errno_t (*layout) (reiser4_alloc_ent_t *, region_func_t, void *);
	
	/* Checks if passed range of blocks used */
	int (*occupied) (reiser4_alloc_ent_t *, uint64_t, uint64_t);
    	
	/* Checks if passed range of blocks unused */
	int (*available) (reiser4_alloc_ent_t *, uint64_t, uint64_t);

	/* Marks passed block as used */
	errno_t (*occupy) (reiser4_alloc_ent_t *, uint64_t, uint64_t);

	/* Tries to allocate passed amount of blocks */
	uint64_t (*allocate) (reiser4_alloc_ent_t *, uint64_t *, uint64_t);
	
	/* Deallocates passed blocks */
	errno_t (*release) (reiser4_alloc_ent_t *, uint64_t, uint64_t);

	/* Calls func for all not reliable regions. */
	errno_t (*layout_bad) (reiser4_alloc_ent_t *, region_func_t, void *);
	
	/* Calls func for the region the blk lies in. */
	errno_t (*region) (reiser4_alloc_ent_t *, blk_t, region_func_t, void *);
};

struct reiser4_journal_plug {
	reiser4_plug_t p;
	
	/* Opens journal on specified device. */
	reiser4_journal_ent_t *(*open) (aal_device_t *, uint32_t, 
					reiser4_format_ent_t *, 
					reiser4_oid_ent_t *,
					uint64_t, uint64_t);

	/* Creates journal on specified device. */
	reiser4_journal_ent_t *(*create) (aal_device_t *, uint32_t, 
					  reiser4_format_ent_t *, 
					  reiser4_oid_ent_t *, 
					  uint64_t, uint64_t);

	/* Returns the device journal lies on */
	aal_device_t *(*device) (reiser4_journal_ent_t *);
    
	/* Frees journal instance */
	void (*close) (reiser4_journal_ent_t *);

	/* Checks journal metadata on validness */
	errno_t (*valid) (reiser4_journal_ent_t *);
    
	/* Synchronizes journal */
	errno_t (*sync) (reiser4_journal_ent_t *);

	/* Functions for set/get object state (dirty, clean, etc). */
	uint32_t (*get_state) (reiser4_journal_ent_t *);
	void (*set_state) (reiser4_journal_ent_t *, uint32_t);
	
	/* Replays the journal */
	errno_t (*replay) (reiser4_journal_ent_t *);

	/* Prints journal content */
	void (*print) (reiser4_journal_ent_t *, aal_stream_t *, uint16_t);
	
	/* Checks thoroughly the journal structure. */
	errno_t (*check_struct) (reiser4_journal_ent_t *, layout_func_t, void *);

	/* Invalidates the journal. */
	void (*invalidate) (reiser4_journal_ent_t *);
	
	/* Calls func for each block in block allocator. */
	errno_t (*layout) (reiser4_journal_ent_t *, region_func_t, void *);

	/* Pack/unpack the journal blocks. */
	errno_t (*pack) (reiser4_journal_ent_t *, aal_stream_t *);
	reiser4_journal_ent_t *(*unpack) (aal_device_t *, uint32_t, 
				     reiser4_format_ent_t *, 
				     reiser4_oid_ent_t *, 
				     uint64_t, uint64_t, 
				     aal_stream_t *);
};

/* Tail policy plugin operations. */
typedef struct reiser4_policy_plug {
	reiser4_plug_t p;
	
	int (*tails) (uint64_t);
} reiser4_policy_plug_t;

#endif


typedef struct reiser4_core reiser4_core_t;

/* Plugin init() and fini() function types. They are used for calling these
   functions during plugin initialization. */
typedef errno_t (*plug_fini_t) (reiser4_core_t *);
typedef errno_t (*plug_func_t) (reiser4_plug_t *, void *);
typedef reiser4_plug_t *(*plug_init_t) (reiser4_core_t *);

struct reiser4_plug_old {
        /* All possible plugin operations. */
	union {
		reiser4_key_plug_t *key;
		reiser4_item_plug_t *item;
		reiser4_node_plug_t *node;
		reiser4_hash_plug_t *hash;
		reiser4_fibre_plug_t *fibre;
		reiser4_sdext_plug_t *sdext;
		reiser4_object_plug_t *object;
		reiser4_format_plug_t *format;

#ifndef ENABLE_MINIMAL
		reiser4_oid_plug_t *oid;
		reiser4_alloc_plug_t *alloc;
		reiser4_policy_plug_t *policy;
		reiser4_journal_plug_t *journal;
#endif
	} pl;
};

#ifndef ENABLE_MINIMAL
typedef struct reiser4_create_plug {
	reiser4_plug_t p;
	rid_t objid;
} reiser4_create_plug_t;

typedef struct reiser4_cluster_plug {
	reiser4_plug_t p;
	rid_t clsize;
} reiser4_cluster_plug_t;
#endif

/* Macros for dirtying nodes place lie at. */
#define place_mkdirty(place) \
        ((place)->node->block->dirty = 1)

#define place_mkclean(place) \
        ((place)->node->block->dirty = 0)

#define place_isdirty(place) \
        ((place)->node->block->dirty)

typedef struct flow_ops {
	/* Reads data from the tree. */
	int64_t (*read) (tree_entity_t *, trans_hint_t *);

#ifndef ENABLE_MINIMAL
	/* Writes data to tree. */
	int64_t (*write) (tree_entity_t *, trans_hint_t *);

	/* Truncates data from tree. */
	int64_t (*cut) (tree_entity_t *, trans_hint_t *);
	
	/* Convert some particular place to another plugin. */
	errno_t (*convert) (tree_entity_t *, conv_hint_t *);
#endif
} flow_ops_t;

typedef struct tree_ops {
	/* Makes lookup in the tree in order to know where say stat data item of
	   a file realy lies. It is used in all object plugins. */
	lookup_t (*lookup) (tree_entity_t *, lookup_hint_t *, 
			    lookup_bias_t, reiser4_place_t *);

#ifndef ENABLE_MINIMAL
	/* Collisions handler. It takes start place and looks for actual data in
	   collided array. */
	lookup_t (*collision) (tree_entity_t *, reiser4_place_t *, 
			       coll_hint_t *);
	
	/* Inserts item/unit in the tree by calling tree_insert() function, used
	   by all object plugins (dir, file, etc). */
	int64_t (*insert) (tree_entity_t *, reiser4_place_t *,
			   trans_hint_t *, uint8_t);

	/* Removes item/unit from the tree. It is used in all object plugins for
	   modification purposes. */
	errno_t (*remove) (tree_entity_t *, reiser4_place_t *, trans_hint_t *);
	
	/* Update the key in the place and the node itsef. */
	errno_t (*update_key) (tree_entity_t *, reiser4_place_t *, reiser4_key_t *);

	/* Get the safe link locality. */
	uint64_t (*slink_locality) (tree_entity_t *);

	/* increment/decriment the free block count in the format. */
	errno_t (*inc_free) (tree_entity_t *, count_t);
	errno_t (*dec_free) (tree_entity_t *, count_t);
#endif
	/* Returns the next item. */
	errno_t (*next_item) (tree_entity_t *, reiser4_place_t *, 
			      reiser4_place_t *);

	errno_t (*mpressure) (tree_entity_t *);
} tree_ops_t;

typedef struct factory_ops {
	/* Finds plugin by its attributes (type and id). */
	reiser4_plug_t *(*ifind) (rid_t, rid_t);
} factory_ops_t;

#ifdef ENABLE_SYMLINKS
typedef struct object_ops {
	errno_t (*resolve) (tree_entity_t *, char *, 
			    reiser4_key_t *, reiser4_key_t *);
} object_ops_t;
#endif

typedef struct pset_ops {
	/* Obtains the plugin from the profile by its profile index. */
	reiser4_plug_t *(*find) (rid_t, rid_t, int);
#ifndef ENABLE_MINIMAL
	/* Diffs 2 psets & returns what needs to be stored on disk. */
	uint64_t (*build_mask) (tree_entity_t *, reiser4_pset_t *);
#endif
} pset_ops_t;

#ifndef ENABLE_MINIMAL
typedef struct key_ops {
	char *(*print) (reiser4_key_t *, uint16_t);
} key_ops_t;

typedef struct item_ops {
	/* Checks if items mergeable. */
	int (*mergeable) (reiser4_place_t *, reiser4_place_t *);
} item_ops_t;
#endif

/* This structure is passed to all plugins in initialization time and used for
   access libreiser4 factories. */
struct reiser4_core {
	flow_ops_t flow_ops;
	tree_ops_t tree_ops;
	factory_ops_t factory_ops;
	pset_ops_t pset_ops;

#ifdef ENABLE_SYMLINKS
	object_ops_t object_ops;
#endif

#ifndef ENABLE_MINIMAL
	key_ops_t key_ops;
	item_ops_t item_ops;
#endif
};

#define print_key(core, key)						\
	((core)->key_ops.print((key), PO_DEFAULT))

#define print_inode(core, key)						\
	((core)->key_ops.print((key), PO_INODE))

#define ident_equal(ident1, ident2)					\
	((ident1)->type == (ident2)->type &&				\
	 (ident1)->id == (ident2)->id)

#define plug_equal(plug1, plug2)					\
        ident_equal(&(((reiser4_plug_t *)(plug1))->id),			\
		    &(((reiser4_plug_t *)(plug2))->id))	

/* Checks if @method is implemented in @plug and calls it. */
#define plugcall(plug, method, ...) ({					\
        aal_assert("Method \""#method"\" isn't implemented "		\
		   "in "#plug"", (plug)->method != NULL);		\
        (plug)->method(__VA_ARGS__);					\
})

/* Checks if @method is implemented in @obj and calls it, passing @obj 
   as the 1st parameter. */
#define entcall(obj, method, ...) ({					\
        aal_assert("Method \""#method"\" isn't implemented in "		\
		   ""#obj"->plug->plug", (obj)->plug->method != NULL);	\
        (obj)->plug->method(obj, ##__VA_ARGS__);			\
})

/* Checks if @method is implemented in @obj->plug and calls it, passing 
   @obj as the 1st parameter. */
#define objcall(obj, method, ...) ({					\
        aal_assert("Method \""#method"\" isn't implemented in "		\
		   ""#obj"->plug", (obj)->plug->method != NULL);	\
        (obj)->plug->method(obj, ##__VA_ARGS__);			\
})

/* Checks if @method is implemented in @obj->ent.plug and calls it,
   passing &obj->ent as the first parameter. */
#define reiser4call(obj, method, ...) ({				\
        aal_assert("Method \""#method"\" isn't implemented in "#obj""	\
		   "->ent->plug", (obj)->ent->plug->method != NULL);	\
        (obj)->ent->plug->method((obj)->ent, ##__VA_ARGS__);		\
})
#endif