2 #include <linux/adfs_fs.h>
4 /* Internal data structures for ADFS */
6 #define ADFS_FREE_FRAG 0
7 #define ADFS_BAD_FRAG 1
8 #define ADFS_ROOT_FRAG 2
10 #define ADFS_NDA_OWNER_READ (1 << 0)
11 #define ADFS_NDA_OWNER_WRITE (1 << 1)
12 #define ADFS_NDA_LOCKED (1 << 2)
13 #define ADFS_NDA_DIRECTORY (1 << 3)
14 #define ADFS_NDA_EXECUTE (1 << 4)
15 #define ADFS_NDA_PUBLIC_READ (1 << 5)
16 #define ADFS_NDA_PUBLIC_WRITE (1 << 6)
23 * adfs file system inode data in memory
25 struct adfs_inode_info
{
27 unsigned long parent_id
; /* object id of parent */
28 __u32 loadaddr
; /* RISC OS load address */
29 __u32 execaddr
; /* RISC OS exec address */
30 unsigned int filetype
; /* RISC OS file type */
31 unsigned int attr
; /* RISC OS permissions */
32 unsigned int stamped
:1; /* RISC OS file has date/time */
33 struct inode vfs_inode
;
37 * Forward-declare this
43 * ADFS file system superblock data in memory
47 struct adfs_discmap
*s_map
; /* bh list containing map */
48 struct adfs_dir_ops
*s_dir
; /* directory operations */
50 struct rcu_head rcu
; /* used only at shutdown time */
52 kuid_t s_uid
; /* owner uid */
53 kgid_t s_gid
; /* owner gid */
54 umode_t s_owner_mask
; /* ADFS owner perm -> unix perm */
55 umode_t s_other_mask
; /* ADFS other perm -> unix perm */
56 int s_ftsuffix
; /* ,xyz hex filetype suffix option */
58 __u32 s_ids_per_zone
; /* max. no ids in one zone */
59 __u32 s_idlen
; /* length of ID in map */
60 __u32 s_map_size
; /* sector size of a map */
61 unsigned long s_size
; /* total size (in blocks) of this fs */
62 signed int s_map2blk
; /* shift left by this for map->sector */
63 unsigned int s_log2sharesize
;/* log2 share size */
64 __le32 s_version
; /* disc format version */
65 unsigned int s_namelen
; /* maximum number of characters in name */
68 static inline struct adfs_sb_info
*ADFS_SB(struct super_block
*sb
)
73 static inline struct adfs_inode_info
*ADFS_I(struct inode
*inode
)
75 return container_of(inode
, struct adfs_inode_info
, vfs_inode
);
82 struct super_block
*sb
;
85 struct buffer_head
*bh
[4];
87 /* big directories need allocated buffers */
88 struct buffer_head
**bh_fplus
;
91 unsigned int parent_id
;
93 struct adfs_dirheader dirhead
;
94 union adfs_dirtail dirtail
;
98 * This is the overall maximum name length
100 #define ADFS_MAX_NAME_LEN (256 + 4) /* +4 for ,xyz hex filetype suffix */
102 __u32 parent_id
; /* parent object id */
103 __u32 file_id
; /* object id */
104 __u32 loadaddr
; /* load address */
105 __u32 execaddr
; /* execution address */
106 __u32 size
; /* size */
107 __u8 attr
; /* RISC OS attributes */
108 unsigned int name_len
; /* name length */
109 char name
[ADFS_MAX_NAME_LEN
];/* file name */
111 /* RISC OS file type (12-bit: derived from loadaddr) */
115 /* RISC OS 12-bit filetype converts to ,xyz hex filename suffix */
116 static inline int append_filetype_suffix(char *buf
, __u16 filetype
)
118 if (filetype
== 0xffff) /* no explicit 12-bit file type was set */
122 *buf
++ = hex_asc_lo(filetype
>> 8);
123 *buf
++ = hex_asc_lo(filetype
>> 4);
124 *buf
++ = hex_asc_lo(filetype
>> 0);
128 struct adfs_dir_ops
{
129 int (*read
)(struct super_block
*sb
, unsigned int id
, unsigned int sz
, struct adfs_dir
*dir
);
130 int (*setpos
)(struct adfs_dir
*dir
, unsigned int fpos
);
131 int (*getnext
)(struct adfs_dir
*dir
, struct object_info
*obj
);
132 int (*update
)(struct adfs_dir
*dir
, struct object_info
*obj
);
133 int (*create
)(struct adfs_dir
*dir
, struct object_info
*obj
);
134 int (*remove
)(struct adfs_dir
*dir
, struct object_info
*obj
);
135 int (*sync
)(struct adfs_dir
*dir
);
136 void (*free
)(struct adfs_dir
*dir
);
139 struct adfs_discmap
{
140 struct buffer_head
*dm_bh
;
142 unsigned int dm_startbit
;
143 unsigned int dm_endbit
;
147 struct inode
*adfs_iget(struct super_block
*sb
, struct object_info
*obj
);
148 int adfs_write_inode(struct inode
*inode
, struct writeback_control
*wbc
);
149 int adfs_notify_change(struct dentry
*dentry
, struct iattr
*attr
);
152 extern int adfs_map_lookup(struct super_block
*sb
, unsigned int frag_id
, unsigned int offset
);
153 extern unsigned int adfs_map_free(struct super_block
*sb
);
156 void __adfs_error(struct super_block
*sb
, const char *function
,
157 const char *fmt
, ...);
158 #define adfs_error(sb, fmt...) __adfs_error(sb, __func__, fmt)
163 * Inodes and file operations
167 extern const struct inode_operations adfs_dir_inode_operations
;
168 extern const struct file_operations adfs_dir_operations
;
169 extern const struct dentry_operations adfs_dentry_operations
;
170 extern struct adfs_dir_ops adfs_f_dir_ops
;
171 extern struct adfs_dir_ops adfs_fplus_dir_ops
;
173 extern int adfs_dir_update(struct super_block
*sb
, struct object_info
*obj
,
177 extern const struct inode_operations adfs_file_inode_operations
;
178 extern const struct file_operations adfs_file_operations
;
180 static inline __u32
signed_asl(__u32 val
, signed int shift
)
190 * Calculate the address of a block in an object given the block offset
191 * and the object identity.
193 * The root directory ID should always be looked up in the map [3.4]
196 __adfs_block_map(struct super_block
*sb
, unsigned int object_id
,
199 if (object_id
& 255) {
202 off
= (object_id
& 255) - 1;
203 block
+= off
<< ADFS_SB(sb
)->s_log2sharesize
;
206 return adfs_map_lookup(sb
, object_id
>> 8, block
);