3 * Revision 2.6 1999/09/11 16:45:50 Michiel
4 * Bug (1024 byte blok supprort) in AccessTest fixed
6 * Revision 2.5 1999/07/28 09:24:56 Michiel
7 * Unneeded anodeblock searches removed
9 * Revision 2.4 1999/05/07 16:49:00 Michiel
12 * Revision 2.3 1999/05/07 09:31:31 Michiel
15 * Revision 2.2 1999/05/04 04:27:13 Michiel
16 * debugged upto buildrext
18 * Revision 2.1 1999/04/30 12:17:58 Michiel
19 * Accepts OK disks, bitmapfix and hardlink fix works
21 * Revision 1.2 1999/04/22 15:26:49 Michiel
25 #include <exec/ports.h>
31 /**************************************
32 * Non-checking functions for access to structures on PFS3 disks
33 **************************************/
35 /* get a buildblock from the buildblock cache
37 cachedblock_t
*GetBuildBlock(uint16 bloktype
, uint32 seqnr
)
39 struct buildblock
*bbl
;
41 for (bbl
= HeadOf(&volume
.buildblocks
); bbl
->next
; bbl
= bbl
->next
)
43 if (bbl
->b
.data
->id
== bloktype
&&
44 bbl
->b
.data
->indexblock
.seqnr
== seqnr
)
54 * anything, except deldir, root, boot, dir and rext
56 error_t
GetResBlock(cachedblock_t
*blok
, uint16 bloktype
, uint32 seqnr
, bool fix
)
58 cachedblock_t blk
, *t
;
59 uint32 blknr
, *bp
= NULL
, index
, offset
;
60 error_t error
= e_none
;
62 // controleer build block lijst
63 t
= GetBuildBlock(bloktype
, seqnr
);
66 blok
->blocknr
= t
->blocknr
;
68 *blok
->data
= *t
->data
;
72 blk
.data
= calloc(1, SIZEOF_RESBLOCK
);
73 index
= seqnr
/INDEX_PER_BLOCK
;
74 offset
= seqnr
%INDEX_PER_BLOCK
;
82 return e_number_error
;
85 bp
= &rext
.data
->superindex
[seqnr
];
90 adderror("superindex block not found");
91 error
= RepairSuperIndex(bp
, seqnr
);
96 volume
.writeblock((cachedblock_t
*)&rext
);
105 bp
= &rbl
->idx
.large
.bitmapindex
[seqnr
];
110 adderror("bitmapindex block not found");
111 error
= RepairBitmapIndex(bp
, seqnr
);
115 c_WriteBlock((uint8
*)rbl
, ROOTBLOCK
+ volume
.firstblock
, volume
.blocksize
);
122 if (rbl
->options
& MODE_SUPERINDEX
)
124 error
= GetResBlock(&blk
, SBLKID
, index
, fix
);
131 bp
= &blk
.data
->indexblock
.index
[offset
];
135 bp
= &rbl
->idx
.small
.indexblocks
[seqnr
];
141 adderror("anodeindex block not found");
142 error
= RepairAnodeIndex(bp
, seqnr
);
147 /* the anodebitmap, which is made per aib,
151 if (rbl
->options
& MODE_SUPERINDEX
)
152 volume
.writeblock((cachedblock_t
*)&blk
);
154 c_WriteBlock((uint8
*)rbl
, ROOTBLOCK
+ volume
.firstblock
, volume
.blocksize
);
162 error
= GetResBlock(&blk
, IBLKID
, index
, fix
);
169 bp
= &blk
.data
->indexblock
.index
[offset
];
174 adderror("anode block not found");
175 // RepairAnodeBlock already called from RepairAnodeTree
176 // Pointless to call it again here.
177 //if (error = RepairAnodeBlock(bp, seqnr))
180 // volume.writeblock((cachedblock_t *)&blk);
187 error
= GetResBlock(&blk
, BMIBLKID
, index
, fix
);
194 bp
= &blk
.data
->indexblock
.index
[offset
];
199 adderror("bitmap block not found");
200 error
= RepairBitmapBlock(bp
, seqnr
);
204 volume
.writeblock((cachedblock_t
*)&blk
);
216 error
= volume
.getblock(blok
, blknr
);
223 static c_anodeblock_t tablk
= { 0 };
224 static ULONG tanodedata
[MAXRESBLOCKSIZE
/ 4];
225 static anodeblock_t
*tanodeblk
= (anodeblock_t
*)tanodedata
;
227 bool GetAnode(canode_t
*anode
, uint32 anodenr
, bool fix
)
229 anodenr_t
*split
= (anodenr_t
*)&anodenr
;
231 if (!(tablk
.data
&& tanodeblk
->seqnr
== split
->seqnr
))
233 tablk
.data
= tanodeblk
;
234 if (GetResBlock((cachedblock_t
*)&tablk
, ABLKID
, split
->seqnr
, fix
))
241 if (split
->offset
> ANODES_PER_BLOCK
)
245 anode
->clustersize
= tablk
.data
->nodes
[split
->offset
].clustersize
;
246 anode
->blocknr
= tablk
.data
->nodes
[split
->offset
].blocknr
;
247 anode
->next
= tablk
.data
->nodes
[split
->offset
].next
;
251 bool SaveAnode(canode_t
*anode
, uint32 nr
)
253 anodenr_t
*split
= (anodenr_t
*)&nr
;
255 uint32 buffer
[MAXRESBLOCKSIZE
/4];
257 tablk
.data
= NULL
; /* kill anode read cache */
258 ablk
.data
= (anodeblock_t
*)buffer
;
259 if (GetResBlock((cachedblock_t
*)&ablk
, ABLKID
, split
->seqnr
, false))
262 if (split
->offset
> ANODES_PER_BLOCK
)
265 ablk
.data
->nodes
[split
->offset
].clustersize
= anode
->clustersize
;
266 ablk
.data
->nodes
[split
->offset
].blocknr
= anode
->blocknr
;
267 ablk
.data
->nodes
[split
->offset
].next
= anode
->next
;
268 volume
.writeblock((cachedblock_t
*)&ablk
);
272 ULONG
GetDEFileSize(struct direntry
*direntry
, struct extrafields
*extra
, ULONG
*high
)
275 if (rbl
->options
& MODE_LARGEFILE
) {
276 *high
= extra
->fsizex
;
277 return direntry
->fsize
;
279 return direntry
->fsize
;
282 ULONG
GetDDFileSize(struct deldirentry
*dde
, ULONG
*high
)
285 if ((rbl
->options
& MODE_LARGEFILE
) && dde
->filename
[0] <= DELENTRYFNSIZE
) {