3 * Revision 1.21 1999/06/13 16:46:01 Michiel
4 * MAXNUMRESERVED raised
6 * Revision 1.20 1999/05/14 11:31:34 Michiel
7 * Long filename support implemented; bugfixes
9 * Revision 1.19 1999/03/09 10:40:11 Michiel
10 * Deldir extension and bitwise reserved roving
12 * Revision 1.18 1998/09/27 11:26:37 Michiel
13 * MAXNUMRESERVED increased
16 * Revision 1.17 1998/09/03 07:12:14 Michiel
18 * bugfixes 118, 121, 123 and superindexblocks and td64 support
20 * Revision 1.16 1998/08/05 00:33:23 Michiel
21 * MAXDISKSIZE, ID_MUPFS_DISK added
23 * Revision 1.15 1998/05/29 19:13:27 Michiel
24 * Wrongly defined ID_PFS2_DISK
26 * Revision 1.14 1998/05/27 22:35:51 Michiel
29 * Revision 1.12 1998/05/22 22:59:58 Michiel
32 * Revision 1.11 1998/05/22 21:00:22 Michiel
33 * Added anode roving pointer (overdue checkin)
35 * Revision 1.10 1995/12/29 11:01:53 Michiel
36 * rollover extrafields added
37 * reserved roving stored in rootblockextension
39 * Revision 1.9 1995/11/15 15:38:27 Michiel
40 * rootblock extension defined
41 * cachedblock 'done' field removed
43 * Revision 1.8 1995/11/07 17:31:22 Michiel
44 * cachedblock changeflag and done now are bytes (instead of words)
46 * Revision 1.7 1995/08/04 04:15:30 Michiel
47 * added DELENTRY_PROT_AND_MASK and DELENTRY_PROT_OR_MASK
48 * added disksize (MODE_SIZEFIELD) to rootblock
50 * Revision 1.6 1995/07/28 08:26:55 Michiel
51 * FNSIZE replaced by PATHSIZE and FILENAMESIZE
53 * Revision 1.5 1995/07/21 06:42:07 Michiel
56 * Revision 1.4 1995/07/11 09:24:38 Michiel
59 * Revision 1.3 1995/07/10 15:17:13 Michiel
60 * ID_MUAF_DISK and ID_AFS_DISK added
62 * Revision 1.2 1995/02/28 18:29:28 Michiel
65 * Revision 1.1 1995/02/15 16:46:45 Michiel
73 #ifndef DOS_DOSEXTENS_H
74 #include <dos/dosextens.h>
76 #ifndef DEVICES_TRACKDISK_H
77 #include <devices/trackdisk.h>
80 #include <proto/exec.h>
83 #include <proto/dos.h>
89 #if defined(__GNUC__) || defined(__VBCC__)
90 /* Force SAS/C compatible alignment rules for all these structures */
96 LONG disktype
; /* PFS\1 */
100 typedef struct rootblock
103 ULONG options
; /* bit 0 is harddisk mode */
104 ULONG datestamp
; /* current datestamp */
105 UWORD creationday
; /* days since Jan. 1, 1978 (like ADOS; WORD instead of LONG) */
106 UWORD creationminute
; /* minutes past modnight */
107 UWORD creationtick
; /* ticks past minute */
108 UWORD protection
; /* protection bits (ala ADOS) */
109 UBYTE diskname
[32]; /* disk label (pascal string) */
110 ULONG lastreserved
; /* reserved area. sector number of last reserved block */
111 ULONG firstreserved
; /* sector number of first reserved block */
112 ULONG reserved_free
; /* number of reserved blocks (blksize blocks) free */
113 UWORD reserved_blksize
; /* size of reserved blocks in bytes */
114 UWORD rblkcluster
; /* number of sectors in rootblock, including bitmap */
115 ULONG blocksfree
; /* blocks free */
116 ULONG alwaysfree
; /* minimum number of blocks free */
117 ULONG roving_ptr
; /* current LONG bitmapfield nr for allocation */
118 ULONG deldir
; /* deldir location (<= 17.8) */
119 ULONG disksize
; /* disksize in sectors */
120 ULONG extension
; /* rootblock extension (16.4) */
124 UWORD anodeblocks
[208]; /* SMALL: 200*84 = 16800 anodes */
127 ULONG bitmapindex
[5]; /* 5 bitmap indexblocks with 253 bitmap blocks each */
128 ULONG indexblocks
[99]; /* 99 index blocks with 253 anode blocks each */
132 ULONG bitmapindex
[104]; /* 104 bitmap indexblocks = max 104 G */
138 /* structure for both normal as reserved bitmap
139 * normal: normal clustersize
140 * reserved: directly behind rootblock. As long as necessary
142 typedef struct bitmapblock
144 UWORD id
; /* BM (bitmap block) */
148 ULONG bitmap
[0]; /* the bitmap. */
151 #if defined(__GNUC__) || defined(__VBCC__)
155 typedef struct cbitmapblock
157 struct cbitmapblock
*next
;
158 struct cbitmapblock
*prev
;
159 struct volumedata
*volume
;
165 struct bitmapblock blk
;
168 #if defined(__GNUC__) || defined(__VBCC__)
172 typedef struct indexblock
174 UWORD id
; /* AI or BI (anode- bitmap index) */
178 LONG index
[0]; /* the indices */
181 #if defined(__GNUC__) || defined(__VBCC__)
185 typedef struct cindexblock
187 struct cindexblock
*next
;
188 struct cindexblock
*prev
;
189 struct volumedata
*volume
;
195 struct indexblock blk
;
198 #if defined(__GNUC__) || defined(__VBCC__)
215 typedef struct anodeblock
222 struct anode nodes
[0];
225 #if defined(__GNUC__) || defined(__VBCC__)
231 struct canodeblock
*next
; /* for cache list */
232 struct canodeblock
*prev
;
233 struct volumedata
*volume
;
234 ULONG blocknr
; /* for already cached check */
236 UWORD used
; /* locknr */
237 UBYTE changeflag
; /* dirty flag */
239 struct anodeblock blk
;
242 #if defined(__GNUC__) || defined(__VBCC__)
246 // Cached Allocation NODE
247 typedef struct canode
249 ULONG clustersize
; // number of blocks in a cluster
250 ULONG blocknr
; // the block number
251 ULONG next
; // next anode (anodenummer), 0 = eof
252 ULONG nr
; // the anodenr
261 ULONG anodenr
; /* anodenr belonging to this directory (points to FIRST block of dir) */
262 ULONG parent
; /* parent */
263 UBYTE entries
[0]; /* entries */
266 #if defined(__GNUC__) || defined(__VBCC__)
272 struct cdirblock
*next
; // volume cachelist
273 struct cdirblock
*prev
;
274 struct volumedata
*volume
;
275 ULONG blocknr
; // voor already cached check
278 UBYTE changeflag
; // size is word, could be byte
285 struct lru_cdirblock
*next
;
286 struct lru_cdirblock
*prev
;
287 struct cdirblock cblk
;
290 #if defined(__GNUC__) || defined(__VBCC__)
296 UBYTE next
; /* sizeof direntry */
297 BYTE type
; /* dir, file, link etc */
298 ULONG anode
; /* anode number */
299 ULONG fsize
; /* sizeof file */
300 UWORD creationday
; /* days since Jan. 1, 1978 (like ADOS; WORD instead of LONG) */
301 UWORD creationminute
; /* minutes past modnight */
302 UWORD creationtick
; /* ticks past minute */
303 UBYTE protection
; /* protection bits (like DOS) */
304 UBYTE nlength
; /* lenght of filename */
305 UBYTE startofname
; /* filename, followed by filenote length & filenote */
306 UBYTE pad
; /* make size even */
311 ULONG link
; /* link anodenr */
312 UWORD uid
; /* user id */
313 UWORD gid
; /* group id */
314 ULONG prot
; /* byte 1-3 of protection */
316 ULONG virtualsize
; /* virtual rollover filesize in bytes (as shown by Examine()) */
317 ULONG rollpointer
; /* current start of file AND end of file pointer */
318 // extended file size
319 UWORD fsizex
; /* extended bits 32-47 of direntry.fsize */
322 #if defined(__GNUC__) || defined(__VBCC__)
331 #if defined(__GNUC__) || defined(__VBCC__)
337 ULONG anodenr
; /* anodenr */
338 ULONG fsize
; /* size of file */
339 UWORD creationday
; /* datestamp */
340 UWORD creationminute
;
342 UBYTE filename
[16]; /* filename; filling up to 30 chars */
343 // was previously filename[18]
344 // now last two bytes used for extended file size
345 UWORD fsizex
; /* extended bits 32-47 of fsize */
355 UWORD not_used_3
; /* roving in older versions (<17.9) */
356 UWORD uid
; /* user id */
357 UWORD gid
; /* group id */
360 UWORD creationminute
;
362 struct deldirentry entries
[0]; /* 31 entries */
365 #if defined(__GNUC__) || defined(__VBCC__)
371 struct cdeldirblock
*next
; /* currently not used */
372 struct cdeldirblock
*prev
; /* currently not used */
373 struct volumedata
*volume
;
379 struct deldirblock blk
;
386 #if defined(__GNUC__) || defined(__VBCC__)
392 ULONG operation_id
; /* which operation is postponed */
393 ULONG argument1
; /* operation arguments, e.g. number of blocks */
398 struct rootblockextension
400 UWORD id
; /* id ('EX') */
404 ULONG pfs2version
; /* pfs2 revision under which the disk was formatted */
405 UWORD root_date
[3]; /* root directory datestamp */
406 UWORD volume_date
[3]; /* volume datestamp */
407 struct postponed_op tobedone
; /* postponed operation (curr. only delete) */
408 ULONG reserved_roving
; /* reserved roving pointer */
409 UWORD rovingbit
; /* bitnr in rootblock->roving_ptr bitmap field */
410 UWORD curranseqnr
; /* anodeallocation roving pointer */
411 UWORD deldirroving
; /* deldir roving pointer */
412 UWORD deldirsize
; /* size of deldir */
413 UWORD fnsize
; /* filename size (18.1) */
415 ULONG superindex
[16]; /* MODE_SUPERINDEX only. */
416 UWORD dd_uid
; /* deldir user id (17.9) */
417 UWORD dd_gid
; /* deldir group id */
418 ULONG dd_protection
; /* deldir protection */
419 UWORD dd_creationday
; /* deldir datestamp */
420 UWORD dd_creationminute
;
421 UWORD dd_creationtick
;
423 ULONG deldir
[32]; /* 32 deldir blocks */
426 #if defined(__GNUC__) || defined(__VBCC__)
430 struct crootblockextension
432 struct crootblockextension
*next
; /* currently not used */
433 struct crootblockextension
*prev
; /* currently not used */
434 struct volumedata
*volume
;
440 struct rootblockextension blk
;
443 typedef struct crootblockextension crootblockextension_t
;
445 /* postponed operations operation_id's */
446 #define PP_FREEBLOCKS_FREE 1
447 #define PP_FREEBLOCKS_KEEP 2
448 #define PP_FREEANODECHAIN 3
453 /* Cached blocks in general
457 struct cachedblock
*next
;
458 struct cachedblock
*prev
;
459 struct volumedata
*volume
;
460 ULONG blocknr
; // the current (new) blocknumber of the block
461 ULONG oldblocknr
; // the blocknr before reallocation. NULL if not reallocated.
462 UWORD used
; // block locked if used == g->locknr
463 UBYTE changeflag
; // dirtyflag
464 UBYTE dummy
; // pad to make offset even
465 UBYTE data
[0]; // the datablock;
468 struct lru_cachedblock
470 struct lru_cachedblock
*next
;
471 struct lru_cachedblock
*prev
;
472 struct cachedblock cblk
;
476 /* max length of filename, diskname and comment
477 * FNSIZE is 108 for compatibilty. Used for searching
482 #define FILENAMESIZE (g->fnsize)
485 #define MAX_ENTRYSIZE (sizeof(struct direntry) + FNSIZE + CMSIZE + 34)
488 #define MAXSMALLBITMAPINDEX 4
489 #define MAXBITMAPINDEX 103
490 // was 28576. was 119837. Nu max reserved bitmap 256K.
491 #define MAXNUMRESERVED (4096 + 255*1024*8)
493 #define MAXSMALLINDEXNR 98
495 // last two bytes used for extended file size
496 #define DELENTRYFNSIZE 16
498 #define DELENTRYFNSIZE 18
500 /* maximum disksize in sectors, limited by number of bitmapindexblocks
501 * smalldisk = 10.241.440 blocks of 512 byte = 5G
502 * normaldisk = 213.021.952 blocks of 512 byte = 104G
503 * 2k reserved blocks = 104*509*509*32 blocks of 512 byte = 411G
504 * 4k reserved blocks = 1,6T
506 #define MAXSMALLDISK (5*253*253*32)
507 #define MAXDISKSIZE1K (104*253*253*32)
508 #define MAXDISKSIZE2K (104*509*509*32)
509 #define MAXDISKSIZE4K ((ULONG)104*1021*1021*32)
510 #define MAXDISKSIZE MAXDISKSIZE4K
512 /* disk id 'PFS\1' */
514 //#define ID_PFS_DISK (0x42455441L) /* 'BETA' */
516 #define ID_PFS_DISK (0x50465301L) /* 'PFS\1' */
518 #define ID_BUSY (0x42555359L) /* 'BUSY' */
520 #define ID_MUAF_DISK (0x6d754146L) /* 'muAF' */
521 #define ID_MUPFS_DISK (0x6d755046L) /* 'muPF' */
522 #define ID_AFS_DISK (0x41465301L) /* 'AFS\1' */
523 #define ID_PFS2_DISK (0x50465302L) /* 'PFS\2' */
524 #define ID_AFS_USER_TEST (0x41465355L) /* 'AFSU' */
527 #define DBLKID 0x4442
528 #define ABLKID 0x4142
529 #define IBLKID 0x4942
530 #define BMBLKID 0x424D
531 #define BMIBLKID 0x4D49
532 #define DELDIRID 0x4444
533 #define EXTENSIONID 0x4558 /* 'EX' */
534 #define SBLKID 0x5342 /* 'SB' */
536 /* macros on cachedblocks */
537 #define IsDirBlock(blk) (((UWORD *)(blk->data))[0] == DBLKID)
538 #define IsAnodeBlock(blk) (((UWORD *)(blk->data))[0] == ABLKID)
539 #define IsIndexBlock(blk) (((UWORD *)(blk->data))[0] == IBLKID)
540 #define IsBitmapBlock(blk) (((UWORD *)(blk->data))[0] == BMBLKID)
541 #define IsBitmapIndexBlock(blk) (((UWORD *)(blk->data))[0] == BMIBLKID)
542 #define IsDeldir(blk) (((UWORD *)(blk->data))[0] == DELDIRID)
543 #define IsSuperBlock(blk) (((UWORD *)(blk->data))[0] == SBLKID)
545 /* size of reserved blocks in bytes and blocks
546 * place you can find rootblock
548 #define SIZEOF_RESBLOCK (g->rootblock->reserved_blksize)
549 #define SIZEOF_CACHEDBLOCK (sizeof(struct cachedblock) + SIZEOF_RESBLOCK)
550 #define SIZEOF_LRUBLOCK (sizeof(struct lru_cachedblock) + SIZEOF_RESBLOCK)
551 #define RESCLUSTER (g->currentvolume->rescluster)
556 /* Longs per bitmapblock */
557 #define LONGS_PER_BMB ((g->rootblock->reserved_blksize/4)-3)
559 /* get filenote from directory entry */
560 #define FILENOTE(de) ((UBYTE*)(&((de)->startofname) + (de)->nlength))
562 /* get next directory entry */
563 #define NEXTENTRY(de) ((struct direntry*)((UBYTE*)(de) + (de)->next))
564 #define DB_HEADSPACE (sizeof(struct dirblock))
565 #define DB_ENTRYSPACE (SIZEOF_RESBLOCK - sizeof(struct dirblock))
568 #define MODE_HARDDISK 1
569 #define MODE_SPLITTED_ANODES 2
570 #define MODE_DIR_EXTENSION 4
571 #define MODE_DELDIR 8
572 #define MODE_SIZEFIELD 16
573 // rootblock extension
574 #define MODE_EXTENSION 32
575 // if enabled the datestamp was on at format time (!)
576 #define MODE_DATESTAMP 64
577 #define MODE_SUPERINDEX 128
578 #define MODE_SUPERDELDIR 256
579 #define MODE_EXTROVING 512
580 #define MODE_LONGFN 1024
581 #define MODE_LARGEFILE 2048
583 /* direntry macros */
584 // comment: de is struct direntry *
585 #define COMMENT(de) ((UBYTE*)(&((de)->startofname) + (de)->nlength))
586 /* DIRENTRYNAME: DSTR of name. */
587 #define DIRENTRYNAME(de) ((UBYTE*)(&(de->nlength)))
588 // get a pointer to the next direntry; de = struct direntry *
589 #define NEXTENTRY(de) ((struct direntry*)((UBYTE*)(de) + (de)->next))
590 // get first direntry; blok is dirblock
591 #define FIRSTENTRY(blok) ((struct direntry*)((blok)->blk.entries))
592 #define ENTRYLEN(de, comment) ((sizeof(struct direntry) + (de)->nlength + strlen(comment))&0xfffe)
595 #define DELENTRY_SEP '@'
596 #define DELENTRY_PROT 0x0005
597 #define DELENTRY_PROT_AND_MASK 0xaa0f
598 #define DELENTRY_PROT_OR_MASK 0x0005
599 /* maximum number of entries per block, max deldirblock seqnr */
600 #define DELENTRIES_PER_BLOCK 31
605 #define ST_ROLLOVERFILE -16
608 /* predefined anodes */
610 #define ANODE_RESERVED_1 1 // not used by MODE_BIG
611 #define ANODE_RESERVED_2 2 // not used by MODE_BIG
612 #define ANODE_RESERVED_3 3 // not used by MODE_BIG
613 #define ANODE_BADBLOCKS 4 // not used yet
614 #define ANODE_ROOTDIR 5
615 #define ANODE_USERFIRST 6
617 /* Max size reported in DOS ULONG size fields */
618 #define MAXFILESIZE32 0x7fffffff
620 #endif /* _BLOCKS_H */