4 #include <linux/types.h>
5 #include <linux/buffer_head.h>
6 #include <linux/string.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[AFFS_SB(sb)->s_hashsize-1-(blk)])
24 affs_set_blocksize(struct super_block
*sb
, int size
)
26 sb_set_blocksize(sb
, size
);
28 static inline struct buffer_head
*
29 affs_bread(struct super_block
*sb
, int block
)
31 pr_debug("affs_bread: %d\n", block
);
32 if (block
>= AFFS_SB(sb
)->s_reserved
&& block
< AFFS_SB(sb
)->s_partition_size
)
33 return sb_bread(sb
, block
);
36 static inline struct buffer_head
*
37 affs_getblk(struct super_block
*sb
, int block
)
39 pr_debug("affs_getblk: %d\n", block
);
40 if (block
>= AFFS_SB(sb
)->s_reserved
&& block
< AFFS_SB(sb
)->s_partition_size
)
41 return sb_getblk(sb
, block
);
44 static inline struct buffer_head
*
45 affs_getzeroblk(struct super_block
*sb
, int block
)
47 struct buffer_head
*bh
;
48 pr_debug("affs_getzeroblk: %d\n", block
);
49 if (block
>= AFFS_SB(sb
)->s_reserved
&& block
< AFFS_SB(sb
)->s_partition_size
) {
50 bh
= sb_getblk(sb
, block
);
52 memset(bh
->b_data
, 0 , sb
->s_blocksize
);
53 set_buffer_uptodate(bh
);
59 static inline struct buffer_head
*
60 affs_getemptyblk(struct super_block
*sb
, int block
)
62 struct buffer_head
*bh
;
63 pr_debug("affs_getemptyblk: %d\n", block
);
64 if (block
>= AFFS_SB(sb
)->s_reserved
&& block
< AFFS_SB(sb
)->s_partition_size
) {
65 bh
= sb_getblk(sb
, block
);
67 set_buffer_uptodate(bh
);
73 affs_brelse(struct buffer_head
*bh
)
76 pr_debug("affs_brelse: %lld\n", (long long) bh
->b_blocknr
);
81 affs_adjust_checksum(struct buffer_head
*bh
, u32 val
)
83 u32 tmp
= be32_to_cpu(((__be32
*)bh
->b_data
)[5]);
84 ((__be32
*)bh
->b_data
)[5] = cpu_to_be32(tmp
- val
);
87 affs_adjust_bitmapchecksum(struct buffer_head
*bh
, u32 val
)
89 u32 tmp
= be32_to_cpu(((__be32
*)bh
->b_data
)[0]);
90 ((__be32
*)bh
->b_data
)[0] = cpu_to_be32(tmp
- val
);
94 affs_lock_link(struct inode
*inode
)
96 down(&AFFS_I(inode
)->i_link_lock
);
99 affs_unlock_link(struct inode
*inode
)
101 up(&AFFS_I(inode
)->i_link_lock
);
104 affs_lock_dir(struct inode
*inode
)
106 down(&AFFS_I(inode
)->i_hash_lock
);
109 affs_unlock_dir(struct inode
*inode
)
111 up(&AFFS_I(inode
)->i_hash_lock
);
114 affs_lock_ext(struct inode
*inode
)
116 down(&AFFS_I(inode
)->i_ext_lock
);
119 affs_unlock_ext(struct inode
*inode
)
121 up(&AFFS_I(inode
)->i_ext_lock
);
124 #ifdef __LITTLE_ENDIAN
125 #define BO_EXBITS 0x18UL
126 #elif defined(__BIG_ENDIAN)
127 #define BO_EXBITS 0x00UL
129 #error Endianness must be known for affs to work.
132 #define FS_OFS 0x444F5300
133 #define FS_FFS 0x444F5301
134 #define FS_INTLOFS 0x444F5302
135 #define FS_INTLFFS 0x444F5303
136 #define FS_DCOFS 0x444F5304
137 #define FS_DCFFS 0x444F5305
138 #define MUFS_FS 0x6d754653 /* 'muFS' */
139 #define MUFS_OFS 0x6d754600 /* 'muF\0' */
140 #define MUFS_FFS 0x6d754601 /* 'muF\1' */
141 #define MUFS_INTLOFS 0x6d754602 /* 'muF\2' */
142 #define MUFS_INTLFFS 0x6d754603 /* 'muF\3' */
143 #define MUFS_DCOFS 0x6d754604 /* 'muF\4' */
144 #define MUFS_DCFFS 0x6d754605 /* 'muF\5' */
150 #define ST_LINKFILE -4
154 #define ST_SOFTLINK 3
157 #define AFFS_ROOT_BMAPS 25
159 #define AFFS_HEAD(bh) ((struct affs_head *)(bh)->b_data)
160 #define AFFS_TAIL(sb, bh) ((struct affs_tail *)((bh)->b_data+(sb)->s_blocksize-sizeof(struct affs_tail)))
161 #define AFFS_ROOT_HEAD(bh) ((struct affs_root_head *)(bh)->b_data)
162 #define AFFS_ROOT_TAIL(sb, bh) ((struct affs_root_tail *)((bh)->b_data+(sb)->s_blocksize-sizeof(struct affs_root_tail)))
163 #define AFFS_DATA_HEAD(bh) ((struct affs_data_head *)(bh)->b_data)
164 #define AFFS_DATA(bh) (((struct affs_data_head *)(bh)->b_data)->data)
172 struct affs_short_date
{
178 struct affs_root_head
{
188 struct affs_root_tail
{
190 __be32 bm_blk
[AFFS_ROOT_BMAPS
];
192 struct affs_date root_change
;
196 struct affs_date disk_change
;
197 struct affs_date disk_create
;
221 struct affs_date change
;
239 u8 symname
[1]; /* depends on block size */
242 struct affs_data_head
250 u8 data
[1]; /* depends on block size */
253 /* Permission bits */
255 #define FIBF_OTR_READ 0x8000
256 #define FIBF_OTR_WRITE 0x4000
257 #define FIBF_OTR_EXECUTE 0x2000
258 #define FIBF_OTR_DELETE 0x1000
259 #define FIBF_GRP_READ 0x0800
260 #define FIBF_GRP_WRITE 0x0400
261 #define FIBF_GRP_EXECUTE 0x0200
262 #define FIBF_GRP_DELETE 0x0100
264 #define FIBF_HIDDEN 0x0080
265 #define FIBF_SCRIPT 0x0040
266 #define FIBF_PURE 0x0020 /* no use under linux */
267 #define FIBF_ARCHIVED 0x0010 /* never set, always cleared on write */
268 #define FIBF_NOREAD 0x0008 /* 0 means allowed */
269 #define FIBF_NOWRITE 0x0004 /* 0 means allowed */
270 #define FIBF_NOEXECUTE 0x0002 /* 0 means allowed, ignored under linux */
271 #define FIBF_NODELETE 0x0001 /* 0 means allowed */
273 #define FIBF_OWNER 0x000F /* Bits pertaining to owner */
274 #define FIBF_MASK 0xEE0E /* Bits modified by Linux */