revert between 56095 -> 55830 in arch
[AROS.git] / rom / filesys / SFS / FS / blockstructure.h
bloba3440fb94d2fa7de185422613652c9c73b0790f5
1 #ifndef _BLOCKSTRUCTURE_H
2 #define _BLOCKSTRUCTURE_H
4 #include <exec/types.h>
6 /* a BLCK is a block number. Blocksize in bytes = SectorSize * SectorsPerBlock.
8 BLCK pointers are used throughout the filesystem. All structures which
9 require to associate themselves with another structure do so using BLCK
10 pointers. Byte pointers are not used. */
12 typedef ULONG BLCK;
13 typedef BLCK BLCKn;
16 /* Below is the standard block header. This header is found before EVERY
17 type of block used in the filesystem, except data blocks.
19 The id field is used to check if the block is of the correct type when
20 it is being referred to using a BLCK pointer.
22 The checksum field is the SUM of all LONGs in a block plus one, and then
23 negated. When applying a checksum the checksum field itself should be
24 set to zero. To check to see if the checksum is okay, the sum of all
25 longs in a block should be zero.
27 The ownblock BLCK pointer points to the block itself. This field is an
28 extra safety check to ensure we are using a valid block. */
30 struct fsBlockHeader {
31 ULONG id; /* 4 character id string of this block */
32 ULONG be_checksum; /* The checksum */
33 BLCK be_ownblock; /* The blocknumber of the block this block is stored at */
38 /* Now follows the structure of the Boot block. The Boot block is always
39 located at block offset 0. It contains only a version number at the
40 moment to identify the block structure of the disk. */
43 struct fsBootBlock {
44 struct fsBlockHeader bheader;
46 UWORD version; // Version number of the filesystem block structure
50 #define STRUCTURE_VERSION (3)
54 /* The fsRootInfo structure has all kinds of information about the format
55 of the disk. */
57 struct fsRootInfo {
58 ULONG be_deletedblocks; /* Amount in blocks which deleted files consume. */
59 ULONG be_deletedfiles; /* Number of deleted files in recycled. */
60 ULONG be_freeblocks; /* Cached number of free blocks on disk. */
62 ULONG be_datecreated;
64 BLCK be_lastallocatedblock; /* Block which was most recently allocated */
65 BLCK be_lastallocatedadminspace; /* AdminSpaceContainer which most recently was used to allocate a block */
66 ULONG be_lastallocatedextentnode; /* ExtentNode which was most recently created */
67 ULONG be_lastallocatedobjectnode; /* ObjectNode which was most recently created */
69 BLCK be_rovingpointer;
74 /* An SFS disk has two Root blocks, one located at the start of
75 the partition and one at the end. On startup the fs will check
76 both Roots to see if it is a valid SFS disk. If either one is
77 missing SFS can still continue.
79 A Root block could be missing on purpose. For example, if you
80 extend the partition at the end (adding a few MB's) then SFS
81 can detect this with the information stored in the Root block
82 located at the beginning (since only the end-offset has changed).
83 Same goes for the other way around, as long as you don't change
84 start and end point at the same time.
86 When a Root block is missing because the partition has been
87 made a bit larger, then SFS will in the future be able to
88 'resize' itself without re-formatting the disk.
90 Note: ownblock pointers won't be correct anymore when start of
91 partition has changed... */
93 struct fsRootBlock {
94 struct fsBlockHeader bheader;
96 UWORD be_version; /* Version number of the filesystem block structure */
97 UWORD be_sequencenumber; /* The Root with the highest sequencenumber is valid */
99 ULONG be_datecreated; /* Creation date (when first formatted). Cannot be changed. */
100 UBYTE bits; /* various settings, see defines below. */
101 UBYTE pad1;
102 UWORD be_pad2;
104 ULONG be_reserved1[2];
106 ULONG be_firstbyteh; /* The first byte of our partition from the start of the */
107 ULONG be_firstbyte; /* disk. firstbyteh = upper 32 bits, firstbyte = lower 32 bits. */
109 ULONG be_lastbyteh; /* The last byte of our partition, excluding this one. */
110 ULONG be_lastbyte;
112 BLCK be_totalblocks; /* size of this partition in blocks */
113 ULONG be_blocksize; /* blocksize used */
115 ULONG be_reserved2[2];
116 ULONG be_reserved3[8];
118 BLCK be_bitmapbase; /* location of the bitmap */
119 BLCK be_adminspacecontainer; /* location of first adminspace container */
120 BLCK be_rootobjectcontainer; /* location of the root objectcontainer */
121 BLCK be_extentbnoderoot; /* location of the root of the extentbnode B-tree */
122 BLCK be_objectnoderoot; /* location of the root of the objectnode tree */
124 ULONG be_reserved4[3];
127 #define ROOTBITS_CASESENSITIVE (128) /* When set, filesystem names are treated case
128 insensitive. */
129 #define ROOTBITS_RECYCLED (64) /* When set, files being deleted will first be
130 moved to the Recycled directory. */
132 struct fsExtentBNode {
133 ULONG be_key; /* data! */
134 ULONG be_next;
135 ULONG be_prev;
136 UWORD be_blocks; /* The size in blocks of the region this Extent controls */
137 } __attribute__((packed));
139 #endif // _BLOCKSTRUCTURE_H