Import 2.3.6
[davej-history.git] / include / linux / amigaffs.h
bloba6b16e066cb985f423aaec555901ccb84e8195c4
1 #ifndef AMIGAFFS_H
2 #define AMIGAFFS_H
4 #include <asm/byteorder.h>
5 #include <linux/types.h>
7 /* AmigaOS allows file names with up to 30 characters length.
8 * Names longer than that will be silently truncated. If you
9 * want to disallow this, comment out the following #define.
10 * Creating filesystem objects with longer names will then
11 * result in an error (ENAMETOOLONG).
13 /*#define AFFS_NO_TRUNCATE */
15 /* Ugly macros make the code more pretty. */
17 #define GET_END_PTR(st,p,sz) ((st *)((char *)(p)+((sz)-sizeof(st))))
18 #define AFFS_GET_HASHENTRY(data,hashkey) be32_to_cpu(((struct dir_front *)data)->hashtable[hashkey])
19 #define AFFS_BLOCK(data,ino,blk) ((struct file_front *)data)->blocks[AFFS_I2HSIZE(ino)-1-(blk)]
21 #define FILE_END(p,i) GET_END_PTR(struct file_end,p,AFFS_I2BSIZE(i))
22 #define ROOT_END(p,i) GET_END_PTR(struct root_end,p,AFFS_I2BSIZE(i))
23 #define DIR_END(p,i) GET_END_PTR(struct dir_end,p,AFFS_I2BSIZE(i))
24 #define LINK_END(p,i) GET_END_PTR(struct hlink_end,p,AFFS_I2BSIZE(i))
25 #define ROOT_END_S(p,s) GET_END_PTR(struct root_end,p,(s)->s_blocksize)
26 #define DATA_FRONT(bh) ((struct data_front *)(bh)->b_data)
27 #define DIR_FRONT(bh) ((struct dir_front *)(bh)->b_data)
29 /* Only for easier debugging if need be */
30 #define affs_bread bread
31 #define affs_brelse brelse
33 #ifdef __LITTLE_ENDIAN
34 #define BO_EXBITS 0x18UL
35 #elif defined(__BIG_ENDIAN)
36 #define BO_EXBITS 0x00UL
37 #else
38 #error Endianness must be known for affs to work.
39 #endif
41 #define FS_OFS 0x444F5300
42 #define FS_FFS 0x444F5301
43 #define FS_INTLOFS 0x444F5302
44 #define FS_INTLFFS 0x444F5303
45 #define FS_DCOFS 0x444F5304
46 #define FS_DCFFS 0x444F5305
47 #define MUFS_FS 0x6d754653 /* 'muFS' */
48 #define MUFS_OFS 0x6d754600 /* 'muF\0' */
49 #define MUFS_FFS 0x6d754601 /* 'muF\1' */
50 #define MUFS_INTLOFS 0x6d754602 /* 'muF\2' */
51 #define MUFS_INTLFFS 0x6d754603 /* 'muF\3' */
52 #define MUFS_DCOFS 0x6d754604 /* 'muF\4' */
53 #define MUFS_DCFFS 0x6d754605 /* 'muF\5' */
55 #define T_SHORT 2
56 #define T_LIST 16
57 #define T_DATA 8
59 #define ST_LINKFILE -4
60 #define ST_FILE -3
61 #define ST_ROOT 1
62 #define ST_USERDIR 2
63 #define ST_SOFTLINK 3
64 #define ST_LINKDIR 4
66 struct root_front
68 s32 primary_type;
69 s32 spare1[2];
70 s32 hash_size;
71 s32 spare2;
72 u32 checksum;
73 s32 hashtable[0];
76 struct root_end
78 s32 bm_flag;
79 s32 bm_keys[25];
80 s32 bm_extend;
81 struct DateStamp dir_altered;
82 u8 disk_name[40];
83 struct DateStamp disk_altered;
84 struct DateStamp disk_made;
85 s32 spare1[3];
86 s32 secondary_type;
89 struct dir_front
91 s32 primary_type;
92 s32 own_key;
93 s32 spare1[3];
94 u32 checksum;
95 s32 hashtable[0];
98 struct dir_end
100 s32 spare1;
101 s16 owner_uid;
102 s16 owner_gid;
103 u32 protect;
104 s32 spare2;
105 u8 comment[92];
106 struct DateStamp created;
107 u8 dir_name[32];
108 s32 spare3[2];
109 s32 link_chain;
110 s32 spare4[5];
111 s32 hash_chain;
112 s32 parent;
113 s32 spare5;
114 s32 secondary_type;
117 struct file_front
119 s32 primary_type;
120 s32 own_key;
121 s32 block_count;
122 s32 unknown1;
123 s32 first_data;
124 u32 checksum;
125 s32 blocks[0];
128 struct file_end
130 s32 spare1;
131 s16 owner_uid;
132 s16 owner_gid;
133 u32 protect;
134 s32 byte_size;
135 u8 comment[92];
136 struct DateStamp created;
137 u8 file_name[32];
138 s32 spare2;
139 s32 original; /* not really in file_end */
140 s32 link_chain;
141 s32 spare3[5];
142 s32 hash_chain;
143 s32 parent;
144 s32 extension;
145 s32 secondary_type;
148 struct hlink_front
150 s32 primary_type;
151 s32 own_key;
152 s32 spare1[3];
153 u32 checksum;
156 struct hlink_end
158 s32 spare1;
159 s16 owner_uid;
160 s16 owner_gid;
161 u32 protect;
162 u8 comment[92];
163 struct DateStamp created;
164 u8 link_name[32];
165 s32 spare2;
166 s32 original;
167 s32 link_chain;
168 s32 spare3[5];
169 s32 hash_chain;
170 s32 parent;
171 s32 spare4;
172 s32 secondary_type;
175 struct slink_front
177 s32 primary_type;
178 s32 own_key;
179 s32 spare1[3];
180 s32 checksum;
181 u8 symname[288]; /* depends on block size */
184 struct data_front
186 s32 primary_type;
187 s32 header_key;
188 s32 sequence_number;
189 s32 data_size;
190 s32 next_data;
191 s32 checksum;
192 u8 data[488]; /* depends on block size */
195 /* Permission bits */
197 #define FIBF_OTR_READ 0x8000
198 #define FIBF_OTR_WRITE 0x4000
199 #define FIBF_OTR_EXECUTE 0x2000
200 #define FIBF_OTR_DELETE 0x1000
201 #define FIBF_GRP_READ 0x0800
202 #define FIBF_GRP_WRITE 0x0400
203 #define FIBF_GRP_EXECUTE 0x0200
204 #define FIBF_GRP_DELETE 0x0100
206 #define FIBF_SCRIPT 0x0040
207 #define FIBF_PURE 0x0020 /* no use under linux */
208 #define FIBF_ARCHIVE 0x0010 /* never set, always cleared on write */
209 #define FIBF_READ 0x0008 /* 0 means allowed */
210 #define FIBF_WRITE 0x0004 /* 0 means allowed */
211 #define FIBF_EXECUTE 0x0002 /* 0 means allowed, ignored under linux */
212 #define FIBF_DELETE 0x0001 /* 0 means allowed */
214 #define FIBF_OWNER 0x000F /* Bits pertaining to owner */
216 #define AFFS_UMAYWRITE(prot) (((prot) & (FIBF_WRITE|FIBF_DELETE)) == (FIBF_WRITE|FIBF_DELETE))
217 #define AFFS_UMAYREAD(prot) ((prot) & FIBF_READ)
218 #define AFFS_UMAYEXECUTE(prot) ((prot) & FIBF_EXECUTE)
219 #define AFFS_GMAYWRITE(prot) (((prot)&(FIBF_GRP_WRITE|FIBF_GRP_DELETE))==\
220 (FIBF_GRP_WRITE|FIBF_GRP_DELETE))
221 #define AFFS_GMAYREAD(prot) ((prot) & FIBF_GRP_READ)
222 #define AFFS_GMAYEXECUTE(prot) ((prot) & FIBF_EXECUTE)
223 #define AFFS_OMAYWRITE(prot) (((prot)&(FIBF_OTR_WRITE|FIBF_OTR_DELETE))==\
224 (FIBF_OTR_WRITE|FIBF_OTR_DELETE))
225 #define AFFS_OMAYREAD(prot) ((prot) & FIBF_OTR_READ)
226 #define AFFS_OMAYEXECUTE(prot) ((prot) & FIBF_EXECUTE)
228 #endif