revert 213 commits (to 56092) from the last month. 10 still need work to resolve...
[AROS.git] / rom / filesys / SFS / FS / objects.h
blob8b17af62d5e2b8912836d5282c47a5dac0f08c80
1 #ifndef _OBJECTS_H
2 #define _OBJECTS_H
4 #include <exec/types.h>
5 #include <libraries/iffparse.h>
6 #include <utility/tagitem.h>
7 #include "blockstructure.h"
8 #include "nodes.h"
10 #define OBJECTCONTAINER_ID AROS_LONG2BE(MAKE_ID('O','B','J','C'))
11 #define HASHTABLE_ID AROS_LONG2BE(MAKE_ID('H','T','A','B'))
12 #define SOFTLINK_ID AROS_LONG2BE(MAKE_ID('S','L','N','K'))
14 /* Below is the structure describing an Object. Objects can be files or
15 directories. Multiple Objects can be stored in an ObjectContainer
16 block.
18 owneruid & ownergid: These are not used at the moment. They have
19 been reserved for future use. They must be set to zero for now.
21 objectnode: This field contains a number uniquely identifying this
22 object. This number can be used to find out the ObjectContainer
23 where the Object is stored in. It is used to refer to an Object
24 without having to use BLCK pointers.
26 protection: Contains the Object's protection bits. By default this
27 field is set to 0x0000000F, which means bits R, W, E and D are set
28 (note that this is opposite to what is used by AmigaDOS).
30 data (files only): Contains the BLCK number of the first data block of
31 a file. To find out where the rest of the data is located this BLCK
32 number can be looked up in a special B+-Tree structure (see below).
34 size (files only): Contains the size of a file in bytes.
36 hashtable (directories only): A BLCK pointer. It points to a
37 HashTable block.
39 firstdirblock (directories only): This BLCK pointer points to the
40 first ObjectContainer block which belongs to this directory object.
41 For empty directories this field is zero.
43 datemodified: The date of the last modification of this Object. The
44 date is stored in seconds from 1-1-1978 (enough for storing 136 years)
46 bits: See the defines below. At the moment this field can be checked
47 to see if the object is a file or directory. A bit is reserved for
48 links, but isn't currently used (and may or may not be used depending
49 on how and if links are implemented).
51 name: Directly following the main structure is the name of the object.
52 It is zero terminated.
54 comment: Directly following the name of the object is the comment
55 field. This field is zero terminated as well (even if there is no
56 comment). */
58 struct fsObject {
59 UWORD be_owneruid;
60 UWORD be_ownergid;
61 NODE be_objectnode;
62 ULONG be_protection;
64 union {
65 struct {
66 BLCK be_data;
67 ULONG be_size;
68 } file;
70 struct {
71 BLCK be_hashtable; /* for directories & root, 0 means no hashblock */
72 BLCK be_firstdirblock;
73 } dir;
74 } object;
76 ULONG be_datemodified;
77 UBYTE bits;
79 UBYTE name[0];
80 UBYTE comment[0];
83 #define OTYPE_HIDDEN (1)
84 #define OTYPE_UNDELETABLE (2)
85 #define OTYPE_QUICKDIR (4)
86 #define OTYPE_RINGLIST (8) /* Already partially implemented, but
87 doesn't seem to be very useful. */
88 #define OTYPE_HARDLINK (32)
89 #define OTYPE_LINK (64)
90 #define OTYPE_DIR (128)
92 /* hashtable can be zero as well. If it is zero then the directory
93 does not have a hashblock. This means looking up a file by name
94 will be slower since the system will fall-back to scanning the
95 complete directory. However, file creation speed will be higher
96 (which includes moving a file to this directory, which happens
97 often with the Recycled directory for example). */
99 /* for all types of objects:
100 -------------------------
102 HIDDEN: The Object won't be returned by EXAMINE_NEXT or
103 EXAMINE_ALL.
105 UNDELETABLE: ACTION_DELETE_OBJECT will return an error for Objects
106 protected by this bit.
108 for directories only:
109 ---------------------
111 QUICKDIR: Entries are added at the start of the directory without
112 checking if there is room anywhere else in the dir. */
114 /* SFS supports Soft links. When OTYPE_LINK is set and OTYPE_HARDLINK is
115 clear then the entry is a soft link. The path of the soft link isn't
116 stored with the directory entry, but instead is stored as the file
117 data. */
121 /* The fsObjectContainer structure is used to hold various Objects which
122 have the same parent directory. Objects always start at 2-byte
123 boundaries, which means sometimes a padding byte is inserted between
124 2 fsObject structures. The next & previous fields link all
125 ObjectContainers in a doubly linked list.
127 parent: The node-number of the parent Object. The node number can be
128 used to lookup the BLCK number of the block where the parent Object is
129 located.
131 next: The next ObjectContainer belonging to this directory or zero if
132 it is the last in the chain.
134 previous: The previous ObjectContainer belonging to this directory or
135 zero if it is the first ObjectContainer.
137 object: A variable number of fsObject structures, depending on their
138 sizes and on the size of the block. The next object structure can be
139 found by creating a pointer pointing to the name field of the current
140 object, then skip 2 strings (name & comment) and if the address is odd,
141 adding 1. */
143 struct fsObjectContainer {
144 struct fsBlockHeader bheader;
146 NODE be_parent;
147 BLCK be_next;
148 BLCK be_previous; /* 0 for the first block in the directory chain */
150 struct fsObject object[0];
155 /* fsHashTable is the structure of a HashTable block. It functions much
156 like the HashTable found in FFS, except that it is stored in a seperate
157 block. This block contains a number of hash-chains (about 120 for a
158 512 byte block). Each hash-chain is a chain of Nodes. Each Node
159 contains a BLCK pointer to an Object and the node number of the next
160 entry in the hash-chain.
162 parent: The node-number of the parent object.
164 hashentry: The node-number of the first entry of a specific
165 hash-chain. */
167 struct fsHashTable {
168 struct fsBlockHeader bheader;
170 NODE be_parent;
172 NODE be_hashentry[0];
177 struct fsSoftLink {
178 struct fsBlockHeader bheader;
180 NODE be_parent;
181 BLCK be_next;
182 BLCK be_previous;
184 UBYTE string[0];
189 struct fsObjectNode {
190 struct fsNode node;
191 NODE be_next;
192 UWORD be_hash16;
193 } __attribute__((packed));
197 /* Tags used by createobjecttags: */
199 #define COBASE (TAG_USER)
201 #define CO_OBJECTNODE (COBASE+1) /* The ObjectNode of the object. Defaults to creating a
202 new ObjectNode. If an ObjectNode is passed then its
203 data field will be set to point to the block which
204 contains the new Object. */
206 #define CO_PROTECTION (COBASE+2) /* The protection bits of the object. Defaults to
207 FIBF_READ|FIBF_WRITE|FIBF_EXECUTE|FIBF_DELETE. */
209 #define CO_DATEMODIFIED (COBASE+3) /* The modification data of the object. Defaults to
210 current date. */
212 #define CO_OWNER (COBASE+4) /* The owneruid and ownergid of the object. Default to
213 zero. */
215 #define CO_COMMENT (COBASE+5) /* Comment of the new object (79 chars max). Defaults to
216 no comment. */
218 #define CO_BITS (COBASE+6) /* See bits in fsObject. */
220 #define CO_HASHOBJECT (COBASE+7) /* If not FALSE, then the new Object will be hashed
221 automatically. Defaults to FALSE. */
223 #define CO_UPDATEPARENT (COBASE+8) /* If not FALSE, then the new Object's Parent's archive
224 bit will be cleared and its modification date will be
225 updated. Defaults to FALSE. */
227 #define CO_ALLOWDUPLICATES (COBASE+9) /* If not FALSE, then createobjecttags() won't check to
228 see if an object already exists. Defaults to FALSE. */
230 /* File specific tags: */
232 #define CO_SIZE (COBASE+20) /* The size of the file. Defaults to zero. Ignored if
233 CO_BITS indicates its a directory. */
235 #define CO_DATA (COBASE+21) /* The first block of the file. Defaults to zero.
236 Ignored if CO_BITS indicates its a directory. */
238 /* Directory specific tags: */
240 #define CO_FIRSTDIRBLOCK (COBASE+30) /* The first ObjectContainer of the directory. Defaults
241 to zero. Ignored if CO_BITS indicates its a file. */
243 #define CO_HASHBLOCK (COBASE+31) /* The Hashblock of the directory. Defaults to creating
244 a new Hashblock. Ignored if CO_BITS indicates its a
245 file. */
247 /* Softlink specific tags: */
249 #define CO_SOFTLINK (COBASE+40) /* The Softlink string. No default! Ignored if CO_BITS
250 indicates its not a softlink. */
252 #endif // _OBJECTS_H