4 #include <linux/types.h>
5 #include <linux/locks.h>
7 #include <asm/byteorder.h>
9 /* AmigaOS allows file names with up to 30 characters length.
10 * Names longer than that will be silently truncated. If you
11 * want to disallow this, comment out the following #define.
12 * Creating filesystem objects with longer names will then
13 * result in an error (ENAMETOOLONG).
15 /*#define AFFS_NO_TRUNCATE */
17 /* Ugly macros make the code more pretty. */
19 #define GET_END_PTR(st,p,sz) ((st *)((char *)(p)+((sz)-sizeof(st))))
20 #define AFFS_GET_HASHENTRY(data,hashkey) be32_to_cpu(((struct dir_front *)data)->hashtable[hashkey])
21 #define AFFS_BLOCK(sb, bh, blk) (AFFS_HEAD(bh)->table[(sb)->u.affs_sb.s_hashsize-1-(blk)])
24 affs_set_blocksize(struct super_block *sb, int size)
26 set_blocksize(sb->s_dev, size);
27 sb->s_blocksize = size;
29 static inline struct buffer_head *
30 affs_bread(struct super_block *sb, int block)
32 pr_debug(KERN_DEBUG "affs_bread: %d\n", block);
33 if (block >= AFFS_SB->s_reserved && block < AFFS_SB->s_partition_size)
34 return sb_bread(sb, block);
37 static inline struct buffer_head *
38 affs_getblk(struct super_block *sb, int block)
40 pr_debug(KERN_DEBUG "affs_getblk: %d\n", block);
41 if (block >= AFFS_SB->s_reserved && block < AFFS_SB->s_partition_size)
42 return sb_getblk(sb, block);
45 static inline struct buffer_head *
46 affs_getzeroblk(struct super_block *sb, int block)
48 struct buffer_head *bh;
49 pr_debug(KERN_DEBUG "affs_getzeroblk: %d\n", block);
50 if (block >= AFFS_SB->s_reserved && block < AFFS_SB->s_partition_size) {
51 bh = sb_getblk(sb, block);
53 memset(bh->b_data, 0 , sb->s_blocksize);
54 mark_buffer_uptodate(bh, 1);
60 static inline struct buffer_head *
61 affs_getemptyblk(struct super_block *sb, int block)
63 struct buffer_head *bh;
64 pr_debug(KERN_DEBUG "affs_getemptyblk: %d\n", block);
65 if (block >= AFFS_SB->s_reserved && block < AFFS_SB->s_partition_size) {
66 bh = sb_getblk(sb, block);
68 mark_buffer_uptodate(bh, 1);
74 affs_brelse(struct buffer_head *bh)
77 pr_debug(KERN_DEBUG "affs_brelse: %ld\n", bh->b_blocknr);
82 affs_adjust_checksum(struct buffer_head *bh, u32 val)
84 u32 tmp = be32_to_cpu(((u32 *)bh->b_data)[5]);
85 ((u32 *)bh->b_data)[5] = cpu_to_be32(tmp - val);
88 affs_adjust_bitmapchecksum(struct buffer_head *bh, u32 val)
90 u32 tmp = be32_to_cpu(((u32 *)bh->b_data)[0]);
91 ((u32 *)bh->b_data)[0] = cpu_to_be32(tmp - val);
95 affs_lock_link(struct inode *inode)
97 down(&AFFS_INODE->i_link_lock);
100 affs_unlock_link(struct inode *inode)
102 up(&AFFS_INODE->i_link_lock);
105 affs_lock_dir(struct inode *inode)
107 down(&AFFS_INODE->i_hash_lock);
110 affs_unlock_dir(struct inode *inode)
112 up(&AFFS_INODE->i_hash_lock);
115 affs_lock_ext(struct inode *inode)
117 down(&AFFS_INODE->i_ext_lock);
120 affs_unlock_ext(struct inode *inode)
122 up(&AFFS_INODE->i_ext_lock);
125 #ifdef __LITTLE_ENDIAN
126 #define BO_EXBITS 0x18UL
127 #elif defined(__BIG_ENDIAN)
128 #define BO_EXBITS 0x00UL
130 #error Endianness must be known for affs to work.
133 #define FS_OFS 0x444F5300
134 #define FS_FFS 0x444F5301
135 #define FS_INTLOFS 0x444F5302
136 #define FS_INTLFFS 0x444F5303
137 #define FS_DCOFS 0x444F5304
138 #define FS_DCFFS 0x444F5305
139 #define MUFS_FS 0x6d754653 /* 'muFS' */
140 #define MUFS_OFS 0x6d754600 /* 'muF\0' */
141 #define MUFS_FFS 0x6d754601 /* 'muF\1' */
142 #define MUFS_INTLOFS 0x6d754602 /* 'muF\2' */
143 #define MUFS_INTLFFS 0x6d754603 /* 'muF\3' */
144 #define MUFS_DCOFS 0x6d754604 /* 'muF\4' */
145 #define MUFS_DCFFS 0x6d754605 /* 'muF\5' */
151 #define ST_LINKFILE -4
155 #define ST_SOFTLINK 3
158 #define AFFS_ROOT_BMAPS 25
160 #define AFFS_HEAD(bh) ((struct affs_head *)(bh)->b_data)
161 #define AFFS_TAIL(sb, bh) ((struct affs_tail *)((bh)->b_data+(sb)->s_blocksize-sizeof(struct affs_tail)))
162 #define AFFS_ROOT_HEAD(bh) ((struct affs_root_head *)(bh)->b_data)
163 #define AFFS_ROOT_TAIL(sb, bh) ((struct affs_root_tail *)((bh)->b_data+(sb)->s_blocksize-sizeof(struct affs_root_tail)))
164 #define AFFS_DATA_HEAD(bh) ((struct affs_data_head *)(bh)->b_data)
165 #define AFFS_DATA(bh) (((struct affs_data_head *)(bh)->b_data)->data)
173 struct affs_short_date {
179 struct affs_root_head {
189 struct affs_root_tail {
191 u32 bm_blk[AFFS_ROOT_BMAPS];
193 struct affs_date root_change;
197 struct affs_date disk_change;
198 struct affs_date disk_create;
222 struct affs_date change;
240 u8 symname[1]; /* depends on block size */
243 struct affs_data_head
251 u8 data[1]; /* depends on block size */
254 /* Permission bits */
256 #define FIBF_OTR_READ 0x8000
257 #define FIBF_OTR_WRITE 0x4000
258 #define FIBF_OTR_EXECUTE 0x2000
259 #define FIBF_OTR_DELETE 0x1000
260 #define FIBF_GRP_READ 0x0800
261 #define FIBF_GRP_WRITE 0x0400
262 #define FIBF_GRP_EXECUTE 0x0200
263 #define FIBF_GRP_DELETE 0x0100
265 #define FIBF_HIDDEN 0x0080
266 #define FIBF_SCRIPT 0x0040
267 #define FIBF_PURE 0x0020 /* no use under linux */
268 #define FIBF_ARCHIVED 0x0010 /* never set, always cleared on write */
269 #define FIBF_NOREAD 0x0008 /* 0 means allowed */
270 #define FIBF_NOWRITE 0x0004 /* 0 means allowed */
271 #define FIBF_NOEXECUTE 0x0002 /* 0 means allowed, ignored under linux */
272 #define FIBF_NODELETE 0x0001 /* 0 means allowed */
274 #define FIBF_OWNER 0x000F /* Bits pertaining to owner */
275 #define FIBF_MASK 0xEE0E /* Bits modified by Linux */