2 * This file forms part of PFS3 (Professional File System 3)
3 * Written by Michiel Pelt
12 #include "exec/ports.h"
13 #endif /* EXEC_PORTS_H */
15 #if defined(__GNUC__) || defined(__VBCC__)
16 /* Force SAS/C compatible alignment rules for all these structures */
20 /****************************************************************************/
21 /* PFS specific actions (packets) */
22 /****************************************************************************/
24 #define ACTION_SLEEP 2200
25 #define ACTION_UPDATE_ANODE 2201
26 #define ACTION_PFS_INFO 2202
27 #define ACTION_PFS_CONFIG 2203
28 #define ACTION_REMOVE_DIRENTRY 2204
29 #define ACTION_CREATE_ROLLOVER 2205
30 #define ACTION_SET_ROLLOVER 2206
31 #define ACTION_IS_PFS2 2211
32 #define ACTION_ADD_IDLE_SIGNAL 2220
33 #define ACTION_SET_DELDIR 2221
34 #define ACTION_SET_FNSIZE 2222
36 /****************************************************************************/
38 /****************************************************************************/
40 typedef struct bootblock
42 LONG disktype
; /* PFS\1 */
46 typedef struct rootblock
49 ULONG options
; /* bit 0 is harddisk mode */
51 UWORD creationday
; /* days since Jan. 1, 1978 (like ADOS; WORD instead of LONG) */
52 UWORD creationminute
; /* minutes past midnight */
53 UWORD creationtick
; /* ticks past minute */
54 UWORD protection
; /* protection bits (ala ADOS) */
55 UBYTE diskname
[32]; /* disk label (pascal string) */
56 ULONG lastreserved
; /* reserved area. blocknumbers */
58 ULONG reserved_free
; /* number of reserved blocks (blksize blocks) free */
59 UWORD reserved_blksize
; /* size of reserved blocks in bytes */
60 UWORD rblkcluster
; /* number of blocks in rootblock, including bitmap */
61 ULONG blocksfree
; /* blocks free */
62 ULONG alwaysfree
; /* minimum number of blocks free */
63 ULONG roving_ptr
; /* current LONG bitmapfield nr for allocation */
64 ULONG deldir
; /* (before 4.3) deldir location */
65 ULONG disksize
; /* disksize in sectors */
66 ULONG extension
; /* rootblock extension */
72 ULONG bitmapindex
[5]; /* 5 bitmap indexblocks */
73 ULONG indexblocks
[99]; /* 99 indexblocks */
77 ULONG bitmapindex
[104]; /* 104 bitmap indexblock */
83 typedef struct rootblockextension
85 UWORD id
; /* id ('EX') */
89 ULONG pfs2version
; /* pfs2 format revision */
90 UWORD root_date
[3]; /* root directory datestamp */
91 UWORD volume_date
[3]; /* volume datestamp */
92 ULONG postponed_op
[4]; /* postponed operation (private) */
93 ULONG reserved_roving
; /* reserved roving pointer */
94 UWORD rovingbit
; /* bitnr in rootblock->roving_ptr field */
95 UWORD curranseqnr
; /* anode allocation roving pointer */
96 UWORD deldirroving
; /* (5.1) deldir roving pointer */
97 UWORD deldirsize
; /* (5.1) size of deldir in blocks, 0 is disabled */
98 UWORD fnsize
; /* (5.1) filename size */
100 ULONG superindex
[16]; /* (4.2) MODE_SUPERINDEX only */
101 UWORD dd_uid
; /* (5.1) deldir user id (17.9) */
102 UWORD dd_gid
; /* (5.1) deldir group id */
103 ULONG dd_protection
; /* (5.1) deldir protection */
104 UWORD dd_creationday
; /* (5.1) deldir datestamp */
105 UWORD dd_creationminute
;
106 UWORD dd_creationtick
;
108 ULONG deldir
[32]; /* (5.1) 32 deldir blocks */
109 ULONG not_used_4
[188];
112 /* structure for both normal as reserved bitmap
113 * normal: normal clustersize
114 * reserved: directly behind rootblock. As long as necessary.
116 typedef struct bitmapblock
118 UWORD id
; /* 'BM' (bitmap block) */
122 ULONG bitmap
[253]; /* the bitmap. */
125 typedef struct indexblock
127 UWORD id
; /* 'AI', 'BI', or 'SB' */
131 LONG index
[253]; /* the indices */
147 typedef struct anodeblock
154 struct anode nodes
[84];
157 typedef struct dirblock
163 ULONG anodenr
; /* anodenr belonging to this directory (points to FIRST block of dir) */
164 ULONG parent
; /* parent */
165 UBYTE entries
[0]; /* entries */
170 UBYTE next
; /* sizeof direntry */
171 BYTE type
; /* dir, file, link etc */
172 ULONG anode
; /* anode nummer */
173 ULONG fsize
; /* sizeof file */
174 UWORD creationday
; /* days since Jan. 1, 1978 (like ADOS; WORD instead of LONG) */
175 UWORD creationminute
; /* minutes past modnight */
176 UWORD creationtick
; /* ticks past minute */
177 UBYTE protection
; /* protection bits (like DOS) */
178 UBYTE nlength
; /* lenght of filename */
179 UBYTE startofname
; /* filename, followed by filenote length & filenote */
180 UBYTE pad
; /* make size even */
185 ULONG link
; /* link anodenr */
186 UWORD uid
; /* user id */
187 UWORD gid
; /* group id */
188 ULONG prot
; /* byte 1-3 of protection */
189 ULONG virtualsize
; /* virtual rollover filesize */
190 ULONG rollpointer
; /* rollover fileoffset */
191 UWORD fsizex
; /* extended bits 32-47 of direntry.fsize */
196 ULONG anodenr
; /* anodenr */
197 ULONG fsize
; /* size of file */
198 UWORD creationday
; /* datestamp */
199 UWORD creationminute
;
201 UBYTE filename
[16]; /* filename; filling up to 30 chars */
202 // was previously filename[18]
203 // now last two bytes used for extended file size
204 UWORD fsizex
; /* extended bits 32-47 of fsize */
207 typedef struct deldirblock
214 UWORD uid
; /* user id */
215 UWORD gid
; /* group id */
218 UWORD creationminute
;
220 struct deldirentry entries
[0]; /* 31 entries */
227 anodeblock_t anodeblock
;
228 bitmapblock_t btmapblock
;
229 bootblock_t bootblock
;
231 deldirblock_t deldirblock
;
232 indexblock_t indexblock
;
233 rootblock_t rootblock
;
234 extensionblock_t extensionblock
;
237 typedef union reservedblock reservedblock_t
;
240 #define MAXSMALLBITMAPINDEX 4
241 #define MAXBITMAPINDEX 103
242 #define MAXNUMRESERVED (4096 + 255*1024*8)
244 #define MAXSMALLINDEXNR 98
245 #define MAXDELDIRSEQNR 31
247 /* maximum disksize in blocks, limited by number of bitmapindexblocks */
248 #define MAXSMALLDISK (5*253*253*32)
249 #define MAXDISKSIZE1K (104*253*253*32)
250 #define MAXDISKSIZE2K (104*509*509*32)
251 #define MAXDISKSIZE4K ((ULONG)104*1021*1021*32)
253 #define MAXRESBLOCKSIZE 4096
255 /* disk id 'PFS\1' */
256 #define ID_PFS_DISK (0x50465301L) /* 'PFS\1' */
257 #define ID_PFS2_DISK (0x50465302L) /* 'PFS\2' */
258 #define ID_MUPFS_DISK (0x6d755046L) /* 'muPF' */
259 #define ID_AFS_DISK (0x41465301L) /* 'AFS\1' */
262 #define DBLKID 0x4442
263 #define ABLKID 0x4142
264 #define IBLKID 0x4942
265 #define BMBLKID 0x424D
266 #define BMIBLKID 0x4D49
267 #define DELDIRID 0x4444
268 #define EXTENSIONID 0x4558
269 #define SBLKID 0x5342
270 #define SIZEOF_RESBLOCK (rbl->reserved_blksize)
273 /* predefined anodes */
275 #define ANODE_BADBLOCKS 4
276 #define ANODE_ROOTDIR 5
277 #define ANODE_USERFIRST 6
280 #define MODE_HARDDISK 1
281 #define MODE_SPLITTED_ANODES 2
282 #define MODE_DIR_EXTENSION 4
283 #define MODE_DELDIR 8
284 #define MODE_SIZEFIELD 16
285 #define MODE_EXTENSION 32
286 #define MODE_DATESTAMP 64
287 #define MODE_SUPERINDEX 128
288 #define MODE_SUPERDELDIR 256
289 #define MODE_EXTROVING 512
290 #define MODE_LONGFN 1024
291 #define MODE_LARGEFILE 2048
292 #define MODE_MASK (4096-1)
294 /* seperator used for deldirentries */
295 #define DELENTRY_SEP '@'
297 /* rollover filetype */
298 #define ST_ROLLOVERFILE -16
300 /* get filenote from directory entry */
301 #define FILENOTE(de) ((UBYTE*)(&((de)->startofname) + (de)->nlength))
303 /* get next directory entry */
304 #define NEXTENTRY(de) ((struct direntry*)((UBYTE*)(de) + (de)->next))
306 #if defined(__GNUC__) || defined(__VBCC__)